[vlc-devel] [PATCH 2/3] mpeg demux: cosmetics

Rafaël Carré funman at videolan.org
Fri Sep 9 15:02:40 CEST 2011


---
 modules/demux/mpeg/es.c |   62 ++++++++++++++++++++++-------------------------
 1 files changed, 29 insertions(+), 33 deletions(-)

diff --git a/modules/demux/mpeg/es.c b/modules/demux/mpeg/es.c
index ff1fd94..52805ca 100644
--- a/modules/demux/mpeg/es.c
+++ b/modules/demux/mpeg/es.c
@@ -259,49 +259,49 @@ static int Demux( demux_t *p_demux )
     int ret = 1;
     demux_sys_t *p_sys = p_demux->p_sys;
 
-    block_t *p_block_out = p_sys->p_packetized_data;
-    if( p_block_out )
+    block_t *p_block = p_sys->p_packetized_data;
+    if( p_block )
         p_sys->p_packetized_data = NULL;
     else
-        ret = Parse( p_demux, &p_block_out );
+        ret = Parse( p_demux, &p_block );
 
-    while( p_block_out )
+    while( p_block )
     {
-        block_t *p_next = p_block_out->p_next;
+        block_t *p_next = p_block->p_next;
 
         /* Correct timestamp */
         if( p_sys->p_packetizer->fmt_out.i_cat == VIDEO_ES )
         {
-            if( p_block_out->i_pts <= VLC_TS_INVALID &&
-                p_block_out->i_dts <= VLC_TS_INVALID )
-                p_block_out->i_dts = VLC_TS_0 + p_sys->i_pts + 1000000 / p_sys->f_fps;
-            if( p_block_out->i_dts > VLC_TS_INVALID )
-                p_sys->i_pts = p_block_out->i_dts - VLC_TS_0;
+            if( p_block->i_pts <= VLC_TS_INVALID &&
+                p_block->i_dts <= VLC_TS_INVALID )
+                p_block->i_dts = VLC_TS_0 + p_sys->i_pts + 1000000 / p_sys->f_fps;
+            if( p_block->i_dts > VLC_TS_INVALID )
+                p_sys->i_pts = p_block->i_dts - VLC_TS_0;
         }
         else
         {
-            p_sys->i_pts = p_block_out->i_pts - VLC_TS_0;
+            p_sys->i_pts = p_block->i_pts - VLC_TS_0;
         }
 
-        if( p_block_out->i_pts > VLC_TS_INVALID )
+        if( p_block->i_pts > VLC_TS_INVALID )
         {
-            p_block_out->i_pts += p_sys->i_time_offset;
+            p_block->i_pts += p_sys->i_time_offset;
         }
-        if( p_block_out->i_dts > VLC_TS_INVALID )
+        if( p_block->i_dts > VLC_TS_INVALID )
         {
-            p_block_out->i_dts += p_sys->i_time_offset;
-            es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block_out->i_dts );
+            p_block->i_dts += p_sys->i_time_offset;
+            es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block->i_dts );
         }
         /* Re-estimate bitrate */
         if( p_sys->b_estimate_bitrate && p_sys->i_pts > INT64_C(500000) )
             p_sys->i_bitrate_avg = 8*INT64_C(1000000)*p_sys->i_bytes/(p_sys->i_pts-1);
-        p_sys->i_bytes += p_block_out->i_buffer;
+        p_sys->i_bytes += p_block->i_buffer;
 
 
-        p_block_out->p_next = NULL;
-        es_out_Send( p_demux->out, p_sys->p_es, p_block_out );
+        p_block->p_next = NULL;
+        es_out_Send( p_demux->out, p_sys->p_es, p_block );
 
-        p_block_out = p_next;
+        p_block = p_next;
     }
     return ret;
 }
@@ -404,27 +404,23 @@ static int Parse( demux_t *p_demux, block_t **pp_output )
 
     *pp_output = NULL;
 
-    if( p_sys->codec.b_use_word )
-    {
-        /* Make sure we are word aligned */
-        int64_t i_pos = stream_Tell( p_demux->s );
-        if( i_pos % 2 )
-            stream_Read( p_demux->s, NULL, 1 );
-    }
+    /* Make sure we are word aligned */
+    if( p_sys->codec.b_use_word && stream_Tell( p_demux->s ) & 1 )
+        stream_Read( p_demux->s, NULL, 1 );
 
     p_block_in = stream_Block( p_demux->s, p_sys->i_packet_size );
-
     if( p_block_in )
     {
-    if( p_sys->codec.b_use_word && !p_sys->b_big_endian && p_block_in->i_buffer > 0 )
-    {
         /* Convert to big endian */
-        swab( p_block_in->p_buffer, p_block_in->p_buffer, p_block_in->i_buffer );
-    }
+        if( p_sys->codec.b_use_word && !p_sys->b_big_endian && p_block_in->i_buffer > 0 )
+            swab( p_block_in->p_buffer, p_block_in->p_buffer, p_block_in->i_buffer );
 
-    p_block_in->i_pts = p_block_in->i_dts = p_sys->b_start || p_sys->b_initial_sync_failed ? VLC_TS_0 : VLC_TS_INVALID;
+        p_block_in->i_pts = p_block_in->i_dts =
+                (p_sys->b_start || p_sys->b_initial_sync_failed)
+                    ? VLC_TS_0 : VLC_TS_INVALID;
     }
     p_sys->b_initial_sync_failed = p_sys->b_start; /* Only try to resync once */
+
     while( ( p_block_out = p_sys->p_packetizer->pf_packetize( p_sys->p_packetizer, p_block_in ? &p_block_in : NULL ) ) )
     {
         p_sys->b_initial_sync_failed = false;
-- 
1.7.5.4



More information about the vlc-devel mailing list