be1c40788f1c44656a55b32aeacdb3e68de8a60f
[platform/upstream/gstreamer.git] / ext / vpx / gstvp9enc.c
1 /* VP9
2  * Copyright (C) 2006 David Schleef <ds@schleef.org>
3  * Copyright (C) 2010 Entropy Wave Inc
4  * Copyright (C) 2010-2013 Sebastian Dröge <slomo@circular-chaos.org>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  */
22 /**
23  * SECTION:element-vp9enc
24  * @title: vp9enc
25  * @see_also: vp9dec, webmmux, oggmux
26  *
27  * This element encodes raw video into a VP9 stream.
28  * [VP9](http://www.webmproject.org) is a royalty-free video codec maintained by
29  * [Google](http://www.google.com/). It's the successor of On2 VP3, which was
30  * the base of the Theora video codec.
31  *
32  * To control the quality of the encoding, the #GstVPXEnc:target-bitrate,
33  * #GstVPXEnc:min-quantizer, #GstVPXEnc:max-quantizer or #GstVPXEnc:cq-level
34  * properties can be used. Which one is used depends on the mode selected by
35  * the #GstVPXEnc:end-usage property.
36  * See [Encoder Parameters](http://www.webmproject.org/docs/encoder-parameters/)
37  * for explanation, examples for useful encoding parameters and more details
38  * on the encoding parameters.
39  *
40  * ## Example pipeline
41  * |[
42  * gst-launch-1.0 -v videotestsrc num-buffers=1000 ! vp9enc ! webmmux ! filesink location=videotestsrc.webm
43  * ]| This example pipeline will encode a test video source to VP9 muxed in an
44  * WebM container.
45  *
46  */
47
48 #ifdef HAVE_CONFIG_H
49 #include "config.h"
50 #endif
51
52 #ifdef HAVE_VP9_ENCODER
53
54 /* glib decided in 2.32 it would be a great idea to deprecated GValueArray without
55  * providing an alternative
56  *
57  * See https://bugzilla.gnome.org/show_bug.cgi?id=667228
58  * */
59 #define GLIB_DISABLE_DEPRECATION_WARNINGS
60
61 #include <gst/tag/tag.h>
62 #include <gst/video/video.h>
63 #include <string.h>
64
65 #include "gstvpxelements.h"
66 #include "gstvp8utils.h"
67 #include "gstvp9enc.h"
68
69 GST_DEBUG_CATEGORY_STATIC (gst_vp9enc_debug);
70 #define GST_CAT_DEFAULT gst_vp9enc_debug
71
72 #define DEFAULT_TILE_COLUMNS 6
73 #define DEFAULT_TILE_ROWS 0
74 #define DEFAULT_ROW_MT 0
75 #define DEFAULT_AQ_MODE 0
76
77 enum
78 {
79   PROP_0,
80   PROP_TILE_COLUMNS,
81   PROP_TILE_ROWS,
82   PROP_ROW_MT,
83   PROP_AQ_MODE,
84 };
85
86 /* FIXME: Y42B do not work yet it seems */
87 static GstStaticPadTemplate gst_vp9_enc_sink_template =
88 GST_STATIC_PAD_TEMPLATE ("sink",
89     GST_PAD_SINK,
90     GST_PAD_ALWAYS,
91     /*GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ I420, YV12, Y42B, Y444 }")) */
92     GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE
93         ("{ I420, YV12, Y444, I420_10LE, I422_10LE }"))
94     );
95
96 static GstStaticPadTemplate gst_vp9_enc_src_template =
97 GST_STATIC_PAD_TEMPLATE ("src",
98     GST_PAD_SRC,
99     GST_PAD_ALWAYS,
100     GST_STATIC_CAPS ("video/x-vp9, " "profile = (string) {0, 1, 2, 3}")
101     );
102
103 #define parent_class gst_vp9_enc_parent_class
104 G_DEFINE_TYPE (GstVP9Enc, gst_vp9_enc, GST_TYPE_VPX_ENC);
105 GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (vp9enc, "vp9enc", GST_RANK_PRIMARY,
106     gst_vp9_enc_get_type (), vpx_element_init (plugin));
107
108 static vpx_codec_iface_t *gst_vp9_enc_get_algo (GstVPXEnc * enc);
109 static gboolean gst_vp9_enc_enable_scaling (GstVPXEnc * enc);
110 static void gst_vp9_enc_set_image_format (GstVPXEnc * enc, vpx_image_t * image);
111 static GstCaps *gst_vp9_enc_get_new_simple_caps (GstVPXEnc * enc);
112 static void gst_vp9_enc_set_stream_info (GstVPXEnc * enc, GstCaps * caps,
113     GstVideoInfo * info);
114 static void *gst_vp9_enc_process_frame_user_data (GstVPXEnc * enc,
115     GstVideoCodecFrame * frame);
116 static GstFlowReturn gst_vp9_enc_handle_invisible_frame_buffer (GstVPXEnc * enc,
117     void *user_data, GstBuffer * buffer);
118 static void gst_vp9_enc_set_frame_user_data (GstVPXEnc * enc,
119     GstVideoCodecFrame * frame, vpx_image_t * image);
120 static void gst_vp9_enc_set_property (GObject * object, guint prop_id,
121     const GValue * value, GParamSpec * pspec);
122 static void gst_vp9_enc_get_property (GObject * object, guint prop_id,
123     GValue * value, GParamSpec * pspec);
124 static gboolean gst_vp9_enc_configure_encoder (GstVPXEnc * encoder,
125     GstVideoCodecState * state);
126
127 #define DEFAULT_BITS_PER_PIXEL 0.0289
128
129 static void
130 gst_vp9_enc_class_init (GstVP9EncClass * klass)
131 {
132   GObjectClass *gobject_class;
133   GstElementClass *element_class;
134   GstVPXEncClass *vpx_encoder_class;
135
136   gobject_class = G_OBJECT_CLASS (klass);
137   element_class = GST_ELEMENT_CLASS (klass);
138   vpx_encoder_class = GST_VPX_ENC_CLASS (klass);
139
140   gobject_class->set_property = gst_vp9_enc_set_property;
141   gobject_class->get_property = gst_vp9_enc_get_property;
142
143   /**
144    * GstVP9Enc:tile-columns:
145    *
146    * Number of tile columns, log2
147    *
148    * Since: 1.20
149    */
150   g_object_class_install_property (gobject_class, PROP_TILE_COLUMNS,
151       g_param_spec_int ("tile-columns", "Tile Columns",
152           "Number of tile columns, log2",
153           0, 6, DEFAULT_TILE_COLUMNS,
154           (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
155
156   /**
157    * GstVP9Enc:tile-rows:
158    *
159    * Number of tile rows, log2
160    *
161    * Since: 1.20
162    */
163   g_object_class_install_property (gobject_class, PROP_TILE_ROWS,
164       g_param_spec_int ("tile-rows", "Tile Rows",
165           "Number of tile rows, log2",
166           0, 2, DEFAULT_TILE_ROWS,
167           (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
168
169   /**
170    * GstVP9Enc:row-mt:
171    *
172    * Whether each row should be encoded using multiple threads
173    *
174    * Since: 1.20
175    */
176   g_object_class_install_property (gobject_class, PROP_ROW_MT,
177       g_param_spec_boolean ("row-mt", "Row Multithreading",
178           "Whether each row should be encoded using multiple threads",
179           DEFAULT_ROW_MT,
180           (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
181
182   /**
183    * GstVP9Enc:aq-mode:
184    *
185    * Adaptive Quantization Mode
186    *
187    * Since: 1.20
188    */
189   g_object_class_install_property (gobject_class, PROP_AQ_MODE,
190       g_param_spec_int ("aq-mode", "Adaptive Quantization Mode",
191           "0: off (default), 1: variance 2: complexity, 3: cyclic refresh, 4: equator360",
192           0, 4, DEFAULT_AQ_MODE,
193           (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
194
195   gst_element_class_add_static_pad_template (element_class,
196       &gst_vp9_enc_src_template);
197   gst_element_class_add_static_pad_template (element_class,
198       &gst_vp9_enc_sink_template);
199
200   gst_element_class_set_static_metadata (element_class,
201       "On2 VP9 Encoder",
202       "Codec/Encoder/Video",
203       "Encode VP9 video streams", "David Schleef <ds@entropywave.com>, "
204       "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
205
206   vpx_encoder_class->get_algo = gst_vp9_enc_get_algo;
207   vpx_encoder_class->enable_scaling = gst_vp9_enc_enable_scaling;
208   vpx_encoder_class->set_image_format = gst_vp9_enc_set_image_format;
209   vpx_encoder_class->get_new_vpx_caps = gst_vp9_enc_get_new_simple_caps;
210   vpx_encoder_class->set_stream_info = gst_vp9_enc_set_stream_info;
211   vpx_encoder_class->process_frame_user_data =
212       gst_vp9_enc_process_frame_user_data;
213   vpx_encoder_class->handle_invisible_frame_buffer =
214       gst_vp9_enc_handle_invisible_frame_buffer;
215   vpx_encoder_class->set_frame_user_data = gst_vp9_enc_set_frame_user_data;
216   vpx_encoder_class->configure_encoder = gst_vp9_enc_configure_encoder;
217
218   GST_DEBUG_CATEGORY_INIT (gst_vp9enc_debug, "vp9enc", 0, "VP9 Encoder");
219 }
220
221 static void
222 gst_vp9_enc_init (GstVP9Enc * gst_vp9_enc)
223 {
224   vpx_codec_err_t status;
225   GstVPXEnc *gst_vpx_enc = GST_VPX_ENC (gst_vp9_enc);
226   GST_DEBUG_OBJECT (gst_vp9_enc, "gst_vp9_enc_init");
227   status =
228       vpx_codec_enc_config_default (gst_vp9_enc_get_algo (gst_vpx_enc),
229       &gst_vpx_enc->cfg, 0);
230   if (status != VPX_CODEC_OK) {
231     GST_ERROR_OBJECT (gst_vpx_enc,
232         "Failed to get default encoder configuration: %s",
233         gst_vpx_error_name (status));
234     gst_vpx_enc->have_default_config = FALSE;
235   } else {
236     gst_vpx_enc->have_default_config = TRUE;
237   }
238   gst_vpx_enc->bits_per_pixel = DEFAULT_BITS_PER_PIXEL;
239
240   gst_vp9_enc->tile_columns = DEFAULT_TILE_COLUMNS;
241   gst_vp9_enc->tile_rows = DEFAULT_TILE_ROWS;
242   gst_vp9_enc->row_mt = DEFAULT_ROW_MT;
243   gst_vp9_enc->aq_mode = DEFAULT_AQ_MODE;
244 }
245
246 static void
247 gst_vp9_enc_set_property (GObject * object, guint prop_id,
248     const GValue * value, GParamSpec * pspec)
249 {
250   GstVPXEnc *gst_vpx_enc = GST_VPX_ENC (object);
251   GstVP9Enc *gst_vp9_enc = GST_VP9_ENC (object);
252   vpx_codec_err_t status;
253
254   g_mutex_lock (&gst_vpx_enc->encoder_lock);
255
256   switch (prop_id) {
257     case PROP_TILE_COLUMNS:
258       gst_vp9_enc->tile_columns = g_value_get_int (value);
259       if (gst_vpx_enc->inited) {
260         status =
261             vpx_codec_control (&gst_vpx_enc->encoder, VP9E_SET_TILE_COLUMNS,
262             gst_vp9_enc->tile_columns);
263         if (status != VPX_CODEC_OK) {
264           GST_WARNING_OBJECT (gst_vpx_enc,
265               "Failed to set VP9E_SET_TILE_COLUMNS: %s",
266               gst_vpx_error_name (status));
267         }
268       }
269       break;
270     case PROP_TILE_ROWS:
271       gst_vp9_enc->tile_rows = g_value_get_int (value);
272       if (gst_vpx_enc->inited) {
273         status =
274             vpx_codec_control (&gst_vpx_enc->encoder, VP9E_SET_TILE_ROWS,
275             gst_vp9_enc->tile_rows);
276         if (status != VPX_CODEC_OK) {
277           GST_WARNING_OBJECT (gst_vpx_enc,
278               "Failed to set VP9E_SET_TILE_ROWS: %s",
279               gst_vpx_error_name (status));
280         }
281       }
282       break;
283     case PROP_ROW_MT:
284       gst_vp9_enc->row_mt = g_value_get_boolean (value);
285       if (gst_vpx_enc->inited) {
286         status =
287             vpx_codec_control (&gst_vpx_enc->encoder, VP9E_SET_ROW_MT,
288             gst_vp9_enc->row_mt ? 1 : 0);
289         if (status != VPX_CODEC_OK) {
290           GST_WARNING_OBJECT (gst_vpx_enc,
291               "Failed to set VP9E_SET_ROW_MT: %s", gst_vpx_error_name (status));
292         }
293       }
294       break;
295     case PROP_AQ_MODE:
296       gst_vp9_enc->aq_mode = g_value_get_int (value);
297       if (gst_vpx_enc->inited) {
298         status = vpx_codec_control (&gst_vpx_enc->encoder, VP9E_SET_AQ_MODE,
299             gst_vp9_enc->aq_mode);
300         if (status != VPX_CODEC_OK) {
301           GST_WARNING_OBJECT (gst_vpx_enc,
302               "Failed to set VP9E_SET_AQ_MODE: %s",
303               gst_vpx_error_name (status));
304         }
305       }
306       break;
307     default:
308       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
309       break;
310   }
311
312   g_mutex_unlock (&gst_vpx_enc->encoder_lock);
313 }
314
315 static void
316 gst_vp9_enc_get_property (GObject * object, guint prop_id, GValue * value,
317     GParamSpec * pspec)
318 {
319   GstVPXEnc *gst_vpx_enc = GST_VPX_ENC (object);
320   GstVP9Enc *gst_vp9_enc = GST_VP9_ENC (object);
321
322   g_mutex_lock (&gst_vpx_enc->encoder_lock);
323
324   switch (prop_id) {
325     case PROP_TILE_COLUMNS:
326       g_value_set_int (value, gst_vp9_enc->tile_columns);
327       break;
328     case PROP_TILE_ROWS:
329       g_value_set_int (value, gst_vp9_enc->tile_rows);
330       break;
331     case PROP_ROW_MT:
332       g_value_set_boolean (value, gst_vp9_enc->row_mt);
333       break;
334     case PROP_AQ_MODE:
335       g_value_set_int (value, gst_vp9_enc->aq_mode);
336       break;
337     default:
338       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
339       break;
340   }
341
342   g_mutex_unlock (&gst_vpx_enc->encoder_lock);
343 }
344
345 static vpx_color_space_t
346 gst_vp9_get_vpx_colorspace (GstVPXEnc * encoder, GstVideoColorimetry * in_cinfo,
347     GstVideoFormat format)
348 {
349   vpx_color_space_t colorspace = VPX_CS_UNKNOWN;
350   GstVideoColorimetry cinfo = *in_cinfo;
351   gchar *colorimetry_str;
352   guint i;
353
354   static const struct
355   {
356     const gchar *str;
357     vpx_color_space_t vpx_color_space;
358   } colorimetry_map[] = {
359     {
360     GST_VIDEO_COLORIMETRY_BT601, VPX_CS_BT_601}, {
361     GST_VIDEO_COLORIMETRY_BT709, VPX_CS_BT_709}, {
362     GST_VIDEO_COLORIMETRY_SMPTE240M, VPX_CS_SMPTE_240}, {
363     GST_VIDEO_COLORIMETRY_BT2020, VPX_CS_BT_2020}
364   };
365
366   /* We support any range, all mapped CSC are by default reduced range. */
367   cinfo.range = GST_VIDEO_COLOR_RANGE_16_235;
368   colorimetry_str = gst_video_colorimetry_to_string (&cinfo);
369
370   if (colorimetry_str != NULL) {
371     for (i = 0; i < G_N_ELEMENTS (colorimetry_map); ++i) {
372       if (g_strcmp0 (colorimetry_map[i].str, colorimetry_str) == 0) {
373         colorspace = colorimetry_map[i].vpx_color_space;
374         break;
375       }
376     }
377   }
378
379   if (colorspace == VPX_CS_UNKNOWN) {
380     if (format == GST_VIDEO_FORMAT_GBR
381         || format == GST_VIDEO_FORMAT_GBR_10BE
382         || format == GST_VIDEO_FORMAT_GBR_10LE
383         || format == GST_VIDEO_FORMAT_GBR_12BE
384         || format == GST_VIDEO_FORMAT_GBR_12LE) {
385       /* Currently has no effect because vp*enc elements only accept YUV video
386        * formats.
387        *
388        * FIXME: Support encoding GST_VIDEO_FORMAT_GBR and its high bits variants.
389        */
390       colorspace = VPX_CS_SRGB;
391     } else {
392       GST_WARNING_OBJECT (encoder, "Unsupported colorspace \"%s\"",
393           GST_STR_NULL (colorimetry_str));
394     }
395   }
396
397   g_free (colorimetry_str);
398
399   return colorspace;
400 }
401
402 static gint
403 gst_vp9_get_vpx_color_range (GstVideoColorimetry * colorimetry)
404 {
405   if (colorimetry->range == GST_VIDEO_COLOR_RANGE_0_255)
406     /* Full range (0..255 or HBD equivalent) */
407     return 1;
408
409   /* Limited range (16..235 or HBD equivalent) */
410   return 0;
411 }
412
413 static gboolean
414 gst_vp9_enc_configure_encoder (GstVPXEnc * encoder, GstVideoCodecState * state)
415 {
416   GstVP9Enc *vp9enc = GST_VP9_ENC (encoder);
417   GstVideoInfo *info = &state->info;
418   vpx_codec_err_t status;
419
420   status = vpx_codec_control (&encoder->encoder, VP9E_SET_COLOR_SPACE,
421       gst_vp9_get_vpx_colorspace (encoder, &GST_VIDEO_INFO_COLORIMETRY (info),
422           GST_VIDEO_INFO_FORMAT (info)));
423   if (status != VPX_CODEC_OK) {
424     GST_WARNING_OBJECT (encoder,
425         "Failed to set VP9E_SET_COLOR_SPACE: %s", gst_vpx_error_name (status));
426   }
427
428   status = vpx_codec_control (&encoder->encoder, VP9E_SET_COLOR_RANGE,
429       gst_vp9_get_vpx_color_range (&GST_VIDEO_INFO_COLORIMETRY (info)));
430   if (status != VPX_CODEC_OK) {
431     GST_WARNING_OBJECT (encoder,
432         "Failed to set VP9E_SET_COLOR_RANGE: %s", gst_vpx_error_name (status));
433   }
434
435   status =
436       vpx_codec_control (&encoder->encoder, VP9E_SET_TILE_COLUMNS,
437       vp9enc->tile_columns);
438   if (status != VPX_CODEC_OK) {
439     GST_DEBUG_OBJECT (encoder, "Failed to set VP9E_SET_TILE_COLUMNS: %s",
440         gst_vpx_error_name (status));
441   }
442
443   status =
444       vpx_codec_control (&encoder->encoder, VP9E_SET_TILE_ROWS,
445       vp9enc->tile_rows);
446   if (status != VPX_CODEC_OK) {
447     GST_DEBUG_OBJECT (encoder, "Failed to set VP9E_SET_TILE_ROWS: %s",
448         gst_vpx_error_name (status));
449   }
450   status =
451       vpx_codec_control (&encoder->encoder, VP9E_SET_ROW_MT,
452       vp9enc->row_mt ? 1 : 0);
453   if (status != VPX_CODEC_OK) {
454     GST_DEBUG_OBJECT (encoder,
455         "Failed to set VP9E_SET_ROW_MT: %s", gst_vpx_error_name (status));
456   }
457   status =
458       vpx_codec_control (&encoder->encoder, VP9E_SET_AQ_MODE, vp9enc->aq_mode);
459   if (status != VPX_CODEC_OK) {
460     GST_WARNING_OBJECT (encoder,
461         "Failed to set VP9E_SET_AQ_MODE: %s", gst_vpx_error_name (status));
462   }
463
464   return TRUE;
465 }
466
467 static vpx_codec_iface_t *
468 gst_vp9_enc_get_algo (GstVPXEnc * enc)
469 {
470   return &vpx_codec_vp9_cx_algo;
471 }
472
473 static gboolean
474 gst_vp9_enc_enable_scaling (GstVPXEnc * enc)
475 {
476   return FALSE;
477 }
478
479 static void
480 gst_vp9_enc_set_image_format (GstVPXEnc * enc, vpx_image_t * image)
481 {
482   switch (enc->input_state->info.finfo->format) {
483     case GST_VIDEO_FORMAT_I420:
484       image->fmt = VPX_IMG_FMT_I420;
485       image->bps = 12;
486       image->x_chroma_shift = image->y_chroma_shift = 1;
487       break;
488     case GST_VIDEO_FORMAT_YV12:
489       image->fmt = VPX_IMG_FMT_YV12;
490       image->bps = 12;
491       image->x_chroma_shift = image->y_chroma_shift = 1;
492       break;
493     case GST_VIDEO_FORMAT_Y42B:
494       image->fmt = VPX_IMG_FMT_I422;
495       image->bps = 16;
496       image->x_chroma_shift = 1;
497       image->y_chroma_shift = 0;
498       break;
499     case GST_VIDEO_FORMAT_Y444:
500       image->fmt = VPX_IMG_FMT_I444;
501       image->bps = 24;
502       image->x_chroma_shift = image->y_chroma_shift = 0;
503       break;
504     case GST_VIDEO_FORMAT_I420_10LE:
505       image->fmt = VPX_IMG_FMT_I42016;
506       image->bps = 15;
507       image->x_chroma_shift = image->y_chroma_shift = 1;
508       break;
509     case GST_VIDEO_FORMAT_I422_10LE:
510       image->fmt = VPX_IMG_FMT_I42216;
511       image->bps = 20;
512       image->x_chroma_shift = 1;
513       image->y_chroma_shift = 0;
514       break;
515     default:
516       g_assert_not_reached ();
517       break;
518   }
519 }
520
521 static GstCaps *
522 gst_vp9_enc_get_new_simple_caps (GstVPXEnc * enc)
523 {
524   GstCaps *caps;
525   gchar *profile_str = g_strdup_printf ("%d", enc->cfg.g_profile);
526   caps = gst_caps_new_simple ("video/x-vp9",
527       "profile", G_TYPE_STRING, profile_str, NULL);
528   g_free (profile_str);
529   return caps;
530 }
531
532 static void
533 gst_vp9_enc_set_stream_info (GstVPXEnc * enc, GstCaps * caps,
534     GstVideoInfo * info)
535 {
536   return;
537 }
538
539 static void *
540 gst_vp9_enc_process_frame_user_data (GstVPXEnc * enc,
541     GstVideoCodecFrame * frame)
542 {
543   return NULL;
544 }
545
546 static GstFlowReturn
547 gst_vp9_enc_handle_invisible_frame_buffer (GstVPXEnc * enc, void *user_data,
548     GstBuffer * buffer)
549 {
550   GstFlowReturn ret;
551   g_mutex_unlock (&enc->encoder_lock);
552   ret = gst_pad_push (GST_VIDEO_ENCODER_SRC_PAD (enc), buffer);
553   g_mutex_lock (&enc->encoder_lock);
554   return ret;
555 }
556
557 static void
558 gst_vp9_enc_user_data_free (vpx_image_t * image)
559 {
560   g_slice_free (vpx_image_t, image);
561 }
562
563 static void
564 gst_vp9_enc_set_frame_user_data (GstVPXEnc * enc, GstVideoCodecFrame * frame,
565     vpx_image_t * image)
566 {
567   gst_video_codec_frame_set_user_data (frame, image,
568       (GDestroyNotify) gst_vp9_enc_user_data_free);
569   return;
570 }
571
572 #endif /* HAVE_VP9_ENCODER */