Deprecated in 11/2012.
Vittorio Giovara authored on 2015/07/28 22:30:21... | ... |
@@ -66,75 +66,3 @@ AVFrame *ff_get_audio_buffer(AVFilterLink *link, int nb_samples) |
66 | 66 |
|
67 | 67 |
return ret; |
68 | 68 |
} |
69 |
- |
|
70 |
-#if FF_API_AVFILTERBUFFER |
|
71 |
-AVFilterBufferRef* avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data, |
|
72 |
- int linesize,int perms, |
|
73 |
- int nb_samples, |
|
74 |
- enum AVSampleFormat sample_fmt, |
|
75 |
- uint64_t channel_layout) |
|
76 |
-{ |
|
77 |
- int planes; |
|
78 |
- AVFilterBuffer *samples = av_mallocz(sizeof(*samples)); |
|
79 |
- AVFilterBufferRef *samplesref = av_mallocz(sizeof(*samplesref)); |
|
80 |
- |
|
81 |
- if (!samples || !samplesref) |
|
82 |
- goto fail; |
|
83 |
- |
|
84 |
- samplesref->buf = samples; |
|
85 |
- samplesref->buf->free = ff_avfilter_default_free_buffer; |
|
86 |
- if (!(samplesref->audio = av_mallocz(sizeof(*samplesref->audio)))) |
|
87 |
- goto fail; |
|
88 |
- |
|
89 |
- samplesref->audio->nb_samples = nb_samples; |
|
90 |
- samplesref->audio->channel_layout = channel_layout; |
|
91 |
- samplesref->audio->planar = av_sample_fmt_is_planar(sample_fmt); |
|
92 |
- |
|
93 |
- planes = samplesref->audio->planar ? av_get_channel_layout_nb_channels(channel_layout) : 1; |
|
94 |
- |
|
95 |
- /* make sure the buffer gets read permission or it's useless for output */ |
|
96 |
- samplesref->perms = perms | AV_PERM_READ; |
|
97 |
- |
|
98 |
- samples->refcount = 1; |
|
99 |
- samplesref->type = AVMEDIA_TYPE_AUDIO; |
|
100 |
- samplesref->format = sample_fmt; |
|
101 |
- |
|
102 |
- memcpy(samples->data, data, |
|
103 |
- FFMIN(FF_ARRAY_ELEMS(samples->data), planes)*sizeof(samples->data[0])); |
|
104 |
- memcpy(samplesref->data, samples->data, sizeof(samples->data)); |
|
105 |
- |
|
106 |
- samples->linesize[0] = samplesref->linesize[0] = linesize; |
|
107 |
- |
|
108 |
- if (planes > FF_ARRAY_ELEMS(samples->data)) { |
|
109 |
- samples-> extended_data = av_mallocz(sizeof(*samples->extended_data) * |
|
110 |
- planes); |
|
111 |
- samplesref->extended_data = av_mallocz(sizeof(*samplesref->extended_data) * |
|
112 |
- planes); |
|
113 |
- |
|
114 |
- if (!samples->extended_data || !samplesref->extended_data) |
|
115 |
- goto fail; |
|
116 |
- |
|
117 |
- memcpy(samples-> extended_data, data, sizeof(*data)*planes); |
|
118 |
- memcpy(samplesref->extended_data, data, sizeof(*data)*planes); |
|
119 |
- } else { |
|
120 |
- samples->extended_data = samples->data; |
|
121 |
- samplesref->extended_data = samplesref->data; |
|
122 |
- } |
|
123 |
- |
|
124 |
- samplesref->pts = AV_NOPTS_VALUE; |
|
125 |
- |
|
126 |
- return samplesref; |
|
127 |
- |
|
128 |
-fail: |
|
129 |
- if (samples && samples->extended_data != samples->data) |
|
130 |
- av_freep(&samples->extended_data); |
|
131 |
- if (samplesref) { |
|
132 |
- av_freep(&samplesref->audio); |
|
133 |
- if (samplesref->extended_data != samplesref->data) |
|
134 |
- av_freep(&samplesref->extended_data); |
|
135 |
- } |
|
136 |
- av_freep(&samplesref); |
|
137 |
- av_freep(&samples); |
|
138 |
- return NULL; |
|
139 |
-} |
|
140 |
-#endif |
... | ... |
@@ -66,168 +66,6 @@ typedef struct AVFilterLink AVFilterLink; |
66 | 66 |
typedef struct AVFilterPad AVFilterPad; |
67 | 67 |
typedef struct AVFilterFormats AVFilterFormats; |
68 | 68 |
|
69 |
-#if FF_API_AVFILTERBUFFER |
|
70 |
-/** |
|
71 |
- * A reference-counted buffer data type used by the filter system. Filters |
|
72 |
- * should not store pointers to this structure directly, but instead use the |
|
73 |
- * AVFilterBufferRef structure below. |
|
74 |
- */ |
|
75 |
-typedef struct AVFilterBuffer { |
|
76 |
- uint8_t *data[8]; ///< buffer data for each plane/channel |
|
77 |
- |
|
78 |
- /** |
|
79 |
- * pointers to the data planes/channels. |
|
80 |
- * |
|
81 |
- * For video, this should simply point to data[]. |
|
82 |
- * |
|
83 |
- * For planar audio, each channel has a separate data pointer, and |
|
84 |
- * linesize[0] contains the size of each channel buffer. |
|
85 |
- * For packed audio, there is just one data pointer, and linesize[0] |
|
86 |
- * contains the total size of the buffer for all channels. |
|
87 |
- * |
|
88 |
- * Note: Both data and extended_data will always be set, but for planar |
|
89 |
- * audio with more channels that can fit in data, extended_data must be used |
|
90 |
- * in order to access all channels. |
|
91 |
- */ |
|
92 |
- uint8_t **extended_data; |
|
93 |
- int linesize[8]; ///< number of bytes per line |
|
94 |
- |
|
95 |
- /** private data to be used by a custom free function */ |
|
96 |
- void *priv; |
|
97 |
- /** |
|
98 |
- * A pointer to the function to deallocate this buffer if the default |
|
99 |
- * function is not sufficient. This could, for example, add the memory |
|
100 |
- * back into a memory pool to be reused later without the overhead of |
|
101 |
- * reallocating it from scratch. |
|
102 |
- */ |
|
103 |
- void (*free)(struct AVFilterBuffer *buf); |
|
104 |
- |
|
105 |
- int format; ///< media format |
|
106 |
- int w, h; ///< width and height of the allocated buffer |
|
107 |
- unsigned refcount; ///< number of references to this buffer |
|
108 |
-} AVFilterBuffer; |
|
109 |
- |
|
110 |
-#define AV_PERM_READ 0x01 ///< can read from the buffer |
|
111 |
-#define AV_PERM_WRITE 0x02 ///< can write to the buffer |
|
112 |
-#define AV_PERM_PRESERVE 0x04 ///< nobody else can overwrite the buffer |
|
113 |
-#define AV_PERM_REUSE 0x08 ///< can output the buffer multiple times, with the same contents each time |
|
114 |
-#define AV_PERM_REUSE2 0x10 ///< can output the buffer multiple times, modified each time |
|
115 |
-#define AV_PERM_NEG_LINESIZES 0x20 ///< the buffer requested can have negative linesizes |
|
116 |
- |
|
117 |
-/** |
|
118 |
- * Audio specific properties in a reference to an AVFilterBuffer. Since |
|
119 |
- * AVFilterBufferRef is common to different media formats, audio specific |
|
120 |
- * per reference properties must be separated out. |
|
121 |
- */ |
|
122 |
-typedef struct AVFilterBufferRefAudioProps { |
|
123 |
- uint64_t channel_layout; ///< channel layout of audio buffer |
|
124 |
- int nb_samples; ///< number of audio samples |
|
125 |
- int sample_rate; ///< audio buffer sample rate |
|
126 |
- int planar; ///< audio buffer - planar or packed |
|
127 |
-} AVFilterBufferRefAudioProps; |
|
128 |
- |
|
129 |
-/** |
|
130 |
- * Video specific properties in a reference to an AVFilterBuffer. Since |
|
131 |
- * AVFilterBufferRef is common to different media formats, video specific |
|
132 |
- * per reference properties must be separated out. |
|
133 |
- */ |
|
134 |
-typedef struct AVFilterBufferRefVideoProps { |
|
135 |
- int w; ///< image width |
|
136 |
- int h; ///< image height |
|
137 |
- AVRational pixel_aspect; ///< pixel aspect ratio |
|
138 |
- int interlaced; ///< is frame interlaced |
|
139 |
- int top_field_first; ///< field order |
|
140 |
- enum AVPictureType pict_type; ///< picture type of the frame |
|
141 |
- int key_frame; ///< 1 -> keyframe, 0-> not |
|
142 |
-} AVFilterBufferRefVideoProps; |
|
143 |
- |
|
144 |
-/** |
|
145 |
- * A reference to an AVFilterBuffer. Since filters can manipulate the origin of |
|
146 |
- * a buffer to, for example, crop image without any memcpy, the buffer origin |
|
147 |
- * and dimensions are per-reference properties. Linesize is also useful for |
|
148 |
- * image flipping, frame to field filters, etc, and so is also per-reference. |
|
149 |
- * |
|
150 |
- * TODO: add anything necessary for frame reordering |
|
151 |
- */ |
|
152 |
-typedef struct AVFilterBufferRef { |
|
153 |
- AVFilterBuffer *buf; ///< the buffer that this is a reference to |
|
154 |
- uint8_t *data[8]; ///< picture/audio data for each plane |
|
155 |
- /** |
|
156 |
- * pointers to the data planes/channels. |
|
157 |
- * |
|
158 |
- * For video, this should simply point to data[]. |
|
159 |
- * |
|
160 |
- * For planar audio, each channel has a separate data pointer, and |
|
161 |
- * linesize[0] contains the size of each channel buffer. |
|
162 |
- * For packed audio, there is just one data pointer, and linesize[0] |
|
163 |
- * contains the total size of the buffer for all channels. |
|
164 |
- * |
|
165 |
- * Note: Both data and extended_data will always be set, but for planar |
|
166 |
- * audio with more channels that can fit in data, extended_data must be used |
|
167 |
- * in order to access all channels. |
|
168 |
- */ |
|
169 |
- uint8_t **extended_data; |
|
170 |
- int linesize[8]; ///< number of bytes per line |
|
171 |
- |
|
172 |
- AVFilterBufferRefVideoProps *video; ///< video buffer specific properties |
|
173 |
- AVFilterBufferRefAudioProps *audio; ///< audio buffer specific properties |
|
174 |
- |
|
175 |
- /** |
|
176 |
- * presentation timestamp. The time unit may change during |
|
177 |
- * filtering, as it is specified in the link and the filter code |
|
178 |
- * may need to rescale the PTS accordingly. |
|
179 |
- */ |
|
180 |
- int64_t pts; |
|
181 |
- int64_t pos; ///< byte position in stream, -1 if unknown |
|
182 |
- |
|
183 |
- int format; ///< media format |
|
184 |
- |
|
185 |
- int perms; ///< permissions, see the AV_PERM_* flags |
|
186 |
- |
|
187 |
- enum AVMediaType type; ///< media type of buffer data |
|
188 |
-} AVFilterBufferRef; |
|
189 |
- |
|
190 |
-/** |
|
191 |
- * Copy properties of src to dst, without copying the actual data |
|
192 |
- */ |
|
193 |
-attribute_deprecated |
|
194 |
-void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src); |
|
195 |
- |
|
196 |
-/** |
|
197 |
- * Add a new reference to a buffer. |
|
198 |
- * |
|
199 |
- * @param ref an existing reference to the buffer |
|
200 |
- * @param pmask a bitmask containing the allowable permissions in the new |
|
201 |
- * reference |
|
202 |
- * @return a new reference to the buffer with the same properties as the |
|
203 |
- * old, excluding any permissions denied by pmask |
|
204 |
- */ |
|
205 |
-attribute_deprecated |
|
206 |
-AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask); |
|
207 |
- |
|
208 |
-/** |
|
209 |
- * Remove a reference to a buffer. If this is the last reference to the |
|
210 |
- * buffer, the buffer itself is also automatically freed. |
|
211 |
- * |
|
212 |
- * @param ref reference to the buffer, may be NULL |
|
213 |
- * |
|
214 |
- * @note it is recommended to use avfilter_unref_bufferp() instead of this |
|
215 |
- * function |
|
216 |
- */ |
|
217 |
-attribute_deprecated |
|
218 |
-void avfilter_unref_buffer(AVFilterBufferRef *ref); |
|
219 |
- |
|
220 |
-/** |
|
221 |
- * Remove a reference to a buffer and set the pointer to NULL. |
|
222 |
- * If this is the last reference to the buffer, the buffer itself |
|
223 |
- * is also automatically freed. |
|
224 |
- * |
|
225 |
- * @param ref pointer to the buffer reference |
|
226 |
- */ |
|
227 |
-attribute_deprecated |
|
228 |
-void avfilter_unref_bufferp(AVFilterBufferRef **ref); |
|
229 |
-#endif |
|
230 |
- |
|
231 | 69 |
/** |
232 | 70 |
* Get the number of elements in a NULL-terminated array of AVFilterPads (e.g. |
233 | 71 |
* AVFilter.inputs/outputs). |
... | ... |
@@ -559,43 +397,6 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad, |
559 | 559 |
*/ |
560 | 560 |
int avfilter_config_links(AVFilterContext *filter); |
561 | 561 |
|
562 |
-#if FF_API_AVFILTERBUFFER |
|
563 |
-/** |
|
564 |
- * Create a buffer reference wrapped around an already allocated image |
|
565 |
- * buffer. |
|
566 |
- * |
|
567 |
- * @param data pointers to the planes of the image to reference |
|
568 |
- * @param linesize linesizes for the planes of the image to reference |
|
569 |
- * @param perms the required access permissions |
|
570 |
- * @param w the width of the image specified by the data and linesize arrays |
|
571 |
- * @param h the height of the image specified by the data and linesize arrays |
|
572 |
- * @param format the pixel format of the image specified by the data and linesize arrays |
|
573 |
- */ |
|
574 |
-attribute_deprecated |
|
575 |
-AVFilterBufferRef * |
|
576 |
-avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int perms, |
|
577 |
- int w, int h, enum AVPixelFormat format); |
|
578 |
- |
|
579 |
-/** |
|
580 |
- * Create an audio buffer reference wrapped around an already |
|
581 |
- * allocated samples buffer. |
|
582 |
- * |
|
583 |
- * @param data pointers to the samples plane buffers |
|
584 |
- * @param linesize linesize for the samples plane buffers |
|
585 |
- * @param perms the required access permissions |
|
586 |
- * @param nb_samples number of samples per channel |
|
587 |
- * @param sample_fmt the format of each sample in the buffer to allocate |
|
588 |
- * @param channel_layout the channel layout of the buffer |
|
589 |
- */ |
|
590 |
-attribute_deprecated |
|
591 |
-AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data, |
|
592 |
- int linesize, |
|
593 |
- int perms, |
|
594 |
- int nb_samples, |
|
595 |
- enum AVSampleFormat sample_fmt, |
|
596 |
- uint64_t channel_layout); |
|
597 |
-#endif |
|
598 |
- |
|
599 | 562 |
/** Initialize the filter system. Register all builtin filters. */ |
600 | 563 |
void avfilter_register_all(void); |
601 | 564 |
|
... | ... |
@@ -733,26 +534,6 @@ void avfilter_free(AVFilterContext *filter); |
733 | 733 |
int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt, |
734 | 734 |
unsigned filt_srcpad_idx, unsigned filt_dstpad_idx); |
735 | 735 |
|
736 |
-#if FF_API_AVFILTERBUFFER |
|
737 |
-/** |
|
738 |
- * Copy the frame properties of src to dst, without copying the actual |
|
739 |
- * image data. |
|
740 |
- * |
|
741 |
- * @return 0 on success, a negative number on error. |
|
742 |
- */ |
|
743 |
-attribute_deprecated |
|
744 |
-int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src); |
|
745 |
- |
|
746 |
-/** |
|
747 |
- * Copy the frame properties and data pointers of src to dst, without copying |
|
748 |
- * the actual data. |
|
749 |
- * |
|
750 |
- * @return 0 on success, a negative number on error. |
|
751 |
- */ |
|
752 |
-attribute_deprecated |
|
753 |
-int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src); |
|
754 |
-#endif |
|
755 |
- |
|
756 | 736 |
/** |
757 | 737 |
* @return AVClass for AVFilterContext. |
758 | 738 |
* |
759 | 739 |
deleted file mode 100644 |
... | ... |
@@ -1,181 +0,0 @@ |
1 |
-/* |
|
2 |
- * This file is part of Libav. |
|
3 |
- * |
|
4 |
- * Libav is free software; you can redistribute it and/or |
|
5 |
- * modify it under the terms of the GNU Lesser General Public |
|
6 |
- * License as published by the Free Software Foundation; either |
|
7 |
- * version 2.1 of the License, or (at your option) any later version. |
|
8 |
- * |
|
9 |
- * Libav is distributed in the hope that it will be useful, |
|
10 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
12 |
- * Lesser General Public License for more details. |
|
13 |
- * |
|
14 |
- * You should have received a copy of the GNU Lesser General Public |
|
15 |
- * License along with Libav; if not, write to the Free Software |
|
16 |
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
17 |
- */ |
|
18 |
- |
|
19 |
-#include "libavutil/channel_layout.h" |
|
20 |
-#include "libavutil/common.h" |
|
21 |
-#include "libavutil/internal.h" |
|
22 |
-#include "libavcodec/avcodec.h" |
|
23 |
- |
|
24 |
-#include "avfilter.h" |
|
25 |
-#include "internal.h" |
|
26 |
-#include "version.h" |
|
27 |
- |
|
28 |
-#if FF_API_AVFILTERBUFFER |
|
29 |
-/* TODO: buffer pool. see comment for avfilter_default_get_video_buffer() */ |
|
30 |
-void ff_avfilter_default_free_buffer(AVFilterBuffer *ptr) |
|
31 |
-{ |
|
32 |
- if (ptr->extended_data != ptr->data) |
|
33 |
- av_freep(&ptr->extended_data); |
|
34 |
- av_free(ptr->data[0]); |
|
35 |
- av_free(ptr); |
|
36 |
-} |
|
37 |
- |
|
38 |
-AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask) |
|
39 |
-{ |
|
40 |
- AVFilterBufferRef *ret = av_malloc(sizeof(AVFilterBufferRef)); |
|
41 |
- if (!ret) |
|
42 |
- return NULL; |
|
43 |
- *ret = *ref; |
|
44 |
- if (ref->type == AVMEDIA_TYPE_VIDEO) { |
|
45 |
- ret->video = av_malloc(sizeof(AVFilterBufferRefVideoProps)); |
|
46 |
- if (!ret->video) { |
|
47 |
- av_free(ret); |
|
48 |
- return NULL; |
|
49 |
- } |
|
50 |
- *ret->video = *ref->video; |
|
51 |
- ret->extended_data = ret->data; |
|
52 |
- } else if (ref->type == AVMEDIA_TYPE_AUDIO) { |
|
53 |
- ret->audio = av_malloc(sizeof(AVFilterBufferRefAudioProps)); |
|
54 |
- if (!ret->audio) { |
|
55 |
- av_free(ret); |
|
56 |
- return NULL; |
|
57 |
- } |
|
58 |
- *ret->audio = *ref->audio; |
|
59 |
- |
|
60 |
- if (ref->extended_data != ref->data) { |
|
61 |
- int nb_channels = av_get_channel_layout_nb_channels(ref->audio->channel_layout); |
|
62 |
- if (!(ret->extended_data = av_malloc(sizeof(*ret->extended_data) * |
|
63 |
- nb_channels))) { |
|
64 |
- av_freep(&ret->audio); |
|
65 |
- av_freep(&ret); |
|
66 |
- return NULL; |
|
67 |
- } |
|
68 |
- memcpy(ret->extended_data, ref->extended_data, |
|
69 |
- sizeof(*ret->extended_data) * nb_channels); |
|
70 |
- } else |
|
71 |
- ret->extended_data = ret->data; |
|
72 |
- } |
|
73 |
- ret->perms &= pmask; |
|
74 |
- ret->buf->refcount ++; |
|
75 |
- return ret; |
|
76 |
-} |
|
77 |
- |
|
78 |
-void avfilter_unref_buffer(AVFilterBufferRef *ref) |
|
79 |
-{ |
|
80 |
- if (!ref) |
|
81 |
- return; |
|
82 |
- if (!(--ref->buf->refcount)) |
|
83 |
- ref->buf->free(ref->buf); |
|
84 |
- if (ref->extended_data != ref->data) |
|
85 |
- av_freep(&ref->extended_data); |
|
86 |
- av_free(ref->video); |
|
87 |
- av_free(ref->audio); |
|
88 |
- av_free(ref); |
|
89 |
-} |
|
90 |
- |
|
91 |
-void avfilter_unref_bufferp(AVFilterBufferRef **ref) |
|
92 |
-{ |
|
93 |
-FF_DISABLE_DEPRECATION_WARNINGS |
|
94 |
- avfilter_unref_buffer(*ref); |
|
95 |
-FF_ENABLE_DEPRECATION_WARNINGS |
|
96 |
- *ref = NULL; |
|
97 |
-} |
|
98 |
- |
|
99 |
-int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src) |
|
100 |
-{ |
|
101 |
- dst->pts = src->pts; |
|
102 |
- dst->format = src->format; |
|
103 |
- |
|
104 |
- switch (dst->type) { |
|
105 |
- case AVMEDIA_TYPE_VIDEO: |
|
106 |
- dst->video->w = src->width; |
|
107 |
- dst->video->h = src->height; |
|
108 |
- dst->video->pixel_aspect = src->sample_aspect_ratio; |
|
109 |
- dst->video->interlaced = src->interlaced_frame; |
|
110 |
- dst->video->top_field_first = src->top_field_first; |
|
111 |
- dst->video->key_frame = src->key_frame; |
|
112 |
- dst->video->pict_type = src->pict_type; |
|
113 |
- break; |
|
114 |
- case AVMEDIA_TYPE_AUDIO: |
|
115 |
- dst->audio->sample_rate = src->sample_rate; |
|
116 |
- dst->audio->channel_layout = src->channel_layout; |
|
117 |
- break; |
|
118 |
- default: |
|
119 |
- return AVERROR(EINVAL); |
|
120 |
- } |
|
121 |
- |
|
122 |
- return 0; |
|
123 |
-} |
|
124 |
- |
|
125 |
-int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src) |
|
126 |
-{ |
|
127 |
- int planes, nb_channels; |
|
128 |
- |
|
129 |
- memcpy(dst->data, src->data, sizeof(dst->data)); |
|
130 |
- memcpy(dst->linesize, src->linesize, sizeof(dst->linesize)); |
|
131 |
- |
|
132 |
- dst->pts = src->pts; |
|
133 |
- dst->format = src->format; |
|
134 |
- |
|
135 |
- switch (src->type) { |
|
136 |
- case AVMEDIA_TYPE_VIDEO: |
|
137 |
- dst->width = src->video->w; |
|
138 |
- dst->height = src->video->h; |
|
139 |
- dst->sample_aspect_ratio = src->video->pixel_aspect; |
|
140 |
- dst->interlaced_frame = src->video->interlaced; |
|
141 |
- dst->top_field_first = src->video->top_field_first; |
|
142 |
- dst->key_frame = src->video->key_frame; |
|
143 |
- dst->pict_type = src->video->pict_type; |
|
144 |
- break; |
|
145 |
- case AVMEDIA_TYPE_AUDIO: |
|
146 |
- nb_channels = av_get_channel_layout_nb_channels(src->audio->channel_layout); |
|
147 |
- planes = av_sample_fmt_is_planar(src->format) ? nb_channels : 1; |
|
148 |
- |
|
149 |
- if (planes > FF_ARRAY_ELEMS(dst->data)) { |
|
150 |
- dst->extended_data = av_mallocz(planes * sizeof(*dst->extended_data)); |
|
151 |
- if (!dst->extended_data) |
|
152 |
- return AVERROR(ENOMEM); |
|
153 |
- memcpy(dst->extended_data, src->extended_data, |
|
154 |
- planes * sizeof(*dst->extended_data)); |
|
155 |
- } else |
|
156 |
- dst->extended_data = dst->data; |
|
157 |
- |
|
158 |
- dst->sample_rate = src->audio->sample_rate; |
|
159 |
- dst->channel_layout = src->audio->channel_layout; |
|
160 |
- dst->nb_samples = src->audio->nb_samples; |
|
161 |
- break; |
|
162 |
- default: |
|
163 |
- return AVERROR(EINVAL); |
|
164 |
- } |
|
165 |
- |
|
166 |
- return 0; |
|
167 |
-} |
|
168 |
- |
|
169 |
-void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src) |
|
170 |
-{ |
|
171 |
- // copy common properties |
|
172 |
- dst->pts = src->pts; |
|
173 |
- dst->pos = src->pos; |
|
174 |
- |
|
175 |
- switch (src->type) { |
|
176 |
- case AVMEDIA_TYPE_VIDEO: *dst->video = *src->video; break; |
|
177 |
- case AVMEDIA_TYPE_AUDIO: *dst->audio = *src->audio; break; |
|
178 |
- default: break; |
|
179 |
- } |
|
180 |
-} |
|
181 |
-#endif /* FF_API_AVFILTERBUFFER */ |
... | ... |
@@ -137,80 +137,6 @@ int attribute_align_arg av_buffersink_get_samples(AVFilterContext *ctx, |
137 | 137 |
return ret; |
138 | 138 |
} |
139 | 139 |
|
140 |
-#if FF_API_AVFILTERBUFFER |
|
141 |
-FF_DISABLE_DEPRECATION_WARNINGS |
|
142 |
-static void compat_free_buffer(AVFilterBuffer *buf) |
|
143 |
-{ |
|
144 |
- AVFrame *frame = buf->priv; |
|
145 |
- av_frame_free(&frame); |
|
146 |
- av_free(buf); |
|
147 |
-} |
|
148 |
- |
|
149 |
-static int compat_read(AVFilterContext *ctx, |
|
150 |
- AVFilterBufferRef **pbuf, int nb_samples) |
|
151 |
-{ |
|
152 |
- AVFilterBufferRef *buf; |
|
153 |
- AVFrame *frame; |
|
154 |
- int ret; |
|
155 |
- |
|
156 |
- if (!pbuf) |
|
157 |
- return ff_poll_frame(ctx->inputs[0]); |
|
158 |
- |
|
159 |
- frame = av_frame_alloc(); |
|
160 |
- if (!frame) |
|
161 |
- return AVERROR(ENOMEM); |
|
162 |
- |
|
163 |
- if (!nb_samples) |
|
164 |
- ret = av_buffersink_get_frame(ctx, frame); |
|
165 |
- else |
|
166 |
- ret = av_buffersink_get_samples(ctx, frame, nb_samples); |
|
167 |
- |
|
168 |
- if (ret < 0) |
|
169 |
- goto fail; |
|
170 |
- |
|
171 |
- if (ctx->inputs[0]->type == AVMEDIA_TYPE_VIDEO) { |
|
172 |
- buf = avfilter_get_video_buffer_ref_from_arrays(frame->data, frame->linesize, |
|
173 |
- AV_PERM_READ, |
|
174 |
- frame->width, frame->height, |
|
175 |
- frame->format); |
|
176 |
- } else { |
|
177 |
- buf = avfilter_get_audio_buffer_ref_from_arrays(frame->extended_data, |
|
178 |
- frame->linesize[0], AV_PERM_READ, |
|
179 |
- frame->nb_samples, |
|
180 |
- frame->format, |
|
181 |
- frame->channel_layout); |
|
182 |
- } |
|
183 |
- if (!buf) { |
|
184 |
- ret = AVERROR(ENOMEM); |
|
185 |
- goto fail; |
|
186 |
- } |
|
187 |
- |
|
188 |
- avfilter_copy_frame_props(buf, frame); |
|
189 |
- |
|
190 |
- buf->buf->priv = frame; |
|
191 |
- buf->buf->free = compat_free_buffer; |
|
192 |
- |
|
193 |
- *pbuf = buf; |
|
194 |
- |
|
195 |
- return 0; |
|
196 |
-fail: |
|
197 |
- av_frame_free(&frame); |
|
198 |
- return ret; |
|
199 |
-} |
|
200 |
- |
|
201 |
-int attribute_align_arg av_buffersink_read(AVFilterContext *ctx, AVFilterBufferRef **buf) |
|
202 |
-{ |
|
203 |
- return compat_read(ctx, buf, 0); |
|
204 |
-} |
|
205 |
- |
|
206 |
-int attribute_align_arg av_buffersink_read_samples(AVFilterContext *ctx, AVFilterBufferRef **buf, |
|
207 |
- int nb_samples) |
|
208 |
-{ |
|
209 |
- return compat_read(ctx, buf, nb_samples); |
|
210 |
-} |
|
211 |
-FF_ENABLE_DEPRECATION_WARNINGS |
|
212 |
-#endif |
|
213 |
- |
|
214 | 140 |
static const AVFilterPad avfilter_vsink_buffer_inputs[] = { |
215 | 141 |
{ |
216 | 142 |
.name = "default", |
... | ... |
@@ -33,43 +33,6 @@ |
33 | 33 |
* @{ |
34 | 34 |
*/ |
35 | 35 |
|
36 |
-#if FF_API_AVFILTERBUFFER |
|
37 |
-/** |
|
38 |
- * Get a buffer with filtered data from sink and put it in buf. |
|
39 |
- * |
|
40 |
- * @param ctx pointer to a context of a buffersink or abuffersink AVFilter. |
|
41 |
- * @param buf pointer to the buffer will be written here if buf is non-NULL. buf |
|
42 |
- * must be freed by the caller using avfilter_unref_buffer(). |
|
43 |
- * Buf may also be NULL to query whether a buffer is ready to be |
|
44 |
- * output. |
|
45 |
- * |
|
46 |
- * @return >= 0 in case of success, a negative AVERROR code in case of |
|
47 |
- * failure. |
|
48 |
- */ |
|
49 |
-attribute_deprecated |
|
50 |
-int av_buffersink_read(AVFilterContext *ctx, AVFilterBufferRef **buf); |
|
51 |
- |
|
52 |
-/** |
|
53 |
- * Same as av_buffersink_read, but with the ability to specify the number of |
|
54 |
- * samples read. This function is less efficient than av_buffersink_read(), |
|
55 |
- * because it copies the data around. |
|
56 |
- * |
|
57 |
- * @param ctx pointer to a context of the abuffersink AVFilter. |
|
58 |
- * @param buf pointer to the buffer will be written here if buf is non-NULL. buf |
|
59 |
- * must be freed by the caller using avfilter_unref_buffer(). buf |
|
60 |
- * will contain exactly nb_samples audio samples, except at the end |
|
61 |
- * of stream, when it can contain less than nb_samples. |
|
62 |
- * Buf may also be NULL to query whether a buffer is ready to be |
|
63 |
- * output. |
|
64 |
- * |
|
65 |
- * @warning do not mix this function with av_buffersink_read(). Use only one or |
|
66 |
- * the other with a single sink, not both. |
|
67 |
- */ |
|
68 |
-attribute_deprecated |
|
69 |
-int av_buffersink_read_samples(AVFilterContext *ctx, AVFilterBufferRef **buf, |
|
70 |
- int nb_samples); |
|
71 |
-#endif |
|
72 |
- |
|
73 | 36 |
/** |
74 | 37 |
* Get a frame with filtered data from sink and put it in frame. |
75 | 38 |
* |
... | ... |
@@ -145,114 +145,6 @@ int attribute_align_arg av_buffersrc_add_frame(AVFilterContext *ctx, |
145 | 145 |
return 0; |
146 | 146 |
} |
147 | 147 |
|
148 |
-#if FF_API_AVFILTERBUFFER |
|
149 |
-FF_DISABLE_DEPRECATION_WARNINGS |
|
150 |
-static void compat_free_buffer(void *opaque, uint8_t *data) |
|
151 |
-{ |
|
152 |
- AVFilterBufferRef *buf = opaque; |
|
153 |
- avfilter_unref_buffer(buf); |
|
154 |
-} |
|
155 |
- |
|
156 |
-static void compat_unref_buffer(void *opaque, uint8_t *data) |
|
157 |
-{ |
|
158 |
- AVBufferRef *buf = opaque; |
|
159 |
- av_buffer_unref(&buf); |
|
160 |
-} |
|
161 |
- |
|
162 |
-int av_buffersrc_buffer(AVFilterContext *ctx, AVFilterBufferRef *buf) |
|
163 |
-{ |
|
164 |
- BufferSourceContext *s = ctx->priv; |
|
165 |
- AVFrame *frame = NULL; |
|
166 |
- AVBufferRef *dummy_buf = NULL; |
|
167 |
- int ret = 0, planes, i; |
|
168 |
- |
|
169 |
- if (!buf) { |
|
170 |
- s->eof = 1; |
|
171 |
- return 0; |
|
172 |
- } else if (s->eof) |
|
173 |
- return AVERROR(EINVAL); |
|
174 |
- |
|
175 |
- frame = av_frame_alloc(); |
|
176 |
- if (!frame) |
|
177 |
- return AVERROR(ENOMEM); |
|
178 |
- |
|
179 |
- dummy_buf = av_buffer_create(NULL, 0, compat_free_buffer, buf, 0); |
|
180 |
- if (!dummy_buf) { |
|
181 |
- ret = AVERROR(ENOMEM); |
|
182 |
- goto fail; |
|
183 |
- } |
|
184 |
- |
|
185 |
- if ((ret = avfilter_copy_buf_props(frame, buf)) < 0) |
|
186 |
- goto fail; |
|
187 |
- |
|
188 |
-#define WRAP_PLANE(ref_out, data, data_size) \ |
|
189 |
-do { \ |
|
190 |
- AVBufferRef *dummy_ref = av_buffer_ref(dummy_buf); \ |
|
191 |
- if (!dummy_ref) { \ |
|
192 |
- ret = AVERROR(ENOMEM); \ |
|
193 |
- goto fail; \ |
|
194 |
- } \ |
|
195 |
- ref_out = av_buffer_create(data, data_size, compat_unref_buffer, \ |
|
196 |
- dummy_ref, 0); \ |
|
197 |
- if (!ref_out) { \ |
|
198 |
- av_buffer_unref(&dummy_ref); \ |
|
199 |
- av_frame_unref(frame); \ |
|
200 |
- ret = AVERROR(ENOMEM); \ |
|
201 |
- goto fail; \ |
|
202 |
- } \ |
|
203 |
-} while (0) |
|
204 |
- |
|
205 |
- if (ctx->outputs[0]->type == AVMEDIA_TYPE_VIDEO) { |
|
206 |
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format); |
|
207 |
- |
|
208 |
- planes = av_pix_fmt_count_planes(frame->format); |
|
209 |
- if (!desc || planes <= 0) { |
|
210 |
- ret = AVERROR(EINVAL); |
|
211 |
- goto fail; |
|
212 |
- } |
|
213 |
- |
|
214 |
- for (i = 0; i < planes; i++) { |
|
215 |
- int v_shift = (i == 1 || i == 2) ? desc->log2_chroma_h : 0; |
|
216 |
- int plane_size = (frame->height >> v_shift) * frame->linesize[i]; |
|
217 |
- |
|
218 |
- WRAP_PLANE(frame->buf[i], frame->data[i], plane_size); |
|
219 |
- } |
|
220 |
- } else { |
|
221 |
- int planar = av_sample_fmt_is_planar(frame->format); |
|
222 |
- int channels = av_get_channel_layout_nb_channels(frame->channel_layout); |
|
223 |
- |
|
224 |
- planes = planar ? channels : 1; |
|
225 |
- |
|
226 |
- if (planes > FF_ARRAY_ELEMS(frame->buf)) { |
|
227 |
- frame->nb_extended_buf = planes - FF_ARRAY_ELEMS(frame->buf); |
|
228 |
- frame->extended_buf = av_mallocz(sizeof(*frame->extended_buf) * |
|
229 |
- frame->nb_extended_buf); |
|
230 |
- if (!frame->extended_buf) { |
|
231 |
- ret = AVERROR(ENOMEM); |
|
232 |
- goto fail; |
|
233 |
- } |
|
234 |
- } |
|
235 |
- |
|
236 |
- for (i = 0; i < FFMIN(planes, FF_ARRAY_ELEMS(frame->buf)); i++) |
|
237 |
- WRAP_PLANE(frame->buf[i], frame->extended_data[i], frame->linesize[0]); |
|
238 |
- |
|
239 |
- for (i = 0; i < planes - FF_ARRAY_ELEMS(frame->buf); i++) |
|
240 |
- WRAP_PLANE(frame->extended_buf[i], |
|
241 |
- frame->extended_data[i + FF_ARRAY_ELEMS(frame->buf)], |
|
242 |
- frame->linesize[0]); |
|
243 |
- } |
|
244 |
- |
|
245 |
- ret = av_buffersrc_add_frame(ctx, frame); |
|
246 |
- |
|
247 |
-fail: |
|
248 |
- av_buffer_unref(&dummy_buf); |
|
249 |
- av_frame_free(&frame); |
|
250 |
- |
|
251 |
- return ret; |
|
252 |
-} |
|
253 |
-FF_ENABLE_DEPRECATION_WARNINGS |
|
254 |
-#endif |
|
255 |
- |
|
256 | 148 |
static av_cold int init_video(AVFilterContext *ctx) |
257 | 149 |
{ |
258 | 150 |
BufferSourceContext *c = ctx->priv; |
... | ... |
@@ -34,21 +34,6 @@ |
34 | 34 |
* @{ |
35 | 35 |
*/ |
36 | 36 |
|
37 |
-#if FF_API_AVFILTERBUFFER |
|
38 |
-/** |
|
39 |
- * Add a buffer to a filtergraph. |
|
40 |
- * |
|
41 |
- * @param ctx an instance of the buffersrc filter |
|
42 |
- * @param buf buffer containing frame data to be passed down the filtergraph. |
|
43 |
- * This function will take ownership of buf, the user must not free it. |
|
44 |
- * A NULL buf signals EOF -- i.e. no more frames will be sent to this filter. |
|
45 |
- * |
|
46 |
- * @deprecated use av_buffersrc_write_frame() or av_buffersrc_add_frame() |
|
47 |
- */ |
|
48 |
-attribute_deprecated |
|
49 |
-int av_buffersrc_buffer(AVFilterContext *ctx, AVFilterBufferRef *buf); |
|
50 |
-#endif |
|
51 |
- |
|
52 | 37 |
/** |
53 | 38 |
* Add a frame to the buffer source. |
54 | 39 |
* |
... | ... |
@@ -135,11 +135,6 @@ struct AVFilterInternal { |
135 | 135 |
avfilter_execute_func *execute; |
136 | 136 |
}; |
137 | 137 |
|
138 |
-#if FF_API_AVFILTERBUFFER |
|
139 |
-/** default handler for freeing audio/video buffer when there are no references left */ |
|
140 |
-void ff_avfilter_default_free_buffer(AVFilterBuffer *buf); |
|
141 |
-#endif |
|
142 |
- |
|
143 | 138 |
/** Tell is a format is contained in the provided list terminated by -1. */ |
144 | 139 |
int ff_fmt_is_in(int fmt, const int *fmts); |
145 | 140 |
|
... | ... |
@@ -49,9 +49,6 @@ |
49 | 49 |
* the public API and may change, break or disappear at any time. |
50 | 50 |
*/ |
51 | 51 |
|
52 |
-#ifndef FF_API_AVFILTERBUFFER |
|
53 |
-#define FF_API_AVFILTERBUFFER (LIBAVFILTER_VERSION_MAJOR < 6) |
|
54 |
-#endif |
|
55 | 52 |
#ifndef FF_API_OLD_FILTER_OPTS |
56 | 53 |
#define FF_API_OLD_FILTER_OPTS (LIBAVFILTER_VERSION_MAJOR < 6) |
57 | 54 |
#endif |
... | ... |
@@ -54,53 +54,6 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h) |
54 | 54 |
return frame; |
55 | 55 |
} |
56 | 56 |
|
57 |
-#if FF_API_AVFILTERBUFFER |
|
58 |
-AVFilterBufferRef * |
|
59 |
-avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int perms, |
|
60 |
- int w, int h, enum AVPixelFormat format) |
|
61 |
-{ |
|
62 |
- AVFilterBuffer *pic = av_mallocz(sizeof(AVFilterBuffer)); |
|
63 |
- AVFilterBufferRef *picref = av_mallocz(sizeof(AVFilterBufferRef)); |
|
64 |
- |
|
65 |
- if (!pic || !picref) |
|
66 |
- goto fail; |
|
67 |
- |
|
68 |
- picref->buf = pic; |
|
69 |
- picref->buf->free = ff_avfilter_default_free_buffer; |
|
70 |
- if (!(picref->video = av_mallocz(sizeof(AVFilterBufferRefVideoProps)))) |
|
71 |
- goto fail; |
|
72 |
- |
|
73 |
- pic->w = picref->video->w = w; |
|
74 |
- pic->h = picref->video->h = h; |
|
75 |
- |
|
76 |
- /* make sure the buffer gets read permission or it's useless for output */ |
|
77 |
- picref->perms = perms | AV_PERM_READ; |
|
78 |
- |
|
79 |
- pic->refcount = 1; |
|
80 |
- picref->type = AVMEDIA_TYPE_VIDEO; |
|
81 |
- pic->format = picref->format = format; |
|
82 |
- |
|
83 |
- memcpy(pic->data, data, 4*sizeof(data[0])); |
|
84 |
- memcpy(pic->linesize, linesize, 4*sizeof(linesize[0])); |
|
85 |
- memcpy(picref->data, pic->data, sizeof(picref->data)); |
|
86 |
- memcpy(picref->linesize, pic->linesize, sizeof(picref->linesize)); |
|
87 |
- |
|
88 |
- pic-> extended_data = pic->data; |
|
89 |
- picref->extended_data = picref->data; |
|
90 |
- |
|
91 |
- picref->pts = AV_NOPTS_VALUE; |
|
92 |
- |
|
93 |
- return picref; |
|
94 |
- |
|
95 |
-fail: |
|
96 |
- if (picref && picref->video) |
|
97 |
- av_free(picref->video); |
|
98 |
- av_free(picref); |
|
99 |
- av_free(pic); |
|
100 |
- return NULL; |
|
101 |
-} |
|
102 |
-#endif |
|
103 |
- |
|
104 | 57 |
AVFrame *ff_get_video_buffer(AVFilterLink *link, int w, int h) |
105 | 58 |
{ |
106 | 59 |
AVFrame *ret = NULL; |