From patchwork Sat Sep 2 15:19:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Sabatini X-Patchwork-Id: 43473 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4f16:b0:149:dfde:5c0a with SMTP id gi22csp226372pzb; Sat, 2 Sep 2023 08:21:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFPVGc6y55t6SVH4U8vxoMpzyCUfkYgWtECWOsgJajAsI1NScY5+eIHOjI7wxfl9hnI7LWX X-Received: by 2002:a50:fe8e:0:b0:523:4b92:9cf8 with SMTP id d14-20020a50fe8e000000b005234b929cf8mr3862371edt.29.1693668078077; Sat, 02 Sep 2023 08:21:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693668078; cv=none; d=google.com; s=arc-20160816; b=Ze000LwzwD5kUnRsVQwHje1dQspOOWv/T1KgF8kbQlYYjA1n3uVRveLwAXyxzKUYNT fXUVeZmwxZsPf9SlCl+5/x5yf7ycx/JIxcWgaOB5Y7CyLU674VqVwybd7QE+NHAjHyEo eAjo/xu7vrDwZC0Q9/OW7vRfZdOeal/1KNB0fzu+lmccvcHElFRbCXtIM0q1t6S9UKep cJ8fg0ivSrfBIjmcz7HXEATGdv2MTnqXwv6NPwpKqqKSzDsNAH1dPS8CB5141eBf1M6S vRH9wYK4RJNlvTjf8WHV3noV0T4NA/vGizJVnfa4ZP6n8OQPuXwNKk2ZoAMjNxdAtABz qgRQ== 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=L9mAfdJYBmFg2xZq4Nfg8oWDHyKZqS8/UrbKoSK68Pk=; fh=QdWxt2OToL83TTnLQn0lGhLakV7i1QyAJdC8te7qN0E=; b=1A3AEJoiuUIcnAKVkzuOJpiltXDiyqD2Oxrxb+HJpMgyA3cBYLtN2PiHZf1cjuNRjF pDIfNXA+wZnHykiU40QYNiS1z+4rICX+KuCtWMayR6xAZgnwy8wSmIKa1q+XRfKecdJw tb4kQ1Dmj2u1TlbjKcv5MRMh7IXiZIz8jer/M9Z/u90FbRnb5CM8V8gT+rb/5A9ZiU8I ypCoVxRiuFlnBI5JHYf29IDa9sVG4ZnmfEnKRA4tfxhPi09QIJkY0ICiw41YO0Nw/rny c+Cmq9r6vmDlw/P1w1QXn9JBYpD5pnpkDHBZjkzLrsNWHhs948bzl3KlagbgptWwvJVZ HbdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=CFP4TxHa; 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 c21-20020aa7d615000000b0052683da3e48si4072358edr.454.2023.09.02.08.21.17; Sat, 02 Sep 2023 08:21:18 -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=CFP4TxHa; 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 ABAA868C80D; Sat, 2 Sep 2023 18:19:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A21FE68C7DF for ; Sat, 2 Sep 2023 18:19:48 +0300 (EEST) Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-401b0d97850so485535e9.2 for ; Sat, 02 Sep 2023 08:19:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693667987; x=1694272787; 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=TiuioRK69WMnvph+BIXBPdqlB7K7prjD/Hcq0NcIt1U=; b=CFP4TxHaRV1ZGsJlB6xSTZMUTp/PDJGSUuY4gY/1LFb2qTnezTtwSP9rhsrX179cpl I9ZDBSZA2cnNQEPgHbNJGT/vk2zU70AvpOLZDd74G2rK70azTBBu6nsbu7a/NOAhMWl4 ITnp0RBL9DLLLSuCZOMSIXRqF8sqC88RebWJgQlGWfAE6bmkW5/FiVrV6XqwsmgH0/8X sU/71KFA/Loy8NftHOlpX1RZCfm1otduN3N0Scu0oKitXKA/LlvhFazN1M1vxMeUK4c/ poiXcRag4qTqawITNr4etmBy7BG2mDOLWc/QV8m35n6kSCHkGEdmLL4OK2ZfpBHaOuoP aRYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693667987; x=1694272787; 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=TiuioRK69WMnvph+BIXBPdqlB7K7prjD/Hcq0NcIt1U=; b=KJHSBhFTphpUkOiQd9dQk6wdKrCpUzXyiKkVcxAKyyiUYvVryToGp30HD7fHGvR3RC cFAhlMwvTpjHLFkNoip9aLJhLxxqYPYf5webUE7Ddkg0u2PlWnhzLD3ZsP2PbA8F37Zf pz0grriJ42cZrifrL/v7B+GJVlXAKgO5f75jLXJvLLc1NsufHIEWBVTa840WmEOwzT4k 8VeQJvHIC+aQKBhdYHoq11jYruGKncC40roc0bd7145QHViB+b+HDad7p8gWlU56QE0m WpN9B8C3Q1Knet9gn21CtxWtvZLWqw8tyc78s9f99Eda/lIZYA9HpX/W76/c8HjavHh7 WfSw== X-Gm-Message-State: AOJu0YxUQBWfI6PER8p21gouTbW6Tl5J1X0tfDvTJ9WwYQTn+h6lL0DL i/yYe1qxSiBYweWnq5m9NCTYjikUvuU= X-Received: by 2002:a05:600c:446:b0:3fd:2e1d:eca1 with SMTP id s6-20020a05600c044600b003fd2e1deca1mr4191841wmb.4.1693667986705; Sat, 02 Sep 2023 08:19:46 -0700 (PDT) Received: from mariano ([82.84.194.139]) by smtp.gmail.com with ESMTPSA id y11-20020a1c4b0b000000b003fe2b081661sm11295277wma.30.2023.09.02.08.19.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Sep 2023 08:19:41 -0700 (PDT) Received: by mariano (Postfix, from userid 1000) id 640B4BFCF0; 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:21 +0200 Message-Id: <20230902151921.1712373-12-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 11/11] doc/examples/transcode: fix selection of sample format if not set in encoder 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: ZWY8qWMpAHwV Fix crash occurring when the list of sample formats is not defined in the encoder, use the decoder one in that case. Possibly fix issue: http://trac.ffmpeg.org/ticket/5849 --- doc/examples/transcode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/examples/transcode.c b/doc/examples/transcode.c index 1d22a4b09e..3c72b9377e 100644 --- a/doc/examples/transcode.c +++ b/doc/examples/transcode.c @@ -189,8 +189,10 @@ static int open_output_file(const char *filename) ret = av_channel_layout_copy(&enc_ctx->ch_layout, &dec_ctx->ch_layout); if (ret < 0) return ret; - /* take first format from list of supported formats */ - enc_ctx->sample_fmt = encoder->sample_fmts[0]; + + /* take first format from list of supported formats or use decoder one */ + enc_ctx->sample_fmt = encoder->sample_fmts ? encoder->sample_fmts[0] : dec_ctx->sample_fmt; + enc_ctx->time_base = (AVRational){1, enc_ctx->sample_rate}; }