[FFmpeg-cvslog] avfilter/lut3d: support 3DLUTSIZE directive for Davinci files.

Clément Bœsch git at videolan.org
Sun May 4 10:56:44 CEST 2014


ffmpeg | branch: master | Clément Bœsch <u at pkh.me> | Sun May  4 10:36:53 2014 +0200| [7c3941b25ce0ce74e46658e5e0d36a5ae0a41761] | committer: Clément Bœsch

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

Fixes Ticket #2847.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7c3941b25ce0ce74e46658e5e0d36a5ae0a41761
---

 libavfilter/vf_lut3d.c |   23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/libavfilter/vf_lut3d.c b/libavfilter/vf_lut3d.c
index 67cdb17..85e270c 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);



More information about the ffmpeg-cvslog mailing list