From patchwork Sun Aug 4 13:30:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 50886 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:1f5a:b0:489:2eb3:e4c4 with SMTP id jm26csp901440vqb; Sun, 4 Aug 2024 06:30:58 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW9c3TI7Npb338Y6dZugVc05oXB45RsTOvBm4wFADK19k+P0YYocuOIQPffHv/fU7T4Sm0J1JIT17EQoM7qmwR54YOjEpkfFHHJVA== X-Google-Smtp-Source: AGHT+IHlj4BASB6H0e/BM5AMRF4iSSwcWkkV7P/KiShjSG5LnS1G/rP9XOtVAMUcjW7LJZEntcY9 X-Received: by 2002:a05:6512:3404:b0:52f:d090:6dae with SMTP id 2adb3069b0e04-530bb39b7e0mr5677194e87.52.1722778258376; Sun, 04 Aug 2024 06:30:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722778258; cv=none; d=google.com; s=arc-20160816; b=yqjOlDwPJA9T7y1UGo+RwUxU/KQ6O7B0G1H5Qw1tZpNg591wSBV+mCtAr31F5Pf8gH zBjMGpYtcpm8+LBftdWcAY2zhFXQJTVYIrw+l537Q37GsFjrB2z2MyjgFNI2BMZzVSol JlVFQTq8aU0Vm6xUCsafAsiOD+QyQ/87DUKgozV2cn7Cmvkp95OmTDY1fmtUXIHGIP32 HGH7eG/x2HCDNTkP9QfOMNOFL428IYDVhue9+X8rKnbaLZQ7lv1+0GWJIf/1ocdY7UaE vpHVMf25D8t8ZVbST6JOfoKo2a5Oz1b1AhUSVLlxCQIcKLNK/c90AVR/L5SxeYWMh7pE uzRg== 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:message-id:date:to:from :dkim-signature:delivered-to; bh=tCITP23sjuBzRiEwHQZlBKHsfFz5ioOgRbphTnUoxao=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=QN2+mbSyQDqgoefeq210zDH+1X+LyJh53z2nppnipwmuw3ZICgUz9tAwpHZ0xKCFg3 pwenSqC2F1FDw4pMNsPD7evTju5WEFHzc6tGmpQ/EvtNKd0rEUmAD9Mb7CCs2IHdhF28 MhiRPKQWgYRAZet+TnUPtOQx2BgkhESyaMdWQQ166OnU3kZhYZkxq5aMSOAKpltuwVKf Uzu9DWr94af5J3yR2YBRsRQ2TFHKollz96u91ApqmOH1iB4HLqKz2pthb9+OM9T8RUyZ y7ZSodq2wO/cN1gjEAbvqOafqMIimGfLcyRrvyrleNAchu/rm3kN2jWeF2JSTMkAb8fE RC1w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=hoYX5XCz; 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; dara=fail header.i=@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 2adb3069b0e04-530bba38264si1847582e87.485.2024.08.04.06.30.57; Sun, 04 Aug 2024 06:30:58 -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=20230601 header.b=hoYX5XCz; 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; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F0F8B68D179; Sun, 4 Aug 2024 16:30:52 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B01A668D882 for ; Sun, 4 Aug 2024 16:30:46 +0300 (EEST) Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1fc47abc040so63729195ad.0 for ; Sun, 04 Aug 2024 06:30:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722778244; x=1723383044; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=6fJd7LVPiFv8uV07uDfourbNPN0LTi77Nr2RxpqU1co=; b=hoYX5XCzr189/GlWq1Rjkn4/uVJUJ6oQEevH5fqm7XvbyR4EZ+yNIt6hu3Kplonmcd IvKkeeF9DHRUzkNNFbmc0vXdkeZ8JmBNLJUOsYF2CN73cv7q7z2yoLHLCchRQBvpFcqg ni7Aw2O5hlYV6fxw9gLT+fArD/wRq197vH8cyXh0fDcTJIevbYtY309OTnU97Ck9eL2L 4JJjNQk6vBTGzHQD0W1vYFgVF/pqOSjhzrkM0Ot4pqrU6pirmPU7CThsgth3Apb21i+G UoPVg4CowKvqymSYuiIAxxnV45zjMnElVt+8bRJTm5qRpY/ikPK8lnx5LwFFUG4YPway wJFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722778244; x=1723383044; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6fJd7LVPiFv8uV07uDfourbNPN0LTi77Nr2RxpqU1co=; b=NO/yJm8So1CZUqVMbKIsfYwkfmfsx6ox6z8/E+w5yjASH/WtDNYIJI228B26vtgCQA OCLxQZJ3uzErBe0Bo/Zrc6XeSzz70VIHW10dFsfayPgSMkJ5NhcdDgX1VBCYgQzOsgVS K6ybyqXRT7h9fX5LW1EMXCA1ATmK1laTgErvX411lHHyuyEhNyvoCQt36lEKBRyc2HHV Qb0oil2L+vMvlQaeOjuyTmxXePs5H6gbp5NFvMeHQOlLs8WXclJc4TB3suAXfIh3TrXI 6s2C+mMpGsKnivsKe3pm9PrBhYBPPAKu2MbyICqYuKKI9vGyz+s4XvWrszcvcIsgNDhc q0Xg== X-Gm-Message-State: AOJu0YxU70FqBKj+Z1/fokUTJSOsi/UHue4D5ATcI3iYNSc4iTXWxorg pSlcHl3hlV9IKXCdUVEv/GRRFQGSkWnu8ORM1oAtJcwS1aglkkwgJcL6uA== X-Received: by 2002:a17:903:41c9:b0:1fd:70f7:220d with SMTP id d9443c01a7336-1ff57421fd0mr89667885ad.40.1722778243909; Sun, 04 Aug 2024 06:30:43 -0700 (PDT) Received: from localhost.localdomain ([190.194.167.233]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ff58f5c5f6sm49450245ad.111.2024.08.04.06.30.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Aug 2024 06:30:43 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sun, 4 Aug 2024 10:30:30 -0300 Message-ID: <20240804133030.2536-1-jamrial@gmail.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/iamf: use aligned intreadwrite macros where possible 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: uhXnmm0RqivD Signed-off-by: James Almer --- libavformat/iamf_parse.c | 12 ++++++------ libavformat/iamf_reader.c | 4 ++-- libavformat/iamf_writer.c | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c index e007d6a7af..296e49157b 100644 --- a/libavformat/iamf_parse.c +++ b/libavformat/iamf_parse.c @@ -45,8 +45,8 @@ static int opus_decoder_config(IAMFCodecConfig *codec_config, if (!codec_config->extradata) return AVERROR(ENOMEM); - AV_WB32(codec_config->extradata, MKBETAG('O','p','u','s')); - AV_WB32(codec_config->extradata + 4, MKBETAG('H','e','a','d')); + AV_WB32A(codec_config->extradata, MKBETAG('O','p','u','s')); + AV_WB32A(codec_config->extradata + 4, MKBETAG('H','e','a','d')); codec_config->extradata_size = avio_read(pb, codec_config->extradata + 8, left); if (codec_config->extradata_size < left) return AVERROR_INVALIDDATA; @@ -283,10 +283,10 @@ static int update_extradata(AVCodecParameters *codecpar) switch(codecpar->codec_id) { case AV_CODEC_ID_OPUS: - AV_WB8(codecpar->extradata + 9, codecpar->ch_layout.nb_channels); - AV_WL16(codecpar->extradata + 10, AV_RB16(codecpar->extradata + 10)); // Byte swap pre-skip - AV_WL32(codecpar->extradata + 12, AV_RB32(codecpar->extradata + 12)); // Byte swap sample rate - AV_WL16(codecpar->extradata + 16, AV_RB16(codecpar->extradata + 16)); // Byte swap Output Gain + AV_WB8(codecpar->extradata + 9, codecpar->ch_layout.nb_channels); + AV_WL16A(codecpar->extradata + 10, AV_RB16A(codecpar->extradata + 10)); // Byte swap pre-skip + AV_WL32A(codecpar->extradata + 12, AV_RB32A(codecpar->extradata + 12)); // Byte swap sample rate + AV_WL16A(codecpar->extradata + 16, AV_RB16A(codecpar->extradata + 16)); // Byte swap Output Gain break; case AV_CODEC_ID_AAC: { uint8_t buf[5]; diff --git a/libavformat/iamf_reader.c b/libavformat/iamf_reader.c index cdb412f637..b00bb997ca 100644 --- a/libavformat/iamf_reader.c +++ b/libavformat/iamf_reader.c @@ -73,8 +73,8 @@ static int audio_frame_obu(AVFormatContext *s, const IAMFDemuxContext *c, uint8_t *side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_SKIP_SAMPLES, 10); if (!side_data) return AVERROR(ENOMEM); - AV_WL32(side_data, skip_samples); - AV_WL32(side_data + 4, discard_padding); + AV_WL32A(side_data, skip_samples); + AV_WL32A(side_data + 4, discard_padding); } if (c->mix) { uint8_t *side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_IAMF_MIX_GAIN_PARAM, c->mix_size); diff --git a/libavformat/iamf_writer.c b/libavformat/iamf_writer.c index 5e8d8f768b..1b620c38ee 100644 --- a/libavformat/iamf_writer.c +++ b/libavformat/iamf_writer.c @@ -42,12 +42,12 @@ static int update_extradata(IAMFCodecConfig *codec_config) if (codec_config->extradata_size != 19) return AVERROR_INVALIDDATA; codec_config->extradata_size -= 8; - AV_WB8(codec_config->extradata + 0, AV_RL8(codec_config->extradata + 8)); // version - AV_WB8(codec_config->extradata + 1, 2); // set channels to stereo - AV_WB16(codec_config->extradata + 2, AV_RL16(codec_config->extradata + 10)); // Byte swap pre-skip - AV_WB32(codec_config->extradata + 4, AV_RL32(codec_config->extradata + 12)); // Byte swap sample rate - AV_WB16(codec_config->extradata + 8, 0); // set Output Gain to 0 - AV_WB8(codec_config->extradata + 10, AV_RL8(codec_config->extradata + 18)); // Mapping family + AV_WB8(codec_config->extradata + 0, AV_RL8(codec_config->extradata + 8)); // version + AV_WB8(codec_config->extradata + 1, 2); // set channels to stereo + AV_WB16A(codec_config->extradata + 2, AV_RL16A(codec_config->extradata + 10)); // Byte swap pre-skip + AV_WB32A(codec_config->extradata + 4, AV_RL32A(codec_config->extradata + 12)); // Byte swap sample rate + AV_WB16A(codec_config->extradata + 8, 0); // set Output Gain to 0 + AV_WB8(codec_config->extradata + 10, AV_RL8(codec_config->extradata + 18)); // Mapping family break; case AV_CODEC_ID_FLAC: { uint8_t buf[13];