1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-10 06:10:52 +02:00

fftools/ffmpeg: factor out attaching FrameData to a frame

Will be useful in following commits.
This commit is contained in:
Anton Khirnov
2023-05-27 12:25:51 +02:00
parent d7781cfb95
commit 9630341073
3 changed files with 19 additions and 3 deletions

View File

@@ -431,6 +431,17 @@ InputStream *ist_iter(InputStream *prev)
return NULL; return NULL;
} }
FrameData *frame_data(AVFrame *frame)
{
if (!frame->opaque_ref) {
frame->opaque_ref = av_buffer_allocz(sizeof(FrameData));
if (!frame->opaque_ref)
return NULL;
}
return (FrameData*)frame->opaque_ref->data;
}
void remove_avoptions(AVDictionary **a, AVDictionary *b) void remove_avoptions(AVDictionary **a, AVDictionary *b)
{ {
const AVDictionaryEntry *t = NULL; const AVDictionaryEntry *t = NULL;

View File

@@ -737,6 +737,12 @@ int init_complex_filtergraph(FilterGraph *fg);
int copy_av_subtitle(AVSubtitle *dst, const AVSubtitle *src); int copy_av_subtitle(AVSubtitle *dst, const AVSubtitle *src);
/**
* Get our axiliary frame data attached to the frame, allocating it
* if needed.
*/
FrameData *frame_data(AVFrame *frame);
int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame, int keep_reference); int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame, int keep_reference);
int ifilter_send_eof(InputFilter *ifilter, int64_t pts, AVRational tb); int ifilter_send_eof(InputFilter *ifilter, int64_t pts, AVRational tb);
int ifilter_sub2video(InputFilter *ifilter, const AVSubtitle *sub); int ifilter_sub2video(InputFilter *ifilter, const AVSubtitle *sub);

View File

@@ -499,12 +499,11 @@ int dec_packet(InputStream *ist, const AVPacket *pkt, int no_eof)
FrameData *fd; FrameData *fd;
av_assert0(!frame->opaque_ref); av_assert0(!frame->opaque_ref);
frame->opaque_ref = av_buffer_allocz(sizeof(*fd)); fd = frame_data(frame);
if (!frame->opaque_ref) { if (!fd) {
av_frame_unref(frame); av_frame_unref(frame);
report_and_exit(AVERROR(ENOMEM)); report_and_exit(AVERROR(ENOMEM));
} }
fd = (FrameData*)frame->opaque_ref->data;
fd->pts = frame->pts; fd->pts = frame->pts;
fd->tb = dec->pkt_timebase; fd->tb = dec->pkt_timebase;
fd->idx = dec->frame_num - 1; fd->idx = dec->frame_num - 1;