vp8cx.h 33 KB

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