Commit 1273e688 authored by Antoine Cellerier's avatar Antoine Cellerier

Properly malloc(), memcpy() and free() the quantizer matrix. (Somebody please...

Properly malloc(), memcpy() and free() the quantizer matrix. (Somebody please patch libmpeg2 so we can postproc it's output too!) Thanks to fenrir for his help.
parent cb1b8ce0
......@@ -160,6 +160,17 @@ static inline void picture_Release( picture_t *p_picture )
p_picture->pf_release( p_picture );
}
/**
* Cleanup quantization matrix data and set to 0
*/
static inline void picture_CleanupQuant( picture_t *p_pic )
{
free( p_pic->p_q );
p_pic->p_q = NULL;
p_pic->i_qstride = 0;
p_pic->i_qtype = 0;
}
/**
* This function will copy all picture dynamic properties.
*/
......
......@@ -651,15 +651,10 @@ picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
p_pic->b_top_field_first = p_sys->p_ff_pic->top_field_first;
p_pic->i_qstride = p_sys->p_ff_pic->qstride;
#if 1
p_pic->p_q = p_sys->p_ff_pic->qscale_table; /* XXX: is this dangerous? shouldn't be since the ff pics are never freed ... but you never know */
#else
/* FIXME: this leaks p_q */
int i_mb_h = ( p_pic->format.i_height + 15 ) / 16;
p_pic->p_q = malloc( p_pic->i_qstride * i_mb_h );
memcpy( p_pic->p_q, p_sys->p_ff_pic->qscale_table,
p_pic->i_qstride * i_mb_h );
#endif
switch( p_sys->p_ff_pic->qscale_type )
{
case FF_QSCALE_TYPE_MPEG1:
......
......@@ -90,6 +90,7 @@ static void ReleasePicture( picture_t *p_pic )
}
else
{
free( p_pic->p_q );
free( p_pic->p_data_orig );
free( p_pic );
}
......
......@@ -2278,6 +2278,7 @@ static void video_del_buffer( vlc_object_t *p_this, picture_t *p_pic )
VLC_UNUSED(p_this);
if( p_pic )
{
free( p_pic->p_q );
free( p_pic->p_data_orig );
free( p_pic->p_sys );
free( p_pic );
......@@ -2289,6 +2290,7 @@ static void video_del_buffer_decoder( decoder_t *p_decoder, picture_t *p_pic )
VLC_UNUSED(p_decoder);
p_pic->i_refcount = 0;
p_pic->i_status = DESTROYED_PICTURE;
picture_CleanupQuant( p_pic );
}
static void video_del_buffer_filter( filter_t *p_filter, picture_t *p_pic )
......@@ -2296,6 +2298,7 @@ static void video_del_buffer_filter( filter_t *p_filter, picture_t *p_pic )
VLC_UNUSED(p_filter);
p_pic->i_refcount = 0;
p_pic->i_status = DESTROYED_PICTURE;
picture_CleanupQuant( p_pic );
}
static void video_link_picture_decoder( decoder_t *p_dec, picture_t *p_pic )
......
......@@ -709,6 +709,7 @@ static void VoutDisplayedPicture( vout_thread_t *p_vout, picture_t *p_pic )
else
{
p_pic->i_status = DESTROYED_PICTURE;
picture_CleanupQuant( p_pic );
p_vout->i_heap_size--;
}
......
......@@ -1253,6 +1253,7 @@ static void DropPicture( vout_thread_t *p_vout, picture_t *p_picture )
/* Destroy the picture without displaying it */
p_picture->i_status = DESTROYED_PICTURE;
p_vout->i_heap_size--;
picture_CleanupQuant( p_picture );
}
vlc_mutex_unlock( &p_vout->picture_lock );
}
......
......@@ -262,6 +262,7 @@ void vout_DestroyPicture( vout_thread_t *p_vout, picture_t *p_pic )
p_pic->i_status = DESTROYED_PICTURE;
p_vout->i_heap_size--;
picture_CleanupQuant( p_pic );
vlc_mutex_unlock( &p_vout->picture_lock );
}
......@@ -294,6 +295,7 @@ void vout_UnlinkPicture( vout_thread_t *p_vout, picture_t *p_pic )
{
p_pic->i_status = DESTROYED_PICTURE;
p_vout->i_heap_size--;
picture_CleanupQuant( p_pic );
}
vlc_mutex_unlock( &p_vout->picture_lock );
......@@ -1045,6 +1047,7 @@ void picture_Delete( picture_t *p_picture )
{
assert( p_picture && p_picture->i_refcount == 0 );
free( p_picture->p_q );
free( p_picture->p_data_orig );
free( p_picture->p_sys );
free( p_picture );
......@@ -1097,4 +1100,3 @@ void plane_CopyPixels( plane_t *p_dst, const plane_t *p_src )
*
*****************************************************************************/
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