From patchwork Sat Sep 2 15:19:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Sabatini X-Patchwork-Id: 43470 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4f16:b0:149:dfde:5c0a with SMTP id gi22csp226182pzb; Sat, 2 Sep 2023 08:20:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGa9FHQm54NLsGn/QUoFWbQ6y0wZkeKDrvpB6aQfeyHoNz4nkgB/BwQfoa7jAMPl7XCdKmO X-Received: by 2002:a17:906:76c8:b0:9a1:bcf9:4f99 with SMTP id q8-20020a17090676c800b009a1bcf94f99mr3503518ejn.36.1693668051578; Sat, 02 Sep 2023 08:20:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693668051; cv=none; d=google.com; s=arc-20160816; b=hGqIe1Fbyi16cP3mJvvhSyOQ65RI7NKec7CCvL5gcDHdZ+1Jms7non6a8gkKXt1xwK RUQ7pCBKQ3B6k2c91xL1S+lWcGBIZMc4RntgGrYdgkSBfehT5B0WFmQDXHpjgQzKqoZ/ WRThEAP0qKmkwFikSi4yT2X7x3c29qBgzOYA2u73exsK6QHEmnVo6/1Q7KhEEc54obhm JC9efOHjbguG4S5kFqqP8xNxlKeGRNeAbEXXvNBB4Q0MhErsptdjW8+QFftwAt/8SzKr q3tjyZZuWHyMb8mQMJ8CIC51FQGBI3jUR9xasQPunkfp3j22+DZES3jBdv1Hb9Q1cqns Zs9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc: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:dkim-signature:delivered-to; bh=2ayyncz0y4C4Jh2N3eJfwzMJZ7uDObeqo45dMGGPbtk=; fh=QdWxt2OToL83TTnLQn0lGhLakV7i1QyAJdC8te7qN0E=; b=okjB+G273+5xmgJg/hyCkFBUfZSvsR+W522n174NT739qXJ/FSMeivfdl7tC7nA3K4 gIG1AIsmaGwSeMIV+tVKUGf/pMkT5sve4PdcZuZCpXealF2m0WIx9FOmmdVptQ+xfRxd 8pz/SsLn3sW05HqZzgzbDLTfLK0cNAOAJSWxeumrgesBZIkGeRMPMdnJjRWCZw7WO1p9 hw7BbfrmfuMbe972jDeZVm7pl1wyEnkYb0dQFb+WvNmxAA1zXOdjM/P5rl+XkujQc+hM W22MjepdWYMmeRTz6ZUt5Nx4E5GoOiTM5i9O09QoQE7du3dO6oGQE7JNJU7IxLIiyuV/ jItg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=MmsmbzZ4; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id rs10-20020a170907036a00b009a21af2dd2esi4023366ejb.612.2023.09.02.08.20.50; Sat, 02 Sep 2023 08:20:51 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=MmsmbzZ4; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8AF1568C7F2; Sat, 2 Sep 2023 18:19:50 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6E71A68C7BB for ; Sat, 2 Sep 2023 18:19:46 +0300 (EEST) Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-31ae6bf91a9so2511488f8f.2 for ; Sat, 02 Sep 2023 08:19:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693667985; x=1694272785; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DODfSd3CyBS4rxIoUggJVmRhc5p6zBdTqGXyhJmoXo0=; b=MmsmbzZ4pUjpVtCYQxPN0qp3RGcM7CmWgatu1MI22NQFekvpaunZ9qgxIJFtkIQYqv w8p1qKyRPw44XYVZyfgPq4QofLusV9a7AhnnKf3e5V8pBVzh3aiiFgqW1IaJgHUxHdHG UtCUIFdTLSmnUrT1ros+uZ70XP8rWsGov60v0gCW/fjaO+o0ES8GaIEThLxNUdlEldjw 3GaoLUDCdqEL6Ruwp04G2szJO7V93rJi1Gu3vDffzWuD2YBhzKwRfpMH9lZs/iWM+ScM BryB3KXJ2i2nyUKC7vjQK49sap7b35kV1ygAXl3n96k5JCBnNGiBzIFEprv127W6IKyq e3oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693667985; x=1694272785; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DODfSd3CyBS4rxIoUggJVmRhc5p6zBdTqGXyhJmoXo0=; b=YatRgSROSM/KZN18MA8Eu0cpL88WLsXlCPYboKSJkso7gerFyWAifxJOpciu6t7HK4 R337DzsUOPC4FLx4gJDquM+SqnYhJWKA/4e2BK9ilavtsNwQqaYgn4/C4CAgyDGHGtGT QWRKCUtWsv3K3xJS4tDZ+OImWocA8JOYFQX0Y4em9ydABncrTT0SELBPHyAn2aMNX1Pz 2JMAqr5AjtN9r4wznJWlwsd05rdnEkgX0I0UaY9VJoDU911GxpwWzFtJb7PmAwjZJa0L UQjggKTGcn9VTA8fV42kGsXOOkbUfbUlpGr7pmvLvOAWsm0/CHwVs/sihuwLXC130tV0 MHhA== X-Gm-Message-State: AOJu0Yw1meukNG6ZiAiiF//u1UEe7MtdZEIHOonAd6Xa2piItbT57EDr jmujyyyGl/gvFocSqZB44fW0uDj4DwM= X-Received: by 2002:adf:f512:0:b0:31a:c6ef:5edc with SMTP id q18-20020adff512000000b0031ac6ef5edcmr3847425wro.12.1693667984925; Sat, 02 Sep 2023 08:19:44 -0700 (PDT) Received: from mariano ([82.84.194.139]) by smtp.gmail.com with ESMTPSA id x9-20020adfdd89000000b003196b1bb528sm8876044wrl.64.2023.09.02.08.19.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Sep 2023 08:19:37 -0700 (PDT) Received: by mariano (Postfix, from userid 1000) id 60669BFCEE; Sat, 2 Sep 2023 17:19:31 +0200 (CEST) From: Stefano Sabatini To: FFmpeg development discussions and patches Date: Sat, 2 Sep 2023 17:19:20 +0200 Message-Id: <20230902151921.1712373-11-stefasab@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230902151921.1712373-1-stefasab@gmail.com> References: <20230902151921.1712373-1-stefasab@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/11] doc/examples/transcode: simplify selection of pix_fmt 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 Cc: Stefano Sabatini Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: gzyz01bM8aUS Use ternary operator. --- doc/examples/transcode.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/doc/examples/transcode.c b/doc/examples/transcode.c index 524bb47f50..1d22a4b09e 100644 --- a/doc/examples/transcode.c +++ b/doc/examples/transcode.c @@ -178,11 +178,10 @@ static int open_output_file(const char *filename) enc_ctx->height = dec_ctx->height; enc_ctx->width = dec_ctx->width; enc_ctx->sample_aspect_ratio = dec_ctx->sample_aspect_ratio; - /* take first format from list of supported formats */ - if (encoder->pix_fmts) - enc_ctx->pix_fmt = encoder->pix_fmts[0]; - else - enc_ctx->pix_fmt = dec_ctx->pix_fmt; + + /* take first format from list of supported formats or use decoder one */ + enc_ctx->pix_fmt = encoder->pix_fmts ? encoder->pix_fmts[0] : dec_ctx->pix_fmt; + /* video time_base can be set to whatever is handy and supported by encoder */ enc_ctx->time_base = av_inv_q(dec_ctx->framerate); } else {