diff mbox series

[FFmpeg-devel,11/29] avcodec/scpr3: Avoid code duplication when updating models

Message ID 20210218034214.2090223-11-andreas.rheinhardt@gmail.com
State Accepted
Commit 84bb18d4e706882cf6e662b5973fb7ad40457769
Headers show
Series [FFmpeg-devel,01/29] configure, libavcodec/Makefile: Remove spurious CAF demuxer dependencies
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Feb. 18, 2021, 3:41 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/scpr3.c | 24 ++++--------------------
 1 file changed, 4 insertions(+), 20 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/scpr3.c b/libavcodec/scpr3.c
index 1ed764baa1..78c58889cb 100644
--- a/libavcodec/scpr3.c
+++ b/libavcodec/scpr3.c
@@ -524,32 +524,16 @@  static int update_model1_to_4(PixelModel3 *m, uint32_t val)
 
 static int update_model1_to_5(PixelModel3 *m, uint32_t val)
 {
-    PixelModel3 n = {0};
     int i, size, freqs;
     uint32_t a;
 
+    update_model1_to_4(m, val);
     size = m->size;
-    n.size = size;
-    for (i = 0; i < size; i++) {
-        n.symbols[i] = m->symbols[i];
-    }
-    AV_QSORT(n.symbols, size, uint8_t, cmpbytes);
-    size = n.size;
-    for (i = 0; i < size; i++) {
-        if (val == n.symbols[i]) {
-            n.freqs[i] = 100;
-            n.maxpos = i;
-        } else {
-            n.freqs[i] = 50;
-        }
-    }
     a = 256 - size;
     for (i = 0; i < size; i++, a += freqs)
-        freqs = n.freqs[i];
-    n.type = 5;
-    n.cntsum = a;
-
-    memcpy(m, &n, sizeof(n));
+        freqs = m->freqs[i];
+    m->type = 5;
+    m->cntsum = a;
 
     return 0;
 }