[FFmpeg-devel] [PATCH] split out ff_hwaccel_pixfmt_list_420[] over individual codecs.

Ronald S. Bultje rsbultje at gmail.com
Mon Feb 18 17:15:52 CET 2013


From: "Ronald S. Bultje" <rsbultje at gmail.com>

Not all hwaccels implement all codecs, so using one single list for
multiple such codecs means some codecs will be represented in the list,
even though they don't actually handle that codec. Copying specific
lists in each codec fixes that.
---
 libavcodec/h263.h          |  2 ++
 libavcodec/h263dec.c       | 15 +++++++++++++--
 libavcodec/h264.c          | 19 ++++++++++++++++++-
 libavcodec/mpeg4videodec.c |  2 +-
 libavcodec/mpegvideo.c     | 17 -----------------
 libavcodec/mpegvideo.h     |  1 -
 libavcodec/vc1dec.c        | 18 ++++++++++++++++--
 7 files changed, 50 insertions(+), 24 deletions(-)

diff --git a/libavcodec/h263.h b/libavcodec/h263.h
index 28d59ec..ccbccbc 100644
--- a/libavcodec/h263.h
+++ b/libavcodec/h263.h
@@ -207,4 +207,6 @@ static inline void memsetw(short *tab, int val, int n)
         tab[i] = val;
 }
 
+extern const enum AVPixelFormat h263_hwaccel_pixfmt_list_420[];
+
 #endif /* AVCODEC_H263_H */
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 6b24880..dd56e11 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -763,6 +763,17 @@ av_log(avctx, AV_LOG_DEBUG, "%"PRId64"\n", rdtsc()-time);
     return (ret && (avctx->err_recognition & AV_EF_EXPLODE))?ret:get_consumed_bytes(s, buf_size);
 }
 
