[vlc-commits] avcodec: map AV_NOPTS_VALUE and VLC_TS_INVALID
Ilkka Ollakka
git at videolan.org
Sun Oct 20 16:19:09 CEST 2013
vlc/vlc-2.1 | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Sun Oct 13 20:02:04 2013 +0300| [41dd3104cb21f138bbf78d38b28f6410dbc4399a] | committer: Jean-Baptiste Kempf
avcodec: map AV_NOPTS_VALUE and VLC_TS_INVALID
(cherry picked from commit 623a50eb2de131a362dac685d318375b2b5e4ace)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.1.git/?a=commit;h=41dd3104cb21f138bbf78d38b28f6410dbc4399a
---
modules/codec/avcodec/encoder.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index 3c1ef3c..7854584 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -649,7 +649,7 @@ int OpenEncoder( vlc_object_t *p_this )
p_context->sample_rate = p_enc->fmt_out.audio.i_rate;
date_Init( &p_sys->buffer_date, p_enc->fmt_out.audio.i_rate, 1 );
- date_Set( &p_sys->buffer_date, 0 );
+ date_Set( &p_sys->buffer_date, AV_NOPTS_VALUE );
p_context->time_base.num = 1;
p_context->time_base.den = p_context->sample_rate;
p_context->channels = p_enc->fmt_out.audio.i_channels;
@@ -1179,7 +1179,8 @@ static block_t *EncodeAudio( encoder_t *p_enc, block_t *p_aout_buf )
p_aout_buf->p_buffer += leftover;
p_aout_buf->i_buffer -= leftover;
- p_aout_buf->i_pts = date_Get( &p_sys->buffer_date );
+ if( likely( p_sys->frame->pts != (int64_t)AV_NOPTS_VALUE) )
+ p_aout_buf->i_pts = date_Get( &p_sys->buffer_date );
}
if(unlikely( ( (leftover + buffer_delay) < p_sys->i_buffer_out ) &&
@@ -1226,7 +1227,10 @@ static block_t *EncodeAudio( encoder_t *p_enc, block_t *p_aout_buf )
(mtime_t)p_sys->frame->nb_samples /
(mtime_t)p_sys->p_context->sample_rate;
- p_block->i_dts = p_block->i_pts = packet.pts;
+ if( likely( packet.pts != (int64_t)AV_NOPTS_VALUE ) )
+ p_block->i_dts = p_block->i_pts = packet.pts;
+ else
+ p_block->i_dts = p_block->i_pts = VLC_TS_INVALID;
block_ChainAppend( &p_chain, p_block );
}
@@ -1248,7 +1252,10 @@ static block_t *EncodeAudio( encoder_t *p_enc, block_t *p_aout_buf )
(mtime_t)p_sys->i_frame_size /
(mtime_t)p_sys->p_context->sample_rate;
- p_block->i_dts = p_block->i_pts = packet.pts;
+ if( likely( packet.pts != (int64_t)AV_NOPTS_VALUE ) )
+ p_block->i_dts = p_block->i_pts = packet.pts;
+ else
+ p_block->i_dts = p_block->i_pts = VLC_TS_INVALID;
if( i_out >= 0 && got_packet )
block_ChainAppend( &p_chain, p_block );
@@ -1297,7 +1304,6 @@ static block_t *EncodeAudio( encoder_t *p_enc, block_t *p_aout_buf )
p_aout_buf->i_nb_samples -= p_sys->frame->nb_samples;
date_Increment( &p_sys->buffer_date, p_sys->frame->nb_samples );
-
p_block = block_Alloc( p_sys->i_buffer_out );
av_init_packet( &packet );
packet.data = p_block->p_buffer;
@@ -1323,7 +1329,10 @@ static block_t *EncodeAudio( encoder_t *p_enc, block_t *p_aout_buf )
(mtime_t)p_sys->frame->nb_samples /
(mtime_t)p_sys->p_context->sample_rate;
- p_block->i_dts = p_block->i_pts = packet.pts;
+ if( likely( packet.pts != (int64_t)AV_NOPTS_VALUE ) )
+ p_block->i_dts = p_block->i_pts = packet.pts;
+ else
+ p_block->i_dts = p_block->i_pts = VLC_TS_INVALID;
block_ChainAppend( &p_chain, p_block );
}
More information about the vlc-commits
mailing list