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