[FFmpeg-cvslog] lavc: make avcodec_get_context_defaults3 "officially" public

Anton Khirnov git at videolan.org
Thu Oct 20 02:37:10 CEST 2011


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sat Oct  8 08:47:47 2011 +0200| [f0eeff708ab5add2d4e8aec9b10683d71b4802be] | committer: Anton Khirnov

lavc: make avcodec_get_context_defaults3 "officially" public

Deprecate avcodec_get_context_defaults/avcodec_get_context_defaults2

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

 avserver.c           |    4 ++--
 libavcodec/avcodec.h |   16 ++++++++++++++--
 libavcodec/options.c |   38 +++++++++++++++++++-------------------
 3 files changed, 35 insertions(+), 23 deletions(-)

diff --git a/avserver.c b/avserver.c
index 72b7754..cb8f41f 100644
--- a/avserver.c
+++ b/avserver.c
@@ -4234,8 +4234,8 @@ static int parse_ffconfig(const char *filename)
                 }
 
                 stream->fmt = avserver_guess_format(NULL, stream->filename, NULL);
-                avcodec_get_context_defaults2(&video_enc, AVMEDIA_TYPE_VIDEO);
-                avcodec_get_context_defaults2(&audio_enc, AVMEDIA_TYPE_AUDIO);
+                avcodec_get_context_defaults3(&video_enc, NULL);
+                avcodec_get_context_defaults3(&audio_enc, NULL);
                 audio_id = CODEC_ID_NONE;
                 video_id = CODEC_ID_NONE;
                 if (stream->fmt) {
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index a8086c6..c2a3098 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3592,19 +3592,31 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
  */
 const char *av_get_profile_name(const AVCodec *codec, int profile);
 
+#if FF_API_ALLOC_CONTEXT
 /**
  * Set the fields of the given AVCodecContext to default values.
  *
  * @param s The AVCodecContext of which the fields should be set to default values.
+ * @deprecated use avcodec_get_context_defaults3
  */
+attribute_deprecated
 void avcodec_get_context_defaults(AVCodecContext *s);
 
 /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
  *  we WILL change its arguments and name a few times! */
+attribute_deprecated
 void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType);
+#endif
 
-/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
- *  we WILL change its arguments and name a few times! */
+/**
+ * Set the fields of the given AVCodecContext to default values corresponding
+ * to the given codec (defaults may be codec-dependent).
+ *
+ * Do not call this function if a non-NULL codec has been passed
+ * to avcodec_alloc_context3() that allocated this AVCodecContext.
+ * If codec is non-NULL, it is illegal to call avcodec_open2() with a
+ * different codec on this AVCodecContext.
+ */
 int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec);
 
 #if FF_API_ALLOC_CONTEXT
diff --git a/libavcodec/options.c b/libavcodec/options.c
index 75a1164..65d57d3 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -531,30 +531,32 @@ static const AVClass av_codec_context_class = {
     .child_class_next        = codec_child_class_next,
 };
 
+#if FF_API_ALLOC_CONTEXT
 void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType codec_type){
+    avcodec_get_context_defaults3(s, NULL);
+}
+#endif
+
+int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec){
     memset(s, 0, sizeof(AVCodecContext));
 
-    s->av_class= &av_codec_context_class;
+    s->av_class = &av_codec_context_class;
 
-    s->codec_type = codec_type;
+    s->codec_type = codec ? codec->type : AVMEDIA_TYPE_UNKNOWN;
     av_opt_set_defaults(s);
 
-    s->time_base= (AVRational){0,1};
-    s->get_buffer= avcodec_default_get_buffer;
-    s->release_buffer= avcodec_default_release_buffer;
-    s->get_format= avcodec_default_get_format;
-    s->execute= avcodec_default_execute;
-    s->execute2= avcodec_default_execute2;
-    s->sample_aspect_ratio= (AVRational){0,1};
-    s->pix_fmt= PIX_FMT_NONE;
-    s->sample_fmt= AV_SAMPLE_FMT_NONE;
-
-    s->reget_buffer= avcodec_default_reget_buffer;
-    s->reordered_opaque= AV_NOPTS_VALUE;
-}
-
-int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec){
-    avcodec_get_context_defaults2(s, codec ? codec->type : AVMEDIA_TYPE_UNKNOWN);
+    s->time_base           = (AVRational){0,1};
+    s->get_buffer          = avcodec_default_get_buffer;
+    s->release_buffer      = avcodec_default_release_buffer;
+    s->get_format          = avcodec_default_get_format;
+    s->execute             = avcodec_default_execute;
+    s->execute2            = avcodec_default_execute2;
+    s->sample_aspect_ratio = (AVRational){0,1};
+    s->pix_fmt             = PIX_FMT_NONE;
+    s->sample_fmt          = AV_SAMPLE_FMT_NONE;
+
+    s->reget_buffer        = avcodec_default_reget_buffer;
+    s->reordered_opaque    = AV_NOPTS_VALUE;
     if(codec && codec->priv_data_size){
         if(!s->priv_data){
             s->priv_data= av_mallocz(codec->priv_data_size);
@@ -602,13 +604,11 @@ AVCodecContext *avcodec_alloc_context2(enum AVMediaType codec_type){
 
     return avctx;
 }
-#endif
 
 void avcodec_get_context_defaults(AVCodecContext *s){
     avcodec_get_context_defaults2(s, AVMEDIA_TYPE_UNKNOWN);
 }
 
-#if FF_API_ALLOC_CONTEXT
 AVCodecContext *avcodec_alloc_context(void){
     return avcodec_alloc_context2(AVMEDIA_TYPE_UNKNOWN);
 }



More information about the ffmpeg-cvslog mailing list