[FFmpeg-cvslog] avcodec/vlc: Pass VLC_MULTI_ELEM directly not by pointer
Michael Niedermayer
git at videolan.org
Fri Nov 10 03:44:16 EET 2023
ffmpeg | branch: release/6.1 | Michael Niedermayer <michael at niedermayer.cc> | Sun Oct 22 22:14:47 2023 +0200| [a1d9e282728a5cfc7a22c272a53328dff9367046] | committer: Michael Niedermayer
avcodec/vlc: Pass VLC_MULTI_ELEM directly not by pointer
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>
(cherry picked from commit a5259f326bcaf933a25df64aa49417c25990f7d3)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a1d9e282728a5cfc7a22c272a53328dff9367046
---
libavcodec/vlc.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/libavcodec/vlc.c b/libavcodec/vlc.c
index 9b7a42f79a..4adec2da70 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)
{
int max_symbols = VLC_MULTI_MAX_SYMBOLS >> is16bit;
for (int i = num-1; i >= max; i--) {
@@ -372,16 +372,16 @@ static void add_level(VLC_MULTI_ELEM *table, const int is16bit,
code = curcode + (buf[t].code >> curlen);
newlimit = curlimit - l;
l += curlen;
- if (is16bit) AV_WN16(info->val+2*curlevel, sym);
- else info->val[curlevel] = sym&0xFF;
+ if (is16bit) AV_WN16(info.val+2*curlevel, sym);
+ else info.val[curlevel] = sym&0xFF;
if (curlevel) { // let's not add single entries
uint32_t val = code >> (32 - numbits);
uint32_t nb = val + (1U << (numbits - l));
- info->len = l;
- info->num = curlevel+1;
+ info.len = l;
+ info.num = curlevel+1;
for (; val < nb; val++)
- AV_COPY64(table+val, info);
+ AV_COPY64(table+val, &info);
levelcnt[curlevel-1]++;
}
@@ -435,7 +435,7 @@ static int vlc_multi_gen(VLC_MULTI_ELEM *table, const VLC *single,
}
add_level(table, is16bit, nb_codes, numbits, buf,
- 0, 0, FFMIN(maxbits, numbits), 0, minbits, max, count, &info);
+ 0, 0, FFMIN(maxbits, numbits), 0, minbits, max, count, info);
av_log(logctx, AV_LOG_DEBUG, "Joint: %d/%d/%d/%d/%d codes min=%ubits max=%u\n",
count[0], count[1], count[2], count[3], count[4], minbits, max);
More information about the ffmpeg-cvslog
mailing list