[vlc-devel] commit: 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. (Antoine Cellerier )
git version control
git at videolan.org
Wed Sep 3 22:45:14 CEST 2008
vlc | branch: master | Antoine Cellerier <dionoea at videolan.org> | Wed Sep 3 22:47:03 2008 +0200| [1273e688ac65d244afc540ba0bcf1b1edf06797b] | committer: Antoine Cellerier
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.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1273e688ac65d244afc540ba0bcf1b1edf06797b
---
include/vlc_vout.h | 11 +++++++++++
modules/codec/avcodec/video.c | 5 -----
modules/stream_out/mosaic_bridge.c | 1 +
modules/stream_out/transcode.c | 3 +++
src/input/decoder.c | 1 +
src/video_output/video_output.c | 1 +
src/video_output/vout_pictures.c | 4 +++-
7 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/include/vlc_vout.h b/include/vlc_vout.h
index fa36858..dde9495 100644
--- a/include/vlc_vout.h
+++ b/include/vlc_vout.h
@@ -161,6 +161,17 @@ static inline void picture_Release( picture_t *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.
*/
static inline void picture_CopyProperties( picture_t *p_dst, const picture_t *p_src )
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 8b1076f..f089504 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -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:
diff --git a/modules/stream_out/mosaic_bridge.c b/modules/stream_out/mosaic_bridge.c
index a28986c..c619b7f 100644
--- a/modules/stream_out/mosaic_bridge.c
+++ b/modules/stream_out/mosaic_bridge.c
@@ -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 );
}
diff --git a/modules/stream_out/transcode.c b/modules/stream_out/transcode.c
index ea7527b..b9e27ec 100644
--- a/modules/stream_out/transcode.c
+++ b/modules/stream_out/transcode.c
@@ -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 )
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 18876a6..49df3ab 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -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--;
}
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 8e11b08..93094ce 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -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 );
}
diff --git a/src/video_output/vout_pictures.c b/src/video_output/vout_pictures.c
index 81f29ba..568d196 100644
--- a/src/video_output/vout_pictures.c
+++ b/src/video_output/vout_pictures.c
@@ -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 )
*
*****************************************************************************/
-
More information about the vlc-devel
mailing list