diff mbox series

[FFmpeg-devel,5/7] avcodec/speedhq: Avoid reversing BE codes for LE bitstream reader

Message ID 20201012081217.1643833-5-andreas.rheinhardt@gmail.com
State Accepted
Commit 3977aeb78cb88575171bbbb515520cb01e9bbe15
Headers show
Series [FFmpeg-devel,1/7] avcodec/indeo2: Remove #ifdef BITSTREAM_READER_LE cruft | expand

Checks

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

Commit Message

Andreas Rheinhardt Oct. 12, 2020, 8:12 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/speedhq.c | 41 +++++++++--------------------------------
 1 file changed, 9 insertions(+), 32 deletions(-)

Comments

Paul B Mahol Oct. 12, 2020, 9:42 a.m. UTC | #1
On Mon, Oct 12, 2020 at 10:12:15AM +0200, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavcodec/speedhq.c | 41 +++++++++--------------------------------
>  1 file changed, 9 insertions(+), 32 deletions(-)

lgtm
diff mbox series

Patch

diff --git a/libavcodec/speedhq.c b/libavcodec/speedhq.c
index 5759cdb036..30a6924321 100644
--- a/libavcodec/speedhq.c
+++ b/libavcodec/speedhq.c
@@ -558,40 +558,17 @@  static av_cold void compute_alpha_vlcs(void)
                               level_symbols, 2, 2, 288);
 }
 
-static uint32_t reverse(uint32_t num, int bits)
-{
-    return bitswap_32(num) >> (32 - bits);
-}
-
-static void reverse_code(const uint16_t *code, const uint8_t *bits,
-                         uint16_t *reversed_code, int num_entries)
-{
-    int i;
-    for (i = 0; i < num_entries; i++) {
-        reversed_code[i] = reverse(code[i], bits[i]);
-    }
-}
-
 static av_cold void speedhq_static_init(void)
 {
-    uint16_t ff_mpeg12_vlc_dc_lum_code_reversed[12];
-    uint16_t ff_mpeg12_vlc_dc_chroma_code_reversed[12];
-
-    /* Exactly the same as MPEG-2, except little-endian. */
-    reverse_code(ff_mpeg12_vlc_dc_lum_code,
-                 ff_mpeg12_vlc_dc_lum_bits,
-                 ff_mpeg12_vlc_dc_lum_code_reversed,
-                 12);
-    INIT_LE_VLC_STATIC(&dc_lum_vlc_le, DC_VLC_BITS, 12,
-                       ff_mpeg12_vlc_dc_lum_bits, 1, 1,
-                       ff_mpeg12_vlc_dc_lum_code_reversed, 2, 2, 512);
-    reverse_code(ff_mpeg12_vlc_dc_chroma_code,
-                 ff_mpeg12_vlc_dc_chroma_bits,
-                 ff_mpeg12_vlc_dc_chroma_code_reversed,
-                 12);
-    INIT_LE_VLC_STATIC(&dc_chroma_vlc_le, DC_VLC_BITS, 12,
-                       ff_mpeg12_vlc_dc_chroma_bits, 1, 1,
-                       ff_mpeg12_vlc_dc_chroma_code_reversed, 2, 2, 514);
+    /* Exactly the same as MPEG-2, except for a little-endian reader. */
+    INIT_CUSTOM_VLC_STATIC(&dc_lum_vlc_le, DC_VLC_BITS, 12,
+                           ff_mpeg12_vlc_dc_lum_bits, 1, 1,
+                           ff_mpeg12_vlc_dc_lum_code, 2, 2,
+                           INIT_VLC_OUTPUT_LE, 512);
+    INIT_CUSTOM_VLC_STATIC(&dc_chroma_vlc_le, DC_VLC_BITS, 12,
+                           ff_mpeg12_vlc_dc_chroma_bits, 1, 1,
+                           ff_mpeg12_vlc_dc_chroma_code, 2, 2,
+                           INIT_VLC_OUTPUT_LE, 514);
 
     ff_rl_init(&rl_speedhq, speedhq_static_rl_table_store);
     INIT_2D_VLC_RL(rl_speedhq, 674, INIT_VLC_LE);