[FFmpeg-devel] [PATCH] lavu/error: use a sorted table for storing error codes and strings, add test

Nicolas George nicolas.george at normalesup.org
Mon Feb 6 14:57:05 CET 2012


L'octidi 18 pluviôse, an CCXX, Stefano Sabatini a écrit :
> The table is mostly useful for enumerating the available AVERROR* in the
> test output.

The idea is interesting, but I find that keeping the table ordered by tag is
rather bad for readability and maintainability. The table is quite small: a
simple linear search could be efficient enough.

Also, note that a good compiler can optimize a big switch/case with a
statically optimized data structure. For example, I look at the assembly
code for avcodec_get_name produced by gcc -O3, and it looks a lot like a
binary search.

As for enumerating all error values, we use a lot AVERROR(errno) codes, even
that we generate ourselves (I mean: not only do we return AVERROR(errno) to
forward a system error, but also we write AVERROR(EINVAL) or AVERROR(ENOMEM)
instead of a custom error code), so the list would always be incomplete.

Regards,

-- 
  Nicolas George


More information about the ffmpeg-devel mailing list