[vlc-commits] demux: asf: add reset helper for asfpacket tracks

Francois Cartegnie git at videolan.org
Tue Nov 17 13:13:36 CET 2020


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Nov 16 22:05:45 2020 +0100| [01bb907f05e2f8d95747db386dfa931404350e99] | committer: Francois Cartegnie

demux: asf: add reset helper for asfpacket tracks

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

 modules/demux/asf/asf.c       | 10 ++--------
 modules/demux/asf/asfpacket.c | 15 +++++++++++++++
 modules/demux/asf/asfpacket.h |  2 ++
 modules/demux/mp4/mp4.c       | 10 +++-------
 4 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/modules/demux/asf/asf.c b/modules/demux/asf/asf.c
index 12368e2a92..0e58c53732 100644
--- a/modules/demux/asf/asf.c
+++ b/modules/demux/asf/asf.c
@@ -900,12 +900,10 @@ static int DemuxInit( demux_t *p_demux )
             goto error;
         memset( tk, 0, sizeof( asf_track_t ) );
 
+        ASFPacketTrackInit( &tk->info );
         tk->i_time = VLC_TICK_INVALID;
         tk->info.p_sp = p_sp;
         tk->p_es = NULL;
-        tk->info.p_esp = NULL;
-        tk->info.p_frame = NULL;
-        tk->info.i_cat = UNKNOWN_ES;
         tk->queue.p_first = NULL;
         tk->queue.pp_last = &tk->queue.p_first;
 
@@ -1373,11 +1371,7 @@ error:
  *****************************************************************************/
 static void FlushQueue( asf_track_t *tk )
 {
-    if( tk->info.p_frame )
-    {
-        block_ChainRelease( tk->info.p_frame );
-        tk->info.p_frame = NULL;
-    }
+    ASFPacketTrackReset( &tk->info );
     if( tk->queue.p_first )
     {
         block_ChainRelease( tk->queue.p_first );
diff --git a/modules/demux/asf/asfpacket.c b/modules/demux/asf/asfpacket.c
index 714d327fbe..1543e71060 100644
--- a/modules/demux/asf/asfpacket.c
+++ b/modules/demux/asf/asfpacket.c
@@ -532,3 +532,18 @@ loop_error_recovery:
 
     return 1;
 }
+
+void ASFPacketTrackInit( asf_track_info_t *p_ti )
+{
+    p_ti->i_cat = UNKNOWN_ES;
+    p_ti->p_esp = NULL;
+    p_ti->p_sp = NULL;
+    p_ti->p_frame = NULL;
+}
+
+void ASFPacketTrackReset( asf_track_info_t *p_ti )
+{
+    if( p_ti->p_frame )
+        block_ChainRelease( p_ti->p_frame );
+    p_ti->p_frame = NULL;
+}
diff --git a/modules/demux/asf/asfpacket.h b/modules/demux/asf/asfpacket.h
index 5f1da1b8b2..af1a029d81 100644
--- a/modules/demux/asf/asfpacket.h
+++ b/modules/demux/asf/asfpacket.h
@@ -61,4 +61,6 @@ struct asf_packet_sys_s
 };
 
 int DemuxASFPacket( asf_packet_sys_t *, uint32_t, uint32_t, uint64_t, uint64_t );
+void ASFPacketTrackInit( asf_track_info_t * );
+void ASFPacketTrackReset( asf_track_info_t * );
 #endif
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index c39e3a2deb..a496f52c12 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -3566,8 +3566,7 @@ static void MP4_TrackClean( es_out_t *out, mp4_track_t *p_track )
     if( !p_track->i_sample_size )
         free( p_track->p_sample_size );
 
-    if ( p_track->asfinfo.p_frame )
-        block_ChainRelease( p_track->asfinfo.p_frame );
+    ASFPacketTrackReset( &p_track->asfinfo );
 
     free( p_track->context.runs.p_array );
 }
@@ -3581,6 +3580,7 @@ static void MP4_TrackInit( mp4_track_t *p_track, const MP4_Box_t *p_trackbox )
     const MP4_Box_t *p_tkhd = MP4_BoxGet( p_trackbox, "tkhd" );
     if(likely(p_tkhd) && BOXDATA(p_tkhd))
         p_track->i_track_ID = BOXDATA(p_tkhd)->i_track_ID;
+    ASFPacketTrackInit( &p_track->asfinfo );
 }
 
 static void MP4_TrackSelect( demux_t *p_demux, mp4_track_t *p_track, bool b_select )
@@ -5198,10 +5198,6 @@ static void MP4ASF_ResetFrames( demux_sys_t *p_sys )
     for ( unsigned int i=0; i<p_sys->i_tracks; i++ )
     {
         mp4_track_t *p_track = &p_sys->track[i];
-        if( p_track->asfinfo.p_frame )
-        {
-            block_ChainRelease( p_track->asfinfo.p_frame );
-            p_track->asfinfo.p_frame = NULL;
-        }
+        ASFPacketTrackReset( &p_track->asfinfo );
     }
 }



More information about the vlc-commits mailing list