summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavcodec/aac_ac3_parser.c15
-rw-r--r--libavcodec/aac_ac3_parser.h8
-rw-r--r--libavcodec/aac_parser.c13
-rw-r--r--libavcodec/ac3_parser.c13
4 files changed, 25 insertions, 24 deletions
diff --git a/libavcodec/aac_ac3_parser.c b/libavcodec/aac_ac3_parser.c
index 999a189158..c72965a76f 100644
--- a/libavcodec/aac_ac3_parser.c
+++ b/libavcodec/aac_ac3_parser.c
@@ -30,7 +30,7 @@ int ff_aac_ac3_parse(AVCodecParserContext *s1,
{
AACAC3ParseContext *s = s1->priv_data;
const uint8_t *buf_ptr;
- int len, sample_rate, bit_rate, channels, samples;
+ int len;
*poutbuf = NULL;
*poutbuf_size = 0;
@@ -50,8 +50,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->inbuf, &channels, &sample_rate, &bit_rate,
- &samples);
+ len = s->sync(s);
if (len == 0) {
/* no sync found : move by one byte (inefficient, but simple!) */
memmove(s->inbuf, s->inbuf + 1, s->header_size - 1);
@@ -59,19 +58,19 @@ int ff_aac_ac3_parse(AVCodecParserContext *s1,
} else {
s->frame_size = len;
/* update codec info */
- avctx->sample_rate = sample_rate;
+ avctx->sample_rate = s->sample_rate;
/* allow downmixing to stereo (or mono for AC3) */
if(avctx->request_channels > 0 &&
- avctx->request_channels < channels &&
+ avctx->request_channels < s->channels &&
(avctx->request_channels <= 2 ||
(avctx->request_channels == 1 &&
avctx->codec_id == CODEC_ID_AC3))) {
avctx->channels = avctx->request_channels;
} else {
- avctx->channels = channels;
+ avctx->channels = s->channels;
}
- avctx->bit_rate = bit_rate;
- avctx->frame_size = samples;
+ avctx->bit_rate = s->bit_rate;
+ avctx->frame_size = s->samples;
}
}
} else {
diff --git a/libavcodec/aac_ac3_parser.h b/libavcodec/aac_ac3_parser.h
index e927de02dd..f93f8a81e9 100644
--- a/libavcodec/aac_ac3_parser.h
+++ b/libavcodec/aac_ac3_parser.h
@@ -30,9 +30,13 @@ typedef struct AACAC3ParseContext {
uint8_t *inbuf_ptr;
int frame_size;
int header_size;
- int (*sync)(const uint8_t *buf, int *channels, int *sample_rate,
- int *bit_rate, int *samples);
+ int (*sync)(struct AACAC3ParseContext *hdr_info);
uint8_t inbuf[8192]; /* input buffer */
+
+ int channels;
+ int sample_rate;
+ int bit_rate;
+ int samples;
} AACAC3ParseContext;
int ff_aac_ac3_parse(AVCodecParserContext *s1,
diff --git a/libavcodec/aac_parser.c b/libavcodec/aac_parser.c
index ac129c23b2..37f014c571 100644
--- a/libavcodec/aac_parser.c
+++ b/libavcodec/aac_parser.c
@@ -38,13 +38,12 @@ static const int aac_channels[8] = {
};
-static int aac_sync(const uint8_t *buf, int *channels, int *sample_rate,
- int *bit_rate, int *samples)
+static int aac_sync(AACAC3ParseContext *hdr_info)
{
GetBitContext bits;
int size, rdb, ch, sr;
- init_get_bits(&bits, buf, AAC_HEADER_SIZE * 8);
+ init_get_bits(&bits, hdr_info->inbuf, AAC_HEADER_SIZE * 8);
if(get_bits(&bits, 12) != 0xfff)
return 0;
@@ -73,10 +72,10 @@ static int aac_sync(const uint8_t *buf, int *channels, int *sample_rate,
skip_bits(&bits, 11); /* adts_buffer_fullness */
rdb = get_bits(&bits, 2); /* number_of_raw_data_blocks_in_frame */
- *channels = aac_channels[ch];
- *sample_rate = aac_sample_rates[sr];
- *samples = (rdb + 1) * 1024;
- *bit_rate = size * 8 * *sample_rate / *samples;
+ hdr_info->channels = aac_channels[ch];
+ 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;
return size;
}
diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c
index bae788ed49..0a8c804e0a 100644
--- a/libavcodec/ac3_parser.c
+++ b/libavcodec/ac3_parser.c
@@ -119,21 +119,20 @@ int ff_ac3_parse_header(const uint8_t buf[7], AC3HeaderInfo *hdr)
return 0;
}
-static int ac3_sync(const uint8_t *buf, int *channels, int *sample_rate,
- int *bit_rate, int *samples)
+static int ac3_sync(AACAC3ParseContext *hdr_info)
{
int err;
AC3HeaderInfo hdr;
- err = ff_ac3_parse_header(buf, &hdr);
+ err = ff_ac3_parse_header(hdr_info->inbuf, &hdr);
if(err < 0)
return 0;
- *sample_rate = hdr.sample_rate;
- *bit_rate = hdr.bit_rate;
- *channels = hdr.channels;
- *samples = AC3_FRAME_SIZE;
+ hdr_info->sample_rate = hdr.sample_rate;
+ hdr_info->bit_rate = hdr.bit_rate;
+ hdr_info->channels = hdr.channels;
+ hdr_info->samples = AC3_FRAME_SIZE;
return hdr.frame_size;
}