From 33e6780967a14c876d0f329ea1c637e6b0f75a92 Mon Sep 17 00:00:00 2001 From: John Stebbins Date: Wed, 25 Jan 2017 11:47:15 -0700 Subject: [PATCH] encca_aac: Fix initial start time encca_aac assumed the first packet start time is 0 which is no longer the case. We now use edit lists to adjust non-zero start times. --- libhb/platform/macosx/encca_aac.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libhb/platform/macosx/encca_aac.c b/libhb/platform/macosx/encca_aac.c index b775b9cb4..5ffb28d5d 100644 --- a/libhb/platform/macosx/encca_aac.c +++ b/libhb/platform/macosx/encca_aac.c @@ -46,6 +46,7 @@ struct hb_work_private_s AudioConverterRef converter; unsigned long isamples, isamplesiz, omaxpacket, nchannels; + int64_t first_pts; uint64_t samples, ibytes; Float64 osamplerate; @@ -146,6 +147,7 @@ int encCoreAudioInit(hb_work_object_t *w, hb_job_t *job, enum AAC_MODE mode) w->private_data = pv; pv->job = job; + pv->first_pts = AV_NOPTS_VALUE; // pass the number of channels used into the private work data pv->nchannels = @@ -441,9 +443,9 @@ static hb_buffer_t* Encode(hb_work_object_t *w) } obuf->size = odesc.mDataByteSize; - obuf->s.start = 90000LL * pv->samples / pv->osamplerate; + obuf->s.start = pv->first_pts + 90000LL * pv->samples / pv->osamplerate; pv->samples += pv->isamples; - obuf->s.stop = 90000LL * pv->samples / pv->osamplerate; + obuf->s.stop = pv->first_pts + 90000LL * pv->samples / pv->osamplerate; obuf->s.duration = (double)90000 * pv->isamples / pv->osamplerate; obuf->s.type = AUDIO_BUF; obuf->s.frametype = HB_FRAME_AUDIO; @@ -515,6 +517,10 @@ int encCoreAudioWork(hb_work_object_t *w, hb_buffer_t **buf_in, return HB_WORK_DONE; } + if (pv->first_pts == AV_NOPTS_VALUE) + { + pv->first_pts = in->s.start; + } hb_list_add(pv->list, in); *buf_out = buf = Encode(w); -- 2.40.0