Mercurial > libavcodec.hg
comparison ac3dec.c @ 5680:5ae5a74b0e4b libavcodec
better AC3 header error reporting
author | jbr |
---|---|
date | Sat, 15 Sep 2007 02:41:24 +0000 |
parents | 8f64e86e1b63 |
children | ed3e9456f295 |
comparison
equal
deleted
inserted
replaced
5679:8f64e86e1b63 | 5680:5ae5a74b0e4b |
---|---|
1087 */ | 1087 */ |
1088 static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, uint8_t *buf, int buf_size) | 1088 static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, uint8_t *buf, int buf_size) |
1089 { | 1089 { |
1090 AC3DecodeContext *ctx = (AC3DecodeContext *)avctx->priv_data; | 1090 AC3DecodeContext *ctx = (AC3DecodeContext *)avctx->priv_data; |
1091 int16_t *out_samples = (int16_t *)data; | 1091 int16_t *out_samples = (int16_t *)data; |
1092 int i, blk, ch; | 1092 int i, blk, ch, err; |
1093 | 1093 |
1094 /* initialize the GetBitContext with the start of valid AC-3 Frame */ | 1094 /* initialize the GetBitContext with the start of valid AC-3 Frame */ |
1095 init_get_bits(&ctx->gb, buf, buf_size * 8); | 1095 init_get_bits(&ctx->gb, buf, buf_size * 8); |
1096 | 1096 |
1097 /* parse the syncinfo */ | 1097 /* parse the syncinfo */ |
1098 if (ac3_parse_header(ctx)) { | 1098 err = ac3_parse_header(ctx); |
1099 av_log(avctx, AV_LOG_ERROR, "\n"); | 1099 if(err) { |
1100 *data_size = 0; | 1100 switch(err) { |
1101 return buf_size; | 1101 case AC3_PARSE_ERROR_SYNC: |
1102 av_log(avctx, AV_LOG_ERROR, "frame sync error\n"); | |
1103 break; | |
1104 case AC3_PARSE_ERROR_BSID: | |
1105 av_log(avctx, AV_LOG_ERROR, "invalid bitstream id\n"); | |
1106 break; | |
1107 case AC3_PARSE_ERROR_SAMPLE_RATE: | |
1108 av_log(avctx, AV_LOG_ERROR, "invalid sample rate\n"); | |
1109 break; | |
1110 case AC3_PARSE_ERROR_FRAME_SIZE: | |
1111 av_log(avctx, AV_LOG_ERROR, "invalid frame size\n"); | |
1112 break; | |
1113 default: | |
1114 av_log(avctx, AV_LOG_ERROR, "invalid header\n"); | |
1115 break; | |
1116 } | |
1117 return -1; | |
1102 } | 1118 } |
1103 | 1119 |
1104 avctx->sample_rate = ctx->sampling_rate; | 1120 avctx->sample_rate = ctx->sampling_rate; |
1105 avctx->bit_rate = ctx->bit_rate; | 1121 avctx->bit_rate = ctx->bit_rate; |
1106 | 1122 |