---
Hi there,
I am trying to use pl_mpeg.h in a Purebasic-program.
You can find the source here: https://github.com/phoboslab/pl_mpeg/tree/master
I was able to compile a .a for macOS with
Code: Select all
gcc -c -arch arm64 pl_mpeg.c -o pl_mpeg.o
Code: Select all
ar rcs libplmpeg.a pl_mpeg.o
Code: Select all
#ifdef __cplusplus
extern "C" {
#endif
#define PL_MPEG_IMPLEMENTATION
#include "pl_mpeg.h"
#ifdef __cplusplus
}
#endif
So, this source will tell me the width and height, but will crash, when trying to decode a frame...
Any help appreciated, and thanks for any hint

Code: Select all
ImportC "libplmpeg.a"
plm_create_with_filename(FileName.p-utf8)
plm_decode(handle)
plm_destroy(handle)
plm_video_decode(handle)
plm_get_width(handle)
plm_get_height(handle)
plm_frame_to_rgb(frame, buffer) ; convert YUV to RGB
plm_get_num_video_streams(handle)
plm_get_video_enabled(handle)
plm_set_video_enabled(handle, enabled)
plm_set_video_decode_callback(handle, callback, user)
plm_set_audio_enabled(handle, enabled)
EndImport
EnableExplicit
Structure plm_frame_t
width.l
height.l
y_stride.l
cr_stride.l
cb_stride.l
*y
*cr
*cb
EndStructure
Define mpeg, width, height
Define filename.s = "video.mpg"
Define *frame
mpeg = plm_create_with_filename(filename)
If mpeg
width = plm_get_width(mpeg)
height = plm_get_height(mpeg)
Debug "Video-Resolution: " + Str(width) + "x" + Str(height)
While plm_decode(mpeg)
*frame = plm_video_decode(mpeg) ; CRASH
If *frame
Debug "Frame decoded!"
Break
EndIf
Wend
plm_destroy(mpeg)
Else
Debug "Error loading mpeg"
EndIf