fix qsv memory leak by updating ffmpeg (#9266)

* fix qsv memory leak by updating ffmpeg

* Memory leaks occur when destroying FFmpeg QSV VRAM encoders. This issue is resolved with FFmpeg version 7.
* FFmpeg requires ffnvcodec version 12.1.14.0 or higher, and an NVIDIA driver version greater than 530. For more details, https://github.com/FFmpeg/nv-codec-headers/tree/n12.1.14.0.
* The code of NVIDIA VRAM encoder is not changed, still use Video Codec SDK version 11, which is unaffected by FFmpeg. Drivers newer than 470 can support this, but we may consider an update later, as the support check by sdk code may not be accurate for FFmpeg RAM encoders.
* The issue is related to FFmpeg, not libmfx. FFmpeg version 7 recommends using libvpl, but vcpkg currently lacks ports for libvpl. We can add these in the future.
* D3D11 Texture Rendering: The "Shared GPU Memory" in the task manager continue increasing when using D3D11 texture render, which can exceed the GPU memory limit (e.g., reaching up to 100GB). I don't know what it is and will try to find it out.
* Roughly tests on Windows, Linux, macOS, and Android for quick fix. Further testing will be performed, and I will share the results in this pr.

Signed-off-by: 21pages <sunboeasy@gmail.com>

* update flutter_gpu_texture_render, fix shared gpu memory leak while
rendering

Signed-off-by: 21pages <sunboeasy@gmail.com>

---------

Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
21pages 2024-09-07 10:20:52 +08:00 committed by GitHub
parent f0ca4b9fee
commit a4cd64f0d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 82 additions and 226 deletions

2
Cargo.lock generated
View File

@ -3045,7 +3045,7 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "hwcodec"
version = "0.7.0"
source = "git+https://github.com/rustdesk-org/hwcodec#b78a69c81631dd9ccfed9df68709808193082242"
source = "git+https://github.com/rustdesk-org/hwcodec#9e8b6efd8e5d904b5325597a271ebe78f5a74f3b"
dependencies = [
"bindgen 0.59.2",
"cc",

View File

@ -525,8 +525,8 @@ packages:
dependency: "direct main"
description:
path: "."
ref: "38951317afe79d953ab25733667bd96e172a80d3"
resolved-ref: "38951317afe79d953ab25733667bd96e172a80d3"
ref: "2ded7f146437a761ffe6981e2f742038f85ca68d"
resolved-ref: "2ded7f146437a761ffe6981e2f742038f85ca68d"
url: "https://github.com/rustdesk-org/flutter_gpu_texture_renderer"
source: git
version: "0.0.1"

View File

@ -93,7 +93,7 @@ dependencies:
flutter_gpu_texture_renderer:
git:
url: https://github.com/rustdesk-org/flutter_gpu_texture_renderer
ref: 38951317afe79d953ab25733667bd96e172a80d3
ref: 2ded7f146437a761ffe6981e2f742038f85ca68d
uuid: ^3.0.7
auto_size_text_field: ^2.2.1
flex_color_picker: ^3.3.0

View File

@ -1,95 +0,0 @@
From afe89a70f6bc7ebd0a6a0a31101801b88cbd60ee Mon Sep 17 00:00:00 2001
From: 21pages <pages21@163.com>
Date: Sun, 5 May 2024 12:45:23 +0800
Subject: [PATCH] use release/7.0's update_bitrate
Signed-off-by: 21pages <pages21@163.com>
---
libavcodec/qsvenc.c | 39 +++++++++++++++++++++++++++++++++++++++
libavcodec/qsvenc.h | 6 ++++++
2 files changed, 45 insertions(+)
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 2382c2f5f7..9b34f37eb3 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -714,6 +714,11 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
brc_param_multiplier = (FFMAX(FFMAX3(target_bitrate_kbps, max_bitrate_kbps, buffer_size_in_kilobytes),
initial_delay_in_kilobytes) + 0x10000) / 0x10000;
+ q->old_rc_buffer_size = avctx->rc_buffer_size;
+ q->old_rc_initial_buffer_occupancy = avctx->rc_initial_buffer_occupancy;
+ q->old_bit_rate = avctx->bit_rate;
+ q->old_rc_max_rate = avctx->rc_max_rate;
+
switch (q->param.mfx.RateControlMethod) {
case MFX_RATECONTROL_CBR:
case MFX_RATECONTROL_VBR:
@@ -1657,6 +1662,39 @@ static int update_qp(AVCodecContext *avctx, QSVEncContext *q,
return updated;
}
+static int update_bitrate(AVCodecContext *avctx, QSVEncContext *q)
+{
+ int updated = 0;
+ int target_bitrate_kbps, max_bitrate_kbps, brc_param_multiplier;
+ int buffer_size_in_kilobytes, initial_delay_in_kilobytes;
+
+ UPDATE_PARAM(q->old_rc_buffer_size, avctx->rc_buffer_size);
+ UPDATE_PARAM(q->old_rc_initial_buffer_occupancy, avctx->rc_initial_buffer_occupancy);
+ UPDATE_PARAM(q->old_bit_rate, avctx->bit_rate);
+ UPDATE_PARAM(q->old_rc_max_rate, avctx->rc_max_rate);
+ if (!updated)
+ return 0;
+
+ buffer_size_in_kilobytes = avctx->rc_buffer_size / 8000;
+ initial_delay_in_kilobytes = avctx->rc_initial_buffer_occupancy / 8000;
+ target_bitrate_kbps = avctx->bit_rate / 1000;
+ max_bitrate_kbps = avctx->rc_max_rate / 1000;
+ brc_param_multiplier = (FFMAX(FFMAX3(target_bitrate_kbps, max_bitrate_kbps, buffer_size_in_kilobytes),
+ initial_delay_in_kilobytes) + 0x10000) / 0x10000;
+
+ q->param.mfx.BufferSizeInKB = buffer_size_in_kilobytes / brc_param_multiplier;
+ q->param.mfx.InitialDelayInKB = initial_delay_in_kilobytes / brc_param_multiplier;
+ q->param.mfx.TargetKbps = target_bitrate_kbps / brc_param_multiplier;
+ q->param.mfx.MaxKbps = max_bitrate_kbps / brc_param_multiplier;
+ q->param.mfx.BRCParamMultiplier = brc_param_multiplier;
+ av_log(avctx, AV_LOG_VERBOSE,
+ "Reset BufferSizeInKB: %d; InitialDelayInKB: %d; "
+ "TargetKbps: %d; MaxKbps: %d; BRCParamMultiplier: %d\n",
+ q->param.mfx.BufferSizeInKB, q->param.mfx.InitialDelayInKB,
+ q->param.mfx.TargetKbps, q->param.mfx.MaxKbps, q->param.mfx.BRCParamMultiplier);
+ return updated;
+}
+
static int update_parameters(AVCodecContext *avctx, QSVEncContext *q,
const AVFrame *frame)
{
@@ -1666,6 +1704,7 @@ static int update_parameters(AVCodecContext *avctx, QSVEncContext *q,
return 0;
needReset = update_qp(avctx, q, frame);
+ needReset |= update_bitrate(avctx, q);
if (!needReset)
return 0;
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index b754ac4b56..5745533165 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -224,6 +224,12 @@ typedef struct QSVEncContext {
int min_qp_p;
int max_qp_b;
int min_qp_b;
+
+ // These are used for bitrate control reset
+ int old_bit_rate;
+ int old_rc_buffer_size;
+ int old_rc_initial_buffer_occupancy;
+ int old_rc_max_rate;
} QSVEncContext;
int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q);
--
2.43.0.windows.1

View File

@ -1,40 +0,0 @@
From be3d9d8092720bbe4239212648d2e9c4ffd7f40c Mon Sep 17 00:00:00 2001
From: 21pages <pages21@163.com>
Date: Wed, 22 May 2024 17:09:28 +0800
Subject: [PATCH] android mediacodec encode align 64
Signed-off-by: 21pages <pages21@163.com>
---
libavcodec/mediacodecenc.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c
index 984014f1b1..8dcd3dcd64 100644
--- a/libavcodec/mediacodecenc.c
+++ b/libavcodec/mediacodecenc.c
@@ -200,16 +200,17 @@ static av_cold int mediacodec_init(AVCodecContext *avctx)
ff_AMediaFormat_setString(format, "mime", codec_mime);
// Workaround the alignment requirement of mediacodec. We can't do it
// silently for AV_PIX_FMT_MEDIACODEC.
+ const int align = 64;
if (avctx->pix_fmt != AV_PIX_FMT_MEDIACODEC) {
- s->width = FFALIGN(avctx->width, 16);
- s->height = FFALIGN(avctx->height, 16);
+ s->width = FFALIGN(avctx->width, align);
+ s->height = FFALIGN(avctx->height, align);
} else {
s->width = avctx->width;
s->height = avctx->height;
- if (s->width % 16 || s->height % 16)
+ if (s->width % align || s->height % align)
av_log(avctx, AV_LOG_WARNING,
- "Video size %dx%d isn't align to 16, it may have device compatibility issue\n",
- s->width, s->height);
+ "Video size %dx%d isn't align to %d, it may have device compatibility issue\n",
+ s->width, s->height, align);
}
ff_AMediaFormat_setInt32(format, "width", s->width);
ff_AMediaFormat_setInt32(format, "height", s->height);
--
2.34.1

View File

@ -1,9 +1,9 @@
From f0b694749b38b2cfd94df4eed10e667342c234e5 Mon Sep 17 00:00:00 2001
From: 21pages <pages21@163.com>
Date: Sat, 24 Feb 2024 15:33:24 +0800
Subject: [PATCH 1/2] avcodec/amfenc: add query_timeout option for h264/hevc
From f6988e5424e041ff6f6e241f4d8fa69a04c05e64 Mon Sep 17 00:00:00 2001
From: 21pages <sunboeasy@gmail.com>
Date: Thu, 5 Sep 2024 16:26:20 +0800
Subject: [PATCH 1/3] avcodec/amfenc: add query_timeout option for h264/hevc
Signed-off-by: 21pages <pages21@163.com>
Signed-off-by: 21pages <sunboeasy@gmail.com>
---
libavcodec/amfenc.h | 1 +
libavcodec/amfenc_h264.c | 4 ++++
@ -11,10 +11,10 @@ Signed-off-by: 21pages <pages21@163.com>
3 files changed, 9 insertions(+)
diff --git a/libavcodec/amfenc.h b/libavcodec/amfenc.h
index 1ab98d2f78..e92120ea39 100644
index 2dbd378ef8..d636673a9d 100644
--- a/libavcodec/amfenc.h
+++ b/libavcodec/amfenc.h
@@ -87,6 +87,7 @@ typedef struct AmfContext {
@@ -89,6 +89,7 @@ typedef struct AmfContext {
int quality;
int b_frame_delta_qp;
int ref_b_frame_delta_qp;
@ -23,40 +23,40 @@ index 1ab98d2f78..e92120ea39 100644
// Dynamic options, can be set after Init() call
diff --git a/libavcodec/amfenc_h264.c b/libavcodec/amfenc_h264.c
index efb04589f6..f55dbc80f0 100644
index c1d5f4054e..415828f005 100644
--- a/libavcodec/amfenc_h264.c
+++ b/libavcodec/amfenc_h264.c
@@ -121,6 +121,7 @@ static const AVOption options[] = {
@@ -135,6 +135,7 @@ static const AVOption options[] = {
{ "aud", "Inserts AU Delimiter NAL unit", OFFSET(aud) ,AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
{ "log_to_dbg", "Enable AMF logging to debug output", OFFSET(log_to_dbg) , AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
+ { "query_timeout", "Timeout for QueryOutput call in ms", OFFSET(query_timeout), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, 1000, VE },
{ NULL }
};
@@ -155,6 +156,9 @@ static av_cold int amf_encode_init_h264(AVCodecContext *avctx)
//Pre Analysis options
{ "preanalysis", "Enable preanalysis", OFFSET(preanalysis), AV_OPT_TYPE_BOOL, {.i64 = -1 }, -1, 1, VE },
@@ -222,6 +223,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
AMF_ASSIGN_PROPERTY_RATE(res, ctx->encoder, AMF_VIDEO_ENCODER_FRAMERATE, framerate);
+ if (ctx->query_timeout >= 0)
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_QUERY_TIMEOUT, ctx->query_timeout);
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_QUERY_TIMEOUT, ctx->query_timeout);
+
switch (avctx->profile) {
case FF_PROFILE_H264_BASELINE:
case AV_PROFILE_H264_BASELINE:
profile = AMF_VIDEO_ENCODER_PROFILE_BASELINE;
diff --git a/libavcodec/amfenc_hevc.c b/libavcodec/amfenc_hevc.c
index 8ab9330730..7a40bcad31 100644
index 33a167aa52..65259d7153 100644
--- a/libavcodec/amfenc_hevc.c
+++ b/libavcodec/amfenc_hevc.c
@@ -89,6 +89,7 @@ static const AVOption options[] = {
@@ -98,6 +98,7 @@ static const AVOption options[] = {
{ "aud", "Inserts AU Delimiter NAL unit", OFFSET(aud) ,AV_OPT_TYPE_BOOL,{ .i64 = 0 }, 0, 1, VE },
{ "log_to_dbg", "Enable AMF logging to debug output", OFFSET(log_to_dbg), AV_OPT_TYPE_BOOL,{ .i64 = 0 }, 0, 1, VE },
+ { "query_timeout", "Timeout for QueryOutput call in ms", OFFSET(query_timeout), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, 1000, VE },
{ NULL }
};
@@ -122,6 +123,9 @@ static av_cold int amf_encode_init_hevc(AVCodecContext *avctx)
//Pre Analysis options
{ "preanalysis", "Enable preanalysis", OFFSET(preanalysis), AV_OPT_TYPE_BOOL, {.i64 = -1 }, -1, 1, VE },
@@ -183,6 +184,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
AMF_ASSIGN_PROPERTY_RATE(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_FRAMERATE, framerate);
@ -64,7 +64,7 @@ index 8ab9330730..7a40bcad31 100644
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_QUERY_TIMEOUT, ctx->query_timeout);
+
switch (avctx->profile) {
case FF_PROFILE_HEVC_MAIN:
case AV_PROFILE_HEVC_MAIN:
profile = AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN;
--
2.43.0.windows.1

View File

@ -1,16 +1,16 @@
From 4d0d20d96ad458cfec0444b9be0182ca6085ee0c Mon Sep 17 00:00:00 2001
From: 21pages <pages21@163.com>
Date: Sat, 24 Feb 2024 16:02:44 +0800
Subject: [PATCH 2/2] libavcodec/amfenc: reconfig when bitrate change
From 6e76c57cf2c0e790228f19c88089eef110fd74aa Mon Sep 17 00:00:00 2001
From: 21pages <sunboeasy@gmail.com>
Date: Thu, 5 Sep 2024 16:32:16 +0800
Subject: [PATCH 2/3] libavcodec/amfenc: reconfig when bitrate change
Signed-off-by: 21pages <pages21@163.com>
Signed-off-by: 21pages <sunboeasy@gmail.com>
---
libavcodec/amfenc.c | 20 ++++++++++++++++++++
libavcodec/amfenc.h | 1 +
2 files changed, 21 insertions(+)
diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c
index a033e1220e..3eab01a903 100644
index 061859f85c..97587fe66b 100644
--- a/libavcodec/amfenc.c
+++ b/libavcodec/amfenc.c
@@ -222,6 +222,7 @@ static int amf_init_context(AVCodecContext *avctx)
@ -21,7 +21,7 @@ index a033e1220e..3eab01a903 100644
// configure AMF logger
// the return of these functions indicates old state and do not affect behaviour
@@ -575,6 +576,23 @@ static void amf_release_buffer_with_frame_ref(AMFBuffer *frame_ref_storage_buffe
@@ -583,6 +584,23 @@ static void amf_release_buffer_with_frame_ref(AMFBuffer *frame_ref_storage_buffe
frame_ref_storage_buffer->pVtbl->Release(frame_ref_storage_buffer);
}
@ -45,9 +45,9 @@ index a033e1220e..3eab01a903 100644
int ff_amf_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
{
AmfContext *ctx = avctx->priv_data;
@@ -586,6 +604,8 @@ int ff_amf_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
AVFrame *frame = ctx->delayed_frame;
int block_and_wait;
@@ -596,6 +614,8 @@ int ff_amf_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
int query_output_data_flag = 0;
AMF_RESULT res_resubmit;
+ reconfig_encoder(avctx);
+
@ -55,13 +55,13 @@ index a033e1220e..3eab01a903 100644
return AVERROR(EINVAL);
diff --git a/libavcodec/amfenc.h b/libavcodec/amfenc.h
index e92120ea39..31172645f2 100644
index d636673a9d..09506ee2e0 100644
--- a/libavcodec/amfenc.h
+++ b/libavcodec/amfenc.h
@@ -107,6 +107,7 @@ typedef struct AmfContext {
int me_half_pel;
int me_quarter_pel;
int aud;
@@ -113,6 +113,7 @@ typedef struct AmfContext {
int max_b_frames;
int qvbr_quality_level;
int hw_high_motion_quality_boost;
+ int64_t av_bitrate;
// HEVC - specific options

View File

@ -1,32 +1,32 @@
From 8fd62e4ecd058b09abf8847be5fbbf0eef44a90f Mon Sep 17 00:00:00 2001
From 14b77216106eaaff9cf701528039ae4264eaf420 Mon Sep 17 00:00:00 2001
From: 21pages <sunboeasy@gmail.com>
Date: Tue, 16 Jul 2024 14:58:33 +0800
Subject: [PATCH] amf colorspace
Date: Thu, 5 Sep 2024 16:41:59 +0800
Subject: [PATCH 3/3] amf colorspace
Signed-off-by: 21pages <sunboeasy@gmail.com>
---
libavcodec/amfenc.h | 1 +
libavcodec/amfenc_h264.c | 39 +++++++++++++++++++++++++++++++++
libavcodec/amfenc_h264.c | 40 ++++++++++++++++++++++++++++++++++
libavcodec/amfenc_hevc.c | 47 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 87 insertions(+)
3 files changed, 88 insertions(+)
diff --git a/libavcodec/amfenc.h b/libavcodec/amfenc.h
index 31172645f2..493e01603d 100644
index 09506ee2e0..7f458b14f7 100644
--- a/libavcodec/amfenc.h
+++ b/libavcodec/amfenc.h
@@ -23,6 +23,7 @@
@@ -24,6 +24,7 @@
#include <AMF/components/VideoEncoderVCE.h>
#include <AMF/components/VideoEncoderHEVC.h>
#include <AMF/components/VideoEncoderAV1.h>
+#include <AMF/components/ColorSpace.h>
#include "libavutil/fifo.h"
diff --git a/libavcodec/amfenc_h264.c b/libavcodec/amfenc_h264.c
index f55dbc80f0..5a6b6e164f 100644
index 415828f005..7da5a96c71 100644
--- a/libavcodec/amfenc_h264.c
+++ b/libavcodec/amfenc_h264.c
@@ -139,6 +139,9 @@ static av_cold int amf_encode_init_h264(AVCodecContext *avctx)
@@ -200,6 +200,9 @@ static av_cold int amf_encode_init_h264(AVCodecContext *avctx)
AMFRate framerate;
AMFSize framesize = AMFConstructSize(avctx->width, avctx->height);
int deblocking_filter = (avctx->flags & AV_CODEC_FLAG_LOOP_FILTER) ? 1 : 0;
@ -36,7 +36,7 @@ index f55dbc80f0..5a6b6e164f 100644
if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
framerate = AMFConstructRate(avctx->framerate.num, avctx->framerate.den);
@@ -199,11 +202,47 @@ static av_cold int amf_encode_init_h264(AVCodecContext *avctx)
@@ -266,10 +269,47 @@ FF_ENABLE_DEPRECATION_WARNINGS
AMF_ASSIGN_PROPERTY_RATIO(res, ctx->encoder, AMF_VIDEO_ENCODER_ASPECT_RATIO, ratio);
}
@ -70,25 +70,25 @@ index f55dbc80f0..5a6b6e164f 100644
+ color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_2020;
+ break;
+ }
+ }
}
+ pix_fmt = avctx->hw_frames_ctx ? ((AVHWFramesContext*)avctx->hw_frames_ctx->data)->sw_format : avctx->pix_fmt;
+ color_depth = AMF_COLOR_BIT_DEPTH_8;
+ if (pix_fmt == AV_PIX_FMT_P010) {
+ color_depth = AMF_COLOR_BIT_DEPTH_10;
}
+ }
+
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_COLOR_BIT_DEPTH, color_depth);
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_OUTPUT_COLOR_PROFILE, color_profile);
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_OUTPUT_TRANSFER_CHARACTERISTIC, (amf_int64)avctx->color_trc);
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_OUTPUT_COLOR_PRIMARIES, (amf_int64)avctx->color_primaries);
// autodetect rate control method
if (ctx->rate_control_mode == AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_UNKNOWN) {
if (ctx->qp_i != -1 || ctx->qp_p != -1 || ctx->qp_b != -1) {
diff --git a/libavcodec/amfenc_hevc.c b/libavcodec/amfenc_hevc.c
index 7a40bcad31..0260f43c81 100644
index 65259d7153..7c930d3ccc 100644
--- a/libavcodec/amfenc_hevc.c
+++ b/libavcodec/amfenc_hevc.c
@@ -106,6 +106,9 @@ static av_cold int amf_encode_init_hevc(AVCodecContext *avctx)
@@ -161,6 +161,9 @@ static av_cold int amf_encode_init_hevc(AVCodecContext *avctx)
AMFRate framerate;
AMFSize framesize = AMFConstructSize(avctx->width, avctx->height);
int deblocking_filter = (avctx->flags & AV_CODEC_FLAG_LOOP_FILTER) ? 1 : 0;
@ -98,17 +98,17 @@ index 7a40bcad31..0260f43c81 100644
if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
framerate = AMFConstructRate(avctx->framerate.num, avctx->framerate.den);
@@ -130,6 +133,9 @@ static av_cold int amf_encode_init_hevc(AVCodecContext *avctx)
case FF_PROFILE_HEVC_MAIN:
@@ -191,6 +194,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
case AV_PROFILE_HEVC_MAIN:
profile = AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN;
break;
+ case FF_PROFILE_HEVC_MAIN_10:
+ case AV_PROFILE_HEVC_MAIN_10:
+ profile = AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN_10;
+ break;
default:
break;
}
@@ -158,6 +164,47 @@ static av_cold int amf_encode_init_hevc(AVCodecContext *avctx)
@@ -219,6 +225,47 @@ FF_ENABLE_DEPRECATION_WARNINGS
AMF_ASSIGN_PROPERTY_RATIO(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_ASPECT_RATIO, ratio);
}

View File

@ -1,16 +1,8 @@
if(VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_LINUX)
set(FF_VERSION "n5.1.5")
set(FF_SHA512 "a933f18e53207ccc277b42c9a68db00f31cefec555e6d5d7c57db3409023b2c38fd93ebe2ccfcd17ba2397adb912e93f2388241ca970b7d8bd005ccfe86d5679")
else()
set(FF_VERSION "n7.0.1")
set(FF_SHA512 "1212ebcb78fdaa103b0304373d374e41bf1fe680e1fa4ce0f60624857491c26b4dda004c490c3ef32d4a0e10f42ae6b54546f9f318e2dcfbaa116117f687bc88")
endif()
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO ffmpeg/ffmpeg
REF "${FF_VERSION}"
SHA512 "${FF_SHA512}"
REF "n${VERSION}"
SHA512 3ba02e8b979c80bf61d55f414bdac2c756578bb36498ed7486151755c6ccf8bd8ff2b8c7afa3c5d1acd862ce48314886a86a105613c05e36601984c334f8f6bf
HEAD_REF master
PATCHES
0002-fix-msvc-link.patch # upstreamed in future version
@ -18,25 +10,11 @@ vcpkg_from_github(
0005-fix-nasm.patch # upstreamed in future version
0012-Fix-ssl-110-detection.patch
0013-define-WINVER.patch
patch/0001-avcodec-amfenc-add-query_timeout-option-for-h264-hev.patch
patch/0002-libavcodec-amfenc-reconfig-when-bitrate-change.patch
patch/0003-amf-colorspace.patch
)
if(VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_LINUX)
vcpkg_apply_patches(
SOURCE_PATH ${SOURCE_PATH}
PATCHES
${CMAKE_CURRENT_LIST_DIR}/5.1/0001-avcodec-amfenc-add-query_timeout-option-for-h264-hev.patch
${CMAKE_CURRENT_LIST_DIR}/5.1/0002-libavcodec-amfenc-reconfig-when-bitrate-change.patch
${CMAKE_CURRENT_LIST_DIR}/5.1/0003-use-release-7.0-s-qsvenc-update_bitrate.patch
${CMAKE_CURRENT_LIST_DIR}/5.1/0004-amf-colorspace.patch
)
elseif(VCPKG_TARGET_IS_ANDROID)
vcpkg_apply_patches(
SOURCE_PATH ${SOURCE_PATH}
PATCHES
${CMAKE_CURRENT_LIST_DIR}/7.0/0001-android-mediacodec-encode-align-64.patch
)
endif()
if(SOURCE_PATH MATCHES " ")
message(FATAL_ERROR "Error: ffmpeg will not build with spaces in the path. Please use a directory with no spaces")
endif()
@ -130,6 +108,7 @@ elseif(VCPKG_TARGET_IS_WINDOWS)
string(APPEND OPTIONS "\
--target-os=win32 \
--toolchain=msvc \
--cc=cl \
--enable-gpl \
--enable-d3d11va \
--enable-cuda \
@ -210,6 +189,10 @@ endif()
string(APPEND VCPKG_COMBINED_C_FLAGS_DEBUG " -I \"${CURRENT_INSTALLED_DIR}/include\"")
string(APPEND VCPKG_COMBINED_C_FLAGS_RELEASE " -I \"${CURRENT_INSTALLED_DIR}/include\"")
if(VCPKG_TARGET_IS_WINDOWS)
string(APPEND VCPKG_COMBINED_C_FLAGS_DEBUG " -I \"${CURRENT_INSTALLED_DIR}/include/mfx\"")
string(APPEND VCPKG_COMBINED_C_FLAGS_RELEASE " -I \"${CURRENT_INSTALLED_DIR}/include/mfx\"")
endif()
# # Setup vcpkg toolchain
set(prog_env "")
@ -219,8 +202,9 @@ if(VCPKG_DETECTED_CMAKE_C_COMPILER)
get_filename_component(CC_filename "${VCPKG_DETECTED_CMAKE_C_COMPILER}" NAME)
set(ENV{CC} "${CC_filename}")
string(APPEND OPTIONS " --cc=${CC_filename}")
# string(APPEND OPTIONS " --host_cc=${CC_filename}") ffmpeg not yet setup for cross builds?
if(VCPKG_HOST_IS_WINDOWS)
string(APPEND OPTIONS " --host_cc=${CC_filename}")
endif()
list(APPEND prog_env "${CC_path}")
endif()
@ -291,6 +275,13 @@ if(VCPKG_DETECTED_CMAKE_STRIP)
list(APPEND prog_env "${STRIP_path}")
endif()
if(VCPKG_HOST_IS_WINDOWS)
vcpkg_acquire_msys(MSYS_ROOT PACKAGES automake1.16)
set(SHELL "${MSYS_ROOT}/usr/bin/bash.exe")
list(APPEND prog_env "${MSYS_ROOT}/usr/bin" "${MSYS_ROOT}/usr/share/automake-1.16")
else()
# find_program(SHELL bash)
endif()
list(REMOVE_DUPLICATES prog_env)
vcpkg_add_to_path(PREPEND ${prog_env})

View File

@ -1,6 +1,6 @@
{
"name": "ffmpeg",
"version": "7.0.1",
"version": "7.0.2",
"port-version": 0,
"description": [
"a library to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created.",

View File

@ -87,7 +87,7 @@
]
},
"overrides": [
{ "name": "ffnvcodec", "version": "11.1.5.2" },
{ "name": "ffnvcodec", "version": "12.1.14.0" },
{ "name": "amd-amf", "version": "1.4.29" },
{ "name": "mfx-dispatch", "version": "1.35.1" }
]