Mercurial > libavcodec.hg
comparison ac3enc.c @ 1408:4d67eb341a0c libavcodec
AC3 encoding patch ba (Ross Martin <ffmpeg at ross dot interwrx dot com>)
author | michaelni |
---|---|
date | Wed, 20 Aug 2003 07:57:00 +0000 |
parents | 1e39f273ecd6 |
children | 79dddc5cd990 |
comparison
equal
deleted
inserted
replaced
1407:69f4f4fb8a50 | 1408:4d67eb341a0c |
---|---|
976 uint8_t bap[AC3_MAX_CHANNELS][N/2], | 976 uint8_t bap[AC3_MAX_CHANNELS][N/2], |
977 int32_t mdct_coefs[AC3_MAX_CHANNELS][N/2], | 977 int32_t mdct_coefs[AC3_MAX_CHANNELS][N/2], |
978 int8_t global_exp[AC3_MAX_CHANNELS], | 978 int8_t global_exp[AC3_MAX_CHANNELS], |
979 int block_num) | 979 int block_num) |
980 { | 980 { |
981 int ch, nb_groups, group_size, i, baie; | 981 int ch, nb_groups, group_size, i, baie, rbnd; |
982 uint8_t *p; | 982 uint8_t *p; |
983 uint16_t qmant[AC3_MAX_CHANNELS][N/2]; | 983 uint16_t qmant[AC3_MAX_CHANNELS][N/2]; |
984 int exp0, exp1; | 984 int exp0, exp1; |
985 int mant1_cnt, mant2_cnt, mant4_cnt; | 985 int mant1_cnt, mant2_cnt, mant4_cnt; |
986 uint16_t *qmant1_ptr, *qmant2_ptr, *qmant4_ptr; | 986 uint16_t *qmant1_ptr, *qmant2_ptr, *qmant4_ptr; |
998 put_bits(&s->pb, 1, 0); /* no coupling strategy */ | 998 put_bits(&s->pb, 1, 0); /* no coupling strategy */ |
999 } else { | 999 } else { |
1000 put_bits(&s->pb, 1, 0); /* no new coupling strategy */ | 1000 put_bits(&s->pb, 1, 0); /* no new coupling strategy */ |
1001 } | 1001 } |
1002 | 1002 |
1003 if (s->acmod == 2) { | 1003 if (s->acmod == 2) |
1004 put_bits(&s->pb, 1, 0); /* no matrixing (but should be used in the future) */ | 1004 { |
1005 } | 1005 if(block_num==0) |
1006 { | |
1007 /* first block must define rematrixing (rematstr) */ | |
1008 put_bits(&s->pb, 1, 1); | |
1009 | |
1010 /* dummy rematrixing rematflg(1:4)=0 */ | |
1011 for (rbnd=0;rbnd<4;rbnd++) | |
1012 put_bits(&s->pb, 1, 0); | |
1013 } | |
1014 else | |
1015 { | |
1016 /* no matrixing (but should be used in the future) */ | |
1017 put_bits(&s->pb, 1, 0); | |
1018 } | |
1019 } | |
1006 | 1020 |
1007 #if defined(DEBUG) | 1021 #if defined(DEBUG) |
1008 { | 1022 { |
1009 static int count = 0; | 1023 static int count = 0; |
1010 printf("Block #%d (%d)\n", block_num, count++); | 1024 printf("Block #%d (%d)\n", block_num, count++); |
1011 } | 1025 } |
1012 #endif | 1026 #endif |
1013 /* exponent strategy */ | 1027 /* exponent strategy */ |
1014 for(ch=0;ch<s->nb_channels;ch++) { | 1028 for(ch=0;ch<s->nb_channels;ch++) { |
1015 put_bits(&s->pb, 2, exp_strategy[ch]); | 1029 put_bits(&s->pb, 2, exp_strategy[ch]); |
1327 flush_put_bits(&s->pb); | 1341 flush_put_bits(&s->pb); |
1328 /* add zero bytes to reach the frame size */ | 1342 /* add zero bytes to reach the frame size */ |
1329 frame = s->pb.buf; | 1343 frame = s->pb.buf; |
1330 n = 2 * s->frame_size - (pbBufPtr(&s->pb) - frame) - 2; | 1344 n = 2 * s->frame_size - (pbBufPtr(&s->pb) - frame) - 2; |
1331 assert(n >= 0); | 1345 assert(n >= 0); |
1332 memset(pbBufPtr(&s->pb), 0, n); | 1346 if(n>0) |
1347 memset(pbBufPtr(&s->pb), 0, n); | |
1333 | 1348 |
1334 /* Now we must compute both crcs : this is not so easy for crc1 | 1349 /* Now we must compute both crcs : this is not so easy for crc1 |
1335 because it is at the beginning of the data... */ | 1350 because it is at the beginning of the data... */ |
1336 frame_size_58 = (frame_size >> 1) + (frame_size >> 3); | 1351 frame_size_58 = (frame_size >> 1) + (frame_size >> 3); |
1337 crc1 = ac3_crc(frame + 4, (2 * frame_size_58) - 4, 0); | 1352 crc1 = ac3_crc(frame + 4, (2 * frame_size_58) - 4, 0); |