diff options
Diffstat (limited to 'libavfilter/avfilter.h')
-rw-r--r-- | libavfilter/avfilter.h | 195 |
1 files changed, 144 insertions, 51 deletions
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index f83c861..9c67b35 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -2,20 +2,20 @@ * filter layer * Copyright (c) 2007 Bobby Bingham * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -29,8 +29,8 @@ #include "libavutil/rational.h" #define LIBAVFILTER_VERSION_MAJOR 2 -#define LIBAVFILTER_VERSION_MINOR 13 -#define LIBAVFILTER_VERSION_MICRO 0 +#define LIBAVFILTER_VERSION_MINOR 45 +#define LIBAVFILTER_VERSION_MICRO 3 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ @@ -40,6 +40,13 @@ LIBAVFILTER_VERSION_MICRO) #define LIBAVFILTER_BUILD LIBAVFILTER_VERSION_INT +#ifndef FF_API_OLD_VSINK_API +#define FF_API_OLD_VSINK_API (LIBAVFILTER_VERSION_MAJOR < 3) +#endif +#ifndef FF_API_OLD_ALL_FORMATS_API +#define FF_API_OLD_ALL_FORMATS_API (LIBAVFILTER_VERSION_MAJOR < 3) +#endif + #include <stddef.h> /** @@ -93,6 +100,9 @@ typedef struct AVFilterBuffer { #define AV_PERM_REUSE 0x08 ///< can output the buffer multiple times, with the same contents each time #define AV_PERM_REUSE2 0x10 ///< can output the buffer multiple times, modified each time #define AV_PERM_NEG_LINESIZES 0x20 ///< the buffer requested can have negative linesizes +#define AV_PERM_ALIGN 0x40 ///< the buffer must be aligned + +#define AVFILTER_ALIGN 16 //not part of ABI /** * Audio specific properties in a reference to an AVFilterBuffer. Since @@ -101,9 +111,8 @@ typedef struct AVFilterBuffer { */ typedef struct AVFilterBufferRefAudioProps { int64_t channel_layout; ///< channel layout of audio buffer - int nb_samples; ///< number of audio samples - int size; ///< audio buffer size - uint32_t sample_rate; ///< audio buffer sample rate + int nb_samples; ///< number of audio samples per channel + int sample_rate; ///< audio buffer sample rate int planar; ///< audio buffer - planar or packed } AVFilterBufferRefAudioProps; @@ -115,7 +124,7 @@ typedef struct AVFilterBufferRefAudioProps { typedef struct AVFilterBufferRefVideoProps { int w; ///< image width int h; ///< image height - AVRational pixel_aspect; ///< pixel aspect ratio + AVRational sample_aspect_ratio; ///< sample aspect ratio int interlaced; ///< is frame interlaced int top_field_first; ///< field order enum AVPictureType pict_type; ///< picture type of the frame @@ -163,6 +172,7 @@ static inline void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilt switch (src->type) { case AVMEDIA_TYPE_VIDEO: *dst->video = *src->video; break; case AVMEDIA_TYPE_AUDIO: *dst->audio = *src->audio; break; + default: break; } } @@ -227,7 +237,7 @@ void avfilter_unref_buffer(AVFilterBufferRef *ref); */ typedef struct AVFilterFormats { unsigned format_count; ///< number of formats - int *formats; ///< list of media formats + int64_t *formats; ///< list of media formats unsigned refcount; ///< number of references to this list struct AVFilterFormats ***refs; ///< references to this list @@ -237,10 +247,12 @@ typedef struct AVFilterFormats { * Create a list of supported formats. This is intended for use in * AVFilter->query_formats(). * - * @param fmts list of media formats, terminated by -1 + * @param fmts list of media formats, terminated by -1. If NULL an + * empty list is created. * @return the format list, with no existing references */ AVFilterFormats *avfilter_make_format_list(const int *fmts); +AVFilterFormats *avfilter_make_format64_list(const int64_t *fmts); /** * Add fmt to the list of media formats contained in *avff. @@ -250,12 +262,35 @@ AVFilterFormats *avfilter_make_format_list(const int *fmts); * @return a non negative value in case of success, or a negative * value corresponding to an AVERROR code in case of error */ -int avfilter_add_format(AVFilterFormats **avff, int fmt); +int avfilter_add_format(AVFilterFormats **avff, int64_t fmt); +#if FF_API_OLD_ALL_FORMATS_API /** - * Return a list of all formats supported by Libav for the given media type. + * @deprecated Use avfilter_make_all_formats() instead. */ +attribute_deprecated AVFilterFormats *avfilter_all_formats(enum AVMediaType type); +#endif + +/** + * Return a list of all formats supported by FFmpeg for the given media type. + */ +AVFilterFormats *avfilter_make_all_formats(enum AVMediaType type); + +/** + * A list of all channel layouts supported by libavfilter. + */ +extern const int64_t avfilter_all_channel_layouts[]; + +/** + * Return a list of all channel layouts supported by FFmpeg. + */ +AVFilterFormats *avfilter_make_all_channel_layouts(void); + +/** + * Return a list of all audio packing formats. + */ +AVFilterFormats *avfilter_make_all_packing_formats(void); /** * Return a format list which contains the intersection of the formats of @@ -374,9 +409,7 @@ struct AVFilterPad { * * Input audio pads only. */ - AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms, - enum AVSampleFormat sample_fmt, int size, - int64_t channel_layout, int planar); + AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms, int nb_samples); /** * Callback called after the slices of a frame are completely sent. If @@ -426,15 +459,18 @@ struct AVFilterPad { /** * Link configuration callback. * - * For output pads, this should set the link properties such as - * width/height. This should NOT set the format property - that is - * negotiated between filters by the filter system using the + * For output pads, this should set the following link properties: + * video: width, height, sample_aspect_ratio, time_base + * audio: sample_rate. + * + * This should NOT set properties such as format, channel_layout, etc which + * are negotiated between filters by the filter system using the * query_formats() callback before this function is called. * * For input pads, this should check the properties of the link, and update * the filter's internal state as necessary. * - * For both input and output filters, this should return zero on success, + * For both input and output pads, this should return zero on success, * and another value on error. */ int (*config_props)(AVFilterLink *link); @@ -452,27 +488,23 @@ void avfilter_default_end_frame(AVFilterLink *link); /** default handler for filter_samples() for audio inputs */ void avfilter_default_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref); -/** default handler for config_props() for audio/video outputs */ -int avfilter_default_config_output_link(AVFilterLink *link); - -/** default handler for config_props() for audio/video inputs */ -int avfilter_default_config_input_link (AVFilterLink *link); - /** default handler for get_video_buffer() for video inputs */ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int perms, int w, int h); /** default handler for get_audio_buffer() for audio inputs */ -AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms, - enum AVSampleFormat sample_fmt, int size, - int64_t channel_layout, int planar); +AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, + int perms, int nb_samples); /** - * A helper for query_formats() which sets all links to the same list of - * formats. If there are no links hooked to this filter, the list of formats is - * freed. + * Helpers for query_formats() which set all links to the same list of + * formats/layouts. If there are no links hooked to this filter, the list + * of formats is freed. */ -void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats); +void avfilter_set_common_pixel_formats(AVFilterContext *ctx, AVFilterFormats *formats); +void avfilter_set_common_sample_formats(AVFilterContext *ctx, AVFilterFormats *formats); +void avfilter_set_common_channel_layouts(AVFilterContext *ctx, AVFilterFormats *formats); +void avfilter_set_common_packing_formats(AVFilterContext *ctx, AVFilterFormats *formats); /** Default handler for query_formats() */ int avfilter_default_query_formats(AVFilterContext *ctx); @@ -494,9 +526,8 @@ AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link, int perms, int w, int h); /** get_audio_buffer() handler for filters which simply pass audio along */ -AVFilterBufferRef *avfilter_null_get_audio_buffer(AVFilterLink *link, int perms, - enum AVSampleFormat sample_fmt, int size, - int64_t channel_layout, int planar); +AVFilterBufferRef *avfilter_null_get_audio_buffer(AVFilterLink *link, + int perms, int nb_samples); /** * Filter definition. This defines the pads a filter contains, and all the @@ -523,9 +554,9 @@ typedef struct AVFilter { void (*uninit)(AVFilterContext *ctx); /** - * Queries formats supported by the filter and its pads, and sets the - * in_formats for links connected to its output pads, and out_formats - * for links connected to its input pads. + * Queries formats/layouts supported by the filter and its pads, and sets + * the in_formats/in_chlayouts for links connected to its output pads, + * and out_formats/out_chlayouts for links connected to its input pads. * * @return zero on success, a negative value corresponding to an * AVERROR code otherwise @@ -540,6 +571,20 @@ typedef struct AVFilter { * NULL_IF_CONFIG_SMALL() macro to define it. */ const char *description; + + /** + * Make the filter instance process a command. + * + * @param cmd the command to process, for handling simplicity all commands must be alphanumeric only + * @param arg the argument for the command + * @param res a buffer with size res_size where the filter(s) can return a response. This must not change when the command is not supported. + * @param flags if AVFILTER_CMD_FLAG_FAST is set and the command would be + * timeconsuming then a filter should treat it like an unsupported command + * + * @returns >=0 on success otherwise an error code. + * AVERROR(ENOSYS) on unsupported commands + */ + int (*process_command)(AVFilterContext *, const char *cmd, const char *arg, char *res, int res_len, int flags); } AVFilter; /** An instance of a filter */ @@ -559,6 +604,13 @@ struct AVFilterContext { AVFilterLink **outputs; ///< array of pointers to output links void *priv; ///< private data for use by the filter + + struct AVFilterCommand *command_queue; +}; + +enum AVFilterPacking { + AVFILTER_PACKED = 0, + AVFILTER_PLANAR, }; /** @@ -588,20 +640,32 @@ struct AVFilterLink { int w; ///< agreed upon image width int h; ///< agreed upon image height AVRational sample_aspect_ratio; ///< agreed upon sample aspect ratio - /* These two parameters apply only to audio */ + /* These parameters apply only to audio */ int64_t channel_layout; ///< channel layout of current buffer (see libavutil/audioconvert.h) +#if LIBAVFILTER_VERSION_MAJOR < 3 int64_t sample_rate; ///< samples per second +#else + int sample_rate; ///< samples per second +#endif + int planar; ///< agreed upon packing mode of audio buffers. true if planar. int format; ///< agreed upon media format /** - * Lists of formats supported by the input and output filters respectively. - * These lists are used for negotiating the format to actually be used, - * which will be loaded into the format member, above, when chosen. + * Lists of formats and channel layouts supported by the input and output + * filters respectively. These lists are used for negotiating the format + * to actually be used, which will be loaded into the format and + * channel_layout members, above, when chosen. + * */ AVFilterFormats *in_formats; AVFilterFormats *out_formats; + AVFilterFormats *in_chlayouts; + AVFilterFormats *out_chlayouts; + AVFilterFormats *in_packing; + AVFilterFormats *out_packing; + /** * The buffer reference currently being sent across the link by the source * filter. This is used internally by the filter system to allow @@ -622,6 +686,8 @@ struct AVFilterLink { * input link is assumed to be an unchangeable property. */ AVRational time_base; + + struct AVFilterPool *pool; }; /** @@ -637,6 +703,11 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad); /** + * Free the link in *link, and set its pointer to NULL. + */ +void avfilter_link_free(AVFilterLink **link); + +/** * Negotiate the media format, dimensions, etc of all inputs to a filter. * * @param filter the filter to negotiate the properties for its inputs @@ -670,7 +741,7 @@ AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, * @param format the pixel format of the image specified by the data and linesize arrays */ AVFilterBufferRef * -avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int perms, +avfilter_get_video_buffer_ref_from_arrays(uint8_t * const data[4], const int linesize[4], int perms, int w, int h, enum PixelFormat format); /** @@ -679,16 +750,29 @@ avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int * @param link the output link to the filter from which the buffer will * be requested * @param perms the required access permissions - * @param sample_fmt the format of each sample in the buffer to allocate - * @param size the buffer size in bytes - * @param channel_layout the number and type of channels per sample in the buffer to allocate - * @param planar audio data layout - planar or packed + * @param nb_samples the number of samples per channel * @return A reference to the samples. This must be unreferenced with * avfilter_unref_buffer when you are finished with it. */ AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms, - enum AVSampleFormat sample_fmt, int size, - int64_t channel_layout, int planar); + int nb_samples); + +/** + * Create an audio buffer reference wrapped around an already + * allocated samples buffer. + * + * @param data pointers to the samples plane buffers + * @param linesize linesize for the samples plane buffers + * @param perms the required access permissions + * @param nb_samples number of samples per channel + * @param sample_fmt the format of each sample in the buffer to allocate + * @param channel_layout the channel layout of the buffer + * @param planar audio data layout - planar or packed + */ +AVFilterBufferRef * +avfilter_get_audio_buffer_ref_from_arrays(uint8_t *data[8], int linesize[8], int perms, + int nb_samples, enum AVSampleFormat sample_fmt, + int64_t channel_layout, int planar); /** * Request an input frame from the filter at the other end of the link. @@ -742,6 +826,15 @@ void avfilter_end_frame(AVFilterLink *link); */ void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); +#define AVFILTER_CMD_FLAG_ONE 1 ///< Stop once a filter understood the command (for target=all for example), fast filters are favored automatically +#define AVFILTER_CMD_FLAG_FAST 2 ///< Only execute command when its fast (like a video out that supports contrast adjustment in hw) + +/** + * Make the filter instance process a command. + * It is recommanded to use avfilter_graph_send_command(). + */ +int avfilter_process_command(AVFilterContext *filter, const char *cmd, const char *arg, char *res, int res_len, int flags); + /** * Send a buffer of audio samples to the next filter. * |