OSDN Git Service

libavfilter/scale2ref: Add constants for the primary input
[android-x86/external-ffmpeg.git] / libavfilter / filters.h
1 /*
2  * Filters implementation helper functions
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License
8  * as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with FFmpeg; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20
21 #ifndef AVFILTER_FILTERS_H
22 #define AVFILTER_FILTERS_H
23
24 /**
25  * Filters implementation helper functions
26  */
27
28 #include "avfilter.h"
29
30 /**
31  * Mark a filter ready and schedule it for activation.
32  *
33  * This is automatically done when something happens to the filter (queued
34  * frame, status change, request on output).
35  * Filters implementing the activate callback can call it directly to
36  * perform one more round of processing later.
37  * It is also useful for filters reacting to external or asynchronous
38  * events.
39  */
40 void ff_filter_set_ready(AVFilterContext *filter, unsigned priority);
41
42 /**
43  * Process the commands queued in the link up to the time of the frame.
44  * Commands will trigger the process_command() callback.
45  * @return  >= 0 or AVERROR code.
46  */
47 int ff_inlink_process_commands(AVFilterLink *link, const AVFrame *frame);
48
49 /**
50  * Evaluate the timeline expression of the link for the time and properties
51  * of the frame.
52  * @return  >0 if enabled, 0 if disabled
53  * @note  It does not update link->dst->is_disabled.
54  */
55 int ff_inlink_evaluate_timeline_at_frame(AVFilterLink *link, const AVFrame *frame);
56
57 /**
58  * Test if a frame is available on the link.
59  * @return  >0 if a frame is available
60  */
61 int ff_inlink_check_available_frame(AVFilterLink *link);
62
63 /**
64  * Test if enough samples are available on the link.
65  * @return  >0 if enough samples are available
66  * @note  on EOF and error, min becomes 1
67  */
68 int ff_inlink_check_available_samples(AVFilterLink *link, unsigned min);
69
70 /**
71  * Take a frame from the link's FIFO and update the link's stats.
72  *
73  * If ff_inlink_check_available_frame() was previously called, the
74  * preferred way of expressing it is "av_assert1(ret);" immediately after
75  * ff_inlink_consume_frame(). Negative error codes must still be checked.
76  *
77  * @note  May trigger process_command() and/or update is_disabled.
78  * @return  >0 if a frame is available,
79  *          0 and set rframe to NULL if no frame available,
80  *          or AVERROR code
81  */
82 int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe);
83
84 /**
85  * Take samples from the link's FIFO and update the link's stats.
86  *
87  * If ff_inlink_check_available_samples() was previously called, the
88  * preferred way of expressing it is "av_assert1(ret);" immediately after
89  * ff_inlink_consume_samples(). Negative error codes must still be checked.
90  *
91  * @note  May trigger process_command() and/or update is_disabled.
92  * @return  >0 if a frame is available,
93  *          0 and set rframe to NULL if no frame available,
94  *          or AVERROR code
95  */
96 int ff_inlink_consume_samples(AVFilterLink *link, unsigned min, unsigned max,
97                             AVFrame **rframe);
98
99 /**
100  * Make sure a frame is writable.
101  * This is similar to av_frame_make_writable() except it uses the link's
102  * buffer allocation callback, and therefore allows direct rendering.
103  */
104 int ff_inlink_make_frame_writable(AVFilterLink *link, AVFrame **rframe);
105
106 /**
107  * Test and acknowledge the change of status on the link.
108  *
109  * Status means EOF or an error condition; a change from the normal (0)
110  * status to a non-zero status can be queued in a filter's input link, it
111  * becomes relevant after the frames queued in the link's FIFO are
112  * processed. This function tests if frames are still queued and if a queued
113  * status change has not yet been processed. In that case it performs basic
114  * treatment (updating the link's timestamp) and returns a positive value to
115  * let the filter do its own treatments (flushing...).
116  *
117  * Filters implementing the activate callback should call this function when
118  * they think it might succeed (usually after checking unsuccessfully for a
119  * queued frame).
120  * Filters implementing the filter_frame and request_frame callbacks do not
121  * need to call that since the same treatment happens in ff_filter_frame().
122  *
123  * @param[out] rstatus  new or current status
124  * @param[out] rpts     current timestamp of the link in link time base
125  * @return  >0 if status changed, <0 if status already acked, 0 otherwise
126  */
127 int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts);
128
129 /**
130  * Mark that a frame is wanted on the link.
131  * Unlike ff_filter_frame(), it must not be called when the link has a
132  * non-zero status, and thus does not acknowledge it.
133  * Also it cannot fail.
134  */
135 void ff_inlink_request_frame(AVFilterLink *link);
136
137 #endif /* AVFILTER_FILTERS_H */