buf = hb_buffer_init( size );
memcpy( buf->data, pv->frame, size );
buf->start = pts;
+ buf->duration = frame_dur;
pts += frame_dur;
buf->stop = pts;
pv->next_expected_pts = pts;
/* 6 blocks per frame, 256 samples per block, channelsused channels */
buf = hb_buffer_init( 6 * 256 * pv->out_discrete_channels * sizeof( float ) );
buf->start = pts;
+ buf->duration = frame_dur;
pts += frame_dur;
buf->stop = pts;
pv->next_expected_pts = pts;
{
int isamp = av_get_bytes_per_sample( context->sample_fmt );
nsamples = out_size / isamp;
- double pts_next = pv->pts_next + nsamples * pv->duration;
+ double duration = nsamples * pv->duration;
+ double pts_next = pv->pts_next + duration;
// DTS-HD can be passed through to mkv
if( audio->config.out.codec & HB_ACODEC_PASS_FLAG )
buf = hb_buffer_init( avp.size );
memcpy( buf->data, avp.data, avp.size );
buf->start = pv->pts_next;
+ buf->duration = duration;
buf->stop = pts_next;
hb_list_add( pv->list, buf );
pv->pts_next = pts_next;
hb_buffer_t * buf;
buf = downmixAudio( audio, pv, buffer, context->channels, nsamples );
buf->start = pv->pts_next;
+ buf->duration = duration;
buf->stop = pts_next;
hb_list_add( pv->list, buf );
buf = hb_buffer_init( pv->size );
memcpy( buf->data, pv->frame, pv->size );
buf->start = pts;
+ buf->duration = frame_dur;
pv->next_pts = pts + frame_dur;
buf->stop = pv->next_pts;
pv->sync = 0;
/* num_blocks blocks per frame, 256 samples per block, channelsused channels */
int nsamp = num_blocks * 256;
+ frame_dur = (double)nsamp / (double)pv->rate * 90000.;
buf = hb_buffer_init( nsamp * pv->out_discrete_channels * sizeof( float ) );
buf->start = pts;
- pv->next_pts = pts + (double)nsamp / (double)pv->rate * 90000.;
+ buf->duration = frame_dur;
+ pv->next_pts = pts + frame_dur;
buf->stop = pv->next_pts;
for( i = 0; i < num_blocks; i++ )
out = hb_buffer_init( pv->samples * sizeof( float ) );
out->start = pv->next_pts;
+ out->duration = pv->duration;
pv->next_pts += pv->duration;
out->stop = pv->next_pts;
int id; // ID of the track that the packet comes from
int64_t start; // Video and subtitle packets: start time of frame/subtitle
+ double duration; // Actual duration, may be fractional ticks
int64_t stop; // Video and subtitle packets: stop time of frame/subtitle
int64_t pcr;
uint8_t discontinuity;
hb_sync_audio_t *sync )
{
int64_t start = (int64_t)sync->next_start;
- double duration = buf->stop - buf->start;
+
+ // Can't count of buf->s.stop - buf->s.start for accurate duration
+ // due to integer rounding, so use buf->s.duration when it is set
+ // (which should be always if I didn't miss anything)
+ double duration;
+ if ( buf->duration > 0 )
+ duration = buf->duration;
+ else
+ duration = buf->stop - buf->start;
if ( !( audio->config.out.codec & HB_ACODEC_PASS_FLAG ) )
{