From patchwork Tue Jul 28 12:22:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takio Yamaoka X-Patchwork-Id: 21338 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 DA45444B4FF for ; Tue, 28 Jul 2020 15:30:20 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B3ECE68B99A; Tue, 28 Jul 2020 15:30:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ED8AB68B84D for ; Tue, 28 Jul 2020 15:30:14 +0300 (EEST) Received: by mail-pf1-f193.google.com with SMTP id w126so10706075pfw.8 for ; Tue, 28 Jul 2020 05:30:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=6A/5a8kTIHNXnSBqEgaHhJMmhA0fCxLmZqV6LoNcOJc=; b=Z119Xa2fkwiBB0bpFIg4dMehNtRGwMzYSk8G5fGrFgs5DiGXiO03zzAwlbG635OWNh gfxT+PuTy06WvyaMXBRU4ohRW6d1aXkZ6T6fdQ2Ov6LI9UcyUfQcekNuxMEm7OzuFciW Fy1lKIRHEMAl2o40V2oxRo6iw2rFy301YBVSJkuqQlOOsAXYSwM3J8IlZGOmkHsDj8XV fmlm558mitaRuTNzPEo7BqwEhSCqkLP5d4tDRjklEQi/W4WGSB2e0SDroD279zbHumdP FwPOWGgRdgyVxYGNwh+ZJALaLm5xlWgpqtArn87DkfS3qiZadm14+Mv40K7ag+sOrT7y wVaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=6A/5a8kTIHNXnSBqEgaHhJMmhA0fCxLmZqV6LoNcOJc=; b=BWG9i6ZND4aV0TjgJ30dYSHGVzYA4n8l5rDGS0+/J+m5MB9fJQ+YHdqxwE1agzS25H 0iO9ZSmCKu5lXEuDJ6cW0L2YZ2/2XuNQ5GmaueKqCGDz7efD9sZxvCG9jI1cxMm+kTca v0aDLHmSqjSuoZWREM3PFU1e7fPWHQhzMoaxPZrbgtwRHHiuyyrgTOTJSBf3PHJtDaeu Cp/uaRe54X8wEO3/MuN/rRcQzDHAC24ks5m5Y6wPK2Yqnpjf+9SRgnfl9v3xa+L+Joyy zVnyXtysUlq2PnGCPqf1yO+6qh8VQ2xvdqcP04mCaLrTNelLR9sFL9ggXZgFwmQ1vm8x zCGg== X-Gm-Message-State: AOAM53060Vxps3IN62q/41Nw2V/ZQitA95dvy5Wv5eKI3AWPhQ2xFzwR xbbnnQH2AzOfczFR3p2gMrLd670+QTc= X-Google-Smtp-Source: ABdhPJymK0uHl/NMwUXWMZg4EDK4xcj1JGo0lQNP+gEoPI6NfKoyQtQnBRMCF6PV6vvfrkbNSJ26mg== X-Received: by 2002:a62:ab15:: with SMTP id p21mr25276429pff.146.1595938928389; Tue, 28 Jul 2020 05:22:08 -0700 (PDT) Received: from localhost.localdomain (112-69-119-199f1.osk2.eonet.ne.jp. [112.69.119.199]) by smtp.gmail.com with ESMTPSA id z190sm9697488pfz.67.2020.07.28.05.22.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 05:22:07 -0700 (PDT) From: Takio Yamaoka To: ffmpeg-devel@ffmpeg.org Date: Tue, 28 Jul 2020 21:22:02 +0900 Message-Id: <20200728122202.14074-1-y.takio@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH] libavcodec/libx264.c: Fix chromaoffset of libx264 doesn't work 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: Takio Yamaoka MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" An initial value of `AVCodecContext::chromaoffset` is zero, then it causes to block `-chromaoffset` setting as result. In addition, even though a negative number of `chromaoffset` is meaningful, `X264Context::chroma_offset` is initialized with `-1` as no setting and ignored if it is negative number. To fix above, it changes ... - a value of `X264Context::chroma_offset` to 0 as no setting - due to x264's default value - conditional statement to import `-chromaoffset` Signed-off-by: Takio Yamaoka Signed-off-by: Takio Yamaoka --- libavcodec/libx264.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 7bbeab7d4c..347d29df27 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -681,11 +681,11 @@ static av_cold int X264_init(AVCodecContext *avctx) #if FF_API_PRIVATE_OPT FF_DISABLE_DEPRECATION_WARNINGS - if (avctx->chromaoffset >= 0) + if (avctx->chromaoffset) x4->chroma_offset = avctx->chromaoffset; FF_ENABLE_DEPRECATION_WARNINGS #endif - if (x4->chroma_offset >= 0) + if (x4->chroma_offset) x4->params.analyse.i_chroma_qp_offset = x4->chroma_offset; if (avctx->gop_size >= 0) @@ -1140,7 +1140,7 @@ static const AVOption options[] = { { "vlc", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "coder" }, { "ac", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "coder" }, { "b_strategy", "Strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 2, VE }, - { "chromaoffset", "QP difference between chroma and luma", OFFSET(chroma_offset), AV_OPT_TYPE_INT, { .i64 = -1 }, INT_MIN, INT_MAX, VE }, + { "chromaoffset", "QP difference between chroma and luma", OFFSET(chroma_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, VE }, { "sc_threshold", "Scene change threshold", OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, { .i64 = -1 }, INT_MIN, INT_MAX, VE }, { "noise_reduction", "Noise reduction", OFFSET(noise_reduction), AV_OPT_TYPE_INT, { .i64 = -1 }, INT_MIN, INT_MAX, VE },