From patchwork Wed Feb 24 11:53:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 25959 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 F0AB844B5C7 for ; Wed, 24 Feb 2021 13:54:31 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D1FBE68A9BB; Wed, 24 Feb 2021 13:54:31 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0A50B68A78A for ; Wed, 24 Feb 2021 13:54:24 +0200 (EET) Received: by mail-wr1-f45.google.com with SMTP id u14so1624397wri.3 for ; Wed, 24 Feb 2021 03:54:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lSALQ0RYubNUfw/2z3kTto+uA/3i++0+/oD8fSTH7yA=; b=dkpb61OCq1GXXY+USuwWs8wuPPSO88gNuS7DGh7ETtFsy5cmT8eebZxTnvkPlf0zmt 3KW6ttykrOhuDvYamDXpIC8Jjgw/G2bX1ixap485YcdMsupUFM5P6gAEG4W9ZtoRy1H6 MoSTfPfg6bbTKOZr7Kq6FWdjvn+Z0Iu0Kn2BIQuwJadyhOK0CEEyQ6His2LTfu4XU4Km aQnhgA2BYudnJVxmBqCzPUOjXlC3K4yPr4UNVDRpINQ0S+WRuDN9cff2efCwaML3xexq Bcn1utc+1vg+hR7ejofbEJMR6QRSyh/4157vGnlqaA+HOcIRTYkRWeWXHjJ9jMJy4r9k mTmw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=lSALQ0RYubNUfw/2z3kTto+uA/3i++0+/oD8fSTH7yA=; b=DRLdhGmadBw//36w/9sLbtFIRsdneUdSL4TPaA8QKGr91jXtJT3hg+35R9k/qNPG1u 3Ar4OfgatXhEIjKOlRMO6nDVNmDEgOMtdtip72hR8YblYky4mmLudithONPmqft0XRX7 /w1EzEquxa1r93t3SO7mydEfDLhhsCGmceXaCh9UHZqA9x01YecL8wcQEIBmyvkYmctE tkIA6UzrEylKC5UvgCDsoM8l8uJGAh6bkbS/C+J64DMm4SQtNGLrzvr3pKrEyEeUfmNY hp59YXN8KqUCUp37/EybMTweC56CkxKqeSfBurY56ENApBBeRDOum356xRr+Y8a1ZSRF bd9g== X-Gm-Message-State: AOAM533CMHTNo6nMA5C2gHOBfvfAAgfYVKhfMUywcHO7py4H5glci8Gz wQpK6gGW/McDroefl+2r9RCQawmvPy4= X-Google-Smtp-Source: ABdhPJwjYEmuvSDi5T2ZgQxtmbxH0hRBUFfbNE7uEJhsjX6QeGnIxth3n9KtfS7FlzXcWhdg04Tnqw== X-Received: by 2002:adf:ce8a:: with SMTP id r10mr1586714wrn.17.1614167664201; Wed, 24 Feb 2021 03:54:24 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id k15sm3911776wrn.0.2021.02.24.03.54.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 03:54:23 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Feb 2021 12:53:34 +0100 Message-Id: <20210224115341.794293-8-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210224115341.794293-1-andreas.rheinhardt@gmail.com> References: <20210224115341.794293-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/15] avformat/pcmdec: Beautify pcm_read_header 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Andreas Rheinhardt --- libavformat/pcmdec.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/libavformat/pcmdec.c b/libavformat/pcmdec.c index cd3e7b2e8f..9b552936ac 100644 --- a/libavformat/pcmdec.c +++ b/libavformat/pcmdec.c @@ -36,18 +36,19 @@ typedef struct PCMAudioDemuxerContext { static int pcm_read_header(AVFormatContext *s) { PCMAudioDemuxerContext *s1 = s->priv_data; + AVCodecParameters *par; AVStream *st; uint8_t *mime_type = NULL; st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); + par = st->codecpar; - - st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; - st->codecpar->codec_id = s->iformat->raw_codec_id; - st->codecpar->sample_rate = s1->sample_rate; - st->codecpar->channels = s1->channels; + par->codec_type = AVMEDIA_TYPE_AUDIO; + par->codec_id = s->iformat->raw_codec_id; + par->sample_rate = s1->sample_rate; + par->channels = s1->channels; av_opt_get(s->pb, "mime_type", AV_OPT_SEARCH_CHILDREN, &mime_type); if (mime_type && s->iformat->mime_type) { @@ -61,7 +62,7 @@ static int pcm_read_header(AVFormatContext *s) if (!channels) sscanf(options, " channels=%d", &channels); if (!little_endian) { - char val[14]; /* sizeof("little-endian") == 14 */ + char val[sizeof("little-endian")]; if (sscanf(options, " endianness=%13s", val) == 1) { little_endian = strcmp(val, "little-endian") == 0; } @@ -74,24 +75,22 @@ static int pcm_read_header(AVFormatContext *s) av_freep(&mime_type); return AVERROR_INVALIDDATA; } - st->codecpar->sample_rate = rate; + par->sample_rate = rate; if (channels > 0) - st->codecpar->channels = channels; + par->channels = channels; if (little_endian) - st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE; + par->codec_id = AV_CODEC_ID_PCM_S16LE; } } av_freep(&mime_type); - st->codecpar->bits_per_coded_sample = - av_get_bits_per_sample(st->codecpar->codec_id); + par->bits_per_coded_sample = av_get_bits_per_sample(par->codec_id); - av_assert0(st->codecpar->bits_per_coded_sample > 0); + av_assert0(par->bits_per_coded_sample > 0); - st->codecpar->block_align = - st->codecpar->bits_per_coded_sample * st->codecpar->channels / 8; + par->block_align = par->bits_per_coded_sample * par->channels / 8; - avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); + avpriv_set_pts_info(st, 64, 1, par->sample_rate); return 0; }