Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -52,6 +52,7 @@ typedef struct GEQContext { · 51 unmodified lines | ||
| 52 | 52 | AVFrame *picref; ///< current input buffer |
| 53 | 53 | uint8_t *dst; ///< reference pointer to the 8bits output |
| 54 | 54 | uint16_t *dst16; ///< reference pointer to the 16bits output |
| 55 | + float *dst32; ///< reference pointer to the 32bits output | |
| 55 | 56 | double values[VAR_VARS_NB]; ///< expression values |
| 56 | 57 | int hsub, vsub; ///< chroma subsampling |
| 57 | 58 | int planes; ///< number of planes |
| @@ -114,13 +115,19 @@ static inline double getpix(void *priv, double x, double y, int plane) · 56 unmodified lines | ||
| 114 | 115 | x -= xi; |
| 115 | 116 | y -= yi; |
| 116 | 117 | |
| 117 | − if (geq->bps > 8) { | |
| 118 | + if (geq->bps > 8 && geq->bps <= 16) { | |
| 118 | 119 | const uint16_t *src16 = (const uint16_t*)src; |
| 119 | 120 | linesize /= 2; |
| 120 | 121 | |
| 121 | 122 | return (1-y)*((1-x)*src16[xi + yi * linesize] + x*src16[xi + 1 + yi * linesize]) |
| 122 | 123 | + y *((1-x)*src16[xi + (yi+1) * linesize] + x*src16[xi + 1 + (yi+1) * linesize]); |
| 123 | − } else { | |
| 124 | + } else if (geq->bps == 32) { | |
| 125 | + const float *src32 = (const float*)src; | |
| 126 | + linesize /= 4; | |
| 127 | + | |
| 128 | + return (1-y)*((1-x)*src32[xi + yi * linesize] + x*src32[xi + 1 + yi * linesize]) | |
| 129 | + + y *((1-x)*src32[xi + (yi+1) * linesize] + x*src32[xi + 1 + (yi+1) * linesize]); | |
| 130 | + } else if (geq->bps == 8) { | |
| 124 | 131 | return (1-y)*((1-x)*src[xi + yi * linesize] + x*src[xi + 1 + yi * linesize]) |
| 125 | 132 | + y *((1-x)*src[xi + (yi+1) * linesize] + x*src[xi + 1 + (yi+1) * linesize]); |
| 126 | 133 | } |
| @@ -128,15 +135,22 @@ static inline double getpix(void *priv, double x, double y, int plane) · 1 unmodified line | ||
| 128 | 135 | xi = av_clipd(x, 0, w - 1); |
| 129 | 136 | yi = av_clipd(y, 0, h - 1); |
| 130 | 137 | |
| 131 | − if (geq->bps > 8) { | |
| 138 | + if (geq->bps > 8 && geq->bps <= 16) { | |
| 132 | 139 | const uint16_t *src16 = (const uint16_t*)src; |
| 133 | 140 | linesize /= 2; |
| 134 | 141 | |
| 135 | 142 | return src16[xi + yi * linesize]; |
| 136 | − } else { | |
| 143 | + } else if (geq->bps == 32) { | |
| 144 | + const float *src32 = (const float*)src; | |
| 145 | + linesize /= 4; | |
| 146 | + | |
| 147 | + return src32[xi + yi * linesize]; | |
| 148 | + } else if (geq->bps == 8) { | |
| 137 | 149 | return src[xi + yi * linesize]; |
| 138 | 150 | } |
| 139 | 151 | } |
| 152 | + | |
| 153 | + return 0; | |
| 140 | 154 | } |
| 141 | 155 | |
| 142 | 156 | static int calculate_sums(GEQContext *geq, int plane, int w, int h) |
| @@ -150,10 +164,12 @@ static int calculate_sums(GEQContext *geq, int plane, int w, int h) · 7 unmodified lines | ||
| 150 | 164 | geq->pixel_sums[plane] = av_malloc_array(w, h * sizeof (*geq->pixel_sums[plane])); |
| 151 | 165 | if (!geq->pixel_sums[plane]) |
| 152 | 166 | return AVERROR(ENOMEM); |
| 153 | − if (geq->bps > 8) | |
| 167 | + if (geq->bps == 32) | |
| 168 | + linesize /= 4; | |
| 169 | + else if (geq->bps > 8 && geq->bps <= 16) | |
| 154 | 170 | linesize /= 2; |
| 155 | 171 | for (yi = 0; yi < h; yi ++) { |
| 156 | − if (geq->bps > 8) { | |
| 172 | + if (geq->bps > 8 && geq->bps <= 16) { | |
| 157 | 173 | const uint16_t *src16 = (const uint16_t*)src; |
| 158 | 174 | double linesum = 0; |
| 159 | 175 | |
| @@ -161,13 +177,21 @@ static int calculate_sums(GEQContext *geq, int plane, int w, int h) · 1 unmodified line | ||
| 161 | 177 | linesum += src16[xi + yi * linesize]; |
| 162 | 178 | geq->pixel_sums[plane][xi + yi * w] = linesum; |
| 163 | 179 | } |
| 164 | − } else { | |
| 180 | + } else if (geq->bps == 8) { | |
| 165 | 181 | double linesum = 0; |
| 166 | 182 | |
| 167 | 183 | for (xi = 0; xi < w; xi ++) { |
| 168 | 184 | linesum += src[xi + yi * linesize]; |
| 169 | 185 | geq->pixel_sums[plane][xi + yi * w] = linesum; |
| 170 | 186 | } |
| 187 | + } else if (geq->bps == 32) { | |
| 188 | + const float *src32 = (const float*)src; | |
| 189 | + double linesum = 0; | |
| 190 | + | |
| 191 | + for (xi = 0; xi < w; xi ++) { | |
| 192 | + linesum += src32[xi + yi * linesize]; | |
| 193 | + geq->pixel_sums[plane][xi + yi * w] = linesum; | |
| 194 | + } | |
| 171 | 195 | } |
| 172 | 196 | if (yi) |
| 173 | 197 | for (xi = 0; xi < w; xi ++) { |
| @@ -249,8 +273,10 @@ static av_cold int geq_init(AVFilterContext *ctx) · 75 unmodified lines | ||
| 249 | 273 | if (!geq->expr_str[V]) geq->expr_str[V] = av_strdup(geq->expr_str[U]); |
| 250 | 274 | } |
| 251 | 275 | |
| 252 | − if (!geq->expr_str[A]) { | |
| 276 | + if (!geq->expr_str[A] && geq->bps != 32) { | |
| 253 | 277 | geq->expr_str[A] = av_asprintf("%d", (1<<geq->bps) - 1); |
| 278 | + } else { | |
| 279 | + geq->expr_str[A] = av_asprintf("%f", 1.f); | |
| 254 | 280 | } |
| 255 | 281 | if (!geq->expr_str[G]) |
| 256 | 282 | geq->expr_str[G] = av_strdup("g(X,Y)"); |
| @@ -322,6 +348,7 @@ static int geq_query_formats(AVFilterContext *ctx) · 65 unmodified lines | ||
| 322 | 348 | AV_PIX_FMT_YUV444P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV420P16, |
| 323 | 349 | AV_PIX_FMT_YUVA444P16, AV_PIX_FMT_YUVA422P16, AV_PIX_FMT_YUVA420P16, |
| 324 | 350 | AV_PIX_FMT_GRAY16, |
| 351 | + AV_PIX_FMT_GRAYF32, | |
| 325 | 352 | AV_PIX_FMT_NONE |
| 326 | 353 | }; |
| 327 | 354 | static const enum AVPixelFormat rgb_pix_fmts[] = { |
| @@ -331,6 +358,7 @@ static int geq_query_formats(AVFilterContext *ctx) · 3 unmodified lines | ||
| 331 | 358 | AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRAP12, |
| 332 | 359 | AV_PIX_FMT_GBRP14, |
| 333 | 360 | AV_PIX_FMT_GBRP16, AV_PIX_FMT_GBRAP16, |
| 361 | + AV_PIX_FMT_GBRPF32, AV_PIX_FMT_GBRAPF32, | |
| 334 | 362 | AV_PIX_FMT_NONE |
| 335 | 363 | }; |
| 336 | 364 | const enum AVPixelFormat *pix_fmts = geq->is_rgb ? rgb_pix_fmts : yuv_pix_fmts; |
| @@ -390,7 +418,7 @@ static int slice_geq_filter(AVFilterContext *ctx, void *arg, int jobnr, int nb_j · 53 unmodified lines | ||
| 390 | 418 | } |
| 391 | 419 | ptr += linesize; |
| 392 | 420 | } |
| 393 | − } else { | |
| 421 | + } else if (geq->bps <= 16) { | |
| 394 | 422 | uint16_t *ptr16 = geq->dst16 + (linesize/2) * slice_start; |
| 395 | 423 | for (y = slice_start; y < slice_end; y++) { |
| 396 | 424 | values[VAR_Y] = y; |
| @@ -400,6 +428,16 @@ static int slice_geq_filter(AVFilterContext *ctx, void *arg, int jobnr, int nb_j · 3 unmodified lines | ||
| 400 | 428 | } |
| 401 | 429 | ptr16 += linesize/2; |
| 402 | 430 | } |
| 431 | + } else { | |
| 432 | + float *ptr32 = geq->dst32 + (linesize/4) * slice_start; | |
| 433 | + for (y = slice_start; y < slice_end; y++) { | |
| 434 | + values[VAR_Y] = y; | |
| 435 | + for (x = 0; x < width; x++) { | |
| 436 | + values[VAR_X] = x; | |
| 437 | + ptr32[x] = av_expr_eval(geq->e[plane][jobnr], values, geq); | |
| 438 | + } | |
| 439 | + ptr32 += linesize/4; | |
| 440 | + } | |
| 403 | 441 | } |
| 404 | 442 | |
| 405 | 443 | return 0; |
| @@ -433,6 +471,7 @@ static int geq_filter_frame(AVFilterLink *inlink, AVFrame *in) · 27 unmodified lines | ||
| 433 | 471 | |
| 434 | 472 | geq->dst = out->data[plane]; |
| 435 | 473 | geq->dst16 = (uint16_t*)out->data[plane]; |
| 474 | + geq->dst32 = (float*)out->data[plane]; | |
| 436 | 475 | |
| 437 | 476 | geq->values[VAR_W] = width; |
| 438 | 477 | geq->values[VAR_H] = height; |