diff mbox

[FFmpeg-devel,v1,3/5] avcodec/v210enc: define DEFINE_V210_PLANAR_FUNC to remove duplicate function

Message ID 1567007116-9088-4-git-send-email-lance.lmwang@gmail.com
State New
Headers show

Commit Message

Lance Wang Aug. 28, 2019, 3:45 p.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavcodec/v210enc.c | 43 ++++++++++++++++---------------------------
 1 file changed, 16 insertions(+), 27 deletions(-)

Comments

Michael Niedermayer Aug. 30, 2019, 6:16 p.m. UTC | #1
On Wed, Aug 28, 2019 at 11:45:14PM +0800, lance.lmwang@gmail.com wrote:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavcodec/v210enc.c | 43 ++++++++++++++++---------------------------
>  1 file changed, 16 insertions(+), 27 deletions(-)
> 
> diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c
> index 69a2efe..716544a 100644
> --- a/libavcodec/v210enc.c
> +++ b/libavcodec/v210enc.c
> @@ -36,35 +36,24 @@
>          dst += 4;                                         \
>      } while (0)
>  
> -static void v210_planar_pack_8_c(const uint8_t *y, const uint8_t *u,
> -                                 const uint8_t *v, uint8_t *dst,
> -                                 ptrdiff_t width)
> -{
> -    uint32_t val;
> -    int i;
> -
> -    for (i = 0; i < width - 5; i += 6) {
> -        WRITE_PIXELS(u, y, v, 8);
> -        WRITE_PIXELS(y, u, y, 8);
> -        WRITE_PIXELS(v, y, u, 8);
> -        WRITE_PIXELS(y, v, y, 8);
> -    }
> +#define DEFINE_V210_PLANAR_FUNC(nbits, depth)                        \
> +static void v210_planar_pack_##depth##_c(const uint##nbits##_t *y,   \
> +                const uint##nbits##_t *u, const uint##nbits##_t *v,  \
> +                uint8_t *dst, ptrdiff_t width)                       \
> +{                                                                    \
> +    uint32_t val;                                                    \
> +    int i;                                                           \
> +                                                                     \
> +    for (i = 0; i < width - 5; i += 6) {                             \
> +        WRITE_PIXELS(u, y, v, depth);                                \
> +        WRITE_PIXELS(y, u, y, depth);                                \
> +        WRITE_PIXELS(v, y, u, depth);                                \
> +        WRITE_PIXELS(y, v, y, depth);                                \
> +    }                                                                \
>  }
>  
> -static void v210_planar_pack_10_c(const uint16_t *y, const uint16_t *u,
> -                                  const uint16_t *v, uint8_t *dst,
> -                                  ptrdiff_t width)
> -{
> -    uint32_t val;
> -    int i;
> -
> -    for (i = 0; i < width - 5; i += 6) {
> -        WRITE_PIXELS(u, y, v, 10);
> -        WRITE_PIXELS(y, u, y, 10);
> -        WRITE_PIXELS(v, y, u, 10);
> -        WRITE_PIXELS(y, v, y, 10);
> -    }
> -}
> +DEFINE_V210_PLANAR_FUNC(8, 8);
> +DEFINE_V210_PLANAR_FUNC(16, 10);

same as with the other per depth functions, i think this might be cleaner
in a seperate "template" file

thx

