summaryrefslogtreecommitdiff
path: root/libavcodec/magicyuv.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-08-31 19:18:03 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-09-01 11:05:38 +0200
commit18dbbff525dd03ed4faefadbe08f5916b9e23666 (patch)
treec155cd70c0e3afd88def65e7cda8cb0c96e4b657 /libavcodec/magicyuv.c
parentd0b0fc7cb94f02a7de0d67cb3ba06a243b323a1d (diff)
downloadffmpeg-18dbbff525dd03ed4faefadbe08f5916b9e23666.tar.gz
avcodec/magicyuv: Unify qsort comparison functions
Up until now, there were three comparison functions depending upon bitness. But they all are actually the same, namely a lexical ordering: entry a > entry b iff a.len > b.len or a.len == b.len and a.sym < b.sym. So they can be easily unified. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/magicyuv.c')
-rw-r--r--libavcodec/magicyuv.c16
1 files changed, 2 insertions, 14 deletions
diff --git a/libavcodec/magicyuv.c b/libavcodec/magicyuv.c
index f630464162..5578374429 100644
--- a/libavcodec/magicyuv.c
+++ b/libavcodec/magicyuv.c
@@ -79,18 +79,6 @@ typedef struct MagicYUVContext {
static int huff_cmp_len(const void *a, const void *b)
{
const HuffEntry *aa = a, *bb = b;
- return (aa->len - bb->len) * 256 + bb->sym - aa->sym;
-}
-
-static int huff_cmp_len10(const void *a, const void *b)
-{
- const HuffEntry *aa = a, *bb = b;
- return (aa->len - bb->len) * 1024 + bb->sym - aa->sym;
-}
-
-static int huff_cmp_len12(const void *a, const void *b)
-{
- const HuffEntry *aa = a, *bb = b;
return (aa->len - bb->len) * 4096 + bb->sym - aa->sym;
}
@@ -106,7 +94,7 @@ static int huff_build10(VLC *vlc, uint8_t *len)
if (len[i] == 0 || len[i] > 32)
return AVERROR_INVALIDDATA;
}
- AV_QSORT(he, 1024, HuffEntry, huff_cmp_len10);
+ AV_QSORT(he, 1024, HuffEntry, huff_cmp_len);
code = 1;
for (i = 1023; i >= 0; i--) {
@@ -133,7 +121,7 @@ static int huff_build12(VLC *vlc, uint8_t *len)
if (len[i] == 0 || len[i] > 32)
return AVERROR_INVALIDDATA;
}
- AV_QSORT(he, 4096, HuffEntry, huff_cmp_len12);
+ AV_QSORT(he, 4096, HuffEntry, huff_cmp_len);
code = 1;
for (i = 4095; i >= 0; i--) {