[FFmpeg-cvslog] hwaccel: Simplify ff_find_hwaccel

Luca Barbato git at videolan.org
Sun Nov 10 17:55:23 CET 2013


ffmpeg | branch: master | Luca Barbato <lu_zero at gentoo.org> | Sat Nov  9 17:07:34 2013 +0100| [08303d774132775d49d4ba767092de5d426f089d] | committer: Luca Barbato

hwaccel: Simplify ff_find_hwaccel

It is always called by passing fields from an AVCodecContext.

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

 libavcodec/h263dec.c   |    2 +-
 libavcodec/h264.c      |    2 +-
 libavcodec/internal.h  |    5 ++---
 libavcodec/mpeg12dec.c |    4 ++--
 libavcodec/utils.c     |    5 ++++-
 libavcodec/vc1dec.c    |    2 +-
 6 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 4c4a4c4..fceb217 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -108,7 +108,7 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
         return AVERROR(ENOSYS);
     }
     s->codec_id    = avctx->codec->id;
-    avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt);
+    avctx->hwaccel = ff_find_hwaccel(avctx);
 
     /* for h263, we allocate the images after having read the header */
     if (avctx->codec->id != AV_CODEC_ID_H263 &&
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index f0ef2eb..8faefbd 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -3144,7 +3144,7 @@ static int h264_slice_header_init(H264Context *h, int reinit)
                   h->sps.num_units_in_tick, den, 1 << 30);
     }
 
-    h->avctx->hwaccel = ff_find_hwaccel(h->avctx->codec->id, h->avctx->pix_fmt);
+    h->avctx->hwaccel = ff_find_hwaccel(h->avctx);
 
     if (reinit)
         free_tables(h, 0);
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 4648c02..c1108ff 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -105,11 +105,10 @@ struct AVCodecDefault {
  * Return the hardware accelerated codec for codec codec_id and
  * pixel format pix_fmt.
  *
- * @param codec_id the codec to match
- * @param pix_fmt the pixel format to match
+ * @param avctx The codec context containing the codec_id and pixel format.
  * @return the hardware accelerated codec, or NULL if none was found.
  */
-AVHWAccel *ff_find_hwaccel(enum AVCodecID codec_id, enum AVPixelFormat pix_fmt);
+AVHWAccel *ff_find_hwaccel(AVCodecContext *avctx);
 
 /**
  * Return the index into tab at which {a,b} match elements {[0],[1]} of tab.
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 53d1e0e..1713cfb 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1227,7 +1227,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
         } // MPEG-2
 
         avctx->pix_fmt = mpeg_get_pixelformat(avctx);
-        avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt);
+        avctx->hwaccel = ff_find_hwaccel(avctx);
         // until then pix_fmt may be changed right after codec init
         if (avctx->pix_fmt == AV_PIX_FMT_XVMC_MPEG2_IDCT ||
             avctx->hwaccel)
@@ -1988,7 +1988,7 @@ static int vcr2_init_sequence(AVCodecContext *avctx)
     s->low_delay = 1;
 
     avctx->pix_fmt = mpeg_get_pixelformat(avctx);
-    avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt);
+    avctx->hwaccel = ff_find_hwaccel(avctx);
 
     if (avctx->pix_fmt == AV_PIX_FMT_XVMC_MPEG2_IDCT || avctx->hwaccel)
         if (avctx->idct_algo == FF_IDCT_AUTO)
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index da519b5..2f5c170 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -2137,8 +2137,11 @@ AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel)
     return hwaccel ? hwaccel->next : first_hwaccel;
 }
 
-AVHWAccel *ff_find_hwaccel(enum AVCodecID codec_id, enum AVPixelFormat pix_fmt)
+AVHWAccel *ff_find_hwaccel(AVCodecContext *avctx)
 {
+    enum AVCodecID codec_id = avctx->codec->id;
+    enum AVPixelFormat pix_fmt = avctx->pix_fmt;
+
     AVHWAccel *hwaccel = NULL;
 
     while ((hwaccel = av_hwaccel_next(hwaccel)))
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index caedfd8..231f425 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -5580,7 +5580,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
         avctx->pix_fmt = avctx->get_format(avctx, avctx->codec->pix_fmts);
     else
         avctx->pix_fmt = AV_PIX_FMT_GRAY8;
-    avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt);
+    avctx->hwaccel = ff_find_hwaccel(avctx);
     v->s.avctx = avctx;
     avctx->flags |= CODEC_FLAG_EMU_EDGE;
     v->s.flags   |= CODEC_FLAG_EMU_EDGE;



More information about the ffmpeg-cvslog mailing list