Mercurial > libavcodec.hg
comparison ac3dec.c @ 8545:a5402e89a80c libavcodec
Factorise enum of AC3 error types to be usable by AAC in the ADTS patch that
will follow
Patch by Alex Converse ( alex converse gmail com )
author | superdump |
---|---|
date | Wed, 07 Jan 2009 18:10:10 +0000 |
parents | f93efc084e41 |
children | 04423b2f6e0b |
comparison
equal
deleted
inserted
replaced
8544:0ae8629baf6f | 8545:a5402e89a80c |
---|---|
34 #include <math.h> | 34 #include <math.h> |
35 #include <string.h> | 35 #include <string.h> |
36 | 36 |
37 #include "libavutil/crc.h" | 37 #include "libavutil/crc.h" |
38 #include "internal.h" | 38 #include "internal.h" |
39 #include "aac_ac3_parser.h" | |
39 #include "ac3_parser.h" | 40 #include "ac3_parser.h" |
40 #include "ac3dec.h" | 41 #include "ac3dec.h" |
41 #include "ac3dec_data.h" | 42 #include "ac3dec_data.h" |
42 | 43 |
43 /** Large enough for maximum possible frame size when the specification limit is ignored */ | 44 /** Large enough for maximum possible frame size when the specification limit is ignored */ |
1246 err = parse_frame_header(s); | 1247 err = parse_frame_header(s); |
1247 | 1248 |
1248 /* check that reported frame size fits in input buffer */ | 1249 /* check that reported frame size fits in input buffer */ |
1249 if(s->frame_size > buf_size) { | 1250 if(s->frame_size > buf_size) { |
1250 av_log(avctx, AV_LOG_ERROR, "incomplete frame\n"); | 1251 av_log(avctx, AV_LOG_ERROR, "incomplete frame\n"); |
1251 err = AC3_PARSE_ERROR_FRAME_SIZE; | 1252 err = AAC_AC3_PARSE_ERROR_FRAME_SIZE; |
1252 } | 1253 } |
1253 | 1254 |
1254 /* check for crc mismatch */ | 1255 /* check for crc mismatch */ |
1255 if(err != AC3_PARSE_ERROR_FRAME_SIZE && avctx->error_recognition >= FF_ER_CAREFUL) { | 1256 if(err != AAC_AC3_PARSE_ERROR_FRAME_SIZE && avctx->error_recognition >= FF_ER_CAREFUL) { |
1256 if(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &buf[2], s->frame_size-2)) { | 1257 if(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &buf[2], s->frame_size-2)) { |
1257 av_log(avctx, AV_LOG_ERROR, "frame CRC mismatch\n"); | 1258 av_log(avctx, AV_LOG_ERROR, "frame CRC mismatch\n"); |
1258 err = AC3_PARSE_ERROR_CRC; | 1259 err = AAC_AC3_PARSE_ERROR_CRC; |
1259 } | 1260 } |
1260 } | 1261 } |
1261 | 1262 |
1262 if(err && err != AC3_PARSE_ERROR_CRC) { | 1263 if(err && err != AAC_AC3_PARSE_ERROR_CRC) { |
1263 switch(err) { | 1264 switch(err) { |
1264 case AC3_PARSE_ERROR_SYNC: | 1265 case AAC_AC3_PARSE_ERROR_SYNC: |
1265 av_log(avctx, AV_LOG_ERROR, "frame sync error\n"); | 1266 av_log(avctx, AV_LOG_ERROR, "frame sync error\n"); |
1266 return -1; | 1267 return -1; |
1267 case AC3_PARSE_ERROR_BSID: | 1268 case AAC_AC3_PARSE_ERROR_BSID: |
1268 av_log(avctx, AV_LOG_ERROR, "invalid bitstream id\n"); | 1269 av_log(avctx, AV_LOG_ERROR, "invalid bitstream id\n"); |
1269 break; | 1270 break; |
1270 case AC3_PARSE_ERROR_SAMPLE_RATE: | 1271 case AAC_AC3_PARSE_ERROR_SAMPLE_RATE: |
1271 av_log(avctx, AV_LOG_ERROR, "invalid sample rate\n"); | 1272 av_log(avctx, AV_LOG_ERROR, "invalid sample rate\n"); |
1272 break; | 1273 break; |
1273 case AC3_PARSE_ERROR_FRAME_SIZE: | 1274 case AAC_AC3_PARSE_ERROR_FRAME_SIZE: |
1274 av_log(avctx, AV_LOG_ERROR, "invalid frame size\n"); | 1275 av_log(avctx, AV_LOG_ERROR, "invalid frame size\n"); |
1275 break; | 1276 break; |
1276 case AC3_PARSE_ERROR_FRAME_TYPE: | 1277 case AAC_AC3_PARSE_ERROR_FRAME_TYPE: |
1277 /* skip frame if CRC is ok. otherwise use error concealment. */ | 1278 /* skip frame if CRC is ok. otherwise use error concealment. */ |
1278 /* TODO: add support for substreams and dependent frames */ | 1279 /* TODO: add support for substreams and dependent frames */ |
1279 if(s->frame_type == EAC3_FRAME_TYPE_DEPENDENT || s->substreamid) { | 1280 if(s->frame_type == EAC3_FRAME_TYPE_DEPENDENT || s->substreamid) { |
1280 av_log(avctx, AV_LOG_ERROR, "unsupported frame type : skipping frame\n"); | 1281 av_log(avctx, AV_LOG_ERROR, "unsupported frame type : skipping frame\n"); |
1281 return s->frame_size; | 1282 return s->frame_size; |