diff mbox series

[FFmpeg-devel,v2,1/2] swscale/input: unify grayf32 funcs with rgbf32 funcs

Message ID 20211108022704.812-1-mindmark@gmail.com
State Accepted
Commit 74e49cc583fbc6a0dd06f8f6eb1ba2f5f340d547
Headers show
Series [FFmpeg-devel,v2,1/2] swscale/input: unify grayf32 funcs with rgbf32 funcs | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Mark Reid Nov. 8, 2021, 2:27 a.m. UTC
From: Mark Reid <mindmark@gmail.com>

---
 libswscale/input.c | 36 +++++++++++-------------------------
 1 file changed, 11 insertions(+), 25 deletions(-)

Comments

Michael Niedermayer Nov. 9, 2021, 5:21 p.m. UTC | #1
On Sun, Nov 07, 2021 at 06:27:03PM -0800, mindmark@gmail.com wrote:
> From: Mark Reid <mindmark@gmail.com>
> 
> ---
>  libswscale/input.c | 36 +++++++++++-------------------------
>  1 file changed, 11 insertions(+), 25 deletions(-)

This should be benchmarked with START/STOP_TIMER
same for the other patch

thx

[...]
Mark Reid Nov. 9, 2021, 7:28 p.m. UTC | #2
On Tue, Nov 9, 2021 at 9:21 AM Michael Niedermayer <michael@niedermayer.cc>
wrote:

> On Sun, Nov 07, 2021 at 06:27:03PM -0800, mindmark@gmail.com wrote:
> > From: Mark Reid <mindmark@gmail.com>
> >
> > ---
> >  libswscale/input.c | 36 +++++++++++-------------------------
> >  1 file changed, 11 insertions(+), 25 deletions(-)
>
> This should be benchmarked with START/STOP_TIMER
> same for the other patch
>
> thx
>

good idea, I'll send a new patch


>
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker.
> User
> questions about the command line tools should be sent to the ffmpeg-user
> ML.
> And questions about how to use libav* should be sent to the libav-user ML.
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
diff mbox series

Patch

diff --git a/libswscale/input.c b/libswscale/input.c
index 336f957c8c..90efdd2ffc 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -1013,31 +1013,19 @@  static av_always_inline void planar_rgbf32_to_y(uint8_t *_dst, const uint8_t *_s
     }
 }
 
-#undef rdpx
-
 static av_always_inline void grayf32ToY16_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
-                                            const uint8_t *unused2, int width, uint32_t *unused)
+                                            const uint8_t *unused2, int width, int is_be, uint32_t *unused)
 {
     int i;
     const float *src = (const float *)_src;
     uint16_t *dst    = (uint16_t *)_dst;
 
     for (i = 0; i < width; ++i){
-        dst[i] = av_clip_uint16(lrintf(65535.0f * src[i]));
+        dst[i] = av_clip_uint16(lrintf(65535.0f * rdpx(src + i)));
     }
 }
 
-static av_always_inline void grayf32ToY16_bswap_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
-                                                  const uint8_t *unused2, int width, uint32_t *unused)
-{
-    int i;
-    const uint32_t *src = (const uint32_t *)_src;
-    uint16_t *dst    = (uint16_t *)_dst;
-
-    for (i = 0; i < width; ++i){
-        dst[i] = av_clip_uint16(lrintf(65535.0f * av_int2float(av_bswap32(src[i]))));
-    }
-}
+#undef rdpx
 
 #define rgb9plus_planar_funcs_endian(nbits, endian_name, endian)                                    \
 static void planar_rgb##nbits##endian_name##_to_y(uint8_t *dst, const uint8_t *src[4],              \
@@ -1092,6 +1080,12 @@  static void planar_rgbf32##endian_name##_to_a(uint8_t *dst, const uint8_t *src[4
                                               int w, int32_t *rgb2yuv)                              \
 {                                                                                                   \
     planar_rgbf32_to_a(dst, src, w, endian, rgb2yuv);                                               \
+}                                                                                                   \
+static void grayf32##endian_name##ToY16_c(uint8_t *dst, const uint8_t *src,                         \
+                                          const uint8_t *unused1, const uint8_t *unused2,           \
+                                          int width, uint32_t *unused)                              \
+{                                                                                                   \
+    grayf32ToY16_c(dst, src, unused1, unused2, width, endian, unused);                              \
 }
 
 rgbf32_planar_funcs_endian(le, 0)
@@ -1699,18 +1693,10 @@  av_cold void ff_sws_init_input_funcs(SwsContext *c)
         c->lumToYV12 = p010BEToY_c;
         break;
     case AV_PIX_FMT_GRAYF32LE:
-#if HAVE_BIGENDIAN
-        c->lumToYV12 = grayf32ToY16_bswap_c;
-#else
-        c->lumToYV12 = grayf32ToY16_c;
-#endif
+        c->lumToYV12 = grayf32leToY16_c;
         break;
     case AV_PIX_FMT_GRAYF32BE:
-#if HAVE_BIGENDIAN
-        c->lumToYV12 = grayf32ToY16_c;
-#else
-        c->lumToYV12 = grayf32ToY16_bswap_c;
-#endif
+        c->lumToYV12 = grayf32beToY16_c;
         break;
     case AV_PIX_FMT_Y210LE:
         c->lumToYV12 = y210le_Y_c;