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