2
0

usage.dox 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*!\page usage Usage
  2. The vpx multi-format codec SDK provides a unified interface amongst its
  3. supported codecs. This abstraction allows applications using this SDK to
  4. easily support multiple video formats with minimal code duplication or
  5. "special casing." This section describes the interface common to all codecs.
  6. For codec-specific details, see the \ref codecs page.
  7. The following sections are common to all codecs:
  8. - \ref usage_types
  9. - \ref usage_features
  10. - \ref usage_init
  11. - \ref usage_errors
  12. For more information on decoder and encoder specific usage, see the
  13. following pages:
  14. \if decoder
  15. \li \subpage usage_decode
  16. \endif
  17. \if encoder
  18. \li \subpage usage_encode
  19. \endif
  20. \section usage_types Important Data Types
  21. There are two important data structures to consider in this interface.
  22. \subsection usage_ctxs Contexts
  23. A context is a storage area allocated by the calling application that the
  24. codec may write into to store details about a single instance of that codec.
  25. Most of the context is implementation specific, and thus opaque to the
  26. application. The context structure as seen by the application is of fixed
  27. size, and thus can be allocated with automatic storage or dynamically
  28. on the heap.
  29. Most operations require an initialized codec context. Codec context
  30. instances are codec specific. That is, the codec to be used for the encoded
  31. video must be known at initialization time. See #vpx_codec_ctx_t for further
  32. information.
  33. \subsection usage_ifaces Interfaces
  34. A codec interface is an opaque structure that controls how function calls
  35. into the generic interface are dispatched to their codec-specific
  36. implementations. Applications \ref MUSTNOT attempt to examine or override
  37. this storage, as it contains internal implementation details likely to
  38. change from release to release.
  39. Each supported codec will expose an interface structure to the application
  40. as an <code>extern</code> reference to a structure of the incomplete type
  41. #vpx_codec_iface_t.
  42. \section usage_features Features
  43. Several "features" are defined that are optionally implemented by codec
  44. algorithms. Indeed, the same algorithm may support different features on
  45. different platforms. The purpose of defining these features is that when
  46. they are implemented, they conform to a common interface. The features, or
  47. capabilities, of an algorithm can be queried from it's interface by using
  48. the vpx_codec_get_caps() method. Attempts to invoke features not supported
  49. by an algorithm will generally result in #VPX_CODEC_INCAPABLE.
  50. \if decoder
  51. Currently defined decoder features include:
  52. - \ref usage_cb
  53. - \ref usage_postproc
  54. \endif
  55. \section usage_init Initialization
  56. To initialize a codec instance, the address of the codec context
  57. and interface structures are passed to an initialization function. Depending
  58. on the \ref usage_features that the codec supports, the codec could be
  59. initialized in different modes.
  60. To prevent cases of confusion where the ABI of the library changes,
  61. the ABI is versioned. The ABI version number must be passed at
  62. initialization time to ensure the application is using a header file that
  63. matches the library. The current ABI version number is stored in the
  64. preprocessor macros #VPX_CODEC_ABI_VERSION, #VPX_ENCODER_ABI_VERSION, and
  65. #VPX_DECODER_ABI_VERSION. For convenience, each initialization function has
  66. a wrapper macro that inserts the correct version number. These macros are
  67. named like the initialization methods, but without the _ver suffix.
  68. The available initialization methods are:
  69. \if encoder
  70. \li #vpx_codec_enc_init (calls vpx_codec_enc_init_ver())
  71. \li #vpx_codec_enc_init_multi (calls vpx_codec_enc_init_multi_ver())
  72. \endif
  73. \if decoder
  74. \li #vpx_codec_dec_init (calls vpx_codec_dec_init_ver())
  75. \endif
  76. \section usage_errors Error Handling
  77. Almost all codec functions return an error status of type #vpx_codec_err_t.
  78. The semantics of how each error condition should be processed is clearly
  79. defined in the definitions of each enumerated value. Error values can be
  80. converted into ASCII strings with the vpx_codec_error() and
  81. vpx_codec_err_to_string() methods. The difference between these two methods is
  82. that vpx_codec_error() returns the error state from an initialized context,
  83. whereas vpx_codec_err_to_string() can be used in cases where an error occurs
  84. outside any context. The enumerated value returned from the last call can be
  85. retrieved from the <code>err</code> member of the decoder context as well.
  86. Finally, more detailed error information may be able to be obtained by using
  87. the vpx_codec_error_detail() method. Not all errors produce detailed error
  88. information.
  89. In addition to error information, the codec library's build configuration
  90. is available at runtime on some platforms. This information can be returned
  91. by calling vpx_codec_build_config(), and is formatted as a base64 coded string
  92. (comprised of characters in the set [a-z_a-Z0-9+/]). This information is not
  93. useful to an application at runtime, but may be of use to vpx for support.
  94. \section usage_deadline Deadline
  95. Both the encoding and decoding functions have a <code>deadline</code>
  96. parameter. This parameter indicates the amount of time, in microseconds
  97. (us), that the application wants the codec to spend processing before
  98. returning. This is a soft deadline -- that is, the semantics of the
  99. requested operation take precedence over meeting the deadline. If, for
  100. example, an application sets a <code>deadline</code> of 1000us, and the
  101. frame takes 2000us to decode, the call to vpx_codec_decode() will return
  102. after 2000us. In this case the deadline is not met, but the semantics of the
  103. function are preserved. If, for the same frame, an application instead sets
  104. a <code>deadline</code> of 5000us, the decoder will see that it has 3000us
  105. remaining in its time slice when decoding completes. It could then choose to
  106. run a set of \ref usage_postproc filters, and perhaps would return after
  107. 4000us (instead of the allocated 5000us). In this case the deadline is met,
  108. and the semantics of the call are preserved, as before.
  109. The special value <code>0</code> is reserved to represent an infinite
  110. deadline. In this case, the codec will perform as much processing as
  111. possible to yield the highest quality frame.
  112. By convention, the value <code>1</code> is used to mean "return as fast as
  113. possible."
  114. */