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