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

Hendrik Leppkes h.leppkes at gmail.com
Mon Dec 14 09:34:11 CET 2015


On Mon, Dec 14, 2015 at 9:02 AM, Ivan Uskov <ivan.uskov at nablet.com> wrote:
> Hello Will,
>
> Friday, December 11, 2015, 6:47:28 PM, you wrote:
>
> WK> Since adaptive_i support is broken, this allows the QSV encoder to use scene-
> WK> change hints from the input stream if force_key_frames = source is used.  The
> WK> result will be improved transcoding quality at scene change boundaries.
>
> WK> Signed-off-by: Will Kelleher <wkelleher at gogoair.com>
> WK> ---
> WK>  libavcodec/qsvenc.c | 11 +++++++++++
> WK>  1 file changed, 11 insertions(+)
>
> WK> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
> WK> index d00fdff..74e40f7 100644
> WK> --- a/libavcodec/qsvenc.c
> WK> +++ b/libavcodec/qsvenc.c
> WK> @@ -939,6 +939,17 @@ int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext *q,
> WK>          q->set_encode_ctrl_cb(avctx, frame, &qsv_frame->enc_ctrl);
> WK>      }
> WK>
> WK> +    if (enc_ctrl) {
> +        if (frame->>pict_type == AV_PICTURE_TYPE_I) {
> WK> +            enc_ctrl->FrameType = MFX_FRAMETYPE_I | MFX_FRAMETYPE_REF;
> WK> +            if (frame->key_frame) {
> WK> +                enc_ctrl->FrameType |= MFX_FRAMETYPE_IDR;
> WK> +            }
> WK> +        } else {
> WK> +            enc_ctrl->FrameType = 0;
> WK> +        }
> WK> +    }
> WK> +
> WK>      do {
> WK>          ret = MFXVideoENCODE_EncodeFrameAsync(q->session, enc_ctrl, surf, bs, &sync);
> WK>          if (ret == MFX_WRN_DEVICE_BUSY) {
> Am  I understanding  right  that suggesting feature is non-optional and will
> active  always? I believe it should have own option to activate because there
> are negative side effects are possible.
>

Strictly speaking, by default the input frames will not have pict_type
set, unless you explicitly instruct ffmpeg to set it. So it is
optional.


More information about the ffmpeg-devel mailing list