X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavfilter%2Favfilter.h;h=c5f8d56297715265057d7e226574989c6901fac2;hb=3b366c3aa0800d2df9f0678f6f4d7791b8adf2a9;hp=c92f7e14d41f3ac744c1ba7d1e6bbb2dd04f3a03;hpb=58b049f2fa4f192b00baadb5f1f32ca366f936ea;p=ffmpeg diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index c92f7e14d41..c5f8d562977 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -61,22 +61,6 @@ typedef struct AVFilterFormats AVFilterFormats; */ typedef struct AVFilterBuffer { uint8_t *data[8]; ///< buffer data for each plane/channel - int linesize[8]; ///< number of bytes per line - - unsigned refcount; ///< number of references to this buffer - - /** private data to be used by a custom free function */ - void *priv; - /** - * A pointer to the function to deallocate this buffer if the default - * function is not sufficient. This could, for example, add the memory - * back into a memory pool to be reused later without the overhead of - * reallocating it from scratch. - */ - void (*free)(struct AVFilterBuffer *buf); - - int format; ///< media format - int w, h; ///< width and height of the allocated buffer /** * pointers to the data planes/channels. @@ -93,6 +77,21 @@ typedef struct AVFilterBuffer { * in order to access all channels. */ uint8_t **extended_data; + int linesize[8]; ///< number of bytes per line + + /** private data to be used by a custom free function */ + void *priv; + /** + * A pointer to the function to deallocate this buffer if the default + * function is not sufficient. This could, for example, add the memory + * back into a memory pool to be reused later without the overhead of + * reallocating it from scratch. + */ + void (*free)(struct AVFilterBuffer *buf); + + int format; ///< media format + int w, h; ///< width and height of the allocated buffer + unsigned refcount; ///< number of references to this buffer } AVFilterBuffer; #define AV_PERM_READ 0x01 ///< can read from the buffer @@ -140,23 +139,6 @@ typedef struct AVFilterBufferRefVideoProps { typedef struct AVFilterBufferRef { AVFilterBuffer *buf; ///< the buffer that this is a reference to uint8_t *data[8]; ///< picture/audio data for each plane - int linesize[8]; ///< number of bytes per line - int format; ///< media format - - /** - * presentation timestamp. The time unit may change during - * filtering, as it is specified in the link and the filter code - * may need to rescale the PTS accordingly. - */ - int64_t pts; - int64_t pos; ///< byte position in stream, -1 if unknown - - int perms; ///< permissions, see the AV_PERM_* flags - - enum AVMediaType type; ///< media type of buffer data - AVFilterBufferRefVideoProps *video; ///< video buffer specific properties - AVFilterBufferRefAudioProps *audio; ///< audio buffer specific properties - /** * pointers to the data planes/channels. * @@ -172,6 +154,24 @@ typedef struct AVFilterBufferRef { * in order to access all channels. */ uint8_t **extended_data; + int linesize[8]; ///< number of bytes per line + + AVFilterBufferRefVideoProps *video; ///< video buffer specific properties + AVFilterBufferRefAudioProps *audio; ///< audio buffer specific properties + + /** + * presentation timestamp. The time unit may change during + * filtering, as it is specified in the link and the filter code + * may need to rescale the PTS accordingly. + */ + int64_t pts; + int64_t pos; ///< byte position in stream, -1 if unknown + + int format; ///< media format + + int perms; ///< permissions, see the AV_PERM_* flags + + enum AVMediaType type; ///< media type of buffer data } AVFilterBufferRef; /** @@ -195,45 +195,20 @@ AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask); * buffer, the buffer itself is also automatically freed. * * @param ref reference to the buffer, may be NULL + * + * @note it is recommended to use avfilter_unref_bufferp() instead of this + * function */ void avfilter_unref_buffer(AVFilterBufferRef *ref); -#if FF_API_FILTERS_PUBLIC /** - * @addtogroup lavfi_deprecated - * @deprecated Those functions are only useful inside filters and - * user filters are not supported at this point. - * @{ + * Remove a reference to a buffer and set the pointer to NULL. + * If this is the last reference to the buffer, the buffer itself + * is also automatically freed. + * + * @param ref pointer to the buffer reference */ -struct AVFilterFormats { - unsigned format_count; ///< number of formats - int *formats; ///< list of media formats - - unsigned refcount; ///< number of references to this list - struct AVFilterFormats ***refs; ///< references to this list -}; - -attribute_deprecated -AVFilterFormats *avfilter_make_format_list(const int *fmts); -attribute_deprecated -int avfilter_add_format(AVFilterFormats **avff, int fmt); -attribute_deprecated -AVFilterFormats *avfilter_all_formats(enum AVMediaType type); -attribute_deprecated -AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b); -attribute_deprecated -void avfilter_formats_ref(AVFilterFormats *formats, AVFilterFormats **ref); -attribute_deprecated -void avfilter_formats_unref(AVFilterFormats **ref); -attribute_deprecated -void avfilter_formats_changeref(AVFilterFormats **oldref, - AVFilterFormats **newref); -attribute_deprecated -void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats); -/** - * @} - */ -#endif +void avfilter_unref_bufferp(AVFilterBufferRef **ref); #if FF_API_AVFILTERPAD_PUBLIC /** @@ -278,13 +253,9 @@ struct AVFilterPad { int rej_perms; /** - * Callback called before passing the first slice of a new frame. If - * NULL, the filter layer will default to storing a reference to the - * picture inside the link structure. - * - * Input video pads only. + * @deprecated unused */ - void (*start_frame)(AVFilterLink *link, AVFilterBufferRef *picref); + int (*start_frame)(AVFilterLink *link, AVFilterBufferRef *picref); /** * Callback function to get a video buffer. If NULL, the filter system will @@ -304,29 +275,26 @@ struct AVFilterPad { int nb_samples); /** - * Callback called after the slices of a frame are completely sent. If - * NULL, the filter layer will default to releasing the reference stored - * in the link structure during start_frame(). - * - * Input video pads only. + * @deprecated unused */ - void (*end_frame)(AVFilterLink *link); + int (*end_frame)(AVFilterLink *link); /** - * Slice drawing callback. This is where a filter receives video data - * and should do its processing. - * - * Input video pads only. + * @deprecated unused */ - void (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir); + int (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir); /** - * Samples filtering callback. This is where a filter receives audio data - * and should do its processing. + * Filtering callback. This is where a filter receives a frame with + * audio/video data and should do its processing. * - * Input audio pads only. + * Input pads only. + * + * @return >= 0 on success, a negative AVERROR on error. This function + * must ensure that samplesref is properly unreferenced on error if it + * hasn't been passed on to another filter. */ - void (*filter_samples)(AVFilterLink *link, AVFilterBufferRef *samplesref); + int (*filter_frame)(AVFilterLink *link, AVFilterBufferRef *frame); /** * Frame poll callback. This returns the number of immediately available @@ -396,54 +364,6 @@ const char *avfilter_pad_get_name(AVFilterPad *pads, int pad_idx); */ enum AVMediaType avfilter_pad_get_type(AVFilterPad *pads, int pad_idx); -#if FF_API_FILTERS_PUBLIC -/** default handler for start_frame() for video inputs */ -attribute_deprecated -void avfilter_default_start_frame(AVFilterLink *link, AVFilterBufferRef *picref); - -/** default handler for draw_slice() for video inputs */ -attribute_deprecated -void avfilter_default_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); - -/** default handler for end_frame() for video inputs */ -attribute_deprecated -void avfilter_default_end_frame(AVFilterLink *link); - -#if FF_API_DEFAULT_CONFIG_OUTPUT_LINK -/** default handler for config_props() for audio/video outputs */ -attribute_deprecated -int avfilter_default_config_output_link(AVFilterLink *link); -#endif - -/** default handler for get_video_buffer() for video inputs */ -attribute_deprecated -AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, - int perms, int w, int h); - -/** Default handler for query_formats() */ -attribute_deprecated -int avfilter_default_query_formats(AVFilterContext *ctx); -#endif - -#if FF_API_FILTERS_PUBLIC -/** start_frame() handler for filters which simply pass video along */ -attribute_deprecated -void avfilter_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref); - -/** draw_slice() handler for filters which simply pass video along */ -attribute_deprecated -void avfilter_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); - -/** end_frame() handler for filters which simply pass video along */ -attribute_deprecated -void avfilter_null_end_frame(AVFilterLink *link); - -/** get_video_buffer() handler for filters which simply pass video along */ -attribute_deprecated -AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link, - int perms, int w, int h); -#endif - /** * Filter definition. This defines the pads a filter contains, and all the * callback functions used to interact with the filter. @@ -451,15 +371,28 @@ AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link, typedef struct AVFilter { const char *name; ///< filter name - int priv_size; ///< size of private data to allocate for the filter + /** + * A description for the filter. You should use the + * NULL_IF_CONFIG_SMALL() macro to define it. + */ + const char *description; + + const AVFilterPad *inputs; ///< NULL terminated list of inputs. NULL if none + const AVFilterPad *outputs; ///< NULL terminated list of outputs. NULL if none + + /***************************************************************** + * All fields below this line are not part of the public API. They + * may not be used outside of libavfilter and can be changed and + * removed at will. + * New public fields should be added right above. + ***************************************************************** + */ /** * Filter initialization function. Args contains the user-supplied * parameters. FIXME: maybe an AVOption-based system would be better? - * opaque is data provided by the code requesting creation of the filter, - * and is used to pass data to the filter. */ - int (*init)(AVFilterContext *ctx, const char *args, void *opaque); + int (*init)(AVFilterContext *ctx, const char *args); /** * Filter uninitialization function. Should deallocate any memory held @@ -478,14 +411,7 @@ typedef struct AVFilter { */ int (*query_formats)(AVFilterContext *); - const AVFilterPad *inputs; ///< NULL terminated list of inputs. NULL if none - const AVFilterPad *outputs; ///< NULL terminated list of outputs. NULL if none - - /** - * A description for the filter. You should use the - * NULL_IF_CONFIG_SMALL() macro to define it. - */ - const char *description; + int priv_size; ///< size of private data to allocate for the filter } AVFilter; /** An instance of a filter */ @@ -496,22 +422,21 @@ struct AVFilterContext { char *name; ///< name of this filter instance + AVFilterPad *input_pads; ///< array of input pads + AVFilterLink **inputs; ///< array of pointers to input links #if FF_API_FOO_COUNT unsigned input_count; ///< @deprecated use nb_inputs #endif - AVFilterPad *input_pads; ///< array of input pads - AVFilterLink **inputs; ///< array of pointers to input links + unsigned nb_inputs; ///< number of input pads + AVFilterPad *output_pads; ///< array of output pads + AVFilterLink **outputs; ///< array of pointers to output links #if FF_API_FOO_COUNT unsigned output_count; ///< @deprecated use nb_outputs #endif - AVFilterPad *output_pads; ///< array of output pads - AVFilterLink **outputs; ///< array of pointers to output links + unsigned nb_outputs; ///< number of output pads void *priv; ///< private data for use by the filter - - unsigned nb_inputs; ///< number of input pads - unsigned nb_outputs; ///< number of output pads }; /** @@ -528,13 +453,6 @@ struct AVFilterLink { AVFilterContext *dst; ///< dest filter AVFilterPad *dstpad; ///< input pad on the dest filter - /** stage of the initialization of the link properties (dimensions, etc) */ - enum { - AVLINK_UNINIT = 0, ///< not started - AVLINK_STARTINIT, ///< started, but incomplete - AVLINK_INIT ///< complete - } init_state; - enum AVMediaType type; ///< filter media type /* These parameters apply only to video */ @@ -542,35 +460,11 @@ struct AVFilterLink { int h; ///< agreed upon image height AVRational sample_aspect_ratio; ///< agreed upon sample aspect ratio /* These two parameters apply only to audio */ - uint64_t channel_layout; ///< channel layout of current buffer (see libavutil/audioconvert.h) -#if FF_API_SAMPLERATE64 - int64_t sample_rate; ///< samples per second -#else + uint64_t channel_layout; ///< channel layout of current buffer (see libavutil/channel_layout.h) int sample_rate; ///< samples per second -#endif 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. - */ - AVFilterFormats *in_formats; - AVFilterFormats *out_formats; - - /** - * The buffer reference currently being sent across the link by the source - * filter. This is used internally by the filter system to allow - * automatic copying of buffers which do not have sufficient permissions - * for the destination. This should not be accessed directly by the - * filters. - */ - AVFilterBufferRef *src_buf; - - AVFilterBufferRef *cur_buf; - AVFilterBufferRef *out_buf; - /** * Define the time base used by the PTS of the frames/samples * which will pass through this link. @@ -587,6 +481,14 @@ struct AVFilterLink { * New public fields should be added right above. ***************************************************************** */ + /** + * 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. + */ + AVFilterFormats *in_formats; + AVFilterFormats *out_formats; + /** * Lists of channel layouts and sample rates used for automatic * negotiation. @@ -595,6 +497,22 @@ struct AVFilterLink { AVFilterFormats *out_samplerates; struct AVFilterChannelLayouts *in_channel_layouts; struct AVFilterChannelLayouts *out_channel_layouts; + + /** + * Audio only, the destination filter sets this to a non-zero value to + * request that buffers with the given number of samples should be sent to + * it. AVFilterPad.needs_fifo must also be set on the corresponding input + * pad. + * Last buffer before EOF will be padded with silence. + */ + int request_samples; + + /** stage of the initialization of the link properties (dimensions, etc) */ + enum { + AVLINK_UNINIT = 0, ///< not started + AVLINK_STARTINIT, ///< started, but incomplete + AVLINK_INIT ///< complete + } init_state; }; /** @@ -617,12 +535,6 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad, */ int avfilter_config_links(AVFilterContext *filter); -#if FF_API_FILTERS_PUBLIC -attribute_deprecated -AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, - int w, int h); -#endif - /** * Create a buffer reference wrapped around an already allocated image * buffer. @@ -636,7 +548,7 @@ AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, */ AVFilterBufferRef * avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int perms, - int w, int h, enum PixelFormat format); + int w, int h, enum AVPixelFormat format); /** * Create an audio buffer reference wrapped around an already @@ -656,21 +568,6 @@ AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data, enum AVSampleFormat sample_fmt, uint64_t channel_layout); -#if FF_API_FILTERS_PUBLIC -attribute_deprecated -int avfilter_request_frame(AVFilterLink *link); - -attribute_deprecated -int avfilter_poll_frame(AVFilterLink *link); - -attribute_deprecated -void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref); -attribute_deprecated -void avfilter_end_frame(AVFilterLink *link); -attribute_deprecated -void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); -#endif - /** Initialize the filter system. Register all builtin filters. */ void avfilter_register_all(void); @@ -748,20 +645,6 @@ void avfilter_free(AVFilterContext *filter); int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt, unsigned filt_srcpad_idx, unsigned filt_dstpad_idx); -#if FF_API_FILTERS_PUBLIC -attribute_deprecated -void avfilter_insert_pad(unsigned idx, unsigned *count, size_t padidx_off, - AVFilterPad **pads, AVFilterLink ***links, - AVFilterPad *newpad); - -attribute_deprecated -void avfilter_insert_inpad(AVFilterContext *f, unsigned index, - AVFilterPad *p); -attribute_deprecated -void avfilter_insert_outpad(AVFilterContext *f, unsigned index, - AVFilterPad *p); -#endif - /** * Copy the frame properties of src to dst, without copying the actual * image data.