diff mbox series

[FFmpeg-devel,40/40] avcodec/h261dec: Make VLC smaller

Message ID 20201229215350.659208-1-andreas.rheinhardt@gmail.com
State Accepted
Commit 9f38fac053010205806ece11e6aea9b7d3bde041
Headers show
Series Make mpegvideo encoders init-threadsafe | expand

Checks

Context Check Description
andriy/configure warning Failed to apply patch

Commit Message

Andreas Rheinhardt Dec. 29, 2020, 9:53 p.m. UTC
The VLC for the macroblock address increment uses nine bits;
yet there is no code with this length: All codes are either shorter or
longer. So one can make the table smaller without changing the amount of
codes that need more than one round of parsing.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/h261dec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Andreas Rheinhardt Jan. 26, 2021, 7:29 p.m. UTC | #1
Andreas Rheinhardt:
> The VLC for the macroblock address increment uses nine bits;
> yet there is no code with this length: All codes are either shorter or
> longer. So one can make the table smaller without changing the amount of
> codes that need more than one round of parsing.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavcodec/h261dec.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
> index 817453f60c..2b3408d7b3 100644
> --- a/libavcodec/h261dec.c
> +++ b/libavcodec/h261dec.c
> @@ -35,7 +35,7 @@
>  #include "h261.h"
>  #include "internal.h"
>  
> -#define H261_MBA_VLC_BITS 9
> +#define H261_MBA_VLC_BITS 8
>  #define H261_MTYPE_VLC_BITS 6
>  #define H261_MV_VLC_BITS 7
>  #define H261_CBP_VLC_BITS 9
> @@ -52,7 +52,7 @@ static av_cold void h261_decode_init_static(void)
>  {
>      INIT_VLC_STATIC(&h261_mba_vlc, H261_MBA_VLC_BITS, 35,
>                      ff_h261_mba_bits, 1, 1,
> -                    ff_h261_mba_code, 1, 1, 662);
> +                    ff_h261_mba_code, 1, 1, 540);
>      INIT_VLC_STATIC(&h261_mtype_vlc, H261_MTYPE_VLC_BITS, 10,
>                      ff_h261_mtype_bits, 1, 1,
>                      ff_h261_mtype_code, 1, 1, 80);
> 
Will apply tomorrow unless there are objections.

- Andreas
diff mbox series

Patch

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 817453f60c..2b3408d7b3 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -35,7 +35,7 @@ 
 #include "h261.h"
 #include "internal.h"
 
-#define H261_MBA_VLC_BITS 9
+#define H261_MBA_VLC_BITS 8
 #define H261_MTYPE_VLC_BITS 6
 #define H261_MV_VLC_BITS 7
 #define H261_CBP_VLC_BITS 9
@@ -52,7 +52,7 @@  static av_cold void h261_decode_init_static(void)
 {
     INIT_VLC_STATIC(&h261_mba_vlc, H261_MBA_VLC_BITS, 35,
                     ff_h261_mba_bits, 1, 1,
-                    ff_h261_mba_code, 1, 1, 662);
+                    ff_h261_mba_code, 1, 1, 540);
     INIT_VLC_STATIC(&h261_mtype_vlc, H261_MTYPE_VLC_BITS, 10,
                     ff_h261_mtype_bits, 1, 1,
                     ff_h261_mtype_code, 1, 1, 80);