[vlc-devel] [PATCH] invmem - code clean-up

Robert Paciorek robert at opcode.eu.org
Tue Dec 2 23:36:36 CET 2008


Hi,

Sorry for sending (by mistake) patch without introduction.

> What's it doing? I mean, how is it different from vmem?

This module make possible uses libvlc as output (not input as vmem) for video 
stream rendering in aplication ... motivation to create this patch can find 
at http://forum.videolan.org/viewtopic.php?f=32&t=53256

Thanks for suggestion, I apply it to code - patch below


Best regards,
Robert Paciorek
http://www.opcode.eu.org/bercik

PS please add me as cc in reply, becouse I'm not subscriber vlc-devel


---
Apply change suggest on vlc-devel mailing list by Rémi Denis-Courmont
---
 modules/codec/Modules.am |    1 +
 modules/codec/invmem.c   |   37 +++++++++++++++++--------------------
 2 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/modules/codec/Modules.am b/modules/codec/Modules.am
index 999f0b8..e69f556 100644
--- a/modules/codec/Modules.am
+++ b/modules/codec/Modules.am
@@ -54,4 +54,5 @@ libvlc_LTLIBRARIES += \
 	libmpeg_audio_plugin.la \
 	librawvideo_plugin.la \
 	libsvcdsub_plugin.la \
+	libinvmem_plugin.la \
 	$(NULL)
diff --git a/modules/codec/invmem.c b/modules/codec/invmem.c
index 4d7220f..1703243 100644
--- a/modules/codec/invmem.c
+++ b/modules/codec/invmem.c
@@ -38,7 +38,6 @@
 
 #include <vlc_image.h>
 #include <vlc_filter.h>
-#include <vlc_charset.h>
 
 /*****************************************************************************
  * Local prototypes
@@ -80,7 +79,7 @@ vlc_module_begin();
     set_shortname( N_("Memory video decoder") );
     set_description( N_("Memory video decoder") );
     set_help( INVMEM_HELP );
-    set_capability( "decoder", 1000 );
+    set_capability( "decoder", 50 );
     set_callbacks( OpenDecoder, CloseDecoder );
     add_shortcut( "invmem" );
 
@@ -102,7 +101,7 @@ struct decoder_sys_t
     int i_height;
     int i_pitch;
 
-    picture_t *p_pic
+    picture_t *p_pic;
 };
 
 
@@ -115,8 +114,6 @@ static int OpenDecoder( vlc_object_t *p_this )
     decoder_sys_t *p_sys;
     char *psz_tmp;
 
-    msg_Dbg( p_dec, "Initialize INVMEM DECODER moduule" );
-
     if( p_dec->fmt_in.i_codec != VLC_FOURCC('f','a','k','e'))
     {
         return VLC_EGENERIC;
@@ -128,22 +125,22 @@ static int OpenDecoder( vlc_object_t *p_this )
         return VLC_ENOMEM;
 
     // get parametrs
-    p_sys->i_width = config_GetInt( p_this, "invmem-width" );
-    p_sys->i_height = config_GetInt( p_this, "invmem-height" );
+    p_sys->i_width = var_CreateGetInteger( p_this, "invmem-width" );
+    p_sys->i_height = var_CreateGetInteger( p_this, "invmem-height" );
     if (p_sys->i_width == 0 || p_sys->i_height == 0) {
         msg_Err( p_dec, "--vmem-width and --vmem-height must be > 0" );
         return VLC_EGENERIC;
     }
 
-    psz_tmp = config_GetPsz( p_dec, "invmem-lock" );
+    psz_tmp = var_CreateGetString( p_dec, "invmem-lock" );
     p_sys->pf_lock = (void * (*) (void *))(intptr_t)atoll( psz_tmp );
     free( psz_tmp );
 
-    psz_tmp = config_GetPsz( p_dec, "invmem-unlock" );
+    psz_tmp = var_CreateGetString( p_dec, "invmem-unlock" );
     p_sys->pf_unlock = (void (*) (void *))(intptr_t)atoll( psz_tmp );
     free( psz_tmp );
 
-    psz_tmp = config_GetPsz( p_dec, "invmem-data" );
+    psz_tmp = var_CreateGetString( p_dec, "invmem-data" );
     p_sys->p_data = (void *)(intptr_t)atoll( psz_tmp );
     free( psz_tmp );
 
@@ -165,10 +162,10 @@ static int OpenDecoder( vlc_object_t *p_this )
     p_dec->fmt_out.video.i_bmask = 0x0000ff;
     p_dec->fmt_out.i_cat = VIDEO_ES;
 
-    p_dec->p_sys->i_pitch = p_dec->p_sys->i_width*3 + 
p_dec->p_sys->i_width%4;
+    p_sys->i_pitch = p_sys->i_width*3 + p_sys->i_width%4;
 
     // create new picture
-    p_dec->p_sys->p_pic = p_dec->pf_vout_buffer_new( p_dec );
+    p_sys->p_pic = p_dec->pf_vout_buffer_new( p_dec );
 
     /* Set callbacks */
     p_dec->pf_decode_video = DecodeBlock;
@@ -188,23 +185,23 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t 
**pp_block )
     if( !pp_block || !*pp_block ) return NULL;
 
     // create new picture
-    picture_Release( p_dec->p_sys->p_pic );
-    p_dec->p_sys->p_pic = p_dec->pf_vout_buffer_new( p_dec );
-    p_dec->p_sys->p_pic->b_force = true;
-    p_dec->p_sys->p_pic->p->i_pitch = p_dec->p_sys->i_pitch;
+    picture_Release( p_sys->p_pic );
+    p_sys->p_pic = p_dec->pf_vout_buffer_new( p_dec );
+    p_sys->p_pic->b_force = true;
+    p_sys->p_pic->p->i_pitch = p_dec->p_sys->i_pitch;
 
    // lock input and copy to picture
-    p_dec->p_sys->p_pic->p->p_pixels = p_dec->p_sys->pf_lock( 
p_dec->p_sys->p_data );
+    p_sys->p_pic->p->p_pixels = p_sys->pf_lock( p_dec->p_sys->p_data );
 
     // unlock input
-    p_dec->p_sys->pf_unlock( p_dec->p_sys->p_data );
+    p_sys->pf_unlock( p_dec->p_sys->p_data );
 
     block_Release( *pp_block ); *pp_block = NULL;
-    return p_dec->p_sys->p_pic;
+    return p_sys->p_pic;
 }
 
 /*****************************************************************************
- * CloseDecoder: png decoder destruction
+ * CloseDecoder: invmem decoder destruction
  
*****************************************************************************/
 static void CloseDecoder( vlc_object_t *p_this )
 {
-- 
1.5.6.5




More information about the vlc-devel mailing list