Mercurial > libavcodec.hg
changeset 6529:5542d0c04a55 libavcodec
using stream type in eac3 parser
author | bwolowiec |
---|---|
date | Mon, 24 Mar 2008 21:25:49 +0000 |
parents | 28d0e7dac45d |
children | 5d9fe8d17643 |
files | aac_ac3_parser.h aac_parser.c ac3.h ac3_parser.c ac3_parser.h ac3dec.c |
diffstat | 6 files changed, 18 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/aac_ac3_parser.h Mon Mar 24 11:49:59 2008 +0000 +++ b/aac_ac3_parser.h Mon Mar 24 21:25:49 2008 +0000 @@ -37,6 +37,7 @@ int sample_rate; int bit_rate; int samples; + uint8_t stream_type; } AACAC3ParseContext; int ff_aac_ac3_parse(AVCodecParserContext *s1,
--- a/aac_parser.c Mon Mar 24 11:49:59 2008 +0000 +++ b/aac_parser.c Mon Mar 24 21:25:49 2008 +0000 @@ -83,6 +83,7 @@ static av_cold int aac_parse_init(AVCodecParserContext *s1) { AACAC3ParseContext *s = s1->priv_data; + s->stream_type = 0; s->inbuf_ptr = s->inbuf; s->header_size = AAC_HEADER_SIZE; s->sync = aac_sync;
--- a/ac3.h Mon Mar 24 11:49:59 2008 +0000 +++ b/ac3.h Mon Mar 24 21:25:49 2008 +0000 @@ -84,6 +84,7 @@ uint8_t bitstream_id; uint8_t channel_mode; uint8_t lfe_on; + uint8_t stream_type; /** @} */ /** @defgroup derived Derived values @@ -97,6 +98,12 @@ /** @} */ } AC3HeaderInfo; +typedef enum { + EAC3_STREAM_TYPE_INDEPENDENT = 0, + EAC3_STREAM_TYPE_DEPENDENT, + EAC3_STREAM_TYPE_AC3_CONVERT, + EAC3_STREAM_TYPE_RESERVED +} EAC3StreamType; void ac3_common_init(void);
--- a/ac3_parser.c Mon Mar 24 11:49:59 2008 +0000 +++ b/ac3_parser.c Mon Mar 24 21:25:49 2008 +0000 @@ -84,10 +84,14 @@ hdr->bit_rate = (ff_ac3_bitrate_tab[frame_size_code>>1] * 1000) >> hdr->sr_shift; hdr->channels = ff_ac3_channels_tab[hdr->channel_mode] + hdr->lfe_on; hdr->frame_size = ff_ac3_frame_size_tab[frame_size_code][hdr->sr_code] * 2; + hdr->stream_type = 0; } else { /* Enhanced AC-3 */ hdr->crc1 = 0; - skip_bits(&gbc, 2); // skip stream type + hdr->stream_type = get_bits(&gbc, 2); + if(hdr->stream_type == 3) + return AC3_PARSE_ERROR_STREAM_TYPE; + skip_bits(&gbc, 3); // skip substream id hdr->frame_size = (get_bits(&gbc, 11) + 1) << 1;
--- a/ac3_parser.h Mon Mar 24 11:49:59 2008 +0000 +++ b/ac3_parser.h Mon Mar 24 21:25:49 2008 +0000 @@ -30,6 +30,7 @@ AC3_PARSE_ERROR_BSID = -2, AC3_PARSE_ERROR_SAMPLE_RATE = -3, AC3_PARSE_ERROR_FRAME_SIZE = -4, + AC3_PARSE_ERROR_STREAM_TYPE = -5, } AC3ParseError; /**
--- a/ac3dec.c Mon Mar 24 11:49:59 2008 +0000 +++ b/ac3dec.c Mon Mar 24 21:25:49 2008 +0000 @@ -1151,6 +1151,9 @@ case AC3_PARSE_ERROR_FRAME_SIZE: av_log(avctx, AV_LOG_ERROR, "invalid frame size\n"); break; + case AC3_PARSE_ERROR_STREAM_TYPE: + av_log(avctx, AV_LOG_ERROR, "invalid stream type\n"); + break; default: av_log(avctx, AV_LOG_ERROR, "invalid header\n"); break;