Skip to content

Commit

Permalink
filters: rename pl_filter_triangle/box to bilinear/nearest
Browse files Browse the repository at this point in the history
I have no idea why I ever gave these such confusing names. Just rename
them and keep around the old names for backwards compatibility.

API bump because this is technically an ABI break (symbol rename).
  • Loading branch information
haasn committed Mar 23, 2021
1 parent 1091353 commit b6d393d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ project('libplacebo', ['c', 'cpp'],
license: 'LGPL2.1+',
default_options: ['c_std=c99', 'cpp_std=c++11', 'warning_level=2'],
meson_version: '>=0.51',
version: '3.116.0',
version: '3.117.0',
)

# Version number
Expand Down
12 changes: 6 additions & 6 deletions src/filters.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,11 +532,11 @@ const struct pl_filter_config pl_filter_spline64 = {
.kernel = &pl_filter_function_spline64,
};

const struct pl_filter_config pl_filter_box = {
const struct pl_filter_config pl_filter_nearest = {
.kernel = &pl_filter_function_box,
};

const struct pl_filter_config pl_filter_triangle = {
const struct pl_filter_config pl_filter_bilinear = {
.kernel = &pl_filter_function_triangle,
};

Expand Down Expand Up @@ -646,10 +646,10 @@ const struct pl_named_filter_config pl_named_filters[] = {
{"spline16", &pl_filter_spline16},
{"spline36", &pl_filter_spline36},
{"spline64", &pl_filter_spline64},
{"box", &pl_filter_box},
{"nearest", &pl_filter_box}, // alias
{"triangle", &pl_filter_triangle},
{"bilinear", &pl_filter_triangle}, // alias
{"nearest", &pl_filter_nearest},
{"box", &pl_filter_nearest}, // alias
{"bilinear", &pl_filter_bilinear},
{"triangle", &pl_filter_bilinear}, // alias
{"gaussian", &pl_filter_gaussian},
{"sinc", &pl_filter_sinc},
{"lanczos", &pl_filter_lanczos},
Expand Down
8 changes: 6 additions & 2 deletions src/include/libplacebo/filters.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ double pl_filter_sample(const struct pl_filter_config *c, double x);
extern const struct pl_filter_config pl_filter_spline16; // 2 taps
extern const struct pl_filter_config pl_filter_spline36; // 3 taps
extern const struct pl_filter_config pl_filter_spline64; // 4 taps
extern const struct pl_filter_config pl_filter_box; // AKA nearest
extern const struct pl_filter_config pl_filter_triangle; // AKA bilinear
extern const struct pl_filter_config pl_filter_nearest; // AKA box
extern const struct pl_filter_config pl_filter_bilinear; // AKA triangle
extern const struct pl_filter_config pl_filter_gaussian;
// Sinc family (all configured to 3 taps):
extern const struct pl_filter_config pl_filter_sinc; // unwindowed,
Expand All @@ -209,6 +209,10 @@ extern const struct pl_filter_config pl_filter_robidouxsharp;
extern const struct pl_filter_config pl_filter_ewa_robidoux;
extern const struct pl_filter_config pl_filter_ewa_robidouxsharp;

// Backwards compatibility
#define pl_filter_box pl_filter_nearest
#define pl_filter_triangle pl_filter_bilinear

struct pl_named_filter_config {
const char *name;
const struct pl_filter_config *filter;
Expand Down
2 changes: 1 addition & 1 deletion src/include/libplacebo/renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct pl_render_params {
// since the built-in GPU sampling algorithms can't anti-alias.
//
// Note: If set to the same address as the built-in `pl_filter_bicubic`,
// `pl_filter_box` etc.; libplacebo will also use the more efficient
// `pl_filter_nearest` etc.; libplacebo will also use the more efficient
// direct sampling algorithm where possible without quality loss.
const struct pl_filter_config *upscaler;
const struct pl_filter_config *downscaler;
Expand Down
4 changes: 2 additions & 2 deletions src/renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,9 @@ static struct sampler_info sample_src_info(struct pl_renderer *rr,
if (can_fast && !params->disable_builtin_scalers) {
if (can_linear && info.config == &pl_filter_bicubic)
info.type = SAMPLER_BICUBIC;
if (can_linear && info.config == &pl_filter_triangle)
if (can_linear && info.config == &pl_filter_bilinear)
info.type = SAMPLER_DIRECT;
if (info.config == &pl_filter_box)
if (info.config == &pl_filter_nearest)
info.type = can_linear ? SAMPLER_NEAREST : SAMPLER_DIRECT;
}
}
Expand Down

0 comments on commit b6d393d

Please sign in to comment.