• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 /*!\defgroup vp8_decoder WebM VP8/VP9 Decoder
12  * \ingroup vp8
13  *
14  * @{
15  */
16 /*!\file
17  * \brief Provides definitions for using VP8 or VP9 within the vpx Decoder
18  *        interface.
19  */
20 #ifndef VPX_VP8DX_H_
21 #define VPX_VP8DX_H_
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Include controls common to both the encoder and decoder */
28 #include "./vp8.h"
29 
30 /*!\name Algorithm interface for VP8
31  *
32  * This interface provides the capability to decode VP8 streams.
33  * @{
34  */
35 extern vpx_codec_iface_t vpx_codec_vp8_dx_algo;
36 extern vpx_codec_iface_t *vpx_codec_vp8_dx(void);
37 /*!@} - end algorithm interface member group*/
38 
39 /*!\name Algorithm interface for VP9
40  *
41  * This interface provides the capability to decode VP9 streams.
42  * @{
43  */
44 extern vpx_codec_iface_t vpx_codec_vp9_dx_algo;
45 extern vpx_codec_iface_t *vpx_codec_vp9_dx(void);
46 /*!@} - end algorithm interface member group*/
47 
48 /*!\enum vp8_dec_control_id
49  * \brief VP8 decoder control functions
50  *
51  * This set of macros define the control functions available for the VP8
52  * decoder interface.
53  *
54  * \sa #vpx_codec_control
55  */
56 enum vp8_dec_control_id {
57   /** control function to get info on which reference frames were updated
58    *  by the last decode
59    */
60   VP8D_GET_LAST_REF_UPDATES = VP8_DECODER_CTRL_ID_START,
61 
62   /** check if the indicated frame is corrupted */
63   VP8D_GET_FRAME_CORRUPTED,
64 
65   /** control function to get info on which reference frames were used
66    *  by the last decode
67    */
68   VP8D_GET_LAST_REF_USED,
69 
70   /** decryption function to decrypt encoded buffer data immediately
71    * before decoding. Takes a vpx_decrypt_init, which contains
72    * a callback function and opaque context pointer.
73    */
74   VPXD_SET_DECRYPTOR,
75   VP8D_SET_DECRYPTOR = VPXD_SET_DECRYPTOR,
76 
77   /** control function to get the dimensions that the current frame is decoded
78    * at. This may be different to the intended display size for the frame as
79    * specified in the wrapper or frame header (see VP9D_GET_DISPLAY_SIZE). */
80   VP9D_GET_FRAME_SIZE,
81 
82   /** control function to get the current frame's intended display dimensions
83    * (as specified in the wrapper or frame header). This may be different to
84    * the decoded dimensions of this frame (see VP9D_GET_FRAME_SIZE). */
85   VP9D_GET_DISPLAY_SIZE,
86 
87   /** control function to get the bit depth of the stream. */
88   VP9D_GET_BIT_DEPTH,
89 
90   /** control function to set the byte alignment of the planes in the reference
91    * buffers. Valid values are power of 2, from 32 to 1024. A value of 0 sets
92    * legacy alignment. I.e. Y plane is aligned to 32 bytes, U plane directly
93    * follows Y plane, and V plane directly follows U plane. Default value is 0.
94    */
95   VP9_SET_BYTE_ALIGNMENT,
96 
97   /** control function to invert the decoding order to from right to left. The
98    * function is used in a test to confirm the decoding independence of tile
99    * columns. The function may be used in application where this order
100    * of decoding is desired.
101    *
102    * TODO(yaowu): Rework the unit test that uses this control, and in a future
103    *              release, this test-only control shall be removed.
104    */
105   VP9_INVERT_TILE_DECODE_ORDER,
106 
107   /** control function to set the skip loop filter flag. Valid values are
108    * integers. The decoder will skip the loop filter when its value is set to
109    * nonzero. If the loop filter is skipped the decoder may accumulate decode
110    * artifacts. The default value is 0.
111    */
112   VP9_SET_SKIP_LOOP_FILTER,
113 
114   /** control function to decode SVC stream up to the x spatial layers,
115    * where x is passed in through the control, and is 0 for base layer.
116    */
117   VP9_DECODE_SVC_SPATIAL_LAYER,
118 
119   /*!\brief Codec control function to get last decoded frame quantizer.
120    *
121    * Return value uses internal quantizer scale defined by the codec.
122    *
123    * Supported in codecs: VP8, VP9
124    */
125   VPXD_GET_LAST_QUANTIZER,
126 
127   VP8_DECODER_CTRL_ID_MAX
128 };
129 
130 /** Decrypt n bytes of data from input -> output, using the decrypt_state
131  *  passed in VPXD_SET_DECRYPTOR.
132  */
133 typedef void (*vpx_decrypt_cb)(void *decrypt_state, const unsigned char *input,
134                                unsigned char *output, int count);
135 
136 /*!\brief Structure to hold decryption state
137  *
138  * Defines a structure to hold the decryption state and access function.
139  */
140 typedef struct vpx_decrypt_init {
141   /*! Decrypt callback. */
142   vpx_decrypt_cb decrypt_cb;
143 
144   /*! Decryption state. */
145   void *decrypt_state;
146 } vpx_decrypt_init;
147 
148 /*!\brief A deprecated alias for vpx_decrypt_init.
149  */
150 typedef vpx_decrypt_init vp8_decrypt_init;
151 
152 /*!\cond */
153 /*!\brief VP8 decoder control function parameter type
154  *
155  * Defines the data types that VP8D control functions take. Note that
156  * additional common controls are defined in vp8.h
157  *
158  */
159 
160 VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_UPDATES, int *)
161 #define VPX_CTRL_VP8D_GET_LAST_REF_UPDATES
162 VPX_CTRL_USE_TYPE(VP8D_GET_FRAME_CORRUPTED, int *)
163 #define VPX_CTRL_VP8D_GET_FRAME_CORRUPTED
164 VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_USED, int *)
165 #define VPX_CTRL_VP8D_GET_LAST_REF_USED
166 VPX_CTRL_USE_TYPE(VPXD_GET_LAST_QUANTIZER, int *)
167 #define VPX_CTRL_VPXD_GET_LAST_QUANTIZER
168 VPX_CTRL_USE_TYPE(VPXD_SET_DECRYPTOR, vpx_decrypt_init *)
169 #define VPX_CTRL_VPXD_SET_DECRYPTOR
170 VPX_CTRL_USE_TYPE(VP8D_SET_DECRYPTOR, vpx_decrypt_init *)
171 #define VPX_CTRL_VP8D_SET_DECRYPTOR
172 VPX_CTRL_USE_TYPE(VP9D_GET_DISPLAY_SIZE, int *)
173 #define VPX_CTRL_VP9D_GET_DISPLAY_SIZE
174 VPX_CTRL_USE_TYPE(VP9D_GET_BIT_DEPTH, unsigned int *)
175 #define VPX_CTRL_VP9D_GET_BIT_DEPTH
176 VPX_CTRL_USE_TYPE(VP9D_GET_FRAME_SIZE, int *)
177 #define VPX_CTRL_VP9D_GET_FRAME_SIZE
178 VPX_CTRL_USE_TYPE(VP9_INVERT_TILE_DECODE_ORDER, int)
179 #define VPX_CTRL_VP9_INVERT_TILE_DECODE_ORDER
180 #define VPX_CTRL_VP9_DECODE_SVC_SPATIAL_LAYER
181 VPX_CTRL_USE_TYPE(VP9_DECODE_SVC_SPATIAL_LAYER, int)
182 #define VPX_CTRL_VP9_SET_SKIP_LOOP_FILTER
183 VPX_CTRL_USE_TYPE(VP9_SET_SKIP_LOOP_FILTER, int)
184 
185 /*!\endcond */
186 /*! @} - end defgroup vp8_decoder */
187 
188 #ifdef __cplusplus
189 }  // extern "C"
190 #endif
191 
192 #endif  // VPX_VP8DX_H_
193