[FFmpeg-devel] [PATCH] avcodec: Add AVClass to AVCodecParameters

Michael Niedermayer michael at niedermayer.cc
Tue May 17 12:07:26 CEST 2016


Most of the major public structures contain an AVClass.
We can add the AVClass now as there has been no release with AVCodecParameters
after the next release this change would require a major version bump

TODO: bump minor version
TODO: update APIChanges

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavcodec/avcodec.h |    9 +++++++++
 libavcodec/utils.c   |   11 +++++++++++
 2 files changed, 20 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 9ec9adf..9abf69f 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3905,6 +3905,10 @@ typedef struct AVSubtitle {
  */
 typedef struct AVCodecParameters {
     /**
+     * A class for logging and AVOptions
+     */
+    AVClass *av_class;
+    /**
      * General type of the encoded data.
      */
     enum AVMediaType codec_type;
@@ -4156,6 +4160,11 @@ const AVClass *avcodec_get_frame_class(void);
 const AVClass *avcodec_get_subtitle_rect_class(void);
 
 /**
+ * Get the AVClass for AVCodecParameters.
+ */
+const AVClass *avcodec_get_parameters_class(void);
+
+/**
  * Copy the settings of the source AVCodecContext into the destination
  * AVCodecContext. The resulting destination codec context will be
  * unopened, i.e. you are required to call avcodec_open2() before you
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index e5a832b..4da6959 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -4005,12 +4005,18 @@ AVCPBProperties *ff_add_cpb_side_data(AVCodecContext *avctx)
     return props;
 }
 
+static const AVClass av_codec_parameters_class = {
+    .class_name              = "AVCodecParameters",
+    .version                 = LIBAVUTIL_VERSION_INT,
+};
+
 static void codec_parameters_reset(AVCodecParameters *par)
 {
     av_freep(&par->extradata);
 
     memset(par, 0, sizeof(*par));
 
+    par->av_class            = &av_codec_parameters_class;
     par->codec_type          = AVMEDIA_TYPE_UNKNOWN;
     par->codec_id            = AV_CODEC_ID_NONE;
     par->format              = -1;
@@ -4025,6 +4031,11 @@ static void codec_parameters_reset(AVCodecParameters *par)
     par->level               = FF_LEVEL_UNKNOWN;
 }
 
+const AVClass *avcodec_get_parameters_class(void)
+{
+    return &av_codec_parameters_class;
+}
+
 AVCodecParameters *avcodec_parameters_alloc(void)
 {
     AVCodecParameters *par = av_mallocz(sizeof(*par));
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list