[FFmpeg-cvslog] ac3enc: prefer passing AC3EncodeContext rather than AVCodecContext

Justin Ruggles git at videolan.org
Thu Jul 14 02:36:48 CEST 2011


ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Wed Jul 13 13:53:58 2011 -0400| [82cea7cb6c38e251f88fbf090cd5361f5d0a49de] | committer: Justin Ruggles

ac3enc: prefer passing AC3EncodeContext rather than AVCodecContext

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=82cea7cb6c38e251f88fbf090cd5361f5d0a49de
---

 libavcodec/ac3enc.c          |   23 ++++++++++++-----------
 libavcodec/ac3enc.h          |    2 +-
 libavcodec/ac3enc_template.c |    2 +-
 3 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index f957ee9..f6a3b31 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -1535,10 +1535,10 @@ void ff_ac3_output_frame(AC3EncodeContext *s, unsigned char *frame)
 }
 
 
-static void dprint_options(AVCodecContext *avctx)
+static void dprint_options(AC3EncodeContext *s)
 {
 #ifdef DEBUG
-    AC3EncodeContext *s = avctx->priv_data;
+    AVCodecContext *avctx = s->avctx;
     AC3EncOptions *opt = &s->options;
     char strbuf[32];
 
@@ -1689,9 +1689,9 @@ static void validate_mix_level(void *log_ctx, const char *opt_name,
  * Validate metadata options as set by AVOption system.
  * These values can optionally be changed per-frame.
  */
-int ff_ac3_validate_metadata(AVCodecContext *avctx)
+int ff_ac3_validate_metadata(AC3EncodeContext *s)
 {
-    AC3EncodeContext *s = avctx->priv_data;
+    AVCodecContext *avctx = s->avctx;
     AC3EncOptions *opt = &s->options;
 
     /* validate mixing levels */
@@ -1892,8 +1892,9 @@ static av_cold int set_channel_info(AC3EncodeContext *s, int channels,
 }
 
 
-static av_cold int validate_options(AVCodecContext *avctx, AC3EncodeContext *s)
+static av_cold int validate_options(AC3EncodeContext *s)
 {
+    AVCodecContext *avctx = s->avctx;
     int i, ret, max_sr;
 
     /* validate channel layout */
@@ -1998,7 +1999,7 @@ static av_cold int validate_options(AVCodecContext *avctx, AC3EncodeContext *s)
     }
 
     if (!s->eac3) {
-        ret = ff_ac3_validate_metadata(avctx);
+        ret = ff_ac3_validate_metadata(s);
         if (ret)
             return ret;
     }
@@ -2085,10 +2086,10 @@ static av_cold void set_bandwidth(AC3EncodeContext *s)
 }
 
 
-static av_cold int allocate_buffers(AVCodecContext *avctx)
+static av_cold int allocate_buffers(AC3EncodeContext *s)
 {
+    AVCodecContext *avctx = s->avctx;
     int blk, ch;
-    AC3EncodeContext *s = avctx->priv_data;
     int channels = s->channels + 1; /* includes coupling channel */
 
     if (s->allocate_sample_buffers(s))
@@ -2201,7 +2202,7 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx)
 
     ff_ac3_common_init();
 
-    ret = validate_options(avctx, s);
+    ret = validate_options(s);
     if (ret)
         return ret;
 
@@ -2246,7 +2247,7 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx)
     if (ret)
         goto init_fail;
 
-    ret = allocate_buffers(avctx);
+    ret = allocate_buffers(s);
     if (ret)
         goto init_fail;
 
@@ -2255,7 +2256,7 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx)
     dsputil_init(&s->dsp, avctx);
     ff_ac3dsp_init(&s->ac3dsp, avctx->flags & CODEC_FLAG_BITEXACT);
 
-    dprint_options(avctx);
+    dprint_options(s);
 
     return 0;
 init_fail:
diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h
index 54f427a..ccef707 100644
--- a/libavcodec/ac3enc.h
+++ b/libavcodec/ac3enc.h
@@ -243,7 +243,7 @@ int ff_ac3_encode_init(AVCodecContext *avctx);
 
 int ff_ac3_encode_close(AVCodecContext *avctx);
 
-int ff_ac3_validate_metadata(AVCodecContext *avctx);
+int ff_ac3_validate_metadata(AC3EncodeContext *s);
 
 void ff_ac3_adjust_frame_size(AC3EncodeContext *s);
 
diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c
index c7243c7..95c190b 100644
--- a/libavcodec/ac3enc_template.c
+++ b/libavcodec/ac3enc_template.c
@@ -424,7 +424,7 @@ int AC3_NAME(encode_frame)(AVCodecContext *avctx, unsigned char *frame,
     int ret;
 
     if (!s->eac3 && s->options.allow_per_frame_metadata) {
-        ret = ff_ac3_validate_metadata(avctx);
+        ret = ff_ac3_validate_metadata(s);
         if (ret)
             return ret;
     }



More information about the ffmpeg-cvslog mailing list