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.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user