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

Fixes Ticket #2847.
This commit is contained in:
Clément Bœsch 2014-05-04 10:36:53 +02:00
parent 3316556cf7
commit 7c3941b25c

View File

@ -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);