Commit 7c3941b2 authored by Clément Bœsch's avatar Clément Bœsch

avfilter/lut3d: support 3DLUTSIZE directive for Davinci files.

Fixes Ticket #2847.
parent 3316556c
...@@ -262,21 +262,29 @@ static int skip_line(const char *p) ...@@ -262,21 +262,29 @@ static int skip_line(const char *p)
} \ } \
} while (loop_cond) } while (loop_cond)
/* Basically r g and b float values on each line; seems to be generated by /* Basically r g and b float values on each line, with a facultative 3DLUTSIZE
* Davinci */ * directive; seems to be generated by Davinci */
static int parse_dat(AVFilterContext *ctx, FILE *f) static int parse_dat(AVFilterContext *ctx, FILE *f)
{ {
LUT3DContext *lut3d = ctx->priv; LUT3DContext *lut3d = ctx->priv;
const int size = lut3d->lutsize; char line[MAX_LINE_SIZE];
int i, j, k; 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 (k = 0; k < size; k++) {
for (j = 0; j < size; j++) { for (j = 0; j < size; j++) {
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
char line[MAX_LINE_SIZE];
struct rgbvec *vec = &lut3d->lut[k][j][i]; struct rgbvec *vec = &lut3d->lut[k][j][i];
if (k != 0 || j != 0 || i != 0)
NEXT_LINE(skip_line(line)); NEXT_LINE(skip_line(line));
sscanf(line, "%f %f %f", &vec->r, &vec->g, &vec->b); 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) ...@@ -569,7 +577,6 @@ static av_cold int lut3d_init(AVFilterContext *ctx)
ext++; ext++;
if (!av_strcasecmp(ext, "dat")) { if (!av_strcasecmp(ext, "dat")) {
lut3d->lutsize = 33;
ret = parse_dat(ctx, f); ret = parse_dat(ctx, f);
} else if (!av_strcasecmp(ext, "3dl")) { } else if (!av_strcasecmp(ext, "3dl")) {
ret = parse_3dl(ctx, f); ret = parse_3dl(ctx, f);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment