diff options
author | John Stebbins <[email protected]> | 2019-01-14 16:40:17 -0800 |
---|---|---|
committer | John Stebbins <[email protected]> | 2019-01-18 12:26:13 -0800 |
commit | 49f8f57ebe1b37df9b9b51c495bc5b2aaf86959e (patch) | |
tree | 8f2af6e07efa73778b1d1b451ba48f26e0ef2f30 | |
parent | 0506627883b843658a6a3dc9ad91ae3b2d9c421f (diff) |
ffmpeg: enable pict_type setting in AMD VCE
This is required by HandBrake in order to place IDR frames
at chapter boundaries
(cherry picked from commit f0af7632557face2d516829386e01bf0c7a6c549)
-rw-r--r-- | contrib/ffmpeg/A11-FFmpeg-devel-amfenc-Add-support-for-pict_type-field.patch | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/contrib/ffmpeg/A11-FFmpeg-devel-amfenc-Add-support-for-pict_type-field.patch b/contrib/ffmpeg/A11-FFmpeg-devel-amfenc-Add-support-for-pict_type-field.patch new file mode 100644 index 000000000..c79ccf91a --- /dev/null +++ b/contrib/ffmpeg/A11-FFmpeg-devel-amfenc-Add-support-for-pict_type-field.patch @@ -0,0 +1,78 @@ +From patchwork Mon Jan 14 19:02:20 2019 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Subject: [FFmpeg-devel] amfenc: Add support for pict_type field +From: Michael Fabian 'Xaymar' Dirks <[email protected]> +X-Patchwork-Id: 11748 +Message-Id: <[email protected]> +To: [email protected] +Cc: Michael Fabian 'Xaymar' Dirks <[email protected]> +Date: Mon, 14 Jan 2019 20:02:20 +0100 + +Adds support for the pict_type field in AVFrame to amf_h264 and amf_h265 simultaneously. This field is needed in cases where the application wishes to override the frame type with another one, such as forcefully inserting a key frame for chapter markers or similar. + +Additionally this abuses AV_PICTURE_TYPE_S for marking Skip frames, a special type of frame in AVC, SVC and HEVC which is a flag for the decoder to repeat the last frame. + +Signed-off-by: Michael Fabian 'Xaymar' Dirks <[email protected]> +--- + libavcodec/amfenc.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 46 insertions(+) + +diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c +index 384d8efc92..eb4b65e4f2 100644 +--- a/libavcodec/amfenc.c ++++ b/libavcodec/amfenc.c +@@ -680,6 +680,52 @@ int ff_amf_send_frame(AVCodecContext *avctx, const AVFrame *frame) + break; + } + ++ // Override Picture Type for Frame ++ if (avctx->codec->id == AV_CODEC_ID_H264) { ++ switch (frame->pict_type) { ++ case AV_PICTURE_TYPE_I: ++ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_PICTURE_TYPE_I); ++ break; ++ case AV_PICTURE_TYPE_P: ++ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_PICTURE_TYPE_P); ++ break; ++ case AV_PICTURE_TYPE_B: ++ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_PICTURE_TYPE_B); ++ break; ++ case AV_PICTURE_TYPE_S: ++ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_PICTURE_TYPE_SKIP); ++ break; ++ default: ++ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_PICTURE_TYPE_NONE); ++ break; ++ } ++ // Keyframe overrides previous assignment. ++ if (frame->key_frame) { ++ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_PICTURE_TYPE_IDR); ++ } ++ } else if (avctx->codec->id == AV_CODEC_ID_HEVC) { ++ switch (frame->pict_type) { ++ case AV_PICTURE_TYPE_I: ++ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_HEVC_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_I); ++ break; ++ case AV_PICTURE_TYPE_P: ++ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_HEVC_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_P); ++ break; ++ case AV_PICTURE_TYPE_B: ++ av_log(ctx, AV_LOG_WARNING, "Ignoring B-Frame, unsupported by AMD AMF H.265 Encoder."); ++ break; ++ case AV_PICTURE_TYPE_S: ++ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_HEVC_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_SKIP); ++ break; ++ default: ++ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_HEVC_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_NONE); ++ break; ++ } ++ // Keyframe overrides previous assignment. ++ if (frame->key_frame) { ++ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_HEVC_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_IDR); ++ } ++ } + + // submit surface + res = ctx->encoder->pVtbl->SubmitInput(ctx->encoder, (AMFData*)surface); |