diff --git a/libavcodec/aac_ac3_parser.c b/libavcodec/aac_ac3_parser.c
index 999a189158fd052c98de4ede89a0b49e24ac30f1..c72965a76f9c424a070322f0903b81abe7492b3b 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 e927de02dd4880a8f868fbd933da6db649990867..f93f8a81e96a032304ddcef972b888a152f082a3 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 ac129c23b21e8aee3019e9098ebb6f7cfb0926b8..37f014c571ce468817c5ebbb37094b5ba261bc46 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 bae788ed49b906191bf238297d8dc8ae473e0926..0a8c804e0ad9264fc901d25d49d2310e5389da62 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;
 }