|
| 1 | +From 126671e73065e29c9582e47bc74774af2200fc8f Mon Sep 17 00:00:00 2001 |
1 | 2 | From: Cameron Gutman <aicommander@gmail.com> |
2 | | -To: ffmpeg-devel@ffmpeg.org |
3 | | -Date: Sat, 2 Aug 2025 23:55:25 -0500 |
4 | | -Message-ID: <20250803045559.1351-1-aicommander@gmail.com> |
5 | | -X-Mailer: git-send-email 2.50.1.windows.1 |
6 | | -MIME-Version: 1.0 |
7 | | -Subject: [FFmpeg-devel] [PATCH] avcodec/mfenc: add low_latency encoder |
8 | | - parameter |
9 | | -X-BeenThere: ffmpeg-devel@ffmpeg.org |
10 | | -X-Mailman-Version: 2.1.29 |
11 | | -Precedence: list |
12 | | -List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org> |
13 | | -List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>, |
14 | | - <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe> |
15 | | -List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel> |
16 | | -List-Post: <mailto:ffmpeg-devel@ffmpeg.org> |
17 | | -List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help> |
18 | | -List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>, |
19 | | - <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe> |
20 | | -Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> |
21 | | -Cc: Conn O'Griofa <connogriofa@gmail.com> |
22 | | -Errors-To: ffmpeg-devel-bounces@ffmpeg.org |
23 | | -Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org> |
| 3 | +Date: Sun, 31 Aug 2025 16:05:15 -0500 |
| 4 | +Subject: [PATCH] avcodec/mfenc: add AVLowLatencyMode support |
24 | 5 |
|
25 | | -Implement support for CODECAPI_AVLowLatencyMode property, which is |
26 | | -useful for live streaming use cases (and cannot be achieved by |
27 | | -selecting any of the low latency "scenario" encoder presets alone). |
| 6 | +Set CODECAPI_AVLowLatencyMode when AV_CODEC_FLAG_LOW_DELAY is enabled on |
| 7 | +the AVCodecContext. AVLowLatencyMode can acheive lower latency encoding |
| 8 | +that may not be accessible using eAVScenarioInfo options alone. |
28 | 9 |
|
29 | | -Co-authored-by: Conn O'Griofa <connogriofa@gmail.com> |
30 | 10 | Signed-off-by: Cameron Gutman <aicommander@gmail.com> |
31 | 11 | --- |
32 | | - libavcodec/mfenc.c | 5 +++++ |
33 | | - 1 file changed, 5 insertions(+) |
| 12 | + libavcodec/mfenc.c | 3 +++ |
| 13 | + 1 file changed, 3 insertions(+) |
34 | 14 |
|
35 | 15 | diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c |
36 | | -index 30531fe3e8..e84ce7bde0 100644 |
| 16 | +index 6f79386404502..541f7fb9612af 100644 |
37 | 17 | --- a/libavcodec/mfenc.c |
38 | 18 | +++ b/libavcodec/mfenc.c |
39 | | -@@ -64,6 +64,7 @@ typedef struct MFContext { |
40 | | - int opt_enc_quality; |
41 | | - int opt_enc_scenario; |
42 | | - int opt_enc_hw; |
43 | | -+ int opt_enc_lowlatency; |
44 | | - AVD3D11VADeviceContext* device_hwctx; |
45 | | - } MFContext; |
46 | | - |
47 | | -@@ -866,6 +867,9 @@ static int mf_encv_output_adjust(AVCodecContext *avctx, IMFMediaType *type) |
48 | | - |
| 19 | +@@ -876,6 +876,9 @@ static int mf_encv_output_adjust(AVCodecContext *avctx, IMFMediaType *type) |
| 20 | + |
49 | 21 | if (c->opt_enc_scenario >= 0) |
50 | 22 | ICodecAPI_SetValue(c->codec_api, &ff_CODECAPI_AVScenarioInfo, FF_VAL_VT_UI4(c->opt_enc_scenario)); |
51 | 23 | + |
52 | | -+ if (c->opt_enc_lowlatency) |
| 24 | ++ if (avctx->flags & AV_CODEC_FLAG_LOW_DELAY) |
53 | 25 | + ICodecAPI_SetValue(c->codec_api, &ff_CODECAPI_AVLowLatencyMode, FF_VAL_VT_UI4(1)); |
54 | 26 | } |
55 | | - |
| 27 | + |
56 | 28 | return 0; |
57 | | -@@ -1445,6 +1449,7 @@ static const AVOption venc_opts[] = { |
58 | | - |
59 | | - {"quality", "Quality", OFFSET(opt_enc_quality), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 100, VE}, |
60 | | - {"hw_encoding", "Force hardware encoding", OFFSET(opt_enc_hw), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, VE}, |
61 | | -+ {"low_latency", "Low latency mode", OFFSET(opt_enc_lowlatency), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, VE}, |
62 | | - {NULL} |
63 | | - }; |
64 | | - |
0 commit comments