It's the same as av_vsrc_buffer_add_frame(), except it doesn't take pts
or pixel_aspect parameters. Those are read from AVFrame.
Deprecate av_vsrc_buffer_add_frame().
... | ... |
@@ -2357,8 +2357,7 @@ static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int |
2357 | 2357 |
buf->refcount++; |
2358 | 2358 |
av_buffersrc_buffer(ist->filters[i]->filter, fb); |
2359 | 2359 |
} else |
2360 |
- av_vsrc_buffer_add_frame(ist->filters[i]->filter, decoded_frame, |
|
2361 |
- decoded_frame->pts, decoded_frame->sample_aspect_ratio); |
|
2360 |
+ av_buffersrc_write_frame(ist->filters[i]->filter, decoded_frame); |
|
2362 | 2361 |
} |
2363 | 2362 |
|
2364 | 2363 |
av_free(buffer_to_free); |
... | ... |
@@ -44,9 +44,27 @@ typedef struct { |
44 | 44 |
return AVERROR(EINVAL);\ |
45 | 45 |
} |
46 | 46 |
|
47 |
+#if FF_API_VSRC_BUFFER_ADD_FRAME |
|
47 | 48 |
int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, |
48 | 49 |
int64_t pts, AVRational pixel_aspect) |
49 | 50 |
{ |
51 |
+ int64_t orig_pts = frame->pts; |
|
52 |
+ AVRational orig_sar = frame->sample_aspect_ratio; |
|
53 |
+ int ret; |
|
54 |
+ |
|
55 |
+ frame->pts = pts; |
|
56 |
+ frame->sample_aspect_ratio = pixel_aspect; |
|
57 |
+ if ((ret = av_buffersrc_write_frame(buffer_filter, frame)) < 0) |
|
58 |
+ return ret; |
|
59 |
+ frame->pts = orig_pts; |
|
60 |
+ frame->sample_aspect_ratio = orig_sar; |
|
61 |
+ |
|
62 |
+ return 0; |
|
63 |
+} |
|
64 |
+#endif |
|
65 |
+ |
|
66 |
+int av_buffersrc_write_frame(AVFilterContext *buffer_filter, AVFrame *frame) |
|
67 |
+{ |
|
50 | 68 |
BufferSourceContext *c = buffer_filter->priv; |
51 | 69 |
AVFilterBufferRef *buf; |
52 | 70 |
int ret; |
... | ... |
@@ -70,8 +88,6 @@ int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, |
70 | 70 |
c->pix_fmt, c->w, c->h); |
71 | 71 |
|
72 | 72 |
avfilter_copy_frame_props(buf, frame); |
73 |
- buf->pts = pts; |
|
74 |
- buf->video->pixel_aspect = pixel_aspect; |
|
75 | 73 |
|
76 | 74 |
if ((ret = av_fifo_generic_write(c->fifo, &buf, sizeof(buf), NULL)) < 0) { |
77 | 75 |
avfilter_unref_buffer(buf); |
... | ... |
@@ -36,4 +36,15 @@ |
36 | 36 |
*/ |
37 | 37 |
int av_buffersrc_buffer(AVFilterContext *s, AVFilterBufferRef *buf); |
38 | 38 |
|
39 |
+/** |
|
40 |
+ * Add a frame to the buffer source. |
|
41 |
+ * |
|
42 |
+ * @param s an instance of the buffersrc filter. |
|
43 |
+ * @param frame frame to be added. |
|
44 |
+ * |
|
45 |
+ * @warning frame data will be memcpy()ed, which may be a big performance |
|
46 |
+ * hit. Use av_buffersrc_buffer() to avoid copying the data. |
|
47 |
+ */ |
|
48 |
+int av_buffersrc_write_frame(AVFilterContext *s, AVFrame *frame); |
|
49 |
+ |
|
39 | 50 |
#endif /* AVFILTER_BUFFERSRC_H */ |
... | ... |
@@ -50,5 +50,8 @@ |
50 | 50 |
#ifndef FF_API_SAMPLERATE64 |
51 | 51 |
#define FF_API_SAMPLERATE64 (LIBAVFILTER_VERSION_MAJOR < 3) |
52 | 52 |
#endif |
53 |
+#ifndef FF_API_VSRC_BUFFER_ADD_FRAME |
|
54 |
+#define FF_API_VSRC_BUFFER_ADD_FRAME (LIBAVFILTER_VERSION_MAJOR < 3) |
|
55 |
+#endif |
|
53 | 56 |
|
54 | 57 |
#endif // AVFILTER_VERSION_H |
... | ... |
@@ -29,7 +29,9 @@ |
29 | 29 |
#include "libavcodec/avcodec.h" /* AVFrame */ |
30 | 30 |
#include "avfilter.h" |
31 | 31 |
|
32 |
+#if FF_API_VSRC_BUFFER_ADD_FRAME |
|
32 | 33 |
int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, |
33 | 34 |
int64_t pts, AVRational pixel_aspect); |
35 |
+#endif |
|
34 | 36 |
|
35 | 37 |
#endif /* AVFILTER_VSRC_BUFFER_H */ |