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