1111
1212#include " thirdparty/misc/yuv2rgb.h"
1313
14- void VideoStreamPlaybackMPG::buffer_data (plm_buffer_t *buf, void *user) { // TODO: fix this and use custom buffer
15- PLM_UNUSED (user);
14+ void VideoStreamPlaybackMPG::dummy_yuv2rgb () {
15+ // MPEG-1 only supports 4:2:0, these are here to prevent werror from yelling
16+ yuv444_2_rgb8888 (nullptr , nullptr , nullptr , nullptr , 0 , 0 , 0 , 0 , 0 );
17+ yuv422_2_rgb8888 (nullptr , nullptr , nullptr , nullptr , 0 , 0 , 0 , 0 , 0 );
18+ }
19+
20+ void VideoStreamPlaybackMPG::load_callback (plm_buffer_t *buf, void *user) { // TODO: fix this and use custom buffer
1621 Ref<FileAccess> fa = *(Ref<FileAccess> *)buf->load_callback_user_data ;
1722
1823 if (buf->discard_read_bytes ) {
@@ -28,17 +33,14 @@ void VideoStreamPlaybackMPG::buffer_data(plm_buffer_t *buf, void *user) { // TOD
2833 }
2934}
3035
31- void VideoStreamPlaybackMPG::video_write (plm_t *self, plm_frame_t *frame, void *user) {
32- PLM_UNUSED (user);
33- VideoStreamPlaybackMPG *ps = (VideoStreamPlaybackMPG *)self->video_decode_callback_user_data ;
36+ void VideoStreamPlaybackMPG::video_callback (plm_t *self, plm_frame_t *frame, void *user) {
37+ VideoStreamPlaybackMPG *ps = (VideoStreamPlaybackMPG *)user;
3438 ps->frame_current = frame;
3539 ps->frame_pending = true ;
3640}
3741
38- void VideoStreamPlaybackMPG::audio_write (plm_t *self, plm_samples_t *samples, void *user) {
39- PLM_UNUSED (user);
40- VideoStreamPlaybackMPG *ps = (VideoStreamPlaybackMPG *)self->audio_decode_callback_user_data ;
41-
42+ void VideoStreamPlaybackMPG::audio_callback (plm_t *self, plm_samples_t *samples, void *user) {
43+ VideoStreamPlaybackMPG *ps = (VideoStreamPlaybackMPG *)user;
4244 if (ps->mix_callback ) {
4345 ps->mix_callback (ps->mix_udata , samples->interleaved , samples->count );
4446 }
@@ -64,8 +66,8 @@ void VideoStreamPlaybackMPG::set_file(const String &p_file) {
6466 file->close ();
6567 mpeg = plm_create_with_memory (file_data.ptr (), file_data.size (), FALSE );
6668
67- plm_set_video_decode_callback (mpeg, video_write , this );
68- plm_set_audio_decode_callback (mpeg, audio_write , this );
69+ plm_set_video_decode_callback (mpeg, video_callback , this );
70+ plm_set_audio_decode_callback (mpeg, audio_callback , this );
6971
7072 if (plm_get_num_audio_streams (mpeg) > 0 ) {
7173 plm_set_audio_stream (mpeg, audio_track);
@@ -163,15 +165,9 @@ void VideoStreamPlaybackMPG::update(double p_delta) {
163165
164166 plm_decode (mpeg, p_delta);
165167
166- if (frame_pending) {
168+ if (frame_pending) { // Write frame to texture
167169 frame_data.resize ((size.x * size.y ) << 2 );
168170 yuv420_2_rgb8888 (frame_data.ptrw (), frame_current->y .data , frame_current->cb .data , frame_current->cr .data , size.x , size.y , size.x , size.x >> 1 , size.x << 2 );
169-
170- if (false ) { // MPEG-1 only supports 4:2:0, these are here to prevent werror from yelling
171- yuv444_2_rgb8888 (nullptr , nullptr , nullptr , nullptr , 0 , 0 , 0 , 0 , 0 );
172- yuv422_2_rgb8888 (nullptr , nullptr , nullptr , nullptr , 0 , 0 , 0 , 0 , 0 );
173- }
174-
175171 Ref<Image> img = memnew (Image (size.x , size.y , false , Image::FORMAT_RGBA8, frame_data));
176172 texture->update (img);
177173
0 commit comments