From patchwork Tue May 14 15:59:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Andreas_H=C3=A5kon?= X-Patchwork-Id: 13110 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 87EA1444A22 for ; Tue, 14 May 2019 19:00:13 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6894B689259; Tue, 14 May 2019 19:00:13 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-40135.protonmail.ch (mail-40135.protonmail.ch [185.70.40.135]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 506C4680110 for ; Tue, 14 May 2019 19:00:07 +0300 (EEST) Date: Tue, 14 May 2019 15:59:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=default; t=1557849605; bh=e/gUkNnLmFEgrg8wpHwMB1xSZPAvhMrwFnpud15esRI=; h=Date:To:From:Reply-To:Subject:Feedback-ID:From; b=HBX8kjeiW/hz+mf1oTaZepa6xoSL8mMk4S+dDbslbHZwKnJK7sV9OpP2C9TRl15kQ OCg/jUNu79eXjWdiX0/eJkr0sGLeRSggSzM+TeW/z9me5eQZlnyeGJQ34Xl+CwXII/ zaF9nGmTx+dmraWrDL5ubZ816vdj38xk0mfUke7o= To: FFmpeg development discussions and patches From: =?UTF-8?Q?Andreas_H=C3=A5kon?= Message-ID: Feedback-ID: Mx8CaiV20jk_fqXDN0fFpg3vRaGkb9VCTrYRnZNHwEija3aOdqvFspzl6ODkmHrlSKJSx29p-LzkuvS_96L02A==:Ext:ProtonMail MIME-Version: 1.0 X-Spam-Status: No, score=-1.2 required=7.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.protonmail.ch X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [FFmpeg-devel] [PATCH] libavcodec/qsvenc: fix mpeg2 encoding X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Fixes bug #7839 https://trac.ffmpeg.org/ticket/7839 Supersedes: #12935 - https://patchwork.ffmpeg.org/patch/12935/ #12872 - https://patchwork.ffmpeg.org/patch/12872/ Regards. A.H. --- From 49aa7d21026051dc353a8658509d2ba81520bf78 Mon Sep 17 00:00:00 2001 From: Andreas Hakon Date: Tue, 14 May 2019 16:42:08 +0100 Subject: [PATCH] libavcodec/qsvenc: fix mpeg2 encoding Commit "lavc/qsvenc: enable QVBR mode" generated a regression with the MPEG-2 QSV HW Encoder on the Windows platform. See trac #7839. This patch fixes the problem by running a runtime check during initialization. When using the MPEG-2 encoder the extended CO3 buffer is not added to the context. Signed-off-by: Andreas Hakon --- libavcodec/qsvenc.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index a03ab69..9d26db0 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -267,10 +267,12 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, #endif #endif +#if QSV_HAVE_CO3 #if QSV_HAVE_GPB if (avctx->codec_id == AV_CODEC_ID_HEVC) av_log(avctx, AV_LOG_VERBOSE,"GPB: %s\n", print_threestate(co3->GPB)); #endif +#endif if (avctx->codec_id == AV_CODEC_ID_H264) { av_log(avctx, AV_LOG_VERBOSE, "Entropy coding: %s; MaxDecFrameBuffering: %"PRIu16"\n", @@ -598,9 +600,11 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) q->param.mfx.MaxKbps = max_bitrate_kbps / brc_param_multiplier; q->param.mfx.BRCParamMultiplier = brc_param_multiplier; #if QSV_HAVE_QVBR +#if QSV_HAVE_CO3 if (q->param.mfx.RateControlMethod == MFX_RATECONTROL_QVBR) q->extco3.QVBRQuality = av_clip(avctx->global_quality, 0, 51); #endif +#endif break; case MFX_RATECONTROL_CQP: quant = avctx->global_quality / FF_QP2LAMBDA; @@ -751,13 +755,16 @@ FF_ENABLE_DEPRECATION_WARNINGS #endif } #if QSV_HAVE_CO3 - q->extco3.Header.BufferId = MFX_EXTBUFF_CODING_OPTION3; - q->extco3.Header.BufferSz = sizeof(q->extco3); + if (avctx->codec_id != AV_CODEC_ID_MPEG2VIDEO ) { + av_log(avctx,AV_LOG_DEBUG,"Initializing the MFX context with the Extended Coding Option 3 (extco3)\n"); + q->extco3.Header.BufferId = MFX_EXTBUFF_CODING_OPTION3; + q->extco3.Header.BufferSz = sizeof(q->extco3); #if QSV_HAVE_GPB - if (avctx->codec_id == AV_CODEC_ID_HEVC) - q->extco3.GPB = q->gpb ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; + if (avctx->codec_id == AV_CODEC_ID_HEVC) + q->extco3.GPB = q->gpb ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; #endif - q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->extco3; + q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->extco3; + } #endif }