[FFmpeg-devel] [PATCH 1/2] qsvenc: Use scene-change hints from source frame if available

Will Kelleher wkelleher at gogoair.com
Fri Dec 11 16:47:28 CET 2015


Since adaptive_i support is broken, this allows the QSV encoder to use scene-
change hints from the input stream if force_key_frames = source is used.  The
result will be improved transcoding quality at scene change boundaries.

Signed-off-by: Will Kelleher <wkelleher at gogoair.com>
---
 libavcodec/qsvenc.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index d00fdff..74e40f7 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -939,6 +939,17 @@ int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext *q,
         q->set_encode_ctrl_cb(avctx, frame, &qsv_frame->enc_ctrl);
     }
 
+    if (enc_ctrl) {
+        if (frame->pict_type == AV_PICTURE_TYPE_I) {
+            enc_ctrl->FrameType = MFX_FRAMETYPE_I | MFX_FRAMETYPE_REF;
+            if (frame->key_frame) {
+                enc_ctrl->FrameType |= MFX_FRAMETYPE_IDR;
+            }
+        } else {
+            enc_ctrl->FrameType = 0;
+        }
+    }
+
     do {
         ret = MFXVideoENCODE_EncodeFrameAsync(q->session, enc_ctrl, surf, bs, &sync);
         if (ret == MFX_WRN_DEVICE_BUSY) {
-- 
2.6.2



More information about the ffmpeg-devel mailing list