diff mbox series

[FFmpeg-devel] lavc/h264_cavlc: use inline function get_bits API

Message ID 20200526141351.14348-1-josh@itanimul.li
State New
Headers show
Series [FFmpeg-devel] lavc/h264_cavlc: use inline function get_bits API | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Josh Dekker May 26, 2020, 2:13 p.m. UTC
To prepare for using the cached bitstream reader, which only defines the
inline functions rather than the macros, with CAVLC decoding.

Signed-off-by: Josh de Kock <josh@itanimul.li>
---
 libavcodec/h264_cavlc.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

Comments

Kieran Kunhya May 26, 2020, 3:51 p.m. UTC | #1
On Tue, 26 May 2020 at 15:14, Josh de Kock <josh@itanimul.li> wrote:

> To prepare for using the cached bitstream reader, which only defines the
> inline functions rather than the macros, with CAVLC decoding.
>
> Signed-off-by: Josh de Kock <josh@itanimul.li>


IMO you should provide cached reader benchmarks on real world CAVLC content
before pushing this patch.

Kieran
Michael Niedermayer May 26, 2020, 6:32 p.m. UTC | #2
On Tue, May 26, 2020 at 03:13:51PM +0100, Josh de Kock wrote:
> To prepare for using the cached bitstream reader, which only defines the
> inline functions rather than the macros, with CAVLC decoding.
> 
> Signed-off-by: Josh de Kock <josh@itanimul.li>
> ---
>  libavcodec/h264_cavlc.c | 13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c
> index 6481992e58..c1ecaea1ba 100644
> --- a/libavcodec/h264_cavlc.c
> +++ b/libavcodec/h264_cavlc.c
> @@ -414,19 +414,12 @@ av_cold void ff_h264_decode_init_vlc(void){
>  }
>  
>  static inline int get_level_prefix(GetBitContext *gb){
> -    unsigned int buf;
>      int log;
>  
> -    OPEN_READER(re, gb);
> -    UPDATE_CACHE(re, gb);
> -    buf=GET_CACHE(re, gb);
> +    log = 16 - av_log2_16bit(show_bits(gb, 16));
> +    skip_bits(gb, log);
>  
> -    log= 32 - av_log2(buf);
> -
> -    LAST_SKIP_BITS(re, gb, log);
> -    CLOSE_READER(re, gb);
> -

> -    return log-1;
> +    return log - 1;

this doesnt belong in  here

also how does this compare to all the code being converted to the macros
instead ? (most of the speed critical code is not using them IIRC)

thx

[...]
diff mbox series

Patch

diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c
index 6481992e58..c1ecaea1ba 100644
--- a/libavcodec/h264_cavlc.c
+++ b/libavcodec/h264_cavlc.c
@@ -414,19 +414,12 @@  av_cold void ff_h264_decode_init_vlc(void){
 }
 
 static inline int get_level_prefix(GetBitContext *gb){
-    unsigned int buf;
     int log;
 
-    OPEN_READER(re, gb);
-    UPDATE_CACHE(re, gb);
-    buf=GET_CACHE(re, gb);
+    log = 16 - av_log2_16bit(show_bits(gb, 16));
+    skip_bits(gb, log);
 
-    log= 32 - av_log2(buf);
-
-    LAST_SKIP_BITS(re, gb, log);
-    CLOSE_READER(re, gb);
-
-    return log-1;
+    return log - 1;
 }
 
 /**