[FFmpeg-devel] [PATCH 1/2] lavu/pixdesc: remove get_pix_fmt_depth().
Nicolas George
george at nsup.org
Sun Aug 22 17:54:08 EEST 2021
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 at 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 --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)
--
2.32.0
More information about the ffmpeg-devel
mailing list