[FFmpeg-devel] [PATCH] avformat/iamf: use aligned intreadwrite macros where possible
James Almer
jamrial at gmail.com
Sun Aug 4 16:30:30 EEST 2024
Signed-off-by: James Almer <jamrial at gmail.com>
---
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];
--
2.46.0
More information about the ffmpeg-devel
mailing list