summaryrefslogtreecommitdiff
path: root/libavfilter/f_select.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-03-10 01:30:30 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-03-10 01:40:35 +0100
commita05a44e205d6ae13d5eb1cd8d4ad2dba6ec940b3 (patch)
tree450d7173e72748db59d6cfb7107c688bc825fc9a /libavfilter/f_select.c
parent586ae70ba78e023d16c0c812b05a26c7d423833b (diff)
parent7e350379f87e7f74420b4813170fe808e2313911 (diff)
Merge commit '7e350379f87e7f74420b4813170fe808e2313911'
* commit '7e350379f87e7f74420b4813170fe808e2313911': lavfi: switch to AVFrame. Conflicts: doc/filters.texi libavfilter/af_ashowinfo.c libavfilter/audio.c libavfilter/avfilter.c libavfilter/avfilter.h libavfilter/buffersink.c libavfilter/buffersrc.c libavfilter/buffersrc.h libavfilter/f_select.c libavfilter/f_setpts.c libavfilter/fifo.c libavfilter/split.c libavfilter/src_movie.c libavfilter/version.h libavfilter/vf_aspect.c libavfilter/vf_bbox.c libavfilter/vf_blackframe.c libavfilter/vf_delogo.c libavfilter/vf_drawbox.c libavfilter/vf_drawtext.c libavfilter/vf_fade.c libavfilter/vf_fieldorder.c libavfilter/vf_fps.c libavfilter/vf_frei0r.c libavfilter/vf_gradfun.c libavfilter/vf_hqdn3d.c libavfilter/vf_lut.c libavfilter/vf_overlay.c libavfilter/vf_pad.c libavfilter/vf_scale.c libavfilter/vf_showinfo.c libavfilter/vf_transpose.c libavfilter/vf_vflip.c libavfilter/vf_yadif.c libavfilter/video.c libavfilter/vsrc_testsrc.c libavfilter/yadif.h Following are notes about the merge authorship and various technical details. Michael Niedermayer: * Main merge operation, notably avfilter.c and video.c * Switch to AVFrame: - afade - anullsrc - apad - aresample - blackframe - deshake - idet - il - mandelbrot - mptestsrc - noise - setfield - smartblur - tinterlace * various merge changes and fixes in: - ashowinfo - blackdetect - field - fps - select - testsrc - yadif Nicolas George: * Switch to AVFrame: - make rawdec work with refcounted frames. Adapted from commit 759001c534287a96dc96d1e274665feb7059145d by Anton Khirnov. Also, fix the use of || instead of | in a flags check. - make buffer sink and src, audio and video work all together Clément Bœsch: * Switch to AVFrame: - aevalsrc - alphaextract - blend - cellauto - colormatrix - concat - earwax - ebur128 - edgedetect - geq - histeq - histogram - hue - kerndeint - life - movie - mp (with the help of Michael) - overlay - pad - pan - pp - pp - removelogo - sendcmd - showspectrum - showwaves - silencedetect - stereo3d - subtitles - super2xsai - swapuv - thumbnail - tile Hendrik Leppkes: * Switch to AVFrame: - aconvert - amerge - asetnsamples - atempo - biquads Matthieu Bouron: * Switch to AVFrame - alphamerge - decimate - volumedetect Stefano Sabatini: * Switch to AVFrame: - astreamsync - flite - framestep Signed-off-by: Michael Niedermayer <michaelni@gmx.at> Signed-off-by: Nicolas George <nicolas.george@normalesup.org> Signed-off-by: Clément Bœsch <ubitux@gmail.com> Signed-off-by: Hendrik Leppkes <h.leppkes@gmail.com> Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com> Signed-off-by: Stefano Sabatini <stefasab@gmail.com> Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter/f_select.c')
-rw-r--r--libavfilter/f_select.c59
1 files changed, 29 insertions, 30 deletions
diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c
index 0f211454ef..36ef50744a 100644
--- a/libavfilter/f_select.c
+++ b/libavfilter/f_select.c
@@ -134,7 +134,7 @@ typedef struct {
DSPContext c; ///< context providing optimized SAD methods (scene detect only)
double prev_mafd; ///< previous MAFD (scene detect only)
#endif
- AVFilterBufferRef *prev_picref; ///< previous frame (scene detect only)
+ AVFrame *prev_picref; ///< previous frame (scene detect only)
double select;
} SelectContext;
@@ -219,25 +219,25 @@ static int config_input(AVFilterLink *inlink)
}
#if CONFIG_AVCODEC
-static double get_scene_score(AVFilterContext *ctx, AVFilterBufferRef *picref)
+static double get_scene_score(AVFilterContext *ctx, AVFrame *frame)
{
double ret = 0;
SelectContext *select = ctx->priv;
- AVFilterBufferRef *prev_picref = select->prev_picref;
+ AVFrame *prev_picref = select->prev_picref;
if (prev_picref &&
- picref->video->h == prev_picref->video->h &&
- picref->video->w == prev_picref->video->w &&
- picref->linesize[0] == prev_picref->linesize[0]) {
+ frame->height == prev_picref->height &&
+ frame->width == prev_picref->width &&
+ frame->linesize[0] == prev_picref->linesize[0]) {
int x, y, nb_sad = 0;
int64_t sad = 0;
double mafd, diff;
- uint8_t *p1 = picref->data[0];
+ uint8_t *p1 = frame->data[0];
uint8_t *p2 = prev_picref->data[0];
- const int linesize = picref->linesize[0];
+ const int linesize = frame->linesize[0];
- for (y = 0; y < picref->video->h - 8; y += 8) {
- for (x = 0; x < picref->video->w*3 - 8; x += 8) {
+ for (y = 0; y < frame->height - 8; y += 8) {
+ for (x = 0; x < frame->width*3 - 8; x += 8) {
sad += select->c.sad[1](select, p1 + x, p2 + x,
linesize, 8);
nb_sad += 8 * 8;
@@ -250,9 +250,9 @@ static double get_scene_score(AVFilterContext *ctx, AVFilterBufferRef *picref)
diff = fabs(mafd - select->prev_mafd);
ret = av_clipf(FFMIN(mafd, diff) / 100., 0, 1);
select->prev_mafd = mafd;
- avfilter_unref_buffer(prev_picref);
+ av_frame_free(&prev_picref);
}
- select->prev_picref = avfilter_ref_buffer(picref, ~0);
+ select->prev_picref = av_frame_clone(frame);
return ret;
}
#endif
@@ -260,38 +260,38 @@ static double get_scene_score(AVFilterContext *ctx, AVFilterBufferRef *picref)
#define D2TS(d) (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d))
#define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
-static int select_frame(AVFilterContext *ctx, AVFilterBufferRef *ref)
+static int select_frame(AVFilterContext *ctx, AVFrame *frame)
{
SelectContext *select = ctx->priv;
AVFilterLink *inlink = ctx->inputs[0];
double res;
if (isnan(select->var_values[VAR_START_PTS]))
- select->var_values[VAR_START_PTS] = TS2D(ref->pts);
+ select->var_values[VAR_START_PTS] = TS2D(frame->pts);
if (isnan(select->var_values[VAR_START_T]))
- select->var_values[VAR_START_T] = TS2D(ref->pts) * av_q2d(inlink->time_base);
+ select->var_values[VAR_START_T] = TS2D(frame->pts) * av_q2d(inlink->time_base);
- select->var_values[VAR_PTS] = TS2D(ref->pts);
- select->var_values[VAR_T ] = TS2D(ref->pts) * av_q2d(inlink->time_base);
- select->var_values[VAR_POS] = ref->pos == -1 ? NAN : ref->pos;
+ select->var_values[VAR_PTS] = TS2D(frame->pts);
+ select->var_values[VAR_T ] = TS2D(frame->pts) * av_q2d(inlink->time_base);
+ select->var_values[VAR_POS] = av_frame_get_pkt_pos(frame) == -1 ? NAN : av_frame_get_pkt_pos(frame);
switch (inlink->type) {
case AVMEDIA_TYPE_AUDIO:
- select->var_values[VAR_SAMPLES_N] = ref->audio->nb_samples;
+ select->var_values[VAR_SAMPLES_N] = frame->nb_samples;
break;
case AVMEDIA_TYPE_VIDEO:
select->var_values[VAR_INTERLACE_TYPE] =
- !ref->video->interlaced ? INTERLACE_TYPE_P :
- ref->video->top_field_first ? INTERLACE_TYPE_T : INTERLACE_TYPE_B;
- select->var_values[VAR_PICT_TYPE] = ref->video->pict_type;
+ !frame->interlaced_frame ? INTERLACE_TYPE_P :
+ frame->top_field_first ? INTERLACE_TYPE_T : INTERLACE_TYPE_B;
+ select->var_values[VAR_PICT_TYPE] = frame->pict_type;
#if CONFIG_AVCODEC
if (select->do_scene_detect) {
char buf[32];
- select->var_values[VAR_SCENE] = get_scene_score(ctx, ref);
+ select->var_values[VAR_SCENE] = get_scene_score(ctx, frame);
// TODO: document metadata
snprintf(buf, sizeof(buf), "%f", select->var_values[VAR_SCENE]);
- av_dict_set(&ref->metadata, "lavfi.scene_score", buf, 0);
+ av_dict_set(&frame->metadata, "lavfi.scene_score", buf, 0);
}
#endif
break;
@@ -299,11 +299,10 @@ static int select_frame(AVFilterContext *ctx, AVFilterBufferRef *ref)
res = av_expr_eval(select->expr, select->var_values, NULL);
av_log(inlink->dst, AV_LOG_DEBUG,
- "n:%f pts:%f t:%f pos:%f key:%d",
+ "n:%f pts:%f t:%f key:%d",
select->var_values[VAR_N],
select->var_values[VAR_PTS],
select->var_values[VAR_T],
- select->var_values[VAR_POS],
(int)select->var_values[VAR_KEY]);
switch (inlink->type) {
@@ -330,7 +329,7 @@ static int select_frame(AVFilterContext *ctx, AVFilterBufferRef *ref)
select->var_values[VAR_PREV_SELECTED_T] = select->var_values[VAR_T];
select->var_values[VAR_SELECTED_N] += 1.0;
if (inlink->type == AVMEDIA_TYPE_AUDIO)
- select->var_values[VAR_CONSUMED_SAMPLES_N] += ref->audio->nb_samples;
+ select->var_values[VAR_CONSUMED_SAMPLES_N] += frame->nb_samples;
}
select->var_values[VAR_N] += 1.0;
@@ -340,7 +339,7 @@ static int select_frame(AVFilterContext *ctx, AVFilterBufferRef *ref)
return res;
}
-static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *frame)
+static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
{
SelectContext *select = inlink->dst->priv;
@@ -348,7 +347,7 @@ static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *frame)
if (select->select)
return ff_filter_frame(inlink->dst->outputs[0], frame);
- avfilter_unref_bufferp(&frame);
+ av_frame_free(&frame);
return 0;
}
@@ -378,7 +377,7 @@ static av_cold void uninit(AVFilterContext *ctx)
#if CONFIG_AVCODEC
if (select->do_scene_detect) {
- avfilter_unref_bufferp(&select->prev_picref);
+ av_frame_free(&select->prev_picref);
if (select->avctx) {
avcodec_close(select->avctx);
av_freep(&select->avctx);