comparison libmpdemux/demux_ts.c @ 17492:3f420548c0ca

export custom mp_a52_framesize(), needed to parse ac3 frames when liba52 is not present; will be moved in a more appropriate place sometimes in the future
author nicodvb
date Fri, 27 Jan 2006 23:07:16 +0000
parents 401b440a6d76
children 67c30d47ffd4
comparison
equal deleted inserted replaced
17491:1de8f7a7ad32 17492:3f420548c0ca
462 off_t probe; 462 off_t probe;
463 } tsdemux_init_t; 463 } tsdemux_init_t;
464 464
465 //stripped down version of a52_syncinfo() from liba52 465 //stripped down version of a52_syncinfo() from liba52
466 //copyright belongs to Michel Lespinasse <walken@zoy.org> and Aaron Holtzman <aholtzma@ess.engr.uvic.ca> 466 //copyright belongs to Michel Lespinasse <walken@zoy.org> and Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
467 static int a52_framesize(uint8_t * buf) 467 int mp_a52_framesize(uint8_t * buf, int *srate)
468 { 468 {
469 int rate[] = { 32, 40, 48, 56, 64, 80, 96, 112, 469 int rate[] = { 32, 40, 48, 56, 64, 80, 96, 112,
470 128, 160, 192, 224, 256, 320, 384, 448, 470 128, 160, 192, 224, 256, 320, 384, 448,
471 512, 576, 640 471 512, 576, 640
472 }; 472 };
488 bitrate = rate[frmsizecod >> 1]; 488 bitrate = rate[frmsizecod >> 1];
489 489
490 switch(buf[4] & 0xc0) 490 switch(buf[4] & 0xc0)
491 { 491 {
492 case 0: /* 48 KHz */ 492 case 0: /* 48 KHz */
493 *srate = 48000 >> half;
493 return 4 * bitrate; 494 return 4 * bitrate;
494 case 0x40: /* 44.1 KHz */ 495 case 0x40: /* 44.1 KHz */
496 *srate = 44100 >> half;
495 return 2 * (320 * bitrate / 147 + (frmsizecod & 1)); 497 return 2 * (320 * bitrate / 147 + (frmsizecod & 1));
496 case 0x80: /* 32 KHz */ 498 case 0x80: /* 32 KHz */
499 *srate = 32000 >> half;
497 return 6 * bitrate; 500 return 6 * bitrate;
498 } 501 }
499 502
500 return 0; 503 return 0;
501 } 504 }
502 505
503 //second stage: returns the count of A52 syncwords found 506 //second stage: returns the count of A52 syncwords found
504 static int a52_check(char *buf, int len) 507 static int a52_check(char *buf, int len)
505 { 508 {
506 int cnt, frame_length, ok; 509 int cnt, frame_length, ok, srate;
507 510
508 cnt = ok = 0; 511 cnt = ok = 0;
509 if(len < 8) 512 if(len < 8)
510 return 0; 513 return 0;
511 514
512 while(cnt < len - 7) 515 while(cnt < len - 7)
513 { 516 {
514 if(buf[cnt] == 0x0B && buf[cnt+1] == 0x77) 517 if(buf[cnt] == 0x0B && buf[cnt+1] == 0x77)
515 { 518 {
516 frame_length = a52_framesize(&buf[cnt]); 519 frame_length = mp_a52_framesize(&buf[cnt], &srate);
517 if(frame_length>=7 && frame_length<=3840) 520 if(frame_length>=7 && frame_length<=3840)
518 { 521 {
519 cnt += frame_length; 522 cnt += frame_length;
520 ok++; 523 ok++;
521 } 524 }