[MPlayer-cvslog] r30421 - in trunk: libmpcodecs/ad_ffmpeg.c libmpdemux/demuxer.c

reimar subversion at mplayerhq.hu
Sun Jan 24 16:19:14 CET 2010


Author: reimar
Date: Sun Jan 24 16:19:14 2010
New Revision: 30421

Log:
Reset the parser on seek. Should fix some cases of audio "blips" after seeking.
AC3 is still broken due to the libavcodec parser being broken.

Modified:
   trunk/libmpcodecs/ad_ffmpeg.c
   trunk/libmpdemux/demuxer.c

Modified: trunk/libmpcodecs/ad_ffmpeg.c
==============================================================================
--- trunk/libmpcodecs/ad_ffmpeg.c	Sun Jan 24 16:16:39 2010	(r30420)
+++ trunk/libmpcodecs/ad_ffmpeg.c	Sun Jan 24 16:19:14 2010	(r30421)
@@ -153,6 +153,7 @@ static int control(sh_audio_t *sh,int cm
     switch(cmd){
     case ADCTRL_RESYNC_STREAM:
         avcodec_flush_buffers(lavc_context);
+        ds_clear_parser(sh->ds);
     return CONTROL_TRUE;
     }
     return CONTROL_UNKNOWN;

Modified: trunk/libmpdemux/demuxer.c
==============================================================================
--- trunk/libmpdemux/demuxer.c	Sun Jan 24 16:16:39 2010	(r30420)
+++ trunk/libmpdemux/demuxer.c	Sun Jan 24 16:19:14 2010	(r30421)
@@ -60,6 +60,7 @@
 // just be removed again.
 #define PARSE_ON_ADD 0
 
+static void clear_parser(sh_common_t *sh);
 void resync_video_stream(sh_video_t *sh_video);
 void resync_audio_stream(sh_audio_t *sh_audio);
 
@@ -286,8 +287,7 @@ void free_sh_sub(sh_sub_t *sh)
 #endif
     free(sh->lang);
 #ifdef CONFIG_LIBAVCODEC
-    av_parser_close(sh->parser);
-    av_freep(&sh->avctx);
+    clear_parser((sh_common_t *)sh);
 #endif
     free(sh);
 }
@@ -327,8 +327,7 @@ void free_sh_audio(demuxer_t *demuxer, i
     free(sh->codecdata);
     free(sh->lang);
 #ifdef CONFIG_LIBAVCODEC
-    av_parser_close(sh->parser);
-    av_freep(&sh->avctx);
+    clear_parser((sh_common_t *)sh);
 #endif
     free(sh);
 }
@@ -359,8 +358,7 @@ void free_sh_video(sh_video_t *sh)
     mp_msg(MSGT_DEMUXER, MSGL_DBG2, "DEMUXER: freeing sh_video at %p\n", sh);
     free(sh->bih);
 #ifdef CONFIG_LIBAVCODEC
-    av_parser_close(sh->parser);
-    av_freep(&sh->avctx);
+    clear_parser((sh_common_t *)sh);
 #endif
     free(sh);
 }
@@ -510,6 +508,20 @@ int ds_parse(demux_stream_t *ds, uint8_t
         return *len;
     return av_parser_parse2(parser, avctx, buffer, len, *buffer, *len, pts, pts, pos);
 }
+
+static void clear_parser(sh_common_t *sh)
+{
+    av_parser_close(sh->parser);
+    sh->parser = NULL;
+    av_freep(&sh->avctx);
+}
+
+void ds_clear_parser(demux_stream_t *ds)
+{
+    if (!ds->sh)
+        return;
+    clear_parser(ds->sh);
+}
 #endif
 
 void ds_add_packet(demux_stream_t *ds, demux_packet_t *dp)
@@ -1200,6 +1212,11 @@ static void demux_resync(demuxer_t *demu
 
 void demux_flush(demuxer_t *demuxer)
 {
+#if PARSE_ON_ADD
+    ds_clear_parser(demuxer->video);
+    ds_clear_parser(demuxer->audio);
+    ds_clear_parser(demuxer->sub);
+#endif
     ds_free_packs(demuxer->video);
     ds_free_packs(demuxer->audio);
     ds_free_packs(demuxer->sub);


More information about the MPlayer-cvslog mailing list