brcmjpeg.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. Copyright (c) 2012, Broadcom Europe Ltd
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are met:
  6. * Redistributions of source code must retain the above copyright
  7. notice, this list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. * Neither the name of the copyright holder nor the
  12. names of its contributors may be used to endorse or promote products
  13. derived from this software without specific prior written permission.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  15. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
  18. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. /** \file
  26. * Jpeg encoder and decoder library using the hardware jpeg codec
  27. */
  28. #ifndef BRCM_JPEG_H
  29. #define BRCM_JPEG_H
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. /** Status return codes from the API */
  34. typedef enum
  35. {
  36. BRCMJPEG_SUCCESS = 0,
  37. BRCMJPEG_ERROR_NOMEM,
  38. BRCMJPEG_ERROR_INIT,
  39. BRCMJPEG_ERROR_INPUT_FORMAT,
  40. BRCMJPEG_ERROR_OUTPUT_FORMAT,
  41. BRCMJPEG_ERROR_INPUT_BUFFER,
  42. BRCMJPEG_ERROR_OUTPUT_BUFFER,
  43. BRCMJPEG_ERROR_EXECUTE,
  44. BRCMJPEG_ERROR_REQUEST,
  45. } BRCMJPEG_STATUS_T;
  46. /** Type of the codec instance to create */
  47. typedef enum
  48. {
  49. BRCMJPEG_TYPE_ENCODER = 0,
  50. BRCMJPEG_TYPE_DECODER
  51. } BRCMJPEG_TYPE_T;
  52. /** Pixel formats supported by the codec */
  53. typedef enum
  54. {
  55. PIXEL_FORMAT_UNKNOWN = 0,
  56. PIXEL_FORMAT_I420, /* planar YUV 4:2:0 */
  57. PIXEL_FORMAT_YV12, /* planar YVU 4:2:0 */
  58. PIXEL_FORMAT_I422, /* planar YUV 4:2:2 */
  59. PIXEL_FORMAT_YV16, /* planar YVU 4:2:2 */
  60. PIXEL_FORMAT_YUYV, /* interleaved YUV 4:2:2 */
  61. PIXEL_FORMAT_RGBA, /* interleaved RGBA */
  62. } BRCMJPEG_PIXEL_FORMAT_T;
  63. /** Definition of a codec request */
  64. typedef struct
  65. {
  66. /** Pointer to the buffer containing the input data
  67. * A client should set input OR input_handle, but not both. */
  68. const unsigned char *input;
  69. /** Actual size of the input data */
  70. unsigned int input_size;
  71. /** Handle to input buffer containing input data */
  72. unsigned int input_handle;
  73. /** Pointer to the buffer used for the output data
  74. * A client should set output OR output_handle, but not both. */
  75. unsigned char *output;
  76. /** Total size of the output buffer */
  77. unsigned int output_alloc_size;
  78. /** Actual size of the output data (this is an output parameter) */
  79. unsigned int output_size;
  80. /** Handle to the buffer used for the output data */
  81. unsigned int output_handle;
  82. /** Width of the raw frame (this is an input parameter for encode) */
  83. unsigned int width;
  84. /** Height of the raw frame (this is an input parameter for encode) */
  85. unsigned int height;
  86. /** Pixel format of the raw frame (this is an input parameter) */
  87. BRCMJPEG_PIXEL_FORMAT_T pixel_format;
  88. /** Width of the buffer containing the raw frame (input parameter).
  89. * This is optional but if set, is used to specify the actual width
  90. * of the buffer containing the raw frame */
  91. unsigned int buffer_width;
  92. /** Height of the buffer containing the raw frame (input parameter).
  93. * This is optional but if set, is used to specify the actual height
  94. * of the buffer containing the raw frame */
  95. unsigned int buffer_height;
  96. /** Encode quality - 0 to 100 */
  97. unsigned int quality;
  98. } BRCMJPEG_REQUEST_T;
  99. /** Type of the codec instance */
  100. typedef struct BRCMJPEG_T BRCMJPEG_T;
  101. /** Create an instance of the jpeg codec
  102. * This will actually re-use an existing instance if one is
  103. * available.
  104. *
  105. * @param type type of codec instance required
  106. * @param ctx will point to the newly created instance
  107. * @return BRCMJPEG_SUCCESS on success
  108. */
  109. BRCMJPEG_STATUS_T brcmjpeg_create(BRCMJPEG_TYPE_T type, BRCMJPEG_T **ctx);
  110. /** Acquire a new reference on a codec instance
  111. *
  112. * @param ctx instance to acquire a reference on
  113. */
  114. void brcmjpeg_acquire(BRCMJPEG_T *ctx);
  115. /** Release an instance of the jpeg codec
  116. * This will only trigger the destruction of the codec instance when
  117. * the last reference to it is being released.
  118. *
  119. * @param ctx instance to release
  120. */
  121. void brcmjpeg_release(BRCMJPEG_T *ctx);
  122. /** Process a jpeg codec request
  123. *
  124. * @param ctx instance of codec to use
  125. * @param request codec request to execute
  126. * @return BRCMJPEG_SUCCESS on success
  127. */
  128. BRCMJPEG_STATUS_T brcmjpeg_process(BRCMJPEG_T *ctx, BRCMJPEG_REQUEST_T *request);
  129. #ifdef __cplusplus
  130. }
  131. #endif
  132. #endif /* BRCM_JPEG_H */