[vlc-commits] avcodec: settings pts doesn't segfault with mp4v
Ilkka Ollakka
git at videolan.org
Wed Oct 24 18:02:20 CEST 2012
vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Wed Oct 24 09:17:43 2012 +0300| [1e0a7a8c2b84f9d577e80c49ae252d75ca94cea1] | committer: Ilkka Ollakka
avcodec: settings pts doesn't segfault with mp4v
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1e0a7a8c2b84f9d577e80c49ae252d75ca94cea1
---
modules/codec/avcodec/encoder.c | 59 +++++++++++++++++----------------------
1 file changed, 26 insertions(+), 33 deletions(-)
diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index 729528e..dc71b8a 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -871,51 +871,44 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
frame->interlaced_frame = !p_pict->b_progressive;
frame->top_field_first = !!p_pict->b_top_field_first;
- /* Set the pts of the frame being encoded (segfaults with mpeg4!)*/
- if( p_enc->fmt_out.i_codec != VLC_CODEC_MP4V )
+ /* Set the pts of the frame being encoded */
+ frame->pts = p_pict->date ? p_pict->date : (int64_t)AV_NOPTS_VALUE;
+
+ if ( p_sys->b_hurry_up && frame->pts != (int64_t)AV_NOPTS_VALUE )
{
- frame->pts = p_pict->date ? p_pict->date : (int64_t)AV_NOPTS_VALUE;
+ mtime_t current_date = mdate();
- if ( p_sys->b_hurry_up && frame->pts != (int64_t)AV_NOPTS_VALUE )
+ if ( current_date + HURRY_UP_GUARD3 > frame->pts )
+ {
+ p_sys->p_context->mb_decision = FF_MB_DECISION_SIMPLE;
+ p_sys->p_context->trellis = 0;
+ msg_Dbg( p_enc, "hurry up mode 3" );
+ }
+ else
{
- mtime_t current_date = mdate();
+ p_sys->p_context->mb_decision = p_sys->i_hq;
- if ( current_date + HURRY_UP_GUARD3 > frame->pts )
+ if ( current_date + HURRY_UP_GUARD2 > frame->pts )
{
- p_sys->p_context->mb_decision = FF_MB_DECISION_SIMPLE;
p_sys->p_context->trellis = 0;
- msg_Dbg( p_enc, "hurry up mode 3" );
+ p_sys->p_context->noise_reduction = p_sys->i_noise_reduction
+ + (HURRY_UP_GUARD2 + current_date - frame->pts) / 500;
+ msg_Dbg( p_enc, "hurry up mode 2" );
}
else
{
- p_sys->p_context->mb_decision = p_sys->i_hq;
-
- if ( current_date + HURRY_UP_GUARD2 > frame->pts )
- {
- p_sys->p_context->trellis = 0;
- p_sys->p_context->noise_reduction = p_sys->i_noise_reduction
- + (HURRY_UP_GUARD2 + current_date - frame->pts) / 500;
- msg_Dbg( p_enc, "hurry up mode 2" );
- }
- else
- {
- p_sys->p_context->trellis = p_sys->b_trellis;
-
- p_sys->p_context->noise_reduction =
- p_sys->i_noise_reduction;
- }
- }
+ p_sys->p_context->trellis = p_sys->b_trellis;
- if ( current_date + HURRY_UP_GUARD1 > frame->pts )
- {
- frame->pict_type = AV_PICTURE_TYPE_P;
- /* msg_Dbg( p_enc, "hurry up mode 1 %lld", current_date + HURRY_UP_GUARD1 - frame.pts ); */
+ p_sys->p_context->noise_reduction =
+ p_sys->i_noise_reduction;
}
}
- }
- else
- {
- frame->pts = (int64_t)AV_NOPTS_VALUE;
+
+ if ( current_date + HURRY_UP_GUARD1 > frame->pts )
+ {
+ frame->pict_type = AV_PICTURE_TYPE_P;
+ /* msg_Dbg( p_enc, "hurry up mode 1 %lld", current_date + HURRY_UP_GUARD1 - frame.pts ); */
+ }
}
if ( frame->pts != (int64_t)AV_NOPTS_VALUE && frame->pts != 0 )
More information about the vlc-commits
mailing list