@@ -431,6 +431,17 @@ InputStream *ist_iter(InputStream *prev)
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)
{
const AVDictionaryEntry *t = NULL;
@@ -737,6 +737,12 @@ int init_complex_filtergraph(FilterGraph *fg);
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_eof(InputFilter *ifilter, int64_t pts, AVRational tb);
int ifilter_sub2video(InputFilter *ifilter, const AVSubtitle *sub);
@@ -499,12 +499,11 @@ int dec_packet(InputStream *ist, const AVPacket *pkt, int no_eof)
FrameData *fd;
av_assert0(!frame->opaque_ref);
- frame->opaque_ref = av_buffer_allocz(sizeof(*fd));
- if (!frame->opaque_ref) {
+ fd = frame_data(frame);
+ if (!fd) {
av_frame_unref(frame);
report_and_exit(AVERROR(ENOMEM));
}
- fd = (FrameData*)frame->opaque_ref->data;
fd->pts = frame->pts;
fd->tb = dec->pkt_timebase;
fd->idx = dec->frame_num - 1;