FastLED 3.9.15
Loading...
Searching...
No Matches
pl_mpeg.h
Go to the documentation of this file.
1/*
2PL_MPEG - MPEG1 Video decoder, MP2 Audio decoder, MPEG-PS demuxer
3SPDX-License-Identifier: MIT
4
5Dominic Szablewski - https://phoboslab.org
6
7
8-- Synopsis
9
10// Define `PL_MPEG_IMPLEMENTATION` in *one* C/C++ file before including this
11// library to create the implementation.
12
13#define PL_MPEG_IMPLEMENTATION
14#include "plmpeg.h"
15
16// This function gets called for each decoded video frame
17void my_video_callback(plm_t *plm, plm_frame_t *frame, void *user) {
18 // Do something with frame->y.data, frame->cr.data, frame->cb.data
19}
20
21// This function gets called for each decoded audio frame
22void my_audio_callback(plm_t *plm, plm_samples_t *frame, void *user) {
23 // Do something with samples->interleaved
24}
25
26// Load a .mpg (MPEG Program Stream) file
27plm_t *plm = plm_create_with_filename("some-file.mpg");
28
29// Install the video & audio decode callbacks
30plm_set_video_decode_callback(plm, my_video_callback, my_data);
31plm_set_audio_decode_callback(plm, my_audio_callback, my_data);
32
33
34// Decode
35do {
36 plm_decode(plm, time_since_last_call);
37} while (!plm_has_ended(plm));
38
39// All done
40plm_destroy(plm);
41
42
43
44-- Documentation
45
46This library provides several interfaces to load, demux and decode MPEG video
47and audio data. A high-level API combines the demuxer, video & audio decoders
48in an easy to use wrapper.
49
50Lower-level APIs for accessing the demuxer, video decoder and audio decoder,
51as well as providing different data sources are also available.
52
53Interfaces are written in an object oriented style, meaning you create object
54instances via various different constructor functions (plm_*create()),
55do some work on them and later dispose them via plm_*destroy().
56
57plm_* ......... the high-level interface, combining demuxer and decoders
58plm_buffer_* .. the data source used by all interfaces
59plm_demux_* ... the MPEG-PS demuxer
60plm_video_* ... the MPEG1 Video ("mpeg1") decoder
61plm_audio_* ... the MPEG1 Audio Layer II ("mp2") decoder
62
63
64With the high-level interface you have two options to decode video & audio:
65
66 1. Use plm_decode() and just hand over the delta time since the last call.
67 It will decode everything needed and call your callbacks (specified through
68 plm_set_{video|audio}_decode_callback()) any number of times.
69
70 2. Use plm_decode_video() and plm_decode_audio() to decode exactly one
71 frame of video or audio data at a time. How you handle the synchronization
72 of both streams is up to you.
73
74If you only want to decode video *or* audio through these functions, you should
75disable the other stream (plm_set_{video|audio}_enabled(FALSE))
76
77Video data is decoded into a struct with all 3 planes (Y, Cr, Cb) stored in
78separate buffers. You can either convert this to RGB on the CPU (slow) via the
79plm_frame_to_rgb() function or do it on the GPU with the following matrix:
80
81mat4 bt601 = mat4(
82 1.16438, 0.00000, 1.59603, -0.87079,
83 1.16438, -0.39176, -0.81297, 0.52959,
84 1.16438, 2.01723, 0.00000, -1.08139,
85 0, 0, 0, 1
86);
87gl_FragColor = vec4(y, cb, cr, 1.0) * bt601;
88
89Audio data is decoded into a struct with either one single float array with the
90samples for the left and right channel interleaved, or if the
91PLM_AUDIO_SEPARATE_CHANNELS is defined *before* including this library, into
92two separate float arrays - one for each channel.
93
94
95Data can be supplied to the high level interface, the demuxer and the decoders
96in three different ways:
97
98 1. Using plm_create_from_filename() or with a file handle with
99 plm_create_from_file().
100
101 2. Using plm_create_with_memory() and supplying a pointer to memory that
102 contains the whole file.
103
104 3. Using plm_create_with_buffer(), supplying your own plm_buffer_t instance and
105 periodically writing to this buffer.
106
107When using your own plm_buffer_t instance, you can fill this buffer using
108plm_buffer_write(). You can either monitor plm_buffer_get_remaining() and push
109data when appropriate, or install a callback on the buffer with
110plm_buffer_set_load_callback() that gets called whenever the buffer needs more
111data.
112
113A buffer created with plm_buffer_create_with_capacity() is treated as a ring
114buffer, meaning that data that has already been read, will be discarded. In
115contrast, a buffer created with plm_buffer_create_for_appending() will keep all
116data written to it in memory. This enables seeking in the already loaded data.
117
118
119There should be no need to use the lower level plm_demux_*, plm_video_* and
120plm_audio_* functions, if all you want to do is read/decode an MPEG-PS file.
121However, if you get raw mpeg1video data or raw mp2 audio data from a different
122source, these functions can be used to decode the raw data directly. Similarly,
123if you only want to analyze an MPEG-PS file or extract raw video or audio
124packets from it, you can use the plm_demux_* functions.
125
126
127This library uses malloc(), realloc() and free() to manage memory. Typically
128all allocation happens up-front when creating the interface. However, the
129default buffer size may be too small for certain inputs. In these cases plmpeg
130will realloc() the buffer with a larger size whenever needed. You can configure
131the default buffer size by defining PLM_BUFFER_DEFAULT_SIZE *before*
132including this library.
133
134You can also define PLM_MALLOC, PLM_REALLOC and PLM_FREE to provide your own
135memory management functions.
136
137
138See below for detailed the API documentation.
139
140*/
141
142
143#pragma once
144
145#include "fl/stl/cstddef.h"
146#include "fl/stl/stdint.h"
147#include "fl/stl/noexcept.h"
148
149namespace fl {
150namespace third_party {
151
152
153// -----------------------------------------------------------------------------
154// Public Data Types
155
156
157// Object types for the various interfaces
158
159typedef struct plm_t plm_t;
164
165
166// Demuxed MPEG PS packet
167// The type maps directly to the various MPEG-PES start codes. PTS is the
168// presentation time stamp of the packet in seconds. Note that not all packets
169// have a PTS value, indicated by PLM_PACKET_INVALID_TS.
170
171#define PLM_PACKET_INVALID_TS -1
172
173typedef struct {
174 int type;
175 double pts;
176 size_t length;
179
180
181// Decoded Video Plane
182// The byte length of the data is width * height. Note that different planes
183// have different sizes: the Luma plane (Y) is double the size of each of
184// the two Chroma planes (Cr, Cb) - i.e. 4 times the byte length.
185// Also note that the size of the plane does *not* denote the size of the
186// displayed frame. The sizes of planes are always rounded up to the nearest
187// macroblock (16px).
188
189typedef struct {
190 unsigned int width;
191 unsigned int height;
194
195
196// Decoded Video Frame
197// width and height denote the desired display size of the frame. This may be
198// different from the internal size of the 3 planes.
199
200typedef struct {
201 double time;
202 unsigned int width;
203 unsigned int height;
208
209
210// Callback function type for decoded video frames used by the high-level
211// plm_* interface
212
214 (plm_t *self, plm_frame_t *frame, void *user);
215
216
217// Decoded Audio Samples
218// Samples are stored as normalized (-1, 1) float either interleaved, or if
219// PLM_AUDIO_SEPARATE_CHANNELS is defined, in two separate arrays.
220// The `count` is always PLM_AUDIO_SAMPLES_PER_FRAME and just there for
221// convenience.
222
223#define PLM_AUDIO_SAMPLES_PER_FRAME 1152
224
225typedef struct {
226 double time;
227 unsigned int count;
228 #ifdef PLM_AUDIO_SEPARATE_CHANNELS
229 float left[PLM_AUDIO_SAMPLES_PER_FRAME];
230 float right[PLM_AUDIO_SAMPLES_PER_FRAME];
231 #else
233 #endif
235
236
237// Callback function type for decoded audio samples used by the high-level
238// plm_* interface
239
241 (plm_t *self, plm_samples_t *samples, void *user);
242
243
244// Callback function for plm_buffer when it needs more data
245
246typedef void(*plm_buffer_load_callback)(plm_buffer_t *self, void *user);
247
248
249// Callback function for plm_buffer when it needs to seek
250
251typedef void(*plm_buffer_seek_callback)(plm_buffer_t *self, size_t offset, void *user);
252
253
254// Callback function for plm_buffer when it needs to tell the position
255
256typedef size_t(*plm_buffer_tell_callback)(plm_buffer_t *self, void *user);
257
258
259// -----------------------------------------------------------------------------
260// plm_* public API
261// High-Level API for loading/demuxing/decoding MPEG-PS data
262
263// #ifndef PLM_NO_STDIO
264
265// // Create a plmpeg instance with a filename. Returns NULL if the file could not
266// // be opened.
267
268// plm_t *plm_create_with_filename(const char *filename);
269
270
271// // Create a plmpeg instance with a file handle. Pass TRUE to close_when_done to
272// // let plmpeg call fclose() on the handle when plm_destroy() is called.
273
274// plm_t *plm_create_with_file(FILE *fh, int close_when_done);
275
276// #endif // PLM_NO_STDIO
277
278
279// Create a plmpeg instance with a pointer to memory as source. This assumes the
280// whole file is in memory. The memory is not copied. Pass TRUE to
281// free_when_done to let plmpeg call free() on the pointer when plm_destroy()
282// is called.
283
284plm_t *plm_create_with_memory(uint8_t *bytes, size_t length, int free_when_done) FL_NOEXCEPT;
285
286
287// Create a plmpeg instance with a plm_buffer as source. Pass TRUE to
288// destroy_when_done to let plmpeg call plm_buffer_destroy() on the buffer when
289// plm_destroy() is called.
290
291plm_t *plm_create_with_buffer(plm_buffer_t *buffer, int destroy_when_done) FL_NOEXCEPT;
292
293
294// Destroy a plmpeg instance and free all data.
295
296void plm_destroy(plm_t *self) FL_NOEXCEPT;
297
298
299// Get whether we have headers on all available streams and we can report the
300// number of video/audio streams, video dimensions, framerate and audio
301// samplerate.
302// This returns FALSE if the file is not an MPEG-PS file or - when not using a
303// file as source - when not enough data is available yet.
304
306
307
308// Probe the MPEG-PS data to find the actual number of video and audio streams
309// within the buffer. For certain files (e.g. VideoCD) this can be more accurate
310// than just reading the number of streams from the headers.
311// This should only be used when the underlying plm_buffer is seekable, i.e. for
312// files, fixed memory buffers or _for_appending buffers. If used with dynamic
313// memory buffers it will skip decoding the probesize!
314// The necessary probesize is dependent on the files you expect to read. Usually
315// a few hundred KB should be enough to find all streams.
316// Use plm_get_num_{audio|video}_streams() afterwards to get the number of
317// streams in the file.
318// Returns TRUE if any streams were found within the probesize.
319
320int plm_probe(plm_t *self, size_t probesize) FL_NOEXCEPT;
321
322
323// Get or set whether video decoding is enabled. Default TRUE.
324
326void plm_set_video_enabled(plm_t *self, int enabled) FL_NOEXCEPT;
327
328
329// Get the number of video streams (0--1) reported in the system header.
330
332
333
334// Get the display width/height of the video stream.
335
339
340
341// Get the framerate of the video stream in frames per second.
342
344
345
346// Get or set whether audio decoding is enabled. Default TRUE.
347
349void plm_set_audio_enabled(plm_t *self, int enabled) FL_NOEXCEPT;
350
351
352// Get the number of audio streams (0--4) reported in the system header.
353
355
356
357// Set the desired audio stream (0--3). Default 0.
358
359void plm_set_audio_stream(plm_t *self, int stream_index) FL_NOEXCEPT;
360
361
362// Get the samplerate of the audio stream in samples per second.
363
365
366
367// Get or set the audio lead time in seconds - the time in which audio samples
368// are decoded in advance (or behind) the video decode time. Typically this
369// should be set to the duration of the buffer of the audio API that you use
370// for output. E.g. for SDL2: (SDL_AudioSpec.samples / samplerate)
371
373void plm_set_audio_lead_time(plm_t *self, double lead_time) FL_NOEXCEPT;
374
375
376// Get the current internal time in seconds.
377
378double plm_get_time(plm_t *self) FL_NOEXCEPT;
379
380
381// Get the video duration of the underlying source in seconds.
382
384
385
386// Rewind all buffers back to the beginning.
387
388void plm_rewind(plm_t *self) FL_NOEXCEPT;
389
390
391// Get or set looping. Default FALSE.
392
394void plm_set_loop(plm_t *self, int loop) FL_NOEXCEPT;
395
396
397// Get whether the file has ended. If looping is enabled, this will always
398// return FALSE.
399
401
402
403// Set the callback for decoded video frames used with plm_decode(). If no
404// callback is set, video data will be ignored and not be decoded. The *user
405// Parameter will be passed to your callback.
406
408
409
410// Set the callback for decoded audio samples used with plm_decode(). If no
411// callback is set, audio data will be ignored and not be decoded. The *user
412// Parameter will be passed to your callback.
413
415
416
417// Advance the internal timer by seconds and decode video/audio up to this time.
418// This will call the video_decode_callback and audio_decode_callback any number
419// of times. A frame-skip is not implemented, i.e. everything up to current time
420// will be decoded.
421
422void plm_decode(plm_t *self, double seconds) FL_NOEXCEPT;
423
424
425// Decode and return one video frame. Returns NULL if no frame could be decoded
426// (either because the source ended or data is corrupt). If you only want to
427// decode video, you should disable audio via plm_set_audio_enabled().
428// The returned plm_frame_t is valid until the next call to plm_decode_video()
429// or until plm_destroy() is called.
430
432
433
434// Decode and return one audio frame. Returns NULL if no frame could be decoded
435// (either because the source ended or data is corrupt). If you only want to
436// decode audio, you should disable video via plm_set_video_enabled().
437// The returned plm_samples_t is valid until the next call to plm_decode_audio()
438// or until plm_destroy() is called.
439
441
442
443// Seek to the specified time, clamped between 0 -- duration. This can only be
444// used when the underlying plm_buffer is seekable, i.e. for files, fixed
445// memory buffers or _for_appending buffers.
446// If seek_exact is TRUE this will seek to the exact time, otherwise it will
447// seek to the last intra frame just before the desired time. Exact seeking can
448// be slow, because all frames up to the seeked one have to be decoded on top of
449// the previous intra frame.
450// If seeking succeeds, this function will call the video_decode_callback
451// exactly once with the target frame. If audio is enabled, it will also call
452// the audio_decode_callback any number of times, until the audio_lead_time is
453// satisfied.
454// Returns TRUE if seeking succeeded or FALSE if no frame could be found.
455
456int plm_seek(plm_t *self, double time, int seek_exact) FL_NOEXCEPT;
457
458
459// Similar to plm_seek(), but will not call the video_decode_callback,
460// audio_decode_callback or make any attempts to sync audio.
461// Returns the found frame or NULL if no frame could be found.
462
463plm_frame_t *plm_seek_frame(plm_t *self, double time, int seek_exact) FL_NOEXCEPT;
464
465
466
467// -----------------------------------------------------------------------------
468// plm_buffer public API
469// Provides the data source for all other plm_* interfaces
470
471
472// The default size for buffers created from files or by the high-level API
473
474#ifndef PLM_BUFFER_DEFAULT_SIZE
475#define PLM_BUFFER_DEFAULT_SIZE (128U * 1024U) /* 131072 bytes */
476#endif
477
478// #ifndef PLM_NO_STDIO
479
480// // Create a buffer instance with a filename. Returns NULL if the file could not
481// // be opened.
482
483// plm_buffer_t *plm_buffer_create_with_filename(const char *filename);
484
485
486// // Create a buffer instance with a file handle. Pass TRUE to close_when_done
487// // to let plmpeg call fclose() on the handle when plm_destroy() is called.
488
489// plm_buffer_t *plm_buffer_create_with_file(FILE *fh, int close_when_done);
490
491// #endif // PLM_NO_STDIO
492
493
494// Create a buffer instance with custom callbacks for loading, seeking and
495// telling the position. This behaves like a file handle, but with user-defined
496// callbacks, useful for file handles that don't use the standard FILE API.
497// Setting the length and closing/freeing has to be done manually.
498
500 plm_buffer_load_callback load_callback,
501 plm_buffer_seek_callback seek_callback,
502 plm_buffer_tell_callback tell_callback,
503 size_t length,
504 void *user
506
507
508// Create a buffer instance with a pointer to memory as source. This assumes
509// the whole file is in memory. The bytes are not copied. Pass 1 to
510// free_when_done to let plmpeg call free() on the pointer when plm_destroy()
511// is called.
512
513plm_buffer_t *plm_buffer_create_with_memory(uint8_t *bytes, size_t length, int free_when_done) FL_NOEXCEPT;
514
515
516// Create an empty buffer with an initial capacity. The buffer will grow
517// as needed. Data that has already been read, will be discarded.
518
520
521
522// Create an empty buffer with an initial capacity. The buffer will grow
523// as needed. Decoded data will *not* be discarded. This can be used when
524// loading a file over the network, without needing to throttle the download.
525// It also allows for seeking in the already loaded data.
526
528
529
530// Destroy a buffer instance and free all data
531
533
534
535// Copy data into the buffer. If the data to be written is larger than the
536// available space, the buffer will realloc() with a larger capacity.
537// Returns the number of bytes written. This will always be the same as the
538// passed in length, except when the buffer was created _with_memory() for
539// which _write() is forbidden.
540
541size_t plm_buffer_write(plm_buffer_t *self, uint8_t *bytes, size_t length) FL_NOEXCEPT;
542
543
544// Mark the current byte length as the end of this buffer and signal that no
545// more data is expected to be written to it. This function should be called
546// just after the last plm_buffer_write().
547// For _with_capacity buffers, this is cleared on a plm_buffer_rewind().
548
550
551
552// Set a callback that is called whenever the buffer needs more data
553
555
556
557// Rewind the buffer back to the beginning. When loading from a file handle,
558// this also seeks to the beginning of the file.
559
561
562
563// Get the total size. For files, this returns the file size. For all other
564// types it returns the number of bytes currently in the buffer.
565
567
568
569// Get the number of remaining (yet unread) bytes in the buffer. This can be
570// useful to throttle writing.
571
573
574
575// Get whether the read position of the buffer is at the end and no more data
576// is expected.
577
579
580
581
582// -----------------------------------------------------------------------------
583// plm_demux public API
584// Demux an MPEG Program Stream (PS) data into separate packages
585
586
587// Various Packet Types
588
589static const int PLM_DEMUX_PACKET_PRIVATE = 0xBD;
590static const int PLM_DEMUX_PACKET_AUDIO_1 = 0xC0;
591static const int PLM_DEMUX_PACKET_AUDIO_2 = 0xC1;
592static const int PLM_DEMUX_PACKET_AUDIO_3 = 0xC2;
593static const int PLM_DEMUX_PACKET_AUDIO_4 = 0xC3;
594static const int PLM_DEMUX_PACKET_VIDEO_1 = 0xE0;
595
596
597// Create a demuxer with a plm_buffer as source. This will also attempt to read
598// the pack and system headers from the buffer.
599
600plm_demux_t *plm_demux_create(plm_buffer_t *buffer, int destroy_when_done) FL_NOEXCEPT;
601
602
603// Destroy a demuxer and free all data.
604
606
607
608// Returns TRUE/FALSE whether pack and system headers have been found. This will
609// attempt to read the headers if non are present yet.
610
612
613
614// Probe the file for the actual number of video/audio streams. See
615// plm_probe() for the details.
616
617int plm_demux_probe(plm_demux_t *self, size_t probesize) FL_NOEXCEPT;
618
619
620// Returns the number of video streams found in the system header. This will
621// attempt to read the system header if non is present yet.
622
624
625
626// Returns the number of audio streams found in the system header. This will
627// attempt to read the system header if non is present yet.
628
630
631
632// Rewind the internal buffer. See plm_buffer_rewind().
633
635
636
637// Get whether the file has ended. This will be cleared on seeking or rewind.
638
640
641
642// Seek to a packet of the specified type with a PTS just before specified time.
643// If force_intra is TRUE, only packets containing an intra frame will be
644// considered - this only makes sense when the type is PLM_DEMUX_PACKET_VIDEO_1.
645// Note that the specified time is considered 0-based, regardless of the first
646// PTS in the data source.
647
648plm_packet_t *plm_demux_seek(plm_demux_t *self, double time, int type, int force_intra) FL_NOEXCEPT;
649
650
651// Get the PTS of the first packet of this type. Returns PLM_PACKET_INVALID_TS
652// if not packet of this packet type can be found.
653
655
656
657// Get the duration for the specified packet type - i.e. the span between the
658// the first PTS and the last PTS in the data source. This only makes sense when
659// the underlying data source is a file or fixed memory.
660
662
663
664// Decode and return the next packet. The returned packet_t is valid until
665// the next call to plm_demux_decode() or until the demuxer is destroyed.
666
668
669
670
671// -----------------------------------------------------------------------------
672// plm_video public API
673// Decode MPEG1 Video ("mpeg1") data into raw YCrCb frames
674
675
676// Create a video decoder with a plm_buffer as source.
677
679
680
681// Destroy a video decoder and free all data.
682
684
685
686// Get whether a sequence header was found and we can accurately report on
687// dimensions and framerate.
688
690
691
692// Get the framerate in frames per second.
693
696
697
698// Get the display width/height.
699
702
703
704// Set "no delay" mode. When enabled, the decoder assumes that the video does
705// *not* contain any B-Frames. This is useful for reducing lag when streaming.
706// The default is FALSE.
707
708void plm_video_set_no_delay(plm_video_t *self, int no_delay) FL_NOEXCEPT;
709
710
711// Get the current internal time in seconds.
712
714
715
716// Set the current internal time in seconds. This is only useful when you
717// manipulate the underlying video buffer and want to enforce a correct
718// timestamps.
719
721
722
723// Rewind the internal buffer. See plm_buffer_rewind().
724
726
727
728// Get whether the file has ended. This will be cleared on rewind.
729
731
732
733// Decode and return one frame of video and advance the internal time by
734// 1/framerate seconds. The returned frame_t is valid until the next call of
735// plm_video_decode() or until the video decoder is destroyed.
736
738
739
740// Convert the YCrCb data of a frame into interleaved R G B data. The stride
741// specifies the width in bytes of the destination buffer. I.e. the number of
742// bytes from one line to the next. The stride must be at least
743// (frame->width * bytes_per_pixel). The buffer pointed to by *dest must have a
744// size of at least (stride * frame->height).
745// Note that the alpha component of the dest buffer is always left untouched.
746
747void plm_frame_to_rgb(plm_frame_t *frame, uint8_t *dest, int stride) FL_NOEXCEPT;
748void plm_frame_to_bgr(plm_frame_t *frame, uint8_t *dest, int stride) FL_NOEXCEPT;
749void plm_frame_to_rgba(plm_frame_t *frame, uint8_t *dest, int stride) FL_NOEXCEPT;
750void plm_frame_to_bgra(plm_frame_t *frame, uint8_t *dest, int stride) FL_NOEXCEPT;
751void plm_frame_to_argb(plm_frame_t *frame, uint8_t *dest, int stride) FL_NOEXCEPT;
752void plm_frame_to_abgr(plm_frame_t *frame, uint8_t *dest, int stride) FL_NOEXCEPT;
753
754
755// -----------------------------------------------------------------------------
756// plm_audio public API
757// Decode MPEG-1 Audio Layer II ("mp2") data into raw samples
758
759
760// Create an audio decoder with a plm_buffer as source.
761
763
764
765// Destroy an audio decoder and free all data.
766
768
769
770// Get whether a frame header was found and we can accurately report on
771// samplerate.
772
774
775
776// Get the samplerate in samples per second.
777
779
780
781// Get the current internal time in seconds.
782
784
785
786// Set the current internal time in seconds. This is only useful when you
787// manipulate the underlying video buffer and want to enforce a correct
788// timestamps.
789
791
792
793// Rewind the internal buffer. See plm_buffer_rewind().
794
796
797
798// Get whether the file has ended. This will be cleared on rewind.
799
801
802
803// Decode and return one "frame" of audio and advance the internal time by
804// (PLM_AUDIO_SAMPLES_PER_FRAME/samplerate) seconds. The returned samples_t
805// is valid until the next call of plm_audio_decode() or until the audio
806// decoder is destroyed.
807
809
810} // namespace third_party
811} // namespace fl
void loop()
fl::UISlider length("Length", 1.0f, 0.0f, 1.0f, 0.01f)
fl::UISlider offset("Offset", 0.0f, 0.0f, 1.0f, 0.01f)
void plm_frame_to_bgra(plm_frame_t *frame, uint8_t *dest, int stride) FL_NOEXCEPT
void plm_set_video_decode_callback(plm_t *self, plm_video_decode_callback fp, void *user) FL_NOEXCEPT
Definition pl_mpeg.hpp:464
void(* plm_buffer_load_callback)(plm_buffer_t *self, void *user)
Definition pl_mpeg.h:246
int plm_video_has_ended(plm_video_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:2193
static const int PLM_DEMUX_PACKET_AUDIO_2
Definition pl_mpeg.h:591
plm_buffer_t * plm_buffer_create_with_callbacks(plm_buffer_load_callback load_callback, plm_buffer_seek_callback seek_callback, plm_buffer_tell_callback tell_callback, size_t length, void *user) FL_NOEXCEPT
Definition pl_mpeg.hpp:807
int plm_demux_get_num_audio_streams(plm_demux_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:1280
int plm_probe(plm_t *self, size_t probesize) FL_NOEXCEPT
Definition pl_mpeg.hpp:331
int plm_get_num_video_streams(plm_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:384
static const int PLM_DEMUX_PACKET_PRIVATE
Definition pl_mpeg.h:589
void plm_decode(plm_t *self, double seconds) FL_NOEXCEPT
Definition pl_mpeg.hpp:474
plm_packet_t * plm_demux_decode(plm_demux_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:1517
double plm_audio_get_time(plm_audio_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:3275
plm_video_t * plm_video_create_with_buffer(plm_buffer_t *buffer, int destroy_when_done) FL_NOEXCEPT
Definition pl_mpeg.hpp:2121
static const int PLM_DEMUX_PACKET_AUDIO_1
Definition pl_mpeg.h:590
int plm_seek(plm_t *self, double time, int seek_exact) FL_NOEXCEPT
Definition pl_mpeg.hpp:672
plm_buffer_t * plm_buffer_create_with_memory(uint8_t *bytes, size_t length, int free_when_done) FL_NOEXCEPT
Definition pl_mpeg.hpp:824
plm_t * plm_create_with_buffer(plm_buffer_t *buffer, int destroy_when_done) FL_NOEXCEPT
Definition pl_mpeg.hpp:249
int plm_get_samplerate(plm_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:416
void plm_frame_to_bgr(plm_frame_t *frame, uint8_t *dest, int stride) FL_NOEXCEPT
int plm_audio_get_samplerate(plm_audio_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:3269
void plm_audio_destroy(plm_audio_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:3253
int plm_audio_has_header(plm_audio_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:3260
size_t plm_buffer_get_size(plm_buffer_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:867
int plm_get_video_enabled(plm_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:367
int plm_get_audio_enabled(plm_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:308
void plm_buffer_set_load_callback(plm_buffer_t *self, plm_buffer_load_callback fp, void *user) FL_NOEXCEPT
Definition pl_mpeg.hpp:914
plm_samples_t * plm_audio_decode(plm_audio_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:3296
void plm_audio_rewind(plm_audio_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:3285
double plm_get_audio_lead_time(plm_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:422
int plm_demux_get_num_video_streams(plm_demux_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:1274
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_destroy(plm_video_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:2136
void plm_rewind(plm_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:438
plm_demux_t * plm_demux_create(plm_buffer_t *buffer, int destroy_when_done) FL_NOEXCEPT
Definition pl_mpeg.hpp:1159
static const int PLM_DEMUX_PACKET_VIDEO_1
Definition pl_mpeg.h:594
void plm_video_rewind(plm_video_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:2185
void plm_buffer_signal_end(plm_buffer_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:910
double plm_demux_get_duration(plm_demux_t *self, int type) FL_NOEXCEPT
Definition pl_mpeg.hpp:1329
void plm_frame_to_abgr(plm_frame_t *frame, uint8_t *dest, int stride) FL_NOEXCEPT
int plm_get_width(plm_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:388
void plm_buffer_destroy(plm_buffer_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:855
void plm_video_set_no_delay(plm_video_t *self, int no_delay) FL_NOEXCEPT
Definition pl_mpeg.hpp:2172
void(* plm_audio_decode_callback)(plm_t *self, plm_samples_t *samples, void *user)
Definition pl_mpeg.h:241
int plm_get_height(plm_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:394
double plm_demux_get_start_time(plm_demux_t *self, int type) FL_NOEXCEPT
Definition pl_mpeg.hpp:1304
plm_frame_t * plm_decode_video(plm_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:533
int plm_buffer_has_ended(plm_buffer_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:994
size_t plm_buffer_get_remaining(plm_buffer_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:873
plm_t * plm_create_with_memory(uint8_t *bytes, size_t length, int free_when_done) FL_NOEXCEPT
Definition pl_mpeg.hpp:244
void plm_set_audio_enabled(plm_t *self, int enabled) FL_NOEXCEPT
Definition pl_mpeg.hpp:344
int plm_get_num_audio_streams(plm_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:412
void plm_frame_to_rgb(plm_frame_t *frame, uint8_t *dest, int stride) FL_NOEXCEPT
void(* plm_buffer_seek_callback)(plm_buffer_t *self, size_t offset, void *user)
Definition pl_mpeg.h:251
static const int PLM_DEMUX_PACKET_AUDIO_3
Definition pl_mpeg.h:592
int plm_video_get_height(plm_video_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:2166
fl::size size_t
Definition coder.h:223
struct plm_buffer_t plm_buffer_t
Definition pl_mpeg.h:160
void plm_frame_to_argb(plm_frame_t *frame, uint8_t *dest, int stride) FL_NOEXCEPT
void plm_set_loop(plm_t *self, int loop) FL_NOEXCEPT
Definition pl_mpeg.hpp:456
void plm_buffer_rewind(plm_buffer_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:919
plm_buffer_t * plm_buffer_create_with_capacity(size_t capacity) FL_NOEXCEPT
Definition pl_mpeg.hpp:837
plm_buffer_t * plm_buffer_create_for_appending(size_t initial_capacity) FL_NOEXCEPT
Definition pl_mpeg.hpp:848
double plm_video_get_pixel_aspect_ratio(plm_video_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:2154
void plm_video_set_time(plm_video_t *self, double time) FL_NOEXCEPT
Definition pl_mpeg.hpp:2180
void plm_set_audio_decode_callback(plm_t *self, plm_audio_decode_callback fp, void *user) FL_NOEXCEPT
Definition pl_mpeg.hpp:469
void plm_demux_rewind(plm_demux_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:1286
int plm_video_get_width(plm_video_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:2160
plm_samples_t * plm_decode_audio(plm_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:552
void plm_frame_to_rgba(plm_frame_t *frame, uint8_t *dest, int stride) FL_NOEXCEPT
int plm_audio_has_ended(plm_audio_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:3292
double plm_video_get_framerate(plm_video_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:2148
void plm_set_audio_lead_time(plm_t *self, double lead_time) FL_NOEXCEPT
Definition pl_mpeg.hpp:426
double plm_get_framerate(plm_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:400
void plm_demux_destroy(plm_demux_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:1174
double plm_get_time(plm_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:430
double plm_get_pixel_aspect_ratio(plm_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:406
unsigned char uint8_t
Definition coder.h:209
int plm_get_loop(plm_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:452
plm_audio_t * plm_audio_create_with_buffer(plm_buffer_t *buffer, int destroy_when_done) FL_NOEXCEPT
Definition pl_mpeg.hpp:3235
void plm_destroy(plm_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:296
int plm_demux_has_headers(plm_demux_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:1181
double plm_get_duration(plm_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:434
void(* plm_video_decode_callback)(plm_t *self, plm_frame_t *frame, void *user)
Definition pl_mpeg.h:214
size_t plm_buffer_write(plm_buffer_t *self, uint8_t *bytes, size_t length) FL_NOEXCEPT
Definition pl_mpeg.hpp:877
double plm_video_get_time(plm_video_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:2176
plm_frame_t * plm_video_decode(plm_video_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:2197
void plm_audio_set_time(plm_audio_t *self, double time) FL_NOEXCEPT
Definition pl_mpeg.hpp:3279
size_t(* plm_buffer_tell_callback)(plm_buffer_t *self, void *user)
Definition pl_mpeg.h:256
void plm_set_video_enabled(plm_t *self, int enabled) FL_NOEXCEPT
Definition pl_mpeg.hpp:371
void plm_set_audio_stream(plm_t *self, int stream_index) FL_NOEXCEPT
Definition pl_mpeg.hpp:357
int plm_has_headers(plm_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:312
int plm_demux_has_ended(plm_demux_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:1293
int plm_demux_probe(plm_demux_t *self, size_t probesize) FL_NOEXCEPT
Definition pl_mpeg.hpp:1241
int plm_video_has_header(plm_video_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:2263
int plm_has_ended(plm_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:460
static const int PLM_DEMUX_PACKET_AUDIO_4
Definition pl_mpeg.h:593
plm_frame_t * plm_seek_frame(plm_t *self, double time, int seek_exact) FL_NOEXCEPT
Definition pl_mpeg.hpp:617
float interleaved[PLM_AUDIO_SAMPLES_PER_FRAME *2]
Definition pl_mpeg.h:232
fl::u64 time() FL_NOEXCEPT
Alias for millis64() - returns 64-bit millisecond time.
Definition chrono.h:346
Base definition for an LED controller.
Definition crgb.hpp:179
#define PLM_AUDIO_SAMPLES_PER_FRAME
Definition pl_mpeg.h:223
#define FL_NOEXCEPT