[FFmpeg-devel] [PATCH] cmdutils: sort codec lists.
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Sun Sep 23 12:06:12 CEST 2012
On Sun, Sep 23, 2012 at 11:05:32AM +0200, Nicolas George wrote:
> The lists are sorted first by type (video first)
> and then alphabetically by name.
>
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
> cmdutils.c | 44 ++++++++++++++++++++++++++++++++++++++++----
> 1 file changed, 40 insertions(+), 4 deletions(-)
>
>
> New version, with the lists for -encoders and -decoders sorted as well.
>
> I do not think I can use Michael's compare function because AFAIK there is
> no guarantee that strcmp's return value is between -255 and +255; I can
> imagine big-endian implementations comparing two or four chars at once and
> returning a larger value.
Doesn't really matter (and I am not completely sure the second at least
isn't actually a good bit uglier/worse), but there are two ways to simplify it:
int type_diff = (*da)->type - (*db)->type;
return type_diff ? type_diff : strcmp((*da)->name, (*db)->name);
or
return 256*((*da)->type - (*db)->type) + (strcmp((*da)->name, (*db)->name) >> 31);
More information about the ffmpeg-devel
mailing list