[FFmpeg-devel,5/5] avfilter/drawutils: support native-endian instead of little endian

Submitted by Muhammad Faiz on Jan. 27, 2019, 9:36 a.m.

Details

Message ID 20190127093619.28904-5-mfcc64@gmail.com
State New
Headers show

Commit Message

Muhammad Faiz Jan. 27, 2019, 9:36 a.m.
Signed-off-by: Muhammad Faiz <mfcc64@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(-)

Comments

Marton Balint Jan. 27, 2019, 10:25 a.m.
On Sun, 27 Jan 2019, Muhammad Faiz wrote:

> Signed-off-by: Muhammad Faiz <mfcc64@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?

Thanks,
Marton
Muhammad Faiz Jan. 27, 2019, 3:18 p.m.
On Sun, Jan 27, 2019 at 5:25 PM Marton Balint <cus@passwd.hu> wrote:
>
>
>
> On Sun, 27 Jan 2019, Muhammad Faiz wrote:
>
> > Signed-off-by: Muhammad Faiz <mfcc64@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.
Carl Eugen Hoyos Jan. 27, 2019, 4:01 p.m.
2019-01-27 16:18 GMT+01:00, Muhammad Faiz <mfcc64@gmail.com>:
> On Sun, Jan 27, 2019 at 5:25 PM Marton Balint <cus@passwd.hu> wrote:
>>
>>
>>
>> On Sun, 27 Jan 2019, Muhammad Faiz wrote:
>>
>> > Signed-off-by: Muhammad Faiz <mfcc64@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.

Something like "return shift + depth <=8 ||
desc->flags | FMT_FLAG_BE ^ !HAVE_BIGENDIAN"

And since the new function is only used once, it may
be more readable not to add a new function.

> 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.

But your patchset does change big-endian code and only
improves big-endian, no?

Carl Eugen
Marton Balint Jan. 27, 2019, 4:21 p.m.
On Sun, 27 Jan 2019, Muhammad Faiz wrote:

> On Sun, Jan 27, 2019 at 5:25 PM Marton Balint <cus@passwd.hu> wrote:
>>
>>
>>
>> On Sun, 27 Jan 2019, Muhammad Faiz wrote:
>>
>> > Signed-off-by: Muhammad Faiz <mfcc64@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
Muhammad Faiz Jan. 27, 2019, 4:38 p.m.
On Sun, Jan 27, 2019 at 11:02 PM Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>
> 2019-01-27 16:18 GMT+01:00, Muhammad Faiz <mfcc64@gmail.com>:
> > On Sun, Jan 27, 2019 at 5:25 PM Marton Balint <cus@passwd.hu> wrote:
> >>
> >>
> >>
> >> On Sun, 27 Jan 2019, Muhammad Faiz wrote:
> >>
> >> > Signed-off-by: Muhammad Faiz <mfcc64@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.
>
> Something like "return shift + depth <=8 ||
> desc->flags | FMT_FLAG_BE ^ !HAVE_BIGENDIAN"

OK, I will try.

>
> And since the new function is only used once, it may
> be more readable not to add a new function.

OK.

>
> > 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.
>
> But your patchset does change big-endian code and only
> improves big-endian, no?

Yes. I write it blindly. I really depends on Michael's report on
big-endian platform.
Muhammad Faiz Jan. 27, 2019, 4:43 p.m.
On Sun, Jan 27, 2019 at 11:21 PM Marton Balint <cus@passwd.hu> wrote:
>
>
>
> On Sun, 27 Jan 2019, Muhammad Faiz wrote:
>
> > On Sun, Jan 27, 2019 at 5:25 PM Marton Balint <cus@passwd.hu> wrote:
> >>
> >>
> >>
> >> On Sun, 27 Jan 2019, Muhammad Faiz wrote:
> >>
> >> > Signed-off-by: Muhammad Faiz <mfcc64@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));
> }
>

comp[0] doesn't have flags.
Anyway, I will try.

Thank's
Carl Eugen Hoyos Jan. 27, 2019, 4:44 p.m.
2019-01-27 17:38 GMT+01:00, Muhammad Faiz <mfcc64@gmail.com>:
> On Sun, Jan 27, 2019 at 11:02 PM Carl Eugen Hoyos <ceffmpeg@gmail.com>
> wrote:
>>
>> 2019-01-27 16:18 GMT+01:00, Muhammad Faiz <mfcc64@gmail.com>:
>> > On Sun, Jan 27, 2019 at 5:25 PM Marton Balint <cus@passwd.hu> wrote:
>> >>
>> >> On Sun, 27 Jan 2019, Muhammad Faiz wrote:

