Browse code

lavfi/drawtext: add 24 hours wrapping option for timecode.

Fixes ticket #1044.

Clément Bœsch authored on 2012/03/12 17:16:04
Showing 1 changed files
... ...
@@ -161,6 +161,7 @@ typedef struct {
161 161
     char       *tc_opt_string;      ///< specified timecode option string
162 162
     AVRational  tc_rate;            ///< frame rate for timecode
163 163
     AVTimecode  tc;                 ///< timecode context
164
+    int tc24hmax;                   ///< 1 if timecode is wrapped to 24 hours, 0 otherwise
164 165
     int frame_id;
165 166
 } DrawTextContext;
166 167
 
... ...
@@ -183,6 +184,7 @@ static const AVOption drawtext_options[]= {
183 183
 {"basetime", "set base time",        OFFSET(basetime),           AV_OPT_TYPE_INT64,  {.dbl=AV_NOPTS_VALUE},     INT64_MIN,        INT64_MAX  },
184 184
 {"draw",     "if false do not draw", OFFSET(d_expr),             AV_OPT_TYPE_STRING, {.str="1"},   CHAR_MIN, CHAR_MAX },
185 185
 {"timecode", "set initial timecode", OFFSET(tc_opt_string),      AV_OPT_TYPE_STRING, {.str=NULL},  CHAR_MIN, CHAR_MAX },
186
+{"tc24hmax", "set 24 hours max (timecode only)", OFFSET(tc24hmax), AV_OPT_TYPE_INT,  {.dbl=0},            0,        1 },
186 187
 {"r",        "set rate (timecode only)", OFFSET(tc_rate),        AV_OPT_TYPE_RATIONAL, {.dbl=0},          0,  INT_MAX },
187 188
 {"rate",     "set rate (timecode only)", OFFSET(tc_rate),        AV_OPT_TYPE_RATIONAL, {.dbl=0},          0,  INT_MAX },
188 189
 {"fix_bounds", "if true, check and fix text coords to avoid clipping",
... ...
@@ -351,6 +353,8 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
351 351
                                                dtext->tc_opt_string, ctx);
352 352
         if (ret < 0)
353 353
             return ret;
354
+        if (dtext->tc24hmax)
355
+            dtext->tc.flags |= AV_TIMECODE_FLAG_24HOURSMAX;
354 356
         if (!dtext->text)
355 357
             dtext->text = av_strdup("");
356 358
     }