[FFmpeg-devel] [PATCH 1/1] avutil/csp: create public API for colorspace structs

Leo Izen leo.izen at gmail.com
Fri May 20 19:06:47 EEST 2022


On 5/20/22 12:01, Andreas Rheinhardt wrote:
> Leo Izen:
>> This commit moves some of the functionality from avfilter/colorspace
>> into avutil/csp and exposes it as a public API so it can be used by
>> libavcodec and/or libavformat. It also converts those structs from
>> double values to AVRational to make regression testing easier and
>> more consistent.
>> ---
>> +
>> +#include <stdlib.h>
>> +
>> +#include "attributes.h"
>> +#include "csp.h"
>> +#include "pixfmt.h"
>> +#include "rational.h"
>> +
>> +#define AVR(d) { (int)(d * 30000), 30000 }
> 
> Does this really lead to the intended values? After all, the cast does
> not round to nearest, instead it just discards the fractional part (i.e.
> rounds towards zero). You should probably use (int)(d * 30000 + 0.5) to
> compensate for that.
> 

I could change it to do that. That said, I modeled this after the FIX 
macro in libavcodec/mpegaudio.h on line 60, which doesn't do that. Is 
that macro also incorrect, or is there a caveat here that makes these 
scenarios different?

- Leo Izen (thebombzen)


More information about the ffmpeg-devel mailing list