[...]
Lance Wang Aug. 31, 2019, 7:27 a.m. UTC | #2
On Fri, Aug 30, 2019 at 08:16:31PM +0200, Michael Niedermayer wrote:
> On Wed, Aug 28, 2019 at 11:45:14PM +0800, lance.lmwang@gmail.com wrote:
> > From: Limin Wang <lance.lmwang@gmail.com>
> > 
> > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > ---
> >  libavcodec/v210enc.c | 43 ++++++++++++++++---------------------------
> >  1 file changed, 16 insertions(+), 27 deletions(-)
> > 
> > diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c
> > index 69a2efe..716544a 100644
> > --- a/libavcodec/v210enc.c
> > +++ b/libavcodec/v210enc.c
> > @@ -36,35 +36,24 @@
> >          dst += 4;                                         \
> >      } while (0)
> >  
> > -static void v210_planar_pack_8_c(const uint8_t *y, const uint8_t *u,
> > -                                 const uint8_t *v, uint8_t *dst,
> > -                                 ptrdiff_t width)
> > -{
> > -    uint32_t val;
> > -    int i;
> > -
> > -    for (i = 0; i < width - 5; i += 6) {
> > -        WRITE_PIXELS(u, y, v, 8);
> > -        WRITE_PIXELS(y, u, y, 8);
> > -        WRITE_PIXELS(v, y, u, 8);
> > -        WRITE_PIXELS(y, v, y, 8);
> > -    }
> > +#define DEFINE_V210_PLANAR_FUNC(nbits, depth)                        \
> > +static void v210_planar_pack_##depth##_c(const uint##nbits##_t *y,   \
> > +                const uint##nbits##_t *u, const uint##nbits##_t *v,  \
> > +                uint8_t *dst, ptrdiff_t width)                       \
> > +{                                                                    \
> > +    uint32_t val;                                                    \
> > +    int i;                                                           \
> > +                                                                     \
> > +    for (i = 0; i < width - 5; i += 6) {                             \
> > +        WRITE_PIXELS(u, y, v, depth);                                \
> > +        WRITE_PIXELS(y, u, y, depth);                                \
> > +        WRITE_PIXELS(v, y, u, depth);                                \
> > +        WRITE_PIXELS(y, v, y, depth);                                \
> > +    }                                                                \
> >  }
> >  
> > -static void v210_planar_pack_10_c(const uint16_t *y, const uint16_t *u,
> > -                                  const uint16_t *v, uint8_t *dst,
> > -                                  ptrdiff_t width)
> > -{
> > -    uint32_t val;
> > -    int i;
> > -
> > -    for (i = 0; i < width - 5; i += 6) {
> > -        WRITE_PIXELS(u, y, v, 10);
> > -        WRITE_PIXELS(y, u, y, 10);
> > -        WRITE_PIXELS(v, y, u, 10);
> > -        WRITE_PIXELS(y, v, y, 10);
> > -    }
> > -}
> > +DEFINE_V210_PLANAR_FUNC(8, 8);
> > +DEFINE_V210_PLANAR_FUNC(16, 10);
> 
> same as with the other per depth functions, i think this might be cleaner
> in a seperate "template" file
> 
OK, I'll update it also.


> thx
> 
> [...]
> 
> -- 
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> The worst form of inequality is to try to make unequal things equal.
> -- Aristotle



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

Patch

diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c
index 69a2efe..716544a 100644
--- a/libavcodec/v210enc.c
+++ b/libavcodec/v210enc.c
@@ -36,35 +36,24 @@ 
         dst += 4;                                         \
     } while (0)
 
-static void v210_planar_pack_8_c(const uint8_t *y, const uint8_t *u,
-                                 const uint8_t *v, uint8_t *dst,
-                                 ptrdiff_t width)
-{
-    uint32_t val;
-    int i;
-
-    for (i = 0; i < width - 5; i += 6) {
-        WRITE_PIXELS(u, y, v, 8);
-        WRITE_PIXELS(y, u, y, 8);
-        WRITE_PIXELS(v, y, u, 8);
-        WRITE_PIXELS(y, v, y, 8);
-    }
+#define DEFINE_V210_PLANAR_FUNC(nbits, depth)                        \
+static void v210_planar_pack_##depth##_c(const uint##nbits##_t *y,   \
+                const uint##nbits##_t *u, const uint##nbits##_t *v,  \
+                uint8_t *dst, ptrdiff_t width)                       \
+{                                                                    \
+    uint32_t val;                                                    \
+    int i;                                                           \
+                                                                     \
+    for (i = 0; i < width - 5; i += 6) {                             \
+        WRITE_PIXELS(u, y, v, depth);                                \
+        WRITE_PIXELS(y, u, y, depth);                                \
+        WRITE_PIXELS(v, y, u, depth);                                \
+        WRITE_PIXELS(y, v, y, depth);                                \
+    }                                                                \
 }
 
-static void v210_planar_pack_10_c(const uint16_t *y, const uint16_t *u,
-                                  const uint16_t *v, uint8_t *dst,
-                                  ptrdiff_t width)
-{
-    uint32_t val;
-    int i;
-
-    for (i = 0; i < width - 5; i += 6) {
-        WRITE_PIXELS(u, y, v, 10);
-        WRITE_PIXELS(y, u, y, 10);
-        WRITE_PIXELS(v, y, u, 10);
-        WRITE_PIXELS(y, v, y, 10);
-    }
-}
+DEFINE_V210_PLANAR_FUNC(8, 8);
+DEFINE_V210_PLANAR_FUNC(16, 10);
 
 av_cold void ff_v210enc_init(V210EncContext *s)
 {