1 /*****************************************************************************
2 * common.h : Common macros for the VLC deinterlacer
3 *****************************************************************************
4 * Copyright (C) 2000-2017 VLC authors and VideoLAN
6 * Author: Sam Hocevar <sam@zoy.org>
7 * Steve Lhomme <robux4@gmail.com>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #ifndef VLC_DEINTERLACE_COMMON_H
25 #define VLC_DEINTERLACE_COMMON_H 1
27 #include <vlc_common.h>
28 #include <vlc_filter.h>
34 * Common macros for the VLC deinterlacer.
37 /* Needed for Yadif, but also some others. */
38 #define FFMAX(a,b) __MAX(a,b)
39 #define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c)
40 #define FFMIN(a,b) __MIN(a,b)
41 #define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c)
44 * Metadata history structure, used for framerate doublers.
45 * This is used for computing field duration in Deinterlace().
51 bool pb_top_field_first;
54 #define METADATA_SIZE (3)
55 #define HISTORY_SIZE (3)
58 bool b_double_rate; /**< Shall we double the framerate? */
59 bool b_use_frame_history; /**< Use the input frame history buffer? */
60 bool b_custom_pts; /**< for inverse telecine */
61 bool b_half_height; /**< Shall be divide the height by 2 */
64 struct deinterlace_ctx
66 /* Algorithm behaviour flags */
67 deinterlace_algo settings;
70 * Metadata history (PTS, nb_fields, TFF). Used for framerate doublers.
71 * @see metadata_history_t
73 metadata_history_t meta[METADATA_SIZE];
75 /** Output frame timing / framerate doubler control
76 (see extra documentation in deinterlace.h) */
79 /** Input frame history buffer for algorithms with temporal filtering. */
80 picture_t *pp_history[HISTORY_SIZE];
84 * @param i_order Temporal field number: 0 = first, 1 = second, 2 = repeat first.
85 * @param i_field Keep which field? 0 = top field, 1 = bottom field.
87 int (*pf_render_ordered)(filter_t *, picture_t *p_dst, picture_t *p_pic,
88 int order, int i_field);
89 int (*pf_render_single_pic)(filter_t *, picture_t *p_dst, picture_t *p_pic);
93 #define DEINTERLACE_DST_SIZE 3
95 void InitDeinterlacingContext( struct deinterlace_ctx * );
98 * @brief Get the field duration based on the previous fields or the frame rate
99 * @param fmt output format of the deinterlacer with the frame rate
100 * @param p_pic the picture which field we want the duration
101 * @return the duration of the field or 0 if there's no known framerate
103 vlc_tick_t GetFieldDuration( const struct deinterlace_ctx *,
104 const video_format_t *fmt, const picture_t *p_pic );
107 * @brief Get the output video_format_t configured for the deinterlacer
108 * @param p_dst video_format_t to fill
109 * @param p_src source video_format_t
111 void GetDeinterlacingOutput( const struct deinterlace_ctx *,
112 video_format_t *p_dst, const video_format_t *p_src );
115 * @brief Do the deinterlacing of the picture using pf_render_ordered() or pf_render_single_pic() calls.
116 * @return The deinterlaced picture or NULL if it failed
118 picture_t *DoDeinterlacing( filter_t *, struct deinterlace_ctx *, picture_t * );
121 * @brief Flush the deinterlacer context
123 void FlushDeinterlacing( struct deinterlace_ctx * );
125 picture_t *AllocPicture( filter_t * );