diff mbox series

[FFmpeg-devel,2/4] avcodec/vp3: Avoid code duplication when initializing coeff_vlcs

Message ID HE1PR0301MB2154FFA376517972FE03094B8F569@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Accepted
Commit 80b5c4bc081b54790688a51791a3da1fcd5a4568
Headers show
Series [FFmpeg-devel,1/4] avcodec/vp3: Don't try to decode VP4 when VP4 decoder is disabled
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 May 8, 2021, 1:27 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/vp3.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index 9aa84e83b7..ef443dbf22 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -2408,6 +2408,8 @@  static av_cold int vp3_decode_init(AVCodecContext *avctx)
     s->fragment_start[2] = y_fragment_count + c_fragment_count;
 
     if (!s->theora_tables) {
+        const uint8_t (*bias_tabs)[32][2];
+
         for (i = 0; i < 64; i++) {
             s->coded_dc_scale_factor[0][i] = s->version < 2 ? vp31_dc_scale_factor[i] : vp4_y_dc_scale_factor[i];
             s->coded_dc_scale_factor[1][i] = s->version < 2 ? vp31_dc_scale_factor[i] : vp4_uv_dc_scale_factor[i];
@@ -2428,27 +2430,15 @@  static av_cold int vp3_decode_init(AVCodecContext *avctx)
         }
 
         /* init VLC tables */
-        if (s->version < 2) {
-            for (i = 0; i < FF_ARRAY_ELEMS(s->coeff_vlc); i++) {
-                ret = ff_init_vlc_from_lengths(&s->coeff_vlc[i], 11, 32,
-                                               &vp3_bias[i][0][1], 2,
-                                               &vp3_bias[i][0][0], 2, 1,
-                                               0, 0, avctx);
-                if (ret < 0)
-                    return ret;
-            }
-#if CONFIG_VP4_DECODER
-        } else { /* version >= 2 */
+        bias_tabs = CONFIG_VP4_DECODER && s->version >= 2 ? vp4_bias : vp3_bias;
             for (i = 0; i < FF_ARRAY_ELEMS(s->coeff_vlc); i++) {
                 ret = ff_init_vlc_from_lengths(&s->coeff_vlc[i], 11, 32,
-                                               &vp4_bias[i][0][1], 2,
-                                               &vp4_bias[i][0][0], 2, 1,
+                                               &bias_tabs[i][0][1], 2,
+                                               &bias_tabs[i][0][0], 2, 1,
                                                0, 0, avctx);
                 if (ret < 0)
                     return ret;
             }
-#endif
-        }
     } else {
         for (i = 0; i < FF_ARRAY_ELEMS(s->coeff_vlc); i++) {
             const HuffTable *tab = &s->huffman_table[i];