Browse code

lavfi/curves: move alloc and init of LUTs inside config_input()

This is needed in order to have different sizes of LUTs according to the
input.

Clément Bœsch authored on 2016/07/24 18:13:29
Showing 1 changed files
... ...
@@ -440,9 +440,8 @@ static int dump_curves(const char *fname, uint8_t *graph[NB_COMP + 1],
440 440
 
441 441
 static av_cold int init(AVFilterContext *ctx)
442 442
 {
443
-    int i, j, ret;
443
+    int i, ret;
444 444
     CurvesContext *curves = ctx->priv;
445
-    struct keypoint *comp_points[NB_COMP + 1] = {0};
446 445
     char **pts = curves->comp_points_str;
447 446
     const char *allp = curves->comp_points_str_all;
448 447
 
... ...
@@ -478,6 +477,37 @@ static av_cold int init(AVFilterContext *ctx)
478 478
         SET_COMP_IF_NOT_SET(3, master);
479 479
     }
480 480
 
481
+    return 0;
482
+}
483
+
484
+static int query_formats(AVFilterContext *ctx)
485
+{
486
+    static const enum AVPixelFormat pix_fmts[] = {
487
+        AV_PIX_FMT_RGB24,  AV_PIX_FMT_BGR24,
488
+        AV_PIX_FMT_RGBA,   AV_PIX_FMT_BGRA,
489
+        AV_PIX_FMT_ARGB,   AV_PIX_FMT_ABGR,
490
+        AV_PIX_FMT_0RGB,   AV_PIX_FMT_0BGR,
491
+        AV_PIX_FMT_RGB0,   AV_PIX_FMT_BGR0,
492
+        AV_PIX_FMT_NONE
493
+    };
494
+    AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
495
+    if (!fmts_list)
496
+        return AVERROR(ENOMEM);
497
+    return ff_set_common_formats(ctx, fmts_list);
498
+}
499
+
500
+static int config_input(AVFilterLink *inlink)
501
+{
502
+    int i, j, ret;
503
+    AVFilterContext *ctx = inlink->dst;
504
+    CurvesContext *curves = ctx->priv;
505
+    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
506
+    char **pts = curves->comp_points_str;
507
+    struct keypoint *comp_points[NB_COMP + 1] = {0};
508
+
509
+    ff_fill_rgba_map(curves->rgba_map, inlink->format);
510
+    curves->step = av_get_padded_bits_per_pixel(desc) >> 3;
511
+
481 512
     for (i = 0; i < NB_COMP + 1; i++) {
482 513
         curves->graph[i] = av_mallocz(256);
483 514
         if (!curves->graph[i])
... ...
@@ -522,33 +552,6 @@ static av_cold int init(AVFilterContext *ctx)
522 522
     return 0;
523 523
 }
524 524
 
525
-static int query_formats(AVFilterContext *ctx)
526
-{
527
-    static const enum AVPixelFormat pix_fmts[] = {
528
-        AV_PIX_FMT_RGB24,  AV_PIX_FMT_BGR24,
529
-        AV_PIX_FMT_RGBA,   AV_PIX_FMT_BGRA,
530
-        AV_PIX_FMT_ARGB,   AV_PIX_FMT_ABGR,
531
-        AV_PIX_FMT_0RGB,   AV_PIX_FMT_0BGR,
532
-        AV_PIX_FMT_RGB0,   AV_PIX_FMT_BGR0,
533
-        AV_PIX_FMT_NONE
534
-    };
535
-    AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
536
-    if (!fmts_list)
537
-        return AVERROR(ENOMEM);
538
-    return ff_set_common_formats(ctx, fmts_list);
539
-}
540
-
541
-static int config_input(AVFilterLink *inlink)
542
-{
543
-    CurvesContext *curves = inlink->dst->priv;
544
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
545
-
546
-    ff_fill_rgba_map(curves->rgba_map, inlink->format);
547
-    curves->step = av_get_padded_bits_per_pixel(desc) >> 3;
548
-
549
-    return 0;
550
-}
551
-
552 525
 static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
553 526
 {
554 527
     int x, y;