1 /* VPX 2 * Copyright (C) 2006 David Schleef <ds@schleef.org> 3 * Copyright (C) 2008,2009,2010 Entropy Wave Inc 4 * Copyright (C) 2010 Sebastian Dröge <sebastian.droege@collabora.co.uk> 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 #ifndef __GST_VPX_DEC_H__ 24 #define __GST_VPX_DEC_H__ 25 26 #ifdef HAVE_CONFIG_H 27 #include "config.h" 28 #endif 29 30 #if defined(HAVE_VP8_DECODER) || defined(HAVE_VP9_DECODER) 31 32 #include <gst/gst.h> 33 #include <gst/video/gstvideodecoder.h> 34 35 /* FIXME: Undef HAVE_CONFIG_H because vpx_codec.h uses it, 36 * which causes compilation failures */ 37 #ifdef HAVE_CONFIG_H 38 #undef HAVE_CONFIG_H 39 #endif 40 41 #include <vpx/vpx_decoder.h> 42 #include <vpx/vp8dx.h> 43 44 G_BEGIN_DECLS 45 46 #define GST_TYPE_VPX_DEC \ 47 (gst_vpx_dec_get_type()) 48 #define GST_VPX_DEC(obj) \ 49 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VPX_DEC,GstVPXDec)) 50 #define GST_VPX_DEC_CLASS(klass) \ 51 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VPX_DEC,GstVPXDecClass)) 52 #define GST_IS_VPX_DEC(obj) \ 53 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VPX_DEC)) 54 #define GST_IS_VPX_DEC_CLASS(obj) \ 55 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VPX_DEC)) 56 #define GST_VPX_DEC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VPX_DEC, GstVPXDecClass)) 57 58 typedef struct _GstVPXDec GstVPXDec; 59 typedef struct _GstVPXDecClass GstVPXDecClass; 60 61 struct _GstVPXDec 62 { 63 GstVideoDecoder base_video_decoder; 64 65 /* < private > */ 66 vpx_codec_ctx_t decoder; 67 68 /* state */ 69 gboolean decoder_inited; 70 71 /* properties */ 72 gboolean post_processing; 73 enum vp8_postproc_level post_processing_flags; 74 gint deblocking_level; 75 gint noise_level; 76 gint threads; 77 78 GstVideoCodecState *input_state; 79 GstVideoCodecState *output_state; 80 81 /* allocation */ 82 gboolean have_video_meta; 83 GstBufferPool *pool; 84 gsize buf_size; 85 gboolean safe_remap; 86 }; 87 88 struct _GstVPXDecClass 89 { 90 GstVideoDecoderClass base_video_decoder_class; 91 const char* video_codec_tag; 92 /*supported vpx algo*/ 93 vpx_codec_iface_t* codec_algo; 94 /*virtual function to open_codec*/ 95 GstFlowReturn (*open_codec) (GstVPXDec * dec, GstVideoCodecFrame * frame); 96 /*virtual function to send tags*/ 97 void (*send_tags) (GstVPXDec* dec); 98 /*virtual function to set/correct the stream info*/ 99 void (*set_stream_info) (GstVPXDec *dec, vpx_codec_stream_info_t *stream_info); 100 /*virtual function to set default format while opening codec*/ 101 void (*set_default_format) (GstVPXDec *dec, GstVideoFormat fmt, int width, int height); 102 /*virtual function to negotiate format while handling frame*/ 103 void (*handle_resolution_change) (GstVPXDec *dec, vpx_image_t *img, GstVideoFormat fmt); 104 /*virtual function to check valid format*/ 105 gboolean (*get_frame_format)(GstVPXDec *dec, vpx_image_t *img, GstVideoFormat* fmt); 106 /* virtual function to check whether the decoder can handle data 107 * before receiving a sync_point, either at the start of after a 108 * decoding error 109 */ 110 gboolean (*get_needs_sync_point)(GstVPXDec *dec); 111 }; 112 113 GType gst_vpx_dec_get_type (void); 114 115 G_DEFINE_AUTOPTR_CLEANUP_FUNC (GstVPXDec, gst_object_unref) 116 117 G_END_DECLS 118 119 #endif 120 121 #endif /* __GST_VP8_DEC_H__ */ 122