LCOV - code coverage report
Current view: top level - src/libavfilter - dualinput.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 38 44 86.4 %
Date: 2017-05-26 21:11:57 Functions: 5 5 100.0 %

          Line data    Source code
       1             : /*
       2             :  * This file is part of FFmpeg.
       3             :  *
       4             :  * FFmpeg is free software; you can redistribute it and/or
       5             :  * modify it under the terms of the GNU Lesser General Public
       6             :  * License as published by the Free Software Foundation; either
       7             :  * version 2.1 of the License, or (at your option) any later version.
       8             :  *
       9             :  * FFmpeg is distributed in the hope that it will be useful,
      10             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      12             :  * Lesser General Public License for more details.
      13             :  *
      14             :  * You should have received a copy of the GNU Lesser General Public
      15             :  * License along with FFmpeg; if not, write to the Free Software
      16             :  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
      17             :  */
      18             : 
      19             : #include "dualinput.h"
      20             : #include "libavutil/timestamp.h"
      21             : 
      22         916 : static int process_frame(FFFrameSync *fs)
      23             : {
      24         916 :     AVFilterContext *ctx = fs->parent;
      25         916 :     FFDualInputContext *s = fs->opaque;
      26         916 :     AVFrame *mainpic = NULL, *secondpic = NULL;
      27         916 :     int ret = 0;
      28             : 
      29        1832 :     if ((ret = ff_framesync_get_frame(&s->fs, 0, &mainpic,   1)) < 0 ||
      30         916 :         (ret = ff_framesync_get_frame(&s->fs, 1, &secondpic, 0)) < 0) {
      31           0 :         av_frame_free(&mainpic);
      32           0 :         return ret;
      33             :     }
      34         916 :     av_assert0(mainpic);
      35         916 :     mainpic->pts = av_rescale_q(s->fs.pts, s->fs.time_base, ctx->outputs[0]->time_base);
      36         916 :     if (secondpic && !ctx->is_disabled)
      37         916 :         mainpic = s->process(ctx, mainpic, secondpic);
      38         916 :     ret = ff_filter_frame(ctx->outputs[0], mainpic);
      39             :     av_assert1(ret != AVERROR(EAGAIN));
      40         916 :     return ret;
      41             : }
      42             : 
      43          13 : int ff_dualinput_init(AVFilterContext *ctx, FFDualInputContext *s)
      44             : {
      45             :     FFFrameSyncIn *in;
      46             :     int ret;
      47             : 
      48          13 :     if ((ret = ff_framesync_init(&s->fs, ctx, 2)) < 0)
      49           0 :         return ret;
      50             : 
      51          13 :     in = s->fs.in;
      52          13 :     s->fs.opaque = s;
      53          13 :     s->fs.on_event = process_frame;
      54          13 :     in[0].time_base = ctx->inputs[0]->time_base;
      55          13 :     in[1].time_base = ctx->inputs[1]->time_base;
      56          13 :     in[0].sync   = 2;
      57          13 :     in[0].before = EXT_STOP;
      58          13 :     in[0].after  = EXT_INFINITY;
      59          13 :     in[1].sync   = 1;
      60          13 :     in[1].before = EXT_NULL;
      61          13 :     in[1].after  = EXT_INFINITY;
      62             : 
      63          13 :     if (s->shortest)
      64           0 :         in[0].after = in[1].after = EXT_STOP;
      65          13 :     if (!s->repeatlast) {
      66           0 :         in[1].after = EXT_NULL;
      67           0 :         in[1].sync  = 0;
      68             :     }
      69          13 :     if (s->skip_initial_unpaired) {
      70           3 :         in[1].before = EXT_STOP;
      71             :     }
      72             : 
      73          13 :     return ff_framesync_configure(&s->fs);
      74             : }
      75             : 
      76        1496 : int ff_dualinput_filter_frame(FFDualInputContext *s,
      77             :                                    AVFilterLink *inlink, AVFrame *in)
      78             : {
      79        1496 :     return ff_framesync_filter_frame(&s->fs, inlink, in);
      80             : }
      81             : 
      82        1394 : int ff_dualinput_request_frame(FFDualInputContext *s, AVFilterLink *outlink)
      83             : {
      84        1394 :     return ff_framesync_request_frame(&s->fs, outlink);
      85             : }
      86             : 
      87          27 : void ff_dualinput_uninit(FFDualInputContext *s)
      88             : {
      89          27 :     ff_framesync_uninit(&s->fs);
      90          27 : }

Generated by: LCOV version 1.13