Skip to content

Commit

Permalink
libhb: do not always set audio extradata
Browse files Browse the repository at this point in the history
It's not need for many formats in Matroska, and the MP4 muxer will create it when needed. Fix HandBrake#6582.
  • Loading branch information
galad87 committed Jan 30, 2025
1 parent 992c94c commit 775f414
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions libhb/muxavformat.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ static int avformatInit( hb_mux_object_t * m )
track->st->time_base = m->time_base;
}

int need_extradata = 0;
switch (audio->config.out.codec & HB_ACODEC_MASK)
{
case HB_ACODEC_DCA:
Expand All @@ -576,24 +577,29 @@ static int avformatInit( hb_mux_object_t * m )
break;
case HB_ACODEC_VORBIS:
track->st->codecpar->codec_id = AV_CODEC_ID_VORBIS;
need_extradata = 1;
break;
case HB_ACODEC_OPUS:
track->st->codecpar->codec_id = AV_CODEC_ID_OPUS;
need_extradata = 1;
break;
case HB_ACODEC_FFALAC:
case HB_ACODEC_FFALAC24:
track->st->codecpar->codec_id = AV_CODEC_ID_ALAC;
need_extradata = 1;
break;
case HB_ACODEC_FFFLAC:
case HB_ACODEC_FFFLAC24:
track->st->codecpar->codec_id = AV_CODEC_ID_FLAC;
need_extradata = 1;
break;
case HB_ACODEC_FFAAC:
case HB_ACODEC_CA_AAC:
case HB_ACODEC_CA_HAAC:
case HB_ACODEC_FDK_AAC:
case HB_ACODEC_FDK_HAAC:
track->st->codecpar->codec_id = AV_CODEC_ID_AAC;
need_extradata = 1;

// AAC from pass-through source may be ADTS.
// Therefore inserting "aac_adtstoasc" bitstream filter is
Expand Down Expand Up @@ -623,9 +629,14 @@ static int avformatInit( hb_mux_object_t * m )
goto error;
}

if (set_extradata(audio->priv.extradata, &track->st->codecpar->extradata, &track->st->codecpar->extradata_size))
if (need_extradata)
{
goto error;
if (set_extradata(audio->priv.extradata,
&track->st->codecpar->extradata,
&track->st->codecpar->extradata_size))
{
goto error;
}
}

if (track->bitstream_context != NULL)
Expand Down

0 comments on commit 775f414

Please sign in to comment.