Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH v2 1/3] lavc/decode: Warp get_hw_config function
@ 2022-08-18  2:25 Fei Wang
  2022-08-18  2:25 ` [FFmpeg-devel] [PATCH v2 2/3] lavc/decode: Add internal surface re-allocate method for hwaccel Fei Wang
  2022-08-18  2:25 ` [FFmpeg-devel] [PATCH v2 3/3] lavc/vaapi_vp9: add surface internal re-allocation capability Fei Wang
  0 siblings, 2 replies; 3+ messages in thread
From: Fei Wang @ 2022-08-18  2:25 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Fei Wang, Linjie Fu

From: Linjie Fu <linjie.fu@intel.com>

Wrap the procedure of getting the hardware config from a pixel format
into a function.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: Fei Wang <fei.w.wang@intel.com>
---
 libavcodec/decode.c | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 75373989c6..3b69426c09 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1156,6 +1156,24 @@ static void hwaccel_uninit(AVCodecContext *avctx)
     av_buffer_unref(&avctx->hw_frames_ctx);
 }
 
+static const AVCodecHWConfigInternal *get_hw_config(AVCodecContext *avctx, enum AVPixelFormat fmt)
+{
+    const AVCodecHWConfigInternal *hw_config;
+
+    if (!ffcodec(avctx->codec)->hw_configs)
+        return NULL;
+
+    for (int i = 0;; i++) {
+        hw_config = ffcodec(avctx->codec)->hw_configs[i];
+        if (!hw_config)
+            return NULL;
+        if (hw_config->public.pix_fmt == fmt)
+            return hw_config;
+    }
+
+    return NULL;
+}
+
 int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
 {
     const AVPixFmtDescriptor *desc;
@@ -1213,18 +1231,7 @@ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
             break;
         }
 
-        if (ffcodec(avctx->codec)->hw_configs) {
-            for (i = 0;; i++) {
-                hw_config = ffcodec(avctx->codec)->hw_configs[i];
-                if (!hw_config)
-                    break;
-                if (hw_config->public.pix_fmt == user_choice)
-                    break;
-            }
-        } else {
-            hw_config = NULL;
-        }
-
+        hw_config = get_hw_config(avctx, user_choice);
         if (!hw_config) {
             // No config available, so no extra setup required.
             ret = user_choice;
-- 
2.25.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-18  2:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-18  2:25 [FFmpeg-devel] [PATCH v2 1/3] lavc/decode: Warp get_hw_config function Fei Wang
2022-08-18  2:25 ` [FFmpeg-devel] [PATCH v2 2/3] lavc/decode: Add internal surface re-allocate method for hwaccel Fei Wang
2022-08-18  2:25 ` [FFmpeg-devel] [PATCH v2 3/3] lavc/vaapi_vp9: add surface internal re-allocation capability Fei Wang

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git