aboutsummaryrefslogtreecommitdiffstats
path: root/fftools/ffmpeg.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-11-24 09:49:37 +0100
committerAnton Khirnov <anton@khirnov.net>2023-12-14 08:11:05 +0100
commitc9f38210fc498ada2605a1faac8aceb3d76e69c6 (patch)
tree1fa43e0a0848a84a4778788bdb1110fb6c80c74f /fftools/ffmpeg.c
parent5475f665f60e7a297d4e650c76678af3225304b1 (diff)
downloadffmpeg-c9f38210fc498ada2605a1faac8aceb3d76e69c6.tar.gz
fftools/ffmpeg: merge DemuxPktData into FrameData
This way we can propagate arbitrary data from the demuxer all the way into the muxer, using a single struct.
Diffstat (limited to 'fftools/ffmpeg.c')
-rw-r--r--fftools/ffmpeg.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 30b594fd97..e7ff9a6d6f 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -404,36 +404,48 @@ InputStream *ist_iter(InputStream *prev)
return NULL;
}
-static int frame_data_ensure(AVFrame *frame, int writable)
+static int frame_data_ensure(AVBufferRef **dst, int writable)
{
- if (!frame->opaque_ref) {
+ if (!*dst) {
FrameData *fd;
- frame->opaque_ref = av_buffer_allocz(sizeof(*fd));
- if (!frame->opaque_ref)
+ *dst = av_buffer_allocz(sizeof(*fd));
+ if (!*dst)
return AVERROR(ENOMEM);
- fd = (FrameData*)frame->opaque_ref->data;
+ fd = (FrameData*)((*dst)->data);
fd->dec.frame_num = UINT64_MAX;
fd->dec.pts = AV_NOPTS_VALUE;
} else if (writable)
- return av_buffer_make_writable(&frame->opaque_ref);
+ return av_buffer_make_writable(dst);
return 0;
}
FrameData *frame_data(AVFrame *frame)
{
- int ret = frame_data_ensure(frame, 1);
+ int ret = frame_data_ensure(&frame->opaque_ref, 1);
return ret < 0 ? NULL : (FrameData*)frame->opaque_ref->data;
}
const FrameData *frame_data_c(AVFrame *frame)
{
- int ret = frame_data_ensure(frame, 0);
+ int ret = frame_data_ensure(&frame->opaque_ref, 0);
return ret < 0 ? NULL : (const FrameData*)frame->opaque_ref->data;
}
+FrameData *packet_data(AVPacket *pkt)
+{
+ int ret = frame_data_ensure(&pkt->opaque_ref, 1);
+ return ret < 0 ? NULL : (FrameData*)pkt->opaque_ref->data;
+}
+
+const FrameData *packet_data_c(AVPacket *pkt)
+{
+ int ret = frame_data_ensure(&pkt->opaque_ref, 0);
+ return ret < 0 ? NULL : (const FrameData*)pkt->opaque_ref->data;
+}
+
void remove_avoptions(AVDictionary **a, AVDictionary *b)
{
const AVDictionaryEntry *t = NULL;