[FFmpeg-devel] [PATCH] Replace usage of the deprecated av_pix_fmt_descriptors array with av_pix_fmt_desc_get

h.leppkes at gmail.com h.leppkes at gmail.com
Sat Oct 20 06:43:48 CEST 2012


From: Hendrik Leppkes <h.leppkes at gmail.com>

---
 ffmpeg_filter.c               | 6 +++---
 libavcodec/libstagefright.cpp | 2 +-
 libavfilter/avfiltergraph.c   | 2 +-
 libavfilter/vf_colormatrix.c  | 2 +-
 libavfilter/vf_decimate.c     | 2 +-
 libavfilter/vf_deshake.c      | 4 ++--
 libavfilter/vf_hflip.c        | 2 +-
 libavfilter/vf_hue.c          | 2 +-
 libavfilter/vf_idet.c         | 2 +-
 libavfilter/vf_overlay.c      | 2 +-
 libavfilter/vf_smartblur.c    | 2 +-
 libavfilter/vf_tinterlace.c   | 4 ++--
 libavfilter/video.c           | 2 +-
 libavfilter/vsrc_mptestsrc.c  | 2 +-
 libswscale/swscale_internal.h | 4 ++--
 libswscale/x86/swscale.c      | 2 +-
 tools/fourcc2pixfmt.c         | 2 +-
 17 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/ffmpeg_filter.c b/ffmpeg_filter.c
