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

◆ plm_video_decode_sequence_header()

int fl::third_party::plm_video_decode_sequence_header ( plm_video_t * self)

Definition at line 2282 of file pl_mpeg.hpp.

2282 {
2283 int max_header_size = 64 + 2 * 64 * 8; // 64 bit header + 2x 64 byte matrix
2284 if (!plm_buffer_has(self->buffer, max_header_size)) {
2285 return FALSE;
2286 }
2287
2288 self->width = plm_buffer_read(self->buffer, 12);
2289 self->height = plm_buffer_read(self->buffer, 12);
2290
2291 if (self->width <= 0 || self->height <= 0) {
2292 return FALSE;
2293 }
2294
2295 // Get pixel aspect ratio
2296 int pixel_aspect_ratio_code;
2297 pixel_aspect_ratio_code = plm_buffer_read(self->buffer, 4);
2298 pixel_aspect_ratio_code -= 1;
2299 if (pixel_aspect_ratio_code < 0) {
2300 pixel_aspect_ratio_code = 0;
2301 }
2302 int par_last = (sizeof(PLM_VIDEO_PIXEL_ASPECT_RATIO) /
2303 sizeof(PLM_VIDEO_PIXEL_ASPECT_RATIO[0]) - 1);
2304 if (pixel_aspect_ratio_code > par_last) {
2305 pixel_aspect_ratio_code = par_last;
2306 }
2307 self->pixel_aspect_ratio =
2308 PLM_VIDEO_PIXEL_ASPECT_RATIO[pixel_aspect_ratio_code];
2309
2310 // Get frame rate
2312
2313 // Skip bit_rate, marker, buffer_size and constrained bit
2314 plm_buffer_skip(self->buffer, 18 + 1 + 10 + 1);
2315
2316 // Load custom intra quant matrix?
2317 if (plm_buffer_read(self->buffer, 1)) {
2318 for (int i = 0; i < 64; i++) {
2319 int idx = PLM_VIDEO_ZIG_ZAG[i];
2320 self->intra_quant_matrix[idx] = plm_buffer_read(self->buffer, 8);
2321 }
2322 }
2323 else {
2325 }
2326
2327 // Load custom non intra quant matrix?
2328 if (plm_buffer_read(self->buffer, 1)) {
2329 for (int i = 0; i < 64; i++) {
2330 int idx = PLM_VIDEO_ZIG_ZAG[i];
2331 self->non_intra_quant_matrix[idx] = plm_buffer_read(self->buffer, 8);
2332 }
2333 }
2334 else {
2336 }
2337
2338 self->mb_width = (self->width + 15) >> 4;
2339 self->mb_height = (self->height + 15) >> 4;
2340 self->mb_size = self->mb_width * self->mb_height;
2341
2342 self->luma_width = self->mb_width << 4;
2343 self->luma_height = self->mb_height << 4;
2344
2345 self->chroma_width = self->mb_width << 3;
2346 self->chroma_height = self->mb_height << 3;
2347
2348
2349 // Allocate one big chunk of data for all 3 frames = 9 planes
2350 size_t luma_plane_size = self->luma_width * self->luma_height;
2351 size_t chroma_plane_size = self->chroma_width * self->chroma_height;
2352 size_t frame_data_size = (luma_plane_size + 2 * chroma_plane_size);
2353
2354 self->frames_data = (uint8_t*)PLM_MALLOC(frame_data_size * 3);
2355 plm_video_init_frame(self, &self->frame_current, self->frames_data + frame_data_size * 0);
2356 plm_video_init_frame(self, &self->frame_forward, self->frames_data + frame_data_size * 1);
2357 plm_video_init_frame(self, &self->frame_backward, self->frames_data + frame_data_size * 2);
2358
2359 self->has_sequence_header = TRUE;
2360 return TRUE;
2361}
static const float PLM_VIDEO_PIXEL_ASPECT_RATIO[]
Definition pl_mpeg.hpp:1644
void plm_video_init_frame(plm_video_t *self, plm_frame_t *frame, uint8_t *base) FL_NOEXCEPT
Definition pl_mpeg.hpp:2363
int plm_buffer_read(plm_buffer_t *self, int count) FL_NOEXCEPT
Definition pl_mpeg.hpp:1017
static const uint8_t PLM_VIDEO_NON_INTRA_QUANT_MATRIX[]
Definition pl_mpeg.hpp:1679
int plm_buffer_has(plm_buffer_t *self, size_t count) FL_NOEXCEPT
Definition pl_mpeg.hpp:998
static const double PLM_VIDEO_PICTURE_RATE[]
Definition pl_mpeg.hpp:1652
static const uint8_t PLM_VIDEO_ZIG_ZAG[]
Definition pl_mpeg.hpp:1657
unsigned char uint8_t
Definition coder.h:209
void plm_buffer_skip(plm_buffer_t *self, size_t count) FL_NOEXCEPT
Definition pl_mpeg.hpp:1044
static const uint8_t PLM_VIDEO_INTRA_QUANT_MATRIX[]
Definition pl_mpeg.hpp:1668
void * memcopy(void *dest, const void *src, size_t n) FL_NOEXCEPT
Definition cstring.h:103
#define PLM_MALLOC(sz)
Definition pl_mpeg.hpp:179
#define TRUE
Definition pl_mpeg.hpp:174
#define FALSE
Definition pl_mpeg.hpp:175

References FALSE, FL_NOEXCEPT, fl::memcopy(), plm_buffer_has(), plm_buffer_read(), plm_buffer_skip(), PLM_MALLOC, plm_video_init_frame(), PLM_VIDEO_INTRA_QUANT_MATRIX, PLM_VIDEO_NON_INTRA_QUANT_MATRIX, PLM_VIDEO_PICTURE_RATE, PLM_VIDEO_PIXEL_ASPECT_RATIO, PLM_VIDEO_ZIG_ZAG, and TRUE.

Referenced by plm_video_create_with_buffer(), and plm_video_has_header().

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