LCOV - code coverage report
Current view: top level - libavfilter - vf_yadif.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 164 234 70.1 %
Date: 2017-12-12 11:08:38 Functions: 11 14 78.6 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (C) 2006-2011 Michael Niedermayer <michaelni@gmx.at>
       3             :  *               2010      James Darnley <james.darnley@gmail.com>
       4             : 
       5             :  * This file is part of FFmpeg.
       6             :  *
       7             :  * FFmpeg is free software; you can redistribute it and/or
       8             :  * modify it under the terms of the GNU Lesser General Public
       9             :  * License as published by the Free Software Foundation; either
      10             :  * version 2.1 of the License, or (at your option) any later version.
      11             :  *
      12             :  * FFmpeg is distributed in the hope that it will be useful,
      13             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15             :  * Lesser General Public License for more details.
      16             :  *
      17             :  * You should have received a copy of the GNU Lesser General Public
      18             :  * License along with FFmpeg; if not, write to the Free Software
      19             :  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
      20             :  */
      21             : 
      22             : #include "libavutil/avassert.h"
      23             : #include "libavutil/cpu.h"
      24             : #include "libavutil/common.h"
      25             : #include "libavutil/opt.h"
      26             : #include "libavutil/pixdesc.h"
      27             : #include "libavutil/imgutils.h"
      28             : #include "avfilter.h"
      29             : #include "formats.h"
      30             : #include "internal.h"
      31             : #include "video.h"
      32             : #include "yadif.h"
      33             : 
      34             : typedef struct ThreadData {
      35             :     AVFrame *frame;
      36             :     int plane;
      37             :     int w, h;
      38             :     int parity;
      39             :     int tff;
      40             : } ThreadData;
      41             : 
      42             : #define CHECK(j)\
      43             :     {   int score = FFABS(cur[mrefs - 1 + (j)] - cur[prefs - 1 - (j)])\
      44             :                   + FFABS(cur[mrefs  +(j)] - cur[prefs  -(j)])\
      45             :                   + FFABS(cur[mrefs + 1 + (j)] - cur[prefs + 1 - (j)]);\
      46             :         if (score < spatial_score) {\
      47             :             spatial_score= score;\
      48             :             spatial_pred= (cur[mrefs  +(j)] + cur[prefs  -(j)])>>1;\
      49             : 
      50             : /* The is_not_edge argument here controls when the code will enter a branch
      51             :  * which reads up to and including x-3 and x+3. */
      52             : 
      53             : #define FILTER(start, end, is_not_edge) \
      54             :     for (x = start;  x < end; x++) { \
      55             :         int c = cur[mrefs]; \
      56             :         int d = (prev2[0] + next2[0])>>1; \
      57             :         int e = cur[prefs]; \
      58             :         int temporal_diff0 = FFABS(prev2[0] - next2[0]); \
      59             :         int temporal_diff1 =(FFABS(prev[mrefs] - c) + FFABS(prev[prefs] - e) )>>1; \
      60             :         int temporal_diff2 =(FFABS(next[mrefs] - c) + FFABS(next[prefs] - e) )>>1; \
      61             :         int diff = FFMAX3(temporal_diff0 >> 1, temporal_diff1, temporal_diff2); \
      62             :         int spatial_pred = (c+e) >> 1; \
      63             :  \
      64             :         if (is_not_edge) {\
      65             :             int spatial_score = FFABS(cur[mrefs - 1] - cur[prefs - 1]) + FFABS(c-e) \
      66             :                               + FFABS(cur[mrefs + 1] - cur[prefs + 1]) - 1; \
      67             :             CHECK(-1) CHECK(-2) }} }} \
      68             :             CHECK( 1) CHECK( 2) }} }} \
      69             :         }\
      70             :  \
      71             :         if (!(mode&2)) { \
      72             :             int b = (prev2[2 * mrefs] + next2[2 * mrefs])>>1; \
      73             :             int f = (prev2[2 * prefs] + next2[2 * prefs])>>1; \
      74             :             int max = FFMAX3(d - e, d - c, FFMIN(b - c, f - e)); \
      75             :             int min = FFMIN3(d - e, d - c, FFMAX(b - c, f - e)); \
      76             :  \
      77             :             diff = FFMAX3(diff, min, -max); \
      78             :         } \
      79             :  \
      80             :         if (spatial_pred > d + diff) \
      81             :            spatial_pred = d + diff; \
      82             :         else if (spatial_pred < d - diff) \
      83             :            spatial_pred = d - diff; \
      84             :  \
      85             :         dst[0] = spatial_pred; \
      86             :  \
      87             :         dst++; \
      88             :         cur++; \
      89             :         prev++; \
      90             :         next++; \
      91             :         prev2++; \
      92             :         next2++; \
      93             :     }
      94             : 
      95       88704 : static void filter_line_c(void *dst1,
      96             :                           void *prev1, void *cur1, void *next1,
      97             :                           int w, int prefs, int mrefs, int parity, int mode)
      98             : {
      99       88704 :     uint8_t *dst  = dst1;
     100       88704 :     uint8_t *prev = prev1;
     101       88704 :     uint8_t *cur  = cur1;
     102       88704 :     uint8_t *next = next1;
     103             :     int x;
     104       88704 :     uint8_t *prev2 = parity ? prev : cur ;
     105       88704 :     uint8_t *next2 = parity ? cur  : next;
     106             : 
     107             :     /* The function is called with the pointers already pointing to data[3] and
     108             :      * with 6 subtracted from the width.  This allows the FILTER macro to be
     109             :      * called so that it processes all the pixels normally.  A constant value of
     110             :      * true for is_not_edge lets the compiler ignore the if statement. */
     111       88704 :     FILTER(0, w, 1)
     112       88704 : }
     113             : 
     114             : #define MAX_ALIGN 8
     115       88704 : static void filter_edges(void *dst1, void *prev1, void *cur1, void *next1,
     116             :                          int w, int prefs, int mrefs, int parity, int mode)
     117             : {
     118       88704 :     uint8_t *dst  = dst1;
     119       88704 :     uint8_t *prev = prev1;
     120       88704 :     uint8_t *cur  = cur1;
     121       88704 :     uint8_t *next = next1;
     122             :     int x;
     123       88704 :     uint8_t *prev2 = parity ? prev : cur ;
     124       88704 :     uint8_t *next2 = parity ? cur  : next;
     125             : 
     126       88704 :     const int edge = MAX_ALIGN - 1;
     127             : 
     128             :     /* Only edge pixels need to be processed here.  A constant value of false
     129             :      * for is_not_edge should let the compiler ignore the whole branch. */
     130       88704 :     FILTER(0, 3, 0)
     131             : 
     132       88704 :     dst  = (uint8_t*)dst1  + w - edge;
     133       88704 :     prev = (uint8_t*)prev1 + w - edge;
     134       88704 :     cur  = (uint8_t*)cur1  + w - edge;
     135       88704 :     next = (uint8_t*)next1 + w - edge;
     136       88704 :     prev2 = (uint8_t*)(parity ? prev : cur);
     137       88704 :     next2 = (uint8_t*)(parity ? cur  : next);
     138             : 
     139       88704 :     FILTER(w - edge, w - 3, 1)
     140       88704 :     FILTER(w - 3, w, 0)
     141       88704 : }
     142             : 
     143             : 
     144           0 : static void filter_line_c_16bit(void *dst1,
     145             :                                 void *prev1, void *cur1, void *next1,
     146             :                                 int w, int prefs, int mrefs, int parity,
     147             :                                 int mode)
     148             : {
     149           0 :     uint16_t *dst  = dst1;
     150           0 :     uint16_t *prev = prev1;
     151           0 :     uint16_t *cur  = cur1;
     152           0 :     uint16_t *next = next1;
     153             :     int x;
     154           0 :     uint16_t *prev2 = parity ? prev : cur ;
     155           0 :     uint16_t *next2 = parity ? cur  : next;
     156           0 :     mrefs /= 2;
     157           0 :     prefs /= 2;
     158             : 
     159           0 :     FILTER(0, w, 1)
     160           0 : }
     161             : 
     162           0 : static void filter_edges_16bit(void *dst1, void *prev1, void *cur1, void *next1,
     163             :                                int w, int prefs, int mrefs, int parity, int mode)
     164             : {
     165           0 :     uint16_t *dst  = dst1;
     166           0 :     uint16_t *prev = prev1;
     167           0 :     uint16_t *cur  = cur1;
     168           0 :     uint16_t *next = next1;
     169             :     int x;
     170           0 :     uint16_t *prev2 = parity ? prev : cur ;
     171           0 :     uint16_t *next2 = parity ? cur  : next;
     172             : 
     173           0 :     const int edge = MAX_ALIGN / 2 - 1;
     174             : 
     175           0 :     mrefs /= 2;
     176           0 :     prefs /= 2;
     177             : 
     178           0 :     FILTER(0, 3, 0)
     179             : 
     180           0 :     dst   = (uint16_t*)dst1  + w - edge;
     181           0 :     prev  = (uint16_t*)prev1 + w - edge;
     182           0 :     cur   = (uint16_t*)cur1  + w - edge;
     183           0 :     next  = (uint16_t*)next1 + w - edge;
     184           0 :     prev2 = (uint16_t*)(parity ? prev : cur);
     185           0 :     next2 = (uint16_t*)(parity ? cur  : next);
     186             : 
     187           0 :     FILTER(w - edge, w - 3, 1)
     188           0 :     FILTER(w - 3, w, 0)
     189           0 : }
     190             : 
     191        4158 : static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
     192             : {
     193        4158 :     YADIFContext *s = ctx->priv;
     194        4158 :     ThreadData *td  = arg;
     195        4158 :     int refs = s->cur->linesize[td->plane];
     196        4158 :     int df = (s->csp->comp[td->plane].depth + 7) / 8;
     197        4158 :     int pix_3 = 3 * df;
     198        4158 :     int slice_start = (td->h *  jobnr   ) / nb_jobs;
     199        4158 :     int slice_end   = (td->h * (jobnr+1)) / nb_jobs;
     200             :     int y;
     201        4158 :     int edge = 3 + MAX_ALIGN / df - 1;
     202             : 
     203             :     /* filtering reads 3 pixels to the left/right; to avoid invalid reads,
     204             :      * we need to call the c variant which avoids this for border pixels
     205             :      */
     206      181566 :     for (y = slice_start; y < slice_end; y++) {
     207      177408 :         if ((y ^ td->parity) & 1) {
     208       88704 :             uint8_t *prev = &s->prev->data[td->plane][y * refs];
     209       88704 :             uint8_t *cur  = &s->cur ->data[td->plane][y * refs];
     210       88704 :             uint8_t *next = &s->next->data[td->plane][y * refs];
     211       88704 :             uint8_t *dst  = &td->frame->data[td->plane][y * td->frame->linesize[td->plane]];
     212       88704 :             int     mode  = y == 1 || y + 2 == td->h ? 2 : s->mode;
     213      443520 :             s->filter_line(dst + pix_3, prev + pix_3, cur + pix_3,
     214      177408 :                            next + pix_3, td->w - edge,
     215       88704 :                            y + 1 < td->h ? refs : -refs,
     216             :                            y ? -refs : refs,
     217       88704 :                            td->parity ^ td->tff, mode);
     218      266112 :             s->filter_edges(dst, prev, cur, next, td->w,
     219       88704 :                             y + 1 < td->h ? refs : -refs,
     220             :                             y ? -refs : refs,
     221       88704 :                             td->parity ^ td->tff, mode);
     222             :         } else {
     223      177408 :             memcpy(&td->frame->data[td->plane][y * td->frame->linesize[td->plane]],
     224      177408 :                    &s->cur->data[td->plane][y * refs], td->w * df);
     225             :         }
     226             :     }
     227        4158 :     return 0;
     228             : }
     229             : 
     230         154 : static void filter(AVFilterContext *ctx, AVFrame *dstpic,
     231             :                    int parity, int tff)
     232             : {
     233         154 :     YADIFContext *yadif = ctx->priv;
     234         154 :     ThreadData td = { .frame = dstpic, .parity = parity, .tff = tff };
     235             :     int i;
     236             : 
     237         616 :     for (i = 0; i < yadif->csp->nb_components; i++) {
     238         462 :         int w = dstpic->width;
     239         462 :         int h = dstpic->height;
     240             : 
     241         462 :         if (i == 1 || i == 2) {
     242         308 :             w = AV_CEIL_RSHIFT(w, yadif->csp->log2_chroma_w);
     243         308 :             h = AV_CEIL_RSHIFT(h, yadif->csp->log2_chroma_h);
     244             :         }
     245             : 
     246             : 
     247         462 :         td.w       = w;
     248         462 :         td.h       = h;
     249         462 :         td.plane   = i;
     250             : 
     251         462 :         ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(h, ff_filter_get_nb_threads(ctx)));
     252             :     }
     253             : 
     254         154 :     emms_c();
     255         154 : }
     256             : 
     257         154 : static int return_frame(AVFilterContext *ctx, int is_second)
     258             : {
     259         154 :     YADIFContext *yadif = ctx->priv;
     260         154 :     AVFilterLink *link  = ctx->outputs[0];
     261             :     int tff, ret;
     262             : 
     263         154 :     if (yadif->parity == -1) {
     264         308 :         tff = yadif->cur->interlaced_frame ?
     265         154 :               yadif->cur->top_field_first : 1;
     266             :     } else {
     267           0 :         tff = yadif->parity ^ 1;
     268             :     }
     269             : 
     270         154 :     if (is_second) {
     271          30 :         yadif->out = ff_get_video_buffer(link, link->w, link->h);
     272          30 :         if (!yadif->out)
     273           0 :             return AVERROR(ENOMEM);
     274             : 
     275          30 :         av_frame_copy_props(yadif->out, yadif->cur);
     276          30 :         yadif->out->interlaced_frame = 0;
     277             :     }
     278             : 
     279         154 :     filter(ctx, yadif->out, tff ^ !is_second, tff);
     280             : 
     281         154 :     if (is_second) {
     282          30 :         int64_t cur_pts  = yadif->cur->pts;
     283          30 :         int64_t next_pts = yadif->next->pts;
     284             : 
     285          30 :         if (next_pts != AV_NOPTS_VALUE && cur_pts != AV_NOPTS_VALUE) {
     286          30 :             yadif->out->pts = cur_pts + next_pts;
     287             :         } else {
     288           0 :             yadif->out->pts = AV_NOPTS_VALUE;
     289             :         }
     290             :     }
     291         154 :     ret = ff_filter_frame(ctx->outputs[0], yadif->out);
     292             : 
     293         154 :     yadif->frame_pending = (yadif->mode&1) && !is_second;
     294         154 :     return ret;
     295             : }
     296             : 
     297         632 : static int checkstride(YADIFContext *yadif, const AVFrame *a, const AVFrame *b)
     298             : {
     299             :     int i;
     300        2528 :     for (i = 0; i < yadif->csp->nb_components; i++)
     301        1896 :         if (a->linesize[i] != b->linesize[i])
     302           0 :             return 1;
     303         632 :     return 0;
     304             : }
     305             : 
     306           0 : static void fixstride(AVFilterLink *link, AVFrame *f)
     307             : {
     308           0 :     AVFrame *dst = ff_default_get_video_buffer(link, f->width, f->height);
     309           0 :     if(!dst)
     310           0 :         return;
     311           0 :     av_frame_copy_props(dst, f);
     312           0 :     av_image_copy(dst->data, dst->linesize,
     313           0 :                   (const uint8_t **)f->data, f->linesize,
     314           0 :                   dst->format, dst->width, dst->height);
     315           0 :     av_frame_unref(f);
     316           0 :     av_frame_move_ref(f, dst);
     317           0 :     av_frame_free(&dst);
     318             : }
     319             : 
     320         128 : static int filter_frame(AVFilterLink *link, AVFrame *frame)
     321             : {
     322         128 :     AVFilterContext *ctx = link->dst;
     323         128 :     YADIFContext *yadif = ctx->priv;
     324             : 
     325         128 :     av_assert0(frame);
     326             : 
     327         128 :     if (yadif->frame_pending)
     328           0 :         return_frame(ctx, 1);
     329             : 
     330         128 :     if (yadif->prev)
     331         120 :         av_frame_free(&yadif->prev);
     332         128 :     yadif->prev = yadif->cur;
     333         128 :     yadif->cur  = yadif->next;
     334         128 :     yadif->next = frame;
     335             : 
     336         132 :     if (!yadif->cur &&
     337           4 :         !(yadif->cur = av_frame_clone(yadif->next)))
     338           0 :         return AVERROR(ENOMEM);
     339             : 
     340         128 :     if (checkstride(yadif, yadif->next, yadif->cur)) {
     341           0 :         av_log(ctx, AV_LOG_VERBOSE, "Reallocating frame due to differing stride\n");
     342           0 :         fixstride(link, yadif->next);
     343             :     }
     344         128 :     if (checkstride(yadif, yadif->next, yadif->cur))
     345           0 :         fixstride(link, yadif->cur);
     346         128 :     if (yadif->prev && checkstride(yadif, yadif->next, yadif->prev))
     347           0 :         fixstride(link, yadif->prev);
     348         128 :     if (checkstride(yadif, yadif->next, yadif->cur) || (yadif->prev && checkstride(yadif, yadif->next, yadif->prev))) {
     349           0 :         av_log(ctx, AV_LOG_ERROR, "Failed to reallocate frame\n");
     350           0 :         return -1;
     351             :     }
     352             : 
     353         128 :     if (!yadif->prev)
     354           4 :         return 0;
     355             : 
     356         248 :     if ((yadif->deint && !yadif->cur->interlaced_frame) ||
     357         248 :         ctx->is_disabled ||
     358         248 :         (yadif->deint && !yadif->prev->interlaced_frame && yadif->prev->repeat_pict) ||
     359         124 :         (yadif->deint && !yadif->next->interlaced_frame && yadif->next->repeat_pict)
     360             :     ) {
     361           0 :         yadif->out  = av_frame_clone(yadif->cur);
     362           0 :         if (!yadif->out)
     363           0 :             return AVERROR(ENOMEM);
     364             : 
     365           0 :         av_frame_free(&yadif->prev);
     366           0 :         if (yadif->out->pts != AV_NOPTS_VALUE)
     367           0 :             yadif->out->pts *= 2;
     368           0 :         return ff_filter_frame(ctx->outputs[0], yadif->out);
     369             :     }
     370             : 
     371         124 :     yadif->out = ff_get_video_buffer(ctx->outputs[0], link->w, link->h);
     372         124 :     if (!yadif->out)
     373           0 :         return AVERROR(ENOMEM);
     374             : 
     375         124 :     av_frame_copy_props(yadif->out, yadif->cur);
     376         124 :     yadif->out->interlaced_frame = 0;
     377             : 
     378         124 :     if (yadif->out->pts != AV_NOPTS_VALUE)
     379         124 :         yadif->out->pts *= 2;
     380             : 
     381         124 :     return return_frame(ctx, 0);
     382             : }
     383             : 
     384         154 : static int request_frame(AVFilterLink *link)
     385             : {
     386         154 :     AVFilterContext *ctx = link->src;
     387         154 :     YADIFContext *yadif = ctx->priv;
     388             :     int ret;
     389             : 
     390         154 :     if (yadif->frame_pending) {
     391          30 :         return_frame(ctx, 1);
     392          30 :         return 0;
     393             :     }
     394             : 
     395         124 :     if (yadif->eof)
     396           0 :         return AVERROR_EOF;
     397             : 
     398         124 :     ret  = ff_request_frame(ctx->inputs[0]);
     399             : 
     400         128 :     if (ret == AVERROR_EOF && yadif->cur) {
     401           4 :         AVFrame *next = av_frame_clone(yadif->next);
     402             : 
     403           4 :         if (!next)
     404           0 :             return AVERROR(ENOMEM);
     405             : 
     406           4 :         next->pts = yadif->next->pts * 2 - yadif->cur->pts;
     407             : 
     408           4 :         filter_frame(ctx->inputs[0], next);
     409           4 :         yadif->eof = 1;
     410         120 :     } else if (ret < 0) {
     411           0 :         return ret;
     412             :     }
     413             : 
     414         124 :     return 0;
     415             : }
     416             : 
     417           4 : static av_cold void uninit(AVFilterContext *ctx)
     418             : {
     419           4 :     YADIFContext *yadif = ctx->priv;
     420             : 
     421           4 :     av_frame_free(&yadif->prev);
     422           4 :     av_frame_free(&yadif->cur );
     423           4 :     av_frame_free(&yadif->next);
     424           4 : }
     425             : 
     426           4 : static int query_formats(AVFilterContext *ctx)
     427             : {
     428             :     static const enum AVPixelFormat pix_fmts[] = {
     429             :         AV_PIX_FMT_YUV420P,
     430             :         AV_PIX_FMT_YUV422P,
     431             :         AV_PIX_FMT_YUV444P,
     432             :         AV_PIX_FMT_YUV410P,
     433             :         AV_PIX_FMT_YUV411P,
     434             :         AV_PIX_FMT_GRAY8,
     435             :         AV_PIX_FMT_YUVJ420P,
     436             :         AV_PIX_FMT_YUVJ422P,
     437             :         AV_PIX_FMT_YUVJ444P,
     438             :         AV_PIX_FMT_GRAY16,
     439             :         AV_PIX_FMT_YUV440P,
     440             :         AV_PIX_FMT_YUVJ440P,
     441             :         AV_PIX_FMT_YUV420P9,
     442             :         AV_PIX_FMT_YUV422P9,
     443             :         AV_PIX_FMT_YUV444P9,
     444             :         AV_PIX_FMT_YUV420P10,
     445             :         AV_PIX_FMT_YUV422P10,
     446             :         AV_PIX_FMT_YUV444P10,
     447             :         AV_PIX_FMT_YUV420P12,
     448             :         AV_PIX_FMT_YUV422P12,
     449             :         AV_PIX_FMT_YUV444P12,
     450             :         AV_PIX_FMT_YUV420P14,
     451             :         AV_PIX_FMT_YUV422P14,
     452             :         AV_PIX_FMT_YUV444P14,
     453             :         AV_PIX_FMT_YUV420P16,
     454             :         AV_PIX_FMT_YUV422P16,
     455             :         AV_PIX_FMT_YUV444P16,
     456             :         AV_PIX_FMT_YUVA420P,
     457             :         AV_PIX_FMT_YUVA422P,
     458             :         AV_PIX_FMT_YUVA444P,
     459             :         AV_PIX_FMT_GBRP,
     460             :         AV_PIX_FMT_GBRP9,
     461             :         AV_PIX_FMT_GBRP10,
     462             :         AV_PIX_FMT_GBRP12,
     463             :         AV_PIX_FMT_GBRP14,
     464             :         AV_PIX_FMT_GBRP16,
     465             :         AV_PIX_FMT_GBRAP,
     466             :         AV_PIX_FMT_NONE
     467             :     };
     468             : 
     469           4 :     AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
     470           4 :     if (!fmts_list)
     471           0 :         return AVERROR(ENOMEM);
     472           4 :     return ff_set_common_formats(ctx, fmts_list);
     473             : }
     474             : 
     475           4 : static int config_props(AVFilterLink *link)
     476             : {
     477           4 :     AVFilterContext *ctx = link->src;
     478           4 :     YADIFContext *s = ctx->priv;
     479             : 
     480           4 :     link->time_base.num = ctx->inputs[0]->time_base.num;
     481           4 :     link->time_base.den = ctx->inputs[0]->time_base.den * 2;
     482           4 :     link->w             = ctx->inputs[0]->w;
     483           4 :     link->h             = ctx->inputs[0]->h;
     484             : 
     485           4 :     if(s->mode & 1)
     486           1 :         link->frame_rate = av_mul_q(ctx->inputs[0]->frame_rate,
     487           1 :                                     (AVRational){2, 1});
     488             : 
     489           4 :     if (link->w < 3 || link->h < 3) {
     490           0 :         av_log(ctx, AV_LOG_ERROR, "Video of less than 3 columns or lines is not supported\n");
     491           0 :         return AVERROR(EINVAL);
     492             :     }
     493             : 
     494           4 :     s->csp = av_pix_fmt_desc_get(link->format);
     495           4 :     if (s->csp->comp[0].depth > 8) {
     496           0 :         s->filter_line  = filter_line_c_16bit;
     497           0 :         s->filter_edges = filter_edges_16bit;
     498             :     } else {
     499           4 :         s->filter_line  = filter_line_c;
     500           4 :         s->filter_edges = filter_edges;
     501             :     }
     502             : 
     503             :     if (ARCH_X86)
     504           4 :         ff_yadif_init_x86(s);
     505             : 
     506           4 :     return 0;
     507             : }
     508             : 
     509             : 
     510             : #define OFFSET(x) offsetof(YADIFContext, x)
     511             : #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
     512             : 
     513             : #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, INT_MIN, INT_MAX, FLAGS, unit }
     514             : 
     515             : static const AVOption yadif_options[] = {
     516             :     { "mode",   "specify the interlacing mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=YADIF_MODE_SEND_FRAME}, 0, 3, FLAGS, "mode"},
     517             :     CONST("send_frame",           "send one frame for each frame",                                     YADIF_MODE_SEND_FRAME,           "mode"),
     518             :     CONST("send_field",           "send one frame for each field",                                     YADIF_MODE_SEND_FIELD,           "mode"),
     519             :     CONST("send_frame_nospatial", "send one frame for each frame, but skip spatial interlacing check", YADIF_MODE_SEND_FRAME_NOSPATIAL, "mode"),
     520             :     CONST("send_field_nospatial", "send one frame for each field, but skip spatial interlacing check", YADIF_MODE_SEND_FIELD_NOSPATIAL, "mode"),
     521             : 
     522             :     { "parity", "specify the assumed picture field parity", OFFSET(parity), AV_OPT_TYPE_INT, {.i64=YADIF_PARITY_AUTO}, -1, 1, FLAGS, "parity" },
     523             :     CONST("tff",  "assume top field first",    YADIF_PARITY_TFF,  "parity"),
     524             :     CONST("bff",  "assume bottom field first", YADIF_PARITY_BFF,  "parity"),
     525             :     CONST("auto", "auto detect parity",        YADIF_PARITY_AUTO, "parity"),
     526             : 
     527             :     { "deint", "specify which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=YADIF_DEINT_ALL}, 0, 1, FLAGS, "deint" },
     528             :     CONST("all",        "deinterlace all frames",                       YADIF_DEINT_ALL,         "deint"),
     529             :     CONST("interlaced", "only deinterlace frames marked as interlaced", YADIF_DEINT_INTERLACED,  "deint"),
     530             : 
     531             :     { NULL }
     532             : };
     533             : 
     534             : AVFILTER_DEFINE_CLASS(yadif);
     535             : 
     536             : static const AVFilterPad avfilter_vf_yadif_inputs[] = {
     537             :     {
     538             :         .name          = "default",
     539             :         .type          = AVMEDIA_TYPE_VIDEO,
     540             :         .filter_frame  = filter_frame,
     541             :     },
     542             :     { NULL }
     543             : };
     544             : 
     545             : static const AVFilterPad avfilter_vf_yadif_outputs[] = {
     546             :     {
     547             :         .name          = "default",
     548             :         .type          = AVMEDIA_TYPE_VIDEO,
     549             :         .request_frame = request_frame,
     550             :         .config_props  = config_props,
     551             :     },
     552             :     { NULL }
     553             : };
     554             : 
     555             : AVFilter ff_vf_yadif = {
     556             :     .name          = "yadif",
     557             :     .description   = NULL_IF_CONFIG_SMALL("Deinterlace the input image."),
     558             :     .priv_size     = sizeof(YADIFContext),
     559             :     .priv_class    = &yadif_class,
     560             :     .uninit        = uninit,
     561             :     .query_formats = query_formats,
     562             :     .inputs        = avfilter_vf_yadif_inputs,
     563             :     .outputs       = avfilter_vf_yadif_outputs,
     564             :     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
     565             : };

Generated by: LCOV version 1.13