[MPlayer-dev-eng] [PATCH] DVB TS subtitle not working if corresponding PID doesn't occur at beginning for -demux lavf

KS Ng - dmbth hk.dmbth at gmail.com
Mon Oct 4 07:13:47 CEST 2010


The patch is amended. Please review!

Thanks,
K.S. Ng

Index: libmpdemux/demux_lavf.c
===================================================================
--- libmpdemux/demux_lavf.c     (revision 32437)
+++ libmpdemux/demux_lavf.c     (working copy)
@@ -77,6 +77,7 @@
     int vstreams[MAX_V_STREAMS];
     int sstreams[MAX_S_STREAMS];
     int cur_program;
+    int nb_streams_last;
 }lavf_priv_t;
 
 static int mp_read(void *opaque, uint8_t *buf, int size) {
@@ -573,6 +574,8 @@
         demuxer->video->id=-2; // audio-only
     } //else if (best_video > 0 && demuxer->video->id == -1) 
demuxer->video->id = best_video;
 
+    priv->nb_streams_last = priv->avfc->nb_streams;
+
     return demuxer;
 }
 
@@ -581,7 +584,7 @@
     AVPacket pkt;
     demux_packet_t *dp;
     demux_stream_t *ds;
-    int id;
+    int id, i;
     mp_msg(MSGT_DEMUX,MSGL_DBG2,"demux_lavf_fill_buffer()\n");
 
     demux->filepos=stream_tell(demux->stream);
@@ -589,6 +592,12 @@
     if(av_read_frame(priv->avfc, &pkt) < 0)
         return 0;
 
+    if( priv->nb_streams_last != priv->avfc->nb_streams ) {
+        for(i=priv->nb_streams_last; i<priv->avfc->nb_streams; i++)
+            handle_stream(demux, priv->avfc, i);
+        priv->nb_streams_last = priv->avfc->nb_streams;
+    }
+
     id= pkt.stream_index;
 
     if(id==demux->audio->id){

Reimar Döffinger wrote:
> On Sun, Oct 03, 2010 at 08:40:16AM +0800, KS Ng - dmbth wrote:
>   
>> --- libmpdemux/demux_lavf.c     (revision 32358)
>> +++ libmpdemux/demux_lavf.c     (working copy)
>> @@ -77,6 +77,7 @@
>>    int vstreams[MAX_V_STREAMS];
>>    int sstreams[MAX_S_STREAMS];
>>    int cur_program;
>> +    int nb_streams_last;
>> }lavf_priv_t;
>>
>> static int mp_read(void *opaque, uint8_t *buf, int size) {
>> @@ -573,6 +574,8 @@
>>        demuxer->video->id=-2; // audio-only
>>    } //else if (best_video > 0 && demuxer->video->id == -1)
>> demuxer->video->id = best_video;
>>
>> +    priv->nb_streams_last = priv->avfc->nb_streams;
>> +
>>     
>
> Your mailer mangled the patch.
> The indentation doesn't match the surrounding one.
> Also, I think it would be better for long-term
> maintainability to put this assignment right
> after the handle_stream loop.
>
>   
>> @@ -589,6 +592,14 @@
>>    if(av_read_frame(priv->avfc, &pkt) < 0)
>>        return 0;
>>
>> +    if( priv->nb_streams_last != priv->avfc->nb_streams ) {
>> +        mp_msg(MSGT_DEMUX, MSGL_DBG2, "Nb streams changed %d %d\n",
>> priv->nb_streams_last, priv->avfc->nb_streams);
>> +        for(i=priv->nb_streams_last; i<priv->avfc->nb_streams; i++) {
>> +            handle_stream(demux, priv->avfc, i);
>> +        }
>> +    }
>> +    priv->nb_streams_last = priv->avfc->nb_streams;
>>     
>
> Remove the mp_msg (we should usually get some output from
> handle_stream anyway).
> Then you can simplify it to
>
> for (i = priv->nb_streams_last; i < priv->avfc->nb_streams; i++)
>     handle_stream(demux, priv->avfc, i);
> priv->nb_streams_last = priv->avfc->nb_streams;
> _______________________________________________
> MPlayer-dev-eng mailing list
> MPlayer-dev-eng at mplayerhq.hu
> https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
>
>   



More information about the MPlayer-dev-eng mailing list