summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2013-10-21 20:57:38 +0000
committerjstebbins <[email protected]>2013-10-21 20:57:38 +0000
commit310454f3726b2187a59246420611a284d7c28c84 (patch)
tree177f5fff28577764318717c24af904a23dcffbb9 /libhb
parentd4d367adde4c5e8754965a390d48693e2aa3acfc (diff)
libhb: fix duration of initial audio frame when decoding with avcodec
For some codecs, the samplerate is not known until we decode some data. So postpone calculation of frame duration till after we have decoded some data. The effect of this error is that the first 2 audio frames could have the same start time. This causes the "non monotonically increasing dts" error in libavformat mp4 muxer. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5849 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r--libhb/decavcodec.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c
index 84ad5103c..15a14dcec 100644
--- a/libhb/decavcodec.c
+++ b/libhb/decavcodec.c
@@ -488,17 +488,6 @@ static int decavcodecaWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
}
if (pout)
{
- // set the duration on every frame since the stream format can
- // change (it shouldn't but there's no way to guarantee it).
- // duration is a scaling factor to go from #bytes in the decoded
- // frame to frame time (in 90KHz mpeg ticks). 'channels' converts
- // total samples to per-channel samples. 'sample_rate' converts
- // per-channel samples to seconds per sample and the 90000
- // is mpeg ticks per second.
- if ( pv->context->sample_rate )
- {
- pv->duration = 90000. / (double)( pv->context->sample_rate );
- }
decodeAudio( w->audio, pv, pout, pout_len, cur );
}
}
@@ -1922,6 +1911,21 @@ static void decodeAudio(hb_audio_t *audio, hb_work_private_t *pv, uint8_t *data,
pos += len;
+ // set the duration on every frame since the stream format can
+ // change (it shouldn't but there's no way to guarantee it).
+ // duration is a scaling factor to go from #bytes in the decoded
+ // frame to frame time (in 90KHz mpeg ticks). 'channels' converts
+ // total samples to per-channel samples. 'sample_rate' converts
+ // per-channel samples to seconds per sample and the 90000
+ // is mpeg ticks per second.
+ //
+ // Also, sample rate is not available until we have decoded some
+ // audio.
+ if ( pv->context->sample_rate )
+ {
+ pv->duration = 90000. / (double)( pv->context->sample_rate );
+ }
+
if (got_frame)
{
hb_buffer_t *out;