1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

avfilter/scene_sad: pass true depth to ff_scene_sad_get_fn()

I need to be able to distinguish between 10/12/14 and 16 bit depths, for
overflow reasons.
This commit is contained in:
Niklas Haas
2025-07-12 11:15:56 +02:00
parent e6af82c498
commit dc61b74c1d
8 changed files with 9 additions and 10 deletions

View File

@ -272,7 +272,7 @@ static int config_input(AVFilterLink *inlink)
inlink->type == AVMEDIA_TYPE_AUDIO ? inlink->sample_rate : NAN; inlink->type == AVMEDIA_TYPE_AUDIO ? inlink->sample_rate : NAN;
if (CONFIG_SELECT_FILTER && select->do_scene_detect) { if (CONFIG_SELECT_FILTER && select->do_scene_detect) {
select->sad = ff_scene_sad_get_fn(select->bitdepth == 8 ? 8 : 16); select->sad = ff_scene_sad_get_fn(select->bitdepth);
if (!select->sad) if (!select->sad)
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }

View File

@ -63,11 +63,10 @@ ff_scene_sad_fn ff_scene_sad_get_fn(int depth)
sad = ff_scene_sad_get_fn_x86(depth); sad = ff_scene_sad_get_fn_x86(depth);
#endif #endif
if (!sad) { if (!sad) {
if (depth == 8) if (depth <= 8)
sad = ff_scene_sad_c; sad = ff_scene_sad_c;
if (depth == 16) else if (depth <= 16)
sad = ff_scene_sad16_c; sad = ff_scene_sad16_c;
} }
return sad; return sad;
} }

View File

@ -282,7 +282,7 @@ static int config_input(AVFilterLink *inlink)
s->bitdepth = pix_desc->comp[0].depth; s->bitdepth = pix_desc->comp[0].depth;
s->sad = ff_scene_sad_get_fn(s->bitdepth == 8 ? 8 : 16); s->sad = ff_scene_sad_get_fn(s->bitdepth);
if (!s->sad) if (!s->sad)
return AVERROR(EINVAL); return AVERROR(EINVAL);

View File

@ -103,7 +103,7 @@ static int config_input(AVFilterLink *inlink)
s->height[plane] = inlink->h >> ((plane == 1 || plane == 2) ? pix_desc->log2_chroma_h : 0); s->height[plane] = inlink->h >> ((plane == 1 || plane == 2) ? pix_desc->log2_chroma_h : 0);
} }
s->sad = ff_scene_sad_get_fn(s->bitdepth == 8 ? 8 : 16); s->sad = ff_scene_sad_get_fn(s->bitdepth);
if (!s->sad) if (!s->sad)
return AVERROR(EINVAL); return AVERROR(EINVAL);

View File

@ -304,7 +304,7 @@ static int config_input_ref(AVFilterLink *inlink)
s->filter_slice = !s->is_msad ? compute_images_identity : compute_images_msad; s->filter_slice = !s->is_msad ? compute_images_identity : compute_images_msad;
s->filter_line = desc->comp[0].depth > 8 ? identity_line_16bit : identity_line_8bit; s->filter_line = desc->comp[0].depth > 8 ? identity_line_16bit : identity_line_8bit;
s->sad = ff_scene_sad_get_fn(desc->comp[0].depth <= 8 ? 8 : 16); s->sad = ff_scene_sad_get_fn(desc->comp[0].depth);
if (!s->sad) if (!s->sad)
return AVERROR(EINVAL); return AVERROR(EINVAL);

View File

@ -387,7 +387,7 @@ static int config_input(AVFilterLink *inlink)
} }
if (mi_ctx->scd_method == SCD_METHOD_FDIFF) { if (mi_ctx->scd_method == SCD_METHOD_FDIFF) {
mi_ctx->sad = ff_scene_sad_get_fn(mi_ctx->bitdepth == 8 ? 8 : 16); mi_ctx->sad = ff_scene_sad_get_fn(mi_ctx->bitdepth);
if (!mi_ctx->sad) if (!mi_ctx->sad)
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }

View File

@ -91,7 +91,7 @@ static int config_input(AVFilterLink *inlink)
s->height[plane] = inlink->h >> ((plane == 1 || plane == 2) ? desc->log2_chroma_h : 0); s->height[plane] = inlink->h >> ((plane == 1 || plane == 2) ? desc->log2_chroma_h : 0);
} }
s->sad = ff_scene_sad_get_fn(s->bitdepth == 8 ? 8 : 16); s->sad = ff_scene_sad_get_fn(s->bitdepth);
if (!s->sad) if (!s->sad)
return AVERROR(EINVAL); return AVERROR(EINVAL);

View File

@ -47,7 +47,7 @@ ff_scene_sad_fn ff_scene_sad_get_fn_x86(int depth)
{ {
#if HAVE_X86ASM #if HAVE_X86ASM
int cpu_flags = av_get_cpu_flags(); int cpu_flags = av_get_cpu_flags();
if (depth == 8) { if (depth <= 8) {
#if HAVE_AVX2_EXTERNAL #if HAVE_AVX2_EXTERNAL
if (EXTERNAL_AVX2_FAST(cpu_flags)) if (EXTERNAL_AVX2_FAST(cpu_flags))
return scene_sad_avx2; return scene_sad_avx2;