You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avfilter/avf_showcwt: refactor code into function
This commit is contained in:
@@ -656,39 +656,13 @@ static int config_output(AVFilterLink *outlink)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int activate(AVFilterContext *ctx)
|
static int output_frame(AVFilterContext *ctx)
|
||||||
{
|
{
|
||||||
AVFilterLink *inlink = ctx->inputs[0];
|
|
||||||
AVFilterLink *outlink = ctx->outputs[0];
|
AVFilterLink *outlink = ctx->outputs[0];
|
||||||
|
AVFilterLink *inlink = ctx->inputs[0];
|
||||||
ShowCWTContext *s = ctx->priv;
|
ShowCWTContext *s = ctx->priv;
|
||||||
int ret = 0, status;
|
|
||||||
int64_t pts;
|
|
||||||
|
|
||||||
FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
|
|
||||||
|
|
||||||
if (s->outpicref) {
|
|
||||||
AVFrame *fin;
|
|
||||||
|
|
||||||
if (s->ihop_index == 0) {
|
|
||||||
ret = ff_inlink_consume_samples(inlink, 1, s->hop_size - s->hop_index, &fin);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (ret > 0) {
|
|
||||||
for (int ch = 0; ch < s->nb_channels; ch++)
|
|
||||||
run_channel_cwt_prepare(ctx, fin, ch,
|
|
||||||
ff_outlink_get_status(inlink));
|
|
||||||
|
|
||||||
if (s->hop_index == 0)
|
|
||||||
s->in_pts = fin->pts;
|
|
||||||
s->hop_index += fin->nb_samples;
|
|
||||||
av_frame_free(&fin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s->hop_index >= s->hop_size || s->ihop_index > 0) {
|
|
||||||
int64_t pts_offset;
|
int64_t pts_offset;
|
||||||
|
int ret;
|
||||||
s->hop_index = 0;
|
|
||||||
|
|
||||||
switch (s->slide) {
|
switch (s->slide) {
|
||||||
case SLIDE_SCROLL:
|
case SLIDE_SCROLL:
|
||||||
@@ -719,11 +693,6 @@ static int activate(AVFilterContext *ctx)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int ch = 0; ch < s->nb_channels && s->ihop_index == 0; ch++) {
|
|
||||||
ff_filter_execute(ctx, run_channel_cwt, (void *)&ch, NULL,
|
|
||||||
s->nb_threads);
|
|
||||||
}
|
|
||||||
|
|
||||||
ff_filter_execute(ctx, draw, NULL, NULL, s->nb_threads);
|
ff_filter_execute(ctx, draw, NULL, NULL, s->nb_threads);
|
||||||
|
|
||||||
pts_offset = av_rescale(s->ihop_index, s->hop_size, s->ihop_size);
|
pts_offset = av_rescale(s->ihop_index, s->hop_size, s->ihop_size);
|
||||||
@@ -760,15 +729,13 @@ static int activate(AVFilterContext *ctx)
|
|||||||
break;
|
break;
|
||||||
case SLIDE_SCROLL:
|
case SLIDE_SCROLL:
|
||||||
switch (s->direction) {
|
switch (s->direction) {
|
||||||
|
case DIRECTION_UD:
|
||||||
case DIRECTION_LR:
|
case DIRECTION_LR:
|
||||||
s->pos = 0;
|
s->pos = 0;
|
||||||
break;
|
break;
|
||||||
case DIRECTION_RL:
|
case DIRECTION_RL:
|
||||||
s->pos = s->w - 1;
|
s->pos = s->w - 1;
|
||||||
break;
|
break;
|
||||||
case DIRECTION_UD:
|
|
||||||
s->pos = 0;
|
|
||||||
break;
|
|
||||||
case DIRECTION_DU:
|
case DIRECTION_DU:
|
||||||
s->pos = s->h - 1;
|
s->pos = s->h - 1;
|
||||||
break;
|
break;
|
||||||
@@ -794,17 +761,62 @@ fail:
|
|||||||
av_frame_free(&out);
|
av_frame_free(&out);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int activate(AVFilterContext *ctx)
|
||||||
|
{
|
||||||
|
AVFilterLink *inlink = ctx->inputs[0];
|
||||||
|
AVFilterLink *outlink = ctx->outputs[0];
|
||||||
|
ShowCWTContext *s = ctx->priv;
|
||||||
|
int ret = 0, status;
|
||||||
|
int64_t pts;
|
||||||
|
|
||||||
|
FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
|
||||||
|
|
||||||
|
if (s->outpicref) {
|
||||||
|
AVFrame *fin;
|
||||||
|
|
||||||
|
if (s->ihop_index == 0) {
|
||||||
|
ret = ff_inlink_consume_samples(inlink, 1, s->hop_size - s->hop_index, &fin);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
if (ret > 0) {
|
||||||
|
for (int ch = 0; ch < s->nb_channels; ch++)
|
||||||
|
run_channel_cwt_prepare(ctx, fin, ch,
|
||||||
|
ff_outlink_get_status(inlink));
|
||||||
|
|
||||||
|
if (s->hop_index == 0)
|
||||||
|
s->in_pts = fin->pts;
|
||||||
|
s->hop_index += fin->nb_samples;
|
||||||
|
av_frame_free(&fin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s->hop_index >= s->hop_size || s->ihop_index > 0) {
|
||||||
|
s->hop_index = 0;
|
||||||
|
|
||||||
|
for (int ch = 0; ch < s->nb_channels && s->ihop_index == 0; ch++) {
|
||||||
|
ff_filter_execute(ctx, run_channel_cwt, (void *)&ch, NULL,
|
||||||
|
s->nb_threads);
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = output_frame(ctx);
|
||||||
|
if (ret != 1)
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ff_inlink_acknowledge_status(inlink, &status, &pts)) {
|
if (ff_inlink_acknowledge_status(inlink, &status, &pts)) {
|
||||||
if (status == AVERROR_EOF) {
|
if (status == AVERROR_EOF) {
|
||||||
ff_outlink_set_status(outlink, status, pts);
|
ff_outlink_set_status(outlink, status, s->old_pts);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ff_inlink_queued_samples(inlink) > 0 || s->ihop_index || s->hop_index >= s->hop_size) {
|
if (ff_inlink_queued_samples(inlink) > 0 || s->ihop_index ||
|
||||||
|
s->hop_index >= s->hop_size) {
|
||||||
ff_filter_set_ready(ctx, 10);
|
ff_filter_set_ready(ctx, 10);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user