History

vsrc_buffer: simplify av_vsrc_buffer_add_frame*() interface

Now that pix_fmt, width, and height are directly embedded in the AVFrame, there is no need to pass these values as separate arguments.

Stefano Sabatini committed 15 years ago

Commit 64c06611 parent 01042d43 files · +11 −33Browse files

Showing the changes to libavfilter/vsrc_buffer.c (1 of 3 files). Show all

Unified · Split

libavfilter/vsrc_buffer.c+8−25
@@ -29,7 +29,6 @@ · 28 unmodified lines
2929 #include "libavutil/imgutils.h"
3030
3131 typedef struct {
32− int64_t pts;
3332 AVFrame frame;
3433 int has_frame;
3534 int h, w;
@@ -40,8 +39,6 @@ typedef struct { · 4 unmodified lines
4039 } BufferSourceContext;
4140
4241 int av_vsrc_buffer_add_frame2(AVFilterContext *buffer_filter, AVFrame *frame,
43− int64_t pts, int width,
44− int height, enum PixelFormat pix_fmt,
4542 const char *sws_param)
4643 {
4744 BufferSourceContext *c = buffer_filter->priv;
@@ -59,14 +56,14 @@ int av_vsrc_buffer_add_frame2(AVFilterContext *buffer_filter, AVFrame *frame, · 11 unmodified lines
5956 snprintf(c->sws_param, 255, "%d:%d:%s", c->w, c->h, sws_param);
6057 }
6158
62− if(width != c->w || height != c->h || pix_fmt != c->pix_fmt){
59+ if (frame->width != c->w || frame->height != c->h || frame->format != c->pix_fmt) {
6360 AVFilterContext *scale= buffer_filter->outputs[0]->dst;
6461 AVFilterLink *link;
6562
6663 av_log(buffer_filter, AV_LOG_INFO,
6764 "Buffer video input changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n",
6865 c->w, c->h, av_pix_fmt_descriptors[c->pix_fmt].name,
69− width, height, av_pix_fmt_descriptors[pix_fmt].name);
66+ frame->width, frame->height, av_pix_fmt_descriptors[frame->format].name);
7067
7168 if(!scale || strcmp(scale->filter->name,"scale")){
7269 AVFilter *f= avfilter_get_by_name("scale");
@@ -92,39 +89,26 @@ int av_vsrc_buffer_add_frame2(AVFilterContext *buffer_filter, AVFrame *frame, · 19 unmodified lines
9289 scale->filter->init(scale, c->sws_param, NULL);
9390 }
9491
95− c->pix_fmt= scale->inputs[0]->format= pix_fmt;
96− c->w= scale->inputs[0]->w= width;
97− c->h= scale->inputs[0]->h= height;
92+ c->pix_fmt = scale->inputs[0]->format = frame->format;
93+ c->w = scale->inputs[0]->w = frame->width;
94+ c->h = scale->inputs[0]->h = frame->height;
9895
9996 link= scale->outputs[0];
10097 if ((ret = link->srcpad->config_props(link)) < 0)
10198 return ret;
10299 }
103100
101+ c->frame = *frame;
104102 memcpy(c->frame.data , frame->data , sizeof(frame->data));
105103 memcpy(c->frame.linesize, frame->linesize, sizeof(frame->linesize));
106− c->frame.width = frame->width;
107− c->frame.height = frame->height;
108− c->frame.format = frame->format;
109− c->frame.interlaced_frame= frame->interlaced_frame;
110− c->frame.top_field_first = frame->top_field_first;
111− c->frame.key_frame = frame->key_frame;
112− c->frame.pict_type = frame->pict_type;
113− c->frame.sample_aspect_ratio = frame->sample_aspect_ratio;
114− c->pts = pts;
115104 c->has_frame = 1;
116105
117106 return 0;
118107 }
119108
120−int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame,
121− int64_t pts)
109+int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame)
122110 {
123− BufferSourceContext *c = buffer_filter->priv;
124−
125− return av_vsrc_buffer_add_frame2(buffer_filter, frame,
126− pts, c->w,
127− c->h, c->pix_fmt, "");
111+ return av_vsrc_buffer_add_frame2(buffer_filter, frame, "");
128112 }
129113
130114 static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
@@ -195,7 +179,6 @@ static int request_frame(AVFilterLink *link) · 64 unmodified lines
195179 c->frame.data, c->frame.linesize,
196180 picref->format, link->w, link->h);
197181 avfilter_copy_frame_props(picref, &c->frame);
198− picref->pts = c->pts;
199182
200183 avfilter_start_frame(link, avfilter_ref_buffer(picref, ~0));
201184 avfilter_draw_slice(link, 0, link->h, 1);

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