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

◆ plm_seek_frame()

plm_frame_t * fl::third_party::plm_seek_frame ( plm_t * self,
double time,
int seek_exact )

Definition at line 617 of file pl_mpeg.hpp.

617 {
618 if (!plm_init_decoders(self)) {
619 return NULL;
620 }
621
622 if (!self->video_packet_type) {
623 return NULL;
624 }
625
626 int type = self->video_packet_type;
627
628 double start_time = plm_demux_get_start_time(self->demux, type);
629 double duration = plm_demux_get_duration(self->demux, type);
630
631 if (time < 0) {
632 time = 0;
633 }
634 else if (time > duration) {
635 time = duration;
636 }
637
638 plm_packet_t *packet = plm_demux_seek(self->demux, time, type, TRUE);
639 if (!packet) {
640 return NULL;
641 }
642
643 // Disable writing to the audio buffer while decoding video
644 int previous_audio_packet_type = self->audio_packet_type;
645 self->audio_packet_type = 0;
646
647 // Clear video buffer and decode the found packet
649 plm_video_set_time(self->video_decoder, packet->pts - start_time);
650 plm_buffer_write(self->video_buffer, packet->data, packet->length);
652
653 // If we want to seek to an exact frame, we have to decode all frames
654 // on top of the intra frame we just jumped to.
655 if (seek_exact) {
656 while (frame && frame->time < time) {
657 frame = plm_video_decode(self->video_decoder);
658 }
659 }
660
661 // Enable writing to the audio buffer again?
662 self->audio_packet_type = previous_audio_packet_type;
663
664 if (frame) {
665 self->time = frame->time;
666 }
667
668 self->has_ended = FALSE;
669 return frame;
670}
#define NULL
plm_packet_t * plm_demux_seek(plm_demux_t *self, double time, int type, int force_intra) FL_NOEXCEPT
Definition pl_mpeg.hpp:1374
void plm_video_rewind(plm_video_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:2185
double plm_demux_get_duration(plm_demux_t *self, int type) FL_NOEXCEPT
Definition pl_mpeg.hpp:1329
double plm_demux_get_start_time(plm_demux_t *self, int type) FL_NOEXCEPT
Definition pl_mpeg.hpp:1304
void plm_video_set_time(plm_video_t *self, double time) FL_NOEXCEPT
Definition pl_mpeg.hpp:2180
int plm_init_decoders(plm_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:261
size_t plm_buffer_write(plm_buffer_t *self, uint8_t *bytes, size_t length) FL_NOEXCEPT
Definition pl_mpeg.hpp:877
plm_frame_t * plm_video_decode(plm_video_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:2197
plm_video_t * video_decoder
Definition pl_mpeg.hpp:205
plm_demux_t * demux
Definition pl_mpeg.hpp:196
plm_buffer_t * video_buffer
Definition pl_mpeg.hpp:204
fl::u64 time() FL_NOEXCEPT
Alias for millis64() - returns 64-bit millisecond time.
Definition chrono.h:346
#define TRUE
Definition pl_mpeg.hpp:174
#define FALSE
Definition pl_mpeg.hpp:175

References fl::third_party::plm_packet_t::data, FALSE, FL_NOEXCEPT, fl::third_party::plm_packet_t::length, NULL, plm_buffer_write(), plm_demux_get_duration(), plm_demux_get_start_time(), plm_demux_seek(), plm_init_decoders(), plm_video_decode(), plm_video_rewind(), plm_video_set_time(), fl::third_party::plm_packet_t::pts, fl::third_party::plm_frame_t::time, fl::time(), and TRUE.

Referenced by plm_seek().

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