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

Baptiste Coudurier baptiste.coudurier
Thu Apr 29 01:58:30 CEST 2010


Hi,

On 04/28/2010 04:45 PM, Janne Grunau wrote:
> On Sat, Apr 24, 2010 at 12:13:49AM +0200, Janne Grunau wrote:
>> Hi,
>>
>> the mpegts demuxer emits pes packets only after the start of the next
>> packet. This creates problems for streams with distant and rare packets
>> like DVB subtitles.
>> The attached patch emits pes packets as soon as the data is completely
>> written.
>>
>> Janne
>
>> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
>> index d594abc..006d640 100644
>> --- a/libavformat/mpegts.c
>> +++ b/libavformat/mpegts.c
>> @@ -807,6 +807,13 @@ static int mpegts_push_data(MpegTSFilter *filter,
>>                   pes->data_index += buf_size;
>>               }
>>               buf_size = 0;
>> +            /* emit complete packets
>> +             * 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->pes_header_size + pes->data_index>= pes->total_size + 6) {
>
> the condition needs to be == and it probably makes sense to check for
> pes packets with known packet size, i.e. total_size<  MAX_PES_PAYLOADSIZE
>
> updated patch attached
>
> Janne
>
>
>
> mpegts_emit_complete_pes.diff
>
>
> 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 ?

> +                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.

-- 
Baptiste COUDURIER
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer                                  http://www.ffmpeg.org



More information about the ffmpeg-devel mailing list