mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-20 18:53:19 +03:00
install ffmpeg lib with vcpkg (#8724)
* use vcpkg to install ffmpeg and build sdk from source, so no prebuild lib in hwcodec. * link ffmpeg in rustdesk directly, ffmpeg can be used as basic library. * for windows developers, `VCPKG_DEFAULT_HOST_TRIPLET` env need to be set to `x64-windows-static` during installation. Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
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
|
||||
|
||||
Signed-off-by: 21pages <pages21@163.com>
|
||||
---
|
||||
libavcodec/amfenc.h | 1 +
|
||||
libavcodec/amfenc_h264.c | 4 ++++
|
||||
libavcodec/amfenc_hevc.c | 4 ++++
|
||||
3 files changed, 9 insertions(+)
|
||||
|
||||
diff --git a/libavcodec/amfenc.h b/libavcodec/amfenc.h
|
||||
index 1ab98d2f78..e92120ea39 100644
|
||||
--- a/libavcodec/amfenc.h
|
||||
+++ b/libavcodec/amfenc.h
|
||||
@@ -87,6 +87,7 @@ typedef struct AmfContext {
|
||||
int quality;
|
||||
int b_frame_delta_qp;
|
||||
int ref_b_frame_delta_qp;
|
||||
+ int64_t query_timeout;
|
||||
|
||||
// Dynamic options, can be set after Init() call
|
||||
|
||||
diff --git a/libavcodec/amfenc_h264.c b/libavcodec/amfenc_h264.c
|
||||
index efb04589f6..f55dbc80f0 100644
|
||||
--- a/libavcodec/amfenc_h264.c
|
||||
+++ b/libavcodec/amfenc_h264.c
|
||||
@@ -121,6 +121,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)
|
||||
|
||||
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);
|
||||
+
|
||||
switch (avctx->profile) {
|
||||
case FF_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
|
||||
--- a/libavcodec/amfenc_hevc.c
|
||||
+++ b/libavcodec/amfenc_hevc.c
|
||||
@@ -89,6 +89,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)
|
||||
|
||||
AMF_ASSIGN_PROPERTY_RATE(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_FRAMERATE, framerate);
|
||||
|
||||
+ if (ctx->query_timeout >= 0)
|
||||
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_QUERY_TIMEOUT, ctx->query_timeout);
|
||||
+
|
||||
switch (avctx->profile) {
|
||||
case FF_PROFILE_HEVC_MAIN:
|
||||
profile = AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN;
|
||||
--
|
||||
2.43.0.windows.1
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
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
|
||||
|
||||
Signed-off-by: 21pages <pages21@163.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
|
||||
--- a/libavcodec/amfenc.c
|
||||
+++ b/libavcodec/amfenc.c
|
||||
@@ -222,6 +222,7 @@ static int amf_init_context(AVCodecContext *avctx)
|
||||
|
||||
ctx->hwsurfaces_in_queue = 0;
|
||||
ctx->hwsurfaces_in_queue_max = 16;
|
||||
+ ctx->av_bitrate = avctx->bit_rate;
|
||||
|
||||
// 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
|
||||
frame_ref_storage_buffer->pVtbl->Release(frame_ref_storage_buffer);
|
||||
}
|
||||
|
||||
+static int reconfig_encoder(AVCodecContext *avctx)
|
||||
+{
|
||||
+ AmfContext *ctx = avctx->priv_data;
|
||||
+ AMF_RESULT res = AMF_OK;
|
||||
+
|
||||
+ if (ctx->av_bitrate != avctx->bit_rate) {
|
||||
+ av_log(ctx, AV_LOG_INFO, "change bitrate from %d to %d\n", ctx->av_bitrate, avctx->bit_rate);
|
||||
+ ctx->av_bitrate = avctx->bit_rate;
|
||||
+ if (avctx->codec->id == AV_CODEC_ID_H264) {
|
||||
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_TARGET_BITRATE, avctx->bit_rate);
|
||||
+ } else if (avctx->codec->id == AV_CODEC_ID_HEVC) {
|
||||
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_TARGET_BITRATE, avctx->bit_rate);
|
||||
+ }
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
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;
|
||||
|
||||
+ reconfig_encoder(avctx);
|
||||
+
|
||||
if (!ctx->encoder)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
diff --git a/libavcodec/amfenc.h b/libavcodec/amfenc.h
|
||||
index e92120ea39..31172645f2 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;
|
||||
+ int64_t av_bitrate;
|
||||
|
||||
// HEVC - specific options
|
||||
|
||||
--
|
||||
2.43.0.windows.1
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
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
|
||||
|
||||
172
res/vcpkg/ffmpeg/5.1/0004-amf-colorspace.patch
Normal file
172
res/vcpkg/ffmpeg/5.1/0004-amf-colorspace.patch
Normal file
@@ -0,0 +1,172 @@
|
||||
From 7c29a6936e7b7a3a3a0bcc88894f2b739bdae9cf Mon Sep 17 00:00:00 2001
|
||||
From: 21pages <sunboeasy@gmail.com>
|
||||
Date: Thu, 11 Jul 2024 16:24:27 +0800
|
||||
Subject: [PATCH] amf colorspace
|
||||
|
||||
Signed-off-by: 21pages <sunboeasy@gmail.com>
|
||||
---
|
||||
libavcodec/amfenc.h | 1 +
|
||||
libavcodec/amfenc_h264.c | 45 ++++++++++++++++++++++++++++++++++
|
||||
libavcodec/amfenc_hevc.c | 52 ++++++++++++++++++++++++++++++++++++++++
|
||||
3 files changed, 98 insertions(+)
|
||||
|
||||
diff --git a/libavcodec/amfenc.h b/libavcodec/amfenc.h
|
||||
index 31172645f2..493e01603d 100644
|
||||
--- a/libavcodec/amfenc.h
|
||||
+++ b/libavcodec/amfenc.h
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <AMF/components/VideoEncoderVCE.h>
|
||||
#include <AMF/components/VideoEncoderHEVC.h>
|
||||
+#include <AMF/components/ColorSpace.h>
|
||||
|
||||
#include "libavutil/fifo.h"
|
||||
|
||||
diff --git a/libavcodec/amfenc_h264.c b/libavcodec/amfenc_h264.c
|
||||
index f55dbc80f0..a916b35f9c 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)
|
||||
AMFRate framerate;
|
||||
AMFSize framesize = AMFConstructSize(avctx->width, avctx->height);
|
||||
int deblocking_filter = (avctx->flags & AV_CODEC_FLAG_LOOP_FILTER) ? 1 : 0;
|
||||
+ amf_int64 color_depth;
|
||||
+ amf_int64 color_profile;
|
||||
+ enum AVPixelFormat pix_fmt;
|
||||
|
||||
if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
|
||||
framerate = AMFConstructRate(avctx->framerate.num, avctx->framerate.den);
|
||||
@@ -199,11 +202,53 @@ static av_cold int amf_encode_init_h264(AVCodecContext *avctx)
|
||||
AMF_ASSIGN_PROPERTY_RATIO(res, ctx->encoder, AMF_VIDEO_ENCODER_ASPECT_RATIO, ratio);
|
||||
}
|
||||
|
||||
+ color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_UNKNOWN;
|
||||
/// Color Range (Partial/TV/MPEG or Full/PC/JPEG)
|
||||
if (avctx->color_range == AVCOL_RANGE_JPEG) {
|
||||
AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_FULL_RANGE_COLOR, 1);
|
||||
+ /// Color Space for Full (JPEG) Range
|
||||
+ switch (avctx->colorspace) {
|
||||
+ case AVCOL_SPC_SMPTE170M:
|
||||
+ color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_601;
|
||||
+ break;
|
||||
+ case AVCOL_SPC_BT709:
|
||||
+ color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_709;
|
||||
+ break;
|
||||
+ case AVCOL_SPC_BT2020_NCL:
|
||||
+ case AVCOL_SPC_BT2020_CL:
|
||||
+ color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_2020;
|
||||
+ break;
|
||||
+ }
|
||||
+ } else {
|
||||
+ AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_FULL_RANGE_COLOR, 0);
|
||||
+ /// Color Space for Limited (MPEG) range
|
||||
+ switch (avctx->colorspace) {
|
||||
+ case AVCOL_SPC_SMPTE170M:
|
||||
+ color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_601;
|
||||
+ break;
|
||||
+ case AVCOL_SPC_BT709:
|
||||
+ color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_709;
|
||||
+ break;
|
||||
+ case AVCOL_SPC_BT2020_NCL:
|
||||
+ case AVCOL_SPC_BT2020_CL:
|
||||
+ color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_2020;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ /// Color Depth
|
||||
+ 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);
|
||||
+ /// Color Transfer Characteristics (AMF matches ISO/IEC)
|
||||
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_OUTPUT_TRANSFER_CHARACTERISTIC, (amf_int64)avctx->color_trc);
|
||||
+ /// Color Primaries (AMF matches ISO/IEC)
|
||||
+ 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..e7979d9aeb 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)
|
||||
AMFRate framerate;
|
||||
AMFSize framesize = AMFConstructSize(avctx->width, avctx->height);
|
||||
int deblocking_filter = (avctx->flags & AV_CODEC_FLAG_LOOP_FILTER) ? 1 : 0;
|
||||
+ amf_int64 color_depth;
|
||||
+ amf_int64 color_profile;
|
||||
+ enum AVPixelFormat pix_fmt;
|
||||
|
||||
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:
|
||||
profile = AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN;
|
||||
break;
|
||||
+ case FF_PROFILE_HEVC_MAIN_10:
|
||||
+ profile = AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN_10;
|
||||
+ break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -158,6 +164,52 @@ static av_cold int amf_encode_init_hevc(AVCodecContext *avctx)
|
||||
AMF_ASSIGN_PROPERTY_RATIO(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_ASPECT_RATIO, ratio);
|
||||
}
|
||||
|
||||
+ // Color Metadata
|
||||
+ color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_UNKNOWN;
|
||||
+ if (avctx->color_range == AVCOL_RANGE_JPEG) {
|
||||
+ AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_NOMINAL_RANGE, 1);
|
||||
+ switch (avctx->colorspace) {
|
||||
+ case AVCOL_SPC_SMPTE170M:
|
||||
+ color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_601;
|
||||
+ break;
|
||||
+ case AVCOL_SPC_BT709:
|
||||
+ color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_709;
|
||||
+ break;
|
||||
+ case AVCOL_SPC_BT2020_NCL:
|
||||
+ case AVCOL_SPC_BT2020_CL:
|
||||
+ color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_2020;
|
||||
+ break;
|
||||
+ }
|
||||
+ } else {
|
||||
+ AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_NOMINAL_RANGE, 0);
|
||||
+ switch (avctx->colorspace) {
|
||||
+ case AVCOL_SPC_SMPTE170M:
|
||||
+ color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_601;
|
||||
+ break;
|
||||
+ case AVCOL_SPC_BT709:
|
||||
+ color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_709;
|
||||
+ break;
|
||||
+ case AVCOL_SPC_BT2020_NCL:
|
||||
+ case AVCOL_SPC_BT2020_CL:
|
||||
+ color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_2020;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ /// Color Depth
|
||||
+ 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_HEVC_COLOR_BIT_DEPTH, color_depth);
|
||||
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_OUTPUT_COLOR_PROFILE, color_profile);
|
||||
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_OUTPUT_TRANSFER_CHARACTERISTIC, (amf_int64)avctx->color_trc);
|
||||
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_OUTPUT_COLOR_PRIMARIES, (amf_int64)avctx->color_primaries);
|
||||
+
|
||||
+
|
||||
+
|
||||
// Picture control properties
|
||||
AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_NUM_GOPS_PER_IDR, ctx->gops_per_idr);
|
||||
AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_GOP_SIZE, avctx->gop_size);
|
||||
--
|
||||
2.39.3 (Apple Git-145)
|
||||
|
||||
Reference in New Issue
Block a user