summaryrefslogtreecommitdiff
path: root/src/codec/ffmpeg
diff options
context:
space:
mode:
Diffstat (limited to 'src/codec/ffmpeg')
-rw-r--r--src/codec/ffmpeg/common.c21
-rw-r--r--src/codec/ffmpeg/common.h7
2 files changed, 26 insertions, 2 deletions
diff --git a/src/codec/ffmpeg/common.c b/src/codec/ffmpeg/common.c
index 59f59b7..5e10bcb 100644
--- a/src/codec/ffmpeg/common.c
+++ b/src/codec/ffmpeg/common.c
@@ -7,7 +7,7 @@
#include "common.h"
-s64 camu_ff_frame_duration(AVFrame *frame)
+s64 camu_ff_get_frame_duration(AVFrame *frame)
{
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 30, 100)
return frame->duration;
@@ -16,6 +16,25 @@ s64 camu_ff_frame_duration(AVFrame *frame)
#endif
}
+// https://code.videolan.org/videolan/libplacebo/-/blob/a7a18af88ff0a17c04840dcb3246047bb6b46df3/src/include/libplacebo/utils/libav_internal.h#L854
+const u8 *camu_ff_get_stream_side_data(const AVStream *stream, enum AVPacketSideDataType type)
+{
+#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(60, 15, 100)
+ AVCodecParameters *codecpar = stream->codecpar;
+ const AVPacketSideData *side_data = av_packet_side_data_get(codecpar->coded_side_data,
+ codecpar->nb_coded_side_data, type);
+ return side_data ? side_data->data : NULL;
+#else
+ return av_stream_get_side_data(stream, type, NULL);
+#endif
+}
+
+const u8 *camu_ff_get_frame_side_data(AVFrame *frame, enum AVFrameSideDataType type)
+{
+ AVFrameSideData *side_data = av_frame_get_side_data(frame, type);
+ return side_data ? side_data->data : NULL;
+}
+
static __thread struct {
char buf[AL_LOG_MESSAGE_SIZE];
size_t pos;
diff --git a/src/codec/ffmpeg/common.h b/src/codec/ffmpeg/common.h
index c40a38d..b49ce88 100644
--- a/src/codec/ffmpeg/common.h
+++ b/src/codec/ffmpeg/common.h
@@ -2,11 +2,16 @@
#include <al/types.h>
#include <libavutil/frame.h>
+#include <libavutil/display.h>
+#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#define camu_ff_longest_name(desc) ((desc)->long_name ? (desc)->long_name : (desc)->name)
-s64 camu_ff_frame_duration(AVFrame *frame);
+s64 camu_ff_get_frame_duration(AVFrame *frame);
+
+const u8 *camu_ff_get_stream_side_data(const AVStream *stream, enum AVPacketSideDataType type);
+const u8 *camu_ff_get_frame_side_data(AVFrame *frame, enum AVFrameSideDataType type);
// userdata, level, fmt, args
void camu_ff_set_log_callback(void (*callback)(void *, int, const char *, va_list));