[FFmpeg-devel] Meaningful return codes (was [PATCH 7/9] Replace AVERROR_NOTSUPP by AVERROR(ENOSYS))
Fri Jul 20 11:05:12 CEST 2007
Op 19-jul-07, om 22:28 heeft Michael Niedermayer het volgende
> On Thu, Jul 19, 2007 at 07:22:00PM +0200, Panagiotis Issaris wrote:
>> I see. Thanks for the information!
>> Related to this: As I've mentioned before on this list, one of the
>> I'd like to change in libavcodec is the handling of errors. I'd like
>> returncodes indicating failure to carry information about the cause
>> of the
>> failure. So, for example, in the case of mpegvideo_enc.c, I'd
>> prefer to
>> see MPV_encode_init() return different errorcodes for different
>> kinds of
>> failures occurring instead of the currently used "return -1;" for all
>> I'm not sure about the granularity though...
>> Would something like this be nice & useful?
>> #define AVERROR_PIXFMT_NOTSUP <somevalue>
>> #define AVERROR_BFRAMES_NOTSUP <somevalue+1>
>> #define AVERROR_RC_PARSE_ERROR <somevalue+2>
> whats the sense of this?
> an application which has code to parse these and do some appropriate
> action beyond printing an error message can as well just contain code
> to set the values properly in the first place
No, I think it's different. For example, it could be that the values
set by the application but by an end-user. Ofcourse the app should parse
the values for legality in some sense, but lets say your writing a GUI
for transcoding files. The end-user tries to transcode a DVD to
then tries to use the H.261 codec instead. Then you can either just show
an error-message explaining that only CIF and QCIF are supported or _for
some applications_ it could be useful to switch to CIF automatically.
pretty sure most of us here would prefer that _not_ to happen, but
end-users, this could be the prefered way of doing things.
When you're returning "-1" in all possible cases something is going
an application can not choose how to handle such situations; it can
the error message.
Ofcourse, the application could also contain all the logic to do these
checks by itself, but imho that would be unnecessary code duplication
exact logic is already available in the library.
A good example would be the rc_eq parsing code. If libavcodec would
meaningful return codes, it would be easy to write an app providing
to alter it. If not, it would have to duplicate a lot of the code
which is already
With friendly regards,
PGP key: http://issaris.org/pi.key
More information about the ffmpeg-devel