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
2357 buf->refcount++;2357 buf->refcount++;
2358 av_buffersrc_buffer(ist->filters[i]->filter, fb);2358 av_buffersrc_buffer(ist->filters[i]->filter, fb);
2359 } else2359 } else
2360 av_vsrc_buffer_add_frame(ist->filters[i]->filter, decoded_frame,2360 av_buffersrc_write_frame(ist->filters[i]->filter, decoded_frame);
2361 decoded_frame->pts, decoded_frame->sample_aspect_ratio);
2362 }2361 }
2363 2362
2364 av_free(buffer_to_free);2363 av_free(buffer_to_free);
libavfilter/buffersrc.c+18−2
@@ -44,8 +44,26 @@ typedef struct { · 43 unmodified lines
44 return AVERROR(EINVAL);\44 return AVERROR(EINVAL);\
45 }45 }
46 46
47#if FF_API_VSRC_BUFFER_ADD_FRAME
47int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame,48int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame,
48 int64_t pts, AVRational pixel_aspect)49 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
66int av_buffersrc_write_frame(AVFilterContext *buffer_filter, AVFrame *frame)
49{67{
50 BufferSourceContext *c = buffer_filter->priv;68 BufferSourceContext *c = buffer_filter->priv;
51 AVFilterBufferRef *buf;69 AVFilterBufferRef *buf;
@@ -70,8 +88,6 @@ int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, · 18 unmodified lines
70 c->pix_fmt, c->w, c->h);88 c->pix_fmt, c->w, c->h);
71 89
72 avfilter_copy_frame_props(buf, frame);90 avfilter_copy_frame_props(buf, frame);
73 buf->pts = pts;
74 buf->video->pixel_aspect = pixel_aspect;
75 91
76 if ((ret = av_fifo_generic_write(c->fifo, &buf, sizeof(buf), NULL)) < 0) {92 if ((ret = av_fifo_generic_write(c->fifo, &buf, sizeof(buf), NULL)) < 0) {
77 avfilter_unref_buffer(buf);93 avfilter_unref_buffer(buf);
libavfilter/buffersrc.h+11−0
@@ -36,4 +36,15 @@ · 35 unmodified lines
36 */36 */
37int av_buffersrc_buffer(AVFilterContext *s, AVFilterBufferRef *buf);37int 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 */
48int av_buffersrc_write_frame(AVFilterContext *s, AVFrame *frame);
49
39#endif /* AVFILTER_BUFFERSRC_H */50#endif /* AVFILTER_BUFFERSRC_H */
libavfilter/version.h+3−0
@@ -50,5 +50,8 @@ · 49 unmodified lines
50#ifndef FF_API_SAMPLERATE6450#ifndef FF_API_SAMPLERATE64
51#define FF_API_SAMPLERATE64 (LIBAVFILTER_VERSION_MAJOR < 3)51#define FF_API_SAMPLERATE64 (LIBAVFILTER_VERSION_MAJOR < 3)
52#endif52#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#endif // AVFILTER_VERSION_H57#endif // AVFILTER_VERSION_H
libavfilter/vsrc_buffer.h+2−0
@@ -29,7 +29,9 @@ · 28 unmodified lines
29#include "libavcodec/avcodec.h" /* AVFrame */29#include "libavcodec/avcodec.h" /* AVFrame */
30#include "avfilter.h"30#include "avfilter.h"
31 31
32#if FF_API_VSRC_BUFFER_ADD_FRAME
32int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame,33int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame,
33 int64_t pts, AVRational pixel_aspect);34 int64_t pts, AVRational pixel_aspect);
35#endif
34 36
35#endif /* AVFILTER_VSRC_BUFFER_H */37#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