Commit 62ba2f68 authored by Jean-Paul Saman's avatar Jean-Paul Saman

rawvideo: fix regression

parent 0e3f762c
...@@ -51,6 +51,12 @@ struct decoder_sys_t ...@@ -51,6 +51,12 @@ struct decoder_sys_t
* Common properties * Common properties
*/ */
date_t pts; date_t pts;
/* stats */
mtime_t i_pts_start;
mtime_t i_pts_end;
int i_fps;
int i_pics;
}; };
/**************************************************************************** /****************************************************************************
...@@ -130,7 +136,7 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -130,7 +136,7 @@ static int OpenDecoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */ /* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys = if( ( p_dec->p_sys = p_sys =
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL ) (decoder_sys_t *)calloc(1, sizeof(decoder_sys_t)) ) == NULL )
return VLC_ENOMEM; return VLC_ENOMEM;
/* Misc init */ /* Misc init */
p_dec->p_sys->b_packetizer = false; p_dec->p_sys->b_packetizer = false;
...@@ -163,6 +169,7 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -163,6 +169,7 @@ static int OpenDecoder( vlc_object_t *p_this )
p_dec->fmt_out.video.i_frame_rate_base); p_dec->fmt_out.video.i_frame_rate_base);
date_Init( &p_sys->pts, 25, 1 ); date_Init( &p_sys->pts, 25, 1 );
} }
p_sys->i_fps = 25;
/* Find out p_vdec->i_raw_size */ /* Find out p_vdec->i_raw_size */
vout_InitFormat( &p_dec->fmt_out.video, p_dec->fmt_in.i_codec, vout_InitFormat( &p_dec->fmt_out.video, p_dec->fmt_in.i_codec,
...@@ -198,6 +205,34 @@ static int OpenPacketizer( vlc_object_t *p_this ) ...@@ -198,6 +205,34 @@ static int OpenPacketizer( vlc_object_t *p_this )
return i_ret; return i_ret;
} }
static inline FPSMeasurements( decoder_t *p_dec )
{
decoder_sys_t *p_sys = p_dec->p_sys;
p_sys->i_pics++;
if( p_sys->i_pics == 1 )
{
p_sys->i_pts_start = mdate();
}
if( p_sys->i_pics == p_sys->i_fps )
{
mtime_t i_diff; /* in us */
double f_fps;
p_sys->i_pts_end = mdate(); /* in us */
i_diff = (p_sys->i_pts_end - p_sys->i_pts_start);
f_fps = (double)((i_diff / (int64_t)p_sys->i_pics)); /* 1 frame per us */
f_fps = ((double)1/f_fps) * (double)1000000;
msg_Info( p_dec, "Packetizer: %d frames per %"PRId64" micro seconds (%4.2f fps)",
p_sys->i_pics, i_diff, f_fps );
/* reset timers */
p_sys->i_pics = 0;
p_sys->i_pts_start = p_sys->i_pts_end = (mtime_t)0;
}
}
/**************************************************************************** /****************************************************************************
* DecodeBlock: the whole thing * DecodeBlock: the whole thing
**************************************************************************** ****************************************************************************
...@@ -256,6 +291,7 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) ...@@ -256,6 +291,7 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
date_Increment( &p_sys->pts, 1 ); date_Increment( &p_sys->pts, 1 );
*pp_block = NULL; *pp_block = NULL;
FPSMeasurements( p_dec );
return p_buf; return p_buf;
} }
...@@ -267,13 +303,11 @@ static void FillPicture( decoder_t *p_dec, block_t *p_block, picture_t *p_pic ) ...@@ -267,13 +303,11 @@ static void FillPicture( decoder_t *p_dec, block_t *p_block, picture_t *p_pic )
int i_plane; int i_plane;
decoder_sys_t *p_sys = p_dec->p_sys; decoder_sys_t *p_sys = p_dec->p_sys;
if( p_pic->i_type == DIRECT_PICTURE ) if( p_pic->i_type == MEMORY_PICTURE )
{ {
free( p_pic->p_data_orig ); free( p_pic->p_data_orig );
p_pic->p_data = p_pic->p_data_orig = p_block->p_buffer; p_pic->p_data = p_block->p_buffer;
p_pic->p_data_orig = p_block;
p_block->p_buffer = NULL;
p_block->i_buffer = 0;
/* Fill the p_pixels field for each plane */ /* Fill the p_pixels field for each plane */
p_pic->p[0].p_pixels = p_pic->p_data; p_pic->p[0].p_pixels = p_pic->p_data;
...@@ -302,6 +336,7 @@ static void FillPicture( decoder_t *p_dec, block_t *p_block, picture_t *p_pic ) ...@@ -302,6 +336,7 @@ static void FillPicture( decoder_t *p_dec, block_t *p_block, picture_t *p_pic )
p_dst += i_pitch, p_src += i_visible_pitch ) p_dst += i_pitch, p_src += i_visible_pitch )
vlc_memcpy( p_dst, p_src, i_visible_pitch ); vlc_memcpy( p_dst, p_src, i_visible_pitch );
} }
block_Release( p_block );
} }
} }
...@@ -326,7 +361,6 @@ static picture_t *DecodeFrame( decoder_t *p_dec, block_t *p_block ) ...@@ -326,7 +361,6 @@ static picture_t *DecodeFrame( decoder_t *p_dec, block_t *p_block )
p_pic->date = date_Get( &p_sys->pts ); p_pic->date = date_Get( &p_sys->pts );
p_pic->b_progressive = true; p_pic->b_progressive = true;
block_Release( p_block );
return p_pic; return p_pic;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment