vp8cx.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874
  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_VP8CX_H_
  11. #define VPX_VP8CX_H_
  12. /*!\defgroup vp8_encoder WebM VP8/VP9 Encoder
  13. * \ingroup vp8
  14. *
  15. * @{
  16. */
  17. #include "./vp8.h"
  18. #include "./vpx_encoder.h"
  19. /*!\file
  20. * \brief Provides definitions for using VP8 or VP9 encoder algorithm within the
  21. * vpx Codec Interface.
  22. */
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /*!\name Algorithm interface for VP8
  27. *
  28. * This interface provides the capability to encode raw VP8 streams.
  29. * @{
  30. */
  31. extern vpx_codec_iface_t vpx_codec_vp8_cx_algo;
  32. extern vpx_codec_iface_t *vpx_codec_vp8_cx(void);
  33. /*!@} - end algorithm interface member group*/
  34. /*!\name Algorithm interface for VP9
  35. *
  36. * This interface provides the capability to encode raw VP9 streams.
  37. * @{
  38. */
  39. extern vpx_codec_iface_t vpx_codec_vp9_cx_algo;
  40. extern vpx_codec_iface_t *vpx_codec_vp9_cx(void);
  41. /*!@} - end algorithm interface member group*/
  42. /*
  43. * Algorithm Flags
  44. */
  45. /*!\brief Don't reference the last frame
  46. *
  47. * When this flag is set, the encoder will not use the last frame as a
  48. * predictor. When not set, the encoder will choose whether to use the
  49. * last frame or not automatically.
  50. */
  51. #define VP8_EFLAG_NO_REF_LAST (1 << 16)
  52. /*!\brief Don't reference the golden frame
  53. *
  54. * When this flag is set, the encoder will not use the golden frame as a
  55. * predictor. When not set, the encoder will choose whether to use the
  56. * golden frame or not automatically.
  57. */
  58. #define VP8_EFLAG_NO_REF_GF (1 << 17)
  59. /*!\brief Don't reference the alternate reference frame
  60. *
  61. * When this flag is set, the encoder will not use the alt ref frame as a
  62. * predictor. When not set, the encoder will choose whether to use the
  63. * alt ref frame or not automatically.
  64. */
  65. #define VP8_EFLAG_NO_REF_ARF (1 << 21)
  66. /*!\brief Don't update the last frame
  67. *
  68. * When this flag is set, the encoder will not update the last frame with
  69. * the contents of the current frame.
  70. */
  71. #define VP8_EFLAG_NO_UPD_LAST (1 << 18)
  72. /*!\brief Don't update the golden frame
  73. *
  74. * When this flag is set, the encoder will not update the golden frame with
  75. * the contents of the current frame.
  76. */
  77. #define VP8_EFLAG_NO_UPD_GF (1 << 22)
  78. /*!\brief Don't update the alternate reference frame
  79. *
  80. * When this flag is set, the encoder will not update the alt ref frame with
  81. * the contents of the current frame.
  82. */
  83. #define VP8_EFLAG_NO_UPD_ARF (1 << 23)
  84. /*!\brief Force golden frame update
  85. *
  86. * When this flag is set, the encoder copy the contents of the current frame
  87. * to the golden frame buffer.
  88. */
  89. #define VP8_EFLAG_FORCE_GF (1 << 19)
  90. /*!\brief Force alternate reference frame update
  91. *
  92. * When this flag is set, the encoder copy the contents of the current frame
  93. * to the alternate reference frame buffer.
  94. */
  95. #define VP8_EFLAG_FORCE_ARF (1 << 24)
  96. /*!\brief Disable entropy update
  97. *
  98. * When this flag is set, the encoder will not update its internal entropy
  99. * model based on the entropy of this frame.
  100. */
  101. #define VP8_EFLAG_NO_UPD_ENTROPY (1 << 20)
  102. /*!\brief VPx encoder control functions
  103. *
  104. * This set of macros define the control functions available for VPx
  105. * encoder interface.
  106. *
  107. * \sa #vpx_codec_control
  108. */
  109. enum vp8e_enc_control_id {
  110. /*!\brief Codec control function to pass an ROI map to encoder.
  111. *
  112. * Supported in codecs: VP8, VP9
  113. */
  114. VP8E_SET_ROI_MAP = 8,
  115. /*!\brief Codec control function to pass an Active map to encoder.
  116. *
  117. * Supported in codecs: VP8, VP9
  118. */
  119. VP8E_SET_ACTIVEMAP,
  120. /*!\brief Codec control function to set encoder scaling mode.
  121. *
  122. * Supported in codecs: VP8, VP9
  123. */
  124. VP8E_SET_SCALEMODE = 11,
  125. /*!\brief Codec control function to set encoder internal speed settings.
  126. *
  127. * Changes in this value influences, among others, the encoder's selection
  128. * of motion estimation methods. Values greater than 0 will increase encoder
  129. * speed at the expense of quality.
  130. *
  131. * \note Valid range for VP8: -16..16
  132. * \note Valid range for VP9: -8..8
  133. *
  134. * Supported in codecs: VP8, VP9
  135. */
  136. VP8E_SET_CPUUSED = 13,
  137. /*!\brief Codec control function to enable automatic set and use alf frames.
  138. *
  139. * Supported in codecs: VP8, VP9
  140. */
  141. VP8E_SET_ENABLEAUTOALTREF,
  142. /*!\brief control function to set noise sensitivity
  143. *
  144. * 0: off, 1: OnYOnly, 2: OnYUV,
  145. * 3: OnYUVAggressive, 4: Adaptive
  146. *
  147. * Supported in codecs: VP8
  148. */
  149. VP8E_SET_NOISE_SENSITIVITY,
  150. /*!\brief Codec control function to set sharpness.
  151. *
  152. * Supported in codecs: VP8, VP9
  153. */
  154. VP8E_SET_SHARPNESS,
  155. /*!\brief Codec control function to set the threshold for MBs treated static.
  156. *
  157. * Supported in codecs: VP8, VP9
  158. */
  159. VP8E_SET_STATIC_THRESHOLD,
  160. /*!\brief Codec control function to set the number of token partitions.
  161. *
  162. * Supported in codecs: VP8
  163. */
  164. VP8E_SET_TOKEN_PARTITIONS,
  165. /*!\brief Codec control function to get last quantizer chosen by the encoder.
  166. *
  167. * Return value uses internal quantizer scale defined by the codec.
  168. *
  169. * Supported in codecs: VP8, VP9
  170. */
  171. VP8E_GET_LAST_QUANTIZER,
  172. /*!\brief Codec control function to get last quantizer chosen by the encoder.
  173. *
  174. * Return value uses the 0..63 scale as used by the rc_*_quantizer config
  175. * parameters.
  176. *
  177. * Supported in codecs: VP8, VP9
  178. */
  179. VP8E_GET_LAST_QUANTIZER_64,
  180. /*!\brief Codec control function to set the max no of frames to create arf.
  181. *
  182. * Supported in codecs: VP8, VP9
  183. */
  184. VP8E_SET_ARNR_MAXFRAMES,
  185. /*!\brief Codec control function to set the filter strength for the arf.
  186. *
  187. * Supported in codecs: VP8, VP9
  188. */
  189. VP8E_SET_ARNR_STRENGTH,
  190. /*!\deprecated control function to set the filter type to use for the arf. */
  191. VP8E_SET_ARNR_TYPE,
  192. /*!\brief Codec control function to set visual tuning.
  193. *
  194. * Supported in codecs: VP8, VP9
  195. */
  196. VP8E_SET_TUNING,
  197. /*!\brief Codec control function to set constrained quality level.
  198. *
  199. * \attention For this value to be used vpx_codec_enc_cfg_t::g_usage must be
  200. * set to #VPX_CQ.
  201. * \note Valid range: 0..63
  202. *
  203. * Supported in codecs: VP8, VP9
  204. */
  205. VP8E_SET_CQ_LEVEL,
  206. /*!\brief Codec control function to set Max data rate for Intra frames.
  207. *
  208. * This value controls additional clamping on the maximum size of a
  209. * keyframe. It is expressed as a percentage of the average
  210. * per-frame bitrate, with the special (and default) value 0 meaning
  211. * unlimited, or no additional clamping beyond the codec's built-in
  212. * algorithm.
  213. *
  214. * For example, to allocate no more than 4.5 frames worth of bitrate
  215. * to a keyframe, set this to 450.
  216. *
  217. * Supported in codecs: VP8, VP9
  218. */
  219. VP8E_SET_MAX_INTRA_BITRATE_PCT,
  220. /*!\brief Codec control function to set reference and update frame flags.
  221. *
  222. * Supported in codecs: VP8
  223. */
  224. VP8E_SET_FRAME_FLAGS,
  225. /*!\brief Codec control function to set max data rate for Inter frames.
  226. *
  227. * This value controls additional clamping on the maximum size of an
  228. * inter frame. It is expressed as a percentage of the average
  229. * per-frame bitrate, with the special (and default) value 0 meaning
  230. * unlimited, or no additional clamping beyond the codec's built-in
  231. * algorithm.
  232. *
  233. * For example, to allow no more than 4.5 frames worth of bitrate
  234. * to an inter frame, set this to 450.
  235. *
  236. * Supported in codecs: VP9
  237. */
  238. VP9E_SET_MAX_INTER_BITRATE_PCT,
  239. /*!\brief Boost percentage for Golden Frame in CBR mode.
  240. *
  241. * This value controls the amount of boost given to Golden Frame in
  242. * CBR mode. It is expressed as a percentage of the average
  243. * per-frame bitrate, with the special (and default) value 0 meaning
  244. * the feature is off, i.e., no golden frame boost in CBR mode and
  245. * average bitrate target is used.
  246. *
  247. * For example, to allow 100% more bits, i.e, 2X, in a golden frame
  248. * than average frame, set this to 100.
  249. *
  250. * Supported in codecs: VP9
  251. */
  252. VP9E_SET_GF_CBR_BOOST_PCT,
  253. /*!\brief Codec control function to set the temporal layer id.
  254. *
  255. * For temporal scalability: this control allows the application to set the
  256. * layer id for each frame to be encoded. Note that this control must be set
  257. * for every frame prior to encoding. The usage of this control function
  258. * supersedes the internal temporal pattern counter, which is now deprecated.
  259. *
  260. * Supported in codecs: VP8
  261. */
  262. VP8E_SET_TEMPORAL_LAYER_ID,
  263. /*!\brief Codec control function to set encoder screen content mode.
  264. *
  265. * 0: off, 1: On, 2: On with more aggressive rate control.
  266. *
  267. * Supported in codecs: VP8
  268. */
  269. VP8E_SET_SCREEN_CONTENT_MODE,
  270. /*!\brief Codec control function to set lossless encoding mode.
  271. *
  272. * VP9 can operate in lossless encoding mode, in which the bitstream
  273. * produced will be able to decode and reconstruct a perfect copy of
  274. * input source. This control function provides a mean to switch encoder
  275. * into lossless coding mode(1) or normal coding mode(0) that may be lossy.
  276. * 0 = lossy coding mode
  277. * 1 = lossless coding mode
  278. *
  279. * By default, encoder operates in normal coding mode (maybe lossy).
  280. *
  281. * Supported in codecs: VP9
  282. */
  283. VP9E_SET_LOSSLESS,
  284. /*!\brief Codec control function to set number of tile columns.
  285. *
  286. * In encoding and decoding, VP9 allows an input image frame be partitioned
  287. * into separated vertical tile columns, which can be encoded or decoded
  288. * independently. This enables easy implementation of parallel encoding and
  289. * decoding. This control requests the encoder to use column tiles in
  290. * encoding an input frame, with number of tile columns (in Log2 unit) as
  291. * the parameter:
  292. * 0 = 1 tile column
  293. * 1 = 2 tile columns
  294. * 2 = 4 tile columns
  295. * .....
  296. * n = 2**n tile columns
  297. * The requested tile columns will be capped by the encoder based on image
  298. * size limitations (The minimum width of a tile column is 256 pixels, the
  299. * maximum is 4096).
  300. *
  301. * By default, the value is 6, i.e., the maximum number of tiles supported by
  302. * the resolution.
  303. *
  304. * Supported in codecs: VP9
  305. */
  306. VP9E_SET_TILE_COLUMNS,
  307. /*!\brief Codec control function to set number of tile rows.
  308. *
  309. * In encoding and decoding, VP9 allows an input image frame be partitioned
  310. * into separated horizontal tile rows. Tile rows are encoded or decoded
  311. * sequentially. Even though encoding/decoding of later tile rows depends on
  312. * earlier ones, this allows the encoder to output data packets for tile rows
  313. * prior to completely processing all tile rows in a frame, thereby reducing
  314. * the latency in processing between input and output. The parameter
  315. * for this control describes the number of tile rows, which has a valid
  316. * range [0, 2]:
  317. * 0 = 1 tile row
  318. * 1 = 2 tile rows
  319. * 2 = 4 tile rows
  320. *
  321. * By default, the value is 0, i.e. one single row tile for entire image.
  322. *
  323. * Supported in codecs: VP9
  324. */
  325. VP9E_SET_TILE_ROWS,
  326. /*!\brief Codec control function to enable frame parallel decoding feature.
  327. *
  328. * VP9 has a bitstream feature to reduce decoding dependency between frames
  329. * by turning off backward update of probability context used in encoding
  330. * and decoding. This allows staged parallel processing of more than one
  331. * video frame in the decoder. This control function provides a means to
  332. * turn this feature on or off for bitstreams produced by encoder.
  333. *
  334. * By default, this feature is on.
  335. *
  336. * Supported in codecs: VP9
  337. */
  338. VP9E_SET_FRAME_PARALLEL_DECODING,
  339. /*!\brief Codec control function to set adaptive quantization mode.
  340. *
  341. * VP9 has a segment based feature that allows encoder to adaptively change
  342. * quantization parameter for each segment within a frame to improve the
  343. * subjective quality. This control makes encoder operate in one of the
  344. * several AQ_modes supported.
  345. *
  346. * By default, encoder operates with AQ_Mode 0(adaptive quantization off).
  347. *
  348. * Supported in codecs: VP9
  349. */
  350. VP9E_SET_AQ_MODE,
  351. /*!\brief Codec control function to enable/disable periodic Q boost.
  352. *
  353. * One VP9 encoder speed feature is to enable quality boost by lowering
  354. * frame level Q periodically. This control function provides a mean to
  355. * turn on/off this feature.
  356. * 0 = off
  357. * 1 = on
  358. *
  359. * By default, the encoder is allowed to use this feature for appropriate
  360. * encoding modes.
  361. *
  362. * Supported in codecs: VP9
  363. */
  364. VP9E_SET_FRAME_PERIODIC_BOOST,
  365. /*!\brief Codec control function to set noise sensitivity.
  366. *
  367. * 0: off, 1: On(YOnly)
  368. *
  369. * Supported in codecs: VP9
  370. */
  371. VP9E_SET_NOISE_SENSITIVITY,
  372. /*!\brief Codec control function to turn on/off SVC in encoder.
  373. * \note Return value is VPX_CODEC_INVALID_PARAM if the encoder does not
  374. * support SVC in its current encoding mode
  375. * 0: off, 1: on
  376. *
  377. * Supported in codecs: VP9
  378. */
  379. VP9E_SET_SVC,
  380. /*!\brief Codec control function to set parameters for SVC.
  381. * \note Parameters contain min_q, max_q, scaling factor for each of the
  382. * SVC layers.
  383. *
  384. * Supported in codecs: VP9
  385. */
  386. VP9E_SET_SVC_PARAMETERS,
  387. /*!\brief Codec control function to set svc layer for spatial and temporal.
  388. * \note Valid ranges: 0..#vpx_codec_enc_cfg::ss_number_layers for spatial
  389. * layer and 0..#vpx_codec_enc_cfg::ts_number_layers for
  390. * temporal layer.
  391. *
  392. * Supported in codecs: VP9
  393. */
  394. VP9E_SET_SVC_LAYER_ID,
  395. /*!\brief Codec control function to set content type.
  396. * \note Valid parameter range:
  397. * VP9E_CONTENT_DEFAULT = Regular video content (Default)
  398. * VP9E_CONTENT_SCREEN = Screen capture content
  399. *
  400. * Supported in codecs: VP9
  401. */
  402. VP9E_SET_TUNE_CONTENT,
  403. /*!\brief Codec control function to get svc layer ID.
  404. * \note The layer ID returned is for the data packet from the registered
  405. * callback function.
  406. *
  407. * Supported in codecs: VP9
  408. */
  409. VP9E_GET_SVC_LAYER_ID,
  410. /*!\brief Codec control function to register callback to get per layer packet.
  411. * \note Parameter for this control function is a structure with a callback
  412. * function and a pointer to private data used by the callback.
  413. *
  414. * Supported in codecs: VP9
  415. */
  416. VP9E_REGISTER_CX_CALLBACK,
  417. /*!\brief Codec control function to set color space info.
  418. * \note Valid ranges: 0..7, default is "UNKNOWN".
  419. * 0 = UNKNOWN,
  420. * 1 = BT_601
  421. * 2 = BT_709
  422. * 3 = SMPTE_170
  423. * 4 = SMPTE_240
  424. * 5 = BT_2020
  425. * 6 = RESERVED
  426. * 7 = SRGB
  427. *
  428. * Supported in codecs: VP9
  429. */
  430. VP9E_SET_COLOR_SPACE,
  431. /*!\brief Codec control function to set temporal layering mode.
  432. * \note Valid ranges: 0..3, default is "0"
  433. * (VP9E_TEMPORAL_LAYERING_MODE_NOLAYERING).
  434. * 0 = VP9E_TEMPORAL_LAYERING_MODE_NOLAYERING
  435. * 1 = VP9E_TEMPORAL_LAYERING_MODE_BYPASS
  436. * 2 = VP9E_TEMPORAL_LAYERING_MODE_0101
  437. * 3 = VP9E_TEMPORAL_LAYERING_MODE_0212
  438. *
  439. * Supported in codecs: VP9
  440. */
  441. VP9E_SET_TEMPORAL_LAYERING_MODE,
  442. /*!\brief Codec control function to set minimum interval between GF/ARF frames
  443. *
  444. * By default the value is set as 4.
  445. *
  446. * Supported in codecs: VP9
  447. */
  448. VP9E_SET_MIN_GF_INTERVAL,
  449. /*!\brief Codec control function to set minimum interval between GF/ARF frames
  450. *
  451. * By default the value is set as 16.
  452. *
  453. * Supported in codecs: VP9
  454. */
  455. VP9E_SET_MAX_GF_INTERVAL,
  456. /*!\brief Codec control function to get an Active map back from the encoder.
  457. *
  458. * Supported in codecs: VP9
  459. */
  460. VP9E_GET_ACTIVEMAP,
  461. /*!\brief Codec control function to set color range bit.
  462. * \note Valid ranges: 0..1, default is 0
  463. * 0 = Limited range (16..235 or HBD equivalent)
  464. * 1 = Full range (0..255 or HBD equivalent)
  465. *
  466. * Supported in codecs: VP9
  467. */
  468. VP9E_SET_COLOR_RANGE,
  469. /*!\brief Codec control function to set the frame flags and buffer indices
  470. * for spatial layers. The frame flags and buffer indices are set using the
  471. * struct #vpx_svc_ref_frame_config defined below.
  472. *
  473. * Supported in codecs: VP9
  474. */
  475. VP9E_SET_SVC_REF_FRAME_CONFIG,
  476. /*!\brief Codec control function to set intended rendering image size.
  477. *
  478. * By default, this is identical to the image size in pixels.
  479. *
  480. * Supported in codecs: VP9
  481. */
  482. VP9E_SET_RENDER_SIZE,
  483. /*!\brief Codec control function to set target level.
  484. *
  485. * 255: off (default); 0: only keep level stats; 10: target for level 1.0;
  486. * 11: target for level 1.1; ... 62: target for level 6.2
  487. *
  488. * Supported in codecs: VP9
  489. */
  490. VP9E_SET_TARGET_LEVEL,
  491. /*!\brief Codec control function to set row level multi-threading.
  492. *
  493. * 0 : off, 1 : on
  494. *
  495. * Supported in codecs: VP9
  496. */
  497. VP9E_SET_ROW_MT,
  498. /*!\brief Codec control function to get bitstream level.
  499. *
  500. * Supported in codecs: VP9
  501. */
  502. VP9E_GET_LEVEL,
  503. /*!\brief Codec control function to enable/disable special mode for altref
  504. * adaptive quantization. You can use it with --aq-mode concurrently.
  505. *
  506. * Enable special adaptive quantization for altref frames based on their
  507. * expected prediction quality for the future frames.
  508. *
  509. * Supported in codecs: VP9
  510. */
  511. VP9E_SET_ALT_REF_AQ,
  512. /*!\brief Boost percentage for Golden Frame in CBR mode.
  513. *
  514. * This value controls the amount of boost given to Golden Frame in
  515. * CBR mode. It is expressed as a percentage of the average
  516. * per-frame bitrate, with the special (and default) value 0 meaning
  517. * the feature is off, i.e., no golden frame boost in CBR mode and
  518. * average bitrate target is used.
  519. *
  520. * For example, to allow 100% more bits, i.e, 2X, in a golden frame
  521. * than average frame, set this to 100.
  522. *
  523. * Supported in codecs: VP8
  524. */
  525. VP8E_SET_GF_CBR_BOOST_PCT,
  526. /*!\brief Codec control function to enable the extreme motion vector unit test
  527. * in VP9. Please note that this is only used in motion vector unit test.
  528. *
  529. * 0 : off, 1 : MAX_EXTREME_MV, 2 : MIN_EXTREME_MV
  530. *
  531. * Supported in codecs: VP9
  532. */
  533. VP9E_ENABLE_MOTION_VECTOR_UNIT_TEST,
  534. };
  535. /*!\brief vpx 1-D scaling mode
  536. *
  537. * This set of constants define 1-D vpx scaling modes
  538. */
  539. typedef enum vpx_scaling_mode_1d {
  540. VP8E_NORMAL = 0,
  541. VP8E_FOURFIVE = 1,
  542. VP8E_THREEFIVE = 2,
  543. VP8E_ONETWO = 3
  544. } VPX_SCALING_MODE;
  545. /*!\brief Temporal layering mode enum for VP9 SVC.
  546. *
  547. * This set of macros define the different temporal layering modes.
  548. * Supported codecs: VP9 (in SVC mode)
  549. *
  550. */
  551. typedef enum vp9e_temporal_layering_mode {
  552. /*!\brief No temporal layering.
  553. * Used when only spatial layering is used.
  554. */
  555. VP9E_TEMPORAL_LAYERING_MODE_NOLAYERING = 0,
  556. /*!\brief Bypass mode.
  557. * Used when application needs to control temporal layering.
  558. * This will only work when the number of spatial layers equals 1.
  559. */
  560. VP9E_TEMPORAL_LAYERING_MODE_BYPASS = 1,
  561. /*!\brief 0-1-0-1... temporal layering scheme with two temporal layers.
  562. */
  563. VP9E_TEMPORAL_LAYERING_MODE_0101 = 2,
  564. /*!\brief 0-2-1-2... temporal layering scheme with three temporal layers.
  565. */
  566. VP9E_TEMPORAL_LAYERING_MODE_0212 = 3
  567. } VP9E_TEMPORAL_LAYERING_MODE;
  568. /*!\brief vpx region of interest map
  569. *
  570. * These defines the data structures for the region of interest map
  571. *
  572. */
  573. typedef struct vpx_roi_map {
  574. /*! An id between 0 and 3 for each 16x16 region within a frame. */
  575. unsigned char *roi_map;
  576. unsigned int rows; /**< Number of rows. */
  577. unsigned int cols; /**< Number of columns. */
  578. // TODO(paulwilkins): broken for VP9 which has 8 segments
  579. // q and loop filter deltas for each segment
  580. // (see MAX_MB_SEGMENTS)
  581. int delta_q[4]; /**< Quantizer deltas. */
  582. int delta_lf[4]; /**< Loop filter deltas. */
  583. /*! Static breakout threshold for each segment. */
  584. unsigned int static_threshold[4];
  585. } vpx_roi_map_t;
  586. /*!\brief vpx active region map
  587. *
  588. * These defines the data structures for active region map
  589. *
  590. */
  591. typedef struct vpx_active_map {
  592. /*!\brief specify an on (1) or off (0) each 16x16 region within a frame */
  593. unsigned char *active_map;
  594. unsigned int rows; /**< number of rows */
  595. unsigned int cols; /**< number of cols */
  596. } vpx_active_map_t;
  597. /*!\brief vpx image scaling mode
  598. *
  599. * This defines the data structure for image scaling mode
  600. *
  601. */
  602. typedef struct vpx_scaling_mode {
  603. VPX_SCALING_MODE h_scaling_mode; /**< horizontal scaling mode */
  604. VPX_SCALING_MODE v_scaling_mode; /**< vertical scaling mode */
  605. } vpx_scaling_mode_t;
  606. /*!\brief VP8 token partition mode
  607. *
  608. * This defines VP8 partitioning mode for compressed data, i.e., the number of
  609. * sub-streams in the bitstream. Used for parallelized decoding.
  610. *
  611. */
  612. typedef enum {
  613. VP8_ONE_TOKENPARTITION = 0,
  614. VP8_TWO_TOKENPARTITION = 1,
  615. VP8_FOUR_TOKENPARTITION = 2,
  616. VP8_EIGHT_TOKENPARTITION = 3
  617. } vp8e_token_partitions;
  618. /*!brief VP9 encoder content type */
  619. typedef enum {
  620. VP9E_CONTENT_DEFAULT,
  621. VP9E_CONTENT_SCREEN,
  622. VP9E_CONTENT_INVALID
  623. } vp9e_tune_content;
  624. /*!\brief VP8 model tuning parameters
  625. *
  626. * Changes the encoder to tune for certain types of input material.
  627. *
  628. */
  629. typedef enum { VP8_TUNE_PSNR, VP8_TUNE_SSIM } vp8e_tuning;
  630. /*!\brief vp9 svc layer parameters
  631. *
  632. * This defines the spatial and temporal layer id numbers for svc encoding.
  633. * This is used with the #VP9E_SET_SVC_LAYER_ID control to set the spatial and
  634. * temporal layer id for the current frame.
  635. *
  636. */
  637. typedef struct vpx_svc_layer_id {
  638. int spatial_layer_id; /**< Spatial layer id number. */
  639. int temporal_layer_id; /**< Temporal layer id number. */
  640. } vpx_svc_layer_id_t;
  641. /*!\brief vp9 svc frame flag parameters.
  642. *
  643. * This defines the frame flags and buffer indices for each spatial layer for
  644. * svc encoding.
  645. * This is used with the #VP9E_SET_SVC_REF_FRAME_CONFIG control to set frame
  646. * flags and buffer indices for each spatial layer for the current (super)frame.
  647. *
  648. */
  649. typedef struct vpx_svc_ref_frame_config {
  650. int frame_flags[VPX_TS_MAX_LAYERS]; /**< Frame flags. */
  651. int lst_fb_idx[VPX_TS_MAX_LAYERS]; /**< Last buffer index. */
  652. int gld_fb_idx[VPX_TS_MAX_LAYERS]; /**< Golden buffer index. */
  653. int alt_fb_idx[VPX_TS_MAX_LAYERS]; /**< Altref buffer index. */
  654. } vpx_svc_ref_frame_config_t;
  655. /*!\cond */
  656. /*!\brief VP8 encoder control function parameter type
  657. *
  658. * Defines the data types that VP8E control functions take. Note that
  659. * additional common controls are defined in vp8.h
  660. *
  661. */
  662. VPX_CTRL_USE_TYPE(VP8E_SET_FRAME_FLAGS, int)
  663. #define VPX_CTRL_VP8E_SET_FRAME_FLAGS
  664. VPX_CTRL_USE_TYPE(VP8E_SET_TEMPORAL_LAYER_ID, int)
  665. #define VPX_CTRL_VP8E_SET_TEMPORAL_LAYER_ID
  666. VPX_CTRL_USE_TYPE(VP8E_SET_ROI_MAP, vpx_roi_map_t *)
  667. #define VPX_CTRL_VP8E_SET_ROI_MAP
  668. VPX_CTRL_USE_TYPE(VP8E_SET_ACTIVEMAP, vpx_active_map_t *)
  669. #define VPX_CTRL_VP8E_SET_ACTIVEMAP
  670. VPX_CTRL_USE_TYPE(VP8E_SET_SCALEMODE, vpx_scaling_mode_t *)
  671. #define VPX_CTRL_VP8E_SET_SCALEMODE
  672. VPX_CTRL_USE_TYPE(VP9E_SET_SVC, int)
  673. #define VPX_CTRL_VP9E_SET_SVC
  674. VPX_CTRL_USE_TYPE(VP9E_SET_SVC_PARAMETERS, void *)
  675. #define VPX_CTRL_VP9E_SET_SVC_PARAMETERS
  676. VPX_CTRL_USE_TYPE(VP9E_REGISTER_CX_CALLBACK, void *)
  677. #define VPX_CTRL_VP9E_REGISTER_CX_CALLBACK
  678. VPX_CTRL_USE_TYPE(VP9E_SET_SVC_LAYER_ID, vpx_svc_layer_id_t *)
  679. #define VPX_CTRL_VP9E_SET_SVC_LAYER_ID
  680. VPX_CTRL_USE_TYPE(VP8E_SET_CPUUSED, int)
  681. #define VPX_CTRL_VP8E_SET_CPUUSED
  682. VPX_CTRL_USE_TYPE(VP8E_SET_ENABLEAUTOALTREF, unsigned int)
  683. #define VPX_CTRL_VP8E_SET_ENABLEAUTOALTREF
  684. VPX_CTRL_USE_TYPE(VP8E_SET_NOISE_SENSITIVITY, unsigned int)
  685. #define VPX_CTRL_VP8E_SET_NOISE_SENSITIVITY
  686. VPX_CTRL_USE_TYPE(VP8E_SET_SHARPNESS, unsigned int)
  687. #define VPX_CTRL_VP8E_SET_SHARPNESS
  688. VPX_CTRL_USE_TYPE(VP8E_SET_STATIC_THRESHOLD, unsigned int)
  689. #define VPX_CTRL_VP8E_SET_STATIC_THRESHOLD
  690. VPX_CTRL_USE_TYPE(VP8E_SET_TOKEN_PARTITIONS, int) /* vp8e_token_partitions */
  691. #define VPX_CTRL_VP8E_SET_TOKEN_PARTITIONS
  692. VPX_CTRL_USE_TYPE(VP8E_SET_ARNR_MAXFRAMES, unsigned int)
  693. #define VPX_CTRL_VP8E_SET_ARNR_MAXFRAMES
  694. VPX_CTRL_USE_TYPE(VP8E_SET_ARNR_STRENGTH, unsigned int)
  695. #define VPX_CTRL_VP8E_SET_ARNR_STRENGTH
  696. VPX_CTRL_USE_TYPE_DEPRECATED(VP8E_SET_ARNR_TYPE, unsigned int)
  697. #define VPX_CTRL_VP8E_SET_ARNR_TYPE
  698. VPX_CTRL_USE_TYPE(VP8E_SET_TUNING, int) /* vp8e_tuning */
  699. #define VPX_CTRL_VP8E_SET_TUNING
  700. VPX_CTRL_USE_TYPE(VP8E_SET_CQ_LEVEL, unsigned int)
  701. #define VPX_CTRL_VP8E_SET_CQ_LEVEL
  702. VPX_CTRL_USE_TYPE(VP9E_SET_TILE_COLUMNS, int)
  703. #define VPX_CTRL_VP9E_SET_TILE_COLUMNS
  704. VPX_CTRL_USE_TYPE(VP9E_SET_TILE_ROWS, int)
  705. #define VPX_CTRL_VP9E_SET_TILE_ROWS
  706. VPX_CTRL_USE_TYPE(VP8E_GET_LAST_QUANTIZER, int *)
  707. #define VPX_CTRL_VP8E_GET_LAST_QUANTIZER
  708. VPX_CTRL_USE_TYPE(VP8E_GET_LAST_QUANTIZER_64, int *)
  709. #define VPX_CTRL_VP8E_GET_LAST_QUANTIZER_64
  710. VPX_CTRL_USE_TYPE(VP9E_GET_SVC_LAYER_ID, vpx_svc_layer_id_t *)
  711. #define VPX_CTRL_VP9E_GET_SVC_LAYER_ID
  712. VPX_CTRL_USE_TYPE(VP8E_SET_MAX_INTRA_BITRATE_PCT, unsigned int)
  713. #define VPX_CTRL_VP8E_SET_MAX_INTRA_BITRATE_PCT
  714. VPX_CTRL_USE_TYPE(VP8E_SET_MAX_INTER_BITRATE_PCT, unsigned int)
  715. #define VPX_CTRL_VP8E_SET_MAX_INTER_BITRATE_PCT
  716. VPX_CTRL_USE_TYPE(VP8E_SET_GF_CBR_BOOST_PCT, unsigned int)
  717. #define VPX_CTRL_VP8E_SET_GF_CBR_BOOST_PCT
  718. VPX_CTRL_USE_TYPE(VP8E_SET_SCREEN_CONTENT_MODE, unsigned int)
  719. #define VPX_CTRL_VP8E_SET_SCREEN_CONTENT_MODE
  720. VPX_CTRL_USE_TYPE(VP9E_SET_GF_CBR_BOOST_PCT, unsigned int)
  721. #define VPX_CTRL_VP9E_SET_GF_CBR_BOOST_PCT
  722. VPX_CTRL_USE_TYPE(VP9E_SET_LOSSLESS, unsigned int)
  723. #define VPX_CTRL_VP9E_SET_LOSSLESS
  724. VPX_CTRL_USE_TYPE(VP9E_SET_FRAME_PARALLEL_DECODING, unsigned int)
  725. #define VPX_CTRL_VP9E_SET_FRAME_PARALLEL_DECODING
  726. VPX_CTRL_USE_TYPE(VP9E_SET_AQ_MODE, unsigned int)
  727. #define VPX_CTRL_VP9E_SET_AQ_MODE
  728. VPX_CTRL_USE_TYPE(VP9E_SET_ALT_REF_AQ, int)
  729. #define VPX_CTRL_VP9E_SET_ALT_REF_AQ
  730. VPX_CTRL_USE_TYPE(VP9E_SET_FRAME_PERIODIC_BOOST, unsigned int)
  731. #define VPX_CTRL_VP9E_SET_FRAME_PERIODIC_BOOST
  732. VPX_CTRL_USE_TYPE(VP9E_SET_NOISE_SENSITIVITY, unsigned int)
  733. #define VPX_CTRL_VP9E_SET_NOISE_SENSITIVITY
  734. VPX_CTRL_USE_TYPE(VP9E_SET_TUNE_CONTENT, int) /* vp9e_tune_content */
  735. #define VPX_CTRL_VP9E_SET_TUNE_CONTENT
  736. VPX_CTRL_USE_TYPE(VP9E_SET_COLOR_SPACE, int)
  737. #define VPX_CTRL_VP9E_SET_COLOR_SPACE
  738. VPX_CTRL_USE_TYPE(VP9E_SET_MIN_GF_INTERVAL, unsigned int)
  739. #define VPX_CTRL_VP9E_SET_MIN_GF_INTERVAL
  740. VPX_CTRL_USE_TYPE(VP9E_SET_MAX_GF_INTERVAL, unsigned int)
  741. #define VPX_CTRL_VP9E_SET_MAX_GF_INTERVAL
  742. VPX_CTRL_USE_TYPE(VP9E_GET_ACTIVEMAP, vpx_active_map_t *)
  743. #define VPX_CTRL_VP9E_GET_ACTIVEMAP
  744. VPX_CTRL_USE_TYPE(VP9E_SET_COLOR_RANGE, int)
  745. #define VPX_CTRL_VP9E_SET_COLOR_RANGE
  746. VPX_CTRL_USE_TYPE(VP9E_SET_SVC_REF_FRAME_CONFIG, vpx_svc_ref_frame_config_t *)
  747. #define VPX_CTRL_VP9E_SET_SVC_REF_FRAME_CONFIG
  748. VPX_CTRL_USE_TYPE(VP9E_SET_RENDER_SIZE, int *)
  749. #define VPX_CTRL_VP9E_SET_RENDER_SIZE
  750. VPX_CTRL_USE_TYPE(VP9E_SET_TARGET_LEVEL, unsigned int)
  751. #define VPX_CTRL_VP9E_SET_TARGET_LEVEL
  752. VPX_CTRL_USE_TYPE(VP9E_SET_ROW_MT, unsigned int)
  753. #define VPX_CTRL_VP9E_SET_ROW_MT
  754. VPX_CTRL_USE_TYPE(VP9E_GET_LEVEL, int *)
  755. #define VPX_CTRL_VP9E_GET_LEVEL
  756. VPX_CTRL_USE_TYPE(VP9E_ENABLE_MOTION_VECTOR_UNIT_TEST, unsigned int)
  757. #define VPX_CTRL_VP9E_ENABLE_MOTION_VECTOR_UNIT_TEST
  758. /*!\endcond */
  759. /*! @} - end defgroup vp8_encoder */
  760. #ifdef __cplusplus
  761. } // extern "C"
  762. #endif
  763. #endif // VPX_VP8CX_H_