[FFmpeg-devel] [PATCH 1/8] lavf: add internal demuxer helpers for subtitles.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Mon Jun 18 07:37:08 CEST 2012


On 17 Jun 2012, at 14:29, Nicolas George <nicolas.george at normalesup.org> wrote:
> Le decadi 30 prairial, an CCXX, Clément Bœsch a écrit :
>> 
>> +static int cmp_pkt_sub(const void *a, const void *b)
>> +{
>> +    const int64_t t1 = ((const FFDemuxSubEntry *)a)->start;
>> +    const int64_t t2 = ((const FFDemuxSubEntry *)b)->start;
>> +    if (t1 == t2)
>> +        return 0;
>> +    return t1 > t2 ? 1 : -1;
>> +}
> 
> The qsort function from the libc is not guaranteed to be stable. In
> subtitles, the order of arrival of simultaneous events may be relevant.

Note that even if not required, that kind of thing can cause test failures, so it is always best to never use qsort in a way that gives it a choice.
Also in some cases it makes sense to use your own sort function more fit for the purpose, but probably that's not the case here.


More information about the ffmpeg-devel mailing list