[FFmpeg-devel] [PATCH 1/2] avformat/dvbtxt: add raw demuxer for dvb teletext probing

Marton Balint cus at passwd.hu
Tue Feb 16 20:19:38 CET 2016


On Tue, 16 Feb 2016, Carl Eugen Hoyos wrote:

> Marton Balint <cus <at> passwd.hu> writes:
>
>> +    /* The purpose of this is demuxer is to detect DVB teletext 
>> streams in
>> +     * mpegts, so we reject invalid buffer sizes */
>> +    if ((p->buf_size + 45) % 184 != 0)
>> +        return 0;
>
> I don't think this is ok (although I may miss 
> something):
> The file could end in the middle of a teletext 
> patckage or the end of the probe buffer could 
> be within a teletext package.

Usually you'd be right, but not this time I think because the reason for 
this demuxer is not to actually handle RAW dvb teletext files (I doubt 
those exists in the real world), but only to detect DVB teletext streams 
in mpegts. Therefore it matches for a single PES payload, not a bitstream.

A RAW dvb teletext file would be a dump of PES payloads without separation 
where one would constantly have to find synchornization because there is 
no way of knowning how big is a PES payload and when the next one starts.

On the other hand DVB teletext PES payloads have a strict length 
requirement, and they are at most 1437 bytes long, so the full payload 
should always be probed even if the probe function truncates at 2048 bytes 
or so (I don't know if it does or not).

>
>> +    if (!ff_data_identifier_is_teletext(p->buf[0]))
>> +        return 0;
>> +
>> +    for (buf = p->buf + 1; buf < end; buf += 46) {
>> +        if (!ff_data_unit_id_is_teletext(buf[0]) && buf[0] != 0xff)
>> +            return 0;
>> +        if (buf[1] != 0x2c)     // data_unit_length
>> +            return 0;
>> +    }
>
> I suspect this should count frames.

Not really, a PES payload is only one frame, the loop match data units 
(practically VBI lines, or stuffing).

>> +    return AVPROBE_SCORE_MAX / 2;
>
> Is this ok for one frame?

I don't know, I figured even for the smallest PES payload which is 139 
bytes we are matching 1+2+2+2 mostly different bytes, which should be a 
pretty safe detection, therefore AVPROBE_SCORE_MAX / 2. I can use anything 
here you prefer.

>
>> +++ b/libavutil/internal.h
>
> Please create a new teletext header in libavcodec.

Why not in libavutil then? It is used in a codec in libavcodec and a probe 
function in libavformat.

Regards,
Marton


More information about the ffmpeg-devel mailing list