FastLED 3.9.15
Loading...
Searching...
No Matches

◆ plm_video_decode_macroblock()

void fl::third_party::plm_video_decode_macroblock ( plm_video_t * self)

Definition at line 2479 of file pl_mpeg.hpp.

2479 {
2480 // Decode increment
2481 int increment = 0;
2483
2484 while (t == 34) {
2485 // macroblock_stuffing
2487 }
2488 while (t == 35) {
2489 // macroblock_escape
2490 increment += 33;
2492 }
2493 increment += t;
2494
2495 // Process any skipped macroblocks
2496 if (self->slice_begin) {
2497 // The first increment of each slice is relative to beginning of the
2498 // previous row, not the previous macroblock
2499 self->slice_begin = FALSE;
2500 self->macroblock_address += increment;
2501 }
2502 else {
2503 if (self->macroblock_address + increment >= self->mb_size) {
2504 return; // invalid
2505 }
2506 if (increment > 1) {
2507 // Skipped macroblocks reset DC predictors
2508 self->dc_predictor[0] = 128;
2509 self->dc_predictor[1] = 128;
2510 self->dc_predictor[2] = 128;
2511
2512 // Skipped macroblocks in P-pictures reset motion vectors
2514 self->motion_forward.h = 0;
2515 self->motion_forward.v = 0;
2516 }
2517 }
2518
2519 // Predict skipped macroblocks
2520 while (increment > 1) {
2521 self->macroblock_address++;
2522 self->mb_row = self->macroblock_address / self->mb_width;
2523 self->mb_col = self->macroblock_address % self->mb_width;
2524
2526 increment--;
2527 }
2528 self->macroblock_address++;
2529 }
2530
2531 self->mb_row = self->macroblock_address / self->mb_width;
2532 self->mb_col = self->macroblock_address % self->mb_width;
2533
2534 if (self->mb_col >= self->mb_width || self->mb_row >= self->mb_height) {
2535 return; // corrupt stream;
2536 }
2537
2538 // Process the current macroblock
2539 const plm_vlc_t *table = PLM_VIDEO_MACROBLOCK_TYPE[self->picture_type];
2540 self->macroblock_type = plm_buffer_read_vlc(self->buffer, table);
2541
2542 self->macroblock_intra = (self->macroblock_type & 0x01);
2543 self->motion_forward.is_set = (self->macroblock_type & 0x08);
2544 self->motion_backward.is_set = (self->macroblock_type & 0x04);
2545
2546 // Quantizer scale
2547 if ((self->macroblock_type & 0x10) != 0) {
2548 self->quantizer_scale = plm_buffer_read(self->buffer, 5);
2549 }
2550
2551 if (self->macroblock_intra) {
2552 // Intra-coded macroblocks reset motion vectors
2553 self->motion_backward.h = self->motion_forward.h = 0;
2554 self->motion_backward.v = self->motion_forward.v = 0;
2555 }
2556 else {
2557 // Non-intra macroblocks reset DC predictors
2558 self->dc_predictor[0] = 128;
2559 self->dc_predictor[1] = 128;
2560 self->dc_predictor[2] = 128;
2561
2564 }
2565
2566 // Decode blocks
2567 int cbp = ((self->macroblock_type & 0x02) != 0)
2569 : (self->macroblock_intra ? 0x3f : 0);
2570
2571 for (int block = 0, mask = 0x20; block < 6; block++) {
2572 if ((cbp & mask) != 0) {
2573 plm_video_decode_block(self, block);
2574 }
2575 mask >>= 1;
2576 }
2577}
static uint32_t t
Definition Luminova.h:55
static const plm_vlc_t PLM_VIDEO_CODE_BLOCK_PATTERN[]
Definition pl_mpeg.hpp:1780
void plm_video_predict_macroblock(plm_video_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:2628
int plm_buffer_read(plm_buffer_t *self, int count) FL_NOEXCEPT
Definition pl_mpeg.hpp:1017
void plm_video_decode_block(plm_video_t *self, int block) FL_NOEXCEPT
Definition pl_mpeg.hpp:2726
static const plm_vlc_t * PLM_VIDEO_MACROBLOCK_TYPE[]
Definition pl_mpeg.hpp:1773
void plm_video_decode_motion_vectors(plm_video_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:2579
static const plm_vlc_t PLM_VIDEO_MACROBLOCK_ADDRESS_INCREMENT[]
Definition pl_mpeg.hpp:1701
static const int PLM_VIDEO_PICTURE_TYPE_PREDICTIVE
Definition pl_mpeg.hpp:1631
int16_t plm_buffer_read_vlc(plm_buffer_t *self, const plm_vlc_t *table) FL_NOEXCEPT
Definition pl_mpeg.hpp:1111
plm_video_motion_t motion_backward
Definition pl_mpeg.hpp:2064
plm_video_motion_t motion_forward
Definition pl_mpeg.hpp:2063
#define FALSE
Definition pl_mpeg.hpp:175

References FALSE, FL_NOEXCEPT, plm_buffer_read(), plm_buffer_read_vlc(), PLM_VIDEO_CODE_BLOCK_PATTERN, plm_video_decode_block(), plm_video_decode_motion_vectors(), PLM_VIDEO_MACROBLOCK_ADDRESS_INCREMENT, PLM_VIDEO_MACROBLOCK_TYPE, PLM_VIDEO_PICTURE_TYPE_PREDICTIVE, plm_video_predict_macroblock(), and fl::t.

Referenced by plm_video_decode_slice().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: