[FFmpeg-devel] [PATCH 5/5] avfilter/drawutils: support native-endian instead of little endian
Marton Balint
cus at passwd.hu
Sun Jan 27 18:21:06 EET 2019
On Sun, 27 Jan 2019, Muhammad Faiz wrote:
> On Sun, Jan 27, 2019 at 5:25 PM Marton Balint <cus at passwd.hu> wrote:
>>
>>
>>
>> On Sun, 27 Jan 2019, Muhammad Faiz wrote:
>>
>> > Signed-off-by: Muhammad Faiz <mfcc64 at gmail.com>
>> > ---
>> > Old thread is here: https://ffmpeg.org/pipermail/ffmpeg-devel/2016-June/195941.html
>> > Need someone test it on big-endian machine.
>> >
>> > libavfilter/drawutils.c | 48 +++++++++++++++++++++----------------
>> > libavfilter/vf_rotate.c | 26 ++++++++++----------
>> > libavfilter/vf_tinterlace.c | 30 +++++++++++------------
>> > 3 files changed, 54 insertions(+), 50 deletions(-)
>> >
>> > diff --git a/libavfilter/drawutils.c b/libavfilter/drawutils.c
>> > index 5f4cb548f0..12bdfcb900 100644
>> > --- a/libavfilter/drawutils.c
>> > +++ b/libavfilter/drawutils.c
>> > @@ -175,6 +175,17 @@ void ff_copy_rectangle(uint8_t *dst[4], int dst_linesize[4],
>> > }
>> > }
>> >
>> > +static int is_native_endian(const AVPixFmtDescriptor *desc)
>> > +{
>> > + int len = strlen(desc->name);
>> > +
>> > + if (!strcmp(desc->name + len - 2, "be"))
>> > + return HAVE_BIGENDIAN;
>> > + if (!strcmp(desc->name + len - 2, "le"))
>> > + return !HAVE_BIGENDIAN;
>> > + return 1;
>> > +}
>> > +
>>
>> Maybe you can check if shift+depth > 8 and FMT_FLAG_BE instead of string
>> compare?
>
> I don't really understand your code. Currently I can't test on
> big-endian platform. Adding something that I don't understand and
> can't test is not a good idea.
Using strcmp to determine format endianness is ugly. Use other means, like
checking component bit depth, or component step:
static int is_native_endian(const AVPixFmtDescriptor *desc)
{
return desc->comp[0].step <= 1 ||
(HAVE_BIGENDIAN == !!(desc->comp[0].flags & AV_PIX_FMT_FLAG_BE));
}
Thanks,
Marton
More information about the ffmpeg-devel
mailing list