This repository has been archived by the owner on Feb 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path0020-lavc-decode-Add-get_hw_config-function.patch
67 lines (61 loc) · 1.97 KB
/
0020-lavc-decode-Add-get_hw_config-function.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
From fb28c8ca006169f4b4fd1d55f32faad786be6202 Mon Sep 17 00:00:00 2001
From: Linjie Fu <[email protected]>
Date: Thu, 2 Jan 2020 11:06:45 +0800
Subject: [PATCH 20/28] lavc/decode: Add get_hw_config function
Wrap the procedure of getting the hardware config from a pixel format
into a function.
Signed-off-by: Linjie Fu <[email protected]>
---
libavcodec/decode.c | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 03b9da2..3e74759 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1367,6 +1367,26 @@ 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;
+ int i;
+
+ if (avctx->codec->hw_configs) {
+ for (i = 0;; i++) {
+ hw_config = avctx->codec->hw_configs[i];
+ if (!hw_config)
+ break;
+ if (hw_config->public.pix_fmt == fmt)
+ break;
+ }
+ } else {
+ hw_config = NULL;
+ }
+
+ return hw_config;
+}
+
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
{
const AVPixFmtDescriptor *desc;
@@ -1426,18 +1446,7 @@ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
break;
}
- if (avctx->codec->hw_configs) {
- for (i = 0;; i++) {
- hw_config = 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.7.4