[FFmpeg-devel] [PATCH 5/9] avcodec/vlc: Pass VLC_MULTI_ELEM directly not by pointer

Michael Niedermayer michael at niedermayer.cc
Mon Oct 23 19:04:16 EEST 2023


On Mon, Oct 23, 2023 at 02:10:35AM -0400, Leo Izen wrote:
> On 10/22/23 17:51, Michael Niedermayer wrote:
> > This makes the code more testable as uninitialized fields are 0
> > and not random values from the last call
> > 
> > Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> > ---
> >   libavcodec/vlc.c | 14 +++++++-------
> >   1 file changed, 7 insertions(+), 7 deletions(-)
> > 
> > diff --git a/libavcodec/vlc.c b/libavcodec/vlc.c
> > index 9b7a42f79a3..4adec2da705 100644
> > --- a/libavcodec/vlc.c
> > +++ b/libavcodec/vlc.c
> > @@ -356,7 +356,7 @@ static void add_level(VLC_MULTI_ELEM *table, const int is16bit,
> >                         uint32_t curcode, int curlen,
> >                         int curlimit, int curlevel,
> >                         const int minlen, const int max,
> > -                      unsigned* levelcnt, VLC_MULTI_ELEM *info)
> > +                      unsigned* levelcnt, VLC_MULTI_ELEM info)
> 
> 
> Is passing a struct by value advisable? Did you benchmark this? How does it
> compare to memset(info, 0, sizeof(*info))?

The struct is 8 bytes, a pointer on 64bit arch is also 8byte

I did not benchmark, I think this code doesnt run that many iterations
(when its not buggy), I mean each iteration adds a entry to the table
and the table will normally be designed to fit in cache and its only
for initializing.

do you still want me to bechmark this ?

thx

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

If you think the mosad wants you dead since a long time then you are either
wrong or dead since a long time.
-------------- 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/20231023/0509d245/attachment.sig>


More information about the ffmpeg-devel mailing list