diff mbox series

[FFmpeg-devel,1/2] lavu/pixdesc: remove get_pix_fmt_depth().

Message ID 20210822145409.316517-1-george@nsup.org
State New
Headers show
Series [FFmpeg-devel,1/2] lavu/pixdesc: remove get_pix_fmt_depth(). | 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

Nicolas George Aug. 22, 2021, 2:54 p.m. UTC
Apart from erroring when nb_components == 0, it is dead code.
nb_components == 0 only for HW formats, and HW formats are handled
earlier in get_pix_fmt_score().

Signed-off-by: Nicolas George <george@nsup.org>
---
 libavutil/pixdesc.c | 26 +-------------------------
 1 file changed, 1 insertion(+), 25 deletions(-)


The strange thing is that it was dead code from the start. Maybe I a
missing something.

I will need to make the score function public to let libavfilter use it.
These two patches were low-hanging fruits and make understanding the
logic easier.
diff mbox series

Patch

diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 2346138d04..f1898a6a13 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -2686,24 +2686,6 @@  static int get_color_type(const AVPixFmtDescriptor *desc) {
     return FF_COLOR_YUV;
 }
 
-static int get_pix_fmt_depth(int *min, int *max, enum AVPixelFormat pix_fmt)
-{
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
-    int i;
-
-    if (!desc || !desc->nb_components) {
-        *min = *max = 0;
-        return AVERROR(EINVAL);
-    }
-
-    *min = INT_MAX, *max = -INT_MAX;
-    for (i = 0; i < desc->nb_components; i++) {
-        *min = FFMIN(desc->comp[i].depth, *min);
-        *max = FFMAX(desc->comp[i].depth, *max);
-    }
-    return 0;
-}
-
 static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt,
                               enum AVPixelFormat src_pix_fmt,
                               unsigned *lossp, unsigned consider)
@@ -2711,8 +2693,7 @@  static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt,
     const AVPixFmtDescriptor *src_desc = av_pix_fmt_desc_get(src_pix_fmt);
     const AVPixFmtDescriptor *dst_desc = av_pix_fmt_desc_get(dst_pix_fmt);
     int src_color, dst_color;
-    int src_min_depth, src_max_depth, dst_min_depth, dst_max_depth;
-    int ret, loss, i, nb_components;
+    int loss, i, nb_components;
     int score = INT_MAX - 1;
 
     if (!src_desc || !dst_desc)
@@ -2732,11 +2713,6 @@  static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt,
     if (dst_pix_fmt == src_pix_fmt)
         return INT_MAX;
 
-    if ((ret = get_pix_fmt_depth(&src_min_depth, &src_max_depth, src_pix_fmt)) < 0)
-        return -3;
-    if ((ret = get_pix_fmt_depth(&dst_min_depth, &dst_max_depth, dst_pix_fmt)) < 0)
-        return -3;
-
     src_color = get_color_type(src_desc);
     dst_color = get_color_type(dst_desc);
     if (dst_pix_fmt == AV_PIX_FMT_PAL8)