Lines 1-4664
Link Here
|
1 |
https://bugzilla.gnome.org/show_bug.cgi?id=792900 |
|
|
2 |
|
3 |
--- configure.orig 2018-10-02 22:09:31 UTC |
4 |
+++ configure |
5 |
@@ -18125,12 +18125,12 @@ if test -n "$PKG_CONFIG"; then |
6 |
pkg_cv_LIBAV_CFLAGS="$LIBAV_CFLAGS" |
7 |
else |
8 |
if test -n "$PKG_CONFIG" && \ |
9 |
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libavfilter libavformat libavcodec >= 57 libavutil\""; } >&5 |
10 |
- ($PKG_CONFIG --exists --print-errors "libavfilter libavformat libavcodec >= 57 libavutil") 2>&5 |
11 |
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libavfilter libavformat libavcodec >= 58 libavutil\""; } >&5 |
12 |
+ ($PKG_CONFIG --exists --print-errors "libavfilter libavformat libavcodec >= 58 libavutil") 2>&5 |
13 |
ac_status=$? |
14 |
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 |
15 |
test $ac_status = 0; }; then |
16 |
- pkg_cv_LIBAV_CFLAGS=`$PKG_CONFIG --cflags "libavfilter libavformat libavcodec >= 57 libavutil" 2>/dev/null` |
17 |
+ pkg_cv_LIBAV_CFLAGS=`$PKG_CONFIG --cflags "libavfilter libavformat libavcodec >= 58 libavutil" 2>/dev/null` |
18 |
else |
19 |
pkg_failed=yes |
20 |
fi |
21 |
@@ -18143,12 +18143,12 @@ if test -n "$PKG_CONFIG"; then |
22 |
pkg_cv_LIBAV_LIBS="$LIBAV_LIBS" |
23 |
else |
24 |
if test -n "$PKG_CONFIG" && \ |
25 |
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libavfilter libavformat libavcodec >= 57 libavutil\""; } >&5 |
26 |
- ($PKG_CONFIG --exists --print-errors "libavfilter libavformat libavcodec >= 57 libavutil") 2>&5 |
27 |
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libavfilter libavformat libavcodec >= 58 libavutil\""; } >&5 |
28 |
+ ($PKG_CONFIG --exists --print-errors "libavfilter libavformat libavcodec >= 58 libavutil") 2>&5 |
29 |
ac_status=$? |
30 |
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 |
31 |
test $ac_status = 0; }; then |
32 |
- pkg_cv_LIBAV_LIBS=`$PKG_CONFIG --libs "libavfilter libavformat libavcodec >= 57 libavutil" 2>/dev/null` |
33 |
+ pkg_cv_LIBAV_LIBS=`$PKG_CONFIG --libs "libavfilter libavformat libavcodec >= 58 libavutil" 2>/dev/null` |
34 |
else |
35 |
pkg_failed=yes |
36 |
fi |
37 |
@@ -18167,14 +18167,14 @@ else |
38 |
_pkg_short_errors_supported=no |
39 |
fi |
40 |
if test $_pkg_short_errors_supported = yes; then |
41 |
- LIBAV_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "libavfilter libavformat libavcodec >= 57 libavutil"` |
42 |
+ LIBAV_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "libavfilter libavformat libavcodec >= 58 libavutil"` |
43 |
else |
44 |
- LIBAV_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "libavfilter libavformat libavcodec >= 57 libavutil"` |
45 |
+ LIBAV_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "libavfilter libavformat libavcodec >= 58 libavutil"` |
46 |
fi |
47 |
# Put the nasty error message in config.log where it belongs |
48 |
echo "$LIBAV_PKG_ERRORS" >&5 |
49 |
|
50 |
- as_fn_error $? "Package requirements (libavfilter libavformat libavcodec >= 57 libavutil) were not met: |
51 |
+ as_fn_error $? "Package requirements (libavfilter libavformat libavcodec >= 58 libavutil) were not met: |
52 |
|
53 |
$LIBAV_PKG_ERRORS |
54 |
|
55 |
@@ -18471,10 +18471,10 @@ fi |
56 |
emblibav_configure_args="$emblibav_configure_args \ |
57 |
--enable-static --enable-pic \ |
58 |
--disable-avdevice --disable-postproc \ |
59 |
- --disable-programs --disable-ffserver --disable-ffplay --disable-ffprobe --disable-ffmpeg \ |
60 |
+ --disable-programs --disable-ffplay --disable-ffprobe --disable-ffmpeg \ |
61 |
--disable-encoder=flac --disable-protocols --disable-devices \ |
62 |
--disable-network --disable-hwaccels --disable-dxva2 --disable-vdpau \ |
63 |
- --disable-filters --enable-filter=yadif --disable-doc --disable-vda --disable-d3d11va --disable-dxva2 \ |
64 |
+ --disable-filters --enable-filter=yadif --disable-doc --disable-d3d11va --disable-dxva2 \ |
65 |
--disable-audiotoolbox --disable-videotoolbox --disable-vaapi --disable-crystalhd \ |
66 |
--disable-mediacodec --disable-nvenc --disable-mmal --disable-omx \ |
67 |
--disable-omx-rpi --disable-cuda --disable-cuvid --disable-libmfx \ |
68 |
--- ext/libav/gstav.c.orig 2018-07-19 11:27:13 UTC |
69 |
+++ ext/libav/gstav.c |
70 |
@@ -28,12 +28,9 @@ |
71 |
#include <string.h> |
72 |
#include <gst/gst.h> |
73 |
|
74 |
-#include <libavcodec/avcodec.h> |
75 |
-#include <libavformat/avformat.h> |
76 |
-#include <libavfilter/avfiltergraph.h> |
77 |
- |
78 |
#include "gstav.h" |
79 |
#include "gstavutils.h" |
80 |
+#include "gstavcfg.h" |
81 |
|
82 |
#ifdef GST_LIBAV_ENABLE_GPL |
83 |
#define LICENSE "GPL" |
84 |
@@ -155,8 +152,8 @@ plugin_init (GstPlugin * plugin) |
85 |
|
86 |
gst_ffmpeg_init_pix_fmt_info (); |
87 |
|
88 |
- av_register_all (); |
89 |
- avfilter_register_all (); |
90 |
+ /* build global ffmpeg param/property info */ |
91 |
+ gst_ffmpeg_cfg_init (); |
92 |
|
93 |
gst_ffmpegaudenc_register (plugin); |
94 |
gst_ffmpegvidenc_register (plugin); |
95 |
--- ext/libav/gstavauddec.c.orig 2018-07-19 11:29:22 UTC |
96 |
+++ ext/libav/gstavauddec.c |
97 |
@@ -153,7 +153,7 @@ gst_ffmpegauddec_init (GstFFMpegAudDec * ffmpegdec) |
98 |
|
99 |
ffmpegdec->frame = av_frame_alloc (); |
100 |
|
101 |
- GST_PAD_SET_ACCEPT_TEMPLATE (GST_VIDEO_DECODER_SINK_PAD (ffmpegdec)); |
102 |
+ GST_PAD_SET_ACCEPT_TEMPLATE (GST_AUDIO_DECODER_SINK_PAD (ffmpegdec)); |
103 |
gst_audio_decoder_set_use_default_pad_acceptcaps (GST_AUDIO_DECODER_CAST |
104 |
(ffmpegdec), TRUE); |
105 |
|
106 |
@@ -287,7 +287,7 @@ gst_ffmpegauddec_propose_allocation (GstAudioDecoder * |
107 |
gst_allocation_params_init (¶ms); |
108 |
params.flags = GST_MEMORY_FLAG_ZERO_PADDED; |
109 |
params.align = 15; |
110 |
- params.padding = FF_INPUT_BUFFER_PADDING_SIZE; |
111 |
+ params.padding = AV_INPUT_BUFFER_PADDING_SIZE; |
112 |
/* we would like to have some padding so that we don't have to |
113 |
* memcpy. We don't suggest an allocator. */ |
114 |
gst_query_add_allocation_param (query, NULL, ¶ms); |
115 |
@@ -360,15 +360,14 @@ static gboolean |
116 |
settings_changed (GstFFMpegAudDec * ffmpegdec, AVFrame * frame) |
117 |
{ |
118 |
GstAudioFormat format; |
119 |
- gint channels = |
120 |
- av_get_channel_layout_nb_channels (av_frame_get_channel_layout (frame)); |
121 |
+ gint channels = av_get_channel_layout_nb_channels (frame->channel_layout); |
122 |
|
123 |
format = gst_ffmpeg_smpfmt_to_audioformat (frame->format); |
124 |
if (format == GST_AUDIO_FORMAT_UNKNOWN) |
125 |
return TRUE; |
126 |
|
127 |
return !(ffmpegdec->info.rate == |
128 |
- av_frame_get_sample_rate (frame) && |
129 |
+ frame->sample_rate && |
130 |
ffmpegdec->info.channels == channels && |
131 |
ffmpegdec->info.finfo->format == format); |
132 |
} |
133 |
@@ -387,10 +386,9 @@ gst_ffmpegauddec_negotiate (GstFFMpegAudDec * ffmpegde |
134 |
format = gst_ffmpeg_smpfmt_to_audioformat (frame->format); |
135 |
if (format == GST_AUDIO_FORMAT_UNKNOWN) |
136 |
goto no_caps; |
137 |
- channels = |
138 |
- av_get_channel_layout_nb_channels (av_frame_get_channel_layout (frame)); |
139 |
+ channels = av_get_channel_layout_nb_channels (frame->channel_layout); |
140 |
if (channels == 0) |
141 |
- channels = av_frame_get_channels (frame); |
142 |
+ channels = frame->channels; |
143 |
if (channels == 0) |
144 |
goto no_caps; |
145 |
|
146 |
@@ -400,11 +398,9 @@ gst_ffmpegauddec_negotiate (GstFFMpegAudDec * ffmpegde |
147 |
GST_DEBUG_OBJECT (ffmpegdec, |
148 |
"Renegotiating audio from %dHz@%dchannels (%d) to %dHz@%dchannels (%d)", |
149 |
ffmpegdec->info.rate, ffmpegdec->info.channels, |
150 |
- ffmpegdec->info.finfo->format, av_frame_get_sample_rate (frame), channels, |
151 |
- format); |
152 |
+ ffmpegdec->info.finfo->format, frame->sample_rate, channels, format); |
153 |
|
154 |
- gst_ffmpeg_channel_layout_to_gst (av_frame_get_channel_layout (frame), |
155 |
- channels, pos); |
156 |
+ gst_ffmpeg_channel_layout_to_gst (frame->channel_layout, channels, pos); |
157 |
memcpy (ffmpegdec->ffmpeg_layout, pos, |
158 |
sizeof (GstAudioChannelPosition) * channels); |
159 |
|
160 |
@@ -413,7 +409,7 @@ gst_ffmpegauddec_negotiate (GstFFMpegAudDec * ffmpegde |
161 |
ffmpegdec->needs_reorder = |
162 |
memcmp (pos, ffmpegdec->ffmpeg_layout, sizeof (pos[0]) * channels) != 0; |
163 |
gst_audio_info_set_format (&ffmpegdec->info, format, |
164 |
- av_frame_get_sample_rate (frame), channels, pos); |
165 |
+ frame->sample_rate, channels, pos); |
166 |
|
167 |
if (!gst_audio_decoder_set_output_format (GST_AUDIO_DECODER (ffmpegdec), |
168 |
&ffmpegdec->info)) |
169 |
@@ -461,25 +457,19 @@ gst_avpacket_init (AVPacket * packet, guint8 * data, g |
170 |
packet->size = size; |
171 |
} |
172 |
|
173 |
-static gint |
174 |
+/* |
175 |
+ * Returns: whether a frame was decoded |
176 |
+ */ |
177 |
+static gboolean |
178 |
gst_ffmpegauddec_audio_frame (GstFFMpegAudDec * ffmpegdec, |
179 |
- AVCodec * in_plugin, guint8 * data, guint size, gint * have_data, |
180 |
- GstBuffer ** outbuf, GstFlowReturn * ret) |
181 |
+ AVCodec * in_plugin, GstBuffer ** outbuf, GstFlowReturn * ret) |
182 |
{ |
183 |
- gint len = -1; |
184 |
- AVPacket packet; |
185 |
+ gboolean got_frame = FALSE; |
186 |
+ gint res; |
187 |
|
188 |
- GST_DEBUG_OBJECT (ffmpegdec, "size: %d", size); |
189 |
+ res = avcodec_receive_frame (ffmpegdec->context, ffmpegdec->frame); |
190 |
|
191 |
- gst_avpacket_init (&packet, data, size); |
192 |
- len = |
193 |
- avcodec_decode_audio4 (ffmpegdec->context, ffmpegdec->frame, have_data, |
194 |
- &packet); |
195 |
- |
196 |
- GST_DEBUG_OBJECT (ffmpegdec, |
197 |
- "Decode audio: len=%d, have_data=%d", len, *have_data); |
198 |
- |
199 |
- if (len >= 0 && *have_data) { |
200 |
+ if (res >= 0) { |
201 |
gint nsamples, channels, byte_per_sample; |
202 |
gsize output_size; |
203 |
|
204 |
@@ -487,10 +477,11 @@ gst_ffmpegauddec_audio_frame (GstFFMpegAudDec * ffmpeg |
205 |
ffmpegdec->frame, FALSE)) { |
206 |
*outbuf = NULL; |
207 |
*ret = GST_FLOW_NOT_NEGOTIATED; |
208 |
- len = -1; |
209 |
goto beach; |
210 |
} |
211 |
|
212 |
+ got_frame = TRUE; |
213 |
+ |
214 |
channels = ffmpegdec->info.channels; |
215 |
nsamples = ffmpegdec->frame->nb_samples; |
216 |
byte_per_sample = ffmpegdec->info.finfo->width / 8; |
217 |
@@ -586,60 +577,46 @@ gst_ffmpegauddec_audio_frame (GstFFMpegAudDec * ffmpeg |
218 |
/* Mark corrupted frames as corrupted */ |
219 |
if (ffmpegdec->frame->flags & AV_FRAME_FLAG_CORRUPT) |
220 |
GST_BUFFER_FLAG_SET (*outbuf, GST_BUFFER_FLAG_CORRUPTED); |
221 |
- } else { |
222 |
+ } else if (res == AVERROR (EAGAIN)) { |
223 |
*outbuf = NULL; |
224 |
+ } else if (res == AVERROR_EOF) { /* Should not happen */ |
225 |
+ *ret = GST_FLOW_EOS; |
226 |
+ GST_WARNING_OBJECT (ffmpegdec, |
227 |
+ "Tried to receive frame on a flushed context"); |
228 |
+ } else if (res < 0) { |
229 |
+ *ret = GST_FLOW_ERROR; |
230 |
+ GST_ELEMENT_ERROR (ffmpegdec, STREAM, DECODE, ("Decoding problem"), |
231 |
+ ("Legitimate decoding error")); |
232 |
} |
233 |
|
234 |
beach: |
235 |
av_frame_unref (ffmpegdec->frame); |
236 |
- GST_DEBUG_OBJECT (ffmpegdec, "return flow %d, out %p, len %d", |
237 |
- *ret, *outbuf, len); |
238 |
- return len; |
239 |
+ GST_DEBUG_OBJECT (ffmpegdec, "return flow %d, out %p, got_frame %d", |
240 |
+ *ret, *outbuf, got_frame); |
241 |
+ return got_frame; |
242 |
} |
243 |
|
244 |
-/* gst_ffmpegauddec_frame: |
245 |
- * ffmpegdec: |
246 |
- * data: pointer to the data to decode |
247 |
- * size: size of data in bytes |
248 |
- * got_data: 0 if no data was decoded, != 0 otherwise. |
249 |
- * in_time: timestamp of data |
250 |
- * in_duration: duration of data |
251 |
- * ret: GstFlowReturn to return in the chain function |
252 |
- * |
253 |
- * Decode the given frame and pushes it downstream. |
254 |
- * |
255 |
- * Returns: Number of bytes used in decoding, -1 on error/failure. |
256 |
+/* |
257 |
+ * Returns: whether a frame was decoded |
258 |
*/ |
259 |
- |
260 |
-static gint |
261 |
-gst_ffmpegauddec_frame (GstFFMpegAudDec * ffmpegdec, |
262 |
- guint8 * data, guint size, gint * have_data, GstFlowReturn * ret) |
263 |
+static gboolean |
264 |
+gst_ffmpegauddec_frame (GstFFMpegAudDec * ffmpegdec, GstFlowReturn * ret) |
265 |
{ |
266 |
GstFFMpegAudDecClass *oclass; |
267 |
GstBuffer *outbuf = NULL; |
268 |
- gint len = 0; |
269 |
+ gboolean got_frame = FALSE; |
270 |
|
271 |
if (G_UNLIKELY (ffmpegdec->context->codec == NULL)) |
272 |
goto no_codec; |
273 |
|
274 |
- GST_LOG_OBJECT (ffmpegdec, "data:%p, size:%d", data, size); |
275 |
- |
276 |
*ret = GST_FLOW_OK; |
277 |
ffmpegdec->context->frame_number++; |
278 |
|
279 |
oclass = (GstFFMpegAudDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec)); |
280 |
|
281 |
- len = |
282 |
- gst_ffmpegauddec_audio_frame (ffmpegdec, oclass->in_plugin, data, size, |
283 |
- have_data, &outbuf, ret); |
284 |
+ got_frame = |
285 |
+ gst_ffmpegauddec_audio_frame (ffmpegdec, oclass->in_plugin, &outbuf, ret); |
286 |
|
287 |
- if (len < 0) { |
288 |
- GST_WARNING_OBJECT (ffmpegdec, |
289 |
- "avdec_%s: decoding error (len: %d, have_data: %d)", |
290 |
- oclass->in_plugin->name, len, *have_data); |
291 |
- goto beach; |
292 |
- } |
293 |
- |
294 |
if (outbuf) { |
295 |
GST_LOG_OBJECT (ffmpegdec, "Decoded data, now storing buffer %p", outbuf); |
296 |
|
297 |
@@ -652,13 +629,13 @@ gst_ffmpegauddec_frame (GstFFMpegAudDec * ffmpegdec, |
298 |
} |
299 |
|
300 |
beach: |
301 |
- return len; |
302 |
+ return got_frame; |
303 |
|
304 |
/* ERRORS */ |
305 |
no_codec: |
306 |
{ |
307 |
GST_ERROR_OBJECT (ffmpegdec, "no codec context"); |
308 |
- return -1; |
309 |
+ goto beach; |
310 |
} |
311 |
} |
312 |
|
313 |
@@ -669,8 +646,8 @@ gst_ffmpegauddec_drain (GstFFMpegAudDec * ffmpegdec) |
314 |
|
315 |
oclass = (GstFFMpegAudDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec)); |
316 |
|
317 |
- if (oclass->in_plugin->capabilities & CODEC_CAP_DELAY) { |
318 |
- gint have_data, len; |
319 |
+ if (oclass->in_plugin->capabilities & AV_CODEC_CAP_DELAY) { |
320 |
+ gboolean got_frame; |
321 |
|
322 |
GST_LOG_OBJECT (ffmpegdec, |
323 |
"codec has delay capabilities, calling until libav has drained everything"); |
324 |
@@ -678,9 +655,8 @@ gst_ffmpegauddec_drain (GstFFMpegAudDec * ffmpegdec) |
325 |
do { |
326 |
GstFlowReturn ret; |
327 |
|
328 |
- len = gst_ffmpegauddec_frame (ffmpegdec, NULL, 0, &have_data, &ret); |
329 |
- |
330 |
- } while (len >= 0 && have_data == 1); |
331 |
+ got_frame = gst_ffmpegauddec_frame (ffmpegdec, &ret); |
332 |
+ } while (got_frame); |
333 |
avcodec_flush_buffers (ffmpegdec->context); |
334 |
} |
335 |
|
336 |
@@ -705,11 +681,13 @@ gst_ffmpegauddec_handle_frame (GstAudioDecoder * decod |
337 |
{ |
338 |
GstFFMpegAudDec *ffmpegdec; |
339 |
GstFFMpegAudDecClass *oclass; |
340 |
- guint8 *data, *bdata; |
341 |
+ guint8 *data; |
342 |
GstMapInfo map; |
343 |
- gint size, bsize, len, have_data; |
344 |
+ gint size; |
345 |
+ gboolean got_frame; |
346 |
GstFlowReturn ret = GST_FLOW_OK; |
347 |
- gboolean do_padding, is_header; |
348 |
+ gboolean is_header; |
349 |
+ AVPacket packet; |
350 |
|
351 |
ffmpegdec = (GstFFMpegAudDec *) decoder; |
352 |
|
353 |
@@ -744,82 +722,47 @@ gst_ffmpegauddec_handle_frame (GstAudioDecoder * decod |
354 |
|
355 |
gst_buffer_map (inbuf, &map, GST_MAP_READ); |
356 |
|
357 |
- bdata = map.data; |
358 |
- bsize = map.size; |
359 |
+ data = map.data; |
360 |
+ size = map.size; |
361 |
|
362 |
- if (bsize > 0 && (!GST_MEMORY_IS_ZERO_PADDED (map.memory) |
363 |
- || (map.maxsize - map.size) < FF_INPUT_BUFFER_PADDING_SIZE)) { |
364 |
+ if (size > 0 && (!GST_MEMORY_IS_ZERO_PADDED (map.memory) |
365 |
+ || (map.maxsize - map.size) < AV_INPUT_BUFFER_PADDING_SIZE)) { |
366 |
/* add padding */ |
367 |
- if (ffmpegdec->padded_size < bsize + FF_INPUT_BUFFER_PADDING_SIZE) { |
368 |
- ffmpegdec->padded_size = bsize + FF_INPUT_BUFFER_PADDING_SIZE; |
369 |
+ if (ffmpegdec->padded_size < size + AV_INPUT_BUFFER_PADDING_SIZE) { |
370 |
+ ffmpegdec->padded_size = size + AV_INPUT_BUFFER_PADDING_SIZE; |
371 |
ffmpegdec->padded = g_realloc (ffmpegdec->padded, ffmpegdec->padded_size); |
372 |
GST_LOG_OBJECT (ffmpegdec, "resized padding buffer to %d", |
373 |
ffmpegdec->padded_size); |
374 |
} |
375 |
GST_CAT_TRACE_OBJECT (GST_CAT_PERFORMANCE, ffmpegdec, |
376 |
"Copy input to add padding"); |
377 |
- memcpy (ffmpegdec->padded, bdata, bsize); |
378 |
- memset (ffmpegdec->padded + bsize, 0, FF_INPUT_BUFFER_PADDING_SIZE); |
379 |
+ memcpy (ffmpegdec->padded, data, size); |
380 |
+ memset (ffmpegdec->padded + size, 0, AV_INPUT_BUFFER_PADDING_SIZE); |
381 |
|
382 |
- bdata = ffmpegdec->padded; |
383 |
- do_padding = TRUE; |
384 |
- } else { |
385 |
- do_padding = FALSE; |
386 |
+ data = ffmpegdec->padded; |
387 |
} |
388 |
|
389 |
- do { |
390 |
- guint8 tmp_padding[FF_INPUT_BUFFER_PADDING_SIZE]; |
391 |
+ gst_avpacket_init (&packet, data, size); |
392 |
|
393 |
- data = bdata; |
394 |
- size = bsize; |
395 |
+ if (!packet.size) |
396 |
+ goto done; |
397 |
|
398 |
- if (do_padding) { |
399 |
- /* add temporary padding */ |
400 |
- GST_CAT_TRACE_OBJECT (GST_CAT_PERFORMANCE, ffmpegdec, |
401 |
- "Add temporary input padding"); |
402 |
- memcpy (tmp_padding, data + size, FF_INPUT_BUFFER_PADDING_SIZE); |
403 |
- memset (data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE); |
404 |
- } |
405 |
+ if (avcodec_send_packet (ffmpegdec->context, &packet) < 0) { |
406 |
+ goto send_packet_failed; |
407 |
+ } |
408 |
|
409 |
+ do { |
410 |
/* decode a frame of audio now */ |
411 |
- len = gst_ffmpegauddec_frame (ffmpegdec, data, size, &have_data, &ret); |
412 |
+ got_frame = gst_ffmpegauddec_frame (ffmpegdec, &ret); |
413 |
|
414 |
- if (do_padding) { |
415 |
- memcpy (data + size, tmp_padding, FF_INPUT_BUFFER_PADDING_SIZE); |
416 |
- } |
417 |
- |
418 |
if (ret != GST_FLOW_OK) { |
419 |
GST_LOG_OBJECT (ffmpegdec, "breaking because of flow ret %s", |
420 |
gst_flow_get_name (ret)); |
421 |
/* bad flow return, make sure we discard all data and exit */ |
422 |
- bsize = 0; |
423 |
break; |
424 |
} |
425 |
+ } while (got_frame); |
426 |
|
427 |
- if (len == 0 && have_data == 0) { |
428 |
- /* nothing was decoded, this could be because no data was available or |
429 |
- * because we were skipping frames. |
430 |
- * If we have no context we must exit and wait for more data, we keep the |
431 |
- * data we tried. */ |
432 |
- GST_LOG_OBJECT (ffmpegdec, "Decoding didn't return any data, breaking"); |
433 |
- break; |
434 |
- } else if (len < 0) { |
435 |
- /* a decoding error happened, we must break and try again with next data. */ |
436 |
- GST_LOG_OBJECT (ffmpegdec, "Decoding error, breaking"); |
437 |
- bsize = 0; |
438 |
- break; |
439 |
- } |
440 |
- /* prepare for the next round, for codecs with a context we did this |
441 |
- * already when using the parser. */ |
442 |
- bsize -= len; |
443 |
- bdata += len; |
444 |
- |
445 |
- do_padding = TRUE; |
446 |
- |
447 |
- GST_LOG_OBJECT (ffmpegdec, "Before (while bsize>0). bsize:%d , bdata:%p", |
448 |
- bsize, bdata); |
449 |
- } while (bsize > 0); |
450 |
- |
451 |
gst_buffer_unmap (inbuf, &map); |
452 |
gst_buffer_unref (inbuf); |
453 |
|
454 |
@@ -827,15 +770,12 @@ gst_ffmpegauddec_handle_frame (GstAudioDecoder * decod |
455 |
ret = |
456 |
gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (ffmpegdec), |
457 |
ffmpegdec->outbuf, 1); |
458 |
- else if (len < 0 || is_header) |
459 |
+ else if (is_header) |
460 |
ret = |
461 |
gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (ffmpegdec), NULL, 1); |
462 |
ffmpegdec->outbuf = NULL; |
463 |
|
464 |
- if (bsize > 0) { |
465 |
- GST_DEBUG_OBJECT (ffmpegdec, "Dropping %d bytes of data", bsize); |
466 |
- } |
467 |
- |
468 |
+done: |
469 |
return ret; |
470 |
|
471 |
/* ERRORS */ |
472 |
@@ -845,8 +785,15 @@ not_negotiated: |
473 |
GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION, (NULL), |
474 |
("avdec_%s: input format was not set before data start", |
475 |
oclass->in_plugin->name)); |
476 |
- return GST_FLOW_NOT_NEGOTIATED; |
477 |
+ ret = GST_FLOW_NOT_NEGOTIATED; |
478 |
+ goto done; |
479 |
} |
480 |
+ |
481 |
+send_packet_failed: |
482 |
+ { |
483 |
+ GST_WARNING_OBJECT (ffmpegdec, "decoding error"); |
484 |
+ goto done; |
485 |
+ } |
486 |
} |
487 |
|
488 |
gboolean |
489 |
@@ -865,19 +812,18 @@ gst_ffmpegauddec_register (GstPlugin * plugin) |
490 |
}; |
491 |
GType type; |
492 |
AVCodec *in_plugin; |
493 |
+ void *i = 0; |
494 |
gint rank; |
495 |
|
496 |
- in_plugin = av_codec_next (NULL); |
497 |
- |
498 |
GST_LOG ("Registering decoders"); |
499 |
|
500 |
- while (in_plugin) { |
501 |
+ while ((in_plugin = (AVCodec *) av_codec_iterate (&i))) { |
502 |
gchar *type_name; |
503 |
|
504 |
/* only decoders */ |
505 |
if (!av_codec_is_decoder (in_plugin) |
506 |
|| in_plugin->type != AVMEDIA_TYPE_AUDIO) { |
507 |
- goto next; |
508 |
+ continue; |
509 |
} |
510 |
|
511 |
/* no quasi codecs, please */ |
512 |
@@ -885,15 +831,8 @@ gst_ffmpegauddec_register (GstPlugin * plugin) |
513 |
(in_plugin->id >= AV_CODEC_ID_PCM_S16LE && |
514 |
in_plugin->id <= AV_CODEC_ID_PCM_BLURAY) || |
515 |
(in_plugin->id >= AV_CODEC_ID_PCM_S8_PLANAR && |
516 |
-#if AV_VERSION_INT (LIBAVCODEC_VERSION_MAJOR, LIBAVCODEC_VERSION_MINOR, LIBAVCODEC_VERSION_MICRO) >= AV_VERSION_INT (57,69,0) |
517 |
- in_plugin->id <= AV_CODEC_ID_PCM_F24LE)) { |
518 |
-#elif AV_VERSION_INT (LIBAVCODEC_VERSION_MAJOR, LIBAVCODEC_VERSION_MINOR, LIBAVCODEC_VERSION_MICRO) >= AV_VERSION_INT (57,54,0) |
519 |
- in_plugin->id <= AV_CODEC_ID_PCM_S64BE)) { |
520 |
-#else |
521 |
- in_plugin->id <= AV_CODEC_ID_PCM_S16BE_PLANAR)) { |
522 |
-#endif |
523 |
- goto next; |
524 |
- } |
525 |
+ in_plugin->id <= AV_CODEC_ID_PCM_F24LE)) |
526 |
+ continue; |
527 |
|
528 |
/* No decoders depending on external libraries (we don't build them, but |
529 |
* people who build against an external ffmpeg might have them. |
530 |
@@ -902,7 +841,7 @@ gst_ffmpegauddec_register (GstPlugin * plugin) |
531 |
GST_DEBUG |
532 |
("Not using external library decoder %s. Use the gstreamer-native ones instead.", |
533 |
in_plugin->name); |
534 |
- goto next; |
535 |
+ continue; |
536 |
} |
537 |
|
538 |
GST_DEBUG ("Trying plugin %s [%s]", in_plugin->name, in_plugin->long_name); |
539 |
@@ -923,7 +862,7 @@ gst_ffmpegauddec_register (GstPlugin * plugin) |
540 |
!strcmp (in_plugin->name, "dvdsub") || |
541 |
!strcmp (in_plugin->name, "dvbsub")) { |
542 |
GST_LOG ("Ignoring decoder %s", in_plugin->name); |
543 |
- goto next; |
544 |
+ continue; |
545 |
} |
546 |
|
547 |
/* construct the type */ |
548 |
@@ -967,9 +906,6 @@ gst_ffmpegauddec_register (GstPlugin * plugin) |
549 |
} |
550 |
|
551 |
g_free (type_name); |
552 |
- |
553 |
- next: |
554 |
- in_plugin = av_codec_next (in_plugin); |
555 |
} |
556 |
|
557 |
GST_LOG ("Finished Registering decoders"); |
558 |
--- ext/libav/gstavauddec.h.orig 2018-03-23 20:45:20 UTC |
559 |
+++ ext/libav/gstavauddec.h |
560 |
@@ -19,6 +19,8 @@ |
561 |
#ifndef __GST_FFMPEGAUDDEC_H__ |
562 |
#define __GST_FFMPEGAUDDEC_H__ |
563 |
|
564 |
+#include <glib.h> |
565 |
+ |
566 |
G_BEGIN_DECLS |
567 |
|
568 |
#include <gst/gst.h> |
569 |
@@ -38,7 +40,7 @@ struct _GstFFMpegAudDec |
570 |
AVFrame *frame; |
571 |
|
572 |
guint8 *padded; |
573 |
- guint padded_size; |
574 |
+ gint padded_size; |
575 |
|
576 |
/* prevent reopening the decoder on GST_EVENT_CAPS when caps are same as last time. */ |
577 |
GstCaps *last_caps; |
578 |
--- ext/libav/gstavaudenc.c.orig 2018-03-23 20:45:20 UTC |
579 |
+++ ext/libav/gstavaudenc.c |
580 |
@@ -31,31 +31,22 @@ |
581 |
#include <errno.h> |
582 |
|
583 |
#include <libavcodec/avcodec.h> |
584 |
+#include <libavutil/opt.h> |
585 |
|
586 |
#include <gst/gst.h> |
587 |
|
588 |
#include "gstav.h" |
589 |
+#include "gstavcfg.h" |
590 |
#include "gstavcodecmap.h" |
591 |
#include "gstavutils.h" |
592 |
#include "gstavaudenc.h" |
593 |
|
594 |
-#define DEFAULT_AUDIO_BITRATE 128000 |
595 |
- |
596 |
enum |
597 |
{ |
598 |
- /* FILL ME */ |
599 |
- LAST_SIGNAL |
600 |
-}; |
601 |
- |
602 |
-enum |
603 |
-{ |
604 |
PROP_0, |
605 |
- PROP_BIT_RATE, |
606 |
- PROP_RTP_PAYLOAD_SIZE, |
607 |
- PROP_COMPLIANCE, |
608 |
+ PROP_CFG_BASE, |
609 |
}; |
610 |
|
611 |
-/* A number of function prototypes are given so we can refer to them later. */ |
612 |
static void gst_ffmpegaudenc_class_init (GstFFMpegAudEncClass * klass); |
613 |
static void gst_ffmpegaudenc_base_init (GstFFMpegAudEncClass * klass); |
614 |
static void gst_ffmpegaudenc_init (GstFFMpegAudEnc * ffmpegaudenc); |
615 |
@@ -78,8 +69,6 @@ static void gst_ffmpegaudenc_get_property (GObject * o |
616 |
|
617 |
static GstElementClass *parent_class = NULL; |
618 |
|
619 |
-/*static guint gst_ffmpegaudenc_signals[LAST_SIGNAL] = { 0 }; */ |
620 |
- |
621 |
static void |
622 |
gst_ffmpegaudenc_base_init (GstFFMpegAudEncClass * klass) |
623 |
{ |
624 |
@@ -148,16 +137,8 @@ gst_ffmpegaudenc_class_init (GstFFMpegAudEncClass * kl |
625 |
gobject_class->set_property = gst_ffmpegaudenc_set_property; |
626 |
gobject_class->get_property = gst_ffmpegaudenc_get_property; |
627 |
|
628 |
- /* FIXME: could use -1 for a sensible per-codec defaults */ |
629 |
- g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BIT_RATE, |
630 |
- g_param_spec_int ("bitrate", "Bit Rate", |
631 |
- "Target Audio Bitrate", 0, G_MAXINT, DEFAULT_AUDIO_BITRATE, |
632 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
633 |
- g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_COMPLIANCE, |
634 |
- g_param_spec_enum ("compliance", "Compliance", |
635 |
- "Adherence of the encoder to the specifications", |
636 |
- GST_TYPE_FFMPEG_COMPLIANCE, FFMPEG_DEFAULT_COMPLIANCE, |
637 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
638 |
+ gst_ffmpeg_cfg_install_properties (gobject_class, klass->in_plugin, |
639 |
+ PROP_CFG_BASE, AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM); |
640 |
|
641 |
gobject_class->finalize = gst_ffmpegaudenc_finalize; |
642 |
|
643 |
@@ -180,11 +161,10 @@ gst_ffmpegaudenc_init (GstFFMpegAudEnc * ffmpegaudenc) |
644 |
|
645 |
/* ffmpeg objects */ |
646 |
ffmpegaudenc->context = avcodec_alloc_context3 (klass->in_plugin); |
647 |
+ ffmpegaudenc->refcontext = avcodec_alloc_context3 (klass->in_plugin); |
648 |
ffmpegaudenc->opened = FALSE; |
649 |
ffmpegaudenc->frame = av_frame_alloc (); |
650 |
|
651 |
- ffmpegaudenc->compliance = FFMPEG_DEFAULT_COMPLIANCE; |
652 |
- |
653 |
gst_audio_encoder_set_drainable (GST_AUDIO_ENCODER (ffmpegaudenc), TRUE); |
654 |
} |
655 |
|
656 |
@@ -197,6 +177,7 @@ gst_ffmpegaudenc_finalize (GObject * object) |
657 |
av_frame_free (&ffmpegaudenc->frame); |
658 |
gst_ffmpeg_avcodec_close (ffmpegaudenc->context); |
659 |
av_free (ffmpegaudenc->context); |
660 |
+ av_free (ffmpegaudenc->refcontext); |
661 |
|
662 |
G_OBJECT_CLASS (parent_class)->finalize (object); |
663 |
} |
664 |
@@ -262,33 +243,8 @@ gst_ffmpegaudenc_set_format (GstAudioEncoder * encoder |
665 |
} |
666 |
} |
667 |
|
668 |
- /* if we set it in _getcaps we should set it also in _link */ |
669 |
- ffmpegaudenc->context->strict_std_compliance = ffmpegaudenc->compliance; |
670 |
+ gst_ffmpeg_cfg_fill_context (G_OBJECT (ffmpegaudenc), ffmpegaudenc->context); |
671 |
|
672 |
- /* user defined properties */ |
673 |
- if (ffmpegaudenc->bitrate > 0) { |
674 |
- GST_INFO_OBJECT (ffmpegaudenc, "Setting avcontext to bitrate %d", |
675 |
- ffmpegaudenc->bitrate); |
676 |
- ffmpegaudenc->context->bit_rate = ffmpegaudenc->bitrate; |
677 |
- ffmpegaudenc->context->bit_rate_tolerance = ffmpegaudenc->bitrate; |
678 |
- } else { |
679 |
- GST_INFO_OBJECT (ffmpegaudenc, |
680 |
- "Using avcontext default bitrate %" G_GINT64_FORMAT, |
681 |
- (gint64) ffmpegaudenc->context->bit_rate); |
682 |
- } |
683 |
- |
684 |
- /* RTP payload used for GOB production (for Asterisk) */ |
685 |
- if (ffmpegaudenc->rtp_payload_size) { |
686 |
- ffmpegaudenc->context->rtp_payload_size = ffmpegaudenc->rtp_payload_size; |
687 |
- } |
688 |
- |
689 |
- /* some other defaults */ |
690 |
- ffmpegaudenc->context->rc_strategy = 2; |
691 |
- ffmpegaudenc->context->b_frame_strategy = 0; |
692 |
- ffmpegaudenc->context->coder_type = 0; |
693 |
- ffmpegaudenc->context->context_model = 0; |
694 |
- ffmpegaudenc->context->scenechange_threshold = 0; |
695 |
- |
696 |
/* fetch pix_fmt and so on */ |
697 |
gst_ffmpeg_audioinfo_to_context (info, ffmpegaudenc->context); |
698 |
if (!ffmpegaudenc->context->time_base.den) { |
699 |
@@ -330,8 +286,9 @@ gst_ffmpegaudenc_set_format (GstAudioEncoder * encoder |
700 |
oclass->in_plugin) < 0) |
701 |
GST_DEBUG_OBJECT (ffmpegaudenc, "Failed to set context defaults"); |
702 |
|
703 |
- if ((oclass->in_plugin->capabilities & CODEC_CAP_EXPERIMENTAL) && |
704 |
- ffmpegaudenc->compliance != GST_FFMPEG_EXPERIMENTAL) { |
705 |
+ if ((oclass->in_plugin->capabilities & AV_CODEC_CAP_EXPERIMENTAL) && |
706 |
+ ffmpegaudenc->context->strict_std_compliance != |
707 |
+ GST_FFMPEG_EXPERIMENTAL) { |
708 |
GST_ELEMENT_ERROR (ffmpegaudenc, LIBRARY, SETTINGS, |
709 |
("Codec is experimental, but settings don't allow encoders to " |
710 |
"produce output of experimental quality"), |
711 |
@@ -445,15 +402,13 @@ buffer_info_free (void *opaque, guint8 * data) |
712 |
} |
713 |
|
714 |
static GstFlowReturn |
715 |
-gst_ffmpegaudenc_encode_audio (GstFFMpegAudEnc * ffmpegaudenc, |
716 |
- GstBuffer * buffer, gint * have_data) |
717 |
+gst_ffmpegaudenc_send_frame (GstFFMpegAudEnc * ffmpegaudenc, GstBuffer * buffer) |
718 |
{ |
719 |
GstAudioEncoder *enc; |
720 |
AVCodecContext *ctx; |
721 |
- gint res; |
722 |
GstFlowReturn ret; |
723 |
+ gint res; |
724 |
GstAudioInfo *info; |
725 |
- AVPacket *pkt; |
726 |
AVFrame *frame = ffmpegaudenc->frame; |
727 |
gboolean planar; |
728 |
gint nsamples = -1; |
729 |
@@ -462,8 +417,6 @@ gst_ffmpegaudenc_encode_audio (GstFFMpegAudEnc * ffmpe |
730 |
|
731 |
ctx = ffmpegaudenc->context; |
732 |
|
733 |
- pkt = g_slice_new0 (AVPacket); |
734 |
- |
735 |
if (buffer != NULL) { |
736 |
BufferInfo *buffer_info = g_slice_new0 (BufferInfo); |
737 |
guint8 *audio_in; |
738 |
@@ -572,28 +525,47 @@ gst_ffmpegaudenc_encode_audio (GstFFMpegAudEnc * ffmpe |
739 |
} |
740 |
|
741 |
/* we have a frame to feed the encoder */ |
742 |
- res = avcodec_encode_audio2 (ctx, pkt, frame, have_data); |
743 |
+ res = avcodec_send_frame (ctx, frame); |
744 |
|
745 |
av_frame_unref (frame); |
746 |
} else { |
747 |
GST_LOG_OBJECT (ffmpegaudenc, "draining"); |
748 |
/* flushing the encoder */ |
749 |
- res = avcodec_encode_audio2 (ctx, pkt, NULL, have_data); |
750 |
+ res = avcodec_send_frame (ctx, NULL); |
751 |
} |
752 |
|
753 |
- if (res < 0) { |
754 |
- char error_str[128] = { 0, }; |
755 |
- |
756 |
- g_slice_free (AVPacket, pkt); |
757 |
- av_strerror (res, error_str, sizeof (error_str)); |
758 |
- GST_ERROR_OBJECT (enc, "Failed to encode buffer: %d - %s", res, error_str); |
759 |
- return GST_FLOW_OK; |
760 |
+ if (res == 0) { |
761 |
+ ret = GST_FLOW_OK; |
762 |
+ } else if (res == AVERROR_EOF) { |
763 |
+ ret = GST_FLOW_EOS; |
764 |
+ } else { /* Any other return value is an error in our context */ |
765 |
+ ret = GST_FLOW_OK; |
766 |
+ GST_WARNING_OBJECT (ffmpegaudenc, "Failed to encode buffer"); |
767 |
} |
768 |
- GST_LOG_OBJECT (ffmpegaudenc, "got output size %d", res); |
769 |
|
770 |
- if (*have_data) { |
771 |
+ return ret; |
772 |
+} |
773 |
+ |
774 |
+static GstFlowReturn |
775 |
+gst_ffmpegaudenc_receive_packet (GstFFMpegAudEnc * ffmpegaudenc, |
776 |
+ gboolean * got_packet) |
777 |
+{ |
778 |
+ GstAudioEncoder *enc; |
779 |
+ AVCodecContext *ctx; |
780 |
+ gint res; |
781 |
+ GstFlowReturn ret; |
782 |
+ AVPacket *pkt; |
783 |
+ |
784 |
+ enc = GST_AUDIO_ENCODER (ffmpegaudenc); |
785 |
+ |
786 |
+ ctx = ffmpegaudenc->context; |
787 |
+ |
788 |
+ pkt = g_slice_new0 (AVPacket); |
789 |
+ |
790 |
+ res = avcodec_receive_packet (ctx, pkt); |
791 |
+ |
792 |
+ if (res == 0) { |
793 |
GstBuffer *outbuf; |
794 |
- const AVCodec *codec; |
795 |
|
796 |
GST_LOG_OBJECT (ffmpegaudenc, "pushing size %d", pkt->size); |
797 |
|
798 |
@@ -601,45 +573,39 @@ gst_ffmpegaudenc_encode_audio (GstFFMpegAudEnc * ffmpe |
799 |
gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY, pkt->data, |
800 |
pkt->size, 0, pkt->size, pkt, gst_ffmpegaudenc_free_avpacket); |
801 |
|
802 |
- codec = ffmpegaudenc->context->codec; |
803 |
- if ((codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE) || !buffer) { |
804 |
- /* FIXME: Not really correct, as -1 means "all the samples we got |
805 |
- given so far", which may not be true depending on the codec, |
806 |
- but we have no way to know AFAICT */ |
807 |
- ret = gst_audio_encoder_finish_frame (enc, outbuf, -1); |
808 |
- } else { |
809 |
- ret = gst_audio_encoder_finish_frame (enc, outbuf, nsamples); |
810 |
- } |
811 |
+ ret = |
812 |
+ gst_audio_encoder_finish_frame (enc, outbuf, |
813 |
+ pkt->duration > 0 ? pkt->duration : -1); |
814 |
+ *got_packet = TRUE; |
815 |
} else { |
816 |
GST_LOG_OBJECT (ffmpegaudenc, "no output produced"); |
817 |
g_slice_free (AVPacket, pkt); |
818 |
ret = GST_FLOW_OK; |
819 |
+ *got_packet = FALSE; |
820 |
} |
821 |
|
822 |
return ret; |
823 |
} |
824 |
|
825 |
-static void |
826 |
+static GstFlowReturn |
827 |
gst_ffmpegaudenc_drain (GstFFMpegAudEnc * ffmpegaudenc) |
828 |
{ |
829 |
- GstFFMpegAudEncClass *oclass; |
830 |
+ GstFlowReturn ret = GST_FLOW_OK; |
831 |
+ gboolean got_packet; |
832 |
|
833 |
- oclass = (GstFFMpegAudEncClass *) (G_OBJECT_GET_CLASS (ffmpegaudenc)); |
834 |
+ ret = gst_ffmpegaudenc_send_frame (ffmpegaudenc, NULL); |
835 |
|
836 |
- if (oclass->in_plugin->capabilities & CODEC_CAP_DELAY) { |
837 |
- gint have_data, try = 0; |
838 |
- |
839 |
- GST_LOG_OBJECT (ffmpegaudenc, |
840 |
- "codec has delay capabilities, calling until libav has drained everything"); |
841 |
- |
842 |
+ if (ret == GST_FLOW_OK) { |
843 |
do { |
844 |
- GstFlowReturn ret; |
845 |
- |
846 |
- ret = gst_ffmpegaudenc_encode_audio (ffmpegaudenc, NULL, &have_data); |
847 |
- if (ret != GST_FLOW_OK || have_data == 0) |
848 |
+ ret = gst_ffmpegaudenc_receive_packet (ffmpegaudenc, &got_packet); |
849 |
+ if (ret != GST_FLOW_OK) |
850 |
break; |
851 |
- } while (try++ < 10); |
852 |
+ } while (got_packet); |
853 |
} |
854 |
+ |
855 |
+ avcodec_flush_buffers (ffmpegaudenc->context); |
856 |
+ |
857 |
+ return ret; |
858 |
} |
859 |
|
860 |
static GstFlowReturn |
861 |
@@ -647,17 +613,15 @@ gst_ffmpegaudenc_handle_frame (GstAudioEncoder * encod |
862 |
{ |
863 |
GstFFMpegAudEnc *ffmpegaudenc; |
864 |
GstFlowReturn ret; |
865 |
- gint have_data; |
866 |
+ gboolean got_packet; |
867 |
|
868 |
ffmpegaudenc = (GstFFMpegAudEnc *) encoder; |
869 |
|
870 |
if (G_UNLIKELY (!ffmpegaudenc->opened)) |
871 |
goto not_negotiated; |
872 |
|
873 |
- if (!inbuf) { |
874 |
- gst_ffmpegaudenc_drain (ffmpegaudenc); |
875 |
- return GST_FLOW_OK; |
876 |
- } |
877 |
+ if (!inbuf) |
878 |
+ return gst_ffmpegaudenc_drain (ffmpegaudenc); |
879 |
|
880 |
inbuf = gst_buffer_ref (inbuf); |
881 |
|
882 |
@@ -675,11 +639,15 @@ gst_ffmpegaudenc_handle_frame (GstAudioEncoder * encod |
883 |
info->channels, info->position, ffmpegaudenc->ffmpeg_layout); |
884 |
} |
885 |
|
886 |
- ret = gst_ffmpegaudenc_encode_audio (ffmpegaudenc, inbuf, &have_data); |
887 |
+ ret = gst_ffmpegaudenc_send_frame (ffmpegaudenc, inbuf); |
888 |
|
889 |
if (ret != GST_FLOW_OK) |
890 |
- goto push_failed; |
891 |
+ goto send_frame_failed; |
892 |
|
893 |
+ do { |
894 |
+ ret = gst_ffmpegaudenc_receive_packet (ffmpegaudenc, &got_packet); |
895 |
+ } while (got_packet); |
896 |
+ |
897 |
return GST_FLOW_OK; |
898 |
|
899 |
/* ERRORS */ |
900 |
@@ -690,9 +658,9 @@ not_negotiated: |
901 |
gst_buffer_unref (inbuf); |
902 |
return GST_FLOW_NOT_NEGOTIATED; |
903 |
} |
904 |
-push_failed: |
905 |
+send_frame_failed: |
906 |
{ |
907 |
- GST_DEBUG_OBJECT (ffmpegaudenc, "Failed to push buffer %d (%s)", ret, |
908 |
+ GST_DEBUG_OBJECT (ffmpegaudenc, "Failed to send frame %d (%s)", ret, |
909 |
gst_flow_get_name (ret)); |
910 |
return ret; |
911 |
} |
912 |
@@ -704,55 +672,34 @@ gst_ffmpegaudenc_set_property (GObject * object, |
913 |
{ |
914 |
GstFFMpegAudEnc *ffmpegaudenc; |
915 |
|
916 |
- /* Get a pointer of the right type. */ |
917 |
ffmpegaudenc = (GstFFMpegAudEnc *) (object); |
918 |
|
919 |
if (ffmpegaudenc->opened) { |
920 |
GST_WARNING_OBJECT (ffmpegaudenc, |
921 |
- "Can't change properties once decoder is setup !"); |
922 |
+ "Can't change properties once encoder is setup !"); |
923 |
return; |
924 |
} |
925 |
|
926 |
- /* Check the argument id to see which argument we're setting. */ |
927 |
switch (prop_id) { |
928 |
- case PROP_BIT_RATE: |
929 |
- ffmpegaudenc->bitrate = g_value_get_int (value); |
930 |
- break; |
931 |
- case PROP_RTP_PAYLOAD_SIZE: |
932 |
- ffmpegaudenc->rtp_payload_size = g_value_get_int (value); |
933 |
- break; |
934 |
- case PROP_COMPLIANCE: |
935 |
- ffmpegaudenc->compliance = g_value_get_enum (value); |
936 |
- break; |
937 |
default: |
938 |
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
939 |
+ if (!gst_ffmpeg_cfg_set_property (ffmpegaudenc->refcontext, value, pspec)) |
940 |
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
941 |
break; |
942 |
} |
943 |
} |
944 |
|
945 |
-/* The set function is simply the inverse of the get fuction. */ |
946 |
static void |
947 |
gst_ffmpegaudenc_get_property (GObject * object, |
948 |
guint prop_id, GValue * value, GParamSpec * pspec) |
949 |
{ |
950 |
GstFFMpegAudEnc *ffmpegaudenc; |
951 |
|
952 |
- /* It's not null if we got it, but it might not be ours */ |
953 |
ffmpegaudenc = (GstFFMpegAudEnc *) (object); |
954 |
|
955 |
switch (prop_id) { |
956 |
- case PROP_BIT_RATE: |
957 |
- g_value_set_int (value, ffmpegaudenc->bitrate); |
958 |
- break; |
959 |
- break; |
960 |
- case PROP_RTP_PAYLOAD_SIZE: |
961 |
- g_value_set_int (value, ffmpegaudenc->rtp_payload_size); |
962 |
- break; |
963 |
- case PROP_COMPLIANCE: |
964 |
- g_value_set_enum (value, ffmpegaudenc->compliance); |
965 |
- break; |
966 |
default: |
967 |
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
968 |
+ if (!gst_ffmpeg_cfg_get_property (ffmpegaudenc->refcontext, value, pspec)) |
969 |
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
970 |
break; |
971 |
} |
972 |
} |
973 |
@@ -773,32 +720,26 @@ gst_ffmpegaudenc_register (GstPlugin * plugin) |
974 |
}; |
975 |
GType type; |
976 |
AVCodec *in_plugin; |
977 |
+ void *i = 0; |
978 |
|
979 |
|
980 |
GST_LOG ("Registering encoders"); |
981 |
|
982 |
- in_plugin = av_codec_next (NULL); |
983 |
- while (in_plugin) { |
984 |
+ while ((in_plugin = (AVCodec *) av_codec_iterate (&i))) { |
985 |
gchar *type_name; |
986 |
guint rank; |
987 |
|
988 |
/* Skip non-AV codecs */ |
989 |
if (in_plugin->type != AVMEDIA_TYPE_AUDIO) |
990 |
- goto next; |
991 |
+ continue; |
992 |
|
993 |
/* no quasi codecs, please */ |
994 |
if (in_plugin->id == AV_CODEC_ID_PCM_S16LE_PLANAR || |
995 |
(in_plugin->id >= AV_CODEC_ID_PCM_S16LE && |
996 |
in_plugin->id <= AV_CODEC_ID_PCM_BLURAY) || |
997 |
(in_plugin->id >= AV_CODEC_ID_PCM_S8_PLANAR && |
998 |
-#if AV_VERSION_INT (LIBAVCODEC_VERSION_MAJOR, LIBAVCODEC_VERSION_MINOR, LIBAVCODEC_VERSION_MICRO) >= AV_VERSION_INT (57,69,0) |
999 |
in_plugin->id <= AV_CODEC_ID_PCM_F24LE)) { |
1000 |
-#elif AV_VERSION_INT (LIBAVCODEC_VERSION_MAJOR, LIBAVCODEC_VERSION_MINOR, LIBAVCODEC_VERSION_MICRO) >= AV_VERSION_INT (57,54,0) |
1001 |
- in_plugin->id <= AV_CODEC_ID_PCM_S64BE)) { |
1002 |
-#else |
1003 |
- in_plugin->id <= AV_CODEC_ID_PCM_S16BE_PLANAR)) { |
1004 |
-#endif |
1005 |
- goto next; |
1006 |
+ continue; |
1007 |
} |
1008 |
|
1009 |
/* No encoders depending on external libraries (we don't build them, but |
1010 |
@@ -808,12 +749,12 @@ gst_ffmpegaudenc_register (GstPlugin * plugin) |
1011 |
GST_DEBUG |
1012 |
("Not using external library encoder %s. Use the gstreamer-native ones instead.", |
1013 |
in_plugin->name); |
1014 |
- goto next; |
1015 |
+ continue; |
1016 |
} |
1017 |
|
1018 |
/* only encoders */ |
1019 |
if (!av_codec_is_encoder (in_plugin)) { |
1020 |
- goto next; |
1021 |
+ continue; |
1022 |
} |
1023 |
|
1024 |
/* FIXME : We should have a method to know cheaply whether we have a mapping |
1025 |
@@ -825,7 +766,7 @@ gst_ffmpegaudenc_register (GstPlugin * plugin) |
1026 |
if (!strcmp (in_plugin->name, "vorbis") |
1027 |
|| !strcmp (in_plugin->name, "flac")) { |
1028 |
GST_LOG ("Ignoring encoder %s", in_plugin->name); |
1029 |
- goto next; |
1030 |
+ continue; |
1031 |
} |
1032 |
|
1033 |
/* construct the type */ |
1034 |
@@ -867,9 +808,6 @@ gst_ffmpegaudenc_register (GstPlugin * plugin) |
1035 |
} |
1036 |
|
1037 |
g_free (type_name); |
1038 |
- |
1039 |
- next: |
1040 |
- in_plugin = av_codec_next (in_plugin); |
1041 |
} |
1042 |
|
1043 |
GST_LOG ("Finished registering encoders"); |
1044 |
--- ext/libav/gstavaudenc.h.orig 2018-03-23 20:45:20 UTC |
1045 |
+++ ext/libav/gstavaudenc.h |
1046 |
@@ -37,16 +37,8 @@ struct _GstFFMpegAudEnc |
1047 |
GstAudioEncoder parent; |
1048 |
|
1049 |
AVCodecContext *context; |
1050 |
+ AVCodecContext *refcontext; |
1051 |
gboolean opened; |
1052 |
- |
1053 |
- /* cache */ |
1054 |
- gint bitrate; |
1055 |
- gint rtp_payload_size; |
1056 |
- gint compliance; |
1057 |
- |
1058 |
- /* other settings are copied over straight, |
1059 |
- * include a context here, rather than copy-and-past it from avcodec.h */ |
1060 |
- AVCodecContext config; |
1061 |
|
1062 |
AVFrame *frame; |
1063 |
|
1064 |
--- ext/libav/gstavcfg.c.orig 2018-03-23 20:45:20 UTC |
1065 |
+++ ext/libav/gstavcfg.c |
1066 |
@@ -30,1047 +30,558 @@ |
1067 |
#include "gstavcfg.h" |
1068 |
|
1069 |
#include <string.h> |
1070 |
+#include <libavutil/opt.h> |
1071 |
|
1072 |
-/* some enums used in property declarations */ |
1073 |
+static GQuark avoption_quark; |
1074 |
+static GHashTable *generic_overrides = NULL; |
1075 |
|
1076 |
-#define GST_TYPE_FFMPEG_PASS (gst_ffmpeg_pass_get_type ()) |
1077 |
-static GType |
1078 |
-gst_ffmpeg_pass_get_type (void) |
1079 |
+static void |
1080 |
+make_generic_overrides (void) |
1081 |
{ |
1082 |
- static GType ffmpeg_pass_type = 0; |
1083 |
+ g_assert (!generic_overrides); |
1084 |
+ generic_overrides = g_hash_table_new_full (g_str_hash, g_str_equal, |
1085 |
+ g_free, (GDestroyNotify) gst_structure_free); |
1086 |
|
1087 |
- if (!ffmpeg_pass_type) { |
1088 |
- static const GEnumValue ffmpeg_passes[] = { |
1089 |
- {0, "Constant Bitrate Encoding", "cbr"}, |
1090 |
- {CODEC_FLAG_QSCALE, "Constant Quantizer", "quant"}, |
1091 |
- {CODEC_FLAG_PASS1, "VBR Encoding - Pass 1", "pass1"}, |
1092 |
- {CODEC_FLAG_PASS2, "VBR Encoding - Pass 2", "pass2"}, |
1093 |
- {0, NULL, NULL}, |
1094 |
- }; |
1095 |
+ g_hash_table_insert (generic_overrides, g_strdup ("b"), |
1096 |
+ gst_structure_new_empty ("bitrate")); |
1097 |
+ g_hash_table_insert (generic_overrides, g_strdup ("ab"), |
1098 |
+ gst_structure_new_empty ("bitrate")); |
1099 |
+ g_hash_table_insert (generic_overrides, g_strdup ("g"), |
1100 |
+ gst_structure_new_empty ("gop-size")); |
1101 |
+ g_hash_table_insert (generic_overrides, g_strdup ("bt"), |
1102 |
+ gst_structure_new_empty ("bitrate-tolerance")); |
1103 |
+ g_hash_table_insert (generic_overrides, g_strdup ("bf"), |
1104 |
+ gst_structure_new_empty ("max-bframes")); |
1105 |
|
1106 |
- ffmpeg_pass_type = |
1107 |
- g_enum_register_static ("GstLibAVEncPass", ffmpeg_passes); |
1108 |
- } |
1109 |
- |
1110 |
- return ffmpeg_pass_type; |
1111 |
+ /* Those are exposed through caps */ |
1112 |
+ g_hash_table_insert (generic_overrides, g_strdup ("profile"), |
1113 |
+ gst_structure_new ("profile", "skip", G_TYPE_BOOLEAN, TRUE, NULL)); |
1114 |
+ g_hash_table_insert (generic_overrides, g_strdup ("level"), |
1115 |
+ gst_structure_new ("level", "skip", G_TYPE_BOOLEAN, TRUE, NULL)); |
1116 |
+ g_hash_table_insert (generic_overrides, g_strdup ("color_primaries"), |
1117 |
+ gst_structure_new ("color_primaries", "skip", G_TYPE_BOOLEAN, TRUE, |
1118 |
+ NULL)); |
1119 |
+ g_hash_table_insert (generic_overrides, g_strdup ("color_trc"), |
1120 |
+ gst_structure_new ("color_trc", "skip", G_TYPE_BOOLEAN, TRUE, NULL)); |
1121 |
+ g_hash_table_insert (generic_overrides, g_strdup ("colorspace"), |
1122 |
+ gst_structure_new ("colorspace", "skip", G_TYPE_BOOLEAN, TRUE, NULL)); |
1123 |
+ g_hash_table_insert (generic_overrides, g_strdup ("color_range"), |
1124 |
+ gst_structure_new ("color_range", "skip", G_TYPE_BOOLEAN, TRUE, NULL)); |
1125 |
} |
1126 |
|
1127 |
-#if 0 |
1128 |
-/* some do not support 2-pass */ |
1129 |
-#define GST_TYPE_FFMPEG_LIM_PASS (gst_ffmpeg_lim_pass_get_type ()) |
1130 |
-static GType |
1131 |
-gst_ffmpeg_lim_pass_get_type (void) |
1132 |
+void |
1133 |
+gst_ffmpeg_cfg_init (void) |
1134 |
{ |
1135 |
- static GType ffmpeg_lim_pass_type = 0; |
1136 |
- |
1137 |
- if (!ffmpeg_lim_pass_type) { |
1138 |
- static const GEnumValue ffmpeg_lim_passes[] = { |
1139 |
- {0, "Constant Bitrate Encoding", "cbr"}, |
1140 |
- {CODEC_FLAG_QSCALE, "Constant Quantizer", "quant"}, |
1141 |
- {0, NULL, NULL}, |
1142 |
- }; |
1143 |
- |
1144 |
- ffmpeg_lim_pass_type = |
1145 |
- g_enum_register_static ("GstLibAVEncLimPass", ffmpeg_lim_passes); |
1146 |
- } |
1147 |
- |
1148 |
- return ffmpeg_lim_pass_type; |
1149 |
+ avoption_quark = g_quark_from_static_string ("ffmpeg-cfg-param-spec-data"); |
1150 |
+ make_generic_overrides (); |
1151 |
} |
1152 |
-#endif |
1153 |
|
1154 |
-#define GST_TYPE_FFMPEG_MB_DECISION (gst_ffmpeg_mb_decision_get_type ()) |
1155 |
-static GType |
1156 |
-gst_ffmpeg_mb_decision_get_type (void) |
1157 |
+static gint |
1158 |
+cmp_enum_value (GEnumValue * val1, GEnumValue * val2) |
1159 |
{ |
1160 |
- static GType ffmpeg_mb_decision_type = 0; |
1161 |
- |
1162 |
- if (!ffmpeg_mb_decision_type) { |
1163 |
- static const GEnumValue ffmpeg_mb_decisions[] = { |
1164 |
- {FF_MB_DECISION_SIMPLE, "Use method set by mb-cmp", "simple"}, |
1165 |
- {FF_MB_DECISION_BITS, |
1166 |
- "Chooses the one which needs the fewest bits aka vhq mode", "bits"}, |
1167 |
- {FF_MB_DECISION_RD, "Rate Distortion", "rd"}, |
1168 |
- {0, NULL, NULL}, |
1169 |
- }; |
1170 |
- |
1171 |
- ffmpeg_mb_decision_type = |
1172 |
- g_enum_register_static ("GstLibAVEncMBDecision", ffmpeg_mb_decisions); |
1173 |
- } |
1174 |
- |
1175 |
- return ffmpeg_mb_decision_type; |
1176 |
+ return val1->value - val2->value; |
1177 |
} |
1178 |
|
1179 |
-#define GST_TYPE_FFMPEG_CMP_FUNCTION (gst_ffmpeg_mb_cmp_get_type ()) |
1180 |
static GType |
1181 |
-gst_ffmpeg_mb_cmp_get_type (void) |
1182 |
+register_enum (const AVClass ** obj, const AVOption * top_opt) |
1183 |
{ |
1184 |
- static GType ffmpeg_mb_cmp_type = 0; |
1185 |
+ const AVOption *opt = NULL; |
1186 |
+ GType res = 0; |
1187 |
+ GArray *values = g_array_new (TRUE, TRUE, sizeof (GEnumValue)); |
1188 |
+ gchar *lower_obj_name = g_ascii_strdown ((*obj)->class_name, -1); |
1189 |
+ gchar *enum_name = g_strdup_printf ("%s-%s", lower_obj_name, top_opt->unit); |
1190 |
+ gboolean none_default = TRUE; |
1191 |
|
1192 |
- /* TODO fill out remaining values */ |
1193 |
- if (!ffmpeg_mb_cmp_type) { |
1194 |
- static const GEnumValue ffmpeg_mb_cmps[] = { |
1195 |
- {FF_CMP_SAD, "Sum of Absolute Differences", "sad"}, |
1196 |
- {FF_CMP_SSE, "Sum of Squared Errors", "sse"}, |
1197 |
- {FF_CMP_SATD, "Sum of Absolute Hadamard Transformed Differences", "satd"}, |
1198 |
- {FF_CMP_DCT, "Sum of Absolute DCT Transformed Differences", "dct"}, |
1199 |
- {FF_CMP_PSNR, "Sum of the Squared Quantization Errors", "psnr"}, |
1200 |
- {FF_CMP_BIT, "Sum of the Bits needed for the block", "bit"}, |
1201 |
- {FF_CMP_RD, "Rate Distortion optimal", "rd"}, |
1202 |
- {FF_CMP_ZERO, "ZERO", "zero"}, |
1203 |
- {FF_CMP_VSAD, "VSAD", "vsad"}, |
1204 |
- {FF_CMP_VSSE, "VSSE", "vsse"}, |
1205 |
-#if 0 |
1206 |
-/* economize a bit for now */ |
1207 |
- {FF_CMP_NSSE, "NSSE", "nsse"}, |
1208 |
- {FF_CMP_W53, "W53", "w53"}, |
1209 |
- {FF_CMP_W97, "W97", "w97"}, |
1210 |
-#endif |
1211 |
- {0, NULL, NULL}, |
1212 |
- }; |
1213 |
+ g_strcanon (enum_name, G_CSET_a_2_z G_CSET_DIGITS, '-'); |
1214 |
|
1215 |
- ffmpeg_mb_cmp_type = |
1216 |
- g_enum_register_static ("GstLibAVCMPFunction", ffmpeg_mb_cmps); |
1217 |
- } |
1218 |
+ if ((res = g_type_from_name (enum_name))) |
1219 |
+ goto done; |
1220 |
|
1221 |
- return ffmpeg_mb_cmp_type; |
1222 |
-} |
1223 |
+ while ((opt = av_opt_next (obj, opt))) { |
1224 |
+ if (opt->type == AV_OPT_TYPE_CONST && !g_strcmp0 (top_opt->unit, opt->unit)) { |
1225 |
+ GEnumValue val; |
1226 |
|
1227 |
-#define GST_TYPE_FFMPEG_DCT_ALGO (gst_ffmpeg_dct_algo_get_type ()) |
1228 |
-static GType |
1229 |
-gst_ffmpeg_dct_algo_get_type (void) |
1230 |
-{ |
1231 |
- static GType ffmpeg_dct_algo_type = 0; |
1232 |
+ val.value = opt->default_val.i64; |
1233 |
+ val.value_name = g_strdup (opt->help ? opt->help : opt->name); |
1234 |
+ val.value_nick = g_strdup (opt->name); |
1235 |
|
1236 |
- if (!ffmpeg_dct_algo_type) { |
1237 |
- static const GEnumValue ffmpeg_dct_algos[] = { |
1238 |
- {FF_DCT_AUTO, "Automatically select a good one", "auto"}, |
1239 |
- {FF_DCT_FASTINT, "Fast Integer", "fastint"}, |
1240 |
- {FF_DCT_INT, "Accurate Integer", "int"}, |
1241 |
- {FF_DCT_MMX, "MMX", "mmx"}, |
1242 |
- {FF_DCT_ALTIVEC, "ALTIVEC", "altivec"}, |
1243 |
- {FF_DCT_FAAN, "FAAN", "faan"}, |
1244 |
- {0, NULL, NULL}, |
1245 |
- }; |
1246 |
+ if (opt->default_val.i64 == top_opt->default_val.i64) |
1247 |
+ none_default = FALSE; |
1248 |
|
1249 |
- ffmpeg_dct_algo_type = |
1250 |
- g_enum_register_static ("GstLibAVDCTAlgo", ffmpeg_dct_algos); |
1251 |
+ g_array_append_val (values, val); |
1252 |
+ } |
1253 |
} |
1254 |
|
1255 |
- return ffmpeg_dct_algo_type; |
1256 |
-} |
1257 |
+ if (values->len) { |
1258 |
+ guint i = 0; |
1259 |
+ gint cur_val; |
1260 |
+ gboolean cur_val_set = FALSE; |
1261 |
|
1262 |
-#define GST_TYPE_FFMPEG_IDCT_ALGO (gst_ffmpeg_idct_algo_get_type ()) |
1263 |
-static GType |
1264 |
-gst_ffmpeg_idct_algo_get_type (void) |
1265 |
-{ |
1266 |
- static GType ffmpeg_idct_algo_type = 0; |
1267 |
+ /* Sometimes ffmpeg sets a default value but no named constants with |
1268 |
+ * this value, we assume this means "unspecified" and add our own |
1269 |
+ */ |
1270 |
+ if (none_default) { |
1271 |
+ GEnumValue val; |
1272 |
|
1273 |
- if (!ffmpeg_idct_algo_type) { |
1274 |
- static const GEnumValue ffmpeg_idct_algos[] = { |
1275 |
- {FF_IDCT_AUTO, "Automatically select a good one", "auto"}, |
1276 |
- {FF_IDCT_INT, "JPEG reference Integer", "int"}, |
1277 |
- {FF_IDCT_SIMPLE, "Simple", "simple"}, |
1278 |
- {FF_IDCT_SIMPLEMMX, "Simple MMX", "simplemmx"}, |
1279 |
- {FF_IDCT_ARM, "ARM", "arm"}, |
1280 |
- {FF_IDCT_ALTIVEC, "Altivec", "altivec"}, |
1281 |
- {FF_IDCT_SIMPLEARM, "Simple ARM", "simplearm"}, |
1282 |
- {FF_IDCT_XVID, "XVID", "xvid"}, |
1283 |
- {FF_IDCT_SIMPLEARMV5TE, "Simple ARMV5TE", "simplearmv5te"}, |
1284 |
- {FF_IDCT_SIMPLEARMV6, "Simple ARMV6", "simplearmv6"}, |
1285 |
- {FF_IDCT_FAAN, "FAAN", "faan"}, |
1286 |
- {FF_IDCT_SIMPLENEON, "Simple NEON", "simpleneon"}, |
1287 |
- {0, NULL, NULL}, |
1288 |
- }; |
1289 |
+ val.value = top_opt->default_val.i64; |
1290 |
+ val.value_name = g_strdup ("Unspecified"); |
1291 |
+ val.value_nick = g_strdup ("unknown"); |
1292 |
+ g_array_append_val (values, val); |
1293 |
+ } |
1294 |
|
1295 |
- ffmpeg_idct_algo_type = |
1296 |
- g_enum_register_static ("GstLibAVIDCTAlgo", ffmpeg_idct_algos); |
1297 |
+ g_array_sort (values, (GCompareFunc) cmp_enum_value); |
1298 |
+ |
1299 |
+ /* Dedup, easy once sorted |
1300 |
+ * We do this because ffmpeg can expose multiple names for the |
1301 |
+ * same constant, the way we expose enums makes this too confusing. |
1302 |
+ */ |
1303 |
+ while (i < values->len) { |
1304 |
+ if (cur_val_set) { |
1305 |
+ if (g_array_index (values, GEnumValue, i).value == cur_val) { |
1306 |
+ g_array_remove_index (values, i); |
1307 |
+ } else { |
1308 |
+ cur_val = g_array_index (values, GEnumValue, i).value; |
1309 |
+ i++; |
1310 |
+ } |
1311 |
+ } else { |
1312 |
+ cur_val = g_array_index (values, GEnumValue, i).value; |
1313 |
+ cur_val_set = TRUE; |
1314 |
+ i++; |
1315 |
+ } |
1316 |
+ } |
1317 |
+ |
1318 |
+ res = |
1319 |
+ g_enum_register_static (enum_name, &g_array_index (values, GEnumValue, |
1320 |
+ 0)); |
1321 |
} |
1322 |
|
1323 |
- return ffmpeg_idct_algo_type; |
1324 |
+done: |
1325 |
+ g_free (lower_obj_name); |
1326 |
+ g_free (enum_name); |
1327 |
+ return res; |
1328 |
} |
1329 |
|
1330 |
-#define GST_TYPE_FFMPEG_QUANT_TYPE (gst_ffmpeg_quant_type_get_type ()) |
1331 |
-static GType |
1332 |
-gst_ffmpeg_quant_type_get_type (void) |
1333 |
+static gint |
1334 |
+cmp_flags_value (GEnumValue * val1, GEnumValue * val2) |
1335 |
{ |
1336 |
- static GType ffmpeg_quant_type_type = 0; |
1337 |
- |
1338 |
- if (!ffmpeg_quant_type_type) { |
1339 |
- static const GEnumValue ffmpeg_quant_types[] = { |
1340 |
- {0, "H263 quantization", "h263"}, |
1341 |
- {1, "MPEG quantization", "mpeg"}, |
1342 |
- {0, NULL, NULL}, |
1343 |
- }; |
1344 |
- |
1345 |
- ffmpeg_quant_type_type = |
1346 |
- g_enum_register_static ("GstLibAVEncQuantTypes", ffmpeg_quant_types); |
1347 |
- } |
1348 |
- |
1349 |
- return ffmpeg_quant_type_type; |
1350 |
+ return val1->value - val2->value; |
1351 |
} |
1352 |
|
1353 |
-#define GST_TYPE_FFMPEG_PRE_ME (gst_ffmpeg_pre_me_get_type ()) |
1354 |
static GType |
1355 |
-gst_ffmpeg_pre_me_get_type (void) |
1356 |
+register_flags (const AVClass ** obj, const AVOption * top_opt) |
1357 |
{ |
1358 |
- static GType ffmpeg_pre_me_type = 0; |
1359 |
+ const AVOption *opt = NULL; |
1360 |
+ GType res = 0; |
1361 |
+ GArray *values = g_array_new (TRUE, TRUE, sizeof (GEnumValue)); |
1362 |
+ gchar *lower_obj_name = g_ascii_strdown ((*obj)->class_name, -1); |
1363 |
+ gchar *flags_name = g_strdup_printf ("%s-%s", lower_obj_name, top_opt->unit); |
1364 |
|
1365 |
- if (!ffmpeg_pre_me_type) { |
1366 |
- static const GEnumValue ffmpeg_pre_mes[] = { |
1367 |
- {0, "Disabled", "off"}, |
1368 |
- {1, "Only after I-frames", "key"}, |
1369 |
- {2, "Always", "all"}, |
1370 |
- {0, NULL, NULL} |
1371 |
- }; |
1372 |
+ g_strcanon (flags_name, G_CSET_a_2_z G_CSET_DIGITS, '-'); |
1373 |
|
1374 |
- ffmpeg_pre_me_type = |
1375 |
- g_enum_register_static ("GstLibAVEncPreME", ffmpeg_pre_mes); |
1376 |
- } |
1377 |
+ if ((res = g_type_from_name (flags_name))) |
1378 |
+ goto done; |
1379 |
|
1380 |
- return ffmpeg_pre_me_type; |
1381 |
-} |
1382 |
+ while ((opt = av_opt_next (obj, opt))) { |
1383 |
+ if (opt->type == AV_OPT_TYPE_CONST && !g_strcmp0 (top_opt->unit, opt->unit)) { |
1384 |
+ GFlagsValue val; |
1385 |
|
1386 |
-#define GST_TYPE_FFMPEG_PRED_METHOD (gst_ffmpeg_pred_method_get_type ()) |
1387 |
-static GType |
1388 |
-gst_ffmpeg_pred_method_get_type (void) |
1389 |
-{ |
1390 |
- static GType ffmpeg_pred_method = 0; |
1391 |
+ /* We expose pass manually, hardcoding this isn't very nice, but |
1392 |
+ * I don't expect we want to do that sort of things often enough |
1393 |
+ * to warrant a general mechanism |
1394 |
+ */ |
1395 |
+ if (!g_strcmp0 (top_opt->name, "flags")) { |
1396 |
+ if (opt->default_val.i64 == AV_CODEC_FLAG_QSCALE || |
1397 |
+ opt->default_val.i64 == AV_CODEC_FLAG_PASS1 || |
1398 |
+ opt->default_val.i64 == AV_CODEC_FLAG_PASS2) { |
1399 |
+ continue; |
1400 |
+ } |
1401 |
+ } |
1402 |
|
1403 |
- if (!ffmpeg_pred_method) { |
1404 |
- static const GEnumValue ffmpeg_pred_methods[] = { |
1405 |
- {FF_PRED_LEFT, "Left", "left"}, |
1406 |
- {FF_PRED_PLANE, "Plane", "plane"}, |
1407 |
- {FF_PRED_MEDIAN, "Median", "median"}, |
1408 |
- {0, NULL, NULL} |
1409 |
- }; |
1410 |
+ val.value = opt->default_val.i64; |
1411 |
+ val.value_name = g_strdup (opt->help ? opt->help : opt->name); |
1412 |
+ val.value_nick = g_strdup (opt->name); |
1413 |
|
1414 |
- ffmpeg_pred_method = |
1415 |
- g_enum_register_static ("GstLibAVEncPredMethod", ffmpeg_pred_methods); |
1416 |
+ g_array_append_val (values, val); |
1417 |
+ } |
1418 |
} |
1419 |
|
1420 |
- return ffmpeg_pred_method; |
1421 |
-} |
1422 |
+ if (values->len) { |
1423 |
+ g_array_sort (values, (GCompareFunc) cmp_flags_value); |
1424 |
|
1425 |
-#define GST_TYPE_FFMPEG_FLAGS (gst_ffmpeg_flags_get_type()) |
1426 |
-static GType |
1427 |
-gst_ffmpeg_flags_get_type (void) |
1428 |
-{ |
1429 |
- static GType ffmpeg_flags_type = 0; |
1430 |
- |
1431 |
- /* FIXME: This needs some serious resyncing with avcodec.h */ |
1432 |
- if (!ffmpeg_flags_type) { |
1433 |
- static const GFlagsValue ffmpeg_flags[] = { |
1434 |
- {CODEC_FLAG_QSCALE, "Use fixed qscale", "qscale"}, |
1435 |
- {CODEC_FLAG_4MV, "Allow 4 MV per MB", "4mv"}, |
1436 |
- {CODEC_FLAG_QPEL, "Quartel Pel Motion Compensation", "qpel"}, |
1437 |
- {CODEC_FLAG_GMC, "GMC", "gmc"}, |
1438 |
- {CODEC_FLAG_MV0, "Always try a MB with MV (0,0)", "mv0"}, |
1439 |
- {CODEC_FLAG_LOOP_FILTER, "Loop filter", "loop-filter"}, |
1440 |
- {CODEC_FLAG_GRAY, "Only decode/encode grayscale", "gray"}, |
1441 |
- {CODEC_FLAG_NORMALIZE_AQP, |
1442 |
- "Normalize Adaptive Quantization (masking, etc)", "aqp"}, |
1443 |
- {CODEC_FLAG_GLOBAL_HEADER, |
1444 |
- "Global headers in extradata instead of every keyframe", |
1445 |
- "global-headers"}, |
1446 |
- {CODEC_FLAG_AC_PRED, "H263 Advanced Intra Coding / MPEG4 AC prediction", |
1447 |
- "aic"}, |
1448 |
- {CODEC_FLAG_CLOSED_GOP, "Closed GOP", "closedgop"}, |
1449 |
- {0, NULL, NULL}, |
1450 |
- }; |
1451 |
- |
1452 |
- ffmpeg_flags_type = g_flags_register_static ("GstLibAVFlags", ffmpeg_flags); |
1453 |
+ res = |
1454 |
+ g_flags_register_static (flags_name, &g_array_index (values, |
1455 |
+ GFlagsValue, 0)); |
1456 |
} |
1457 |
|
1458 |
- return ffmpeg_flags_type; |
1459 |
+done: |
1460 |
+ g_free (lower_obj_name); |
1461 |
+ g_free (flags_name); |
1462 |
+ return res; |
1463 |
} |
1464 |
|
1465 |
-/* provides additional info to attach to a property */ |
1466 |
- |
1467 |
-typedef struct _GParamSpecData GParamSpecData; |
1468 |
- |
1469 |
-struct _GParamSpecData |
1470 |
+static guint |
1471 |
+install_opts (GObjectClass * gobject_class, const AVClass ** obj, guint prop_id, |
1472 |
+ gint flags, const gchar * extra_help, GHashTable * overrides) |
1473 |
{ |
1474 |
- /* offset of member in the element struct that stores the property */ |
1475 |
- guint offset; |
1476 |
+ const AVOption *opt = NULL; |
1477 |
|
1478 |
- /* size of the above member */ |
1479 |
- guint size; |
1480 |
+ while ((opt = av_opt_next (obj, opt))) { |
1481 |
+ GParamSpec *pspec = NULL; |
1482 |
+ AVOptionRanges *r; |
1483 |
+ gdouble min = G_MINDOUBLE; |
1484 |
+ gdouble max = G_MAXDOUBLE; |
1485 |
+ gchar *help; |
1486 |
+ const gchar *name; |
1487 |
|
1488 |
- /* if TRUE, try to get the default from lavc and ignore the paramspec default */ |
1489 |
- gboolean lavc_default; |
1490 |
+ if (overrides && g_hash_table_contains (overrides, opt->name)) { |
1491 |
+ gboolean skip; |
1492 |
+ const GstStructure *s = |
1493 |
+ (GstStructure *) g_hash_table_lookup (overrides, opt->name); |
1494 |
|
1495 |
- /* these lists are arrays terminated by AV_CODEC_ID_NONE entry: |
1496 |
- * property applies to a codec if it's not in the exclude_list |
1497 |
- * and in exclude_list (or the latter is NULL) */ |
1498 |
- gint *include_list; |
1499 |
- gint *exclude_list; |
1500 |
-}; |
1501 |
+ name = gst_structure_get_name (s); |
1502 |
+ if (gst_structure_get_boolean (s, "skip", &skip) && skip) { |
1503 |
+ continue; |
1504 |
+ } |
1505 |
+ } else { |
1506 |
+ name = opt->name; |
1507 |
+ } |
1508 |
|
1509 |
-/* properties whose member offset is higher than the config base |
1510 |
- * can be copied directly at context configuration time; |
1511 |
- * and can also retrieve a default value from lavc */ |
1512 |
-#define CONTEXT_CONFIG_OFFSET G_STRUCT_OFFSET (GstFFMpegVidEnc, config) |
1513 |
+ if ((opt->flags & flags) != flags) |
1514 |
+ continue; |
1515 |
|
1516 |
-/* additional info is named pointer specified by the quark */ |
1517 |
-static GQuark quark; |
1518 |
+ if (g_object_class_find_property (gobject_class, name)) |
1519 |
+ continue; |
1520 |
|
1521 |
-/* central configuration store: |
1522 |
- * list of GParamSpec's with GParamSpecData attached as named pointer */ |
1523 |
-static GList *property_list; |
1524 |
+ if (av_opt_query_ranges (&r, obj, opt->name, AV_OPT_SEARCH_FAKE_OBJ) >= 0 |
1525 |
+ && r->nb_ranges == 1) { |
1526 |
+ min = r->range[0]->value_min; |
1527 |
+ max = r->range[0]->value_max; |
1528 |
+ } |
1529 |
|
1530 |
-/* add the GParamSpec pspec to store with GParamSpecData |
1531 |
- * constructed from struct_type, member, default and include and exclude */ |
1532 |
-#define gst_ffmpeg_add_pspec_full(pspec, store, struct_type, member, \ |
1533 |
- default, include, exclude) \ |
1534 |
-G_STMT_START { \ |
1535 |
- GParamSpecData *_qdata = g_new0 (GParamSpecData, 1); \ |
1536 |
- GstFFMpegVidEnc _enc; \ |
1537 |
- _qdata->offset = G_STRUCT_OFFSET (struct_type, member); \ |
1538 |
- _qdata->size = sizeof (_enc.member); \ |
1539 |
- _qdata->lavc_default = default; \ |
1540 |
- _qdata->include_list = include; \ |
1541 |
- _qdata->exclude_list = exclude; \ |
1542 |
- g_param_spec_set_qdata_full (pspec, quark, _qdata, g_free); \ |
1543 |
- store = g_list_append (store, pspec); \ |
1544 |
-} G_STMT_END |
1545 |
+ help = g_strdup_printf ("%s%s", opt->help, extra_help); |
1546 |
|
1547 |
-#define gst_ffmpeg_add_pspec(pspec, member, default, include, exclude) \ |
1548 |
- gst_ffmpeg_add_pspec_full (pspec, property_list, GstFFMpegVidEnc, member, \ |
1549 |
- default, include, exclude) |
1550 |
+ switch (opt->type) { |
1551 |
+ case AV_OPT_TYPE_INT: |
1552 |
+ if (opt->unit) { |
1553 |
+ GType enum_gtype; |
1554 |
+ enum_gtype = register_enum (obj, opt); |
1555 |
|
1556 |
-/* ==== BEGIN CONFIGURATION SECTION ==== */ |
1557 |
+ if (enum_gtype) { |
1558 |
+ pspec = g_param_spec_enum (name, name, help, |
1559 |
+ enum_gtype, opt->default_val.i64, G_PARAM_READWRITE); |
1560 |
+ g_object_class_install_property (gobject_class, prop_id++, pspec); |
1561 |
+ } else { /* Some options have a unit but no named constants associated */ |
1562 |
+ pspec = g_param_spec_int (name, name, help, |
1563 |
+ (gint) min, (gint) max, opt->default_val.i64, |
1564 |
+ G_PARAM_READWRITE); |
1565 |
+ g_object_class_install_property (gobject_class, prop_id++, pspec); |
1566 |
+ } |
1567 |
+ } else { |
1568 |
+ pspec = g_param_spec_int (name, name, help, |
1569 |
+ (gint) min, (gint) max, opt->default_val.i64, G_PARAM_READWRITE); |
1570 |
+ g_object_class_install_property (gobject_class, prop_id++, pspec); |
1571 |
+ } |
1572 |
+ break; |
1573 |
+ case AV_OPT_TYPE_FLAGS: |
1574 |
+ if (opt->unit) { |
1575 |
+ GType flags_gtype; |
1576 |
+ flags_gtype = register_flags (obj, opt); |
1577 |
|
1578 |
-/* some typical include and exclude lists; modify and/or add where needed */ |
1579 |
+ if (flags_gtype) { |
1580 |
+ pspec = g_param_spec_flags (name, name, help, |
1581 |
+ flags_gtype, opt->default_val.i64, G_PARAM_READWRITE); |
1582 |
+ g_object_class_install_property (gobject_class, prop_id++, pspec); |
1583 |
+ } |
1584 |
+ } |
1585 |
+ break; |
1586 |
+ case AV_OPT_TYPE_DURATION: /* Fall through */ |
1587 |
+ case AV_OPT_TYPE_INT64: |
1588 |
+ /* ffmpeg expresses all ranges with doubles, this is sad */ |
1589 |
+ pspec = g_param_spec_int64 (name, name, help, |
1590 |
+ (gint64) (min == (gdouble) INT64_MIN ? INT64_MIN : min), |
1591 |
+ (gint64) (max == (gdouble) INT64_MAX ? INT64_MAX : max), |
1592 |
+ opt->default_val.i64, G_PARAM_READWRITE); |
1593 |
+ g_object_class_install_property (gobject_class, prop_id++, pspec); |
1594 |
+ break; |
1595 |
+ case AV_OPT_TYPE_DOUBLE: |
1596 |
+ pspec = g_param_spec_double (name, name, help, |
1597 |
+ min, max, opt->default_val.dbl, G_PARAM_READWRITE); |
1598 |
+ g_object_class_install_property (gobject_class, prop_id++, pspec); |
1599 |
+ break; |
1600 |
+ case AV_OPT_TYPE_FLOAT: |
1601 |
+ pspec = g_param_spec_float (name, name, help, |
1602 |
+ (gfloat) min, (gfloat) max, (gfloat) opt->default_val.dbl, |
1603 |
+ G_PARAM_READWRITE); |
1604 |
+ g_object_class_install_property (gobject_class, prop_id++, pspec); |
1605 |
+ break; |
1606 |
+ case AV_OPT_TYPE_STRING: |
1607 |
+ pspec = g_param_spec_string (name, name, help, |
1608 |
+ opt->default_val.str, G_PARAM_READWRITE); |
1609 |
+ g_object_class_install_property (gobject_class, prop_id++, pspec); |
1610 |
+ break; |
1611 |
+ case AV_OPT_TYPE_UINT64: |
1612 |
+ /* ffmpeg expresses all ranges with doubles, this is appalling */ |
1613 |
+ pspec = g_param_spec_uint64 (name, name, help, |
1614 |
+ (gint64) (min == (gdouble) 0 ? 0 : min), |
1615 |
+ (gint64) (max == (gdouble) UINT64_MAX ? UINT64_MAX : min), |
1616 |
+ opt->default_val.i64, G_PARAM_READWRITE); |
1617 |
+ g_object_class_install_property (gobject_class, prop_id++, pspec); |
1618 |
+ break; |
1619 |
+ case AV_OPT_TYPE_BOOL: |
1620 |
+ pspec = g_param_spec_boolean (name, name, help, |
1621 |
+ opt->default_val.i64 ? TRUE : FALSE, G_PARAM_READWRITE); |
1622 |
+ g_object_class_install_property (gobject_class, prop_id++, pspec); |
1623 |
+ break; |
1624 |
+ /* TODO: didn't find options for the video encoders with |
1625 |
+ * the following type, add support if needed */ |
1626 |
+ case AV_OPT_TYPE_CHANNEL_LAYOUT: |
1627 |
+ case AV_OPT_TYPE_COLOR: |
1628 |
+ case AV_OPT_TYPE_VIDEO_RATE: |
1629 |
+ case AV_OPT_TYPE_SAMPLE_FMT: |
1630 |
+ case AV_OPT_TYPE_PIXEL_FMT: |
1631 |
+ case AV_OPT_TYPE_IMAGE_SIZE: |
1632 |
+ case AV_OPT_TYPE_DICT: |
1633 |
+ case AV_OPT_TYPE_BINARY: |
1634 |
+ case AV_OPT_TYPE_RATIONAL: |
1635 |
+ default: |
1636 |
+ break; |
1637 |
+ } |
1638 |
|
1639 |
-static gint mpeg[] = { |
1640 |
- AV_CODEC_ID_MPEG4, |
1641 |
- AV_CODEC_ID_MSMPEG4V1, |
1642 |
- AV_CODEC_ID_MSMPEG4V2, |
1643 |
- AV_CODEC_ID_MSMPEG4V3, |
1644 |
- AV_CODEC_ID_MPEG1VIDEO, |
1645 |
- AV_CODEC_ID_MPEG2VIDEO, |
1646 |
- AV_CODEC_ID_H263P, |
1647 |
- AV_CODEC_ID_FLV1, |
1648 |
- AV_CODEC_ID_H263, |
1649 |
- AV_CODEC_ID_NONE |
1650 |
-}; |
1651 |
+ g_free (help); |
1652 |
|
1653 |
-static gint huffyuv[] = { |
1654 |
- AV_CODEC_ID_HUFFYUV, |
1655 |
- AV_CODEC_ID_FFVHUFF, |
1656 |
- AV_CODEC_ID_NONE |
1657 |
-}; |
1658 |
- |
1659 |
-/* Properties should be added here for registration into the config store. |
1660 |
- * Note that some may occur more than once, with different include/exclude lists, |
1661 |
- * as some may require different defaults for different codecs, |
1662 |
- * or some may have slightly varying enum-types with more or less options. |
1663 |
- * The enum-types themselves should be declared above. */ |
1664 |
-void |
1665 |
-gst_ffmpeg_cfg_init (void) |
1666 |
-{ |
1667 |
- GParamSpec *pspec; |
1668 |
- |
1669 |
- /* initialize global config vars */ |
1670 |
- quark = g_quark_from_static_string ("ffmpeg-cfg-param-spec-data"); |
1671 |
- property_list = NULL; |
1672 |
- |
1673 |
- /* list properties here */ |
1674 |
- pspec = g_param_spec_enum ("pass", "Encoding pass/type", |
1675 |
- "Encoding pass/type", GST_TYPE_FFMPEG_PASS, 0, |
1676 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1677 |
- gst_ffmpeg_add_pspec (pspec, pass, FALSE, mpeg, NULL); |
1678 |
- |
1679 |
- pspec = g_param_spec_float ("quantizer", "Constant Quantizer", |
1680 |
- "Constant Quantizer", 0, 30, 0.01f, |
1681 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1682 |
- gst_ffmpeg_add_pspec (pspec, quantizer, FALSE, mpeg, NULL); |
1683 |
- |
1684 |
- pspec = g_param_spec_string ("multipass-cache-file", "Multipass Cache File", |
1685 |
- "Filename for multipass cache file", "stats.log", |
1686 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1687 |
- gst_ffmpeg_add_pspec (pspec, filename, FALSE, mpeg, NULL); |
1688 |
- |
1689 |
- pspec = g_param_spec_int ("bitrate-tolerance", "Bitrate Tolerance", |
1690 |
- "Number of bits the bitstream is allowed to diverge from the reference", |
1691 |
- 0, 100000000, 8000000, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1692 |
- gst_ffmpeg_add_pspec (pspec, config.bit_rate_tolerance, FALSE, mpeg, NULL); |
1693 |
- |
1694 |
- pspec = g_param_spec_enum ("mb-decision", "Macroblock Decision", |
1695 |
- "Macroblok Decision Mode", |
1696 |
- GST_TYPE_FFMPEG_MB_DECISION, FF_CMP_SAD, |
1697 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1698 |
- gst_ffmpeg_add_pspec (pspec, config.mb_decision, FALSE, mpeg, NULL); |
1699 |
- |
1700 |
- pspec = g_param_spec_enum ("mb-cmp", "Macroblock Compare Function", |
1701 |
- "Macroblok Compare Function", |
1702 |
- GST_TYPE_FFMPEG_CMP_FUNCTION, FF_CMP_SAD, |
1703 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1704 |
- gst_ffmpeg_add_pspec (pspec, config.mb_cmp, FALSE, mpeg, NULL); |
1705 |
- |
1706 |
- pspec = |
1707 |
- g_param_spec_enum ("me-pre-cmp", |
1708 |
- "Motion Estimation Pre Pass Compare Function", |
1709 |
- "Motion Estimation Pre Pass Compare Function", |
1710 |
- GST_TYPE_FFMPEG_CMP_FUNCTION, FF_CMP_SAD, |
1711 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1712 |
- gst_ffmpeg_add_pspec (pspec, config.me_pre_cmp, FALSE, mpeg, NULL); |
1713 |
- |
1714 |
- pspec = g_param_spec_enum ("me-cmp", "Motion Estimation Compare Function", |
1715 |
- "Motion Estimation Compare Function", |
1716 |
- GST_TYPE_FFMPEG_CMP_FUNCTION, FF_CMP_SAD, |
1717 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1718 |
- gst_ffmpeg_add_pspec (pspec, config.me_cmp, FALSE, mpeg, NULL); |
1719 |
- |
1720 |
- pspec = g_param_spec_enum ("me-sub-cmp", |
1721 |
- "Subpixel Motion Estimation Compare Function", |
1722 |
- "Subpixel Motion Estimation Compare Function", |
1723 |
- GST_TYPE_FFMPEG_CMP_FUNCTION, FF_CMP_SAD, |
1724 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1725 |
- gst_ffmpeg_add_pspec (pspec, config.me_sub_cmp, FALSE, mpeg, NULL); |
1726 |
- |
1727 |
- pspec = g_param_spec_enum ("ildct-cmp", "Interlaced DCT Compare Function", |
1728 |
- "Interlaced DCT Compare Function", |
1729 |
- GST_TYPE_FFMPEG_CMP_FUNCTION, FF_CMP_VSAD, |
1730 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1731 |
- gst_ffmpeg_add_pspec (pspec, config.ildct_cmp, FALSE, mpeg, NULL); |
1732 |
- |
1733 |
- pspec = g_param_spec_enum ("dct-algo", "DCT Algorithm", |
1734 |
- "DCT Algorithm", |
1735 |
- GST_TYPE_FFMPEG_DCT_ALGO, FF_DCT_AUTO, |
1736 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1737 |
- gst_ffmpeg_add_pspec (pspec, config.dct_algo, FALSE, mpeg, NULL); |
1738 |
- |
1739 |
- pspec = g_param_spec_enum ("idct-algo", "IDCT Algorithm", |
1740 |
- "IDCT Algorithm", |
1741 |
- GST_TYPE_FFMPEG_IDCT_ALGO, FF_IDCT_AUTO, |
1742 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1743 |
- gst_ffmpeg_add_pspec (pspec, config.idct_algo, FALSE, mpeg, NULL); |
1744 |
- |
1745 |
- pspec = g_param_spec_enum ("quant-type", "Quantizer Type", |
1746 |
- "Quantizer Type", GST_TYPE_FFMPEG_QUANT_TYPE, 0, |
1747 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1748 |
- gst_ffmpeg_add_pspec (pspec, config.mpeg_quant, FALSE, mpeg, NULL); |
1749 |
- |
1750 |
- pspec = g_param_spec_int ("qmin", "Minimum Quantizer", |
1751 |
- "Minimum Quantizer", 1, 31, 2, |
1752 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1753 |
- gst_ffmpeg_add_pspec (pspec, config.qmin, FALSE, mpeg, NULL); |
1754 |
- |
1755 |
- pspec = g_param_spec_int ("qmax", "Maximum Quantizer", |
1756 |
- "Maximum Quantizer", 1, 31, 31, |
1757 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1758 |
- gst_ffmpeg_add_pspec (pspec, config.qmax, FALSE, mpeg, NULL); |
1759 |
- |
1760 |
- pspec = g_param_spec_int ("max-qdiff", "Maximum Quantizer Difference", |
1761 |
- "Maximum Quantizer Difference between frames", |
1762 |
- 1, 31, 3, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1763 |
- gst_ffmpeg_add_pspec (pspec, config.max_qdiff, FALSE, mpeg, NULL); |
1764 |
- |
1765 |
- pspec = g_param_spec_int ("lmin", "Minimum Lagrange Multiplier", |
1766 |
- "Minimum Lagrange Multiplier", 1, 31, 2, |
1767 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1768 |
- gst_ffmpeg_add_pspec (pspec, lmin, FALSE, mpeg, NULL); |
1769 |
- |
1770 |
- pspec = g_param_spec_int ("lmax", "Maximum Lagrange Multiplier", |
1771 |
- "Maximum Lagrange Multiplier", 1, 31, 31, |
1772 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1773 |
- gst_ffmpeg_add_pspec (pspec, lmax, FALSE, mpeg, NULL); |
1774 |
- |
1775 |
- pspec = g_param_spec_float ("qcompress", "Quantizer Change", |
1776 |
- "Quantizer Change between easy and hard scenes", |
1777 |
- 0, 1.0f, 0.5f, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1778 |
- gst_ffmpeg_add_pspec (pspec, config.qcompress, FALSE, mpeg, NULL); |
1779 |
- |
1780 |
- pspec = g_param_spec_float ("qblur", "Quantizer Smoothing", |
1781 |
- "Quantizer Smoothing over time", 0, 1.0f, 0.5f, |
1782 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1783 |
- gst_ffmpeg_add_pspec (pspec, config.qblur, FALSE, mpeg, NULL); |
1784 |
- |
1785 |
- pspec = g_param_spec_float ("rc-qsquish", "Ratecontrol Limiting Method", |
1786 |
- "0 means limit by clipping, otherwise use nice continuous function", |
1787 |
- 0, 99.0f, 1.0f, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1788 |
- gst_ffmpeg_add_pspec (pspec, config.rc_qsquish, FALSE, mpeg, NULL); |
1789 |
- |
1790 |
- pspec = g_param_spec_float ("rc-qmod-amp", "Ratecontrol Mod", |
1791 |
- "Ratecontrol Mod", 0, 99.0f, 0, |
1792 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1793 |
- gst_ffmpeg_add_pspec (pspec, config.rc_qmod_amp, FALSE, mpeg, NULL); |
1794 |
- |
1795 |
- pspec = g_param_spec_int ("rc-qmod-freq", "Ratecontrol Freq", |
1796 |
- "Ratecontrol Freq", 0, 0, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1797 |
- gst_ffmpeg_add_pspec (pspec, config.rc_qmod_freq, FALSE, mpeg, NULL); |
1798 |
- |
1799 |
- pspec = g_param_spec_int ("rc-buffer-size", "Ratecontrol Buffer Size", |
1800 |
- "Decoder bitstream buffer size", 0, G_MAXINT, 0, |
1801 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1802 |
- gst_ffmpeg_add_pspec (pspec, config.rc_buffer_size, FALSE, mpeg, NULL); |
1803 |
- |
1804 |
- pspec = |
1805 |
- g_param_spec_float ("rc-buffer-aggressivity", |
1806 |
- "Ratecontrol Buffer Aggressivity", "Ratecontrol Buffer Aggressivity", 0, |
1807 |
- 99.0f, 1.0f, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1808 |
- gst_ffmpeg_add_pspec (pspec, config.rc_buffer_aggressivity, FALSE, mpeg, |
1809 |
- NULL); |
1810 |
- |
1811 |
-#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT (57, 3, 0) |
1812 |
- pspec = g_param_spec_int ("rc-max-rate", "Ratecontrol Maximum Bitrate", |
1813 |
- "Ratecontrol Maximum Bitrate", 0, G_MAXINT, 0, |
1814 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1815 |
-#else |
1816 |
- pspec = g_param_spec_int64 ("rc-max-rate", "Ratecontrol Maximum Bitrate", |
1817 |
- "Ratecontrol Maximum Bitrate", 0, G_MAXINT64, 0, |
1818 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1819 |
-#endif |
1820 |
- gst_ffmpeg_add_pspec (pspec, config.rc_max_rate, FALSE, mpeg, NULL); |
1821 |
- |
1822 |
- pspec = g_param_spec_int64 ("rc-min-rate", "Ratecontrol Minimum Bitrate", |
1823 |
- "Ratecontrol Minimum Bitrate", 0, G_MAXINT64, 0, |
1824 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1825 |
- gst_ffmpeg_add_pspec (pspec, config.rc_min_rate, FALSE, mpeg, NULL); |
1826 |
- |
1827 |
- pspec = |
1828 |
- g_param_spec_float ("rc-initial-cplx", |
1829 |
- "Initial Complexity for Pass 1 Ratecontrol", |
1830 |
- "Initial Complexity for Pass 1 Ratecontrol", 0, 9999999.0f, 0, |
1831 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1832 |
- gst_ffmpeg_add_pspec (pspec, config.rc_initial_cplx, FALSE, mpeg, NULL); |
1833 |
- |
1834 |
- pspec = g_param_spec_string ("rc-eq", "Ratecontrol Equation", |
1835 |
- "Ratecontrol Equation", "tex^qComp", |
1836 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1837 |
- gst_ffmpeg_add_pspec (pspec, config.rc_eq, FALSE, mpeg, NULL); |
1838 |
- |
1839 |
- pspec = g_param_spec_float ("b-quant-factor", "B-Quantizer Factor", |
1840 |
- "Factor in B-Frame Quantizer Computation", |
1841 |
- -31.0f, 31.0f, 1.25f, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1842 |
- gst_ffmpeg_add_pspec (pspec, config.b_quant_factor, FALSE, mpeg, NULL); |
1843 |
- |
1844 |
- pspec = g_param_spec_float ("b-quant-offset", "B-Quantizer Offset", |
1845 |
- "Offset in B-Frame Quantizer Computation", |
1846 |
- 0.0f, 31.0f, 1.25f, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1847 |
- gst_ffmpeg_add_pspec (pspec, config.b_quant_offset, FALSE, mpeg, NULL); |
1848 |
- |
1849 |
- pspec = g_param_spec_float ("i-quant-factor", "I-Quantizer Factor", |
1850 |
- "Factor in P-Frame Quantizer Computation", |
1851 |
- -31.0f, 31.0f, 0.8f, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1852 |
- gst_ffmpeg_add_pspec (pspec, config.i_quant_factor, FALSE, mpeg, NULL); |
1853 |
- |
1854 |
- pspec = g_param_spec_float ("i-quant-offset", "I-Quantizer Offset", |
1855 |
- "Offset in P-Frame Quantizer Computation", |
1856 |
- 0.0f, 31.0f, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1857 |
- gst_ffmpeg_add_pspec (pspec, config.i_quant_offset, FALSE, mpeg, NULL); |
1858 |
- |
1859 |
- /* note overlap with gop-size; 0 means do not override */ |
1860 |
- pspec = g_param_spec_int ("max-key-interval", "Maximum Key Interval", |
1861 |
- "Maximum number of frames between two keyframes (< 0 is in sec)", |
1862 |
- -100, G_MAXINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1863 |
- gst_ffmpeg_add_pspec (pspec, max_key_interval, FALSE, mpeg, NULL); |
1864 |
- |
1865 |
- pspec = g_param_spec_float ("lumi-masking", "Luminance Masking", |
1866 |
- "Luminance Masking", -1.0f, 1.0f, 0.0f, |
1867 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1868 |
- gst_ffmpeg_add_pspec (pspec, config.lumi_masking, FALSE, mpeg, NULL); |
1869 |
- |
1870 |
- pspec = g_param_spec_float ("dark-masking", "Darkness Masking", |
1871 |
- "Darkness Masking", -1.0f, 1.0f, 0.0f, |
1872 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1873 |
- gst_ffmpeg_add_pspec (pspec, config.dark_masking, FALSE, mpeg, NULL); |
1874 |
- |
1875 |
- pspec = g_param_spec_float ("temporal-cplx-masking", |
1876 |
- "Temporal Complexity Masking", |
1877 |
- "Temporal Complexity Masking", -1.0f, 1.0f, 0.0f, |
1878 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1879 |
- gst_ffmpeg_add_pspec (pspec, config.temporal_cplx_masking, FALSE, mpeg, NULL); |
1880 |
- |
1881 |
- pspec = g_param_spec_float ("spatial-cplx-masking", |
1882 |
- "Spatial Complexity Masking", |
1883 |
- "Spatial Complexity Masking", -1.0f, 1.0f, 0.0f, |
1884 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1885 |
- gst_ffmpeg_add_pspec (pspec, config.spatial_cplx_masking, FALSE, mpeg, NULL); |
1886 |
- |
1887 |
- pspec = g_param_spec_float ("p-masking", "P Block Masking", |
1888 |
- "P Block Masking", -1.0f, 1.0f, 0.0f, |
1889 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1890 |
- gst_ffmpeg_add_pspec (pspec, config.p_masking, FALSE, mpeg, NULL); |
1891 |
- |
1892 |
- pspec = g_param_spec_int ("dia-size", |
1893 |
- "Motion Estimation Diamond Size/Shape", |
1894 |
- "Motion Estimation Diamond Size/Shape", |
1895 |
- -2000, 2000, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1896 |
- gst_ffmpeg_add_pspec (pspec, config.dia_size, FALSE, mpeg, NULL); |
1897 |
- |
1898 |
- pspec = g_param_spec_int ("pre-dia-size", |
1899 |
- "Motion Estimation Pre Pass Diamond Size/Shape", |
1900 |
- "Motion Estimation Diamond Size/Shape", |
1901 |
- -2000, 2000, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1902 |
- gst_ffmpeg_add_pspec (pspec, config.pre_dia_size, FALSE, mpeg, NULL); |
1903 |
- |
1904 |
- pspec = g_param_spec_int ("last-predictor-count", |
1905 |
- "Last Predictor Count", |
1906 |
- "Amount of previous Motion Vector predictors", |
1907 |
- 0, 2000, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1908 |
- gst_ffmpeg_add_pspec (pspec, config.last_predictor_count, FALSE, mpeg, NULL); |
1909 |
- |
1910 |
- pspec = g_param_spec_enum ("pre-me", |
1911 |
- "Pre Pass for Motion Estimation", |
1912 |
- "Pre Pass for Motion Estimation", |
1913 |
- GST_TYPE_FFMPEG_PRE_ME, 1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1914 |
- gst_ffmpeg_add_pspec (pspec, config.pre_me, FALSE, mpeg, NULL); |
1915 |
- |
1916 |
- pspec = g_param_spec_int ("me-subpel-quality", |
1917 |
- "Motion Estimation Subpixel Quality", |
1918 |
- "Motion Estimation Subpixel Refinement Quality", |
1919 |
- 0, 8, 8, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1920 |
- gst_ffmpeg_add_pspec (pspec, config.me_subpel_quality, FALSE, mpeg, NULL); |
1921 |
- |
1922 |
- pspec = g_param_spec_int ("me-range", |
1923 |
- "Motion Estimation Range", |
1924 |
- "Motion Estimation search range in subpel units", |
1925 |
- 0, 16000, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1926 |
- gst_ffmpeg_add_pspec (pspec, config.me_range, FALSE, mpeg, NULL); |
1927 |
- |
1928 |
- pspec = g_param_spec_int ("intra-quant-bias", |
1929 |
- "Intra Quantizer Bias", |
1930 |
- "Intra Quantizer Bias", |
1931 |
- -1000000, 1000000, FF_DEFAULT_QUANT_BIAS, |
1932 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1933 |
- gst_ffmpeg_add_pspec (pspec, config.intra_quant_bias, FALSE, mpeg, NULL); |
1934 |
- |
1935 |
- pspec = g_param_spec_int ("inter-quant-bias", |
1936 |
- "Inter Quantizer Bias", |
1937 |
- "Inter Quantizer Bias", |
1938 |
- -1000000, 1000000, FF_DEFAULT_QUANT_BIAS, |
1939 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1940 |
- gst_ffmpeg_add_pspec (pspec, config.inter_quant_bias, FALSE, mpeg, NULL); |
1941 |
- |
1942 |
- pspec = g_param_spec_int ("noise-reduction", |
1943 |
- "Noise Reduction", |
1944 |
- "Noise Reduction Strength", 0, 1000000, 0, |
1945 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1946 |
- gst_ffmpeg_add_pspec (pspec, config.noise_reduction, FALSE, mpeg, NULL); |
1947 |
- |
1948 |
- pspec = g_param_spec_int ("intra-dc-precision", |
1949 |
- "Intra DC precision", |
1950 |
- "Precision of the Intra DC coefficient - 8", 0, 16, 0, |
1951 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1952 |
- gst_ffmpeg_add_pspec (pspec, config.intra_dc_precision, FALSE, mpeg, NULL); |
1953 |
- |
1954 |
- /* TODO skipped coder_type, context_model, inter_threshold, scenechange_threshold */ |
1955 |
- |
1956 |
- pspec = g_param_spec_flags ("flags", "Flags", |
1957 |
- "Flags", GST_TYPE_FFMPEG_FLAGS, 0, |
1958 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1959 |
- gst_ffmpeg_add_pspec (pspec, config.flags, FALSE, mpeg, NULL); |
1960 |
- |
1961 |
- pspec = g_param_spec_boolean ("interlaced", "Interlaced Material", |
1962 |
- "Interlaced Material", FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1963 |
- gst_ffmpeg_add_pspec (pspec, interlaced, FALSE, mpeg, NULL); |
1964 |
- |
1965 |
- pspec = g_param_spec_int ("max-bframes", "Max B-Frames", |
1966 |
- "Maximum B-frames in a row", 0, INT_MAX, 0, |
1967 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1968 |
- gst_ffmpeg_add_pspec (pspec, config.max_b_frames, FALSE, mpeg, NULL); |
1969 |
- |
1970 |
- pspec = g_param_spec_enum ("prediction-method", "Prediction Method", |
1971 |
- "Prediction Method", |
1972 |
- GST_TYPE_FFMPEG_PRED_METHOD, FF_PRED_LEFT, |
1973 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1974 |
- gst_ffmpeg_add_pspec (pspec, config.prediction_method, FALSE, huffyuv, NULL); |
1975 |
- pspec = g_param_spec_int ("trellis", "Trellis Quantization", |
1976 |
- "Trellis RD quantization", 0, 1, 1, |
1977 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
1978 |
- gst_ffmpeg_add_pspec (pspec, config.trellis, FALSE, mpeg, NULL); |
1979 |
-} |
1980 |
- |
1981 |
-/* ==== END CONFIGURATION SECTION ==== */ |
1982 |
- |
1983 |
- |
1984 |
-/* return TRUE if property described by pspec applies to the codec with codec_id */ |
1985 |
-static gboolean |
1986 |
-gst_ffmpeg_cfg_codec_has_pspec (enum AVCodecID codec_id, GParamSpec * pspec) |
1987 |
-{ |
1988 |
- GParamSpecData *qdata; |
1989 |
- gint *codec; |
1990 |
- gboolean ret = FALSE; |
1991 |
- |
1992 |
- qdata = g_param_spec_get_qdata (pspec, quark); |
1993 |
- |
1994 |
- /* check if excluded first */ |
1995 |
- if ((codec = qdata->exclude_list)) { |
1996 |
- for (; *codec != AV_CODEC_ID_NONE; ++codec) { |
1997 |
- if (*codec == codec_id) |
1998 |
- return FALSE; |
1999 |
+ if (pspec) { |
2000 |
+ g_param_spec_set_qdata (pspec, avoption_quark, (gpointer) opt); |
2001 |
} |
2002 |
} |
2003 |
|
2004 |
- /* no include list means it is accepted */ |
2005 |
- if ((codec = qdata->include_list)) { |
2006 |
- for (; *codec != AV_CODEC_ID_NONE; ++codec) { |
2007 |
- if (*codec == codec_id) |
2008 |
- ret = TRUE; |
2009 |
- } |
2010 |
- } else { |
2011 |
- ret = TRUE; |
2012 |
- } |
2013 |
- |
2014 |
- return ret; |
2015 |
+ return prop_id; |
2016 |
} |
2017 |
|
2018 |
-/* install all properties for klass that have been registered in property_list */ |
2019 |
void |
2020 |
-gst_ffmpeg_cfg_install_property (GstFFMpegVidEncClass * klass, guint base) |
2021 |
+gst_ffmpeg_cfg_install_properties (GObjectClass * klass, AVCodec * in_plugin, |
2022 |
+ guint base, gint flags) |
2023 |
{ |
2024 |
- GParamSpec *pspec; |
2025 |
- GList *list; |
2026 |
gint prop_id; |
2027 |
AVCodecContext *ctx; |
2028 |
|
2029 |
prop_id = base; |
2030 |
g_return_if_fail (base > 0); |
2031 |
|
2032 |
- ctx = avcodec_alloc_context3 (klass->in_plugin); |
2033 |
+ ctx = avcodec_alloc_context3 (in_plugin); |
2034 |
if (!ctx) |
2035 |
g_warning ("could not get context"); |
2036 |
|
2037 |
- for (list = property_list; list; list = list->next) { |
2038 |
- pspec = G_PARAM_SPEC (list->data); |
2039 |
- if (gst_ffmpeg_cfg_codec_has_pspec (klass->in_plugin->id, pspec)) { |
2040 |
- /* 'clone' the paramspec for the various codecs, |
2041 |
- * since a single paramspec cannot be owned by distinct types */ |
2042 |
+ prop_id = |
2043 |
+ install_opts ((GObjectClass *) klass, &in_plugin->priv_class, prop_id, 0, |
2044 |
+ " (Private codec option)", NULL); |
2045 |
+ prop_id = |
2046 |
+ install_opts ((GObjectClass *) klass, &ctx->av_class, prop_id, flags, |
2047 |
+ " (Generic codec option, might have no effect)", generic_overrides); |
2048 |
|
2049 |
- const gchar *name = g_param_spec_get_name (pspec); |
2050 |
- const gchar *nick = g_param_spec_get_nick (pspec); |
2051 |
- const gchar *blurb = g_param_spec_get_blurb (pspec); |
2052 |
- GParamSpecData *qdata = g_param_spec_get_qdata (pspec, quark); |
2053 |
- gint ctx_offset = 0; |
2054 |
- gboolean lavc_default; |
2055 |
- |
2056 |
- /* cannot obtain lavc default if no context */ |
2057 |
- if (!ctx) |
2058 |
- lavc_default = FALSE; |
2059 |
- else { |
2060 |
- ctx_offset = qdata->offset - CONTEXT_CONFIG_OFFSET; |
2061 |
- /* safety check; is it really member of the avcodec context */ |
2062 |
- if (ctx_offset < 0) |
2063 |
- lavc_default = FALSE; |
2064 |
- else |
2065 |
- lavc_default = qdata->lavc_default; |
2066 |
- } |
2067 |
- |
2068 |
- switch (G_PARAM_SPEC_VALUE_TYPE (pspec)) { |
2069 |
- case G_TYPE_STRING:{ |
2070 |
- GParamSpecString *pstring = G_PARAM_SPEC_STRING (pspec); |
2071 |
- |
2072 |
- pspec = g_param_spec_string (name, nick, blurb, |
2073 |
- lavc_default ? G_STRUCT_MEMBER (gchar *, ctx, ctx_offset) |
2074 |
- : pstring->default_value, pspec->flags); |
2075 |
- break; |
2076 |
- } |
2077 |
- case G_TYPE_INT:{ |
2078 |
- GParamSpecInt *pint = G_PARAM_SPEC_INT (pspec); |
2079 |
- |
2080 |
- pspec = g_param_spec_int (name, nick, blurb, |
2081 |
- pint->minimum, pint->maximum, |
2082 |
- lavc_default ? G_STRUCT_MEMBER (gint, ctx, ctx_offset) |
2083 |
- : pint->default_value, pspec->flags); |
2084 |
- break; |
2085 |
- } |
2086 |
- case G_TYPE_INT64:{ |
2087 |
- GParamSpecInt64 *pint = G_PARAM_SPEC_INT64 (pspec); |
2088 |
- |
2089 |
- pspec = g_param_spec_int64 (name, nick, blurb, |
2090 |
- pint->minimum, pint->maximum, |
2091 |
- lavc_default ? G_STRUCT_MEMBER (gint64, ctx, ctx_offset) |
2092 |
- : pint->default_value, pspec->flags); |
2093 |
- break; |
2094 |
- } |
2095 |
- case G_TYPE_UINT:{ |
2096 |
- GParamSpecUInt *puint = G_PARAM_SPEC_UINT (pspec); |
2097 |
- |
2098 |
- pspec = g_param_spec_uint (name, nick, blurb, |
2099 |
- puint->minimum, puint->maximum, |
2100 |
- lavc_default ? G_STRUCT_MEMBER (guint, ctx, ctx_offset) |
2101 |
- : puint->default_value, pspec->flags); |
2102 |
- break; |
2103 |
- } |
2104 |
- case G_TYPE_FLOAT:{ |
2105 |
- GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (pspec); |
2106 |
- |
2107 |
- pspec = g_param_spec_float (name, nick, blurb, |
2108 |
- pfloat->minimum, pfloat->maximum, |
2109 |
- lavc_default ? G_STRUCT_MEMBER (gfloat, ctx, ctx_offset) |
2110 |
- : pfloat->default_value, pspec->flags); |
2111 |
- break; |
2112 |
- } |
2113 |
- case G_TYPE_BOOLEAN:{ |
2114 |
- GParamSpecBoolean *pboolean = G_PARAM_SPEC_BOOLEAN (pspec); |
2115 |
- |
2116 |
- pspec = g_param_spec_boolean (name, nick, blurb, |
2117 |
- lavc_default ? G_STRUCT_MEMBER (gboolean, ctx, ctx_offset) |
2118 |
- : pboolean->default_value, pspec->flags); |
2119 |
- break; |
2120 |
- } |
2121 |
- default: |
2122 |
- if (G_IS_PARAM_SPEC_ENUM (pspec)) { |
2123 |
- GParamSpecEnum *penum = G_PARAM_SPEC_ENUM (pspec); |
2124 |
- |
2125 |
- pspec = g_param_spec_enum (name, nick, blurb, |
2126 |
- pspec->value_type, |
2127 |
- lavc_default ? G_STRUCT_MEMBER (gint, ctx, ctx_offset) |
2128 |
- : penum->default_value, pspec->flags); |
2129 |
- } else if (G_IS_PARAM_SPEC_FLAGS (pspec)) { |
2130 |
- GParamSpecFlags *pflags = G_PARAM_SPEC_FLAGS (pspec); |
2131 |
- |
2132 |
- pspec = g_param_spec_flags (name, nick, blurb, |
2133 |
- pspec->value_type, |
2134 |
- lavc_default ? G_STRUCT_MEMBER (guint, ctx, ctx_offset) |
2135 |
- : pflags->default_value, pspec->flags); |
2136 |
- } else { |
2137 |
- g_critical ("%s does not yet support type %s", GST_FUNCTION, |
2138 |
- g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec))); |
2139 |
- continue; |
2140 |
- } |
2141 |
- break; |
2142 |
- } |
2143 |
- g_param_spec_set_qdata (pspec, quark, qdata); |
2144 |
- g_object_class_install_property (G_OBJECT_CLASS (klass), prop_id, pspec); |
2145 |
- ++prop_id; |
2146 |
- } |
2147 |
- } |
2148 |
- |
2149 |
if (ctx) { |
2150 |
gst_ffmpeg_avcodec_close (ctx); |
2151 |
av_free (ctx); |
2152 |
} |
2153 |
} |
2154 |
|
2155 |
-/* returns TRUE if it is a known property for this config system, |
2156 |
- * FALSE otherwise */ |
2157 |
-gboolean |
2158 |
-gst_ffmpeg_cfg_set_property (GObject * object, |
2159 |
- const GValue * value, GParamSpec * pspec) |
2160 |
+static gint |
2161 |
+set_option_value (AVCodecContext * ctx, GParamSpec * pspec, |
2162 |
+ const GValue * value, const AVOption * opt) |
2163 |
{ |
2164 |
- GstFFMpegVidEnc *ffmpegenc = (GstFFMpegVidEnc *) (object); |
2165 |
- GParamSpecData *qdata; |
2166 |
+ int res = -1; |
2167 |
|
2168 |
- qdata = g_param_spec_get_qdata (pspec, quark); |
2169 |
- |
2170 |
- /* our param specs should have such qdata */ |
2171 |
- if (!qdata) |
2172 |
- return FALSE; |
2173 |
- |
2174 |
- /* set the member using the offset, also mild type check based on size */ |
2175 |
switch (G_PARAM_SPEC_VALUE_TYPE (pspec)) { |
2176 |
- case G_TYPE_BOOLEAN: |
2177 |
- g_return_val_if_fail (qdata->size == sizeof (gboolean), TRUE); |
2178 |
- G_STRUCT_MEMBER (gboolean, ffmpegenc, qdata->offset) = |
2179 |
- g_value_get_boolean (value); |
2180 |
- break; |
2181 |
- case G_TYPE_UINT: |
2182 |
- g_return_val_if_fail (qdata->size == sizeof (guint), TRUE); |
2183 |
- G_STRUCT_MEMBER (guint, ffmpegenc, qdata->offset) = |
2184 |
- g_value_get_uint (value); |
2185 |
- break; |
2186 |
case G_TYPE_INT: |
2187 |
- g_return_val_if_fail (qdata->size == sizeof (gint), TRUE); |
2188 |
- G_STRUCT_MEMBER (gint, ffmpegenc, qdata->offset) = |
2189 |
- g_value_get_int (value); |
2190 |
+ res = av_opt_set_int (ctx, opt->name, |
2191 |
+ g_value_get_int (value), AV_OPT_SEARCH_CHILDREN); |
2192 |
break; |
2193 |
case G_TYPE_INT64: |
2194 |
- g_return_val_if_fail (qdata->size == sizeof (gint64), TRUE); |
2195 |
- G_STRUCT_MEMBER (gint64, ffmpegenc, qdata->offset) = |
2196 |
- g_value_get_int64 (value); |
2197 |
+ res = av_opt_set_int (ctx, opt->name, |
2198 |
+ g_value_get_int64 (value), AV_OPT_SEARCH_CHILDREN); |
2199 |
break; |
2200 |
+ case G_TYPE_UINT64: |
2201 |
+ res = av_opt_set_int (ctx, opt->name, |
2202 |
+ g_value_get_uint64 (value), AV_OPT_SEARCH_CHILDREN); |
2203 |
+ break; |
2204 |
+ case G_TYPE_DOUBLE: |
2205 |
+ res = av_opt_set_double (ctx, opt->name, |
2206 |
+ g_value_get_double (value), AV_OPT_SEARCH_CHILDREN); |
2207 |
+ break; |
2208 |
case G_TYPE_FLOAT: |
2209 |
- g_return_val_if_fail (qdata->size == sizeof (gfloat), TRUE); |
2210 |
- G_STRUCT_MEMBER (gfloat, ffmpegenc, qdata->offset) = |
2211 |
- g_value_get_float (value); |
2212 |
+ res = av_opt_set_double (ctx, opt->name, |
2213 |
+ g_value_get_float (value), AV_OPT_SEARCH_CHILDREN); |
2214 |
break; |
2215 |
case G_TYPE_STRING: |
2216 |
- g_return_val_if_fail (qdata->size == sizeof (gchar *), TRUE); |
2217 |
- g_free (G_STRUCT_MEMBER (gchar *, ffmpegenc, qdata->offset)); |
2218 |
- G_STRUCT_MEMBER (gchar *, ffmpegenc, qdata->offset) = |
2219 |
- g_value_dup_string (value); |
2220 |
+ res = av_opt_set (ctx, opt->name, |
2221 |
+ g_value_get_string (value), AV_OPT_SEARCH_CHILDREN); |
2222 |
+ /* Some code in FFmpeg returns ENOMEM if the string is NULL: |
2223 |
+ * *dst = av_strdup(val); |
2224 |
+ * return *dst ? 0 : AVERROR(ENOMEM); |
2225 |
+ * That makes little sense, let's ignore that |
2226 |
+ */ |
2227 |
+ if (!g_value_get_string (value)) |
2228 |
+ res = 0; |
2229 |
break; |
2230 |
- default: /* must be enum, given the check above */ |
2231 |
+ case G_TYPE_BOOLEAN: |
2232 |
+ res = av_opt_set_int (ctx, opt->name, |
2233 |
+ g_value_get_boolean (value), AV_OPT_SEARCH_CHILDREN); |
2234 |
+ break; |
2235 |
+ default: |
2236 |
if (G_IS_PARAM_SPEC_ENUM (pspec)) { |
2237 |
- g_return_val_if_fail (qdata->size == sizeof (gint), TRUE); |
2238 |
- G_STRUCT_MEMBER (gint, ffmpegenc, qdata->offset) = |
2239 |
- g_value_get_enum (value); |
2240 |
+ res = av_opt_set_int (ctx, opt->name, |
2241 |
+ g_value_get_enum (value), AV_OPT_SEARCH_CHILDREN); |
2242 |
} else if (G_IS_PARAM_SPEC_FLAGS (pspec)) { |
2243 |
- g_return_val_if_fail (qdata->size == sizeof (guint), TRUE); |
2244 |
- G_STRUCT_MEMBER (guint, ffmpegenc, qdata->offset) = |
2245 |
- g_value_get_flags (value); |
2246 |
+ res = av_opt_set_int (ctx, opt->name, |
2247 |
+ g_value_get_flags (value), AV_OPT_SEARCH_CHILDREN); |
2248 |
} else { /* oops, bit lazy we don't cover this case yet */ |
2249 |
g_critical ("%s does not yet support type %s", GST_FUNCTION, |
2250 |
g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec))); |
2251 |
} |
2252 |
- |
2253 |
- break; |
2254 |
} |
2255 |
|
2256 |
- return TRUE; |
2257 |
+ return res; |
2258 |
} |
2259 |
|
2260 |
-/* returns TRUE if it is a known property for this config system, |
2261 |
- * FALSE otherwise */ |
2262 |
gboolean |
2263 |
-gst_ffmpeg_cfg_get_property (GObject * object, |
2264 |
- GValue * value, GParamSpec * pspec) |
2265 |
+gst_ffmpeg_cfg_set_property (AVCodecContext * refcontext, const GValue * value, |
2266 |
+ GParamSpec * pspec) |
2267 |
{ |
2268 |
- GstFFMpegVidEnc *ffmpegenc = (GstFFMpegVidEnc *) (object); |
2269 |
- GParamSpecData *qdata; |
2270 |
+ const AVOption *opt; |
2271 |
|
2272 |
- qdata = g_param_spec_get_qdata (pspec, quark); |
2273 |
+ opt = g_param_spec_get_qdata (pspec, avoption_quark); |
2274 |
|
2275 |
- /* our param specs should have such qdata */ |
2276 |
- if (!qdata) |
2277 |
+ if (!opt) |
2278 |
return FALSE; |
2279 |
|
2280 |
- /* get the member using the offset, also mild type check based on size */ |
2281 |
- switch (G_PARAM_SPEC_VALUE_TYPE (pspec)) { |
2282 |
- case G_TYPE_BOOLEAN: |
2283 |
- g_return_val_if_fail (qdata->size == sizeof (gboolean), TRUE); |
2284 |
- g_value_set_boolean (value, |
2285 |
- G_STRUCT_MEMBER (gboolean, ffmpegenc, qdata->offset)); |
2286 |
- break; |
2287 |
- case G_TYPE_UINT: |
2288 |
- g_return_val_if_fail (qdata->size == sizeof (guint), TRUE); |
2289 |
- g_value_set_uint (value, |
2290 |
- G_STRUCT_MEMBER (guint, ffmpegenc, qdata->offset)); |
2291 |
- break; |
2292 |
- case G_TYPE_INT: |
2293 |
- g_return_val_if_fail (qdata->size == sizeof (gint), TRUE); |
2294 |
- g_value_set_int (value, G_STRUCT_MEMBER (gint, ffmpegenc, qdata->offset)); |
2295 |
- break; |
2296 |
- case G_TYPE_INT64: |
2297 |
- g_return_val_if_fail (qdata->size == sizeof (gint64), TRUE); |
2298 |
- g_value_set_int64 (value, G_STRUCT_MEMBER (gint64, ffmpegenc, |
2299 |
- qdata->offset)); |
2300 |
- break; |
2301 |
- case G_TYPE_FLOAT: |
2302 |
- g_return_val_if_fail (qdata->size == sizeof (gfloat), TRUE); |
2303 |
- g_value_set_float (value, |
2304 |
- G_STRUCT_MEMBER (gfloat, ffmpegenc, qdata->offset)); |
2305 |
- break; |
2306 |
- case G_TYPE_STRING: |
2307 |
- g_return_val_if_fail (qdata->size == sizeof (gchar *), TRUE); |
2308 |
- g_value_take_string (value, |
2309 |
- g_strdup (G_STRUCT_MEMBER (gchar *, ffmpegenc, qdata->offset))); |
2310 |
- break; |
2311 |
- default: /* must be enum, given the check above */ |
2312 |
- if (G_IS_PARAM_SPEC_ENUM (pspec)) { |
2313 |
- g_return_val_if_fail (qdata->size == sizeof (gint), TRUE); |
2314 |
- g_value_set_enum (value, |
2315 |
- G_STRUCT_MEMBER (gint, ffmpegenc, qdata->offset)); |
2316 |
- } else if (G_IS_PARAM_SPEC_FLAGS (pspec)) { |
2317 |
- g_return_val_if_fail (qdata->size == sizeof (guint), TRUE); |
2318 |
- g_value_set_flags (value, |
2319 |
- G_STRUCT_MEMBER (guint, ffmpegenc, qdata->offset)); |
2320 |
- } else { /* oops, bit lazy we don't cover this case yet */ |
2321 |
- g_critical ("%s does not yet support type %s", GST_FUNCTION, |
2322 |
- g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec))); |
2323 |
- } |
2324 |
- break; |
2325 |
- } |
2326 |
- |
2327 |
- return TRUE; |
2328 |
+ return set_option_value (refcontext, pspec, value, opt) >= 0; |
2329 |
} |
2330 |
|
2331 |
-void |
2332 |
-gst_ffmpeg_cfg_set_defaults (GstFFMpegVidEnc * ffmpegenc) |
2333 |
+gboolean |
2334 |
+gst_ffmpeg_cfg_get_property (AVCodecContext * refcontext, GValue * value, |
2335 |
+ GParamSpec * pspec) |
2336 |
{ |
2337 |
- GParamSpec **pspecs; |
2338 |
- guint num_props, i; |
2339 |
+ const AVOption *opt; |
2340 |
|
2341 |
- pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (ffmpegenc), |
2342 |
- &num_props); |
2343 |
+ opt = g_param_spec_get_qdata (pspec, avoption_quark); |
2344 |
|
2345 |
- for (i = 0; i < num_props; ++i) { |
2346 |
- GValue val = { 0, }; |
2347 |
- GParamSpec *pspec = pspecs[i]; |
2348 |
- |
2349 |
- /* only touch those that are really ours; i.e. should have some qdata */ |
2350 |
- if (!g_param_spec_get_qdata (pspec, quark)) |
2351 |
- continue; |
2352 |
- g_value_init (&val, G_PARAM_SPEC_VALUE_TYPE (pspec)); |
2353 |
- g_param_value_set_default (pspec, &val); |
2354 |
- g_object_set_property (G_OBJECT (ffmpegenc), |
2355 |
- g_param_spec_get_name (pspec), &val); |
2356 |
- g_value_unset (&val); |
2357 |
+ if (!opt) { |
2358 |
+ return FALSE; |
2359 |
} |
2360 |
|
2361 |
- g_free (pspecs); |
2362 |
+ if (opt) { |
2363 |
+ int res = -1; |
2364 |
|
2365 |
-} |
2366 |
+ switch (G_PARAM_SPEC_VALUE_TYPE (pspec)) { |
2367 |
+ case G_TYPE_INT: |
2368 |
+ { |
2369 |
+ int64_t val; |
2370 |
+ if ((res = av_opt_get_int (refcontext, opt->name, |
2371 |
+ AV_OPT_SEARCH_CHILDREN, &val) >= 0)) |
2372 |
+ g_value_set_int (value, val); |
2373 |
+ break; |
2374 |
+ } |
2375 |
+ case G_TYPE_INT64: |
2376 |
+ { |
2377 |
+ int64_t val; |
2378 |
+ if ((res = av_opt_get_int (refcontext, opt->name, |
2379 |
+ AV_OPT_SEARCH_CHILDREN, &val) >= 0)) |
2380 |
+ g_value_set_int64 (value, val); |
2381 |
+ break; |
2382 |
+ } |
2383 |
+ case G_TYPE_UINT64: |
2384 |
+ { |
2385 |
+ int64_t val; |
2386 |
+ if ((res = av_opt_get_int (refcontext, opt->name, |
2387 |
+ AV_OPT_SEARCH_CHILDREN, &val) >= 0)) |
2388 |
+ g_value_set_uint64 (value, val); |
2389 |
+ break; |
2390 |
+ } |
2391 |
+ case G_TYPE_DOUBLE: |
2392 |
+ { |
2393 |
+ gdouble val; |
2394 |
+ if ((res = av_opt_get_double (refcontext, opt->name, |
2395 |
+ AV_OPT_SEARCH_CHILDREN, &val) >= 0)) |
2396 |
+ g_value_set_double (value, val); |
2397 |
+ break; |
2398 |
+ } |
2399 |
+ case G_TYPE_FLOAT: |
2400 |
+ { |
2401 |
+ gdouble val; |
2402 |
+ if ((res = av_opt_get_double (refcontext, opt->name, |
2403 |
+ AV_OPT_SEARCH_CHILDREN, &val) >= 0)) |
2404 |
+ g_value_set_float (value, (gfloat) val); |
2405 |
+ break; |
2406 |
+ } |
2407 |
+ case G_TYPE_STRING: |
2408 |
+ { |
2409 |
+ uint8_t *val; |
2410 |
+ if ((res = av_opt_get (refcontext, opt->name, |
2411 |
+ AV_OPT_SEARCH_CHILDREN | AV_OPT_ALLOW_NULL, &val) >= 0)) { |
2412 |
+ g_value_set_string (value, (gchar *) val); |
2413 |
+ } |
2414 |
+ break; |
2415 |
+ } |
2416 |
+ case G_TYPE_BOOLEAN: |
2417 |
+ { |
2418 |
+ int64_t val; |
2419 |
+ if ((res = av_opt_get_int (refcontext, opt->name, |
2420 |
+ AV_OPT_SEARCH_CHILDREN, &val) >= 0)) |
2421 |
+ g_value_set_boolean (value, val ? TRUE : FALSE); |
2422 |
+ break; |
2423 |
+ } |
2424 |
+ default: |
2425 |
+ if (G_IS_PARAM_SPEC_ENUM (pspec)) { |
2426 |
+ int64_t val; |
2427 |
|
2428 |
+ if ((res = av_opt_get_int (refcontext, opt->name, |
2429 |
+ AV_OPT_SEARCH_CHILDREN, &val) >= 0)) |
2430 |
+ g_value_set_enum (value, val); |
2431 |
+ } else if (G_IS_PARAM_SPEC_FLAGS (pspec)) { |
2432 |
+ int64_t val; |
2433 |
|
2434 |
-void |
2435 |
-gst_ffmpeg_cfg_fill_context (GstFFMpegVidEnc * ffmpegenc, |
2436 |
- AVCodecContext * context) |
2437 |
-{ |
2438 |
- GstFFMpegVidEncClass *klass |
2439 |
- = (GstFFMpegVidEncClass *) G_OBJECT_GET_CLASS (ffmpegenc); |
2440 |
- GParamSpec *pspec; |
2441 |
- GParamSpecData *qdata; |
2442 |
- GList *list; |
2443 |
- |
2444 |
- list = property_list; |
2445 |
- |
2446 |
- while (list) { |
2447 |
- gint context_offset; |
2448 |
- |
2449 |
- pspec = G_PARAM_SPEC (list->data); |
2450 |
- qdata = g_param_spec_get_qdata (pspec, quark); |
2451 |
- context_offset = qdata->offset - CONTEXT_CONFIG_OFFSET; |
2452 |
- if (gst_ffmpeg_cfg_codec_has_pspec (klass->in_plugin->id, pspec) |
2453 |
- && context_offset >= 0) { |
2454 |
- if (G_PARAM_SPEC_VALUE_TYPE (pspec) == G_TYPE_STRING) { |
2455 |
- /* make a copy for ffmpeg, it will likely free only some, |
2456 |
- * but in any case safer than a potential double free */ |
2457 |
- G_STRUCT_MEMBER (gchar *, context, context_offset) = |
2458 |
- av_strdup (G_STRUCT_MEMBER (gchar *, ffmpegenc, qdata->offset)); |
2459 |
- } else { |
2460 |
- /* memcpy a bit heavy for a small copy, |
2461 |
- * but hardly part of 'inner loop' */ |
2462 |
- memcpy (G_STRUCT_MEMBER_P (context, context_offset), |
2463 |
- G_STRUCT_MEMBER_P (ffmpegenc, qdata->offset), qdata->size); |
2464 |
- } |
2465 |
+ if ((res = av_opt_get_int (refcontext, opt->name, |
2466 |
+ AV_OPT_SEARCH_CHILDREN, &val) >= 0)) |
2467 |
+ g_value_set_flags (value, val); |
2468 |
+ } else { /* oops, bit lazy we don't cover this case yet */ |
2469 |
+ g_critical ("%s does not yet support type %s", GST_FUNCTION, |
2470 |
+ g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec))); |
2471 |
+ } |
2472 |
} |
2473 |
- list = list->next; |
2474 |
+ return res >= 0; |
2475 |
} |
2476 |
+ |
2477 |
+ return TRUE; |
2478 |
} |
2479 |
|
2480 |
void |
2481 |
-gst_ffmpeg_cfg_finalize (GstFFMpegVidEnc * ffmpegenc) |
2482 |
+gst_ffmpeg_cfg_fill_context (GObject * object, AVCodecContext * context) |
2483 |
{ |
2484 |
GParamSpec **pspecs; |
2485 |
guint num_props, i; |
2486 |
|
2487 |
- pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (ffmpegenc), |
2488 |
+ pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (object), |
2489 |
&num_props); |
2490 |
|
2491 |
for (i = 0; i < num_props; ++i) { |
2492 |
GParamSpec *pspec = pspecs[i]; |
2493 |
- GParamSpecData *qdata; |
2494 |
+ const AVOption *opt; |
2495 |
+ GValue value; |
2496 |
|
2497 |
- qdata = g_param_spec_get_qdata (pspec, quark); |
2498 |
+ opt = g_param_spec_get_qdata (pspec, avoption_quark); |
2499 |
|
2500 |
- /* our param specs should have such qdata */ |
2501 |
- if (!qdata) |
2502 |
+ if (!opt) |
2503 |
continue; |
2504 |
|
2505 |
- switch (G_PARAM_SPEC_VALUE_TYPE (pspec)) { |
2506 |
- case G_TYPE_STRING: |
2507 |
- if (qdata->size == sizeof (gchar *)) { |
2508 |
- g_free (G_STRUCT_MEMBER (gchar *, ffmpegenc, qdata->offset)); |
2509 |
- G_STRUCT_MEMBER (gchar *, ffmpegenc, qdata->offset) = NULL; |
2510 |
- } |
2511 |
- break; |
2512 |
- default: |
2513 |
- break; |
2514 |
- } |
2515 |
+ g_object_getv (object, 1, &pspec->name, &value); |
2516 |
+ set_option_value (context, pspec, &value, opt); |
2517 |
} |
2518 |
g_free (pspecs); |
2519 |
+} |
2520 |
+ |
2521 |
+void |
2522 |
+gst_ffmpeg_cfg_finalize (void) |
2523 |
+{ |
2524 |
+ GST_ERROR ("Finalizing"); |
2525 |
+ g_assert (generic_overrides); |
2526 |
+ g_hash_table_unref (generic_overrides); |
2527 |
} |
2528 |
--- ext/libav/gstavcfg.h.orig 2018-03-23 20:45:20 UTC |
2529 |
+++ ext/libav/gstavcfg.h |
2530 |
@@ -21,21 +21,23 @@ |
2531 |
#ifndef __GST_FFMPEGCFG_H__ |
2532 |
#define __GST_FFMPEGCFG_H__ |
2533 |
|
2534 |
+#include <glib-object.h> |
2535 |
+#include <libavcodec/avcodec.h> |
2536 |
+ |
2537 |
G_BEGIN_DECLS |
2538 |
|
2539 |
void gst_ffmpeg_cfg_init (void); |
2540 |
|
2541 |
-void gst_ffmpeg_cfg_install_property (GstFFMpegVidEncClass * klass, guint base); |
2542 |
+void gst_ffmpeg_cfg_install_properties (GObjectClass * klass, AVCodec *in_plugin, guint base, gint flags); |
2543 |
|
2544 |
-gboolean gst_ffmpeg_cfg_set_property (GObject * object, |
2545 |
+gboolean gst_ffmpeg_cfg_set_property (AVCodecContext *refcontext, |
2546 |
const GValue * value, GParamSpec * pspec); |
2547 |
|
2548 |
-gboolean gst_ffmpeg_cfg_get_property (GObject * object, |
2549 |
+gboolean gst_ffmpeg_cfg_get_property (AVCodecContext *refcontext, |
2550 |
GValue * value, GParamSpec * pspec); |
2551 |
|
2552 |
-void gst_ffmpeg_cfg_fill_context (GstFFMpegVidEnc * ffmpegenc, AVCodecContext * context); |
2553 |
-void gst_ffmpeg_cfg_set_defaults (GstFFMpegVidEnc * ffmpegenc); |
2554 |
-void gst_ffmpeg_cfg_finalize (GstFFMpegVidEnc * ffmpegenc); |
2555 |
+void gst_ffmpeg_cfg_fill_context (GObject *object, AVCodecContext * context); |
2556 |
+void gst_ffmpeg_cfg_finalize (void); |
2557 |
|
2558 |
G_END_DECLS |
2559 |
|
2560 |
--- ext/libav/gstavcodecmap.c.orig 2018-03-23 20:45:20 UTC |
2561 |
+++ ext/libav/gstavcodecmap.c |
2562 |
@@ -825,10 +825,11 @@ gst_ffmpeg_codecid_to_caps (enum AVCodecID codec_id, |
2563 |
if (encode && context) { |
2564 |
|
2565 |
gst_caps_set_simple (caps, |
2566 |
- "annex-f", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_4MV, |
2567 |
- "annex-j", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_LOOP_FILTER, |
2568 |
- "annex-i", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_AC_PRED, |
2569 |
- "annex-t", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_AC_PRED, |
2570 |
+ "annex-f", G_TYPE_BOOLEAN, context->flags & AV_CODEC_FLAG_4MV, |
2571 |
+ "annex-j", G_TYPE_BOOLEAN, |
2572 |
+ context->flags & AV_CODEC_FLAG_LOOP_FILTER, |
2573 |
+ "annex-i", G_TYPE_BOOLEAN, context->flags & AV_CODEC_FLAG_AC_PRED, |
2574 |
+ "annex-t", G_TYPE_BOOLEAN, context->flags & AV_CODEC_FLAG_AC_PRED, |
2575 |
NULL); |
2576 |
} |
2577 |
break; |
2578 |
@@ -3181,7 +3182,7 @@ gst_ffmpeg_caps_with_codecid (enum AVCodecID codec_id, |
2579 |
* as is, as that is what most players do. */ |
2580 |
context->extradata = |
2581 |
av_mallocz (GST_ROUND_UP_16 (size * 2 + |
2582 |
- FF_INPUT_BUFFER_PADDING_SIZE)); |
2583 |
+ AV_INPUT_BUFFER_PADDING_SIZE)); |
2584 |
copy_config (context->extradata, data, size, &extrasize); |
2585 |
GST_DEBUG ("escaped size: %d", extrasize); |
2586 |
context->extradata_size = extrasize; |
2587 |
@@ -3192,7 +3193,7 @@ gst_ffmpeg_caps_with_codecid (enum AVCodecID codec_id, |
2588 |
GST_DEBUG ("copy codec_data"); |
2589 |
context->extradata = |
2590 |
av_mallocz (GST_ROUND_UP_16 (map.size + |
2591 |
- FF_INPUT_BUFFER_PADDING_SIZE)); |
2592 |
+ AV_INPUT_BUFFER_PADDING_SIZE)); |
2593 |
memcpy (context->extradata, map.data, map.size); |
2594 |
context->extradata_size = map.size; |
2595 |
} |
2596 |
@@ -3216,7 +3217,7 @@ gst_ffmpeg_caps_with_codecid (enum AVCodecID codec_id, |
2597 |
{ |
2598 |
const gchar *mime = gst_structure_get_name (str); |
2599 |
|
2600 |
- context->flags |= CODEC_FLAG_4MV; |
2601 |
+ context->flags |= AV_CODEC_FLAG_4MV; |
2602 |
|
2603 |
if (!strcmp (mime, "video/x-divx")) |
2604 |
context->codec_tag = GST_MAKE_FOURCC ('D', 'I', 'V', 'X'); |
2605 |
@@ -3228,7 +3229,7 @@ gst_ffmpeg_caps_with_codecid (enum AVCodecID codec_id, |
2606 |
profile = gst_structure_get_string (str, "profile"); |
2607 |
if (profile) { |
2608 |
if (g_strcmp0 (profile, "advanced-simple") == 0) |
2609 |
- context->flags |= CODEC_FLAG_GMC | CODEC_FLAG_QPEL; |
2610 |
+ context->flags |= AV_CODEC_FLAG_QPEL; |
2611 |
} |
2612 |
} |
2613 |
break; |
2614 |
@@ -3334,18 +3335,18 @@ gst_ffmpeg_caps_with_codecid (enum AVCodecID codec_id, |
2615 |
gboolean val; |
2616 |
|
2617 |
if (!gst_structure_get_boolean (str, "annex-f", &val) || val) |
2618 |
- context->flags |= CODEC_FLAG_4MV; |
2619 |
+ context->flags |= AV_CODEC_FLAG_4MV; |
2620 |
else |
2621 |
- context->flags &= ~CODEC_FLAG_4MV; |
2622 |
+ context->flags &= ~AV_CODEC_FLAG_4MV; |
2623 |
if ((!gst_structure_get_boolean (str, "annex-i", &val) || val) && |
2624 |
(!gst_structure_get_boolean (str, "annex-t", &val) || val)) |
2625 |
- context->flags |= CODEC_FLAG_AC_PRED; |
2626 |
+ context->flags |= AV_CODEC_FLAG_AC_PRED; |
2627 |
else |
2628 |
- context->flags &= ~CODEC_FLAG_AC_PRED; |
2629 |
+ context->flags &= ~AV_CODEC_FLAG_AC_PRED; |
2630 |
if (!gst_structure_get_boolean (str, "annex-j", &val) || val) |
2631 |
- context->flags |= CODEC_FLAG_LOOP_FILTER; |
2632 |
+ context->flags |= AV_CODEC_FLAG_LOOP_FILTER; |
2633 |
else |
2634 |
- context->flags &= ~CODEC_FLAG_LOOP_FILTER; |
2635 |
+ context->flags &= ~AV_CODEC_FLAG_LOOP_FILTER; |
2636 |
break; |
2637 |
} |
2638 |
case AV_CODEC_ID_ADPCM_G726: |
2639 |
--- ext/libav/gstavcodecmap.h.orig 2018-03-23 20:45:20 UTC |
2640 |
+++ ext/libav/gstavcodecmap.h |
2641 |
@@ -155,7 +155,7 @@ gst_ffmpeg_formatid_to_caps (const gchar *format_name) |
2642 |
|
2643 |
/* |
2644 |
* _formatid_get_codecids () can be used to get the codecIDs |
2645 |
- * (CODEC_ID_NONE-terminated list) that fit that specific |
2646 |
+ * (AV_CODEC_ID_NONE-terminated list) that fit that specific |
2647 |
* output format. |
2648 |
*/ |
2649 |
|
2650 |
--- ext/libav/gstavdeinterlace.c.orig 2018-03-23 20:45:20 UTC |
2651 |
+++ ext/libav/gstavdeinterlace.c |
2652 |
@@ -96,7 +96,7 @@ typedef struct _GstFFMpegDeinterlace |
2653 |
GstFFMpegDeinterlaceMode new_mode; |
2654 |
|
2655 |
enum AVPixelFormat pixfmt; |
2656 |
- AVPicture from_frame, to_frame; |
2657 |
+ AVFrame from_frame, to_frame; |
2658 |
|
2659 |
AVFilterContext *buffersink_ctx; |
2660 |
AVFilterContext *buffersrc_ctx; |
2661 |
@@ -355,8 +355,8 @@ init_filter_graph (GstFFMpegDeinterlace * deinterlace, |
2662 |
} |
2663 |
|
2664 |
static int |
2665 |
-process_filter_graph (GstFFMpegDeinterlace * deinterlace, AVPicture * dst, |
2666 |
- const AVPicture * src, enum AVPixelFormat pixfmt, int width, int height) |
2667 |
+process_filter_graph (GstFFMpegDeinterlace * deinterlace, AVFrame * dst, |
2668 |
+ const AVFrame * src, enum AVPixelFormat pixfmt, int width, int height) |
2669 |
{ |
2670 |
int res; |
2671 |
|
2672 |
@@ -384,8 +384,9 @@ process_filter_graph (GstFFMpegDeinterlace * deinterla |
2673 |
deinterlace->filter_frame); |
2674 |
if (res < 0) |
2675 |
return res; |
2676 |
- av_picture_copy (dst, (const AVPicture *) deinterlace->filter_frame, pixfmt, |
2677 |
- width, height); |
2678 |
+ av_image_copy (dst->data, dst->linesize, |
2679 |
+ (const uint8_t **) deinterlace->filter_frame->data, |
2680 |
+ deinterlace->filter_frame->linesize, pixfmt, width, height); |
2681 |
av_frame_unref (deinterlace->filter_frame); |
2682 |
|
2683 |
return 0; |
2684 |
--- ext/libav/gstavdemux.c.orig 2018-07-18 16:35:27 UTC |
2685 |
+++ ext/libav/gstavdemux.c |
2686 |
@@ -26,6 +26,7 @@ |
2687 |
#include <string.h> |
2688 |
|
2689 |
#include <libavformat/avformat.h> |
2690 |
+#include <libavutil/imgutils.h> |
2691 |
/* #include <ffmpeg/avi.h> */ |
2692 |
#include <gst/gst.h> |
2693 |
#include <gst/base/gstflowcombiner.h> |
2694 |
@@ -922,18 +923,19 @@ gst_ffmpegdemux_get_stream (GstFFMpegDemux * demux, AV |
2695 |
gint num; |
2696 |
gchar *padname; |
2697 |
const gchar *codec; |
2698 |
- AVCodecContext *ctx; |
2699 |
+ AVCodecContext *ctx = NULL; |
2700 |
GstFFStream *stream; |
2701 |
GstEvent *event; |
2702 |
gchar *stream_id; |
2703 |
|
2704 |
- ctx = avstream->codec; |
2705 |
- |
2706 |
oclass = (GstFFMpegDemuxClass *) G_OBJECT_GET_CLASS (demux); |
2707 |
|
2708 |
if (demux->streams[avstream->index] != NULL) |
2709 |
goto exists; |
2710 |
|
2711 |
+ ctx = avcodec_alloc_context3 (NULL); |
2712 |
+ avcodec_parameters_to_context (ctx, avstream->codecpar); |
2713 |
+ |
2714 |
/* create new stream */ |
2715 |
stream = g_new0 (GstFFStream, 1); |
2716 |
demux->streams[avstream->index] = stream; |
2717 |
@@ -1042,23 +1044,27 @@ gst_ffmpegdemux_get_stream (GstFFMpegDemux * demux, AV |
2718 |
GST_TAG_VIDEO_CODEC : GST_TAG_AUDIO_CODEC, codec, NULL); |
2719 |
} |
2720 |
|
2721 |
+done: |
2722 |
+ if (ctx) |
2723 |
+ avcodec_free_context (&ctx); |
2724 |
return stream; |
2725 |
|
2726 |
/* ERRORS */ |
2727 |
exists: |
2728 |
{ |
2729 |
GST_DEBUG_OBJECT (demux, "Pad existed (stream %d)", avstream->index); |
2730 |
- return demux->streams[avstream->index]; |
2731 |
+ stream = demux->streams[avstream->index]; |
2732 |
+ goto done; |
2733 |
} |
2734 |
unknown_type: |
2735 |
{ |
2736 |
GST_WARNING_OBJECT (demux, "Unknown pad type %d", ctx->codec_type); |
2737 |
- return stream; |
2738 |
+ goto done; |
2739 |
} |
2740 |
unknown_caps: |
2741 |
{ |
2742 |
GST_WARNING_OBJECT (demux, "Unknown caps for codec %d", ctx->codec_id); |
2743 |
- return stream; |
2744 |
+ goto done; |
2745 |
} |
2746 |
} |
2747 |
|
2748 |
@@ -1477,12 +1483,12 @@ gst_ffmpegdemux_loop (GstFFMpegDemux * demux) |
2749 |
/* prepare to push packet to peer */ |
2750 |
srcpad = stream->pad; |
2751 |
|
2752 |
- rawvideo = (avstream->codec->codec_type == AVMEDIA_TYPE_VIDEO && |
2753 |
- avstream->codec->codec_id == AV_CODEC_ID_RAWVIDEO); |
2754 |
+ rawvideo = (avstream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && |
2755 |
+ avstream->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO); |
2756 |
|
2757 |
if (rawvideo) |
2758 |
- outsize = gst_ffmpeg_avpicture_get_size (avstream->codec->pix_fmt, |
2759 |
- avstream->codec->width, avstream->codec->height); |
2760 |
+ outsize = gst_ffmpeg_avpicture_get_size (avstream->codecpar->format, |
2761 |
+ avstream->codecpar->width, avstream->codecpar->height); |
2762 |
else |
2763 |
outsize = pkt.size; |
2764 |
|
2765 |
@@ -1491,23 +1497,24 @@ gst_ffmpegdemux_loop (GstFFMpegDemux * demux) |
2766 |
/* copy the data from packet into the target buffer |
2767 |
* and do conversions for raw video packets */ |
2768 |
if (rawvideo) { |
2769 |
- AVPicture src, dst; |
2770 |
+ AVFrame src, dst; |
2771 |
const gchar *plugin_name = |
2772 |
((GstFFMpegDemuxClass *) (G_OBJECT_GET_CLASS (demux)))->in_plugin->name; |
2773 |
GstMapInfo map; |
2774 |
|
2775 |
GST_WARNING ("Unknown demuxer %s, no idea what to do", plugin_name); |
2776 |
gst_ffmpeg_avpicture_fill (&src, pkt.data, |
2777 |
- avstream->codec->pix_fmt, avstream->codec->width, |
2778 |
- avstream->codec->height); |
2779 |
+ avstream->codecpar->format, avstream->codecpar->width, |
2780 |
+ avstream->codecpar->height); |
2781 |
|
2782 |
gst_buffer_map (outbuf, &map, GST_MAP_WRITE); |
2783 |
gst_ffmpeg_avpicture_fill (&dst, map.data, |
2784 |
- avstream->codec->pix_fmt, avstream->codec->width, |
2785 |
- avstream->codec->height); |
2786 |
+ avstream->codecpar->format, avstream->codecpar->width, |
2787 |
+ avstream->codecpar->height); |
2788 |
|
2789 |
- av_picture_copy (&dst, &src, avstream->codec->pix_fmt, |
2790 |
- avstream->codec->width, avstream->codec->height); |
2791 |
+ av_image_copy (dst.data, dst.linesize, (const uint8_t **) src.data, |
2792 |
+ src.linesize, avstream->codecpar->format, avstream->codecpar->width, |
2793 |
+ avstream->codecpar->height); |
2794 |
gst_buffer_unmap (outbuf, &map); |
2795 |
} else { |
2796 |
gst_buffer_fill (outbuf, 0, pkt.data, outsize); |
2797 |
@@ -1954,7 +1961,7 @@ gboolean |
2798 |
gst_ffmpegdemux_register (GstPlugin * plugin) |
2799 |
{ |
2800 |
GType type; |
2801 |
- AVInputFormat *in_plugin; |
2802 |
+ const AVInputFormat *in_plugin; |
2803 |
gchar *extensions; |
2804 |
GTypeInfo typeinfo = { |
2805 |
sizeof (GstFFMpegDemuxClass), |
2806 |
@@ -1968,11 +1975,11 @@ gst_ffmpegdemux_register (GstPlugin * plugin) |
2807 |
(GInstanceInitFunc) gst_ffmpegdemux_init, |
2808 |
}; |
2809 |
|
2810 |
- in_plugin = av_iformat_next (NULL); |
2811 |
+ void *i = 0; |
2812 |
|
2813 |
GST_LOG ("Registering demuxers"); |
2814 |
|
2815 |
- while (in_plugin) { |
2816 |
+ while ((in_plugin = av_demuxer_iterate (&i))) { |
2817 |
gchar *type_name, *typefind_name; |
2818 |
gint rank; |
2819 |
gboolean register_typefind_func = TRUE; |
2820 |
@@ -2000,14 +2007,14 @@ gst_ffmpegdemux_register (GstPlugin * plugin) |
2821 |
!strncmp (in_plugin->name, "f64", 3) || |
2822 |
!strcmp (in_plugin->name, "mulaw") || !strcmp (in_plugin->name, "alaw") |
2823 |
) |
2824 |
- goto next; |
2825 |
+ continue; |
2826 |
|
2827 |
/* no network demuxers */ |
2828 |
if (!strcmp (in_plugin->name, "sdp") || |
2829 |
!strcmp (in_plugin->name, "rtsp") || |
2830 |
!strcmp (in_plugin->name, "applehttp") |
2831 |
) |
2832 |
- goto next; |
2833 |
+ continue; |
2834 |
|
2835 |
/* these don't do what one would expect or |
2836 |
* are only partially functional/useful */ |
2837 |
@@ -2015,7 +2022,7 @@ gst_ffmpegdemux_register (GstPlugin * plugin) |
2838 |
!strcmp (in_plugin->name, "wv") || |
2839 |
!strcmp (in_plugin->name, "ass") || |
2840 |
!strcmp (in_plugin->name, "ffmetadata")) |
2841 |
- goto next; |
2842 |
+ continue; |
2843 |
|
2844 |
/* Don't use the typefind functions of formats for which we already have |
2845 |
* better typefind functions */ |
2846 |
@@ -2095,7 +2102,7 @@ gst_ffmpegdemux_register (GstPlugin * plugin) |
2847 |
else { |
2848 |
GST_DEBUG ("ignoring %s", in_plugin->name); |
2849 |
rank = GST_RANK_NONE; |
2850 |
- goto next; |
2851 |
+ continue; |
2852 |
} |
2853 |
|
2854 |
/* construct the type */ |
2855 |
@@ -2105,7 +2112,7 @@ gst_ffmpegdemux_register (GstPlugin * plugin) |
2856 |
/* if it's already registered, drop it */ |
2857 |
if (g_type_from_name (type_name)) { |
2858 |
g_free (type_name); |
2859 |
- goto next; |
2860 |
+ continue; |
2861 |
} |
2862 |
|
2863 |
typefind_name = g_strdup_printf ("avtype_%s", in_plugin->name); |
2864 |
@@ -2123,8 +2130,8 @@ gst_ffmpegdemux_register (GstPlugin * plugin) |
2865 |
if (!gst_element_register (plugin, type_name, rank, type) || |
2866 |
(register_typefind_func == TRUE && |
2867 |
!gst_type_find_register (plugin, typefind_name, rank, |
2868 |
- gst_ffmpegdemux_type_find, extensions, NULL, in_plugin, |
2869 |
- NULL))) { |
2870 |
+ gst_ffmpegdemux_type_find, extensions, NULL, |
2871 |
+ (gpointer) in_plugin, NULL))) { |
2872 |
g_warning ("Registration of type %s failed", type_name); |
2873 |
g_free (type_name); |
2874 |
g_free (typefind_name); |
2875 |
@@ -2135,9 +2142,6 @@ gst_ffmpegdemux_register (GstPlugin * plugin) |
2876 |
g_free (type_name); |
2877 |
g_free (typefind_name); |
2878 |
g_free (extensions); |
2879 |
- |
2880 |
- next: |
2881 |
- in_plugin = av_iformat_next (in_plugin); |
2882 |
} |
2883 |
|
2884 |
GST_LOG ("Finished registering demuxers"); |
2885 |
--- ext/libav/gstavmux.c.orig 2018-03-23 20:45:20 UTC |
2886 |
+++ ext/libav/gstavmux.c |
2887 |
@@ -160,7 +160,7 @@ gst_ffmpegmux_get_replacement (const char *name) |
2888 |
{"mp3", "id3v2mux"}, |
2889 |
{"mp2", "id3v2mux"} |
2890 |
}; |
2891 |
- int i; |
2892 |
+ guint i; |
2893 |
|
2894 |
for (i = 0; i < sizeof (blacklist) / sizeof (blacklist[0]); i++) { |
2895 |
if (strcmp (blacklist[i].name, name) == 0) { |
2896 |
@@ -446,10 +446,10 @@ gst_ffmpegmux_request_new_pad (GstElement * element, |
2897 |
/* AVStream needs to be created */ |
2898 |
st = avformat_new_stream (ffmpegmux->context, NULL); |
2899 |
st->id = collect_pad->padnum; |
2900 |
- st->codec->codec_type = type; |
2901 |
- st->codec->codec_id = AV_CODEC_ID_NONE; /* this is a check afterwards */ |
2902 |
- st->codec->bit_rate = bitrate; |
2903 |
- st->codec->frame_size = framesize; |
2904 |
+ st->codecpar->codec_type = type; |
2905 |
+ st->codecpar->codec_id = AV_CODEC_ID_NONE; /* this is a check afterwards */ |
2906 |
+ st->codecpar->bit_rate = bitrate; |
2907 |
+ st->codecpar->frame_size = framesize; |
2908 |
/* we fill in codec during capsnego */ |
2909 |
|
2910 |
/* we love debug output (c) (tm) (r) */ |
2911 |
@@ -475,6 +475,7 @@ gst_ffmpegmux_setcaps (GstPad * pad, GstCaps * caps) |
2912 |
GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) (gst_pad_get_parent (pad)); |
2913 |
GstFFMpegMuxPad *collect_pad; |
2914 |
AVStream *st; |
2915 |
+ AVCodecContext tmp; |
2916 |
|
2917 |
collect_pad = (GstFFMpegMuxPad *) gst_pad_get_element_private (pad); |
2918 |
|
2919 |
@@ -484,12 +485,14 @@ gst_ffmpegmux_setcaps (GstPad * pad, GstCaps * caps) |
2920 |
|
2921 |
/* for the format-specific guesses, we'll go to |
2922 |
* our famous codec mapper */ |
2923 |
- if (gst_ffmpeg_caps_to_codecid (caps, st->codec) == AV_CODEC_ID_NONE) |
2924 |
+ if (gst_ffmpeg_caps_to_codecid (caps, &tmp) == AV_CODEC_ID_NONE) |
2925 |
goto not_accepted; |
2926 |
|
2927 |
+ avcodec_parameters_from_context (st->codecpar, &tmp); |
2928 |
+ |
2929 |
/* copy over the aspect ratios, ffmpeg expects the stream aspect to match the |
2930 |
* codec aspect. */ |
2931 |
- st->sample_aspect_ratio = st->codec->sample_aspect_ratio; |
2932 |
+ st->sample_aspect_ratio = st->codecpar->sample_aspect_ratio; |
2933 |
|
2934 |
GST_LOG_OBJECT (pad, "accepted caps %" GST_PTR_FORMAT, caps); |
2935 |
return TRUE; |
2936 |
@@ -563,23 +566,23 @@ gst_ffmpegmux_collected (GstCollectPads * pads, gpoint |
2937 |
AVStream *st = ffmpegmux->context->streams[collect_pad->padnum]; |
2938 |
|
2939 |
/* check whether the pad has successfully completed capsnego */ |
2940 |
- if (st->codec->codec_id == AV_CODEC_ID_NONE) { |
2941 |
+ if (st->codecpar->codec_id == AV_CODEC_ID_NONE) { |
2942 |
GST_ELEMENT_ERROR (ffmpegmux, CORE, NEGOTIATION, (NULL), |
2943 |
("no caps set on stream %d (%s)", collect_pad->padnum, |
2944 |
- (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) ? |
2945 |
+ (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) ? |
2946 |
"video" : "audio")); |
2947 |
return GST_FLOW_ERROR; |
2948 |
} |
2949 |
/* set framerate for audio */ |
2950 |
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { |
2951 |
- switch (st->codec->codec_id) { |
2952 |
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { |
2953 |
+ switch (st->codecpar->codec_id) { |
2954 |
case AV_CODEC_ID_PCM_S16LE: |
2955 |
case AV_CODEC_ID_PCM_S16BE: |
2956 |
case AV_CODEC_ID_PCM_U16LE: |
2957 |
case AV_CODEC_ID_PCM_U16BE: |
2958 |
case AV_CODEC_ID_PCM_S8: |
2959 |
case AV_CODEC_ID_PCM_U8: |
2960 |
- st->codec->frame_size = 1; |
2961 |
+ st->codecpar->frame_size = 1; |
2962 |
break; |
2963 |
default: |
2964 |
{ |
2965 |
@@ -590,8 +593,8 @@ gst_ffmpegmux_collected (GstCollectPads * pads, gpoint |
2966 |
buffer = gst_collect_pads_peek (ffmpegmux->collect, |
2967 |
(GstCollectData *) collect_pad); |
2968 |
if (buffer) { |
2969 |
- st->codec->frame_size = |
2970 |
- st->codec->sample_rate * |
2971 |
+ st->codecpar->frame_size = |
2972 |
+ st->codecpar->sample_rate * |
2973 |
GST_BUFFER_DURATION (buffer) / GST_SECOND; |
2974 |
gst_buffer_unref (buffer); |
2975 |
} |
2976 |
@@ -733,8 +736,6 @@ gst_ffmpegmux_collected (GstCollectPads * pads, gpoint |
2977 |
buf = |
2978 |
gst_collect_pads_pop (ffmpegmux->collect, (GstCollectData *) best_pad); |
2979 |
|
2980 |
- ffmpegmux->context->streams[best_pad->padnum]->codec->frame_number++; |
2981 |
- |
2982 |
/* set time */ |
2983 |
pkt.pts = gst_ffmpeg_time_gst_to_ff (GST_BUFFER_TIMESTAMP (buf), |
2984 |
ffmpegmux->context->streams[best_pad->padnum]->time_base); |
2985 |
@@ -844,7 +845,7 @@ gst_ffmpeg_mux_simple_caps_set_int_list (GstCaps * cap |
2986 |
{ |
2987 |
GValue list = { 0, }; |
2988 |
GValue val = { 0, }; |
2989 |
- gint i; |
2990 |
+ guint i; |
2991 |
|
2992 |
g_return_if_fail (GST_CAPS_IS_SIMPLE (caps)); |
2993 |
|
2994 |
@@ -880,13 +881,12 @@ gst_ffmpegmux_register (GstPlugin * plugin) |
2995 |
NULL, NULL, NULL |
2996 |
}; |
2997 |
GType type; |
2998 |
- AVOutputFormat *in_plugin; |
2999 |
+ const AVOutputFormat *in_plugin; |
3000 |
+ void *i = 0; |
3001 |
|
3002 |
- in_plugin = av_oformat_next (NULL); |
3003 |
- |
3004 |
GST_LOG ("Registering muxers"); |
3005 |
|
3006 |
- while (in_plugin) { |
3007 |
+ while ((in_plugin = av_muxer_iterate (&i))) { |
3008 |
gchar *type_name; |
3009 |
GstRank rank = GST_RANK_MARGINAL; |
3010 |
|
3011 |
@@ -925,12 +925,12 @@ gst_ffmpegmux_register (GstPlugin * plugin) |
3012 |
!strncmp (in_plugin->name, "webm", 4) |
3013 |
) { |
3014 |
GST_LOG ("Ignoring muxer %s", in_plugin->name); |
3015 |
- goto next; |
3016 |
+ continue; |
3017 |
} |
3018 |
|
3019 |
if ((!strncmp (in_plugin->long_name, "raw ", 4))) { |
3020 |
GST_LOG ("Ignoring raw muxer %s", in_plugin->name); |
3021 |
- goto next; |
3022 |
+ continue; |
3023 |
} |
3024 |
|
3025 |
if (gst_ffmpegmux_get_replacement (in_plugin->name)) |
3026 |
@@ -958,9 +958,6 @@ gst_ffmpegmux_register (GstPlugin * plugin) |
3027 |
} |
3028 |
|
3029 |
g_free (type_name); |
3030 |
- |
3031 |
- next: |
3032 |
- in_plugin = av_oformat_next (in_plugin); |
3033 |
} |
3034 |
|
3035 |
GST_LOG ("Finished registering muxers"); |
3036 |
--- ext/libav/gstavutils.c.orig 2018-03-23 20:45:20 UTC |
3037 |
+++ ext/libav/gstavutils.c |
3038 |
@@ -77,7 +77,7 @@ av_smp_format_depth (enum AVSampleFormat smp_fmt) |
3039 |
|
3040 |
|
3041 |
/* |
3042 |
- * Fill in pointers to memory in a AVPicture, where |
3043 |
+ * Fill in pointers to memory in a AVFrame, where |
3044 |
* everything is aligned by 4 (as required by X). |
3045 |
* This is mostly a copy from imgconvert.c with some |
3046 |
* small changes. |
3047 |
@@ -88,7 +88,7 @@ av_smp_format_depth (enum AVSampleFormat smp_fmt) |
3048 |
#define FF_COLOR_YUV 2 /* YUV color space. 16 <= Y <= 235, 16 <= U, V <= 240 */ |
3049 |
#define FF_COLOR_YUV_JPEG 3 /* YUV color space. 0 <= Y <= 255, 0 <= U, V <= 255 */ |
3050 |
|
3051 |
-#define FF_PIXEL_PLANAR 0 /* each channel has one component in AVPicture */ |
3052 |
+#define FF_PIXEL_PLANAR 0 /* each channel has one component in AVFrame */ |
3053 |
#define FF_PIXEL_PACKED 1 /* only one components containing all the channels */ |
3054 |
#define FF_PIXEL_PALETTE 2 /* one components containing indexes for a palette */ |
3055 |
|
3056 |
@@ -267,7 +267,7 @@ gst_ffmpeg_init_pix_fmt_info (void) |
3057 |
int |
3058 |
gst_ffmpeg_avpicture_get_size (int pix_fmt, int width, int height) |
3059 |
{ |
3060 |
- AVPicture dummy_pict; |
3061 |
+ AVFrame dummy_pict; |
3062 |
|
3063 |
return gst_ffmpeg_avpicture_fill (&dummy_pict, NULL, pix_fmt, width, height); |
3064 |
} |
3065 |
@@ -280,7 +280,7 @@ gst_ffmpeg_avpicture_get_size (int pix_fmt, int width, |
3066 |
#define DIV_ROUND_UP_X(v,x) (((v) + GEN_MASK(x)) >> (x)) |
3067 |
|
3068 |
int |
3069 |
-gst_ffmpeg_avpicture_fill (AVPicture * picture, |
3070 |
+gst_ffmpeg_avpicture_fill (AVFrame * picture, |
3071 |
uint8_t * ptr, enum AVPixelFormat pix_fmt, int width, int height) |
3072 |
{ |
3073 |
int size, w2, h2, size2; |
3074 |
--- ext/libav/gstavutils.h.orig 2018-03-23 20:45:20 UTC |
3075 |
+++ ext/libav/gstavutils.h |
3076 |
@@ -36,11 +36,11 @@ int |
3077 |
gst_ffmpeg_avpicture_get_size (int pix_fmt, int width, int height); |
3078 |
|
3079 |
/* |
3080 |
- * Fill in pointers in an AVPicture, aligned by 4 (required by X). |
3081 |
+ * Fill in pointers in an AVFrame, aligned by 4 (required by X). |
3082 |
*/ |
3083 |
|
3084 |
int |
3085 |
-gst_ffmpeg_avpicture_fill (AVPicture * picture, |
3086 |
+gst_ffmpeg_avpicture_fill (AVFrame * picture, |
3087 |
uint8_t * ptr, |
3088 |
enum AVPixelFormat pix_fmt, |
3089 |
int width, |
3090 |
--- ext/libav/gstavviddec.c.orig 2018-07-19 11:29:37 UTC |
3091 |
+++ ext/libav/gstavviddec.c |
3092 |
@@ -239,7 +239,7 @@ gst_ffmpegviddec_class_init (GstFFMpegVidDecClass * kl |
3093 |
DEFAULT_OUTPUT_CORRUPT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
3094 |
|
3095 |
caps = klass->in_plugin->capabilities; |
3096 |
- if (caps & (CODEC_CAP_FRAME_THREADS | CODEC_CAP_SLICE_THREADS)) { |
3097 |
+ if (caps & (AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_SLICE_THREADS)) { |
3098 |
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MAX_THREADS, |
3099 |
g_param_spec_int ("max-threads", "Maximum decode threads", |
3100 |
"Maximum number of worker threads to spawn. (0 = auto)", |
3101 |
@@ -317,7 +317,7 @@ static gboolean |
3102 |
gst_ffmpegviddec_close (GstFFMpegVidDec * ffmpegdec, gboolean reset) |
3103 |
{ |
3104 |
GstFFMpegVidDecClass *oclass; |
3105 |
- gint i; |
3106 |
+ guint i; |
3107 |
|
3108 |
oclass = (GstFFMpegVidDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec)); |
3109 |
|
3110 |
@@ -353,7 +353,7 @@ static gboolean |
3111 |
gst_ffmpegviddec_open (GstFFMpegVidDec * ffmpegdec) |
3112 |
{ |
3113 |
GstFFMpegVidDecClass *oclass; |
3114 |
- gint i; |
3115 |
+ guint i; |
3116 |
|
3117 |
oclass = (GstFFMpegVidDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec)); |
3118 |
|
3119 |
@@ -369,7 +369,7 @@ gst_ffmpegviddec_open (GstFFMpegVidDec * ffmpegdec) |
3120 |
oclass->in_plugin->name, oclass->in_plugin->id); |
3121 |
|
3122 |
gst_ffmpegviddec_context_set_flags (ffmpegdec->context, |
3123 |
- CODEC_FLAG_OUTPUT_CORRUPT, ffmpegdec->output_corrupt); |
3124 |
+ AV_CODEC_FLAG_OUTPUT_CORRUPT, ffmpegdec->output_corrupt); |
3125 |
|
3126 |
return TRUE; |
3127 |
|
3128 |
@@ -499,7 +499,7 @@ gst_ffmpegviddec_set_format (GstVideoDecoder * decoder |
3129 |
gboolean is_live; |
3130 |
|
3131 |
if (ffmpegdec->max_threads == 0) { |
3132 |
- if (!(oclass->in_plugin->capabilities & CODEC_CAP_AUTO_THREADS)) |
3133 |
+ if (!(oclass->in_plugin->capabilities & AV_CODEC_CAP_AUTO_THREADS)) |
3134 |
ffmpegdec->context->thread_count = gst_ffmpeg_auto_max_threads (); |
3135 |
else |
3136 |
ffmpegdec->context->thread_count = 0; |
3137 |
@@ -618,7 +618,6 @@ gst_ffmpegvideodec_prepare_dr_pool (GstFFMpegVidDec * |
3138 |
gint width, height; |
3139 |
gint linesize_align[4]; |
3140 |
gint i; |
3141 |
- guint edge; |
3142 |
gsize max_align; |
3143 |
|
3144 |
width = GST_VIDEO_INFO_WIDTH (info); |
3145 |
@@ -628,20 +627,11 @@ gst_ffmpegvideodec_prepare_dr_pool (GstFFMpegVidDec * |
3146 |
avcodec_align_dimensions2 (ffmpegdec->context, &width, &height, |
3147 |
linesize_align); |
3148 |
|
3149 |
- if (ffmpegdec->context->flags & CODEC_FLAG_EMU_EDGE) |
3150 |
- edge = 0; |
3151 |
- else |
3152 |
- edge = avcodec_get_edge_width (); |
3153 |
+ align.padding_top = 0; |
3154 |
+ align.padding_left = 0; |
3155 |
+ align.padding_right = width - GST_VIDEO_INFO_WIDTH (info); |
3156 |
+ align.padding_bottom = height - GST_VIDEO_INFO_HEIGHT (info); |
3157 |
|
3158 |
- /* increase the size for the padding */ |
3159 |
- width += edge << 1; |
3160 |
- height += edge << 1; |
3161 |
- |
3162 |
- align.padding_top = edge; |
3163 |
- align.padding_left = edge; |
3164 |
- align.padding_right = width - GST_VIDEO_INFO_WIDTH (info) - edge; |
3165 |
- align.padding_bottom = height - GST_VIDEO_INFO_HEIGHT (info) - edge; |
3166 |
- |
3167 |
/* add extra padding to match libav buffer allocation sizes */ |
3168 |
align.padding_bottom++; |
3169 |
|
3170 |
@@ -684,7 +674,7 @@ gst_ffmpegviddec_ensure_internal_pool (GstFFMpegVidDec |
3171 |
GstVideoFormat format; |
3172 |
GstCaps *caps; |
3173 |
GstStructure *config; |
3174 |
- gint i; |
3175 |
+ guint i; |
3176 |
|
3177 |
if (ffmpegdec->internal_pool != NULL && |
3178 |
ffmpegdec->pool_width == picture->width && |
3179 |
@@ -698,6 +688,12 @@ gst_ffmpegviddec_ensure_internal_pool (GstFFMpegVidDec |
3180 |
format = gst_ffmpeg_pixfmt_to_videoformat (picture->format); |
3181 |
gst_video_info_set_format (&info, format, picture->width, picture->height); |
3182 |
|
3183 |
+ /* If we have not yet been negotiated, a NONE format here would |
3184 |
+ * result in invalid initial dimension alignments, and potential |
3185 |
+ * out of bounds writes. |
3186 |
+ */ |
3187 |
+ ffmpegdec->context->pix_fmt = picture->format; |
3188 |
+ |
3189 |
for (i = 0; i < G_N_ELEMENTS (ffmpegdec->stride); i++) |
3190 |
ffmpegdec->stride[i] = -1; |
3191 |
|
3192 |
@@ -736,7 +732,8 @@ gst_ffmpegviddec_can_direct_render (GstFFMpegVidDec * |
3193 |
return FALSE; |
3194 |
|
3195 |
oclass = (GstFFMpegVidDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec)); |
3196 |
- return ((oclass->in_plugin->capabilities & CODEC_CAP_DR1) == CODEC_CAP_DR1); |
3197 |
+ return ((oclass->in_plugin->capabilities & AV_CODEC_CAP_DR1) == |
3198 |
+ AV_CODEC_CAP_DR1); |
3199 |
} |
3200 |
|
3201 |
/* called when ffmpeg wants us to allocate a buffer to write the decoded frame |
3202 |
@@ -748,7 +745,7 @@ gst_ffmpegviddec_get_buffer2 (AVCodecContext * context |
3203 |
GstVideoCodecFrame *frame; |
3204 |
GstFFMpegVidDecVideoFrame *dframe; |
3205 |
GstFFMpegVidDec *ffmpegdec; |
3206 |
- gint c; |
3207 |
+ guint c; |
3208 |
GstFlowReturn ret; |
3209 |
|
3210 |
ffmpegdec = (GstFFMpegVidDec *) context->opaque; |
3211 |
@@ -1388,7 +1385,7 @@ get_output_buffer (GstFFMpegVidDec * ffmpegdec, GstVid |
3212 |
AVFrame pic, *outpic; |
3213 |
GstVideoFrame vframe; |
3214 |
GstVideoInfo *info; |
3215 |
- gint c; |
3216 |
+ guint c; |
3217 |
|
3218 |
GST_LOG_OBJECT (ffmpegdec, "get output buffer"); |
3219 |
|
3220 |
@@ -1469,28 +1466,18 @@ gst_avpacket_init (AVPacket * packet, guint8 * data, g |
3221 |
packet->size = size; |
3222 |
} |
3223 |
|
3224 |
-/* gst_ffmpegviddec_[video|audio]_frame: |
3225 |
- * ffmpegdec: |
3226 |
- * data: pointer to the data to decode |
3227 |
- * size: size of data in bytes |
3228 |
- * in_timestamp: incoming timestamp. |
3229 |
- * in_duration: incoming duration. |
3230 |
- * in_offset: incoming offset (frame number). |
3231 |
- * ret: Return flow. |
3232 |
- * |
3233 |
- * Returns: number of bytes used in decoding. The check for successful decode is |
3234 |
- * outbuf being non-NULL. |
3235 |
+/* |
3236 |
+ * Returns: whether a frame was decoded |
3237 |
*/ |
3238 |
-static gint |
3239 |
+static gboolean |
3240 |
gst_ffmpegviddec_video_frame (GstFFMpegVidDec * ffmpegdec, |
3241 |
- guint8 * data, guint size, gint * have_data, GstVideoCodecFrame * frame, |
3242 |
- GstFlowReturn * ret) |
3243 |
+ GstVideoCodecFrame * frame, GstFlowReturn * ret) |
3244 |
{ |
3245 |
- gint len = -1; |
3246 |
+ gint res; |
3247 |
+ gboolean got_frame = FALSE; |
3248 |
gboolean mode_switch; |
3249 |
GstVideoCodecFrame *out_frame; |
3250 |
GstFFMpegVidDecVideoFrame *out_dframe; |
3251 |
- AVPacket packet; |
3252 |
GstBufferPool *pool; |
3253 |
|
3254 |
*ret = GST_FLOW_OK; |
3255 |
@@ -1502,49 +1489,25 @@ gst_ffmpegviddec_video_frame (GstFFMpegVidDec * ffmpeg |
3256 |
* else we might skip a reference frame */ |
3257 |
gst_ffmpegviddec_do_qos (ffmpegdec, frame, &mode_switch); |
3258 |
|
3259 |
- if (frame) { |
3260 |
- /* save reference to the timing info */ |
3261 |
- ffmpegdec->context->reordered_opaque = (gint64) frame->system_frame_number; |
3262 |
- ffmpegdec->picture->reordered_opaque = (gint64) frame->system_frame_number; |
3263 |
+ res = avcodec_receive_frame (ffmpegdec->context, ffmpegdec->picture); |
3264 |
|
3265 |
- GST_DEBUG_OBJECT (ffmpegdec, "stored opaque values idx %d", |
3266 |
- frame->system_frame_number); |
3267 |
+ /* No frames available at this time */ |
3268 |
+ if (res == AVERROR (EAGAIN)) |
3269 |
+ goto beach; |
3270 |
+ else if (res == AVERROR_EOF) { /* Should not happen */ |
3271 |
+ *ret = GST_FLOW_EOS; |
3272 |
+ GST_WARNING_OBJECT (ffmpegdec, |
3273 |
+ "Tried to receive frame on a flushed context"); |
3274 |
+ goto beach; |
3275 |
+ } else if (res < 0) { |
3276 |
+ *ret = GST_FLOW_ERROR; |
3277 |
+ GST_ELEMENT_ERROR (ffmpegdec, STREAM, DECODE, ("Decoding problem"), |
3278 |
+ ("Legitimate decoding error")); |
3279 |
+ goto beach; |
3280 |
} |
3281 |
|
3282 |
- /* now decode the frame */ |
3283 |
- gst_avpacket_init (&packet, data, size); |
3284 |
+ got_frame = TRUE; |
3285 |
|
3286 |
- if (ffmpegdec->palette) { |
3287 |
- guint8 *pal; |
3288 |
- |
3289 |
- pal = av_packet_new_side_data (&packet, AV_PKT_DATA_PALETTE, |
3290 |
- AVPALETTE_SIZE); |
3291 |
- gst_buffer_extract (ffmpegdec->palette, 0, pal, AVPALETTE_SIZE); |
3292 |
- GST_DEBUG_OBJECT (ffmpegdec, "copy pal %p %p", &packet, pal); |
3293 |
- } |
3294 |
- |
3295 |
- /* This might call into get_buffer() from another thread, |
3296 |
- * which would cause a deadlock. Release the lock here |
3297 |
- * and taking it again later seems safe |
3298 |
- * See https://bugzilla.gnome.org/show_bug.cgi?id=726020 |
3299 |
- */ |
3300 |
- GST_VIDEO_DECODER_STREAM_UNLOCK (ffmpegdec); |
3301 |
- len = avcodec_decode_video2 (ffmpegdec->context, |
3302 |
- ffmpegdec->picture, have_data, &packet); |
3303 |
- GST_VIDEO_DECODER_STREAM_LOCK (ffmpegdec); |
3304 |
- |
3305 |
- GST_DEBUG_OBJECT (ffmpegdec, "after decode: len %d, have_data %d", |
3306 |
- len, *have_data); |
3307 |
- |
3308 |
- /* when we are in skip_frame mode, don't complain when ffmpeg returned |
3309 |
- * no data because we told it to skip stuff. */ |
3310 |
- if (len < 0 && (mode_switch || ffmpegdec->context->skip_frame)) |
3311 |
- len = 0; |
3312 |
- |
3313 |
- /* no data, we're done */ |
3314 |
- if (len < 0 || *have_data == 0) |
3315 |
- goto beach; |
3316 |
- |
3317 |
/* get the output picture timing info again */ |
3318 |
out_dframe = ffmpegdec->picture->opaque; |
3319 |
out_frame = gst_video_codec_frame_ref (out_dframe->frame); |
3320 |
@@ -1614,8 +1577,8 @@ gst_ffmpegviddec_video_frame (GstFFMpegVidDec * ffmpeg |
3321 |
GstVideoMeta *vmeta = gst_buffer_get_video_meta (out_frame->output_buffer); |
3322 |
if (vmeta) { |
3323 |
GstVideoInfo *info = &ffmpegdec->output_state->info; |
3324 |
- g_assert (vmeta->width == GST_VIDEO_INFO_WIDTH (info)); |
3325 |
- g_assert (vmeta->height == GST_VIDEO_INFO_HEIGHT (info)); |
3326 |
+ g_assert ((gint) vmeta->width == GST_VIDEO_INFO_WIDTH (info)); |
3327 |
+ g_assert ((gint) vmeta->height == GST_VIDEO_INFO_HEIGHT (info)); |
3328 |
} |
3329 |
} |
3330 |
#endif |
3331 |
@@ -1683,16 +1646,15 @@ gst_ffmpegviddec_video_frame (GstFFMpegVidDec * ffmpeg |
3332 |
gst_video_decoder_finish_frame (GST_VIDEO_DECODER (ffmpegdec), out_frame); |
3333 |
|
3334 |
beach: |
3335 |
- GST_DEBUG_OBJECT (ffmpegdec, "return flow %s, len %d", |
3336 |
- gst_flow_get_name (*ret), len); |
3337 |
- return len; |
3338 |
+ GST_DEBUG_OBJECT (ffmpegdec, "return flow %s, got frame: %d", |
3339 |
+ gst_flow_get_name (*ret), got_frame); |
3340 |
+ return got_frame; |
3341 |
|
3342 |
/* special cases */ |
3343 |
no_output: |
3344 |
{ |
3345 |
GST_DEBUG_OBJECT (ffmpegdec, "no output buffer"); |
3346 |
gst_video_decoder_drop_frame (GST_VIDEO_DECODER (ffmpegdec), out_frame); |
3347 |
- len = -1; |
3348 |
goto beach; |
3349 |
} |
3350 |
|
3351 |
@@ -1709,50 +1671,23 @@ negotiation_error: |
3352 |
} |
3353 |
|
3354 |
|
3355 |
-/* gst_ffmpegviddec_frame: |
3356 |
- * ffmpegdec: |
3357 |
- * data: pointer to the data to decode |
3358 |
- * size: size of data in bytes |
3359 |
- * got_data: 0 if no data was decoded, != 0 otherwise. |
3360 |
- * in_time: timestamp of data |
3361 |
- * in_duration: duration of data |
3362 |
- * ret: GstFlowReturn to return in the chain function |
3363 |
- * |
3364 |
- * Decode the given frame and pushes it downstream. |
3365 |
- * |
3366 |
- * Returns: Number of bytes used in decoding, -1 on error/failure. |
3367 |
- */ |
3368 |
- |
3369 |
-static gint |
3370 |
-gst_ffmpegviddec_frame (GstFFMpegVidDec * ffmpegdec, |
3371 |
- guint8 * data, guint size, gint * have_data, GstVideoCodecFrame * frame, |
3372 |
+ /* Returns: Whether a frame was decoded */ |
3373 |
+static gboolean |
3374 |
+gst_ffmpegviddec_frame (GstFFMpegVidDec * ffmpegdec, GstVideoCodecFrame * frame, |
3375 |
GstFlowReturn * ret) |
3376 |
{ |
3377 |
- GstFFMpegVidDecClass *oclass; |
3378 |
- gint len = 0; |
3379 |
+ gboolean got_frame = FALSE; |
3380 |
|
3381 |
if (G_UNLIKELY (ffmpegdec->context->codec == NULL)) |
3382 |
goto no_codec; |
3383 |
|
3384 |
- GST_LOG_OBJECT (ffmpegdec, "data:%p, size:%d", data, size); |
3385 |
- |
3386 |
*ret = GST_FLOW_OK; |
3387 |
ffmpegdec->context->frame_number++; |
3388 |
|
3389 |
- oclass = (GstFFMpegVidDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec)); |
3390 |
+ got_frame = gst_ffmpegviddec_video_frame (ffmpegdec, frame, ret); |
3391 |
|
3392 |
- len = |
3393 |
- gst_ffmpegviddec_video_frame (ffmpegdec, data, size, have_data, frame, |
3394 |
- ret); |
3395 |
+ return got_frame; |
3396 |
|
3397 |
- if (len < 0) { |
3398 |
- GST_WARNING_OBJECT (ffmpegdec, |
3399 |
- "avdec_%s: decoding error (len: %d, have_data: %d)", |
3400 |
- oclass->in_plugin->name, len, *have_data); |
3401 |
- } |
3402 |
- |
3403 |
- return len; |
3404 |
- |
3405 |
/* ERRORS */ |
3406 |
no_codec: |
3407 |
{ |
3408 |
@@ -1773,16 +1708,16 @@ gst_ffmpegviddec_drain (GstVideoDecoder * decoder) |
3409 |
|
3410 |
oclass = (GstFFMpegVidDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec)); |
3411 |
|
3412 |
- if (oclass->in_plugin->capabilities & CODEC_CAP_DELAY) { |
3413 |
- gint have_data, len; |
3414 |
+ if (oclass->in_plugin->capabilities & AV_CODEC_CAP_DELAY) { |
3415 |
GstFlowReturn ret; |
3416 |
+ gboolean got_frame = FALSE; |
3417 |
|
3418 |
GST_LOG_OBJECT (ffmpegdec, |
3419 |
"codec has delay capabilities, calling until ffmpeg has drained everything"); |
3420 |
|
3421 |
do { |
3422 |
- len = gst_ffmpegviddec_frame (ffmpegdec, NULL, 0, &have_data, NULL, &ret); |
3423 |
- } while (len >= 0 && have_data == 1 && ret == GST_FLOW_OK); |
3424 |
+ got_frame = gst_ffmpegviddec_frame (ffmpegdec, NULL, &ret); |
3425 |
+ } while (got_frame && ret == GST_FLOW_OK); |
3426 |
} |
3427 |
|
3428 |
return GST_FLOW_OK; |
3429 |
@@ -1793,11 +1728,12 @@ gst_ffmpegviddec_handle_frame (GstVideoDecoder * decod |
3430 |
GstVideoCodecFrame * frame) |
3431 |
{ |
3432 |
GstFFMpegVidDec *ffmpegdec = (GstFFMpegVidDec *) decoder; |
3433 |
- guint8 *data, *bdata; |
3434 |
- gint size, len, have_data, bsize; |
3435 |
+ guint8 *data; |
3436 |
+ gint size; |
3437 |
+ gboolean got_frame; |
3438 |
GstMapInfo minfo; |
3439 |
GstFlowReturn ret = GST_FLOW_OK; |
3440 |
- gboolean do_padding; |
3441 |
+ AVPacket packet; |
3442 |
|
3443 |
GST_LOG_OBJECT (ffmpegdec, |
3444 |
"Received new data of size %" G_GSIZE_FORMAT ", dts %" GST_TIME_FORMAT |
3445 |
@@ -1815,94 +1751,84 @@ gst_ffmpegviddec_handle_frame (GstVideoDecoder * decod |
3446 |
GST_VIDEO_CODEC_FRAME_FLAG_SET (frame, |
3447 |
GST_VIDEO_CODEC_FRAME_FLAG_DECODE_ONLY); |
3448 |
|
3449 |
- bdata = minfo.data; |
3450 |
- bsize = minfo.size; |
3451 |
+ data = minfo.data; |
3452 |
+ size = minfo.size; |
3453 |
|
3454 |
- if (bsize > 0 && (!GST_MEMORY_IS_ZERO_PADDED (minfo.memory) |
3455 |
- || (minfo.maxsize - minfo.size) < FF_INPUT_BUFFER_PADDING_SIZE)) { |
3456 |
+ if (size > 0 && (!GST_MEMORY_IS_ZERO_PADDED (minfo.memory) |
3457 |
+ || (minfo.maxsize - minfo.size) < AV_INPUT_BUFFER_PADDING_SIZE)) { |
3458 |
/* add padding */ |
3459 |
- if (ffmpegdec->padded_size < bsize + FF_INPUT_BUFFER_PADDING_SIZE) { |
3460 |
- ffmpegdec->padded_size = bsize + FF_INPUT_BUFFER_PADDING_SIZE; |
3461 |
+ if (ffmpegdec->padded_size < size + AV_INPUT_BUFFER_PADDING_SIZE) { |
3462 |
+ ffmpegdec->padded_size = size + AV_INPUT_BUFFER_PADDING_SIZE; |
3463 |
ffmpegdec->padded = g_realloc (ffmpegdec->padded, ffmpegdec->padded_size); |
3464 |
GST_LOG_OBJECT (ffmpegdec, "resized padding buffer to %d", |
3465 |
ffmpegdec->padded_size); |
3466 |
} |
3467 |
GST_CAT_TRACE_OBJECT (GST_CAT_PERFORMANCE, ffmpegdec, |
3468 |
"Copy input to add padding"); |
3469 |
- memcpy (ffmpegdec->padded, bdata, bsize); |
3470 |
- memset (ffmpegdec->padded + bsize, 0, FF_INPUT_BUFFER_PADDING_SIZE); |
3471 |
+ memcpy (ffmpegdec->padded, data, size); |
3472 |
+ memset (ffmpegdec->padded + size, 0, AV_INPUT_BUFFER_PADDING_SIZE); |
3473 |
|
3474 |
- bdata = ffmpegdec->padded; |
3475 |
- do_padding = TRUE; |
3476 |
- } else { |
3477 |
- do_padding = FALSE; |
3478 |
+ data = ffmpegdec->padded; |
3479 |
} |
3480 |
|
3481 |
- do { |
3482 |
- guint8 tmp_padding[FF_INPUT_BUFFER_PADDING_SIZE]; |
3483 |
+ /* now decode the frame */ |
3484 |
+ gst_avpacket_init (&packet, data, size); |
3485 |
|
3486 |
- /* parse, if at all possible */ |
3487 |
- data = bdata; |
3488 |
- size = bsize; |
3489 |
+ if (ffmpegdec->palette) { |
3490 |
+ guint8 *pal; |
3491 |
|
3492 |
- if (do_padding) { |
3493 |
- /* add temporary padding */ |
3494 |
- GST_CAT_TRACE_OBJECT (GST_CAT_PERFORMANCE, ffmpegdec, |
3495 |
- "Add temporary input padding"); |
3496 |
- memcpy (tmp_padding, data + size, FF_INPUT_BUFFER_PADDING_SIZE); |
3497 |
- memset (data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE); |
3498 |
- } |
3499 |
+ pal = av_packet_new_side_data (&packet, AV_PKT_DATA_PALETTE, |
3500 |
+ AVPALETTE_SIZE); |
3501 |
+ gst_buffer_extract (ffmpegdec->palette, 0, pal, AVPALETTE_SIZE); |
3502 |
+ GST_DEBUG_OBJECT (ffmpegdec, "copy pal %p %p", &packet, pal); |
3503 |
+ } |
3504 |
|
3505 |
+ if (!packet.size) |
3506 |
+ goto done; |
3507 |
+ |
3508 |
+ if (frame) { |
3509 |
+ /* save reference to the timing info */ |
3510 |
+ ffmpegdec->context->reordered_opaque = (gint64) frame->system_frame_number; |
3511 |
+ ffmpegdec->picture->reordered_opaque = (gint64) frame->system_frame_number; |
3512 |
+ |
3513 |
+ GST_DEBUG_OBJECT (ffmpegdec, "stored opaque values idx %d", |
3514 |
+ frame->system_frame_number); |
3515 |
+ } |
3516 |
+ |
3517 |
+ /* This might call into get_buffer() from another thread, |
3518 |
+ * which would cause a deadlock. Release the lock here |
3519 |
+ * and taking it again later seems safe |
3520 |
+ * See https://bugzilla.gnome.org/show_bug.cgi?id=726020 |
3521 |
+ */ |
3522 |
+ GST_VIDEO_DECODER_STREAM_UNLOCK (ffmpegdec); |
3523 |
+ if (avcodec_send_packet (ffmpegdec->context, &packet) < 0) { |
3524 |
+ GST_VIDEO_DECODER_STREAM_LOCK (ffmpegdec); |
3525 |
+ goto send_packet_failed; |
3526 |
+ } |
3527 |
+ GST_VIDEO_DECODER_STREAM_LOCK (ffmpegdec); |
3528 |
+ |
3529 |
+ do { |
3530 |
/* decode a frame of audio/video now */ |
3531 |
- len = |
3532 |
- gst_ffmpegviddec_frame (ffmpegdec, data, size, &have_data, frame, &ret); |
3533 |
+ got_frame = gst_ffmpegviddec_frame (ffmpegdec, frame, &ret); |
3534 |
|
3535 |
if (ret != GST_FLOW_OK) { |
3536 |
GST_LOG_OBJECT (ffmpegdec, "breaking because of flow ret %s", |
3537 |
gst_flow_get_name (ret)); |
3538 |
- /* bad flow return, make sure we discard all data and exit */ |
3539 |
- bsize = 0; |
3540 |
break; |
3541 |
} |
3542 |
+ } while (got_frame); |
3543 |
|
3544 |
- if (do_padding) { |
3545 |
- memcpy (data + size, tmp_padding, FF_INPUT_BUFFER_PADDING_SIZE); |
3546 |
- } |
3547 |
- |
3548 |
- if (len == 0 && have_data == 0) { |
3549 |
- /* nothing was decoded, this could be because no data was available or |
3550 |
- * because we were skipping frames. |
3551 |
- * If we have no context we must exit and wait for more data, we keep the |
3552 |
- * data we tried. */ |
3553 |
- GST_LOG_OBJECT (ffmpegdec, "Decoding didn't return any data, breaking"); |
3554 |
- break; |
3555 |
- } |
3556 |
- |
3557 |
- if (len < 0) { |
3558 |
- /* a decoding error happened, we must break and try again with next data. */ |
3559 |
- GST_LOG_OBJECT (ffmpegdec, "Decoding error, breaking"); |
3560 |
- bsize = 0; |
3561 |
- break; |
3562 |
- } |
3563 |
- |
3564 |
- /* prepare for the next round, for codecs with a context we did this |
3565 |
- * already when using the parser. */ |
3566 |
- bsize -= len; |
3567 |
- bdata += len; |
3568 |
- |
3569 |
- do_padding = TRUE; |
3570 |
- |
3571 |
- GST_LOG_OBJECT (ffmpegdec, "Before (while bsize>0). bsize:%d , bdata:%p", |
3572 |
- bsize, bdata); |
3573 |
- } while (bsize > 0); |
3574 |
- |
3575 |
- if (bsize > 0) |
3576 |
- GST_DEBUG_OBJECT (ffmpegdec, "Dropping %d bytes of data", bsize); |
3577 |
- |
3578 |
+done: |
3579 |
gst_buffer_unmap (frame->input_buffer, &minfo); |
3580 |
gst_video_codec_frame_unref (frame); |
3581 |
|
3582 |
return ret; |
3583 |
+ |
3584 |
+send_packet_failed: |
3585 |
+ { |
3586 |
+ GST_WARNING_OBJECT (ffmpegdec, "Failed to send data for decoding"); |
3587 |
+ goto done; |
3588 |
+ } |
3589 |
} |
3590 |
|
3591 |
static gboolean |
3592 |
@@ -2069,7 +1995,7 @@ gst_ffmpegviddec_decide_allocation (GstVideoDecoder * |
3593 |
if (ret == GST_FLOW_OK) { |
3594 |
GstVideoMeta *vmeta = gst_buffer_get_video_meta (tmp); |
3595 |
gboolean same_stride = TRUE; |
3596 |
- gint i; |
3597 |
+ guint i; |
3598 |
|
3599 |
for (i = 0; i < vmeta->n_planes; i++) { |
3600 |
if (vmeta->stride[i] != ffmpegdec->stride[i]) { |
3601 |
@@ -2147,7 +2073,7 @@ gst_ffmpegviddec_propose_allocation (GstVideoDecoder * |
3602 |
gst_allocation_params_init (¶ms); |
3603 |
params.flags = GST_MEMORY_FLAG_ZERO_PADDED; |
3604 |
params.align = DEFAULT_STRIDE_ALIGN; |
3605 |
- params.padding = FF_INPUT_BUFFER_PADDING_SIZE; |
3606 |
+ params.padding = AV_INPUT_BUFFER_PADDING_SIZE; |
3607 |
/* we would like to have some padding so that we don't have to |
3608 |
* memcpy. We don't suggest an allocator. */ |
3609 |
gst_query_add_allocation_param (query, NULL, ¶ms); |
3610 |
@@ -2237,19 +2163,18 @@ gst_ffmpegviddec_register (GstPlugin * plugin) |
3611 |
GType type; |
3612 |
AVCodec *in_plugin; |
3613 |
gint rank; |
3614 |
+ void *i = 0; |
3615 |
|
3616 |
- in_plugin = av_codec_next (NULL); |
3617 |
- |
3618 |
GST_LOG ("Registering decoders"); |
3619 |
|
3620 |
- while (in_plugin) { |
3621 |
+ while ((in_plugin = (AVCodec *) av_codec_iterate (&i))) { |
3622 |
gchar *type_name; |
3623 |
gchar *plugin_name; |
3624 |
|
3625 |
/* only video decoders */ |
3626 |
if (!av_codec_is_decoder (in_plugin) |
3627 |
|| in_plugin->type != AVMEDIA_TYPE_VIDEO) |
3628 |
- goto next; |
3629 |
+ continue; |
3630 |
|
3631 |
/* no quasi codecs, please */ |
3632 |
if (in_plugin->id == AV_CODEC_ID_RAWVIDEO || |
3633 |
@@ -2268,7 +2193,7 @@ gst_ffmpegviddec_register (GstPlugin * plugin) |
3634 |
|| in_plugin->id == AV_CODEC_ID_WRAPPED_AVFRAME |
3635 |
#endif |
3636 |
|| in_plugin->id == AV_CODEC_ID_ZLIB) { |
3637 |
- goto next; |
3638 |
+ continue; |
3639 |
} |
3640 |
|
3641 |
/* No decoders depending on external libraries (we don't build them, but |
3642 |
@@ -2278,7 +2203,7 @@ gst_ffmpegviddec_register (GstPlugin * plugin) |
3643 |
GST_DEBUG |
3644 |
("Not using external library decoder %s. Use the gstreamer-native ones instead.", |
3645 |
in_plugin->name); |
3646 |
- goto next; |
3647 |
+ continue; |
3648 |
} |
3649 |
|
3650 |
/* No vdpau plugins until we can figure out how to properly use them |
3651 |
@@ -2287,42 +2212,42 @@ gst_ffmpegviddec_register (GstPlugin * plugin) |
3652 |
GST_DEBUG |
3653 |
("Ignoring VDPAU decoder %s. We can't handle this outside of ffmpeg", |
3654 |
in_plugin->name); |
3655 |
- goto next; |
3656 |
+ continue; |
3657 |
} |
3658 |
|
3659 |
if (g_str_has_suffix (in_plugin->name, "_xvmc")) { |
3660 |
GST_DEBUG |
3661 |
("Ignoring XVMC decoder %s. We can't handle this outside of ffmpeg", |
3662 |
in_plugin->name); |
3663 |
- goto next; |
3664 |
+ continue; |
3665 |
} |
3666 |
|
3667 |
if (strstr (in_plugin->name, "vaapi")) { |
3668 |
GST_DEBUG |
3669 |
("Ignoring VAAPI decoder %s. We can't handle this outside of ffmpeg", |
3670 |
in_plugin->name); |
3671 |
- goto next; |
3672 |
+ continue; |
3673 |
} |
3674 |
|
3675 |
if (g_str_has_suffix (in_plugin->name, "_qsv")) { |
3676 |
GST_DEBUG |
3677 |
("Ignoring qsv decoder %s. We can't handle this outside of ffmpeg", |
3678 |
in_plugin->name); |
3679 |
- goto next; |
3680 |
+ continue; |
3681 |
} |
3682 |
|
3683 |
if (g_str_has_suffix (in_plugin->name, "_cuvid")) { |
3684 |
GST_DEBUG |
3685 |
("Ignoring CUVID decoder %s. We can't handle this outside of ffmpeg", |
3686 |
in_plugin->name); |
3687 |
- goto next; |
3688 |
+ continue; |
3689 |
} |
3690 |
|
3691 |
if (g_str_has_suffix (in_plugin->name, "_v4l2m2m")) { |
3692 |
GST_DEBUG |
3693 |
("Ignoring V4L2 mem-to-mem decoder %s. We can't handle this outside of ffmpeg", |
3694 |
in_plugin->name); |
3695 |
- goto next; |
3696 |
+ continue; |
3697 |
} |
3698 |
|
3699 |
GST_DEBUG ("Trying plugin %s [%s]", in_plugin->name, in_plugin->long_name); |
3700 |
@@ -2341,7 +2266,7 @@ gst_ffmpegviddec_register (GstPlugin * plugin) |
3701 |
!strcmp (in_plugin->name, "dvdsub") || |
3702 |
!strcmp (in_plugin->name, "dvbsub")) { |
3703 |
GST_LOG ("Ignoring decoder %s", in_plugin->name); |
3704 |
- goto next; |
3705 |
+ continue; |
3706 |
} |
3707 |
|
3708 |
/* construct the type */ |
3709 |
@@ -2399,9 +2324,6 @@ gst_ffmpegviddec_register (GstPlugin * plugin) |
3710 |
} |
3711 |
|
3712 |
g_free (type_name); |
3713 |
- |
3714 |
- next: |
3715 |
- in_plugin = av_codec_next (in_plugin); |
3716 |
} |
3717 |
|
3718 |
GST_LOG ("Finished Registering decoders"); |
3719 |
--- ext/libav/gstavviddec.h.orig 2018-03-23 20:45:20 UTC |
3720 |
+++ ext/libav/gstavviddec.h |
3721 |
@@ -61,7 +61,7 @@ struct _GstFFMpegVidDec |
3722 |
GstBuffer *palette; |
3723 |
|
3724 |
guint8 *padded; |
3725 |
- guint padded_size; |
3726 |
+ gint padded_size; |
3727 |
|
3728 |
/* some properties */ |
3729 |
enum AVDiscard skip_frame; |
3730 |
--- ext/libav/gstavvidenc.c.orig 2018-03-23 20:45:20 UTC |
3731 |
+++ ext/libav/gstavvidenc.c |
3732 |
@@ -30,6 +30,7 @@ |
3733 |
|
3734 |
#include <libavcodec/avcodec.h> |
3735 |
#include <libavutil/stereo3d.h> |
3736 |
+#include <libavutil/opt.h> |
3737 |
|
3738 |
#include <gst/gst.h> |
3739 |
#include <gst/video/gstvideometa.h> |
3740 |
@@ -40,56 +41,16 @@ |
3741 |
#include "gstavvidenc.h" |
3742 |
#include "gstavcfg.h" |
3743 |
|
3744 |
-#define DEFAULT_VIDEO_BITRATE 300000 /* in bps */ |
3745 |
-#define DEFAULT_VIDEO_GOP_SIZE 15 |
3746 |
|
3747 |
-#define DEFAULT_WIDTH 352 |
3748 |
-#define DEFAULT_HEIGHT 288 |
3749 |
- |
3750 |
- |
3751 |
-#define VIDEO_BUFFER_SIZE (1024*1024) |
3752 |
- |
3753 |
enum |
3754 |
{ |
3755 |
- /* FILL ME */ |
3756 |
- LAST_SIGNAL |
3757 |
-}; |
3758 |
- |
3759 |
-enum |
3760 |
-{ |
3761 |
PROP_0, |
3762 |
- PROP_BIT_RATE, |
3763 |
- PROP_GOP_SIZE, |
3764 |
- PROP_ME_METHOD, |
3765 |
- PROP_BUFSIZE, |
3766 |
- PROP_RTP_PAYLOAD_SIZE, |
3767 |
- PROP_MAX_THREADS, |
3768 |
- PROP_COMPLIANCE, |
3769 |
+ PROP_QUANTIZER, |
3770 |
+ PROP_PASS, |
3771 |
+ PROP_FILENAME, |
3772 |
PROP_CFG_BASE, |
3773 |
}; |
3774 |
|
3775 |
-#define GST_TYPE_ME_METHOD (gst_ffmpegvidenc_me_method_get_type()) |
3776 |
-static GType |
3777 |
-gst_ffmpegvidenc_me_method_get_type (void) |
3778 |
-{ |
3779 |
- static GType ffmpegenc_me_method_type = 0; |
3780 |
- static GEnumValue ffmpegenc_me_methods[] = { |
3781 |
- {ME_ZERO, "None (Very low quality)", "zero"}, |
3782 |
- {ME_FULL, "Full (Slow, unmaintained)", "full"}, |
3783 |
- {ME_LOG, "Logarithmic (Low quality, unmaintained)", "logarithmic"}, |
3784 |
- {ME_PHODS, "phods (Low quality, unmaintained)", "phods"}, |
3785 |
- {ME_EPZS, "EPZS (Best quality, Fast)", "epzs"}, |
3786 |
- {ME_X1, "X1 (Experimental)", "x1"}, |
3787 |
- {0, NULL, NULL}, |
3788 |
- }; |
3789 |
- if (!ffmpegenc_me_method_type) { |
3790 |
- ffmpegenc_me_method_type = |
3791 |
- g_enum_register_static ("GstLibAVVidEncMeMethod", ffmpegenc_me_methods); |
3792 |
- } |
3793 |
- return ffmpegenc_me_method_type; |
3794 |
-} |
3795 |
- |
3796 |
-/* A number of function prototypes are given so we can refer to them later. */ |
3797 |
static void gst_ffmpegvidenc_class_init (GstFFMpegVidEncClass * klass); |
3798 |
static void gst_ffmpegvidenc_base_init (GstFFMpegVidEncClass * klass); |
3799 |
static void gst_ffmpegvidenc_init (GstFFMpegVidEnc * ffmpegenc); |
3800 |
@@ -116,8 +77,28 @@ static void gst_ffmpegvidenc_get_property (GObject * o |
3801 |
|
3802 |
static GstElementClass *parent_class = NULL; |
3803 |
|
3804 |
-/*static guint gst_ffmpegvidenc_signals[LAST_SIGNAL] = { 0 }; */ |
3805 |
+#define GST_TYPE_FFMPEG_PASS (gst_ffmpeg_pass_get_type ()) |
3806 |
+static GType |
3807 |
+gst_ffmpeg_pass_get_type (void) |
3808 |
+{ |
3809 |
+ static GType ffmpeg_pass_type = 0; |
3810 |
|
3811 |
+ if (!ffmpeg_pass_type) { |
3812 |
+ static const GEnumValue ffmpeg_passes[] = { |
3813 |
+ {0, "Constant Bitrate Encoding", "cbr"}, |
3814 |
+ {AV_CODEC_FLAG_QSCALE, "Constant Quantizer", "quant"}, |
3815 |
+ {AV_CODEC_FLAG_PASS1, "VBR Encoding - Pass 1", "pass1"}, |
3816 |
+ {AV_CODEC_FLAG_PASS2, "VBR Encoding - Pass 2", "pass2"}, |
3817 |
+ {0, NULL, NULL}, |
3818 |
+ }; |
3819 |
+ |
3820 |
+ ffmpeg_pass_type = |
3821 |
+ g_enum_register_static ("GstLibAVEncPass", ffmpeg_passes); |
3822 |
+ } |
3823 |
+ |
3824 |
+ return ffmpeg_pass_type; |
3825 |
+} |
3826 |
+ |
3827 |
static void |
3828 |
gst_ffmpegvidenc_base_init (GstFFMpegVidEncClass * klass) |
3829 |
{ |
3830 |
@@ -181,7 +162,6 @@ gst_ffmpegvidenc_class_init (GstFFMpegVidEncClass * kl |
3831 |
{ |
3832 |
GObjectClass *gobject_class; |
3833 |
GstVideoEncoderClass *venc_class; |
3834 |
- int caps; |
3835 |
|
3836 |
gobject_class = (GObjectClass *) klass; |
3837 |
venc_class = (GstVideoEncoderClass *) klass; |
3838 |
@@ -191,46 +171,24 @@ gst_ffmpegvidenc_class_init (GstFFMpegVidEncClass * kl |
3839 |
gobject_class->set_property = gst_ffmpegvidenc_set_property; |
3840 |
gobject_class->get_property = gst_ffmpegvidenc_get_property; |
3841 |
|
3842 |
- /* FIXME: could use -1 for a sensible per-codec default based on |
3843 |
- * e.g. input resolution and framerate */ |
3844 |
- g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BIT_RATE, |
3845 |
- g_param_spec_int ("bitrate", "Bit Rate", |
3846 |
- "Target Video Bitrate", 0, G_MAXINT, DEFAULT_VIDEO_BITRATE, |
3847 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
3848 |
- g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_GOP_SIZE, |
3849 |
- g_param_spec_int ("gop-size", "GOP Size", |
3850 |
- "Number of frames within one GOP", 0, G_MAXINT, |
3851 |
- DEFAULT_VIDEO_GOP_SIZE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
3852 |
- g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_ME_METHOD, |
3853 |
- g_param_spec_enum ("me-method", "ME Method", "Motion Estimation Method", |
3854 |
- GST_TYPE_ME_METHOD, ME_EPZS, |
3855 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
3856 |
+ g_object_class_install_property (gobject_class, PROP_QUANTIZER, |
3857 |
+ g_param_spec_float ("quantizer", "Constant Quantizer", |
3858 |
+ "Constant Quantizer", 0, 30, 0.01f, |
3859 |
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT)); |
3860 |
|
3861 |
- g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BUFSIZE, |
3862 |
- g_param_spec_int ("buffer-size", "Buffer Size", |
3863 |
- "Size of the video buffers", 0, G_MAXINT, 0, |
3864 |
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); |
3865 |
- g_object_class_install_property (G_OBJECT_CLASS (klass), |
3866 |
- PROP_RTP_PAYLOAD_SIZE, g_param_spec_int ("rtp-payload-size", |
3867 |
- "RTP Payload Size", "Target GOB length", 0, G_MAXINT, 0, |
3868 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
3869 |
+ g_object_class_install_property (gobject_class, PROP_PASS, |
3870 |
+ g_param_spec_enum ("pass", "Encoding pass/type", |
3871 |
+ "Encoding pass/type", GST_TYPE_FFMPEG_PASS, 0, |
3872 |
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT)); |
3873 |
|
3874 |
- caps = klass->in_plugin->capabilities; |
3875 |
- if (caps & (CODEC_CAP_FRAME_THREADS | CODEC_CAP_SLICE_THREADS)) { |
3876 |
- g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MAX_THREADS, |
3877 |
- g_param_spec_int ("max-threads", "Maximum encode threads", |
3878 |
- "Maximum number of worker threads to spawn. (0 = auto)", |
3879 |
- 0, G_MAXINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
3880 |
- } |
3881 |
+ g_object_class_install_property (gobject_class, PROP_FILENAME, |
3882 |
+ g_param_spec_string ("multipass-cache-file", "Multipass Cache File", |
3883 |
+ "Filename for multipass cache file", "stats.log", |
3884 |
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT)); |
3885 |
|
3886 |
- g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_COMPLIANCE, |
3887 |
- g_param_spec_enum ("compliance", "Compliance", |
3888 |
- "Adherence of the encoder to the specifications", |
3889 |
- GST_TYPE_FFMPEG_COMPLIANCE, FFMPEG_DEFAULT_COMPLIANCE, |
3890 |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
3891 |
- |
3892 |
/* register additional properties, possibly dependent on the exact CODEC */ |
3893 |
- gst_ffmpeg_cfg_install_property (klass, PROP_CFG_BASE); |
3894 |
+ gst_ffmpeg_cfg_install_properties (gobject_class, klass->in_plugin, |
3895 |
+ PROP_CFG_BASE, AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM); |
3896 |
|
3897 |
venc_class->start = gst_ffmpegvidenc_start; |
3898 |
venc_class->stop = gst_ffmpegvidenc_stop; |
3899 |
@@ -251,26 +209,11 @@ gst_ffmpegvidenc_init (GstFFMpegVidEnc * ffmpegenc) |
3900 |
|
3901 |
GST_PAD_SET_ACCEPT_TEMPLATE (GST_VIDEO_ENCODER_SINK_PAD (ffmpegenc)); |
3902 |
|
3903 |
- /* ffmpeg objects */ |
3904 |
ffmpegenc->context = avcodec_alloc_context3 (klass->in_plugin); |
3905 |
+ ffmpegenc->refcontext = avcodec_alloc_context3 (klass->in_plugin); |
3906 |
ffmpegenc->picture = av_frame_alloc (); |
3907 |
ffmpegenc->opened = FALSE; |
3908 |
- |
3909 |
ffmpegenc->file = NULL; |
3910 |
- |
3911 |
- ffmpegenc->bitrate = DEFAULT_VIDEO_BITRATE; |
3912 |
- ffmpegenc->me_method = ME_EPZS; |
3913 |
- ffmpegenc->buffer_size = 512 * 1024; |
3914 |
- ffmpegenc->gop_size = DEFAULT_VIDEO_GOP_SIZE; |
3915 |
- ffmpegenc->rtp_payload_size = 0; |
3916 |
- ffmpegenc->compliance = FFMPEG_DEFAULT_COMPLIANCE; |
3917 |
- ffmpegenc->max_threads = 0; |
3918 |
- |
3919 |
- ffmpegenc->lmin = 2; |
3920 |
- ffmpegenc->lmax = 31; |
3921 |
- ffmpegenc->max_key_interval = 0; |
3922 |
- |
3923 |
- gst_ffmpeg_cfg_set_defaults (ffmpegenc); |
3924 |
} |
3925 |
|
3926 |
static void |
3927 |
@@ -278,15 +221,12 @@ gst_ffmpegvidenc_finalize (GObject * object) |
3928 |
{ |
3929 |
GstFFMpegVidEnc *ffmpegenc = (GstFFMpegVidEnc *) object; |
3930 |
|
3931 |
- gst_ffmpeg_cfg_finalize (ffmpegenc); |
3932 |
- |
3933 |
/* clean up remaining allocated data */ |
3934 |
av_frame_free (&ffmpegenc->picture); |
3935 |
gst_ffmpeg_avcodec_close (ffmpegenc->context); |
3936 |
av_free (ffmpegenc->context); |
3937 |
+ av_free (ffmpegenc->refcontext); |
3938 |
|
3939 |
- g_free (ffmpegenc->filename); |
3940 |
- |
3941 |
G_OBJECT_CLASS (parent_class)->finalize (object); |
3942 |
} |
3943 |
|
3944 |
@@ -314,66 +254,25 @@ gst_ffmpegvidenc_set_format (GstVideoEncoder * encoder |
3945 |
} |
3946 |
} |
3947 |
|
3948 |
- /* if we set it in _getcaps we should set it also in _link */ |
3949 |
- ffmpegenc->context->strict_std_compliance = ffmpegenc->compliance; |
3950 |
- |
3951 |
- /* user defined properties */ |
3952 |
- ffmpegenc->context->bit_rate = ffmpegenc->bitrate; |
3953 |
- ffmpegenc->context->bit_rate_tolerance = ffmpegenc->bitrate; |
3954 |
- ffmpegenc->context->gop_size = ffmpegenc->gop_size; |
3955 |
- ffmpegenc->context->me_method = ffmpegenc->me_method; |
3956 |
- GST_DEBUG_OBJECT (ffmpegenc, "Setting avcontext to bitrate %d, gop_size %d", |
3957 |
- ffmpegenc->bitrate, ffmpegenc->gop_size); |
3958 |
- |
3959 |
- if (ffmpegenc->max_threads == 0) { |
3960 |
- if (!(oclass->in_plugin->capabilities & CODEC_CAP_AUTO_THREADS)) |
3961 |
- ffmpegenc->context->thread_count = gst_ffmpeg_auto_max_threads (); |
3962 |
- else |
3963 |
- ffmpegenc->context->thread_count = 0; |
3964 |
- } else |
3965 |
- ffmpegenc->context->thread_count = ffmpegenc->max_threads; |
3966 |
- |
3967 |
- /* RTP payload used for GOB production (for Asterisk) */ |
3968 |
- if (ffmpegenc->rtp_payload_size) { |
3969 |
- ffmpegenc->context->rtp_payload_size = ffmpegenc->rtp_payload_size; |
3970 |
- } |
3971 |
- |
3972 |
/* additional avcodec settings */ |
3973 |
- /* first fill in the majority by copying over */ |
3974 |
- gst_ffmpeg_cfg_fill_context (ffmpegenc, ffmpegenc->context); |
3975 |
+ gst_ffmpeg_cfg_fill_context (G_OBJECT (ffmpegenc), ffmpegenc->context); |
3976 |
|
3977 |
- /* then handle some special cases */ |
3978 |
- ffmpegenc->context->lmin = (ffmpegenc->lmin * FF_QP2LAMBDA + 0.5); |
3979 |
- ffmpegenc->context->lmax = (ffmpegenc->lmax * FF_QP2LAMBDA + 0.5); |
3980 |
- |
3981 |
- if (ffmpegenc->interlaced) { |
3982 |
- ffmpegenc->context->flags |= |
3983 |
- CODEC_FLAG_INTERLACED_DCT | CODEC_FLAG_INTERLACED_ME; |
3984 |
- } |
3985 |
- |
3986 |
- /* some other defaults */ |
3987 |
- ffmpegenc->context->rc_strategy = 2; |
3988 |
- ffmpegenc->context->b_frame_strategy = 0; |
3989 |
- ffmpegenc->context->coder_type = 0; |
3990 |
- ffmpegenc->context->context_model = 0; |
3991 |
- ffmpegenc->context->scenechange_threshold = 0; |
3992 |
- |
3993 |
/* and last but not least the pass; CBR, 2-pass, etc */ |
3994 |
ffmpegenc->context->flags |= ffmpegenc->pass; |
3995 |
switch (ffmpegenc->pass) { |
3996 |
/* some additional action depends on type of pass */ |
3997 |
- case CODEC_FLAG_QSCALE: |
3998 |
+ case AV_CODEC_FLAG_QSCALE: |
3999 |
ffmpegenc->context->global_quality |
4000 |
= ffmpegenc->picture->quality = FF_QP2LAMBDA * ffmpegenc->quantizer; |
4001 |
break; |
4002 |
- case CODEC_FLAG_PASS1: /* need to prepare a stats file */ |
4003 |
+ case AV_CODEC_FLAG_PASS1: /* need to prepare a stats file */ |
4004 |
/* we don't close when changing caps, fingers crossed */ |
4005 |
if (!ffmpegenc->file) |
4006 |
ffmpegenc->file = g_fopen (ffmpegenc->filename, "w"); |
4007 |
if (!ffmpegenc->file) |
4008 |
goto open_file_err; |
4009 |
break; |
4010 |
- case CODEC_FLAG_PASS2: |
4011 |
+ case AV_CODEC_FLAG_PASS2: |
4012 |
{ /* need to read the whole stats file ! */ |
4013 |
gsize size; |
4014 |
|
4015 |
@@ -412,18 +311,6 @@ gst_ffmpegvidenc_set_format (GstVideoEncoder * encoder |
4016 |
|
4017 |
pix_fmt = ffmpegenc->context->pix_fmt; |
4018 |
|
4019 |
- /* max-key-interval may need the framerate set above */ |
4020 |
- if (ffmpegenc->max_key_interval) { |
4021 |
- AVCodecContext *ctx; |
4022 |
- |
4023 |
- /* override gop-size */ |
4024 |
- ctx = ffmpegenc->context; |
4025 |
- ctx->gop_size = (ffmpegenc->max_key_interval < 0) ? |
4026 |
- (-ffmpegenc->max_key_interval |
4027 |
- * (ctx->time_base.den * ctx->ticks_per_frame / ctx->time_base.num)) |
4028 |
- : ffmpegenc->max_key_interval; |
4029 |
- } |
4030 |
- |
4031 |
/* some codecs support more than one format, first auto-choose one */ |
4032 |
GST_DEBUG_OBJECT (ffmpegenc, "picking an output format ..."); |
4033 |
allowed_caps = gst_pad_get_allowed_caps (GST_VIDEO_ENCODER_SRC_PAD (encoder)); |
4034 |
@@ -634,26 +521,31 @@ stereo_gst_to_av (GstVideoMultiviewMode mview_mode) |
4035 |
} |
4036 |
|
4037 |
static GstFlowReturn |
4038 |
-gst_ffmpegvidenc_handle_frame (GstVideoEncoder * encoder, |
4039 |
+gst_ffmpegvidenc_send_frame (GstFFMpegVidEnc * ffmpegenc, |
4040 |
GstVideoCodecFrame * frame) |
4041 |
{ |
4042 |
- GstFFMpegVidEnc *ffmpegenc = (GstFFMpegVidEnc *) encoder; |
4043 |
- GstBuffer *outbuf; |
4044 |
- gint ret = 0, c; |
4045 |
GstVideoInfo *info = &ffmpegenc->input_state->info; |
4046 |
- AVPacket *pkt; |
4047 |
- int have_data = 0; |
4048 |
BufferInfo *buffer_info; |
4049 |
+ guint c; |
4050 |
+ gint res; |
4051 |
+ GstFlowReturn ret = GST_FLOW_ERROR; |
4052 |
+ AVFrame *picture = NULL; |
4053 |
|
4054 |
- if (ffmpegenc->interlaced) { |
4055 |
- ffmpegenc->picture->interlaced_frame = TRUE; |
4056 |
+ if (!frame) |
4057 |
+ goto send_frame; |
4058 |
+ |
4059 |
+ picture = ffmpegenc->picture; |
4060 |
+ |
4061 |
+ if (ffmpegenc->context->flags & (AV_CODEC_FLAG_INTERLACED_DCT | |
4062 |
+ AV_CODEC_FLAG_INTERLACED_ME)) { |
4063 |
+ picture->interlaced_frame = TRUE; |
4064 |
/* if this is not the case, a filter element should be used to swap fields */ |
4065 |
- ffmpegenc->picture->top_field_first = |
4066 |
+ picture->top_field_first = |
4067 |
GST_BUFFER_FLAG_IS_SET (frame->input_buffer, GST_VIDEO_BUFFER_FLAG_TFF); |
4068 |
} |
4069 |
|
4070 |
if (GST_VIDEO_INFO_MULTIVIEW_MODE (info) != GST_VIDEO_MULTIVIEW_MODE_NONE) { |
4071 |
- AVStereo3D *stereo = av_stereo3d_create_side_data (ffmpegenc->picture); |
4072 |
+ AVStereo3D *stereo = av_stereo3d_create_side_data (picture); |
4073 |
stereo->type = stereo_gst_to_av (GST_VIDEO_INFO_MULTIVIEW_MODE (info)); |
4074 |
|
4075 |
if (GST_VIDEO_INFO_MULTIVIEW_FLAGS (info) & |
4076 |
@@ -663,64 +555,86 @@ gst_ffmpegvidenc_handle_frame (GstVideoEncoder * encod |
4077 |
} |
4078 |
|
4079 |
if (GST_VIDEO_CODEC_FRAME_IS_FORCE_KEYFRAME (frame)) |
4080 |
- ffmpegenc->picture->pict_type = AV_PICTURE_TYPE_I; |
4081 |
+ picture->pict_type = AV_PICTURE_TYPE_I; |
4082 |
|
4083 |
buffer_info = g_slice_new0 (BufferInfo); |
4084 |
buffer_info->buffer = gst_buffer_ref (frame->input_buffer); |
4085 |
|
4086 |
if (!gst_video_frame_map (&buffer_info->vframe, info, frame->input_buffer, |
4087 |
GST_MAP_READ)) { |
4088 |
- GST_ERROR_OBJECT (encoder, "Failed to map input buffer"); |
4089 |
+ GST_ERROR_OBJECT (ffmpegenc, "Failed to map input buffer"); |
4090 |
gst_buffer_unref (buffer_info->buffer); |
4091 |
g_slice_free (BufferInfo, buffer_info); |
4092 |
gst_video_codec_frame_unref (frame); |
4093 |
- return GST_FLOW_ERROR; |
4094 |
+ goto done; |
4095 |
} |
4096 |
|
4097 |
/* Fill avpicture */ |
4098 |
- ffmpegenc->picture->buf[0] = |
4099 |
+ picture->buf[0] = |
4100 |
av_buffer_create (NULL, 0, buffer_info_free, buffer_info, 0); |
4101 |
for (c = 0; c < AV_NUM_DATA_POINTERS; c++) { |
4102 |
if (c < GST_VIDEO_INFO_N_COMPONENTS (info)) { |
4103 |
- ffmpegenc->picture->data[c] = |
4104 |
- GST_VIDEO_FRAME_PLANE_DATA (&buffer_info->vframe, c); |
4105 |
- ffmpegenc->picture->linesize[c] = |
4106 |
+ picture->data[c] = GST_VIDEO_FRAME_PLANE_DATA (&buffer_info->vframe, c); |
4107 |
+ picture->linesize[c] = |
4108 |
GST_VIDEO_FRAME_COMP_STRIDE (&buffer_info->vframe, c); |
4109 |
} else { |
4110 |
- ffmpegenc->picture->data[c] = NULL; |
4111 |
- ffmpegenc->picture->linesize[c] = 0; |
4112 |
+ picture->data[c] = NULL; |
4113 |
+ picture->linesize[c] = 0; |
4114 |
} |
4115 |
} |
4116 |
|
4117 |
- ffmpegenc->picture->format = ffmpegenc->context->pix_fmt; |
4118 |
- ffmpegenc->picture->width = GST_VIDEO_FRAME_WIDTH (&buffer_info->vframe); |
4119 |
- ffmpegenc->picture->height = GST_VIDEO_FRAME_HEIGHT (&buffer_info->vframe); |
4120 |
+ picture->format = ffmpegenc->context->pix_fmt; |
4121 |
+ picture->width = GST_VIDEO_FRAME_WIDTH (&buffer_info->vframe); |
4122 |
+ picture->height = GST_VIDEO_FRAME_HEIGHT (&buffer_info->vframe); |
4123 |
|
4124 |
- ffmpegenc->picture->pts = |
4125 |
+ picture->pts = |
4126 |
gst_ffmpeg_time_gst_to_ff (frame->pts / |
4127 |
ffmpegenc->context->ticks_per_frame, ffmpegenc->context->time_base); |
4128 |
|
4129 |
- have_data = 0; |
4130 |
- pkt = g_slice_new0 (AVPacket); |
4131 |
+send_frame: |
4132 |
+ res = avcodec_send_frame (ffmpegenc->context, picture); |
4133 |
|
4134 |
- ret = |
4135 |
- avcodec_encode_video2 (ffmpegenc->context, pkt, ffmpegenc->picture, |
4136 |
- &have_data); |
4137 |
+ if (picture) |
4138 |
+ av_frame_unref (picture); |
4139 |
|
4140 |
- av_frame_unref (ffmpegenc->picture); |
4141 |
+ if (res == 0) |
4142 |
+ ret = GST_FLOW_OK; |
4143 |
+ else if (res == AVERROR_EOF) |
4144 |
+ ret = GST_FLOW_EOS; |
4145 |
|
4146 |
- if (ret < 0 || !have_data) |
4147 |
- g_slice_free (AVPacket, pkt); |
4148 |
+done: |
4149 |
+ return ret; |
4150 |
+} |
4151 |
|
4152 |
- if (ret < 0) |
4153 |
- goto encode_fail; |
4154 |
+static GstFlowReturn |
4155 |
+gst_ffmpegvidenc_receive_packet (GstFFMpegVidEnc * ffmpegenc, |
4156 |
+ gboolean * got_packet, gboolean send) |
4157 |
+{ |
4158 |
+ AVPacket *pkt; |
4159 |
+ GstBuffer *outbuf; |
4160 |
+ GstVideoCodecFrame *frame; |
4161 |
+ gint res; |
4162 |
+ GstFlowReturn ret = GST_FLOW_OK; |
4163 |
|
4164 |
- /* Encoder needs more data */ |
4165 |
- if (!have_data) { |
4166 |
- gst_video_codec_frame_unref (frame); |
4167 |
- return GST_FLOW_OK; |
4168 |
+ *got_packet = FALSE; |
4169 |
+ |
4170 |
+ pkt = g_slice_new0 (AVPacket); |
4171 |
+ |
4172 |
+ res = avcodec_receive_packet (ffmpegenc->context, pkt); |
4173 |
+ |
4174 |
+ if (res == AVERROR (EAGAIN)) { |
4175 |
+ g_slice_free (AVPacket, pkt); |
4176 |
+ goto done; |
4177 |
+ } else if (res == AVERROR_EOF) { |
4178 |
+ ret = GST_FLOW_EOS; |
4179 |
+ goto done; |
4180 |
+ } else if (res < 0) { |
4181 |
+ res = GST_FLOW_ERROR; |
4182 |
+ goto done; |
4183 |
} |
4184 |
|
4185 |
+ *got_packet = TRUE; |
4186 |
+ |
4187 |
/* save stats info if there is some as well as a stats file */ |
4188 |
if (ffmpegenc->file && ffmpegenc->context->stats_out) |
4189 |
if (fprintf (ffmpegenc->file, "%s", ffmpegenc->context->stats_out) < 0) |
4190 |
@@ -728,24 +642,52 @@ gst_ffmpegvidenc_handle_frame (GstVideoEncoder * encod |
4191 |
(("Could not write to file \"%s\"."), ffmpegenc->filename), |
4192 |
GST_ERROR_SYSTEM); |
4193 |
|
4194 |
- gst_video_codec_frame_unref (frame); |
4195 |
- |
4196 |
/* Get oldest frame */ |
4197 |
- frame = gst_video_encoder_get_oldest_frame (encoder); |
4198 |
+ frame = gst_video_encoder_get_oldest_frame (GST_VIDEO_ENCODER (ffmpegenc)); |
4199 |
|
4200 |
- outbuf = |
4201 |
- gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY, pkt->data, |
4202 |
- pkt->size, 0, pkt->size, pkt, gst_ffmpegvidenc_free_avpacket); |
4203 |
- frame->output_buffer = outbuf; |
4204 |
+ if (send) { |
4205 |
+ outbuf = |
4206 |
+ gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY, pkt->data, |
4207 |
+ pkt->size, 0, pkt->size, pkt, gst_ffmpegvidenc_free_avpacket); |
4208 |
+ frame->output_buffer = outbuf; |
4209 |
|
4210 |
- if (pkt->flags & AV_PKT_FLAG_KEY) |
4211 |
- GST_VIDEO_CODEC_FRAME_SET_SYNC_POINT (frame); |
4212 |
- else |
4213 |
- GST_VIDEO_CODEC_FRAME_UNSET_SYNC_POINT (frame); |
4214 |
+ if (pkt->flags & AV_PKT_FLAG_KEY) |
4215 |
+ GST_VIDEO_CODEC_FRAME_SET_SYNC_POINT (frame); |
4216 |
+ else |
4217 |
+ GST_VIDEO_CODEC_FRAME_UNSET_SYNC_POINT (frame); |
4218 |
+ } |
4219 |
|
4220 |
- return gst_video_encoder_finish_frame (encoder, frame); |
4221 |
+ ret = gst_video_encoder_finish_frame (GST_VIDEO_ENCODER (ffmpegenc), frame); |
4222 |
|
4223 |
- /* ERRORS */ |
4224 |
+done: |
4225 |
+ return ret; |
4226 |
+} |
4227 |
+ |
4228 |
+static GstFlowReturn |
4229 |
+gst_ffmpegvidenc_handle_frame (GstVideoEncoder * encoder, |
4230 |
+ GstVideoCodecFrame * frame) |
4231 |
+{ |
4232 |
+ GstFFMpegVidEnc *ffmpegenc = (GstFFMpegVidEnc *) encoder; |
4233 |
+ GstFlowReturn ret; |
4234 |
+ gboolean got_packet; |
4235 |
+ |
4236 |
+ ret = gst_ffmpegvidenc_send_frame (ffmpegenc, frame); |
4237 |
+ |
4238 |
+ if (ret != GST_FLOW_OK) |
4239 |
+ goto encode_fail; |
4240 |
+ |
4241 |
+ gst_video_codec_frame_unref (frame); |
4242 |
+ |
4243 |
+ do { |
4244 |
+ ret = gst_ffmpegvidenc_receive_packet (ffmpegenc, &got_packet, TRUE); |
4245 |
+ if (ret != GST_FLOW_OK) |
4246 |
+ break; |
4247 |
+ } while (got_packet); |
4248 |
+ |
4249 |
+done: |
4250 |
+ return ret; |
4251 |
+ |
4252 |
+ /* We choose to be error-resilient */ |
4253 |
encode_fail: |
4254 |
{ |
4255 |
#ifndef GST_DISABLE_GST_DEBUG |
4256 |
@@ -755,19 +697,16 @@ encode_fail: |
4257 |
"avenc_%s: failed to encode buffer", oclass->in_plugin->name); |
4258 |
#endif /* GST_DISABLE_GST_DEBUG */ |
4259 |
/* avoid frame (and ts etc) piling up */ |
4260 |
- return gst_video_encoder_finish_frame (encoder, frame); |
4261 |
+ ret = gst_video_encoder_finish_frame (encoder, frame); |
4262 |
+ goto done; |
4263 |
} |
4264 |
} |
4265 |
|
4266 |
static GstFlowReturn |
4267 |
gst_ffmpegvidenc_flush_buffers (GstFFMpegVidEnc * ffmpegenc, gboolean send) |
4268 |
{ |
4269 |
- GstVideoCodecFrame *frame; |
4270 |
- GstFlowReturn flow_ret = GST_FLOW_OK; |
4271 |
- GstBuffer *outbuf; |
4272 |
- gint ret; |
4273 |
- AVPacket *pkt; |
4274 |
- int have_data = 0; |
4275 |
+ GstFlowReturn ret = GST_FLOW_OK; |
4276 |
+ gboolean got_packet; |
4277 |
|
4278 |
GST_DEBUG_OBJECT (ffmpegenc, "flushing buffers with sending %d", send); |
4279 |
|
4280 |
@@ -775,64 +714,27 @@ gst_ffmpegvidenc_flush_buffers (GstFFMpegVidEnc * ffmp |
4281 |
if (!ffmpegenc->opened) |
4282 |
goto done; |
4283 |
|
4284 |
- while ((frame = |
4285 |
- gst_video_encoder_get_oldest_frame (GST_VIDEO_ENCODER (ffmpegenc)))) { |
4286 |
- pkt = g_slice_new0 (AVPacket); |
4287 |
- have_data = 0; |
4288 |
+ ret = gst_ffmpegvidenc_send_frame (ffmpegenc, NULL); |
4289 |
|
4290 |
- ret = avcodec_encode_video2 (ffmpegenc->context, pkt, NULL, &have_data); |
4291 |
+ if (ret != GST_FLOW_OK) |
4292 |
+ goto done; |
4293 |
|
4294 |
- if (ret < 0) { /* there should be something, notify and give up */ |
4295 |
-#ifndef GST_DISABLE_GST_DEBUG |
4296 |
- GstFFMpegVidEncClass *oclass = |
4297 |
- (GstFFMpegVidEncClass *) (G_OBJECT_GET_CLASS (ffmpegenc)); |
4298 |
- GST_WARNING_OBJECT (ffmpegenc, |
4299 |
- "avenc_%s: failed to flush buffer", oclass->in_plugin->name); |
4300 |
-#endif /* GST_DISABLE_GST_DEBUG */ |
4301 |
- g_slice_free (AVPacket, pkt); |
4302 |
- gst_video_codec_frame_unref (frame); |
4303 |
+ do { |
4304 |
+ ret = gst_ffmpegvidenc_receive_packet (ffmpegenc, &got_packet, send); |
4305 |
+ if (ret != GST_FLOW_OK) |
4306 |
break; |
4307 |
- } |
4308 |
+ } while (got_packet); |
4309 |
|
4310 |
- /* save stats info if there is some as well as a stats file */ |
4311 |
- if (ffmpegenc->file && ffmpegenc->context->stats_out) |
4312 |
- if (fprintf (ffmpegenc->file, "%s", ffmpegenc->context->stats_out) < 0) |
4313 |
- GST_ELEMENT_ERROR (ffmpegenc, RESOURCE, WRITE, |
4314 |
- (("Could not write to file \"%s\"."), ffmpegenc->filename), |
4315 |
- GST_ERROR_SYSTEM); |
4316 |
- |
4317 |
- if (send && have_data) { |
4318 |
- outbuf = |
4319 |
- gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY, pkt->data, |
4320 |
- pkt->size, 0, pkt->size, pkt, gst_ffmpegvidenc_free_avpacket); |
4321 |
- frame->output_buffer = outbuf; |
4322 |
- |
4323 |
- if (pkt->flags & AV_PKT_FLAG_KEY) |
4324 |
- GST_VIDEO_CODEC_FRAME_SET_SYNC_POINT (frame); |
4325 |
- else |
4326 |
- GST_VIDEO_CODEC_FRAME_UNSET_SYNC_POINT (frame); |
4327 |
- |
4328 |
- flow_ret = |
4329 |
- gst_video_encoder_finish_frame (GST_VIDEO_ENCODER (ffmpegenc), frame); |
4330 |
- } else { |
4331 |
- /* no frame attached, so will be skipped and removed from frame list */ |
4332 |
- gst_video_encoder_finish_frame (GST_VIDEO_ENCODER (ffmpegenc), frame); |
4333 |
- } |
4334 |
- } |
4335 |
- |
4336 |
done: |
4337 |
- |
4338 |
- return flow_ret; |
4339 |
+ return ret; |
4340 |
} |
4341 |
|
4342 |
- |
4343 |
static void |
4344 |
gst_ffmpegvidenc_set_property (GObject * object, |
4345 |
guint prop_id, const GValue * value, GParamSpec * pspec) |
4346 |
{ |
4347 |
GstFFMpegVidEnc *ffmpegenc; |
4348 |
|
4349 |
- /* Get a pointer of the right type. */ |
4350 |
ffmpegenc = (GstFFMpegVidEnc *) (object); |
4351 |
|
4352 |
if (ffmpegenc->opened) { |
4353 |
@@ -841,69 +743,44 @@ gst_ffmpegvidenc_set_property (GObject * object, |
4354 |
return; |
4355 |
} |
4356 |
|
4357 |
- /* Check the argument id to see which argument we're setting. */ |
4358 |
switch (prop_id) { |
4359 |
- case PROP_BIT_RATE: |
4360 |
- ffmpegenc->bitrate = g_value_get_int (value); |
4361 |
+ case PROP_QUANTIZER: |
4362 |
+ ffmpegenc->quantizer = g_value_get_float (value); |
4363 |
break; |
4364 |
- case PROP_GOP_SIZE: |
4365 |
- ffmpegenc->gop_size = g_value_get_int (value); |
4366 |
+ case PROP_PASS: |
4367 |
+ ffmpegenc->pass = g_value_get_enum (value); |
4368 |
break; |
4369 |
- case PROP_ME_METHOD: |
4370 |
- ffmpegenc->me_method = g_value_get_enum (value); |
4371 |
+ case PROP_FILENAME: |
4372 |
+ g_free (ffmpegenc->filename); |
4373 |
+ ffmpegenc->filename = g_value_dup_string (value); |
4374 |
break; |
4375 |
- case PROP_BUFSIZE: |
4376 |
- break; |
4377 |
- case PROP_RTP_PAYLOAD_SIZE: |
4378 |
- ffmpegenc->rtp_payload_size = g_value_get_int (value); |
4379 |
- break; |
4380 |
- case PROP_COMPLIANCE: |
4381 |
- ffmpegenc->compliance = g_value_get_enum (value); |
4382 |
- break; |
4383 |
- case PROP_MAX_THREADS: |
4384 |
- ffmpegenc->max_threads = g_value_get_int (value); |
4385 |
- break; |
4386 |
default: |
4387 |
- if (!gst_ffmpeg_cfg_set_property (object, value, pspec)) |
4388 |
+ if (!gst_ffmpeg_cfg_set_property (ffmpegenc->refcontext, value, pspec)) |
4389 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
4390 |
break; |
4391 |
} |
4392 |
} |
4393 |
|
4394 |
-/* The set function is simply the inverse of the get fuction. */ |
4395 |
static void |
4396 |
gst_ffmpegvidenc_get_property (GObject * object, |
4397 |
guint prop_id, GValue * value, GParamSpec * pspec) |
4398 |
{ |
4399 |
GstFFMpegVidEnc *ffmpegenc; |
4400 |
|
4401 |
- /* It's not null if we got it, but it might not be ours */ |
4402 |
ffmpegenc = (GstFFMpegVidEnc *) (object); |
4403 |
|
4404 |
switch (prop_id) { |
4405 |
- case PROP_BIT_RATE: |
4406 |
- g_value_set_int (value, ffmpegenc->bitrate); |
4407 |
+ case PROP_QUANTIZER: |
4408 |
+ g_value_set_float (value, ffmpegenc->quantizer); |
4409 |
break; |
4410 |
- case PROP_GOP_SIZE: |
4411 |
- g_value_set_int (value, ffmpegenc->gop_size); |
4412 |
+ case PROP_PASS: |
4413 |
+ g_value_set_enum (value, ffmpegenc->pass); |
4414 |
break; |
4415 |
- case PROP_ME_METHOD: |
4416 |
- g_value_set_enum (value, ffmpegenc->me_method); |
4417 |
+ case PROP_FILENAME: |
4418 |
+ g_value_take_string (value, g_strdup (ffmpegenc->filename)); |
4419 |
break; |
4420 |
- case PROP_BUFSIZE: |
4421 |
- g_value_set_int (value, ffmpegenc->buffer_size); |
4422 |
- break; |
4423 |
- case PROP_RTP_PAYLOAD_SIZE: |
4424 |
- g_value_set_int (value, ffmpegenc->rtp_payload_size); |
4425 |
- break; |
4426 |
- case PROP_COMPLIANCE: |
4427 |
- g_value_set_enum (value, ffmpegenc->compliance); |
4428 |
- break; |
4429 |
- case PROP_MAX_THREADS: |
4430 |
- g_value_set_int (value, ffmpegenc->max_threads); |
4431 |
- break; |
4432 |
default: |
4433 |
- if (!gst_ffmpeg_cfg_get_property (object, value, pspec)) |
4434 |
+ if (!gst_ffmpeg_cfg_get_property (ffmpegenc->refcontext, value, pspec)) |
4435 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
4436 |
break; |
4437 |
} |
4438 |
@@ -946,10 +823,6 @@ gst_ffmpegvidenc_stop (GstVideoEncoder * encoder) |
4439 |
gst_ffmpeg_avcodec_close (ffmpegenc->context); |
4440 |
ffmpegenc->opened = FALSE; |
4441 |
|
4442 |
- if (ffmpegenc->file) { |
4443 |
- fclose (ffmpegenc->file); |
4444 |
- ffmpegenc->file = NULL; |
4445 |
- } |
4446 |
if (ffmpegenc->input_state) { |
4447 |
gst_video_codec_state_unref (ffmpegenc->input_state); |
4448 |
ffmpegenc->input_state = NULL; |
4449 |
@@ -982,20 +855,16 @@ gst_ffmpegvidenc_register (GstPlugin * plugin) |
4450 |
}; |
4451 |
GType type; |
4452 |
AVCodec *in_plugin; |
4453 |
+ void *i = 0; |
4454 |
|
4455 |
- |
4456 |
GST_LOG ("Registering encoders"); |
4457 |
|
4458 |
- /* build global ffmpeg param/property info */ |
4459 |
- gst_ffmpeg_cfg_init (); |
4460 |
- |
4461 |
- in_plugin = av_codec_next (NULL); |
4462 |
- while (in_plugin) { |
4463 |
+ while ((in_plugin = (AVCodec *) av_codec_iterate (&i))) { |
4464 |
gchar *type_name; |
4465 |
|
4466 |
/* Skip non-AV codecs */ |
4467 |
if (in_plugin->type != AVMEDIA_TYPE_VIDEO) |
4468 |
- goto next; |
4469 |
+ continue; |
4470 |
|
4471 |
/* no quasi codecs, please */ |
4472 |
if (in_plugin->id == AV_CODEC_ID_RAWVIDEO || |
4473 |
@@ -1014,7 +883,7 @@ gst_ffmpegvidenc_register (GstPlugin * plugin) |
4474 |
|| in_plugin->id == AV_CODEC_ID_WRAPPED_AVFRAME |
4475 |
#endif |
4476 |
|| in_plugin->id == AV_CODEC_ID_ZLIB) { |
4477 |
- goto next; |
4478 |
+ continue; |
4479 |
} |
4480 |
|
4481 |
/* No encoders depending on external libraries (we don't build them, but |
4482 |
@@ -1024,41 +893,41 @@ gst_ffmpegvidenc_register (GstPlugin * plugin) |
4483 |
GST_DEBUG |
4484 |
("Not using external library encoder %s. Use the gstreamer-native ones instead.", |
4485 |
in_plugin->name); |
4486 |
- goto next; |
4487 |
+ continue; |
4488 |
} |
4489 |
|
4490 |
if (strstr (in_plugin->name, "vaapi")) { |
4491 |
GST_DEBUG |
4492 |
("Ignoring VAAPI encoder %s. We can't handle this outside of ffmpeg", |
4493 |
in_plugin->name); |
4494 |
- goto next; |
4495 |
+ continue; |
4496 |
} |
4497 |
|
4498 |
if (strstr (in_plugin->name, "nvenc")) { |
4499 |
GST_DEBUG |
4500 |
("Ignoring nvenc encoder %s. We can't handle this outside of ffmpeg", |
4501 |
in_plugin->name); |
4502 |
- goto next; |
4503 |
+ continue; |
4504 |
} |
4505 |
|
4506 |
if (g_str_has_suffix (in_plugin->name, "_qsv")) { |
4507 |
GST_DEBUG |
4508 |
("Ignoring qsv encoder %s. We can't handle this outside of ffmpeg", |
4509 |
in_plugin->name); |
4510 |
- goto next; |
4511 |
+ continue; |
4512 |
} |
4513 |
|
4514 |
if (g_str_has_suffix (in_plugin->name, "_v4l2m2m")) { |
4515 |
GST_DEBUG |
4516 |
("Ignoring V4L2 mem-to-mem encoder %s. We can't handle this outside of ffmpeg", |
4517 |
in_plugin->name); |
4518 |
- goto next; |
4519 |
+ continue; |
4520 |
} |
4521 |
|
4522 |
/* only video encoders */ |
4523 |
if (!av_codec_is_encoder (in_plugin) |
4524 |
|| in_plugin->type != AVMEDIA_TYPE_VIDEO) |
4525 |
- goto next; |
4526 |
+ continue; |
4527 |
|
4528 |
/* FIXME : We should have a method to know cheaply whether we have a mapping |
4529 |
* for the given plugin or not */ |
4530 |
@@ -1068,7 +937,7 @@ gst_ffmpegvidenc_register (GstPlugin * plugin) |
4531 |
/* no codecs for which we're GUARANTEED to have better alternatives */ |
4532 |
if (!strcmp (in_plugin->name, "gif")) { |
4533 |
GST_LOG ("Ignoring encoder %s", in_plugin->name); |
4534 |
- goto next; |
4535 |
+ continue; |
4536 |
} |
4537 |
|
4538 |
/* construct the type */ |
4539 |
@@ -1100,9 +969,6 @@ gst_ffmpegvidenc_register (GstPlugin * plugin) |
4540 |
} |
4541 |
|
4542 |
g_free (type_name); |
4543 |
- |
4544 |
- next: |
4545 |
- in_plugin = av_codec_next (in_plugin); |
4546 |
} |
4547 |
|
4548 |
GST_LOG ("Finished registering encoders"); |
4549 |
--- ext/libav/gstavvidenc.h.orig 2018-03-23 20:45:20 UTC |
4550 |
+++ ext/libav/gstavvidenc.h |
4551 |
@@ -24,12 +24,12 @@ |
4552 |
#ifndef __GST_FFMPEGVIDENC_H__ |
4553 |
#define __GST_FFMPEGVIDENC_H__ |
4554 |
|
4555 |
-G_BEGIN_DECLS |
4556 |
- |
4557 |
#include <gst/gst.h> |
4558 |
#include <gst/video/gstvideoencoder.h> |
4559 |
#include <libavcodec/avcodec.h> |
4560 |
|
4561 |
+G_BEGIN_DECLS |
4562 |
+ |
4563 |
typedef struct _GstFFMpegVidEnc GstFFMpegVidEnc; |
4564 |
|
4565 |
struct _GstFFMpegVidEnc |
4566 |
@@ -42,34 +42,18 @@ struct _GstFFMpegVidEnc |
4567 |
AVFrame *picture; |
4568 |
gboolean opened; |
4569 |
gboolean discont; |
4570 |
- |
4571 |
- /* cache */ |
4572 |
- gint bitrate; |
4573 |
- gint me_method; |
4574 |
- gint gop_size; |
4575 |
- gint buffer_size; |
4576 |
- gint rtp_payload_size; |
4577 |
- gint compliance; |
4578 |
- gint max_threads; |
4579 |
- |
4580 |
- guint8 *working_buf; |
4581 |
- gsize working_buf_size; |
4582 |
- |
4583 |
- /* settings with some special handling */ |
4584 |
guint pass; |
4585 |
gfloat quantizer; |
4586 |
- gchar *filename; |
4587 |
- guint lmin; |
4588 |
- guint lmax; |
4589 |
- gint max_key_interval; |
4590 |
- gboolean interlaced; |
4591 |
|
4592 |
/* statistics file */ |
4593 |
+ gchar *filename; |
4594 |
FILE *file; |
4595 |
|
4596 |
- /* other settings are copied over straight, |
4597 |
- * include a context here, rather than copy-and-past it from avcodec.h */ |
4598 |
- AVCodecContext config; |
4599 |
+ /* cache */ |
4600 |
+ guint8 *working_buf; |
4601 |
+ gsize working_buf_size; |
4602 |
+ |
4603 |
+ AVCodecContext *refcontext; |
4604 |
}; |
4605 |
|
4606 |
typedef struct _GstFFMpegVidEncClass GstFFMpegVidEncClass; |
4607 |
--- meson.build.orig 2018-10-02 22:09:23 UTC |
4608 |
+++ meson.build |
4609 |
@@ -15,10 +15,14 @@ else |
4610 |
gst_version_nano = 0 |
4611 |
endif |
4612 |
|
4613 |
-libavfilter_dep = dependency('libavfilter', version: '>= 6.47.100') |
4614 |
-libavformat_dep = dependency('libavformat', version: '>= 57.41.100') |
4615 |
-libavcodec_dep = dependency('libavcodec', version: '>= 57.48.101') |
4616 |
-libavutil_dep = dependency('libavutil', version: '>= 55.28.100') |
4617 |
+libavfilter_dep = dependency('libavfilter', version: '>= 7.16.100', |
4618 |
+ fallback: ['FFmpeg', 'libavfilter_dep']) |
4619 |
+libavformat_dep = dependency('libavformat', version: '>= 58.12.100', |
4620 |
+ fallback: ['FFmpeg', 'libavformat_dep']) |
4621 |
+libavcodec_dep = dependency('libavcodec', version: '>= 58.18.100', |
4622 |
+ fallback: ['FFmpeg', 'libavcodec_dep']) |
4623 |
+libavutil_dep = dependency('libavutil', version: '>= 56.14.100', |
4624 |
+ fallback: ['FFmpeg', 'libavutil_dep']) |
4625 |
|
4626 |
libav_deps = [libavfilter_dep, libavformat_dep, libavcodec_dep, libavutil_dep] |
4627 |
|
4628 |
@@ -31,8 +35,24 @@ check_ffmpeg_src = '''#include <libavcodec/avcodec.h> |
4629 |
#error libav provider should be FFmpeg |
4630 |
#endif''' |
4631 |
|
4632 |
-if not cc.compiles(check_ffmpeg_src, dependencies : libav_deps, name : 'libav is provided by FFmpeg') |
4633 |
+libav_deps_type_name = '' |
4634 |
+ |
4635 |
+foreach dep: libav_deps |
4636 |
+ message('type name: @0@'.format(dep.type_name())) |
4637 |
+endforeach |
4638 |
+ |
4639 |
+foreach dep: libav_deps |
4640 |
+ message('[@0@] / [@1@]'.format(libav_deps_type_name, dep.type_name())) |
4641 |
+ if libav_deps_type_name != '' and dep.type_name() != libav_deps_type_name |
4642 |
+ error('Libav deps must be either all internal or all external') |
4643 |
+ endif |
4644 |
+ libav_deps_type_name = dep.type_name() |
4645 |
+endforeach |
4646 |
+ |
4647 |
+if dep.type_name() != 'internal' |
4648 |
+ if not cc.compiles(check_ffmpeg_src, dependencies : libav_deps, name : 'libav is provided by FFmpeg') |
4649 |
error('Uncompatible libavcodec found') |
4650 |
+ endif |
4651 |
endif |
4652 |
|
4653 |
cdata = configuration_data() |
4654 |
@@ -80,9 +100,7 @@ libm = cc.find_library('m', required : false) |
4655 |
configure_file(output : 'config.h', configuration : cdata) |
4656 |
|
4657 |
gst_libav_args = ['-DHAVE_CONFIG_H'] |
4658 |
-if cc.get_id() != 'msvc' |
4659 |
- gst_libav_args += ['-Wno-deprecated-declarations'] |
4660 |
-else |
4661 |
+if cc.get_id() == 'msvc' |
4662 |
# Ignore several spurious warnings for things gstreamer does very commonly |
4663 |
# If a warning is completely useless and spammy, use '/wdXXXX' to suppress it |
4664 |
# If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once |