aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartlomiej Wolowiec <bartek.wolowiec@gmail.com>2008-03-24 21:25:49 +0000
committerBartlomiej Wolowiec <bartek.wolowiec@gmail.com>2008-03-24 21:25:49 +0000
commit4e6eeaf01968a22748e27590d29f343323cca9c6 (patch)
treeb4c32d09b5b6a3dddf4fd6a917289f7ed7b56b80
parentb4e806b2b9696443954de88e54ea583d705bcd24 (diff)
downloadffmpeg-4e6eeaf01968a22748e27590d29f343323cca9c6.tar.gz
using stream type in eac3 parser
Originally committed as revision 12570 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavcodec/aac_ac3_parser.h1
-rw-r--r--libavcodec/aac_parser.c1
-rw-r--r--libavcodec/ac3.h7
-rw-r--r--libavcodec/ac3_parser.c6
-rw-r--r--libavcodec/ac3_parser.h1
-rw-r--r--libavcodec/ac3dec.c3
6 files changed, 18 insertions, 1 deletions
diff --git a/libavcodec/aac_ac3_parser.h b/libavcodec/aac_ac3_parser.h
index f93f8a81e9..49982500cc 100644
--- a/libavcodec/aac_ac3_parser.h
+++ b/libavcodec/aac_ac3_parser.h
@@ -37,6 +37,7 @@ typedef struct AACAC3ParseContext {
int sample_rate;
int bit_rate;
int samples;
+ uint8_t stream_type;
} AACAC3ParseContext;
int ff_aac_ac3_parse(AVCodecParserContext *s1,
diff --git a/libavcodec/aac_parser.c b/libavcodec/aac_parser.c
index 37f014c571..4e8ddc1dfb 100644
--- a/libavcodec/aac_parser.c
+++ b/libavcodec/aac_parser.c
@@ -83,6 +83,7 @@ static int aac_sync(AACAC3ParseContext *hdr_info)
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;
diff --git a/libavcodec/ac3.h b/libavcodec/ac3.h
index b5fa789c49..7c2e3d9cbb 100644
--- a/libavcodec/ac3.h
+++ b/libavcodec/ac3.h
@@ -84,6 +84,7 @@ typedef struct {
uint8_t bitstream_id;
uint8_t channel_mode;
uint8_t lfe_on;
+ uint8_t stream_type;
/** @} */
/** @defgroup derived Derived values
@@ -97,6 +98,12 @@ typedef struct {
/** @} */
} 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);
diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c
index 0a8c804e0a..393133efe7 100644
--- a/libavcodec/ac3_parser.c
+++ b/libavcodec/ac3_parser.c
@@ -84,10 +84,14 @@ int ff_ac3_parse_header(const uint8_t buf[7], AC3HeaderInfo *hdr)
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;
diff --git a/libavcodec/ac3_parser.h b/libavcodec/ac3_parser.h
index ffac6190f8..f82be029fb 100644
--- a/libavcodec/ac3_parser.h
+++ b/libavcodec/ac3_parser.h
@@ -30,6 +30,7 @@ typedef enum {
AC3_PARSE_ERROR_BSID = -2,
AC3_PARSE_ERROR_SAMPLE_RATE = -3,
AC3_PARSE_ERROR_FRAME_SIZE = -4,
+ AC3_PARSE_ERROR_STREAM_TYPE = -5,
} AC3ParseError;
/**
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 75208de33d..79a8606dba 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -1151,6 +1151,9 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size,
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;