comparison ac3enc.c @ 6108:75804d49f33b libavcodec

improve CRC API - don't export any global var - provide either generated or hardcoded tables
author aurel
date Fri, 04 Jan 2008 23:09:58 +0000
parents 77d27412c35d
children bf4d7ce32af5
comparison
equal deleted inserted replaced
6107:99e470e62bad 6108:75804d49f33b
1139 memset(pbBufPtr(&s->pb), 0, n); 1139 memset(pbBufPtr(&s->pb), 0, n);
1140 1140
1141 /* Now we must compute both crcs : this is not so easy for crc1 1141 /* Now we must compute both crcs : this is not so easy for crc1
1142 because it is at the beginning of the data... */ 1142 because it is at the beginning of the data... */
1143 frame_size_58 = (frame_size >> 1) + (frame_size >> 3); 1143 frame_size_58 = (frame_size >> 1) + (frame_size >> 3);
1144 crc1 = bswap_16(av_crc(av_crc8005, 0, frame + 4, 2 * frame_size_58 - 4)); 1144 crc1 = bswap_16(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0,
1145 frame + 4, 2 * frame_size_58 - 4));
1145 /* XXX: could precompute crc_inv */ 1146 /* XXX: could precompute crc_inv */
1146 crc_inv = pow_poly((CRC16_POLY >> 1), (16 * frame_size_58) - 16, CRC16_POLY); 1147 crc_inv = pow_poly((CRC16_POLY >> 1), (16 * frame_size_58) - 16, CRC16_POLY);
1147 crc1 = mul_poly(crc_inv, crc1, CRC16_POLY); 1148 crc1 = mul_poly(crc_inv, crc1, CRC16_POLY);
1148 AV_WB16(frame+2,crc1); 1149 AV_WB16(frame+2,crc1);
1149 1150
1150 crc2 = bswap_16(av_crc(av_crc8005, 0, frame + 2 * frame_size_58, (frame_size - frame_size_58) * 2 - 2)); 1151 crc2 = bswap_16(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0,
1152 frame + 2 * frame_size_58,
1153 (frame_size - frame_size_58) * 2 - 2));
1151 AV_WB16(frame+2*frame_size-2,crc2); 1154 AV_WB16(frame+2*frame_size-2,crc2);
1152 1155
1153 // printf("n=%d frame_size=%d\n", n, frame_size); 1156 // printf("n=%d frame_size=%d\n", n, frame_size);
1154 return frame_size * 2; 1157 return frame_size * 2;
1155 } 1158 }