From patchwork Mon Sep 23 02:02:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Guo, Yejun" X-Patchwork-Id: 15227 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 9E644449DD8 for ; Mon, 23 Sep 2019 05:07:41 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 789066881DB; Mon, 23 Sep 2019 05:07:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EA7BF6881B0 for ; Mon, 23 Sep 2019 05:07:34 +0300 (EEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Sep 2019 19:07:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,538,1559545200"; d="scan'208";a="203024274" Received: from yguo18-skl-u1604.sh.intel.com ([10.239.13.25]) by fmsmga001.fm.intel.com with ESMTP; 22 Sep 2019 19:07:31 -0700 From: "Guo, Yejun" To: ffmpeg-devel@ffmpeg.org Date: Mon, 23 Sep 2019 10:02:34 +0800 Message-Id: <1569204154-16526-1-git-send-email-yejun.guo@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCH V2] libavcodec/libx264 and libx265: add a flag to output ROI warnings only once. 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 Cc: yejun.guo@intel.com MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Guo, Yejun --- libavcodec/libx264.c | 16 ++++++++++++++-- libavcodec/libx265.c | 11 ++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 86e3530..8788286 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -99,6 +99,12 @@ typedef struct X264Context { int nb_reordered_opaque, next_reordered_opaque; int64_t *reordered_opaque; + + /** + * If the encoder does not support ROI then warn the first time we + * encounter a frame with ROI side data. + */ + int roi_warned; } X264Context; static void X264_log(void *p, int level, const char *fmt, va_list args) @@ -356,7 +362,10 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, sd = av_frame_get_side_data(frame, AV_FRAME_DATA_REGIONS_OF_INTEREST); if (sd) { if (x4->params.rc.i_aq_mode == X264_AQ_NONE) { - av_log(ctx, AV_LOG_WARNING, "Adaptive quantization must be enabled to use ROI encoding, skipping ROI.\n"); + if (!x4->roi_warned) { + x4->roi_warned = 1; + av_log(ctx, AV_LOG_WARNING, "Adaptive quantization must be enabled to use ROI encoding, skipping ROI.\n"); + } } else { if (frame->interlaced_frame == 0) { int mbx = (frame->width + MB_SIZE - 1) / MB_SIZE; @@ -410,7 +419,10 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, x4->pic.prop.quant_offsets = qoffsets; x4->pic.prop.quant_offsets_free = av_free; } else { - av_log(ctx, AV_LOG_WARNING, "interlaced_frame not supported for ROI encoding yet, skipping ROI.\n"); + if (!x4->roi_warned) { + x4->roi_warned = 1; + av_log(ctx, AV_LOG_WARNING, "interlaced_frame not supported for ROI encoding yet, skipping ROI.\n"); + } } } } diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index 665b780..4e75077 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -47,6 +47,12 @@ typedef struct libx265Context { char *tune; char *profile; char *x265_opts; + + /** + * If the encoder does not support ROI then warn the first time we + * encounter a frame with ROI side data. + */ + int roi_warned; } libx265Context; static int is_keyframe(NalUnitType naltype) @@ -310,7 +316,10 @@ static av_cold int libx265_encode_set_roi(libx265Context *ctx, const AVFrame *fr AVFrameSideData *sd = av_frame_get_side_data(frame, AV_FRAME_DATA_REGIONS_OF_INTEREST); if (sd) { if (ctx->params->rc.aqMode == X265_AQ_NONE) { - av_log(ctx, AV_LOG_WARNING, "Adaptive quantization must be enabled to use ROI encoding, skipping ROI.\n"); + if (!ctx->roi_warned) { + ctx->roi_warned = 1; + av_log(ctx, AV_LOG_WARNING, "Adaptive quantization must be enabled to use ROI encoding, skipping ROI.\n"); + } } else { /* 8x8 block when qg-size is 8, 16*16 block otherwise. */ int mb_size = (ctx->params->rc.qgSize == 8) ? 8 : 16;