diff options
author | jstebbins <[email protected]> | 2015-02-04 00:23:12 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2015-02-04 00:23:12 +0000 |
commit | d5775eaba2f914dcf8a6b44c98b5a4b756157662 (patch) | |
tree | b20248e834609907b987acee602c49d5071fab1c /libhb/muxavformat.c | |
parent | cfc7078049cead5e3c830db6c225b3808a6f5fcc (diff) |
libhb: Fix AAC passthru from TS files
Apply aac_adtstoasc bitstream filter while muxing AAC stream and extract
AudioSpecificConfig during scan.
Patch submitted by Taihei Momma
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6867 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/muxavformat.c')
-rw-r--r-- | libhb/muxavformat.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libhb/muxavformat.c b/libhb/muxavformat.c index bf28ae6aa..266a3ae45 100644 --- a/libhb/muxavformat.c +++ b/libhb/muxavformat.c @@ -32,6 +32,8 @@ struct hb_mux_data_s int64_t prev_chapter_tc; int16_t current_chapter; + + AVBitStreamFilterContext* bitstream_filter; }; struct hb_mux_object_s @@ -515,6 +517,15 @@ static int avformatInit( hb_mux_object_t * m ) memcpy(priv_data, audio->priv.config.extradata.bytes, audio->priv.config.extradata.length); + + // AAC from pass-through source may be ADTS. + // Therefore inserting "aac_adtstoasc" bitstream filter is + // preferred. + // The filter does nothing for non-ADTS bitstream. + if (audio->config.out.codec == HB_ACODEC_AAC_PASS) + { + track->bitstream_filter = av_bitstream_filter_init("aac_adtstoasc"); + } break; default: hb_error("muxavformat: Unknown audio codec: %x", @@ -1173,6 +1184,11 @@ static int avformatMux(hb_mux_object_t *m, hb_mux_data_t *track, hb_buffer_t *bu } track->duration = pts + pkt.duration; + if (track->bitstream_filter) + { + av_bitstream_filter_filter(track->bitstream_filter, track->st->codec, NULL, &pkt.data, &pkt.size, pkt.data, pkt.size, 0); + } + pkt.stream_index = track->st->index; int ret = av_interleaved_write_frame(m->oc, &pkt); // Many avformat muxer functions do not check the error status @@ -1211,6 +1227,11 @@ static int avformatEnd(hb_mux_object_t *m) for (ii = 0; ii < m->ntracks; ii++) { avformatMux(m, m->tracks[ii], NULL); + + if (m->tracks[ii]->bitstream_filter) + { + av_bitstream_filter_close(m->tracks[ii]->bitstream_filter); + } } if (job->chapter_markers) |