Showing the changes to libavfilter (1 of 2 files). Show all
Unified · Split
| @@ -33,6 +33,12 @@ · 32 unmodified lines | |||
| 33 | #include "libavutil/pixdesc.h" | 33 | #include "libavutil/pixdesc.h" |
| 34 | #include "internal.h" | 34 | #include "internal.h" |
| 35 | 35 | ||
| 36 | enum InterpolationMethods { | ||
| 37 | INTERP_NEAREST, | ||
| 38 | INTERP_BILINEAR, | ||
| 39 | NB_INTERP | ||
| 40 | }; | ||
| 41 | |||
| 36 | static const char *const var_names[] = { "X", "Y", "W", "H", "N", "SW", "SH", "T", NULL }; | 42 | static const char *const var_names[] = { "X", "Y", "W", "H", "N", "SW", "SH", "T", NULL }; |
| 37 | enum { VAR_X, VAR_Y, VAR_W, VAR_H, VAR_N, VAR_SW, VAR_SH, VAR_T, VAR_VARS_NB }; | 43 | enum { VAR_X, VAR_Y, VAR_W, VAR_H, VAR_N, VAR_SW, VAR_SH, VAR_T, VAR_VARS_NB }; |
| 38 | 44 | ||
| @@ -46,6 +52,7 @@ typedef struct GEQContext { · 7 unmodified lines | |||
| 46 | double values[VAR_VARS_NB]; ///< expression values | 52 | double values[VAR_VARS_NB]; ///< expression values |
| 47 | int hsub, vsub; ///< chroma subsampling | 53 | int hsub, vsub; ///< chroma subsampling |
| 48 | int planes; ///< number of planes | 54 | int planes; ///< number of planes |
| 55 | int interpolation; | ||
| 49 | int is_rgb; | 56 | int is_rgb; |
| 50 | int bps; | 57 | int bps; |
| 51 | } GEQContext; | 58 | } GEQContext; |
| @@ -70,6 +77,12 @@ static const AVOption geq_options[] = { · 18 unmodified lines | |||
| 70 | { "g", "set green expression", OFFSET(expr_str[G]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, | 77 | { "g", "set green expression", OFFSET(expr_str[G]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
| 71 | { "blue_expr", "set blue expression", OFFSET(expr_str[B]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, | 78 | { "blue_expr", "set blue expression", OFFSET(expr_str[B]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
| 72 | { "b", "set blue expression", OFFSET(expr_str[B]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, | 79 | { "b", "set blue expression", OFFSET(expr_str[B]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
| 80 | { "interpolation","set interpolation method", OFFSET(interpolation), AV_OPT_TYPE_INT, {.i64=INTERP_BILINEAR}, 0, NB_INTERP-1, FLAGS, "interp" }, | ||
| 81 | { "i", "set interpolation method", OFFSET(interpolation), AV_OPT_TYPE_INT, {.i64=INTERP_BILINEAR}, 0, NB_INTERP-1, FLAGS, "interp" }, | ||
| 82 | { "nearest", "nearest interpolation", 0, AV_OPT_TYPE_CONST, {.i64=INTERP_NEAREST}, 0, 0, FLAGS, "interp" }, | ||
| 83 | { "n", "nearest interpolation", 0, AV_OPT_TYPE_CONST, {.i64=INTERP_NEAREST}, 0, 0, FLAGS, "interp" }, | ||
| 84 | { "bilinear", "bilinear interpolation", 0, AV_OPT_TYPE_CONST, {.i64=INTERP_BILINEAR}, 0, 0, FLAGS, "interp" }, | ||
| 85 | { "b", "bilinear interpolation", 0, AV_OPT_TYPE_CONST, {.i64=INTERP_BILINEAR}, 0, 0, FLAGS, "interp" }, | ||
| 73 | {NULL}, | 86 | {NULL}, |
| 74 | }; | 87 | }; |
| 75 | 88 | ||
| @@ -88,6 +101,7 @@ static inline double getpix(void *priv, double x, double y, int plane) · 12 unmodified lines | |||
| 88 | if (!src) | 101 | if (!src) |
| 89 | return 0; | 102 | return 0; |
| 90 | 103 | ||
| 104 | if (geq->interpolation == INTERP_BILINEAR) { | ||
| 91 | xi = x = av_clipd(x, 0, w - 2); | 105 | xi = x = av_clipd(x, 0, w - 2); |
| 92 | yi = y = av_clipd(y, 0, h - 2); | 106 | yi = y = av_clipd(y, 0, h - 2); |
| 93 | 107 | ||
| @@ -104,6 +118,19 @@ static inline double getpix(void *priv, double x, double y, int plane) · 10 unmodified lines | |||
| 104 | return (1-y)*((1-x)*src[xi + yi * linesize] + x*src[xi + 1 + yi * linesize]) | 118 | return (1-y)*((1-x)*src[xi + yi * linesize] + x*src[xi + 1 + yi * linesize]) |
| 105 | + y *((1-x)*src[xi + (yi+1) * linesize] + x*src[xi + 1 + (yi+1) * linesize]); | 119 | + y *((1-x)*src[xi + (yi+1) * linesize] + x*src[xi + 1 + (yi+1) * linesize]); |
| 106 | } | 120 | } |
| 121 | } else { | ||
| 122 | xi = av_clipd(x, 0, w - 1); | ||
| 123 | yi = av_clipd(y, 0, h - 1); | ||
| 124 | |||
| 125 | if (geq->bps > 8) { | ||
| 126 | const uint16_t *src16 = (const uint16_t*)src; | ||
| 127 | linesize /= 2; | ||
| 128 | |||
| 129 | return src16[xi + yi * linesize]; | ||
| 130 | } else { | ||
| 131 | return src[xi + yi * linesize]; | ||
| 132 | } | ||
| 133 | } | ||
| 107 | } | 134 | } |
| 108 | 135 | ||
| 109 | //TODO: cubic interpolate | 136 | //TODO: cubic interpolate |