>> >> > +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.
>>
>> Something like "return shift + depth <=8 ||
>> desc->flags | FMT_FLAG_BE ^ !HAVE_BIGENDIAN"
>
> OK, I will try.

Please use Marton's suggestion, the "|" will not be the only
thing completely wrong.

Carl Eugen

Patch hide | download patch | download mbox

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;
+}
+
 int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags)
 {
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(format);
@@ -185,20 +196,20 @@  int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags)
 
     if (!desc || !desc->name)
         return AVERROR(EINVAL);
-    if (desc->flags & ~(AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB | FF_PSEUDOPAL | AV_PIX_FMT_FLAG_ALPHA))
+    if (desc->flags & ~(AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB | FF_PSEUDOPAL | AV_PIX_FMT_FLAG_ALPHA | AV_PIX_FMT_FLAG_BE))
         return AVERROR(ENOSYS);
     if (format == AV_PIX_FMT_P010LE || format == AV_PIX_FMT_P010BE || format == AV_PIX_FMT_P016LE || format == AV_PIX_FMT_P016BE)
         return AVERROR(ENOSYS);
     if (format == AV_PIX_FMT_YUVJ420P || format == AV_PIX_FMT_YUVJ422P || format == AV_PIX_FMT_YUVJ444P ||
         format == AV_PIX_FMT_YUVJ411P || format == AV_PIX_FMT_YUVJ440P)
         full_range = 1;
