diff options
-rw-r--r-- | libavfilter/vf_lut3d.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/libavfilter/vf_lut3d.c b/libavfilter/vf_lut3d.c index 67cdb17ee0..85e270cc5f 100644 --- a/libavfilter/vf_lut3d.c +++ b/libavfilter/vf_lut3d.c @@ -262,21 +262,29 @@ static int skip_line(const char *p) } \ } while (loop_cond) -/* Basically r g and b float values on each line; seems to be generated by - * Davinci */ +/* Basically r g and b float values on each line, with a facultative 3DLUTSIZE + * directive; seems to be generated by Davinci */ static int parse_dat(AVFilterContext *ctx, FILE *f) { LUT3DContext *lut3d = ctx->priv; - const int size = lut3d->lutsize; - int i, j, k; + char line[MAX_LINE_SIZE]; + int i, j, k, size; + lut3d->lutsize = size = 33; + + NEXT_LINE(skip_line(line)); + if (!strncmp(line, "3DLUTSIZE ", 10)) { + lut3d->lutsize = size = strtol(line + 10, NULL, 0); + NEXT_LINE(skip_line(line)); + } for (k = 0; k < size; k++) { for (j = 0; j < size; j++) { for (i = 0; i < size; i++) { - char line[MAX_LINE_SIZE]; struct rgbvec *vec = &lut3d->lut[k][j][i]; - NEXT_LINE(skip_line(line)); - sscanf(line, "%f %f %f", &vec->r, &vec->g, &vec->b); + if (k != 0 || j != 0 || i != 0) + NEXT_LINE(skip_line(line)); + if (sscanf(line, "%f %f %f", &vec->r, &vec->g, &vec->b) != 3) + return AVERROR_INVALIDDATA; } } } @@ -569,7 +577,6 @@ static av_cold int lut3d_init(AVFilterContext *ctx) ext++; if (!av_strcasecmp(ext, "dat")) { - lut3d->lutsize = 33; ret = parse_dat(ctx, f); } else if (!av_strcasecmp(ext, "3dl")) { ret = parse_3dl(ctx, f); |