24 #include <AMF/components/PreAnalysis.h>
26 #define OFFSET(x) offsetof(AmfContext, x)
27 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
29 {
"usage",
"Set the encoding usage",
OFFSET(
usage),
AV_OPT_TYPE_INT, {.i64 = AMF_VIDEO_ENCODER_HEVC_USAGE_TRANSCODING }, AMF_VIDEO_ENCODER_HEVC_USAGE_TRANSCODING, AMF_VIDEO_ENCODER_HEVC_USAGE_LOW_LATENCY_HIGH_QUALITY,
VE, .unit =
"usage" },
30 {
"transcoding",
"Generic Transcoding", 0,
AV_OPT_TYPE_CONST, {.i64 = AMF_VIDEO_ENCODER_HEVC_USAGE_TRANSCODING }, 0, 0,
VE, .unit =
"usage" },
31 {
"ultralowlatency",
"ultra low latency trancoding", 0,
AV_OPT_TYPE_CONST, {.i64 = AMF_VIDEO_ENCODER_HEVC_USAGE_ULTRA_LOW_LATENCY }, 0, 0,
VE, .unit =
"usage" },
32 {
"lowlatency",
"low latency trancoding", 0,
AV_OPT_TYPE_CONST, {.i64 = AMF_VIDEO_ENCODER_HEVC_USAGE_LOW_LATENCY }, 0, 0,
VE, .unit =
"usage" },
33 {
"webcam",
"Webcam", 0,
AV_OPT_TYPE_CONST, {.i64 = AMF_VIDEO_ENCODER_HEVC_USAGE_WEBCAM }, 0, 0,
VE, .unit =
"usage" },
34 {
"high_quality",
"high quality trancoding", 0,
AV_OPT_TYPE_CONST, {.i64 = AMF_VIDEO_ENCODER_HEVC_USAGE_HIGH_QUALITY }, 0, 0,
VE, .unit =
"usage" },
35 {
"lowlatency_high_quality",
"low latency yet high quality trancoding", 0,
AV_OPT_TYPE_CONST, {.i64 = AMF_VIDEO_ENCODER_HEVC_USAGE_LOW_LATENCY_HIGH_QUALITY }, 0, 0,
VE, .unit =
"usage" },
37 {
"profile",
"Set the profile (default main)",
OFFSET(
profile),
AV_OPT_TYPE_INT,{ .i64 = AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN }, AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN, AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN,
VE, .unit =
"profile" },
38 {
"main",
"", 0,
AV_OPT_TYPE_CONST,{ .i64 = AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN }, 0, 0,
VE, .unit =
"profile" },
40 {
"profile_tier",
"Set the profile tier (default main)",
OFFSET(
tier),
AV_OPT_TYPE_INT,{ .i64 = AMF_VIDEO_ENCODER_HEVC_TIER_MAIN }, AMF_VIDEO_ENCODER_HEVC_TIER_MAIN, AMF_VIDEO_ENCODER_HEVC_TIER_HIGH,
VE, .unit =
"tier" },
41 {
"main",
"", 0,
AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_TIER_MAIN }, 0, 0,
VE, .unit =
"tier" },
42 {
"high",
"", 0,
AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_TIER_HIGH }, 0, 0,
VE, .unit =
"tier" },
44 {
"level",
"Set the encoding level (default auto)",
OFFSET(
level),
AV_OPT_TYPE_INT,{ .i64 = 0 }, 0, AMF_LEVEL_6_2,
VE, .unit =
"level" },
60 {
"quality",
"Set the encoding quality",
OFFSET(
quality),
AV_OPT_TYPE_INT, { .i64 = AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_SPEED }, AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_QUALITY, AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_SPEED,
VE, .unit =
"quality" },
61 {
"balanced",
"", 0,
AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_BALANCED }, 0, 0,
VE, .unit =
"quality" },
62 {
"speed",
"", 0,
AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_SPEED }, 0, 0,
VE, .unit =
"quality" },
63 {
"quality",
"", 0,
AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_QUALITY }, 0, 0,
VE, .unit =
"quality" },
65 {
"rc",
"Set the rate control mode",
OFFSET(rate_control_mode),
AV_OPT_TYPE_INT, { .i64 = AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_UNKNOWN }, AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_UNKNOWN, AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_HIGH_QUALITY_CBR,
VE, .unit =
"rc" },
66 {
"cqp",
"Constant Quantization Parameter", 0,
AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_CONSTANT_QP }, 0, 0,
VE, .unit =
"rc" },
67 {
"cbr",
"Constant Bitrate", 0,
AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_CBR }, 0, 0,
VE, .unit =
"rc" },
68 {
"vbr_peak",
"Peak Contrained Variable Bitrate", 0,
AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_PEAK_CONSTRAINED_VBR }, 0, 0,
VE, .unit =
"rc" },
69 {
"vbr_latency",
"Latency Constrained Variable Bitrate", 0,
AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_LATENCY_CONSTRAINED_VBR }, 0, 0,
VE, .unit =
"rc" },
70 {
"qvbr",
"Quality Variable Bitrate", 0,
AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_QUALITY_VBR }, 0, 0,
VE, .unit =
"rc" },
71 {
"hqvbr",
"High Quality Variable Bitrate", 0,
AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_HIGH_QUALITY_VBR }, 0, 0,
VE, .unit =
"rc" },
72 {
"hqcbr",
"High Quality Constant Bitrate", 0,
AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_HIGH_QUALITY_CBR }, 0, 0,
VE, .unit =
"rc" },
74 {
"qvbr_quality_level",
"Sets the QVBR quality level",
OFFSET(qvbr_quality_level),
AV_OPT_TYPE_INT, {.i64 = -1 }, -1, 51,
VE },
76 {
"header_insertion_mode",
"Set header insertion mode",
OFFSET(header_insertion_mode),
AV_OPT_TYPE_INT,{ .i64 = AMF_VIDEO_ENCODER_HEVC_HEADER_INSERTION_MODE_NONE }, AMF_VIDEO_ENCODER_HEVC_HEADER_INSERTION_MODE_NONE, AMF_VIDEO_ENCODER_HEVC_HEADER_INSERTION_MODE_IDR_ALIGNED,
VE, .unit =
"hdrmode" },
77 {
"none",
"", 0,
AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_HEADER_INSERTION_MODE_NONE }, 0, 0,
VE, .unit =
"hdrmode" },
78 {
"gop",
"", 0,
AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_HEADER_INSERTION_MODE_GOP_ALIGNED }, 0, 0,
VE, .unit =
"hdrmode" },
79 {
"idr",
"", 0,
AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_HEADER_INSERTION_MODE_IDR_ALIGNED }, 0, 0,
VE, .unit =
"hdrmode" },
81 {
"high_motion_quality_boost_enable",
"Enable High motion quality boost mode",
OFFSET(hw_high_motion_quality_boost),
AV_OPT_TYPE_BOOL, {.i64 = -1 }, -1, 1,
VE },
82 {
"gops_per_idr",
"GOPs per IDR 0-no IDR will be inserted",
OFFSET(gops_per_idr),
AV_OPT_TYPE_INT, { .i64 = 1 }, 0, INT_MAX,
VE },
87 {
"max_au_size",
"Maximum Access Unit Size for rate control (in bits)",
OFFSET(max_au_size),
AV_OPT_TYPE_INT,{ .i64 = 0 }, 0, INT_MAX,
VE},
88 {
"min_qp_i",
"min quantization parameter for I-frame",
OFFSET(min_qp_i),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51,
VE },
89 {
"max_qp_i",
"max quantization parameter for I-frame",
OFFSET(max_qp_i),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51,
VE },
90 {
"min_qp_p",
"min quantization parameter for P-frame",
OFFSET(min_qp_p),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51,
VE },
91 {
"max_qp_p",
"max quantization parameter for P-frame",
OFFSET(max_qp_p),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51,
VE },
100 {
"log_to_dbg",
"Enable AMF logging to debug output",
OFFSET(log_to_dbg),
AV_OPT_TYPE_BOOL,{ .i64 = 0 }, 0, 1,
VE },
105 {
"pa_activity_type",
"Set the type of activity analysis",
OFFSET(pa_activity_type),
AV_OPT_TYPE_INT, {.i64 = -1 }, -1, AMF_PA_ACTIVITY_YUV,
VE, .unit =
"activity_type" },
106 {
"y",
"activity y", 0,
AV_OPT_TYPE_CONST, {.i64 = AMF_PA_ACTIVITY_Y }, 0, 0,
VE, .unit =
"activity_type" },
107 {
"yuv",
"activity yuv", 0,
AV_OPT_TYPE_CONST, {.i64 = AMF_PA_ACTIVITY_YUV }, 0, 0,
VE, .unit =
"activity_type" },
109 {
"pa_scene_change_detection_enable",
"Enable scene change detection",
OFFSET(pa_scene_change_detection),
AV_OPT_TYPE_BOOL, {.i64 = -1 }, -1, 1,
VE },
111 {
"pa_scene_change_detection_sensitivity",
"Set the sensitivity of scene change detection",
OFFSET(pa_scene_change_detection_sensitivity),
AV_OPT_TYPE_INT, {.i64 = -1 }, -1, AMF_PA_SCENE_CHANGE_DETECTION_SENSITIVITY_HIGH,
VE, .unit =
"scene_change_sensitivity" },
112 {
"low",
"low scene change dectection sensitivity", 0,
AV_OPT_TYPE_CONST, {.i64 = AMF_PA_SCENE_CHANGE_DETECTION_SENSITIVITY_LOW }, 0, 0,
VE, .unit =
"scene_change_sensitivity" },
113 {
"medium",
"medium scene change dectection sensitivity", 0,
AV_OPT_TYPE_CONST, {.i64 = AMF_PA_SCENE_CHANGE_DETECTION_SENSITIVITY_MEDIUM }, 0, 0,
VE, .unit =
"scene_change_sensitivity" },
114 {
"high",
"high scene change dectection sensitivity", 0,
AV_OPT_TYPE_CONST, {.i64 = AMF_PA_SCENE_CHANGE_DETECTION_SENSITIVITY_HIGH }, 0, 0,
VE, .unit =
"scene_change_sensitivity" },
116 {
"pa_static_scene_detection_enable",
"Enable static scene detection",
OFFSET(pa_static_scene_detection),
AV_OPT_TYPE_BOOL, {.i64 = -1 }, -1, 1,
VE },
118 {
"pa_static_scene_detection_sensitivity",
"Set the sensitivity of static scene detection",
OFFSET(pa_static_scene_detection_sensitivity),
AV_OPT_TYPE_INT, {.i64 = -1 }, -1, AMF_PA_STATIC_SCENE_DETECTION_SENSITIVITY_HIGH,
VE , .unit =
"static_scene_sensitivity" },
119 {
"low",
"low static scene dectection sensitivity", 0,
AV_OPT_TYPE_CONST, {.i64 = AMF_PA_STATIC_SCENE_DETECTION_SENSITIVITY_LOW }, 0, 0,
VE, .unit =
"static_scene_sensitivity" },
120 {
"medium",
"medium static scene dectection sensitivity", 0,
AV_OPT_TYPE_CONST, {.i64 = AMF_PA_STATIC_SCENE_DETECTION_SENSITIVITY_MEDIUM }, 0, 0,
VE, .unit =
"static_scene_sensitivity" },
121 {
"high",
"high static scene dectection sensitivity", 0,
AV_OPT_TYPE_CONST, {.i64 = AMF_PA_STATIC_SCENE_DETECTION_SENSITIVITY_HIGH }, 0, 0,
VE, .unit =
"static_scene_sensitivity" },
123 {
"pa_initial_qp_after_scene_change",
"The QP value that is used immediately after a scene change",
OFFSET(pa_initial_qp),
AV_OPT_TYPE_INT, {.i64 = -1 }, -1, 51,
VE },
124 {
"pa_max_qp_before_force_skip",
"The QP threshold to allow a skip frame",
OFFSET(pa_max_qp),
AV_OPT_TYPE_INT, {.i64 = -1 }, -1, 51,
VE },
126 {
"pa_caq_strength",
"Content Adaptive Quantization strength",
OFFSET(pa_caq_strength),
AV_OPT_TYPE_INT, {.i64 = -1 }, -1, AMF_PA_CAQ_STRENGTH_HIGH,
VE , .unit =
"caq_strength" },
127 {
"low",
"low Content Adaptive Quantization strength", 0,
AV_OPT_TYPE_CONST, {.i64 = AMF_PA_CAQ_STRENGTH_LOW }, 0, 0,
VE, .unit =
"caq_strength" },
128 {
"medium",
"medium Content Adaptive Quantization strength", 0,
AV_OPT_TYPE_CONST, {.i64 = AMF_PA_CAQ_STRENGTH_MEDIUM }, 0, 0,
VE, .unit =
"caq_strength" },
129 {
"high",
"high Content Adaptive Quantization strength", 0,
AV_OPT_TYPE_CONST, {.i64 = AMF_PA_CAQ_STRENGTH_HIGH }, 0, 0,
VE, .unit =
"caq_strength" },
131 {
"pa_frame_sad_enable",
"Enable Frame SAD algorithm",
OFFSET(pa_frame_sad),
AV_OPT_TYPE_BOOL, {.i64 = -1 }, -1, 1,
VE },
132 {
"pa_ltr_enable",
"Enable long term reference frame management",
OFFSET(pa_ltr),
AV_OPT_TYPE_BOOL, {.i64 = -1 }, -1, 1,
VE },
135 {
"pa_paq_mode",
"Sets the perceptual adaptive quantization mode",
OFFSET(pa_paq_mode),
AV_OPT_TYPE_INT, {.i64 = -1 }, -1, AMF_PA_PAQ_MODE_CAQ,
VE , .unit =
"paq_mode" },
136 {
"none",
"no perceptual adaptive quantization", 0,
AV_OPT_TYPE_CONST, {.i64 = AMF_PA_PAQ_MODE_NONE }, 0, 0,
VE, .unit =
"paq_mode" },
137 {
"caq",
"caq perceptual adaptive quantization", 0,
AV_OPT_TYPE_CONST, {.i64 = AMF_PA_PAQ_MODE_CAQ }, 0, 0,
VE, .unit =
"paq_mode" },
139 {
"pa_taq_mode",
"Sets the temporal adaptive quantization mode",
OFFSET(pa_taq_mode),
AV_OPT_TYPE_INT, {.i64 = -1 }, -1, AMF_PA_TAQ_MODE_2,
VE , .unit =
"taq_mode" },
140 {
"none",
"no temporal adaptive quantization", 0,
AV_OPT_TYPE_CONST, {.i64 = AMF_PA_TAQ_MODE_NONE }, 0, 0,
VE, .unit =
"taq_mode" },
141 {
"1",
"temporal adaptive quantization mode 1", 0,
AV_OPT_TYPE_CONST, {.i64 = AMF_PA_TAQ_MODE_1 }, 0, 0,
VE, .unit =
"taq_mode" },
142 {
"2",
"temporal adaptive quantization mode 2", 0,
AV_OPT_TYPE_CONST, {.i64 = AMF_PA_TAQ_MODE_2 }, 0, 0,
VE, .unit =
"taq_mode" },
144 {
"pa_high_motion_quality_boost_mode",
"Sets the PA high motion quality boost mode",
OFFSET(pa_high_motion_quality_boost_mode),
AV_OPT_TYPE_INT, {.i64 = -1 }, -1, AMF_PA_HIGH_MOTION_QUALITY_BOOST_MODE_AUTO,
VE , .unit =
"high_motion_quality_boost_mode" },
145 {
"none",
"no high motion quality boost", 0,
AV_OPT_TYPE_CONST, {.i64 = AMF_PA_HIGH_MOTION_QUALITY_BOOST_MODE_NONE }, 0, 0,
VE, .unit =
"high_motion_quality_boost_mode" },
146 {
"auto",
"auto high motion quality boost", 0,
AV_OPT_TYPE_CONST, {.i64 = AMF_PA_HIGH_MOTION_QUALITY_BOOST_MODE_AUTO }, 0, 0,
VE, .unit =
"high_motion_quality_boost_mode" },
153 AMF_RESULT res = AMF_OK;
155 AMFVariantStruct var = {0};
157 amf_int64 profile_level = 0;
161 AMFSize framesize = AMFConstructSize(avctx->
width, avctx->
height);
180 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_USAGE,
ctx->usage);
182 AMF_ASSIGN_PROPERTY_SIZE(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_FRAMESIZE, framesize);
184 AMF_ASSIGN_PROPERTY_RATE(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_FRAMERATE,
framerate);
188 profile = AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN;
196 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_PROFILE,
profile);
198 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_TIER,
ctx->tier);
200 profile_level = avctx->
level;
202 profile_level =
ctx->level;
204 if (profile_level != 0) {
205 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_PROFILE_LEVEL, profile_level);
207 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET,
ctx->quality);
209 if (avctx->
refs != -1) {
210 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_MAX_NUM_REFRAMES, avctx->
refs);
215 AMF_ASSIGN_PROPERTY_RATIO(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_ASPECT_RATIO, ratio);
219 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_NUM_GOPS_PER_IDR,
ctx->gops_per_idr);
220 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_GOP_SIZE, avctx->
gop_size);
222 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_SLICES_PER_FRAME, avctx->
slices);
224 AMF_ASSIGN_PROPERTY_BOOL(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_DE_BLOCKING_FILTER_DISABLE, deblocking_filter);
225 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_HEADER_INSERTION_MODE,
ctx->header_insertion_mode);
229 if (
ctx->rate_control_mode == AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_UNKNOWN) {
230 if (
ctx->min_qp_i != -1 ||
ctx->max_qp_i != -1 ||
231 ctx->min_qp_p != -1 ||
ctx->max_qp_p != -1 ||
232 ctx->qp_i !=-1 ||
ctx->qp_p != -1) {
233 ctx->rate_control_mode = AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_CONSTANT_QP;
236 ctx->rate_control_mode = AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_PEAK_CONSTRAINED_VBR;
239 ctx->rate_control_mode = AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_CBR;
245 if (
ctx->rate_control_mode == AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_CONSTANT_QP) {
246 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_PREENCODE_ENABLE, 0);
248 av_log(
ctx,
AV_LOG_WARNING,
"Preencode is not supported by cqp Rate Control Method, automatically disabled\n");
251 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_PREENCODE_ENABLE,
ctx->preencode);
254 if (
ctx->rate_control_mode == AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_QUALITY_VBR) {
255 if (
ctx->qvbr_quality_level != -1) {
256 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_QVBR_QUALITY_LEVEL,
ctx->qvbr_quality_level);
260 if (
ctx->hw_high_motion_quality_boost != -1) {
261 AMF_ASSIGN_PROPERTY_BOOL(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_HIGH_MOTION_QUALITY_BOOST_ENABLE, ((
ctx->hw_high_motion_quality_boost == 0) ?
false :
true));
264 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD,
ctx->rate_control_mode);
266 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_VBV_BUFFER_SIZE, avctx->
rc_buffer_size);
270 if (amf_buffer_fullness > 64)
271 amf_buffer_fullness = 64;
272 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_INITIAL_VBV_BUFFER_FULLNESS, amf_buffer_fullness);
276 if (
ctx->rate_control_mode == AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_CONSTANT_QP) {
277 AMF_ASSIGN_PROPERTY_BOOL(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_ENABLE_VBAQ,
false);
278 if (
ctx->enable_vbaq)
281 AMF_ASSIGN_PROPERTY_BOOL(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_ENABLE_VBAQ, !!
ctx->enable_vbaq);
283 AMF_ASSIGN_PROPERTY_BOOL(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_MOTION_HALF_PIXEL,
ctx->me_half_pel);
284 AMF_ASSIGN_PROPERTY_BOOL(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_MOTION_QUARTERPIXEL,
ctx->me_quarter_pel);
287 if (
ctx->max_au_size)
288 ctx->enforce_hrd = 1;
289 AMF_ASSIGN_PROPERTY_BOOL(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_ENFORCE_HRD,
ctx->enforce_hrd);
290 AMF_ASSIGN_PROPERTY_BOOL(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_FILLER_DATA_ENABLE,
ctx->filler_data);
292 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_TARGET_BITRATE, avctx->
bit_rate);
294 if (
ctx->rate_control_mode == AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_CBR) {
295 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_PEAK_BITRATE, avctx->
bit_rate);
298 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_PEAK_BITRATE, avctx->
rc_max_rate);
299 }
else if (
ctx->rate_control_mode == AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_PEAK_CONSTRAINED_VBR) {
303 if (
ctx->preanalysis != -1) {
304 AMF_ASSIGN_PROPERTY_BOOL(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_PRE_ANALYSIS_ENABLE, !!((
ctx->preanalysis == 0) ?
false :
true));
307 res =
ctx->encoder->pVtbl->GetProperty(
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_PRE_ANALYSIS_ENABLE, &var);
308 if ((
int)var.int64Value)
310 if (
ctx->pa_activity_type != -1) {
311 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_PA_ACTIVITY_TYPE,
ctx->pa_activity_type);
313 if (
ctx->pa_scene_change_detection != -1) {
314 AMF_ASSIGN_PROPERTY_BOOL(res,
ctx->encoder, AMF_PA_SCENE_CHANGE_DETECTION_ENABLE, ((
ctx->pa_scene_change_detection == 0) ?
false :
true));
316 if (
ctx->pa_scene_change_detection_sensitivity != -1) {
317 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_PA_SCENE_CHANGE_DETECTION_SENSITIVITY,
ctx->pa_scene_change_detection_sensitivity);
319 if (
ctx->pa_static_scene_detection != -1) {
320 AMF_ASSIGN_PROPERTY_BOOL(res,
ctx->encoder, AMF_PA_STATIC_SCENE_DETECTION_ENABLE, ((
ctx->pa_static_scene_detection == 0) ?
false :
true));
322 if (
ctx->pa_static_scene_detection_sensitivity != -1) {
323 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_PA_STATIC_SCENE_DETECTION_SENSITIVITY,
ctx->pa_static_scene_detection_sensitivity);
325 if (
ctx->pa_initial_qp != -1) {
326 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_PA_INITIAL_QP_AFTER_SCENE_CHANGE,
ctx->pa_initial_qp);
328 if (
ctx->pa_max_qp != -1) {
329 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_PA_MAX_QP_BEFORE_FORCE_SKIP,
ctx->pa_max_qp);
331 if (
ctx->pa_caq_strength != -1) {
332 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_PA_CAQ_STRENGTH,
ctx->pa_caq_strength);
334 if (
ctx->pa_frame_sad != -1) {
335 AMF_ASSIGN_PROPERTY_BOOL(res,
ctx->encoder, AMF_PA_FRAME_SAD_ENABLE, ((
ctx->pa_frame_sad == 0) ?
false :
true));
337 if (
ctx->pa_paq_mode != -1) {
338 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_PA_PAQ_MODE,
ctx->pa_paq_mode);
340 if (
ctx->pa_taq_mode != -1) {
341 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_PA_TAQ_MODE,
ctx->pa_taq_mode);
343 if (
ctx->pa_ltr != -1) {
344 AMF_ASSIGN_PROPERTY_BOOL(res,
ctx->encoder, AMF_PA_LTR_ENABLE, ((
ctx->pa_ltr == 0) ?
false :
true));
346 if (
ctx->pa_lookahead_buffer_depth != -1) {
347 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_PA_LOOKAHEAD_BUFFER_DEPTH,
ctx->pa_lookahead_buffer_depth);
349 if (
ctx->pa_high_motion_quality_boost_mode != -1) {
350 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_PA_HIGH_MOTION_QUALITY_BOOST_MODE,
ctx->pa_high_motion_quality_boost_mode);
359 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_MAX_AU_SIZE,
ctx->max_au_size);
361 if (
ctx->min_qp_i != -1) {
362 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_MIN_QP_I,
ctx->min_qp_i);
363 }
else if (avctx->
qmin != -1) {
364 int qval = avctx->
qmin > 51 ? 51 : avctx->
qmin;
365 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_MIN_QP_I, qval);
367 if (
ctx->max_qp_i != -1) {
368 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_MAX_QP_I,
ctx->max_qp_i);
369 }
else if (avctx->
qmax != -1) {
370 int qval = avctx->
qmax > 51 ? 51 : avctx->
qmax;
371 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_MAX_QP_I, qval);
373 if (
ctx->min_qp_p != -1) {
374 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_MIN_QP_P,
ctx->min_qp_p);
375 }
else if (avctx->
qmin != -1) {
376 int qval = avctx->
qmin > 51 ? 51 : avctx->
qmin;
377 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_MIN_QP_P, qval);
379 if (
ctx->max_qp_p != -1) {
380 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_MAX_QP_P,
ctx->max_qp_p);
381 }
else if (avctx->
qmax != -1) {
382 int qval = avctx->
qmax > 51 ? 51 : avctx->
qmax;
383 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_MAX_QP_P, qval);
386 if (
ctx->qp_p != -1) {
387 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_QP_P,
ctx->qp_p);
389 if (
ctx->qp_i != -1) {
390 AMF_ASSIGN_PROPERTY_INT64(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_QP_I,
ctx->qp_i);
392 AMF_ASSIGN_PROPERTY_BOOL(res,
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_SKIP_FRAME_ENABLE,
ctx->skip_frame);
395 res = AMFVariantInit(&var);
398 res =
ctx->encoder->pVtbl->GetProperty(
ctx->encoder, AMF_VIDEO_ENCODER_HEVC_EXTRADATA, &var);
402 guid = IID_AMFBuffer();
404 res = var.pInterface->pVtbl->QueryInterface(var.pInterface, &guid, (
void**)&
buffer);
406 var.pInterface->pVtbl->Release(var.pInterface);
414 var.pInterface->pVtbl->Release(var.pInterface);
420 var.pInterface->pVtbl->Release(var.pInterface);
442 .
p.
name =
"hevc_amf",
457 .p.wrapper_name =
"amf",