History

buffersrc: add av_buffersrc_write_frame().

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().

Anton Khirnov committed 14 years ago

Commit 720c6b71 parent 8b05e135 files · +35 −4Browse files

Unified · Split

5 files
  1. avconv.c +1 −2
  2. libavfilter/buffersrc.c +18 −2
  3. libavfilter/buffersrc.h +11 −0
  4. libavfilter/version.h +3 −0
  5. libavfilter/vsrc_buffer.h +2 −0
avconv.c+1−2
@@ -2357,8 +2357,7 @@ static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int · 2356 unmodified lines
23572357 buf->refcount++;
23582358 av_buffersrc_buffer(ist->filters[i]->filter, fb);
23592359 } 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);
23622361 }
23632362
23642363 av_free(buffer_to_free);
libavfilter/buffersrc.c+18−2
@@ -44,8 +44,26 @@ typedef struct { · 43 unmodified lines
4444 return AVERROR(EINVAL);\
4545 }
4646
47+#if FF_API_VSRC_BUFFER_ADD_FRAME
4748 int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame,
4849 int64_t pts, AVRational pixel_aspect)
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)
4967 {
5068 BufferSourceContext *c = buffer_filter->priv;
5169 AVFilterBufferRef *buf;
@@ -70,8 +88,6 @@ int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, · 18 unmodified lines
7088 c->pix_fmt, c->w, c->h);
7189
7290 avfilter_copy_frame_props(buf, frame);
73− buf->pts = pts;
74− buf->video->pixel_aspect = pixel_aspect;
7591
7692 if ((ret = av_fifo_generic_write(c->fifo, &buf, sizeof(buf), NULL)) < 0) {
7793 avfilter_unref_buffer(buf);
libavfilter/buffersrc.h+11−0
@@ -36,4 +36,15 @@ · 35 unmodified lines
3636 */
3737 int av_buffersrc_buffer(AVFilterContext *s, AVFilterBufferRef *buf);
3838
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+
3950 #endif /* AVFILTER_BUFFERSRC_H */
libavfilter/version.h+3−0
@@ -50,5 +50,8 @@ · 49 unmodified lines
5050 #ifndef FF_API_SAMPLERATE64
5151 #define FF_API_SAMPLERATE64 (LIBAVFILTER_VERSION_MAJOR < 3)
5252 #endif
53+#ifndef FF_API_VSRC_BUFFER_ADD_FRAME
54+#define FF_API_VSRC_BUFFER_ADD_FRAME (LIBAVFILTER_VERSION_MAJOR < 3)
55+#endif
5356
5457 #endif // AVFILTER_VERSION_H
libavfilter/vsrc_buffer.h+2−0
@@ -29,7 +29,9 @@ · 28 unmodified lines
2929 #include "libavcodec/avcodec.h" /* AVFrame */
3030 #include "avfilter.h"
3131
32+#if FF_API_VSRC_BUFFER_ADD_FRAME
3233 int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame,
3334 int64_t pts, AVRational pixel_aspect);
35+#endif
3436
3537 #endif /* AVFILTER_VSRC_BUFFER_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t