comparison ac3dec.c @ 6950:ec4e01cb0089 libavcodec

move header error logging to after CRC check
author jbr
date Sat, 31 May 2008 15:30:55 +0000
parents 86e3dce7f723
children 4c1b8b50313c
comparison
equal deleted inserted replaced
6949:8e907d8094f5 6950:ec4e01cb0089
1142 } else { 1142 } else {
1143 init_get_bits(&s->gbc, buf, buf_size * 8); 1143 init_get_bits(&s->gbc, buf, buf_size * 8);
1144 } 1144 }
1145 1145
1146 /* parse the syncinfo */ 1146 /* parse the syncinfo */
1147 *data_size = 0;
1147 err = ac3_parse_header(s); 1148 err = ac3_parse_header(s);
1148 if(err) { 1149
1150 /* check that reported frame size fits in input buffer */
1151 if(s->frame_size > buf_size) {
1152 av_log(avctx, AV_LOG_ERROR, "incomplete frame\n");
1153 err = AC3_PARSE_ERROR_FRAME_SIZE;
1154 }
1155
1156 /* check for crc mismatch */
1157 if(err != AC3_PARSE_ERROR_FRAME_SIZE && avctx->error_resilience >= FF_ER_CAREFUL) {
1158 if(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &buf[2], s->frame_size-2)) {
1159 av_log(avctx, AV_LOG_ERROR, "frame CRC mismatch\n");
1160 err = 1;
1161 }
1162 }
1163
1164 /* parse the syncinfo */
1165 if(err && err != 1) {
1149 switch(err) { 1166 switch(err) {
1150 case AC3_PARSE_ERROR_SYNC: 1167 case AC3_PARSE_ERROR_SYNC:
1151 av_log(avctx, AV_LOG_ERROR, "frame sync error : cannot use error concealment\n"); 1168 av_log(avctx, AV_LOG_ERROR, "frame sync error\n");
1152 return -1; 1169 break;
1153 case AC3_PARSE_ERROR_BSID: 1170 case AC3_PARSE_ERROR_BSID:
1154 av_log(avctx, AV_LOG_ERROR, "invalid bitstream id\n"); 1171 av_log(avctx, AV_LOG_ERROR, "invalid bitstream id\n");
1155 break; 1172 break;
1156 case AC3_PARSE_ERROR_SAMPLE_RATE: 1173 case AC3_PARSE_ERROR_SAMPLE_RATE:
1157 av_log(avctx, AV_LOG_ERROR, "invalid sample rate\n"); 1174 av_log(avctx, AV_LOG_ERROR, "invalid sample rate\n");
1166 av_log(avctx, AV_LOG_ERROR, "invalid header\n"); 1183 av_log(avctx, AV_LOG_ERROR, "invalid header\n");
1167 break; 1184 break;
1168 } 1185 }
1169 } 1186 }
1170 1187
1171 /* check that reported frame size fits in input buffer */
1172 if(s->frame_size > buf_size) {
1173 av_log(avctx, AV_LOG_ERROR, "incomplete frame\n");
1174 return -1;
1175 }
1176
1177 /* check for crc mismatch */
1178 if(!err && avctx->error_resilience >= FF_ER_CAREFUL) {
1179 if(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &buf[2], s->frame_size-2)) {
1180 av_log(avctx, AV_LOG_ERROR, "frame CRC mismatch\n");
1181 err = 1;
1182 }
1183 }
1184
1185 /* if frame is ok, set audio parameters */ 1188 /* if frame is ok, set audio parameters */
1186 if (!err) { 1189 if (!err) {
1187 avctx->sample_rate = s->sample_rate; 1190 avctx->sample_rate = s->sample_rate;
1188 avctx->bit_rate = s->bit_rate; 1191 avctx->bit_rate = s->bit_rate;
1189 1192