diff options
author | Bartlomiej Wolowiec <bartek.wolowiec@gmail.com> | 2008-03-28 19:59:58 +0000 |
---|---|---|
committer | Bartlomiej Wolowiec <bartek.wolowiec@gmail.com> | 2008-03-28 19:59:58 +0000 |
commit | be1e2a2bfa592ff14355c6b97e90c530e2c0fcc0 (patch) | |
tree | a9d7171af4f5eda9a96a8aff32b824034df9b474 | |
parent | 5610f20ed4358af3c1380ceb79ee51e258df79bf (diff) | |
download | ffmpeg-be1e2a2bfa592ff14355c6b97e90c530e2c0fcc0.tar.gz |
removal of stream_type in AACAC3ParseContext and adding AACAC3FrameFlag
Originally committed as revision 12622 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/aac_ac3_parser.c | 3 | ||||
-rw-r--r-- | libavcodec/aac_ac3_parser.h | 9 | ||||
-rw-r--r-- | libavcodec/aac_parser.c | 5 | ||||
-rw-r--r-- | libavcodec/ac3_parser.c | 14 |
4 files changed, 24 insertions, 7 deletions
diff --git a/libavcodec/aac_ac3_parser.c b/libavcodec/aac_ac3_parser.c index c72965a76f..1193647e90 100644 --- a/libavcodec/aac_ac3_parser.c +++ b/libavcodec/aac_ac3_parser.c @@ -29,6 +29,7 @@ int ff_aac_ac3_parse(AVCodecParserContext *s1, const uint8_t *buf, int buf_size) { AACAC3ParseContext *s = s1->priv_data; + AACAC3FrameFlag frame_flag; const uint8_t *buf_ptr; int len; @@ -50,7 +51,7 @@ int ff_aac_ac3_parse(AVCodecParserContext *s1, if (s->frame_size == 0) { if ((s->inbuf_ptr - s->inbuf) == s->header_size) { - len = s->sync(s); + len = s->sync(s, &frame_flag); if (len == 0) { /* no sync found : move by one byte (inefficient, but simple!) */ memmove(s->inbuf, s->inbuf + 1, s->header_size - 1); diff --git a/libavcodec/aac_ac3_parser.h b/libavcodec/aac_ac3_parser.h index 49982500cc..ec9ce48a4a 100644 --- a/libavcodec/aac_ac3_parser.h +++ b/libavcodec/aac_ac3_parser.h @@ -26,18 +26,23 @@ #include <stdint.h> #include "avcodec.h" +typedef enum{ + FRAME_COMPLETE, ///< Complete frame, ends previous frame + FRAME_START, ///< Frame start, ends previous frame + FRAME_CONTINUATION ///< Part of the previous frame +}AACAC3FrameFlag; + typedef struct AACAC3ParseContext { uint8_t *inbuf_ptr; int frame_size; int header_size; - int (*sync)(struct AACAC3ParseContext *hdr_info); + int (*sync)(struct AACAC3ParseContext *hdr_info, AACAC3FrameFlag *flag); uint8_t inbuf[8192]; /* input buffer */ int channels; 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 45c8b95e76..3a20129c06 100644 --- a/libavcodec/aac_parser.c +++ b/libavcodec/aac_parser.c @@ -23,7 +23,6 @@ #include "parser.h" #include "aac_ac3_parser.h" #include "bitstream.h" -#include "ac3.h" #define AAC_HEADER_SIZE 7 @@ -39,7 +38,7 @@ static const int aac_channels[8] = { }; -static int aac_sync(AACAC3ParseContext *hdr_info) +static int aac_sync(AACAC3ParseContext *hdr_info, AACAC3FrameFlag *flag) { GetBitContext bits; int size, rdb, ch, sr; @@ -77,6 +76,7 @@ static int aac_sync(AACAC3ParseContext *hdr_info) hdr_info->sample_rate = aac_sample_rates[sr]; hdr_info->samples = (rdb + 1) * 1024; hdr_info->bit_rate = size * 8 * hdr_info->sample_rate / hdr_info->samples; + *flag = FRAME_COMPLETE; return size; } @@ -84,7 +84,6 @@ static int aac_sync(AACAC3ParseContext *hdr_info) static av_cold int aac_parse_init(AVCodecParserContext *s1) { AACAC3ParseContext *s = s1->priv_data; - s->stream_type = EAC3_STREAM_TYPE_INDEPENDENT; s->inbuf_ptr = s->inbuf; s->header_size = AAC_HEADER_SIZE; s->sync = aac_sync; diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c index 7f0818b607..ea7f592082 100644 --- a/libavcodec/ac3_parser.c +++ b/libavcodec/ac3_parser.c @@ -123,7 +123,7 @@ int ff_ac3_parse_header(const uint8_t buf[7], AC3HeaderInfo *hdr) return 0; } -static int ac3_sync(AACAC3ParseContext *hdr_info) +static int ac3_sync(AACAC3ParseContext *hdr_info, AACAC3FrameFlag *flag) { int err; AC3HeaderInfo hdr; @@ -137,6 +137,18 @@ static int ac3_sync(AACAC3ParseContext *hdr_info) hdr_info->bit_rate = hdr.bit_rate; hdr_info->channels = hdr.channels; hdr_info->samples = AC3_FRAME_SIZE; + + switch(hdr.stream_type){ + case EAC3_STREAM_TYPE_INDEPENDENT: + *flag = FRAME_START; + break; + case EAC3_STREAM_TYPE_DEPENDENT: + *flag = FRAME_CONTINUATION; + break; + case EAC3_STREAM_TYPE_AC3_CONVERT: + *flag = FRAME_COMPLETE; + break; + } return hdr.frame_size; } |