index 5f9c42c..b634ac5 100644
--- a/ffmpeg_filter.c
+++ b/ffmpeg_filter.c
@@ -37,7 +37,7 @@ enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodec *codec, enum AVPixelFo
 {
     if (codec && codec->pix_fmts) {
         const enum AVPixelFormat *p = codec->pix_fmts;
-        int has_alpha= av_pix_fmt_descriptors[target].nb_components % 2 == 0;
+        int has_alpha= av_pix_fmt_desc_get(target)->nb_components % 2 == 0;
         enum AVPixelFormat best= AV_PIX_FMT_NONE;
         if (st->codec->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {
             if (st->codec->codec_id == AV_CODEC_ID_MJPEG) {
@@ -56,9 +56,9 @@ enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodec *codec, enum AVPixelFo
             if (target != AV_PIX_FMT_NONE)
                 av_log(NULL, AV_LOG_WARNING,
                        "Incompatible pixel format '%s' for codec '%s', auto-selecting format '%s'\n",
-                       av_pix_fmt_descriptors[target].name,
+                       av_get_pix_fmt_name(target),
                        codec->name,
-                       av_pix_fmt_descriptors[best].name);
+                       av_get_pix_fmt_name(best));
             return best;
         }
     }
diff --git a/libavcodec/libstagefright.cpp b/libavcodec/libstagefright.cpp
index 3c18527..f741df9 100644
--- a/libavcodec/libstagefright.cpp
+++ b/libavcodec/libstagefright.cpp
@@ -153,7 +153,7 @@ void* decode_thread(void *arg)
 {
     AVCodecContext *avctx = (AVCodecContext*)arg;
     StagefrightContext *s = (StagefrightContext*)avctx->priv_data;
-    const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[avctx->pix_fmt];
+    const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(avctx->pix_fmt);
     Frame* frame;
     MediaBuffer *buffer;
     int32_t w, h;
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index ab37fae..980cdf2 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -424,7 +424,7 @@ static int pick_format(AVFilterLink *link, AVFilterLink *ref)
 
     if (link->type == AVMEDIA_TYPE_VIDEO) {
         if(ref && ref->type == AVMEDIA_TYPE_VIDEO){
-            int has_alpha= av_pix_fmt_descriptors[ref->format].nb_components % 2 == 0;
+            int has_alpha= av_pix_fmt_desc_get(ref->format)->nb_components % 2 == 0;
             enum AVPixelFormat best= AV_PIX_FMT_NONE;
             int i;
             for (i=0; i<link->in_formats->format_count; i++) {
diff --git a/libavfilter/vf_colormatrix.c b/libavfilter/vf_colormatrix.c
index f331204..7200e1d 100644
--- a/libavfilter/vf_colormatrix.c
+++ b/libavfilter/vf_colormatrix.c
@@ -308,7 +308,7 @@ static int config_input(AVFilterLink *inlink)
 {
     AVFilterContext *ctx = inlink->dst;
     ColorMatrixContext *color = ctx->priv;
-    const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[inlink->format];
+    const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
 
     color->hsub = pix_desc->log2_chroma_w;
     color->vsub = pix_desc->log2_chroma_h;
diff --git a/libavfilter/vf_decimate.c b/libavfilter/vf_decimate.c
index b4abfa3..8d54d39 100644
--- a/libavfilter/vf_decimate.c
+++ b/libavfilter/vf_decimate.c
@@ -180,7 +180,7 @@ static int config_input(AVFilterLink *inlink)
 {
     AVFilterContext *ctx = inlink->dst;
     DecimateContext *decimate = ctx->priv;
-    const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[inlink->format];
+    const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
     decimate->hsub = pix_desc->log2_chroma_w;
     decimate->vsub = pix_desc->log2_chroma_h;
 
diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c
index e86d5bc..0444de0 100644
--- a/libavfilter/vf_deshake.c
+++ b/libavfilter/vf_deshake.c
@@ -59,8 +59,8 @@
 
 #include "transform.h"
 
-#define CHROMA_WIDTH(link)  -((-link->w) >> av_pix_fmt_descriptors[link->format].log2_chroma_w)
-#define CHROMA_HEIGHT(link) -((-link->h) >> av_pix_fmt_descriptors[link->format].log2_chroma_h)
+#define CHROMA_WIDTH(link)  -((-link->w) >> av_pix_fmt_desc_get(link->format)->log2_chroma_w)
+#define CHROMA_HEIGHT(link) -((-link->h) >> av_pix_fmt_desc_get(link->format)->log2_chroma_h)
 
 enum SearchMethod {
     EXHAUSTIVE,        ///< Search all possible positions
diff --git a/libavfilter/vf_hflip.c b/libavfilter/vf_hflip.c
index 70bf5c9..41b4d54 100644
--- a/libavfilter/vf_hflip.c
+++ b/libavfilter/vf_hflip.c
@@ -95,7 +95,7 @@ static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
     avfilter_copy_buffer_ref_props(outlink->out_buf, picref);
 
     /* copy palette if required */
-    if (av_pix_fmt_descriptors[inlink->format].flags & PIX_FMT_PAL)
+    if (av_pix_fmt_desc_get(inlink->format)->flags & PIX_FMT_PAL)
         memcpy(inlink->dst->outputs[0]->out_buf->data[1], picref->data[1], AVPALETTE_SIZE);
 
     return ff_start_frame(outlink, avfilter_ref_buffer(outlink->out_buf, ~0));
diff --git a/libavfilter/vf_hue.c b/libavfilter/vf_hue.c
index 71d5cc8..7e421bd 100644
--- a/libavfilter/vf_hue.c
+++ b/libavfilter/vf_hue.c
@@ -252,7 +252,7 @@ static int query_formats(AVFilterContext *ctx)
 static int config_props(AVFilterLink *inlink)
 {
     HueContext *hue = inlink->dst->priv;
-    const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[inlink->format];
+    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
 
     hue->hsub = desc->log2_chroma_w;
     hue->vsub = desc->log2_chroma_h;
diff --git a/libavfilter/vf_idet.c b/libavfilter/vf_idet.c
index d64c48c..d7c6544 100644
--- a/libavfilter/vf_idet.c
+++ b/libavfilter/vf_idet.c
@@ -195,7 +195,7 @@ static int end_frame(AVFilterLink *link)
         return 0;
 
     if (!idet->csp)
-        idet->csp = &av_pix_fmt_descriptors[link->format];
+        idet->csp = av_pix_fmt_desc_get(link->format);
     if (idet->csp->comp[0].depth_minus1 / 8 == 1)
         idet->filter_line = (void*)filter_line_c_16bit;
 
diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index 4f2f423..f060684 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -217,7 +217,7 @@ static int config_input_overlay(AVFilterLink *inlink)
     char *expr;
     double var_values[VAR_VARS_NB], res;
     int ret;
-    const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[inlink->format];
+    const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
 
     av_image_fill_max_pixsteps(over->overlay_pix_step, NULL, pix_desc);
 
diff --git a/libavfilter/vf_smartblur.c b/libavfilter/vf_smartblur.c
index e1f27ec..0402d1a 100644
--- a/libavfilter/vf_smartblur.c
+++ b/libavfilter/vf_smartblur.c
@@ -169,7 +169,7 @@ static int alloc_sws_context(FilterParam *f, int width, int height, unsigned int
 static int config_props(AVFilterLink *inlink)
 {
     SmartblurContext *sblur = inlink->dst->priv;
-    const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[inlink->format];
+    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
 
     sblur->hsub = desc->log2_chroma_w;
     sblur->vsub = desc->log2_chroma_h;
diff --git a/libavfilter/vf_tinterlace.c b/libavfilter/vf_tinterlace.c
index 0bfccfb..99e3222 100644
--- a/libavfilter/vf_tinterlace.c
+++ b/libavfilter/vf_tinterlace.c
@@ -130,7 +130,7 @@ static int config_out_props(AVFilterLink *outlink)
 {
     AVFilterContext *ctx = outlink->src;
     AVFilterLink *inlink = outlink->src->inputs[0];
-    const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[outlink->format];
+    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(outlink->format);
     TInterlaceContext *tinterlace = ctx->priv;
 
     tinterlace->vsub = desc->log2_chroma_h;
@@ -179,7 +179,7 @@ void copy_picture_field(uint8_t *dst[4], int dst_linesize[4],
                         enum AVPixelFormat format, int w, int src_h,
                         int src_field, int interleave, int dst_field)
 {
-    const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[format];
+    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(format);
     int plane, vsub = desc->log2_chroma_h;
     int k = src_field == FIELD_UPPER_AND_LOWER ? 1 : 2;
 
diff --git a/libavfilter/video.c b/libavfilter/video.c
index 7a0cce9..4d8804b 100644
--- a/libavfilter/video.c
+++ b/libavfilter/video.c
@@ -286,7 +286,7 @@ int ff_start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
         avfilter_copy_buffer_ref_props(link->cur_buf, link->src_buf);
 
         /* copy palette if required */
-        if (av_pix_fmt_descriptors[link->format].flags & PIX_FMT_PAL)
+        if (av_pix_fmt_desc_get(link->format)->flags & PIX_FMT_PAL)
             memcpy(link->cur_buf->data[1], link->src_buf-> data[1], AVPALETTE_SIZE);
     }
     else
diff --git a/libavfilter/vsrc_mptestsrc.c b/libavfilter/vsrc_mptestsrc.c
index 9589b51..2b41637 100644
--- a/libavfilter/vsrc_mptestsrc.c
+++ b/libavfilter/vsrc_mptestsrc.c
@@ -298,7 +298,7 @@ static int config_props(AVFilterLink *outlink)
 {
     AVFilterContext *ctx = outlink->src;
     MPTestContext *test = ctx->priv;
-    const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[outlink->format];
+    const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(outlink->format);
 
     test->hsub = pix_desc->log2_chroma_w;
     test->vsub = pix_desc->log2_chroma_h;
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 9a7baab..b3f20cc 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -602,8 +602,8 @@ static av_always_inline int isRGB(enum AVPixelFormat pix_fmt)
 
 #if 0 // FIXME
 #define isGray(x) \
-    (!(av_pix_fmt_descriptors[x].flags & PIX_FMT_PAL) && \
-     av_pix_fmt_descriptors[x].nb_components <= 2)
+    (!(av_pix_fmt_desc_get(x)->flags & PIX_FMT_PAL) && \
+     av_pix_fmt_desc_get(x)->nb_components <= 2)
 #else
 #define isGray(x)                      \
     ((x) == AV_PIX_FMT_GRAY8       ||  \
diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c
index e6a0123..56ef3bc 100644
--- a/libswscale/x86/swscale.c
+++ b/libswscale/x86/swscale.c
@@ -402,7 +402,7 @@ av_cold void ff_sws_init_swScale_mmx(SwsContext *c)
     } else if (c->srcBpc == 12) { \
         hscalefn = c->dstBpc <= 14 ? ff_hscale12to15_ ## filtersize ## _ ## opt2 : \
                                      ff_hscale12to19_ ## filtersize ## _ ## opt1; \
-    } else if (c->srcBpc == 14 || ((c->srcFormat==AV_PIX_FMT_PAL8||isAnyRGB(c->srcFormat)) && av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1<15)) { \
+    } else if (c->srcBpc == 14 || ((c->srcFormat==AV_PIX_FMT_PAL8||isAnyRGB(c->srcFormat)) && av_pix_fmt_desc_get(c->srcFormat)->comp[0].depth_minus1<15)) { \
         hscalefn = c->dstBpc <= 14 ? ff_hscale14to15_ ## filtersize ## _ ## opt2 : \
                                      ff_hscale14to19_ ## filtersize ## _ ## opt1; \
     } else { /* c->srcBpc == 16 */ \
diff --git a/tools/fourcc2pixfmt.c b/tools/fourcc2pixfmt.c
index 6ee085b..8ea6c37 100644
--- a/tools/fourcc2pixfmt.c
+++ b/tools/fourcc2pixfmt.c
@@ -98,7 +98,7 @@ int main(int argc, char **argv)
 
     if (list_pix_fmt_fourccs) {
         for (i = 0; i < AV_PIX_FMT_NB; i++) {
-            const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[i];
+            const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(i);
             if (!pix_desc->name || pix_desc->flags & PIX_FMT_HWACCEL)
                 continue;
             printf("%s: ", pix_desc->name);
-- 
1.7.11.msysgit.1



More information about the ffmpeg-devel mailing list