From patchwork Sun Jun 19 21:53:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 36342 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1a22:b0:84:42e0:ad30 with SMTP id cj34csp1333090pzb; Sun, 19 Jun 2022 14:53:59 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uT0gXpOy9/dkA1WCm39GpPU0eC2Rc3rLF8QE32PIGNDjL6YZMT+2o5330aTiFmgzVKfUgR X-Received: by 2002:a17:907:7da2:b0:711:f36e:b855 with SMTP id oz34-20020a1709077da200b00711f36eb855mr18841762ejc.308.1655675639816; Sun, 19 Jun 2022 14:53:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655675639; cv=none; d=google.com; s=arc-20160816; b=HcjC3k5IcYk/SaRu5an9oc78oFxUeUtaNRTph1IFp4UPxtNuQ3olh4+evB0cVLWaon +6Gov3VxTEZL+AIZee7AG1aC1MiVYa6jw3ZbHEnOS1oCUzQDzR4KHPvazFmJa2/GBd74 +n3BtRCdb4BlN17dxEsJ0QfxgKr4bUcJicsj+ad1f5O5NGajEiniwIvZLSt/WesgxjRY ylY+SnT+KDr8zGqAkA/hcagLTkiAxaDreFsY3JhNRSvavbPPKa/mjzTXi9RDuIyLOhNm FLNJJHYH8LbbriuJRYlWXqTcQzSCQz+wjY/d81o/5NIlJVdsN99p3wXZUWRM3NCFF+Od aZeg== 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:delivered-to; bh=2+/0MEu7q2FidW7KXw84qfQnZK4WxzRXKFvWht0Uy8E=; b=KxTe9nyvApeW4U22OdHXdfjnBIZLMManQxCbQmrf85p9YoofO8x5f+uehxI2F/hiA1 THNTZpfepaRWJNTTbZsFXlaiNHr+rgwEHUMWqDhsiHk9WPQJwjvcC5csNaqBwrrW1Z4N Hzk69Y7QppYr4hh2RER9poqdvtavyk92F7ixKg5KhTjSw/IKx25Kq13HVoVg2JvsPefm mXwkZYp18P40fGBKP3/tfTCjNwlL63fiTAcM2d5xVifkdtjQ3J3vvurrAWnDBXqc9fLZ m47Ug/61JoFFK1tlSQ0gy/bUhA4PQrynyFPW3aB7hv2bn8KcKZnnKrRVn8D42HisubMZ hbig== 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 dm10-20020a170907948a00b006e87c1deef1si11963187ejc.176.2022.06.19.14.53.59; Sun, 19 Jun 2022 14:53:59 -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; 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 017D368B5C8; Mon, 20 Jun 2022 00:53:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BF5B868B44E for ; Mon, 20 Jun 2022 00:53:50 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 1B624E73AD; Sun, 19 Jun 2022 23:53:51 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UEijsuNPcbjs; Sun, 19 Jun 2022 23:53:49 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id BCEBCE73A6; Sun, 19 Jun 2022 23:53:48 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 19 Jun 2022 23:53:39 +0200 Message-Id: <20220619215340.9508-1-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] avformat/mov: factorize setting little endian PCM streams 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: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: lpQ6ptz+oJHM Signed-off-by: Marton Balint --- libavformat/mov.c | 51 +++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 3ec0ea2361..0660a51492 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1544,35 +1544,38 @@ static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } -static int mov_read_enda(MOVContext *c, AVIOContext *pb, MOVAtom atom) +static void set_last_stream_little_endian(AVFormatContext *fc) { AVStream *st; - int little_endian; - if (c->fc->nb_streams < 1) - return 0; - st = c->fc->streams[c->fc->nb_streams-1]; + if (fc->nb_streams < 1) + return; + st = fc->streams[fc->nb_streams-1]; - little_endian = avio_rb16(pb) & 0xFF; - av_log(c->fc, AV_LOG_TRACE, "enda %d\n", little_endian); - if (little_endian == 1) { - switch (st->codecpar->codec_id) { - case AV_CODEC_ID_PCM_S24BE: - st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE; - break; - case AV_CODEC_ID_PCM_S32BE: - st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE; - break; - case AV_CODEC_ID_PCM_F32BE: - st->codecpar->codec_id = AV_CODEC_ID_PCM_F32LE; - break; - case AV_CODEC_ID_PCM_F64BE: - st->codecpar->codec_id = AV_CODEC_ID_PCM_F64LE; - break; - default: - break; - } + switch (st->codecpar->codec_id) { + case AV_CODEC_ID_PCM_S24BE: + st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE; + break; + case AV_CODEC_ID_PCM_S32BE: + st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE; + break; + case AV_CODEC_ID_PCM_F32BE: + st->codecpar->codec_id = AV_CODEC_ID_PCM_F32LE; + break; + case AV_CODEC_ID_PCM_F64BE: + st->codecpar->codec_id = AV_CODEC_ID_PCM_F64LE; + break; + default: + break; } +} + +static int mov_read_enda(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ + int little_endian = avio_rb16(pb) & 0xFF; + av_log(c->fc, AV_LOG_TRACE, "enda %d\n", little_endian); + if (little_endian == 1) + set_last_stream_little_endian(c->fc); return 0; }