avformat/iamf: use aligned intreadwrite macros where possible

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer 2024-08-04 10:29:48 -03:00
parent 49a6e448d7
commit 94165d1b79
3 changed files with 14 additions and 14 deletions

View File

@ -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];

View File

@ -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);

View File

@ -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];