[FFmpeg-devel] [Patch] mpegts: emit pes packets on completion

Janne Grunau janne-ffmpeg
Thu Apr 29 02:37:41 CEST 2010


Hej,

On Wed, Apr 28, 2010 at 04:58:30PM -0700, Baptiste Coudurier wrote:
> >
> > diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> > index c92a9c2..c002a3f 100644
> > --- a/libavformat/mpegts.c
> > +++ b/libavformat/mpegts.c
> > @@ -807,6 +807,14 @@ static int mpegts_push_data(MpegTSFilter *filter,
> >                   pes->data_index += buf_size;
> >               }
> >               buf_size = 0;
> > +            /* emit complete packets with known packet size
> > +             * total_size is the number of bytes following pes_packet_length
> > +             * in the pes header, i.e. not counting the first 6 bytes */
> > +            if (pes->total_size<  MAX_PES_PAYLOAD&&
> 
> Are you sure this condition can trigger ?

yes, pes->total_size is set to MAX_PES_PAYLOAD for unbound pes packets

> > +                pes->pes_header_size + pes->data_index == pes->total_size + 6) {
> > +                ts->stop_parse = 1;
> > +                new_pes_packet(pes, ts->pkt);
> > +            }
> 
> having the reason in the comment would be nice, like this is especially 
> needed for subtitles.

updated patch attached

Janne
-------------- next part --------------
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index c92a9c2..eb7a874 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -807,6 +807,16 @@ static int mpegts_push_data(MpegTSFilter *filter,
                 pes->data_index += buf_size;
             }
             buf_size = 0;
+            /* emit complete packets with known packet size
+	     * decreases demuxer delay for infrequent packets like subtitles from
+	     * a couple of seconds to milliseconds for properly muxed files.
+             * total_size is the number of bytes following pes_packet_length
+             * in the pes header, i.e. not counting the first 6 bytes */
+            if (pes->total_size < MAX_PES_PAYLOAD &&
+                pes->pes_header_size + pes->data_index == pes->total_size + 6) {
+                ts->stop_parse = 1;
+                new_pes_packet(pes, ts->pkt);
+            }
             break;
         case MPEGTS_SKIP:
             buf_size = 0;



More information about the ffmpeg-devel mailing list