aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-07-21 22:19:19 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-07-21 22:20:49 +0200
commit9e1508f1e7a21aab9c25614c03d726e400c5691c (patch)
tree1450ec6130c71c5d1867b43c5333b0afc2e62212
parentf7e0c1854950b072dce4aa21053c1a344bf76c72 (diff)
parent4c9080a7ef18ad71fb0a75c8d1c1803edd780edd (diff)
downloadffmpeg-9e1508f1e7a21aab9c25614c03d726e400c5691c.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: lavfi: unref AVFilterLink.out_buf in ff_end_frame(). lavfi: unref AVFilterLink.cur_buf in ff_end_frame(). vsrc_testsrc: avoid an unnecessary avfilter_ref_buffer(). vf_slicify: clear AVFilterLink.cur_buf in start_frame(). vf_settb: simplify start_frame(). vf_fieldorder: don't give up its own reference to the output buffer. vf_pad: don't give up its own reference to the output buffer. vf_overlay: don't access a buffer reference that's been given away. vf_drawtext: don't give up its own reference to the input buffer. vf_gradfun: don't store two pointers to one AVFilterBufferRef. vf_delogo: don't store two pointers to one AVFilterBufferRef. vf_aspect: clear AVFilterLink.cur_buf in start_frame(). lavfi: add avfilter_unref_bufferp() Conflicts: doc/APIchanges libavfilter/avfilter.h libavfilter/buffer.c libavfilter/vf_aspect.c libavfilter/vf_drawtext.c libavfilter/vf_overlay.c libavfilter/vf_pad.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavfilter/avfilter.h4
-rw-r--r--libavfilter/f_settb.c13
-rw-r--r--libavfilter/fifo.c1
-rw-r--r--libavfilter/split.c2
-rw-r--r--libavfilter/vf_aspect.c1
-rw-r--r--libavfilter/vf_bbox.c1
-rw-r--r--libavfilter/vf_blackdetect.c1
-rw-r--r--libavfilter/vf_blackframe.c1
-rw-r--r--libavfilter/vf_colormatrix.c1
-rw-r--r--libavfilter/vf_crop.c1
-rw-r--r--libavfilter/vf_delogo.c7
-rw-r--r--libavfilter/vf_deshake.c1
-rw-r--r--libavfilter/vf_fieldorder.c6
-rw-r--r--libavfilter/vf_fps.c1
-rw-r--r--libavfilter/vf_frei0r.c2
-rw-r--r--libavfilter/vf_gradfun.c5
-rw-r--r--libavfilter/vf_hqdn3d.c2
-rw-r--r--libavfilter/vf_libopencv.c2
-rw-r--r--libavfilter/vf_mp.c2
-rw-r--r--libavfilter/vf_overlay.c3
-rw-r--r--libavfilter/vf_pad.c4
-rw-r--r--libavfilter/vf_removelogo.c3
-rw-r--r--libavfilter/vf_select.c2
-rw-r--r--libavfilter/vf_showinfo.c1
-rw-r--r--libavfilter/vf_slicify.c1
-rw-r--r--libavfilter/vf_super2xsai.c2
-rw-r--r--libavfilter/vf_transpose.c2
-rw-r--r--libavfilter/vf_unsharp.c2
-rw-r--r--libavfilter/video.c19
-rw-r--r--libavfilter/vsrc_testsrc.c5
30 files changed, 33 insertions, 65 deletions
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index f039c1e228..4d3a7a82d1 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -196,6 +196,9 @@ AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask);
* buffer, the buffer itself is also automatically freed.
*
* @param ref reference to the buffer, may be NULL
+ *
+ * @note it is recommended to use avfilter_unref_bufferp() instead of this
+ * function
*/
void avfilter_unref_buffer(AVFilterBufferRef *ref);
@@ -208,7 +211,6 @@ void avfilter_unref_buffer(AVFilterBufferRef *ref);
*/
void avfilter_unref_bufferp(AVFilterBufferRef **ref);
-
#if FF_API_AVFILTERPAD_PUBLIC
/**
* A filter pad used for either input or output.
diff --git a/libavfilter/f_settb.c b/libavfilter/f_settb.c
index 3ba35be70e..9aed96468d 100644
--- a/libavfilter/f_settb.c
+++ b/libavfilter/f_settb.c
@@ -103,18 +103,17 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
{
AVFilterContext *ctx = inlink->dst;
AVFilterLink *outlink = ctx->outputs[0];
- AVFilterBufferRef *picref2 = picref;
if (av_cmp_q(inlink->time_base, outlink->time_base)) {
- picref2 = avfilter_ref_buffer(picref, ~0);
- picref2->pts = av_rescale_q(picref->pts, inlink->time_base, outlink->time_base);
+ int64_t orig_pts = picref->pts;
+ picref->pts = av_rescale_q(picref->pts, inlink->time_base, outlink->time_base);
av_log(ctx, AV_LOG_DEBUG, "tb:%d/%d pts:%"PRId64" -> tb:%d/%d pts:%"PRId64"\n",
- inlink ->time_base.num, inlink ->time_base.den, picref ->pts,
- outlink->time_base.num, outlink->time_base.den, picref2->pts);
- avfilter_unref_buffer(picref);
+ inlink ->time_base.num, inlink ->time_base.den, orig_pts,
+ outlink->time_base.num, outlink->time_base.den, picref->pts);
}
+ inlink->cur_buf = NULL;
- ff_start_frame(outlink, picref2);
+ ff_start_frame(outlink, picref);
}
static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples)
diff --git a/libavfilter/fifo.c b/libavfilter/fifo.c
index 34db5ecbee..bb7f0fab85 100644
--- a/libavfilter/fifo.c
+++ b/libavfilter/fifo.c
@@ -91,6 +91,7 @@ static int add_to_queue(AVFilterLink *inlink, AVFilterBufferRef *buf)
static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *buf)
{
add_to_queue(inlink, buf);
+ inlink->cur_buf = NULL;
}
static void queue_pop(FifoContext *s)
diff --git a/libavfilter/split.c b/libavfilter/split.c
index 98be342bfc..c42a8abf8d 100644
--- a/libavfilter/split.c
+++ b/libavfilter/split.c
@@ -89,8 +89,6 @@ static void end_frame(AVFilterLink *inlink)
for (i = 0; i < ctx->nb_outputs; i++)
ff_end_frame(ctx->outputs[i]);
-
- avfilter_unref_buffer(inlink->cur_buf);
}
AVFilter avfilter_vf_split = {
diff --git a/libavfilter/vf_aspect.c b/libavfilter/vf_aspect.c
index 76bc490356..6e639c1480 100644
--- a/libavfilter/vf_aspect.c
+++ b/libavfilter/vf_aspect.c
@@ -56,6 +56,7 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
AspectContext *aspect = link->dst->priv;
picref->video->sample_aspect_ratio = aspect->ratio;
+ link->cur_buf = NULL;
ff_start_frame(link->dst->outputs[0], picref);
}
diff --git a/libavfilter/vf_bbox.c b/libavfilter/vf_bbox.c
index 99066a674f..47d4709dc4 100644
--- a/libavfilter/vf_bbox.c
+++ b/libavfilter/vf_bbox.c
@@ -86,7 +86,6 @@ static void end_frame(AVFilterLink *inlink)
av_log(ctx, AV_LOG_INFO, "\n");
bbox->frame++;
- avfilter_unref_buffer(picref);
ff_end_frame(inlink->dst->outputs[0]);
}
diff --git a/libavfilter/vf_blackdetect.c b/libavfilter/vf_blackdetect.c
index 85a13f2844..cd35297845 100644
--- a/libavfilter/vf_blackdetect.c
+++ b/libavfilter/vf_blackdetect.c
@@ -194,7 +194,6 @@ static void end_frame(AVFilterLink *inlink)
blackdetect->last_picref_pts = picref->pts;
blackdetect->frame_count++;
blackdetect->nb_black_pixels = 0;
- avfilter_unref_buffer(picref);
ff_end_frame(inlink->dst->outputs[0]);
}
diff --git a/libavfilter/vf_blackframe.c b/libavfilter/vf_blackframe.c
index e41f1f4d8c..2c842deeb7 100644
--- a/libavfilter/vf_blackframe.c
+++ b/libavfilter/vf_blackframe.c
@@ -114,7 +114,6 @@ static void end_frame(AVFilterLink *inlink)
blackframe->frame++;
blackframe->nblack = 0;
- avfilter_unref_buffer(picref);
ff_end_frame(inlink->dst->outputs[0]);
}
diff --git a/libavfilter/vf_colormatrix.c b/libavfilter/vf_colormatrix.c
index bc423621ec..d6f6dbd721 100644
--- a/libavfilter/vf_colormatrix.c
+++ b/libavfilter/vf_colormatrix.c
@@ -366,7 +366,6 @@ static void end_frame(AVFilterLink *link)
ff_draw_slice(ctx->outputs[0], 0, link->dst->outputs[0]->h, 1);
ff_end_frame(ctx->outputs[0]);
- avfilter_unref_buffer(link->cur_buf);
}
static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { }
diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c
index 915806bdaa..18ad88f585 100644
--- a/libavfilter/vf_crop.c
+++ b/libavfilter/vf_crop.c
@@ -336,7 +336,6 @@ static void end_frame(AVFilterLink *link)
CropContext *crop = link->dst->priv;
crop->var_values[VAR_N] += 1.0;
- avfilter_unref_buffer(link->cur_buf);
ff_end_frame(link->dst->outputs[0]);
}
diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c
index 996609da4a..35ceb35fd9 100644
--- a/libavfilter/vf_delogo.c
+++ b/libavfilter/vf_delogo.c
@@ -221,7 +221,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
outpicref->video->w = outlink->w;
outpicref->video->h = outlink->h;
} else
- outpicref = inpicref;
+ outpicref = avfilter_ref_buffer(inpicref, ~0);
outlink->out_buf = outpicref;
ff_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0));
@@ -235,7 +235,7 @@ static void end_frame(AVFilterLink *inlink)
AVFilterLink *outlink = inlink->dst->outputs[0];
AVFilterBufferRef *inpicref = inlink ->cur_buf;
AVFilterBufferRef *outpicref = outlink->out_buf;
- int direct = inpicref == outpicref;
+ int direct = inpicref->buf == outpicref->buf;
int hsub0 = av_pix_fmt_descriptors[inlink->format].log2_chroma_w;
int vsub0 = av_pix_fmt_descriptors[inlink->format].log2_chroma_h;
int plane;
@@ -255,9 +255,6 @@ static void end_frame(AVFilterLink *inlink)
ff_draw_slice(outlink, 0, inlink->h, 1);
ff_end_frame(outlink);
- avfilter_unref_buffer(inpicref);
- if (!direct)
- avfilter_unref_buffer(outpicref);
}
AVFilter avfilter_vf_delogo = {
diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c
index 45da72b079..70d7fe91bc 100644
--- a/libavfilter/vf_deshake.c
+++ b/libavfilter/vf_deshake.c
@@ -530,7 +530,6 @@ static void end_frame(AVFilterLink *link)
// Draw the transformed frame information
ff_draw_slice(link->dst->outputs[0], 0, link->h, 1);
ff_end_frame(link->dst->outputs[0]);
- avfilter_unref_buffer(out);
}
static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
diff --git a/libavfilter/vf_fieldorder.c b/libavfilter/vf_fieldorder.c
index 4f657358d4..be753be9dc 100644
--- a/libavfilter/vf_fieldorder.c
+++ b/libavfilter/vf_fieldorder.c
@@ -121,12 +121,13 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
AVFilterContext *ctx = inlink->dst;
AVFilterLink *outlink = ctx->outputs[0];
- AVFilterBufferRef *outpicref;
+ AVFilterBufferRef *outpicref, *for_next_filter;
outpicref = avfilter_ref_buffer(inpicref, ~0);
outlink->out_buf = outpicref;
- ff_start_frame(outlink, outpicref);
+ for_next_filter = avfilter_ref_buffer(outpicref, ~0);
+ ff_start_frame(outlink, for_next_filter);
}
static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
@@ -212,7 +213,6 @@ static void end_frame(AVFilterLink *inlink)
}
ff_end_frame(outlink);
- avfilter_unref_buffer(inpicref);
}
AVFilter avfilter_vf_fieldorder = {
diff --git a/libavfilter/vf_fps.c b/libavfilter/vf_fps.c
index 8734a9acde..16122def70 100644
--- a/libavfilter/vf_fps.c
+++ b/libavfilter/vf_fps.c
@@ -175,6 +175,7 @@ static void end_frame(AVFilterLink *inlink)
int64_t delta;
int i;
+ inlink->cur_buf = NULL;
s->frames_in++;
/* discard frames until we get the first timestamp */
if (s->pts == AV_NOPTS_VALUE) {
diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c
index 99594551f8..f367264986 100644
--- a/libavfilter/vf_frei0r.c
+++ b/libavfilter/vf_frei0r.c
@@ -352,10 +352,8 @@ static void end_frame(AVFilterLink *inlink)
frei0r->update(frei0r->instance, inpicref->pts * av_q2d(inlink->time_base) * 1000,
(const uint32_t *)inpicref->data[0],
(uint32_t *)outpicref->data[0]);
- avfilter_unref_buffer(inpicref);
ff_draw_slice(outlink, 0, outlink->h, 1);
ff_end_frame(outlink);
- avfilter_unref_buffer(outpicref);
}
AVFilter avfilter_vf_frei0r = {
diff --git a/libavfilter/vf_gradfun.c b/libavfilter/vf_gradfun.c
index 4b3a59fd17..a35e3b09cd 100644
--- a/libavfilter/vf_gradfun.c
+++ b/libavfilter/vf_gradfun.c
@@ -191,7 +191,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
outpicref->video->w = outlink->w;
outpicref->video->h = outlink->h;
} else
- outpicref = inpicref;
+ outpicref = avfilter_ref_buffer(inpicref, ~0);
outlink->out_buf = outpicref;
ff_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0));
@@ -225,9 +225,6 @@ static void end_frame(AVFilterLink *inlink)
ff_draw_slice(outlink, 0, inlink->h, 1);
ff_end_frame(outlink);
- avfilter_unref_buffer(inpic);
- if (outpic != inpic)
- avfilter_unref_buffer(outpic);
}
AVFilter avfilter_vf_gradfun = {
diff --git a/libavfilter/vf_hqdn3d.c b/libavfilter/vf_hqdn3d.c
index 62e197dea7..c18bb8fb93 100644
--- a/libavfilter/vf_hqdn3d.c
+++ b/libavfilter/vf_hqdn3d.c
@@ -322,8 +322,6 @@ static void end_frame(AVFilterLink *inlink)
ff_draw_slice(outlink, 0, inpic->video->h, 1);
ff_end_frame(outlink);
- avfilter_unref_buffer(inpic);
- avfilter_unref_buffer(outpic);
}
AVFilter avfilter_vf_hqdn3d = {
diff --git a/libavfilter/vf_libopencv.c b/libavfilter/vf_libopencv.c
index 3c6f645431..b7c73dbc20 100644
--- a/libavfilter/vf_libopencv.c
+++ b/libavfilter/vf_libopencv.c
@@ -365,10 +365,8 @@ static void end_frame(AVFilterLink *inlink)
ocv->end_frame_filter(ctx, &inimg, &outimg);
fill_picref_from_iplimage(outpicref, &outimg, inlink->format);
- avfilter_unref_buffer(inpicref);
ff_draw_slice(outlink, 0, outlink->h, 1);
ff_end_frame(outlink);
- avfilter_unref_buffer(outpicref);
}
AVFilter avfilter_vf_ocv = {
diff --git a/libavfilter/vf_mp.c b/libavfilter/vf_mp.c
index 0cf2b79fd4..8ae89475b1 100644
--- a/libavfilter/vf_mp.c
+++ b/libavfilter/vf_mp.c
@@ -883,8 +883,6 @@ static void end_frame(AVFilterLink *inlink)
av_log(m->avfctx, AV_LOG_DEBUG, "put_image() says skip\n");
}
free_mp_image(mpi);
-
- avfilter_unref_buffer(inpic);
}
AVFilter avfilter_vf_mp = {
diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index 6736b06c31..680e074019 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -497,7 +497,6 @@ static int try_push_frame(AVFilterContext *ctx)
over->overpicref->video->w, over->overpicref->video->h,
0, outpicref->video->w, outpicref->video->h);
ff_draw_slice(outlink, 0, outpicref->video->h, +1);
- avfilter_unref_bufferp(&outlink->out_buf);
ff_end_frame(outlink);
return 0;
}
@@ -546,8 +545,6 @@ static void end_frame_main(AVFilterLink *inlink)
if (!outpicref)
return;
- avfilter_unref_bufferp(&inlink->cur_buf);
- avfilter_unref_bufferp(&outlink->out_buf);
ff_end_frame(ctx->outputs[0]);
}
diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c
index aeff4241d0..ba7020a0e9 100644
--- a/libavfilter/vf_pad.c
+++ b/libavfilter/vf_pad.c
@@ -263,6 +263,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
{
PadContext *pad = inlink->dst->priv;
AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0);
+ AVFilterBufferRef *for_next_filter;
int plane;
for (plane = 0; plane < 4 && outpicref->data[plane] && pad->draw.pixelstep[plane]; plane++) {
@@ -299,7 +300,8 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
outpicref->video->w = pad->w;
outpicref->video->h = pad->h;
- ff_start_frame(inlink->dst->outputs[0], avfilter_ref_buffer(outpicref, ~0));
+ for_next_filter = avfilter_ref_buffer(outpicref, ~0);
+ ff_start_frame(inlink->dst->outputs[0], for_next_filter);
}
static void draw_send_bar_slice(AVFilterLink *link, int y, int h, int slice_dir, int before_slice)
diff --git a/libavfilter/vf_removelogo.c b/libavfilter/vf_removelogo.c
index 2e395c7eea..df67193fd3 100644
--- a/libavfilter/vf_removelogo.c
+++ b/libavfilter/vf_removelogo.c
@@ -516,9 +516,6 @@ static void end_frame(AVFilterLink *inlink)
ff_draw_slice(outlink, 0, inlink->h, 1);
ff_end_frame(outlink);
- avfilter_unref_buffer(inpicref);
- if (!direct)
- avfilter_unref_buffer(outpicref);
}
static void uninit(AVFilterContext *ctx)
diff --git a/libavfilter/vf_select.c b/libavfilter/vf_select.c
index 9d2217102c..b187fa3d7c 100644
--- a/libavfilter/vf_select.c
+++ b/libavfilter/vf_select.c
@@ -300,14 +300,12 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
static void end_frame(AVFilterLink *inlink)
{
SelectContext *select = inlink->dst->priv;
- AVFilterBufferRef *picref = inlink->cur_buf;
if (select->select) {
if (select->cache_frames)
return;
ff_end_frame(inlink->dst->outputs[0]);
}
- avfilter_unref_buffer(picref);
}
static int request_frame(AVFilterLink *outlink)
diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 2c03177f1e..fb522a343c 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -81,7 +81,6 @@ static void end_frame(AVFilterLink *inlink)
av_log(ctx, AV_LOG_INFO, "]\n");
showinfo->frame++;
- avfilter_unref_buffer(picref);
ff_end_frame(inlink->dst->outputs[0]);
}
diff --git a/libavfilter/vf_slicify.c b/libavfilter/vf_slicify.c
index 1b43a82a53..0c924ac608 100644
--- a/libavfilter/vf_slicify.c
+++ b/libavfilter/vf_slicify.c
@@ -73,6 +73,7 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
slice->h = FFMAX(8, slice->h & (-1 << slice->vshift));
av_log(link->dst, AV_LOG_DEBUG, "h:%d\n", slice->h);
+ link->cur_buf = NULL;
ff_start_frame(link->dst->outputs[0], picref);
}
diff --git a/libavfilter/vf_super2xsai.c b/libavfilter/vf_super2xsai.c
index b941358c72..cbd9fcbff8 100644
--- a/libavfilter/vf_super2xsai.c
+++ b/libavfilter/vf_super2xsai.c
@@ -314,10 +314,8 @@ static void end_frame(AVFilterLink *inlink)
outpicref->data[0], outpicref->linesize[0],
inlink->w, inlink->h);
- avfilter_unref_buffer(inpicref);
ff_draw_slice(outlink, 0, outlink->h, 1);
ff_end_frame(outlink);
- avfilter_unref_buffer(outpicref);
}
AVFilter avfilter_vf_super2xsai = {
diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c
index bd3d038cec..b5a742c161 100644
--- a/libavfilter/vf_transpose.c
+++ b/libavfilter/vf_transpose.c
@@ -189,10 +189,8 @@ static void end_frame(AVFilterLink *inlink)
}
}
- avfilter_unref_buffer(inpic);
ff_draw_slice(outlink, 0, outpic->video->h, 1);
ff_end_frame(outlink);
- avfilter_unref_buffer(outpic);
}
static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { }
diff --git a/libavfilter/vf_unsharp.c b/libavfilter/vf_unsharp.c
index 4feea8f12f..53381f5acf 100644
--- a/libavfilter/vf_unsharp.c
+++ b/libavfilter/vf_unsharp.c
@@ -225,10 +225,8 @@ static void end_frame(AVFilterLink *link)
apply_unsharp(out->data[1], out->linesize[1], in->data[1], in->linesize[1], cw, ch, &unsharp->chroma);
apply_unsharp(out->data[2], out->linesize[2], in->data[2], in->linesize[2], cw, ch, &unsharp->chroma);
- avfilter_unref_buffer(in);
ff_draw_slice(link->dst->outputs[0], 0, link->h, 1);
ff_end_frame(link->dst->outputs[0]);
- avfilter_unref_buffer(out);
}
static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
diff --git a/libavfilter/video.c b/libavfilter/video.c
index 4e3de8d4b0..0eed22129a 100644
--- a/libavfilter/video.c
+++ b/libavfilter/video.c
@@ -151,7 +151,8 @@ AVFilterBufferRef *ff_get_video_buffer(AVFilterLink *link, int perms, int w, int
void ff_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
{
- ff_start_frame(link->dst->outputs[0], picref);
+ AVFilterBufferRef *buf_out = avfilter_ref_buffer(picref, ~0);
+ ff_start_frame(link->dst->outputs[0], buf_out);
}
static void default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
@@ -178,6 +179,7 @@ void ff_start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
AVFilterPad *dst = link->dstpad;
int perms = picref->perms;
AVFilterCommand *cmd= link->dst->command_queue;
+ int64_t pts;
FF_TPRINTF_START(NULL, start_frame); ff_tlog_link(NULL, link, 0); ff_tlog(NULL, " "); ff_tlog_ref(NULL, picref, 1);
@@ -212,9 +214,9 @@ void ff_start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
ff_command_queue_pop(link->dst);
cmd= link->dst->command_queue;
}
-
+ pts = link->cur_buf->pts;
start_frame(link, link->cur_buf);
- ff_update_link_current_pts(link, link->cur_buf->pts);
+ ff_update_link_current_pts(link,link->cur_buf ? link->cur_buf->pts : pts);
}
void ff_null_start_frame_keep_ref(AVFilterLink *inlink,
@@ -235,14 +237,7 @@ static void default_end_frame(AVFilterLink *inlink)
if (inlink->dst->nb_outputs)
outlink = inlink->dst->outputs[0];
- avfilter_unref_buffer(inlink->cur_buf);
- inlink->cur_buf = NULL;
-
if (outlink) {
- if (outlink->out_buf) {
- avfilter_unref_buffer(outlink->out_buf);
- outlink->out_buf = NULL;
- }
ff_end_frame(outlink);
}
}
@@ -262,6 +257,10 @@ void ff_end_frame(AVFilterLink *link)
avfilter_unref_buffer(link->src_buf);
link->src_buf = NULL;
}
+ if(link->cur_buf != link->out_buf)
+ avfilter_unref_bufferp(&link->cur_buf);
+ link->cur_buf = NULL;
+ avfilter_unref_bufferp(&link->out_buf);
}
void ff_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c
index a920314d1b..e5681c8e70 100644
--- a/libavfilter/vsrc_testsrc.c
+++ b/libavfilter/vsrc_testsrc.c
@@ -147,10 +147,9 @@ static int request_frame(AVFilterLink *outlink)
test->fill_picture_fn(outlink->src, picref);
test->nb_frame++;
- ff_start_frame(outlink, avfilter_ref_buffer(picref, ~0));
- ff_draw_slice(outlink, 0, picref->video->h, 1);
+ ff_start_frame(outlink, picref);
+ ff_draw_slice(outlink, 0, test->h, 1);
ff_end_frame(outlink);
- avfilter_unref_buffer(picref);
return 0;
}