History

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

Michael Niedermayer committed 3 years ago

Commit a5259f31 parent 85166091 file · +7 −7Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/vlc.c+7−7
@@ -424,7 +424,7 @@ static void add_level(VLC_MULTI_ELEM *table, const int is16bit, · 423 unmodified lines
424 uint32_t curcode, int curlen,424 uint32_t curcode, int curlen,
425 int curlimit, int curlevel,425 int curlimit, int curlevel,
426 const int minlen, const int max,426 const int minlen, const int max,
427 unsigned* levelcnt, VLC_MULTI_ELEM *info)427 unsigned* levelcnt, VLC_MULTI_ELEM info)
428{428{
429 int max_symbols = VLC_MULTI_MAX_SYMBOLS >> is16bit;429 int max_symbols = VLC_MULTI_MAX_SYMBOLS >> is16bit;
430 for (int i = num-1; i >= max; i--) {430 for (int i = num-1; i >= max; i--) {
@@ -440,16 +440,16 @@ static void add_level(VLC_MULTI_ELEM *table, const int is16bit, · 9 unmodified lines
440 code = curcode + (buf[t].code >> curlen);440 code = curcode + (buf[t].code >> curlen);
441 newlimit = curlimit - l;441 newlimit = curlimit - l;
442 l += curlen;442 l += curlen;
443 if (is16bit) AV_WN16(info->val+2*curlevel, sym);443 if (is16bit) AV_WN16(info.val+2*curlevel, sym);
444 else info->val[curlevel] = sym&0xFF;444 else info.val[curlevel] = sym&0xFF;
445 445
446 if (curlevel) { // let's not add single entries446 if (curlevel) { // let's not add single entries
447 uint32_t val = code >> (32 - numbits);447 uint32_t val = code >> (32 - numbits);
448 uint32_t nb = val + (1U << (numbits - l));448 uint32_t nb = val + (1U << (numbits - l));
449 info->len = l;449 info.len = l;
450 info->num = curlevel+1;450 info.num = curlevel+1;
451 for (; val < nb; val++)451 for (; val < nb; val++)
452 AV_COPY64(table+val, info);452 AV_COPY64(table+val, &info);
453 levelcnt[curlevel-1]++;453 levelcnt[curlevel-1]++;
454 }454 }
455 455
@@ -503,7 +503,7 @@ static int vlc_multi_gen(VLC_MULTI_ELEM *table, const VLC *single, · 47 unmodified lines
503 }503 }
504 504
505 add_level(table, is16bit, nb_codes, numbits, buf,505 add_level(table, is16bit, nb_codes, numbits, buf,
506 0, 0, FFMIN(maxbits, numbits), 0, minbits, max, count, &info);506 0, 0, FFMIN(maxbits, numbits), 0, minbits, max, count, info);
507 507
508 av_log(logctx, AV_LOG_DEBUG, "Joint: %d/%d/%d/%d/%d codes min=%ubits max=%u\n",508 av_log(logctx, AV_LOG_DEBUG, "Joint: %d/%d/%d/%d/%d codes min=%ubits max=%u\n",
509 count[0], count[1], count[2], count[3], count[4], minbits, max);509 count[0], count[1], count[2], count[3], count[4], minbits, max);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t