[FFmpeg-devel] [PATCH 3/8] avcodec/vlc: Add macro for ff_init_vlc_sparse()

Michael Niedermayer michael at niedermayer.cc
Sat Aug 1 21:58:56 EEST 2020


On Fri, Jul 31, 2020 at 01:22:36PM +0200, Andreas Rheinhardt wrote:
> ff_init_vlc_sparse() supports arrays of uint8_t, uint16_t and uint32_t
> as input (and it also supports padding/other elements in between the
> elements). This makes the typical case in which the input is a simple
> array more cumbersome. E.g. for an array of uint8_t one would either
> need to call the function with arguments like "array, sizeof(array[0]),
> sizeof(array[0])" or with "array, 1, 1". The former is nicer, but
> longer, so that the latter is mostly used. Therefore this commit adds a
> macro that expands to the sizeof() construct.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> ---
>  libavcodec/vlc.h | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/vlc.h b/libavcodec/vlc.h
> index 42ccddf3fc..7cb323b62c 100644
> --- a/libavcodec/vlc.h
> +++ b/libavcodec/vlc.h
> @@ -35,7 +35,12 @@ typedef struct RL_VLC_ELEM {
>      uint8_t run;
>  } RL_VLC_ELEM;
>  
> -#define init_vlc(vlc, nb_bits, nb_codes,                \
> +#define INIT_VLC_DEFAULT_SIZES(ptr) \
> +    (ptr), sizeof((ptr)[0]), sizeof((ptr)[0])

LGTM, maybe add some documentation

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20200801/4828d9f6/attachment.sig>


More information about the ffmpeg-devel mailing list