[vlc-commits] dirac: use block_Init() and block_Release() as appropriate

Rémi Denis-Courmont git at videolan.org
Mon Aug 29 17:41:20 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Aug 29 18:38:15 2011 +0300| [a3cb8280272b24016059965c3edd292320af0a7b] | committer: Rémi Denis-Courmont

dirac: use block_Init() and block_Release() as appropriate

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a3cb8280272b24016059965c3edd292320af0a7b
---

 modules/packetizer/dirac.c |   31 +++++++++++++++++++------------
 1 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/modules/packetizer/dirac.c b/modules/packetizer/dirac.c
index 91de688..8588674 100644
--- a/modules/packetizer/dirac.c
+++ b/modules/packetizer/dirac.c
@@ -215,23 +215,24 @@ enum {
 typedef struct {
     block_t fake;
     block_t *p_orig;
-    void *p_priv;
+    dirac_block_encap_t *p_dbe;
 } fake_block_t;
 
 static dirac_block_encap_t *dirac_RemoveBlockEncap( block_t *p_block )
 {
     fake_block_t *p_fake = (fake_block_t *)p_block;
-    dirac_block_encap_t *p_dbe = p_fake->p_priv;
+    dirac_block_encap_t *p_dbe = p_fake->p_dbe;
 
-    p_fake->p_priv = NULL;
+    p_fake->p_dbe = NULL;
     return p_dbe;
 }
 
 static void dirac_ReleaseBlockAndEncap( block_t *p_block )
 {
     fake_block_t *p_fake = (fake_block_t *)p_block;
+
     free( dirac_RemoveBlockEncap( p_block ) );
-    p_fake->p_orig->pf_release( p_fake->p_orig );
+    block_Release( p_fake->p_orig );
     free( p_fake );
 }
 
@@ -239,13 +240,19 @@ static void dirac_AddBlockEncap( block_t **pp_block, dirac_block_encap_t *p_dbe
 {
     /* must not fail, fixby: adding a p_priv to block_t */
     fake_block_t *p_fake = xcalloc( 1, sizeof( *p_fake ) );
-
-    p_fake->p_orig = *pp_block;
-    memcpy( &p_fake->fake, *pp_block, sizeof( block_t ) );
-    *pp_block = &p_fake->fake;
-
-    p_fake->p_priv = p_dbe;
-    p_fake->fake.pf_release = dirac_ReleaseBlockAndEncap;
+    block_t *in = *pp_block, *out = &p_fake->fake;
+
+    block_Init( out, in->p_buffer, in->i_buffer );
+    out->i_flags = in->i_flags;
+    out->i_nb_samples = in->i_nb_samples;
+    out->i_pts = in->i_pts;
+    out->i_dts = in->i_dts;
+    out->i_length = in->i_length;
+    out->pf_release = dirac_ReleaseBlockAndEncap;
+    p_fake->p_orig = in;
+    p_fake->p_dbe = p_dbe;
+
+    *pp_block = out;
 }
 
 static dirac_block_encap_t *dirac_NewBlockEncap( block_t **pp_block )
@@ -257,7 +264,7 @@ static dirac_block_encap_t *dirac_NewBlockEncap( block_t **pp_block )
 
 static dirac_block_encap_t *dirac_GetBlockEncap( block_t *p_block )
 {
-    return (dirac_block_encap_t*) ((fake_block_t *)p_block)->p_priv;
+    return ((fake_block_t *)p_block)->p_dbe;
 }
 
 /***



More information about the vlc-commits mailing list