MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / dv_decode_ac

Function dv_decode_ac

libavcodec/dv.c:384–443  ·  view source on GitHub ↗

decode ac coefficients */

Source from the content-addressed store, hash-verified

382
383/* decode ac coefficients */
384static void dv_decode_ac(GetBitContext *gb, BlockInfo *mb, DCTELEM *block)
385{
386 int last_index = gb->size_in_bits;
387 const uint8_t *scan_table = mb->scan_table;
388 const uint32_t *factor_table = mb->factor_table;
389 int pos = mb->pos;
390 int partial_bit_count = mb->partial_bit_count;
391 int level, run, vlc_len, index;
392
393 OPEN_READER(re, gb);
394 UPDATE_CACHE(re, gb);
395
396 /* if we must parse a partial vlc, we do it here */
397 if (partial_bit_count > 0) {
398 re_cache = ((unsigned)re_cache >> partial_bit_count) |
399 (mb->partial_bit_buffer << (sizeof(re_cache) * 8 - partial_bit_count));
400 re_index -= partial_bit_count;
401 mb->partial_bit_count = 0;
402 }
403
404 /* get the AC coefficients until last_index is reached */
405 for (;;) {
406#ifdef VLC_DEBUG
407 printf("%2d: bits=%04x index=%d\n", pos, SHOW_UBITS(re, gb, 16), re_index);
408#endif
409 /* our own optimized GET_RL_VLC */
410 index = NEG_USR32(re_cache, TEX_VLC_BITS);
411 vlc_len = dv_rl_vlc[index].len;
412 if (vlc_len < 0) {
413 index = NEG_USR32((unsigned)re_cache << TEX_VLC_BITS, -vlc_len) + dv_rl_vlc[index].level;
414 vlc_len = TEX_VLC_BITS - vlc_len;
415 }
416 level = dv_rl_vlc[index].level;
417 run = dv_rl_vlc[index].run;
418
419 /* gotta check if we're still within gb boundaries */
420 if (re_index + vlc_len > last_index) {
421 /* should be < 16 bits otherwise a codeword could have been parsed */
422 mb->partial_bit_count = last_index - re_index;
423 mb->partial_bit_buffer = NEG_USR32(re_cache, mb->partial_bit_count);
424 re_index = last_index;
425 break;
426 }
427 re_index += vlc_len;
428
429#ifdef VLC_DEBUG
430 printf("run=%d level=%d\n", run, level);
431#endif
432 pos += run;
433 if (pos >= 64)
434 break;
435
436 level = (level * factor_table[pos] + (1 << (dv_iweight_bits - 1))) >> dv_iweight_bits;
437 block[scan_table[pos]] = level;
438
439 UPDATE_CACHE(re, gb);
440 }
441 CLOSE_READER(re, gb);

Callers 1

dv_decode_video_segmentFunction · 0.85

Calls 1

NEG_USR32Function · 0.85

Tested by

no test coverage detected