• 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 #ifndef VPX_VPX_VP8CX_H_
11 #define VPX_VPX_VP8CX_H_
12 
13 /*!\defgroup vp8_encoder WebM VP8/VP9 Encoder
14  * \ingroup vp8
15  *
16  * @{
17  */
18 #include "./vp8.h"
19 #include "./vpx_encoder.h"
20 
21 /*!\file
22  * \brief Provides definitions for using VP8 or VP9 encoder algorithm within the
23  *        vpx Codec Interface.
24  */
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 /*!\name Algorithm interface for VP8
31  *
32  * This interface provides the capability to encode raw VP8 streams.
33  * @{
34  */
35 extern vpx_codec_iface_t vpx_codec_vp8_cx_algo;
36 extern vpx_codec_iface_t *vpx_codec_vp8_cx(void);
37 /*!@} - end algorithm interface member group*/
38 
39 /*!\name Algorithm interface for VP9
40  *
41  * This interface provides the capability to encode raw VP9 streams.
42  * @{
43  */
44 extern vpx_codec_iface_t vpx_codec_vp9_cx_algo;
45 extern vpx_codec_iface_t *vpx_codec_vp9_cx(void);
46 /*!@} - end algorithm interface member group*/
47 
48 /*
49  * Algorithm Flags
50  */
51 
52 /*!\brief Don't reference the last frame
53  *
54  * When this flag is set, the encoder will not use the last frame as a
55  * predictor. When not set, the encoder will choose whether to use the
56  * last frame or not automatically.
57  */
58 #define VP8_EFLAG_NO_REF_LAST (1 << 16)
59 
60 /*!\brief Don't reference the golden frame
61  *
62  * When this flag is set, the encoder will not use the golden frame as a
63  * predictor. When not set, the encoder will choose whether to use the
64  * golden frame or not automatically.
65  */
66 #define VP8_EFLAG_NO_REF_GF (1 << 17)
67 
68 /*!\brief Don't reference the alternate reference frame
69  *
70  * When this flag is set, the encoder will not use the alt ref frame as a
71  * predictor. When not set, the encoder will choose whether to use the
72  * alt ref frame or not automatically.
73  */
74 #define VP8_EFLAG_NO_REF_ARF (1 << 21)
75 
76 /*!\brief Don't update the last frame
77  *
78  * When this flag is set, the encoder will not update the last frame with
79  * the contents of the current frame.
80  */
81 #define VP8_EFLAG_NO_UPD_LAST (1 << 18)
82 
83 /*!\brief Don't update the golden frame
84  *
85  * When this flag is set, the encoder will not update the golden frame with
86  * the contents of the current frame.
87  */
88 #define VP8_EFLAG_NO_UPD_GF (1 << 22)
89 
90 /*!\brief Don't update the alternate reference frame
91  *
92  * When this flag is set, the encoder will not update the alt ref frame with
93  * the contents of the current frame.
94  */
95 #define VP8_EFLAG_NO_UPD_ARF (1 << 23)
96 
97 /*!\brief Force golden frame update
98  *
99  * When this flag is set, the encoder copy the contents of the current frame
100  * to the golden frame buffer.
101  */
102 #define VP8_EFLAG_FORCE_GF (1 << 19)
103 
104 /*!\brief Force alternate reference frame update
105  *
106  * When this flag is set, the encoder copy the contents of the current frame
107  * to the alternate reference frame buffer.
108  */
109 #define VP8_EFLAG_FORCE_ARF (1 << 24)
110 
111 /*!\brief Disable entropy update
112  *
113  * When this flag is set, the encoder will not update its internal entropy
114  * model based on the entropy of this frame.
115  */
116 #define VP8_EFLAG_NO_UPD_ENTROPY (1 << 20)
117 
118 /*!\brief VPx encoder control functions
119  *
120  * This set of macros define the control functions available for VPx
121  * encoder interface.
122  *
123  * \sa #vpx_codec_control
124  */
125 enum vp8e_enc_control_id {
126   /*!\brief Codec control function to pass an ROI map to encoder.
127    *
128    * Supported in codecs: VP8
129    */
130   VP8E_SET_ROI_MAP = 8,
131 
132   /*!\brief Codec control function to pass an Active map to encoder.
133    *
134    * Supported in codecs: VP8, VP9
135    */
136   VP8E_SET_ACTIVEMAP,
137 
138   /*!\brief Codec control function to set encoder scaling mode.
139    *
140    * Supported in codecs: VP8, VP9
141    */
142   VP8E_SET_SCALEMODE = 11,
143 
144   /*!\brief Codec control function to set encoder internal speed settings.
145    *
146    * Changes in this value influences, among others, the encoder's selection
147    * of motion estimation methods. Values greater than 0 will increase encoder
148    * speed at the expense of quality.
149    *
150    * \note Valid range for VP8: -16..16
151    * \note Valid range for VP9: -8..8
152    *
153    * Supported in codecs: VP8, VP9
154    */
155   VP8E_SET_CPUUSED = 13,
156 
157   /*!\brief Codec control function to enable automatic use of arf frames.
158    *
159    * Supported in codecs: VP8, VP9
160    */
161   VP8E_SET_ENABLEAUTOALTREF,
162 
163   /*!\brief control function to set noise sensitivity
164    *
165    * 0: off, 1: OnYOnly, 2: OnYUV,
166    * 3: OnYUVAggressive, 4: Adaptive
167    *
168    * Supported in codecs: VP8
169    */
170   VP8E_SET_NOISE_SENSITIVITY,
171 
172   /*!\brief Codec control function to set higher sharpness at the expense
173    * of a lower PSNR.
174    *
175    * \note Valid range: 0..7
176    *
177    * Supported in codecs: VP8, VP9
178    */
179   VP8E_SET_SHARPNESS,
180 
181   /*!\brief Codec control function to set the threshold for MBs treated static.
182    *
183    * Supported in codecs: VP8, VP9
184    */
185   VP8E_SET_STATIC_THRESHOLD,
186 
187   /*!\brief Codec control function to set the number of token partitions.
188    *
189    * Supported in codecs: VP8
190    */
191   VP8E_SET_TOKEN_PARTITIONS,
192 
193   /*!\brief Codec control function to get last quantizer chosen by the encoder.
194    *
195    * Return value uses internal quantizer scale defined by the codec.
196    *
197    * Supported in codecs: VP8, VP9
198    */
199   VP8E_GET_LAST_QUANTIZER,
200 
201   /*!\brief Codec control function to get last quantizer chosen by the encoder.
202    *
203    * Return value uses the 0..63 scale as used by the rc_*_quantizer config
204    * parameters.
205    *
206    * Supported in codecs: VP8, VP9
207    */
208   VP8E_GET_LAST_QUANTIZER_64,
209 
210   /*!\brief Codec control function to set the max no of frames to create arf.
211    *
212    * Supported in codecs: VP8, VP9
213    */
214   VP8E_SET_ARNR_MAXFRAMES,
215 
216   /*!\brief Codec control function to set the filter strength for the arf.
217    *
218    * Supported in codecs: VP8, VP9
219    */
220   VP8E_SET_ARNR_STRENGTH,
221 
222   /*!\deprecated control function to set the filter type to use for the arf. */
223   VP8E_SET_ARNR_TYPE,
224 
225   /*!\brief Codec control function to set visual tuning.
226    *
227    * Supported in codecs: VP8, VP9
228    */
229   VP8E_SET_TUNING,
230 
231   /*!\brief Codec control function to set constrained quality level.
232    *
233    * \attention For this value to be used vpx_codec_enc_cfg_t::rc_end_usage must
234    *            be set to #VPX_CQ
235    * \note Valid range: 0..63
236    *
237    * Supported in codecs: VP8, VP9
238    */
239   VP8E_SET_CQ_LEVEL,
240 
241   /*!\brief Codec control function to set Max data rate for Intra frames.
242    *
243    * This value controls additional clamping on the maximum size of a
244    * keyframe. It is expressed as a percentage of the average
245    * per-frame bitrate, with the special (and default) value 0 meaning
246    * unlimited, or no additional clamping beyond the codec's built-in
247    * algorithm.
248    *
249    * For example, to allocate no more than 4.5 frames worth of bitrate
250    * to a keyframe, set this to 450.
251    *
252    * Supported in codecs: VP8, VP9
253    */
254   VP8E_SET_MAX_INTRA_BITRATE_PCT,
255 
256   /*!\brief Codec control function to set reference and update frame flags.
257    *
258    *  Supported in codecs: VP8
259    */
260   VP8E_SET_FRAME_FLAGS,
261 
262   /*!\brief Codec control function to set max data rate for Inter frames.
263    *
264    * This value controls additional clamping on the maximum size of an
265    * inter frame. It is expressed as a percentage of the average
266    * per-frame bitrate, with the special (and default) value 0 meaning
267    * unlimited, or no additional clamping beyond the codec's built-in
268    * algorithm.
269    *
270    * For example, to allow no more than 4.5 frames worth of bitrate
271    * to an inter frame, set this to 450.
272    *
273    * Supported in codecs: VP9
274    */
275   VP9E_SET_MAX_INTER_BITRATE_PCT,
276 
277   /*!\brief Boost percentage for Golden Frame in CBR mode.
278    *
279    * This value controls the amount of boost given to Golden Frame in
280    * CBR mode. It is expressed as a percentage of the average
281    * per-frame bitrate, with the special (and default) value 0 meaning
282    * the feature is off, i.e., no golden frame boost in CBR mode and
283    * average bitrate target is used.
284    *
285    * For example, to allow 100% more bits, i.e, 2X, in a golden frame
286    * than average frame, set this to 100.
287    *
288    * Supported in codecs: VP9
289    */
290   VP9E_SET_GF_CBR_BOOST_PCT,
291 
292   /*!\brief Codec control function to set the temporal layer id.
293    *
294    * For temporal scalability: this control allows the application to set the
295    * layer id for each frame to be encoded. Note that this control must be set
296    * for every frame prior to encoding. The usage of this control function
297    * supersedes the internal temporal pattern counter, which is now deprecated.
298    *
299    * Supported in codecs: VP8
300    */
301   VP8E_SET_TEMPORAL_LAYER_ID,
302 
303   /*!\brief Codec control function to set encoder screen content mode.
304    *
305    * 0: off, 1: On, 2: On with more aggressive rate control.
306    *
307    * Supported in codecs: VP8
308    */
309   VP8E_SET_SCREEN_CONTENT_MODE,
310 
311   /*!\brief Codec control function to set lossless encoding mode.
312    *
313    * VP9 can operate in lossless encoding mode, in which the bitstream
314    * produced will be able to decode and reconstruct a perfect copy of
315    * input source. This control function provides a mean to switch encoder
316    * into lossless coding mode(1) or normal coding mode(0) that may be lossy.
317    *                          0 = lossy coding mode
318    *                          1 = lossless coding mode
319    *
320    *  By default, encoder operates in normal coding mode (maybe lossy).
321    *
322    * Supported in codecs: VP9
323    */
324   VP9E_SET_LOSSLESS,
325 
326   /*!\brief Codec control function to set number of tile columns.
327    *
328    * In encoding and decoding, VP9 allows an input image frame be partitioned
329    * into separated vertical tile columns, which can be encoded or decoded
330    * independently. This enables easy implementation of parallel encoding and
331    * decoding. This control requests the encoder to use column tiles in
332    * encoding an input frame, with number of tile columns (in Log2 unit) as
333    * the parameter:
334    *             0 = 1 tile column
335    *             1 = 2 tile columns
336    *             2 = 4 tile columns
337    *             .....
338    *             n = 2**n tile columns
339    * The requested tile columns will be capped by the encoder based on image
340    * size limitations (The minimum width of a tile column is 256 pixels, the
341    * maximum is 4096).
342    *
343    * By default, the value is 6, i.e., the maximum number of tiles supported by
344    * the resolution.
345    *
346    * Supported in codecs: VP9
347    */
348   VP9E_SET_TILE_COLUMNS,
349 
350   /*!\brief Codec control function to set number of tile rows.
351    *
352    * In encoding and decoding, VP9 allows an input image frame be partitioned
353    * into separated horizontal tile rows. Tile rows are encoded or decoded
354    * sequentially. Even though encoding/decoding of later tile rows depends on
355    * earlier ones, this allows the encoder to output data packets for tile rows
356    * prior to completely processing all tile rows in a frame, thereby reducing
357    * the latency in processing between input and output. The parameter
358    * for this control describes the number of tile rows, which has a valid
359    * range [0, 2]:
360    *            0 = 1 tile row
361    *            1 = 2 tile rows
362    *            2 = 4 tile rows
363    *
364    * By default, the value is 0, i.e. one single row tile for entire image.
365    *
366    * Supported in codecs: VP9
367    */
368   VP9E_SET_TILE_ROWS,
369 
370   /*!\brief Codec control function to enable frame parallel decoding feature.
371    *
372    * VP9 has a bitstream feature to reduce decoding dependency between frames
373    * by turning off backward update of probability context used in encoding
374    * and decoding. This allows staged parallel processing of more than one
375    * video frame in the decoder. This control function provides a means to
376    * turn this feature on or off for bitstreams produced by encoder.
377    *
378    * By default, this feature is on.
379    *
380    * Supported in codecs: VP9
381    */
382   VP9E_SET_FRAME_PARALLEL_DECODING,
383 
384   /*!\brief Codec control function to set adaptive quantization mode.
385    *
386    * VP9 has a segment based feature that allows encoder to adaptively change
387    * quantization parameter for each segment within a frame to improve the
388    * subjective quality. This control makes encoder operate in one of the
389    * several AQ_modes supported.
390    *
391    * By default, encoder operates with AQ_Mode 0(adaptive quantization off).
392    *
393    * Supported in codecs: VP9
394    */
395   VP9E_SET_AQ_MODE,
396 
397   /*!\brief Codec control function to enable/disable periodic Q boost.
398    *
399    * One VP9 encoder speed feature is to enable quality boost by lowering
400    * frame level Q periodically. This control function provides a mean to
401    * turn on/off this feature.
402    *               0 = off
403    *               1 = on
404    *
405    * By default, the encoder is allowed to use this feature for appropriate
406    * encoding modes.
407    *
408    * Supported in codecs: VP9
409    */
410   VP9E_SET_FRAME_PERIODIC_BOOST,
411 
412   /*!\brief Codec control function to set noise sensitivity.
413    *
414    *  0: off, 1: On(YOnly), 2: For SVC only, on top two spatial layers(YOnly)
415    *
416    * Supported in codecs: VP9
417    */
418   VP9E_SET_NOISE_SENSITIVITY,
419 
420   /*!\brief Codec control function to turn on/off SVC in encoder.
421    * \note Return value is VPX_CODEC_INVALID_PARAM if the encoder does not
422    *       support SVC in its current encoding mode
423    *  0: off, 1: on
424    *
425    * Supported in codecs: VP9
426    */
427   VP9E_SET_SVC,
428 
429   /*!\brief Codec control function to pass an ROI map to encoder.
430    *
431    * Supported in codecs: VP9
432    */
433   VP9E_SET_ROI_MAP,
434 
435   /*!\brief Codec control function to set parameters for SVC.
436    * \note Parameters contain min_q, max_q, scaling factor for each of the
437    *       SVC layers.
438    *
439    * Supported in codecs: VP9
440    */
441   VP9E_SET_SVC_PARAMETERS,
442 
443   /*!\brief Codec control function to set svc layer for spatial and temporal.
444    * \note Valid ranges: 0..#vpx_codec_enc_cfg::ss_number_layers for spatial
445    *                     layer and 0..#vpx_codec_enc_cfg::ts_number_layers for
446    *                     temporal layer.
447    *
448    * Supported in codecs: VP9
449    */
450   VP9E_SET_SVC_LAYER_ID,
451 
452   /*!\brief Codec control function to set content type.
453    * \note Valid parameter range:
454    *              VP9E_CONTENT_DEFAULT = Regular video content (Default)
455    *              VP9E_CONTENT_SCREEN  = Screen capture content
456    *              VP9E_CONTENT_FILM    = Film content: improves grain retention
457    *
458    * Supported in codecs: VP9
459    */
460   VP9E_SET_TUNE_CONTENT,
461 
462   /*!\brief Codec control function to get svc layer ID.
463    * \note The layer ID returned is for the data packet from the registered
464    *       callback function.
465    *
466    * Supported in codecs: VP9
467    */
468   VP9E_GET_SVC_LAYER_ID,
469 
470   /*!\brief Codec control function to register callback to get per layer packet.
471    * \note Parameter for this control function is a structure with a callback
472    *       function and a pointer to private data used by the callback.
473    *
474    * Supported in codecs: VP9
475    */
476   VP9E_REGISTER_CX_CALLBACK,
477 
478   /*!\brief Codec control function to set color space info.
479    * \note Valid ranges: 0..7, default is "UNKNOWN".
480    *                     0 = UNKNOWN,
481    *                     1 = BT_601
482    *                     2 = BT_709
483    *                     3 = SMPTE_170
484    *                     4 = SMPTE_240
485    *                     5 = BT_2020
486    *                     6 = RESERVED
487    *                     7 = SRGB
488    *
489    * Supported in codecs: VP9
490    */
491   VP9E_SET_COLOR_SPACE,
492 
493   /*!\brief Codec control function to set temporal layering mode.
494    * \note Valid ranges: 0..3, default is "0"
495    * (VP9E_TEMPORAL_LAYERING_MODE_NOLAYERING).
496    *                     0 = VP9E_TEMPORAL_LAYERING_MODE_NOLAYERING
497    *                     1 = VP9E_TEMPORAL_LAYERING_MODE_BYPASS
498    *                     2 = VP9E_TEMPORAL_LAYERING_MODE_0101
499    *                     3 = VP9E_TEMPORAL_LAYERING_MODE_0212
500    *
501    * Supported in codecs: VP9
502    */
503   VP9E_SET_TEMPORAL_LAYERING_MODE,
504 
505   /*!\brief Codec control function to set minimum interval between GF/ARF frames
506    *
507    * By default the value is set as 4.
508    *
509    * Supported in codecs: VP9
510    */
511   VP9E_SET_MIN_GF_INTERVAL,
512 
513   /*!\brief Codec control function to set minimum interval between GF/ARF frames
514    *
515    * By default the value is set as 16.
516    *
517    * Supported in codecs: VP9
518    */
519   VP9E_SET_MAX_GF_INTERVAL,
520 
521   /*!\brief Codec control function to get an Active map back from the encoder.
522    *
523    * Supported in codecs: VP9
524    */
525   VP9E_GET_ACTIVEMAP,
526 
527   /*!\brief Codec control function to set color range bit.
528    * \note Valid ranges: 0..1, default is 0
529    *                     0 = Limited range (16..235 or HBD equivalent)
530    *                     1 = Full range (0..255 or HBD equivalent)
531    *
532    * Supported in codecs: VP9
533    */
534   VP9E_SET_COLOR_RANGE,
535 
536   /*!\brief Codec control function to set the frame flags and buffer indices
537    * for spatial layers. The frame flags and buffer indices are set using the
538    * struct #vpx_svc_ref_frame_config defined below.
539    *
540    * Supported in codecs: VP9
541    */
542   VP9E_SET_SVC_REF_FRAME_CONFIG,
543 
544   /*!\brief Codec control function to set intended rendering image size.
545    *
546    * By default, this is identical to the image size in pixels.
547    *
548    * Supported in codecs: VP9
549    */
550   VP9E_SET_RENDER_SIZE,
551 
552   /*!\brief Codec control function to set target level.
553    *
554    * 255: off (default); 0: only keep level stats; 10: target for level 1.0;
555    * 11: target for level 1.1; ... 62: target for level 6.2
556    *
557    * Supported in codecs: VP9
558    */
559   VP9E_SET_TARGET_LEVEL,
560 
561   /*!\brief Codec control function to set row level multi-threading.
562    *
563    * 0 : off, 1 : on
564    *
565    * Supported in codecs: VP9
566    */
567   VP9E_SET_ROW_MT,
568 
569   /*!\brief Codec control function to get bitstream level.
570    *
571    * Supported in codecs: VP9
572    */
573   VP9E_GET_LEVEL,
574 
575   /*!\brief Codec control function to enable/disable special mode for altref
576    *        adaptive quantization. You can use it with --aq-mode concurrently.
577    *
578    * Enable special adaptive quantization for altref frames based on their
579    * expected prediction quality for the future frames.
580    *
581    * Supported in codecs: VP9
582    */
583   VP9E_SET_ALT_REF_AQ,
584 
585   /*!\brief Boost percentage for Golden Frame in CBR mode.
586    *
587    * This value controls the amount of boost given to Golden Frame in
588    * CBR mode. It is expressed as a percentage of the average
589    * per-frame bitrate, with the special (and default) value 0 meaning
590    * the feature is off, i.e., no golden frame boost in CBR mode and
591    * average bitrate target is used.
592    *
593    * For example, to allow 100% more bits, i.e, 2X, in a golden frame
594    * than average frame, set this to 100.
595    *
596    * Supported in codecs: VP8
597    */
598   VP8E_SET_GF_CBR_BOOST_PCT,
599 
600   /*!\brief Codec control function to enable the extreme motion vector unit test
601    * in VP9. Please note that this is only used in motion vector unit test.
602    *
603    * 0 : off, 1 : MAX_EXTREME_MV, 2 : MIN_EXTREME_MV
604    *
605    * Supported in codecs: VP9
606    */
607   VP9E_ENABLE_MOTION_VECTOR_UNIT_TEST,
608 
609   /*!\brief Codec control function to constrain the inter-layer prediction
610    * (prediction of lower spatial resolution) in VP9 SVC.
611    *
612    * 0 : inter-layer prediction on, 1 : off, 2 : off only on non-key frames
613    *
614    * Supported in codecs: VP9
615    */
616   VP9E_SET_SVC_INTER_LAYER_PRED,
617 
618   /*!\brief Codec control function to set mode and thresholds for frame
619    *  dropping in SVC. Drop frame thresholds are set per-layer. Mode is set as:
620    * 0 : layer-dependent dropping, 1 : constrained dropping, current layer drop
621    * forces drop on all upper layers. Default mode is 0.
622    *
623    * Supported in codecs: VP9
624    */
625   VP9E_SET_SVC_FRAME_DROP_LAYER,
626 
627   /*!\brief Codec control function to get the refresh and reference flags and
628    * the buffer indices, up to the last encoded spatial layer.
629    *
630    * Supported in codecs: VP9
631    */
632   VP9E_GET_SVC_REF_FRAME_CONFIG,
633 
634   /*!\brief Codec control function to enable/disable use of golden reference as
635    * a second temporal reference for SVC. Only used when inter-layer prediction
636    * is disabled on INTER frames.
637    *
638    * 0: Off, 1: Enabled (default)
639    *
640    * Supported in codecs: VP9
641    */
642   VP9E_SET_SVC_GF_TEMPORAL_REF,
643 
644   /*!\brief Codec control function to enable spatial layer sync frame, for any
645    * spatial layer. Enabling it for layer k means spatial layer k will disable
646    * all temporal prediction, but keep the inter-layer prediction. It will
647    * refresh any temporal reference buffer for that layer, and reset the
648    * temporal layer for the superframe to 0. Setting the layer sync for base
649    * spatial layer forces a key frame. Default is off (0) for all spatial
650    * layers. Spatial layer sync flag is reset to 0 after each encoded layer,
651    * so when control is invoked it is only used for the current superframe.
652    *
653    * 0: Off (default), 1: Enabled
654    *
655    * Supported in codecs: VP9
656    */
657   VP9E_SET_SVC_SPATIAL_LAYER_SYNC,
658 
659   /*!\brief Codec control function to enable temporal dependency model.
660    *
661    * Vp9 allows the encoder to run temporal dependency model and use it to
662    * improve the compression performance. To enable, set this parameter to be
663    * 1. The default value is set to be 1.
664    */
665   VP9E_SET_TPL,
666 
667   /*!\brief Codec control function to enable postencode frame drop.
668    *
669    * This will allow encoder to drop frame after it's encoded.
670    *
671    * 0: Off (default), 1: Enabled
672    *
673    * Supported in codecs: VP9
674    */
675   VP9E_SET_POSTENCODE_DROP,
676 };
677 
678 /*!\brief vpx 1-D scaling mode
679  *
680  * This set of constants define 1-D vpx scaling modes
681  */
682 typedef enum vpx_scaling_mode_1d {
683   VP8E_NORMAL = 0,
684   VP8E_FOURFIVE = 1,
685   VP8E_THREEFIVE = 2,
686   VP8E_ONETWO = 3
687 } VPX_SCALING_MODE;
688 
689 /*!\brief Temporal layering mode enum for VP9 SVC.
690  *
691  * This set of macros define the different temporal layering modes.
692  * Supported codecs: VP9 (in SVC mode)
693  *
694  */
695 typedef enum vp9e_temporal_layering_mode {
696   /*!\brief No temporal layering.
697    * Used when only spatial layering is used.
698    */
699   VP9E_TEMPORAL_LAYERING_MODE_NOLAYERING = 0,
700 
701   /*!\brief Bypass mode.
702    * Used when application needs to control temporal layering.
703    * This will only work when the number of spatial layers equals 1.
704    */
705   VP9E_TEMPORAL_LAYERING_MODE_BYPASS = 1,
706 
707   /*!\brief 0-1-0-1... temporal layering scheme with two temporal layers.
708    */
709   VP9E_TEMPORAL_LAYERING_MODE_0101 = 2,
710 
711   /*!\brief 0-2-1-2... temporal layering scheme with three temporal layers.
712    */
713   VP9E_TEMPORAL_LAYERING_MODE_0212 = 3
714 } VP9E_TEMPORAL_LAYERING_MODE;
715 
716 /*!\brief  vpx region of interest map
717  *
718  * These defines the data structures for the region of interest map
719  *
720  */
721 
722 typedef struct vpx_roi_map {
723   /*! If ROI is enabled. */
724   uint8_t enabled;
725   /*! An id between 0-3 (0-7 for vp9) for each 16x16 (8x8 for VP9)
726    * region within a frame. */
727   unsigned char *roi_map;
728   unsigned int rows; /**< Number of rows. */
729   unsigned int cols; /**< Number of columns. */
730   /*! VP8 only uses the first 4 segments. VP9 uses 8 segments. */
731   int delta_q[8];  /**< Quantizer deltas. */
732   int delta_lf[8]; /**< Loop filter deltas. */
733   /*! skip and ref frame segment is only used in VP9. */
734   int skip[8];      /**< Skip this block. */
735   int ref_frame[8]; /**< Reference frame for this block. */
736   /*! Static breakout threshold for each segment. Only used in VP8. */
737   unsigned int static_threshold[4];
738 } vpx_roi_map_t;
739 
740 /*!\brief  vpx active region map
741  *
742  * These defines the data structures for active region map
743  *
744  */
745 
746 typedef struct vpx_active_map {
747   /*!\brief specify an on (1) or off (0) each 16x16 region within a frame */
748   unsigned char *active_map;
749   unsigned int rows; /**< number of rows */
750   unsigned int cols; /**< number of cols */
751 } vpx_active_map_t;
752 
753 /*!\brief  vpx image scaling mode
754  *
755  * This defines the data structure for image scaling mode
756  *
757  */
758 typedef struct vpx_scaling_mode {
759   VPX_SCALING_MODE h_scaling_mode; /**< horizontal scaling mode */
760   VPX_SCALING_MODE v_scaling_mode; /**< vertical scaling mode   */
761 } vpx_scaling_mode_t;
762 
763 /*!\brief VP8 token partition mode
764  *
765  * This defines VP8 partitioning mode for compressed data, i.e., the number of
766  * sub-streams in the bitstream. Used for parallelized decoding.
767  *
768  */
769 
770 typedef enum {
771   VP8_ONE_TOKENPARTITION = 0,
772   VP8_TWO_TOKENPARTITION = 1,
773   VP8_FOUR_TOKENPARTITION = 2,
774   VP8_EIGHT_TOKENPARTITION = 3
775 } vp8e_token_partitions;
776 
777 /*!brief VP9 encoder content type */
778 typedef enum {
779   VP9E_CONTENT_DEFAULT,
780   VP9E_CONTENT_SCREEN,
781   VP9E_CONTENT_FILM,
782   VP9E_CONTENT_INVALID
783 } vp9e_tune_content;
784 
785 /*!\brief VP8 model tuning parameters
786  *
787  * Changes the encoder to tune for certain types of input material.
788  *
789  */
790 typedef enum { VP8_TUNE_PSNR, VP8_TUNE_SSIM } vp8e_tuning;
791 
792 /*!\brief  vp9 svc layer parameters
793  *
794  * This defines the spatial and temporal layer id numbers for svc encoding.
795  * This is used with the #VP9E_SET_SVC_LAYER_ID control to set the spatial and
796  * temporal layer id for the current frame.
797  *
798  */
799 typedef struct vpx_svc_layer_id {
800   int spatial_layer_id; /**< First spatial layer to start encoding. */
801   // TODO(jianj): Deprecated, to be removed.
802   int temporal_layer_id; /**< Temporal layer id number. */
803   int temporal_layer_id_per_spatial[VPX_SS_MAX_LAYERS]; /**< Temp layer id. */
804 } vpx_svc_layer_id_t;
805 
806 /*!\brief vp9 svc frame flag parameters.
807  *
808  * This defines the frame flags and buffer indices for each spatial layer for
809  * svc encoding.
810  * This is used with the #VP9E_SET_SVC_REF_FRAME_CONFIG control to set frame
811  * flags and buffer indices for each spatial layer for the current (super)frame.
812  *
813  */
814 typedef struct vpx_svc_ref_frame_config {
815   int lst_fb_idx[VPX_SS_MAX_LAYERS];         /**< Last buffer index. */
816   int gld_fb_idx[VPX_SS_MAX_LAYERS];         /**< Golden buffer index. */
817   int alt_fb_idx[VPX_SS_MAX_LAYERS];         /**< Altref buffer index. */
818   int update_buffer_slot[VPX_SS_MAX_LAYERS]; /**< Update reference frames. */
819   // TODO(jianj): Remove update_last/golden/alt_ref, these are deprecated.
820   int update_last[VPX_SS_MAX_LAYERS];       /**< Update last. */
821   int update_golden[VPX_SS_MAX_LAYERS];     /**< Update golden. */
822   int update_alt_ref[VPX_SS_MAX_LAYERS];    /**< Update altref. */
823   int reference_last[VPX_SS_MAX_LAYERS];    /**< Last as reference. */
824   int reference_golden[VPX_SS_MAX_LAYERS];  /**< Golden as reference. */
825   int reference_alt_ref[VPX_SS_MAX_LAYERS]; /**< Altref as reference. */
826   int64_t duration[VPX_SS_MAX_LAYERS];      /**< Duration per spatial layer. */
827 } vpx_svc_ref_frame_config_t;
828 
829 /*!\brief VP9 svc frame dropping mode.
830  *
831  * This defines the frame drop mode for SVC.
832  *
833  */
834 typedef enum {
835   CONSTRAINED_LAYER_DROP,
836   /**< Upper layers are constrained to drop if current layer drops. */
837   LAYER_DROP,           /**< Any spatial layer can drop. */
838   FULL_SUPERFRAME_DROP, /**< Only full superframe can drop. */
839 } SVC_LAYER_DROP_MODE;
840 
841 /*!\brief vp9 svc frame dropping parameters.
842  *
843  * This defines the frame drop thresholds for each spatial layer, and
844  * the frame dropping mode: 0 = layer based frame dropping (default),
845  * 1 = constrained dropping where current layer drop forces all upper
846  * spatial layers to drop.
847  */
848 typedef struct vpx_svc_frame_drop {
849   int framedrop_thresh[VPX_SS_MAX_LAYERS]; /**< Frame drop thresholds */
850   SVC_LAYER_DROP_MODE
851   framedrop_mode;      /**< Layer-based or constrained dropping. */
852   int max_consec_drop; /**< Maximum consecutive drops, for any layer. */
853 } vpx_svc_frame_drop_t;
854 
855 /*!\brief vp9 svc spatial layer sync parameters.
856  *
857  * This defines the spatial layer sync flag, defined per spatial layer.
858  *
859  */
860 typedef struct vpx_svc_spatial_layer_sync {
861   int spatial_layer_sync[VPX_SS_MAX_LAYERS]; /**< Sync layer flags */
862   int base_layer_intra_only; /**< Flag for setting Intra-only frame on base */
863 } vpx_svc_spatial_layer_sync_t;
864 
865 /*!\cond */
866 /*!\brief VP8 encoder control function parameter type
867  *
868  * Defines the data types that VP8E control functions take. Note that
869  * additional common controls are defined in vp8.h
870  *
871  */
872 
873 VPX_CTRL_USE_TYPE(VP8E_SET_FRAME_FLAGS, int)
874 #define VPX_CTRL_VP8E_SET_FRAME_FLAGS
875 VPX_CTRL_USE_TYPE(VP8E_SET_TEMPORAL_LAYER_ID, int)
876 #define VPX_CTRL_VP8E_SET_TEMPORAL_LAYER_ID
877 VPX_CTRL_USE_TYPE(VP8E_SET_ROI_MAP, vpx_roi_map_t *)
878 #define VPX_CTRL_VP8E_SET_ROI_MAP
879 VPX_CTRL_USE_TYPE(VP9E_SET_ROI_MAP, vpx_roi_map_t *)
880 #define VPX_CTRL_VP9E_SET_ROI_MAP
881 VPX_CTRL_USE_TYPE(VP8E_SET_ACTIVEMAP, vpx_active_map_t *)
882 #define VPX_CTRL_VP8E_SET_ACTIVEMAP
883 VPX_CTRL_USE_TYPE(VP8E_SET_SCALEMODE, vpx_scaling_mode_t *)
884 #define VPX_CTRL_VP8E_SET_SCALEMODE
885 
886 VPX_CTRL_USE_TYPE(VP9E_SET_SVC, int)
887 #define VPX_CTRL_VP9E_SET_SVC
888 VPX_CTRL_USE_TYPE(VP9E_SET_SVC_PARAMETERS, void *)
889 #define VPX_CTRL_VP9E_SET_SVC_PARAMETERS
890 VPX_CTRL_USE_TYPE(VP9E_REGISTER_CX_CALLBACK, void *)
891 #define VPX_CTRL_VP9E_REGISTER_CX_CALLBACK
892 VPX_CTRL_USE_TYPE(VP9E_SET_SVC_LAYER_ID, vpx_svc_layer_id_t *)
893 #define VPX_CTRL_VP9E_SET_SVC_LAYER_ID
894 
895 VPX_CTRL_USE_TYPE(VP8E_SET_CPUUSED, int)
896 #define VPX_CTRL_VP8E_SET_CPUUSED
897 VPX_CTRL_USE_TYPE(VP8E_SET_ENABLEAUTOALTREF, unsigned int)
898 #define VPX_CTRL_VP8E_SET_ENABLEAUTOALTREF
899 VPX_CTRL_USE_TYPE(VP8E_SET_NOISE_SENSITIVITY, unsigned int)
900 #define VPX_CTRL_VP8E_SET_NOISE_SENSITIVITY
901 VPX_CTRL_USE_TYPE(VP8E_SET_SHARPNESS, unsigned int)
902 #define VPX_CTRL_VP8E_SET_SHARPNESS
903 VPX_CTRL_USE_TYPE(VP8E_SET_STATIC_THRESHOLD, unsigned int)
904 #define VPX_CTRL_VP8E_SET_STATIC_THRESHOLD
905 VPX_CTRL_USE_TYPE(VP8E_SET_TOKEN_PARTITIONS, int) /* vp8e_token_partitions */
906 #define VPX_CTRL_VP8E_SET_TOKEN_PARTITIONS
907 
908 VPX_CTRL_USE_TYPE(VP8E_SET_ARNR_MAXFRAMES, unsigned int)
909 #define VPX_CTRL_VP8E_SET_ARNR_MAXFRAMES
910 VPX_CTRL_USE_TYPE(VP8E_SET_ARNR_STRENGTH, unsigned int)
911 #define VPX_CTRL_VP8E_SET_ARNR_STRENGTH
912 VPX_CTRL_USE_TYPE_DEPRECATED(VP8E_SET_ARNR_TYPE, unsigned int)
913 #define VPX_CTRL_VP8E_SET_ARNR_TYPE
914 VPX_CTRL_USE_TYPE(VP8E_SET_TUNING, int) /* vp8e_tuning */
915 #define VPX_CTRL_VP8E_SET_TUNING
916 VPX_CTRL_USE_TYPE(VP8E_SET_CQ_LEVEL, unsigned int)
917 #define VPX_CTRL_VP8E_SET_CQ_LEVEL
918 
919 VPX_CTRL_USE_TYPE(VP9E_SET_TILE_COLUMNS, int)
920 #define VPX_CTRL_VP9E_SET_TILE_COLUMNS
921 VPX_CTRL_USE_TYPE(VP9E_SET_TILE_ROWS, int)
922 #define VPX_CTRL_VP9E_SET_TILE_ROWS
923 
924 VPX_CTRL_USE_TYPE(VP9E_SET_TPL, int)
925 #define VPX_CTRL_VP9E_SET_TPL
926 
927 VPX_CTRL_USE_TYPE(VP8E_GET_LAST_QUANTIZER, int *)
928 #define VPX_CTRL_VP8E_GET_LAST_QUANTIZER
929 VPX_CTRL_USE_TYPE(VP8E_GET_LAST_QUANTIZER_64, int *)
930 #define VPX_CTRL_VP8E_GET_LAST_QUANTIZER_64
931 VPX_CTRL_USE_TYPE(VP9E_GET_SVC_LAYER_ID, vpx_svc_layer_id_t *)
932 #define VPX_CTRL_VP9E_GET_SVC_LAYER_ID
933 
934 VPX_CTRL_USE_TYPE(VP8E_SET_MAX_INTRA_BITRATE_PCT, unsigned int)
935 #define VPX_CTRL_VP8E_SET_MAX_INTRA_BITRATE_PCT
936 VPX_CTRL_USE_TYPE(VP8E_SET_MAX_INTER_BITRATE_PCT, unsigned int)
937 #define VPX_CTRL_VP8E_SET_MAX_INTER_BITRATE_PCT
938 
939 VPX_CTRL_USE_TYPE(VP8E_SET_GF_CBR_BOOST_PCT, unsigned int)
940 #define VPX_CTRL_VP8E_SET_GF_CBR_BOOST_PCT
941 
942 VPX_CTRL_USE_TYPE(VP8E_SET_SCREEN_CONTENT_MODE, unsigned int)
943 #define VPX_CTRL_VP8E_SET_SCREEN_CONTENT_MODE
944 
945 VPX_CTRL_USE_TYPE(VP9E_SET_GF_CBR_BOOST_PCT, unsigned int)
946 #define VPX_CTRL_VP9E_SET_GF_CBR_BOOST_PCT
947 
948 VPX_CTRL_USE_TYPE(VP9E_SET_LOSSLESS, unsigned int)
949 #define VPX_CTRL_VP9E_SET_LOSSLESS
950 
951 VPX_CTRL_USE_TYPE(VP9E_SET_FRAME_PARALLEL_DECODING, unsigned int)
952 #define VPX_CTRL_VP9E_SET_FRAME_PARALLEL_DECODING
953 
954 VPX_CTRL_USE_TYPE(VP9E_SET_AQ_MODE, unsigned int)
955 #define VPX_CTRL_VP9E_SET_AQ_MODE
956 
957 VPX_CTRL_USE_TYPE(VP9E_SET_ALT_REF_AQ, int)
958 #define VPX_CTRL_VP9E_SET_ALT_REF_AQ
959 
960 VPX_CTRL_USE_TYPE(VP9E_SET_FRAME_PERIODIC_BOOST, unsigned int)
961 #define VPX_CTRL_VP9E_SET_FRAME_PERIODIC_BOOST
962 
963 VPX_CTRL_USE_TYPE(VP9E_SET_NOISE_SENSITIVITY, unsigned int)
964 #define VPX_CTRL_VP9E_SET_NOISE_SENSITIVITY
965 
966 VPX_CTRL_USE_TYPE(VP9E_SET_TUNE_CONTENT, int) /* vp9e_tune_content */
967 #define VPX_CTRL_VP9E_SET_TUNE_CONTENT
968 
969 VPX_CTRL_USE_TYPE(VP9E_SET_COLOR_SPACE, int)
970 #define VPX_CTRL_VP9E_SET_COLOR_SPACE
971 
972 VPX_CTRL_USE_TYPE(VP9E_SET_MIN_GF_INTERVAL, unsigned int)
973 #define VPX_CTRL_VP9E_SET_MIN_GF_INTERVAL
974 
975 VPX_CTRL_USE_TYPE(VP9E_SET_MAX_GF_INTERVAL, unsigned int)
976 #define VPX_CTRL_VP9E_SET_MAX_GF_INTERVAL
977 
978 VPX_CTRL_USE_TYPE(VP9E_GET_ACTIVEMAP, vpx_active_map_t *)
979 #define VPX_CTRL_VP9E_GET_ACTIVEMAP
980 
981 VPX_CTRL_USE_TYPE(VP9E_SET_COLOR_RANGE, int)
982 #define VPX_CTRL_VP9E_SET_COLOR_RANGE
983 
984 VPX_CTRL_USE_TYPE(VP9E_SET_SVC_REF_FRAME_CONFIG, vpx_svc_ref_frame_config_t *)
985 #define VPX_CTRL_VP9E_SET_SVC_REF_FRAME_CONFIG
986 
987 VPX_CTRL_USE_TYPE(VP9E_SET_RENDER_SIZE, int *)
988 #define VPX_CTRL_VP9E_SET_RENDER_SIZE
989 
990 VPX_CTRL_USE_TYPE(VP9E_SET_TARGET_LEVEL, unsigned int)
991 #define VPX_CTRL_VP9E_SET_TARGET_LEVEL
992 
993 VPX_CTRL_USE_TYPE(VP9E_SET_ROW_MT, unsigned int)
994 #define VPX_CTRL_VP9E_SET_ROW_MT
995 
996 VPX_CTRL_USE_TYPE(VP9E_GET_LEVEL, int *)
997 #define VPX_CTRL_VP9E_GET_LEVEL
998 
999 VPX_CTRL_USE_TYPE(VP9E_ENABLE_MOTION_VECTOR_UNIT_TEST, unsigned int)
1000 #define VPX_CTRL_VP9E_ENABLE_MOTION_VECTOR_UNIT_TEST
1001 
1002 VPX_CTRL_USE_TYPE(VP9E_SET_SVC_INTER_LAYER_PRED, unsigned int)
1003 #define VPX_CTRL_VP9E_SET_SVC_INTER_LAYER_PRED
1004 
1005 VPX_CTRL_USE_TYPE(VP9E_SET_SVC_FRAME_DROP_LAYER, vpx_svc_frame_drop_t *)
1006 #define VPX_CTRL_VP9E_SET_SVC_FRAME_DROP_LAYER
1007 
1008 VPX_CTRL_USE_TYPE(VP9E_GET_SVC_REF_FRAME_CONFIG, vpx_svc_ref_frame_config_t *)
1009 #define VPX_CTRL_VP9E_GET_SVC_REF_FRAME_CONFIG
1010 
1011 VPX_CTRL_USE_TYPE(VP9E_SET_SVC_GF_TEMPORAL_REF, unsigned int)
1012 #define VPX_CTRL_VP9E_SET_SVC_GF_TEMPORAL_REF
1013 
1014 VPX_CTRL_USE_TYPE(VP9E_SET_SVC_SPATIAL_LAYER_SYNC,
1015                   vpx_svc_spatial_layer_sync_t *)
1016 #define VPX_CTRL_VP9E_SET_SVC_SPATIAL_LAYER_SYNC
1017 
1018 VPX_CTRL_USE_TYPE(VP9E_SET_POSTENCODE_DROP, unsigned int)
1019 #define VPX_CTRL_VP9E_SET_POSTENCODE_DROP
1020 
1021 /*!\endcond */
1022 /*! @} - end defgroup vp8_encoder */
1023 #ifdef __cplusplus
1024 }  // extern "C"
1025 #endif
1026 
1027 #endif  // VPX_VPX_VP8CX_H_
1028