+const enum AVPixelFormat h263_hwaccel_pixfmt_list_420[] = {
+#if CONFIG_VAAPI
+    AV_PIX_FMT_VAAPI_VLD,
+#endif
+#if CONFIG_VDPAU
+    AV_PIX_FMT_VDPAU,
+#endif
+    AV_PIX_FMT_YUV420P,
+    AV_PIX_FMT_NONE
+};
+
 AVCodec ff_h263_decoder = {
     .name           = "h263",
     .type           = AVMEDIA_TYPE_VIDEO,
@@ -776,7 +787,7 @@ AVCodec ff_h263_decoder = {
     .flush          = ff_mpeg_flush,
     .max_lowres     = 3,
     .long_name      = NULL_IF_CONFIG_SMALL("H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2"),
-    .pix_fmts       = ff_hwaccel_pixfmt_list_420,
+    .pix_fmts       = h263_hwaccel_pixfmt_list_420,
 };
 
 AVCodec ff_h263p_decoder = {
@@ -792,5 +803,5 @@ AVCodec ff_h263p_decoder = {
     .flush          = ff_mpeg_flush,
     .max_lowres     = 3,
     .long_name      = NULL_IF_CONFIG_SMALL("H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2"),
-    .pix_fmts       = ff_hwaccel_pixfmt_list_420,
+    .pix_fmts       = h263_hwaccel_pixfmt_list_420,
 };
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 8a8e606..c7a73a8 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -68,6 +68,23 @@ static const uint8_t div6[QP_MAX_NUM + 1] = {
    14,14,14,14,
 };
 
+static const enum AVPixelFormat hwaccel_pixfmt_list_h264_420[] = {
+#if CONFIG_H264_DXVA2_HWACCEL
+    AV_PIX_FMT_DXVA2_VLD,
+#endif
+#if CONFIG_H264_VAAPI_HWACCEL
+    AV_PIX_FMT_VAAPI_VLD,
+#endif
+#if CONFIG_H264_VDA_HWACCEL
+    AV_PIX_FMT_VDA_VLD,
+#endif
+#if CONFIG_H264_VDPAU_HWACCEL
+    AV_PIX_FMT_VDPAU,
+#endif
+    AV_PIX_FMT_YUV420P,
+    AV_PIX_FMT_NONE
+};
+
 static const enum AVPixelFormat hwaccel_pixfmt_list_h264_jpeg_420[] = {
 #if CONFIG_H264_DXVA2_HWACCEL
     AV_PIX_FMT_DXVA2_VLD,
@@ -2932,7 +2949,7 @@ static enum PixelFormat get_pixel_format(H264Context *h)
                                         h->avctx->codec->pix_fmts :
                                         h->avctx->color_range == AVCOL_RANGE_JPEG ?
                                         hwaccel_pixfmt_list_h264_jpeg_420 :
-                                        ff_hwaccel_pixfmt_list_420;
+                                        hwaccel_pixfmt_list_h264_420;
 
             for (i=0; fmt[i] != AV_PIX_FMT_NONE; i++)
                 if (fmt[i] == h->avctx->pix_fmt)
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index cdb1f97..4820e35 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -2359,7 +2359,7 @@ AVCodec ff_mpeg4_decoder = {
     .flush                 = ff_mpeg_flush,
     .max_lowres            = 3,
     .long_name             = NULL_IF_CONFIG_SMALL("MPEG-4 part 2"),
-    .pix_fmts              = ff_hwaccel_pixfmt_list_420,
+    .pix_fmts              = h263_hwaccel_pixfmt_list_420,
     .profiles              = NULL_IF_CONFIG_SMALL(mpeg4_video_profiles),
     .update_thread_context = ONLY_IF_THREADS_ENABLED(ff_mpeg_update_thread_context),
     .priv_class = &mpeg4_class,
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index c031c84..7660719 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -128,23 +128,6 @@ const enum AVPixelFormat ff_pixfmt_list_420[] = {
     AV_PIX_FMT_NONE
 };
 
-const enum AVPixelFormat ff_hwaccel_pixfmt_list_420[] = {
-#if CONFIG_DXVA2
-    AV_PIX_FMT_DXVA2_VLD,
-#endif
-#if CONFIG_VAAPI
-    AV_PIX_FMT_VAAPI_VLD,
-#endif
-#if CONFIG_VDA
-    AV_PIX_FMT_VDA_VLD,
-#endif
-#if CONFIG_VDPAU
-    AV_PIX_FMT_VDPAU,
-#endif
-    AV_PIX_FMT_YUV420P,
-    AV_PIX_FMT_NONE
-};
-
 static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
                               int (*mv)[2][4][2],
                               int mb_x, int mb_y, int mb_intra, int mb_skipped)
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 23b80ed..4d6487d 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -817,7 +817,6 @@ void ff_MPV_motion(MpegEncContext *s,
 int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared);
 
 extern const enum AVPixelFormat ff_pixfmt_list_420[];
-extern const enum AVPixelFormat ff_hwaccel_pixfmt_list_420[];
 
 /**
  * permute block according to permuatation.
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 33f7426..a3476fd 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -5789,6 +5789,20 @@ static const AVProfile profiles[] = {
     { FF_PROFILE_UNKNOWN },
 };
 
+static const enum AVPixelFormat vc1_hwaccel_pixfmt_list_420[] = {
+#if CONFIG_DXVA2
+    AV_PIX_FMT_DXVA2_VLD,
+#endif
+#if CONFIG_VAAPI
+    AV_PIX_FMT_VAAPI_VLD,
+#endif
+#if CONFIG_VDPAU
+    AV_PIX_FMT_VDPAU,
+#endif
+    AV_PIX_FMT_YUV420P,
+    AV_PIX_FMT_NONE
+};
+
 AVCodec ff_vc1_decoder = {
     .name           = "vc1",
     .type           = AVMEDIA_TYPE_VIDEO,
@@ -5800,7 +5814,7 @@ AVCodec ff_vc1_decoder = {
     .flush          = ff_mpeg_flush,
     .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_DELAY,
     .long_name      = NULL_IF_CONFIG_SMALL("SMPTE VC-1"),
-    .pix_fmts       = ff_hwaccel_pixfmt_list_420,
+    .pix_fmts       = vc1_hwaccel_pixfmt_list_420,
     .profiles       = NULL_IF_CONFIG_SMALL(profiles)
 };
 
@@ -5816,7 +5830,7 @@ AVCodec ff_wmv3_decoder = {
     .flush          = ff_mpeg_flush,
     .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_DELAY,
     .long_name      = NULL_IF_CONFIG_SMALL("Windows Media Video 9"),
-    .pix_fmts       = ff_hwaccel_pixfmt_list_420,
+    .pix_fmts       = vc1_hwaccel_pixfmt_list_420,
     .profiles       = NULL_IF_CONFIG_SMALL(profiles)
 };
 #endif
-- 
1.7.11.3



More information about the ffmpeg-devel mailing list