+    if (!is_native_endian(desc))
+        return AVERROR(ENOSYS);
     for (i = 0; i < desc->nb_components; i++) {
         c = &desc->comp[i];
         /* for now, only 8-16 bits formats */
         if (c->depth < 8 || c->depth > 16)
             return AVERROR(ENOSYS);
-        if (desc->flags & AV_PIX_FMT_FLAG_BE)
-            return AVERROR(ENOSYS);
         if (c->plane >= MAX_PLANES)
             return AVERROR(ENOSYS);
         /* strange interleaving */
@@ -268,11 +279,11 @@  void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4
         EXPAND(1);
         EXPAND(0);
     } else if (draw->format == AV_PIX_FMT_GRAY8 || draw->format == AV_PIX_FMT_GRAY8A ||
-               draw->format == AV_PIX_FMT_GRAY16LE || draw->format == AV_PIX_FMT_YA16LE ||
-               draw->format == AV_PIX_FMT_GRAY9LE  ||
-               draw->format == AV_PIX_FMT_GRAY10LE ||
-               draw->format == AV_PIX_FMT_GRAY12LE ||
-               draw->format == AV_PIX_FMT_GRAY14LE) {
+               draw->format == AV_PIX_FMT_GRAY16 || draw->format == AV_PIX_FMT_YA16 ||
+               draw->format == AV_PIX_FMT_GRAY9  ||
+               draw->format == AV_PIX_FMT_GRAY10 ||
+               draw->format == AV_PIX_FMT_GRAY12 ||
+               draw->format == AV_PIX_FMT_GRAY14) {
         const AVPixFmtDescriptor *desc = draw->desc;
         color->comp[0].u8[0] = RGB_TO_Y_CCIR(rgba[0], rgba[1], rgba[2]);
         EXPAND(0);
@@ -331,11 +342,6 @@  void ff_fill_rectangle(FFDrawContext *draw, FFDrawColor *color,
             return;
         p = p0;
 
-        if (HAVE_BIGENDIAN && draw->desc->comp[0].depth > 8) {
-            for (x = 0; 2*x < draw->pixelstep[plane]; x++)
-                color_tmp.comp[plane].u16[x] = av_bswap16(color_tmp.comp[plane].u16[x]);
-        }
-
         /* copy first line from color */
         for (x = 0; x < wp; x++) {
             memcpy(p, color_tmp.comp[plane].u8, draw->pixelstep[plane]);
@@ -426,19 +432,19 @@  static void blend_line16(uint8_t *dst, unsigned src, unsigned alpha,
 
     if (left) {
         unsigned suba = (left * alpha) >> hsub;
-        uint16_t value = AV_RL16(dst);
-        AV_WL16(dst, (value * (0x10001 - suba) + src * suba) >> 16);
+        uint16_t value = AV_RN16A(dst);
+        AV_WN16A(dst, (value * (0x10001 - suba) + src * suba) >> 16);
         dst += dx;
     }
     for (x = 0; x < w; x++) {
-        uint16_t value = AV_RL16(dst);
-        AV_WL16(dst, (value * tau + asrc) >> 16);
+        uint16_t value = AV_RN16A(dst);
+        AV_WN16A(dst, (value * tau + asrc) >> 16);
         dst += dx;
     }
     if (right) {
         unsigned suba = (right * alpha) >> hsub;
-        uint16_t value = AV_RL16(dst);
-        AV_WL16(dst, (value * (0x10001 - suba) + src * suba) >> 16);
+        uint16_t value = AV_RN16A(dst);
+        AV_WN16A(dst, (value * (0x10001 - suba) + src * suba) >> 16);
     }
 }
 
@@ -531,7 +537,7 @@  static void blend_pixel16(uint8_t *dst, unsigned src, unsigned alpha,
     unsigned xmmod = 7 >> l2depth;
     unsigned mbits = (1 << (1 << l2depth)) - 1;
     unsigned mmult = 255 / mbits;
-    uint16_t value = AV_RL16(dst);
+    uint16_t value = AV_RN16A(dst);
 
     for (y = 0; y < h; y++) {
         xm = xm0;
@@ -543,7 +549,7 @@  static void blend_pixel16(uint8_t *dst, unsigned src, unsigned alpha,
         mask += mask_linesize;
     }
     alpha = (t >> shift) * alpha;
-    AV_WL16(dst, ((0x10001 - alpha) * value + alpha * src) >> 16);
+    AV_WN16A(dst, ((0x10001 - alpha) * value + alpha * src) >> 16);
 }
 
 static void blend_pixel(uint8_t *dst, unsigned src, unsigned alpha,
diff --git a/libavfilter/vf_rotate.c b/libavfilter/vf_rotate.c
index 371ff7f722..0ed8ebff5b 100644
--- a/libavfilter/vf_rotate.c
+++ b/libavfilter/vf_rotate.c
@@ -145,14 +145,14 @@  static int query_formats(AVFilterContext *ctx)
         AV_PIX_FMT_YUV444P,  AV_PIX_FMT_YUVJ444P,
         AV_PIX_FMT_YUV420P,  AV_PIX_FMT_YUVJ420P,
         AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA420P,
-        AV_PIX_FMT_YUV420P10LE, AV_PIX_FMT_YUVA420P10LE,
-        AV_PIX_FMT_YUV444P10LE, AV_PIX_FMT_YUVA444P10LE,
-        AV_PIX_FMT_YUV420P12LE,
-        AV_PIX_FMT_YUV444P12LE,
-        AV_PIX_FMT_YUV444P16LE, AV_PIX_FMT_YUVA444P16LE,
-        AV_PIX_FMT_YUV420P16LE, AV_PIX_FMT_YUVA420P16LE,
-        AV_PIX_FMT_YUV444P9LE, AV_PIX_FMT_YUVA444P9LE,
-        AV_PIX_FMT_YUV420P9LE, AV_PIX_FMT_YUVA420P9LE,
+        AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUVA420P10,
+        AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUVA444P10,
+        AV_PIX_FMT_YUV420P12,
+        AV_PIX_FMT_YUV444P12,
+        AV_PIX_FMT_YUV444P16, AV_PIX_FMT_YUVA444P16,
+        AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUVA420P16,
+        AV_PIX_FMT_YUV444P9, AV_PIX_FMT_YUVA444P9,
+        AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUVA420P9,
         AV_PIX_FMT_NONE
     };
 
@@ -272,14 +272,14 @@  static uint8_t *interpolate_bilinear16(uint8_t *dst_color,
     int int_y1 = FFMIN(int_y+1, max_y);
 
     for (i = 0; i < src_linestep; i+=2) {
-        int s00 = AV_RL16(&src[src_linestep * int_x  + i + src_linesize * int_y ]);
-        int s01 = AV_RL16(&src[src_linestep * int_x1 + i + src_linesize * int_y ]);
-        int s10 = AV_RL16(&src[src_linestep * int_x  + i + src_linesize * int_y1]);
-        int s11 = AV_RL16(&src[src_linestep * int_x1 + i + src_linesize * int_y1]);
+        int s00 = AV_RN16A(&src[src_linestep * int_x  + i + src_linesize * int_y ]);
+        int s01 = AV_RN16A(&src[src_linestep * int_x1 + i + src_linesize * int_y ]);
+        int s10 = AV_RN16A(&src[src_linestep * int_x  + i + src_linesize * int_y1]);
+        int s11 = AV_RN16A(&src[src_linestep * int_x1 + i + src_linesize * int_y1]);
         int s0 = (((1<<16) - frac_x)*s00 + frac_x*s01);
         int s1 = (((1<<16) - frac_x)*s10 + frac_x*s11);
 
-        AV_WL16(&dst_color[i], ((int64_t)((1<<16) - frac_y)*s0 + (int64_t)frac_y*s1) >> 32);
+        AV_WN16A(&dst_color[i], ((int64_t)((1<<16) - frac_y)*s0 + (int64_t)frac_y*s1) >> 32);
     }
 
     return dst_color;
diff --git a/libavfilter/vf_tinterlace.c b/libavfilter/vf_tinterlace.c
index 22746ebfb1..9a579211d3 100644
--- a/libavfilter/vf_tinterlace.c
+++ b/libavfilter/vf_tinterlace.c
@@ -92,12 +92,12 @@  static int query_formats(AVFilterContext *ctx)
         AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P,
         AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P,
         AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P,
-        AV_PIX_FMT_YUV420P10LE, AV_PIX_FMT_YUV422P10LE,
-        AV_PIX_FMT_YUV440P10LE, AV_PIX_FMT_YUV444P10LE,
-        AV_PIX_FMT_YUV420P12LE, AV_PIX_FMT_YUV422P12LE,
-        AV_PIX_FMT_YUV440P12LE, AV_PIX_FMT_YUV444P12LE,
+        AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10,
+        AV_PIX_FMT_YUV440P10, AV_PIX_FMT_YUV444P10,
+        AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV422P12,
+        AV_PIX_FMT_YUV440P12, AV_PIX_FMT_YUV444P12,
         AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P,
-        AV_PIX_FMT_YUVA420P10LE, AV_PIX_FMT_YUVA422P10LE, AV_PIX_FMT_YUVA444P10LE,
+        AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA444P10,
         AV_PIX_FMT_GRAY8, FULL_SCALE_YUVJ_FORMATS,
         AV_PIX_FMT_NONE
     };
@@ -134,9 +134,8 @@  static void lowpass_line_c_16(uint8_t *dst8, ptrdiff_t width, const uint8_t *src
         // this calculation is an integer representation of
         // '0.5 * current + 0.25 * above + 0.25 * below'
         // '1 +' is for rounding.
-        src_x   = av_le2ne16(srcp[i]) << 1;
-        dstp[i] = av_le2ne16((1 + src_x + av_le2ne16(srcp_above[i])
-                             + av_le2ne16(srcp_below[i])) >> 2);
+        src_x   = srcp[i] << 1;
+        dstp[i] = (1 + src_x + srcp_above[i] + srcp_below[i]) >> 2;
     }
 }
 
@@ -181,24 +180,23 @@  static void lowpass_line_complex_c_16(uint8_t *dst8, ptrdiff_t width, const uint
         // this calculation is an integer representation of
         // '0.75 * current + 0.25 * above + 0.25 * below - 0.125 * above2 - 0.125 * below2'
         // '4 +' is for rounding.
-        src_le = av_le2ne16(srcp[i]);
+        src_le = srcp[i];
         src_x  = src_le << 1;
-        src_ab = av_le2ne16(srcp_above[i]) + av_le2ne16(srcp_below[i]);
+        src_ab = srcp_above[i] + srcp_below[i];
         dst_le = av_clip((4 + ((src_le + src_x + src_ab) << 1)
-                         - av_le2ne16(srcp_above2[i])
-                         - av_le2ne16(srcp_below2[i])) >> 3, 0, clip_max);
+                         - srcp_above2[i] - srcp_below2[i]) >> 3, 0, clip_max);
         // Prevent over-sharpening:
         // dst must not exceed src when the average of above and below
         // is less than src. And the other way around.
         if (src_ab > src_x) {
             if (dst_le < src_le)
-                dstp[i] = av_le2ne16(src_le);
+                dstp[i] = src_le;
             else
-                dstp[i] = av_le2ne16(dst_le);
+                dstp[i] = dst_le;
         } else if (dst_le > src_le) {
-            dstp[i] = av_le2ne16(src_le);
+            dstp[i] = src_le;
         } else
-            dstp[i] = av_le2ne16(dst_le);
+            dstp[i] = dst_le;
     }
 }