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

◆ plm_video_decode()

plm_frame_t * fl::third_party::plm_video_decode ( plm_video_t * self)

Definition at line 2197 of file pl_mpeg.hpp.

2197 {
2198 if (!plm_video_has_header(self)) {
2199 return NULL;
2200 }
2201
2202 plm_frame_t *frame = NULL;
2203 do {
2204 if (self->start_code != PLM_START_PICTURE) {
2206
2207 if (self->start_code == -1) {
2208 // If we reached the end of the file and the previously decoded
2209 // frame was a reference frame, we still have to return it.
2210 if (
2211 self->has_reference_frame &&
2212 !self->assume_no_b_frames &&
2213 plm_buffer_has_ended(self->buffer) && (
2216 )
2217 ) {
2218 self->has_reference_frame = FALSE;
2219 frame = &self->frame_backward;
2220 break;
2221 }
2222
2223 return NULL;
2224 }
2225 }
2226
2227 // Make sure we have a full picture in the buffer before attempting to
2228 // decode it. Sadly, this can only be done by seeking for the start code
2229 // of the next picture. Also, if we didn't find the start code for the
2230 // next picture, but the source has ended, we assume that this last
2231 // picture is in the buffer.
2232 if (
2235 ) {
2236 return NULL;
2237 }
2239
2241
2242 if (self->assume_no_b_frames) {
2243 frame = &self->frame_backward;
2244 }
2245 else if (self->picture_type == PLM_VIDEO_PICTURE_TYPE_B) {
2246 frame = &self->frame_current;
2247 }
2248 else if (self->has_reference_frame) {
2249 frame = &self->frame_forward;
2250 }
2251 else {
2252 self->has_reference_frame = TRUE;
2253 }
2254 } while (!frame);
2255
2256 frame->time = self->time;
2257 self->frames_decoded++;
2258 self->time = (double)self->frames_decoded / self->framerate;
2259
2260 return frame;
2261}
#define NULL
void plm_buffer_discard_read_bytes(plm_buffer_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:951
void plm_video_decode_picture(plm_video_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:2382
int plm_buffer_has_ended(plm_buffer_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:994
static const int PLM_VIDEO_PICTURE_TYPE_B
Definition pl_mpeg.hpp:1632
static const int PLM_VIDEO_PICTURE_TYPE_PREDICTIVE
Definition pl_mpeg.hpp:1631
int plm_buffer_find_start_code(plm_buffer_t *self, int code) FL_NOEXCEPT
Definition pl_mpeg.hpp:1078
int plm_buffer_has_start_code(plm_buffer_t *self, int code) FL_NOEXCEPT
Definition pl_mpeg.hpp:1089
static const int PLM_VIDEO_PICTURE_TYPE_INTRA
Definition pl_mpeg.hpp:1630
static const int PLM_START_PICTURE
Definition pl_mpeg.hpp:1637
int plm_video_has_header(plm_video_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:2263
#define TRUE
Definition pl_mpeg.hpp:174
#define FALSE
Definition pl_mpeg.hpp:175

References FALSE, FL_NOEXCEPT, NULL, plm_buffer_discard_read_bytes(), plm_buffer_find_start_code(), plm_buffer_has_ended(), plm_buffer_has_start_code(), PLM_START_PICTURE, plm_video_decode_picture(), plm_video_has_header(), PLM_VIDEO_PICTURE_TYPE_B, PLM_VIDEO_PICTURE_TYPE_INTRA, PLM_VIDEO_PICTURE_TYPE_PREDICTIVE, fl::third_party::plm_frame_t::time, and TRUE.

Referenced by plm_decode(), plm_decode_video(), and plm_seek_frame().

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