diff mbox

[FFmpeg-devel,v2,4/5] avfilter/vf_lut3d: simplify code

Message ID 20191030132056.21150-4-lance.lmwang@gmail.com
State Accepted
Commit 99fc5059fbee8a0fd2957f958b34fdec1e9ca361
Headers show

Commit Message

Lance Wang Oct. 30, 2019, 1:20 p.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavfilter/vf_lut3d.c | 54 +++++-------------------------------------
 1 file changed, 6 insertions(+), 48 deletions(-)

Comments

Paul B Mahol Oct. 30, 2019, 2:34 p.m. UTC | #1
lgtm

On 10/30/19, lance.lmwang@gmail.com <lance.lmwang@gmail.com> wrote:
> From: Limin Wang <lance.lmwang@gmail.com>
>
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavfilter/vf_lut3d.c | 54 +++++-------------------------------------
>  1 file changed, 6 insertions(+), 48 deletions(-)
>
> diff --git a/libavfilter/vf_lut3d.c b/libavfilter/vf_lut3d.c
> index cd0aba1f69..9e820a17c9 100644
> --- a/libavfilter/vf_lut3d.c
> +++ b/libavfilter/vf_lut3d.c
> @@ -711,34 +711,13 @@ static int query_formats(AVFilterContext *ctx)
>
>  static int config_input(AVFilterLink *inlink)
>  {
> -    int depth, is16bit = 0, planar = 0;
> +    int depth, is16bit, planar;
>      LUT3DContext *lut3d = inlink->dst->priv;
>      const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
>
>      depth = desc->comp[0].depth;
> -
> -    switch (inlink->format) {
> -    case AV_PIX_FMT_RGB48:
> -    case AV_PIX_FMT_BGR48:
> -    case AV_PIX_FMT_RGBA64:
> -    case AV_PIX_FMT_BGRA64:
> -        is16bit = 1;
> -        break;
> -    case AV_PIX_FMT_GBRP9:
> -    case AV_PIX_FMT_GBRP10:
> -    case AV_PIX_FMT_GBRP12:
> -    case AV_PIX_FMT_GBRP14:
> -    case AV_PIX_FMT_GBRP16:
> -    case AV_PIX_FMT_GBRAP10:
> -    case AV_PIX_FMT_GBRAP12:
> -    case AV_PIX_FMT_GBRAP16:
> -        is16bit = 1;
> -    case AV_PIX_FMT_GBRP:
> -    case AV_PIX_FMT_GBRAP:
> -        planar = 1;
> -        break;
> -    }
> -
> +    is16bit = desc->comp[0].depth > 8;
> +    planar = desc->flags & AV_PIX_FMT_FLAG_PLANAR;
>      ff_fill_rgba_map(lut3d->rgba_map, inlink->format);
>      lut3d->step = av_get_padded_bits_per_pixel(desc) >> (3 + is16bit);
>
> @@ -1558,34 +1537,13 @@ DEFINE_INTERP_FUNC_1D(spline,      16)
>
>  static int config_input_1d(AVFilterLink *inlink)
>  {
> -    int depth, is16bit = 0, planar = 0;
> +    int depth, is16bit, planar;
>      LUT1DContext *lut1d = inlink->dst->priv;
>      const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
>
>      depth = desc->comp[0].depth;
> -
> -    switch (inlink->format) {
> -    case AV_PIX_FMT_RGB48:
> -    case AV_PIX_FMT_BGR48:
> -    case AV_PIX_FMT_RGBA64:
> -    case AV_PIX_FMT_BGRA64:
> -        is16bit = 1;
> -        break;
> -    case AV_PIX_FMT_GBRP9:
> -    case AV_PIX_FMT_GBRP10:
> -    case AV_PIX_FMT_GBRP12:
> -    case AV_PIX_FMT_GBRP14:
> -    case AV_PIX_FMT_GBRP16:
> -    case AV_PIX_FMT_GBRAP10:
> -    case AV_PIX_FMT_GBRAP12:
> -    case AV_PIX_FMT_GBRAP16:
> -        is16bit = 1;
> -    case AV_PIX_FMT_GBRP:
> -    case AV_PIX_FMT_GBRAP:
> -        planar = 1;
> -        break;
> -    }
> -
> +    is16bit = desc->comp[0].depth > 8;
> +    planar = desc->flags & AV_PIX_FMT_FLAG_PLANAR;
>      ff_fill_rgba_map(lut1d->rgba_map, inlink->format);
>      lut1d->step = av_get_padded_bits_per_pixel(desc) >> (3 + is16bit);
>
> --
> 2.21.0
>
> _______________________________________________
> 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".
Michael Niedermayer Nov. 1, 2019, 6:48 p.m. UTC | #2
On Wed, Oct 30, 2019 at 03:34:59PM +0100, Paul B Mahol wrote:
> lgtm

will apply

thx

[...]
diff mbox

Patch

diff --git a/libavfilter/vf_lut3d.c b/libavfilter/vf_lut3d.c
index cd0aba1f69..9e820a17c9 100644
--- a/libavfilter/vf_lut3d.c
+++ b/libavfilter/vf_lut3d.c
@@ -711,34 +711,13 @@  static int query_formats(AVFilterContext *ctx)
 
 static int config_input(AVFilterLink *inlink)
 {
-    int depth, is16bit = 0, planar = 0;
+    int depth, is16bit, planar;
     LUT3DContext *lut3d = inlink->dst->priv;
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
 
     depth = desc->comp[0].depth;
-
-    switch (inlink->format) {
-    case AV_PIX_FMT_RGB48:
-    case AV_PIX_FMT_BGR48:
-    case AV_PIX_FMT_RGBA64:
-    case AV_PIX_FMT_BGRA64:
-        is16bit = 1;
-        break;
-    case AV_PIX_FMT_GBRP9:
-    case AV_PIX_FMT_GBRP10:
-    case AV_PIX_FMT_GBRP12:
-    case AV_PIX_FMT_GBRP14:
-    case AV_PIX_FMT_GBRP16:
-    case AV_PIX_FMT_GBRAP10:
-    case AV_PIX_FMT_GBRAP12:
-    case AV_PIX_FMT_GBRAP16:
-        is16bit = 1;
-    case AV_PIX_FMT_GBRP:
-    case AV_PIX_FMT_GBRAP:
-        planar = 1;
-        break;
-    }
-
+    is16bit = desc->comp[0].depth > 8;
+    planar = desc->flags & AV_PIX_FMT_FLAG_PLANAR;
     ff_fill_rgba_map(lut3d->rgba_map, inlink->format);
     lut3d->step = av_get_padded_bits_per_pixel(desc) >> (3 + is16bit);
 
@@ -1558,34 +1537,13 @@  DEFINE_INTERP_FUNC_1D(spline,      16)
 
 static int config_input_1d(AVFilterLink *inlink)
 {
-    int depth, is16bit = 0, planar = 0;
+    int depth, is16bit, planar;
     LUT1DContext *lut1d = inlink->dst->priv;
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
 
     depth = desc->comp[0].depth;
-
-    switch (inlink->format) {
-    case AV_PIX_FMT_RGB48:
-    case AV_PIX_FMT_BGR48:
-    case AV_PIX_FMT_RGBA64:
-    case AV_PIX_FMT_BGRA64:
-        is16bit = 1;
-        break;
-    case AV_PIX_FMT_GBRP9:
-    case AV_PIX_FMT_GBRP10:
-    case AV_PIX_FMT_GBRP12:
-    case AV_PIX_FMT_GBRP14:
-    case AV_PIX_FMT_GBRP16:
-    case AV_PIX_FMT_GBRAP10:
-    case AV_PIX_FMT_GBRAP12:
-    case AV_PIX_FMT_GBRAP16:
-        is16bit = 1;
-    case AV_PIX_FMT_GBRP:
-    case AV_PIX_FMT_GBRAP:
-        planar = 1;
-        break;
-    }
-
+    is16bit = desc->comp[0].depth > 8;
+    planar = desc->flags & AV_PIX_FMT_FLAG_PLANAR;
     ff_fill_rgba_map(lut1d->rgba_map, inlink->format);
     lut1d->step = av_get_padded_bits_per_pixel(desc) >> (3 + is16bit);