avfilter/vf_morpho: move structure processing in separate loop

This commit is contained in:
Paul B Mahol 2023-05-08 16:12:07 +02:00
parent 63d7ea38c7
commit bbe410a7fd
1 changed files with 22 additions and 17 deletions

View File

@ -808,30 +808,13 @@ static int do_morpho(FFFrameSync *fs)
av_frame_copy_props(out, in);
for (int p = 0; p < s->nb_planes; p++) {
const uint8_t *src = in->data[p];
int src_linesize = in->linesize[p];
const uint8_t *ssrc = structurepic->data[p];
const int ssrc_linesize = structurepic->linesize[p];
uint8_t *dst = out->data[p];
int dst_linesize = out->linesize[p];
const int swidth = s->splanewidth[p];
const int sheight = s->splaneheight[p];
const int width = s->planewidth[p];
const int height = s->planeheight[p];
const int depth = s->depth;
int type_size = s->type_size;
if (ctx->is_disabled || !(s->planes & (1 << p))) {
copy:
av_image_copy_plane(out->data[p] + 0 * out->linesize[p],
out->linesize[p],
in->data[p] + 0 * in->linesize[p],
in->linesize[p],
width * ((s->depth + 7) / 8),
height);
continue;
}
if (!s->got_structure[p] || s->structures) {
free_chord_set(&s->SE[p]);
@ -843,6 +826,28 @@ copy:
goto fail;
s->got_structure[p] = 1;
}
}
for (int p = 0; p < s->nb_planes; p++) {
const uint8_t *src = in->data[p];
int src_linesize = in->linesize[p];
uint8_t *dst = out->data[p];
int dst_linesize = out->linesize[p];
const int width = s->planewidth[p];
const int height = s->planeheight[p];
const int depth = s->depth;
int type_size = s->type_size;
if (ctx->is_disabled || !(s->planes & (1 << p))) {
copy:
av_image_copy_plane(out->data[p] + 0 * out->linesize[p],
out->linesize[p],
in->data[p] + 0 * in->linesize[p],
in->linesize[p],
width * ((depth + 7) / 8),
height);
continue;
}
if (s->SE[p].minX == INT16_MAX ||
s->SE[p].minY == INT16_MAX ||