]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_select.c
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libavfilter / vf_select.c
index 3d05167d134d7ffbe8dd4a97f45b21bfe825ca95..3ba2670a0fb7b777b29aea80c8057507ab3c58fe 100644 (file)
@@ -45,18 +45,18 @@ static const char *var_names[] = {
     "prev_selected_t",   ///< previously selected time
 
     "pict_type",         ///< the type of picture in the movie
-    "PICT_TYPE_I",
-    "PICT_TYPE_P",
-    "PICT_TYPE_B",
-    "PICT_TYPE_S",
-    "PICT_TYPE_SI",
-    "PICT_TYPE_SP",
-    "PICT_TYPE_BI",
+    "I",
+    "P",
+    "B",
+    "S",
+    "SI",
+    "SP",
+    "BI",
 
     "interlace_type",    ///< the frame interlace type
-    "INTERLACE_TYPE_P",
-    "INTERLACE_TYPE_T",
-    "INTERLACE_TYPE_B",
+    "PROGRESSIVE",
+    "TOPFIRST",
+    "BOTTOMFIRST",
 
     "n",                 ///< frame number (starting from zero)
     "selected_n",        ///< selected frame number (starting from zero)
@@ -185,9 +185,11 @@ static int select_frame(AVFilterContext *ctx, AVFilterBufferRef *picref)
 
     if (isnan(select->var_values[VAR_START_PTS]))
         select->var_values[VAR_START_PTS] = TS2D(picref->pts);
+    if (isnan(select->var_values[VAR_START_T]))
+        select->var_values[VAR_START_T] = TS2D(picref->pts) * av_q2d(inlink->time_base);
 
     select->var_values[VAR_PTS] = TS2D(picref->pts);
-    select->var_values[VAR_T  ] = picref->pts * av_q2d(inlink->time_base);
+    select->var_values[VAR_T  ] = TS2D(picref->pts) * av_q2d(inlink->time_base);
     select->var_values[VAR_POS] = picref->pos == -1 ? NAN : picref->pos;
     select->var_values[VAR_PREV_PTS] = TS2D(picref ->pts);
 
@@ -315,16 +317,15 @@ static av_cold void uninit(AVFilterContext *ctx)
 {
     SelectContext *select = ctx->priv;
     AVFilterBufferRef *picref;
-    int i;
 
     av_expr_free(select->expr);
     select->expr = NULL;
 
-    for (i = 0; i < av_fifo_size(select->pending_frames)/sizeof(picref); i++) {
-        av_fifo_generic_read(select->pending_frames, &picref, sizeof(picref), NULL);
+    while (select->pending_frames &&
+           av_fifo_generic_read(select->pending_frames, &picref, sizeof(picref), NULL) == sizeof(picref))
         avfilter_unref_buffer(picref);
-    }
     av_fifo_free(select->pending_frames);
+    select->pending_frames = NULL;
 }
 
 AVFilter avfilter_vf_select = {