From patchwork Sun Nov 27 17:03:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39512 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp6961719pzb; Sun, 27 Nov 2022 09:10:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf5MdEoE5jtTNRTkcuHoTDxq1MVd0pXozhfp3GwjiWanT4qT44jzDCqr+dGO9LTzaBuXimh1 X-Received: by 2002:a17:906:160b:b0:78d:dddb:3974 with SMTP id m11-20020a170906160b00b0078ddddb3974mr39885258ejd.411.1669569010023; Sun, 27 Nov 2022 09:10:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669569010; cv=none; d=google.com; s=arc-20160816; b=EpESVFYX1Erbc/x37fhkjBkFf/SutYPS8VPDLj2l7W9XTYicjJnur6NEwCw5a7/02E pSExWeYn3gEOnfAJxitVGTGNKjZddqOl7ro3iqWwFT0D4gs9ccDJG9ZWe/4g0n4EHzTC fyy9XQa8dVARvv2QQw1J/XOd/q6gtYljjrVJVuovY77um9P5AR4fV28+qFdiv4jIfevT 9Uif2ZXUg2chA0nTKpg/gaXAfVTID37sTssbh6YksILwzqZlF/auQe8d6hBdFPfeo9n9 GNKBf++fbukOa8qCw5Ffgj4FrvpeAPLI52jWdw0DWEBxCNDoHBhiu/9ckM5krM45+aVq IGpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=xc2vdAE4oC1ihXqw+Z+dA1yj3ATlpWNxFhraiKvehbQ=; b=PaOBnIYjU162h/+C63/g+Ex7Lat2xwTw5aZSeaBnYZeGuWRq1ZujqQiE++dBlGPDSn FxfGHGi/K7S3KJaPiankT2wkap1Pf/lQ87490VuiiuK0p8olvwPILszluZ9QTh8DdQqD x6UefQKFaWKMeyKv7TsEOxxUrG7S4P8WJINv5fUPRR8NPikXZcYlcyo9HnWEe1NNnMd4 BAUAXdd0EGi2sLSaP6Ko1JQRxoEd38dfB3P+DCFV/1njXYAhNwwPq/KpNAApvjS652bx ULbWOcg0/gL70UzM/OBNYq6d+8oc2evTFW7BWk1FEi7kruS+DqUSjT7Zoih1woMQDchr BXuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id js15-20020a17090797cf00b007adcc8fb7a0si8511799ejc.399.2022.11.27.09.10.09; Sun, 27 Nov 2022 09:10:10 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8AA3168BB0D; Sun, 27 Nov 2022 19:06:27 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B58CD68B9A3 for ; Sun, 27 Nov 2022 19:06:05 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 821DA2404F8 for ; Sun, 27 Nov 2022 18:06:05 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id yWBwep-TAxC1 for ; Sun, 27 Nov 2022 18:06:04 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 1DB46240D25 for ; Sun, 27 Nov 2022 18:05:53 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 026C83A1E8B for ; Sun, 27 Nov 2022 18:05:46 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 27 Nov 2022 18:03:26 +0100 Message-Id: <20221127170351.11477-5-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221127170351.11477-1-anton@khirnov.net> References: <20221127170351.11477-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/30] lavc/libx264: reindent after previous commit X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: CePU+VyiCrC7 --- libavcodec/libx264.c | 104 +++++++++++++++++++++---------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 470e9bc8c7..1e9ca73cdf 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -338,70 +338,70 @@ static int setup_roi(AVCodecContext *ctx, x264_picture_t *pic, int bit_depth, { X264Context *x4 = ctx->priv_data; - if (x4->params.rc.i_aq_mode == X264_AQ_NONE) { - 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"); + if (x4->params.rc.i_aq_mode == X264_AQ_NONE) { + 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; + int mby = (frame->height + MB_SIZE - 1) / MB_SIZE; + int qp_range = 51 + 6 * (bit_depth - 8); + int nb_rois; + const AVRegionOfInterest *roi; + uint32_t roi_size; + float *qoffsets; + + roi = (const AVRegionOfInterest*)data; + roi_size = roi->self_size; + if (!roi_size || size % roi_size != 0) { + av_log(ctx, AV_LOG_ERROR, "Invalid AVRegionOfInterest.self_size.\n"); + return AVERROR(EINVAL); } - } else { - if (frame->interlaced_frame == 0) { - int mbx = (frame->width + MB_SIZE - 1) / MB_SIZE; - int mby = (frame->height + MB_SIZE - 1) / MB_SIZE; - int qp_range = 51 + 6 * (bit_depth - 8); - int nb_rois; - const AVRegionOfInterest *roi; - uint32_t roi_size; - float *qoffsets; - - roi = (const AVRegionOfInterest*)data; - roi_size = roi->self_size; - if (!roi_size || size % roi_size != 0) { - av_log(ctx, AV_LOG_ERROR, "Invalid AVRegionOfInterest.self_size.\n"); - return AVERROR(EINVAL); - } - nb_rois = size / roi_size; + nb_rois = size / roi_size; - qoffsets = av_calloc(mbx * mby, sizeof(*qoffsets)); - if (!qoffsets) - return AVERROR(ENOMEM); + qoffsets = av_calloc(mbx * mby, sizeof(*qoffsets)); + if (!qoffsets) + return AVERROR(ENOMEM); - // This list must be iterated in reverse because the first - // region in the list applies when regions overlap. - for (int i = nb_rois - 1; i >= 0; i--) { - int startx, endx, starty, endy; - float qoffset; + // This list must be iterated in reverse because the first + // region in the list applies when regions overlap. + for (int i = nb_rois - 1; i >= 0; i--) { + int startx, endx, starty, endy; + float qoffset; - roi = (const AVRegionOfInterest*)(data + roi_size * i); + roi = (const AVRegionOfInterest*)(data + roi_size * i); - starty = FFMIN(mby, roi->top / MB_SIZE); - endy = FFMIN(mby, (roi->bottom + MB_SIZE - 1)/ MB_SIZE); - startx = FFMIN(mbx, roi->left / MB_SIZE); - endx = FFMIN(mbx, (roi->right + MB_SIZE - 1)/ MB_SIZE); + starty = FFMIN(mby, roi->top / MB_SIZE); + endy = FFMIN(mby, (roi->bottom + MB_SIZE - 1)/ MB_SIZE); + startx = FFMIN(mbx, roi->left / MB_SIZE); + endx = FFMIN(mbx, (roi->right + MB_SIZE - 1)/ MB_SIZE); - if (roi->qoffset.den == 0) { - av_free(qoffsets); - av_log(ctx, AV_LOG_ERROR, "AVRegionOfInterest.qoffset.den must not be zero.\n"); - return AVERROR(EINVAL); - } - qoffset = roi->qoffset.num * 1.0f / roi->qoffset.den; - qoffset = av_clipf(qoffset * qp_range, -qp_range, +qp_range); + if (roi->qoffset.den == 0) { + av_free(qoffsets); + av_log(ctx, AV_LOG_ERROR, "AVRegionOfInterest.qoffset.den must not be zero.\n"); + return AVERROR(EINVAL); + } + qoffset = roi->qoffset.num * 1.0f / roi->qoffset.den; + qoffset = av_clipf(qoffset * qp_range, -qp_range, +qp_range); - for (int y = starty; y < endy; y++) { - for (int x = startx; x < endx; x++) { - qoffsets[x + y*mbx] = qoffset; - } + for (int y = starty; y < endy; y++) { + for (int x = startx; x < endx; x++) { + qoffsets[x + y*mbx] = qoffset; } } + } - pic->prop.quant_offsets = qoffsets; - pic->prop.quant_offsets_free = av_free; - } else { - 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"); - } + pic->prop.quant_offsets = qoffsets; + pic->prop.quant_offsets_free = av_free; + } else { + 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"); } } + } return 0; }