From patchwork Thu Jan 20 16:05:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 33726 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp5974390iog; Thu, 20 Jan 2022 08:05:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJL1BLMViE5k3RO7/TY+yzuwwAQojJeJ4G6Bbeisb0boU5UT8lHrmfBMgywurRbGr376hj X-Received: by 2002:a50:fe89:: with SMTP id d9mr37068737edt.252.1642694754823; Thu, 20 Jan 2022 08:05:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642694754; cv=none; d=google.com; s=arc-20160816; b=YCNUPKYSUQIx2b0Yrt0wvXo3FUhedkNVwAmOqdSPA9S0CqCbz2TwgjaDnopFR8Z8rX Lc7fX+mS5VzMIqiPvUqEpxtwTFPNAJSkLBn6Ch/2nO9uavSBsZkwNz6s+TJFQ1V9BoGd d4Wo1qbU6UzvcDjnSsoAFFmkMGUX2cLty7g1pX8QrIG1t0gJzUQb1a2SbdL99VZF4s2n xh9Dg2f/0IxIzrZnFc/bKrPO9MjBZXHlbpLCDrYlKKkPhdic//N80BS3KqXGCGKNXGly eOVaToFNgUO41mPSkxqmxUEloOcIOfW9JGWk+EqT7iLnGhhcQXcPYfOmXYGOkW6gsDEU Dxpw== 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=5JJSzstBNHpcgbLIICpj3cRc26O6hLZkRhiOGM96Wpo=; b=WmDIWwpq2gJOSGFrrDu5K6aJU5AnHH+V/gWXrfZwbMVHA8Dj/p9MyewI399MmPrsem B3yHHhIpplihA7ctNwGPilEUINdNF62I7ghM7izqCwA5aIyo7VCzCykX+/gC+iq7/xUZ HbnS9c7blDZ+NRLFY3NHizwwOL4jKcsltwhpcVTA4QAfVaA2zdJ2q1+nRTNHmXcGNRJ6 zbw+xUcjQX5jsayulR8CaQJH5jcbNLmyFE/PoWGuDpyHpRRi8ZKEmDonV5Ruu+GFj7IF T+EN4duG6koOtjcuvL7hlPqnhZ530vpZ4p1J2qwqiuj/yfIeyelmio6Ibvx1Ojx3IjgE MUgw== 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 b2si2030244edx.83.2022.01.20.08.05.54; Thu, 20 Jan 2022 08:05:54 -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 9DBC068B1DD; Thu, 20 Jan 2022 18:05:24 +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 9200168B19F for ; Thu, 20 Jan 2022 18:05:15 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 9D808240179 for ; Thu, 20 Jan 2022 17:05:14 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 6zxZvNwuxRqG for ; Thu, 20 Jan 2022 17:05:14 +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 2AF0124017E for ; Thu, 20 Jan 2022 17:05:13 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 2ACE73A0743; Thu, 20 Jan 2022 17:05:07 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 20 Jan 2022 17:05:06 +0100 Message-Id: <20220120160506.32698-3-anton@khirnov.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220120160506.32698-1-anton@khirnov.net> References: <20220120160506.32698-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] lavc/encode: pick a sane default for bits_per_raw_sample if it's not set 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: ZLqqpur4VxlS Fixes #9563. --- libavcodec/encode.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/encode.c b/libavcodec/encode.c index b6f81d1458..44ab81af3f 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -535,6 +535,9 @@ static int encode_preinit_audio(AVCodecContext *avctx) return AVERROR(EINVAL); } + if (!avctx->bits_per_raw_sample) + avctx->bits_per_raw_sample = 8 * av_get_bytes_per_sample(avctx->sample_fmt); + return 0; }