Projektarbeit Line Following Robot bei Prof. Chowanetz im WS22/23
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mmal_format.h 9.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. #ifndef MMAL_FORMAT_H
  26. #define MMAL_FORMAT_H
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /** \defgroup MmalFormat Elementary stream format
  31. * Definition of an elementary stream format and its associated API */
  32. /* @{ */
  33. #include "mmal_types.h"
  34. #include "mmal_encodings.h"
  35. /** Enumeration of the different types of elementary streams.
  36. * This divides elementary streams into 4 big categories, plus an invalid type. */
  37. typedef enum {
  38. MMAL_ES_TYPE_UNKNOWN, /**< Unknown elementary stream type */
  39. MMAL_ES_TYPE_CONTROL, /**< Elementary stream of control commands */
  40. MMAL_ES_TYPE_AUDIO, /**< Audio elementary stream */
  41. MMAL_ES_TYPE_VIDEO, /**< Video elementary stream */
  42. MMAL_ES_TYPE_SUBPICTURE /**< Sub-picture elementary stream (e.g. subtitles, overlays) */
  43. } MMAL_ES_TYPE_T;
  44. /** Definition of a video format.
  45. * This describes the properties specific to a video stream */
  46. typedef struct
  47. {
  48. uint32_t width; /**< Width of frame in pixels */
  49. uint32_t height; /**< Height of frame in rows of pixels */
  50. MMAL_RECT_T crop; /**< Visible region of the frame */
  51. MMAL_RATIONAL_T frame_rate; /**< Frame rate */
  52. MMAL_RATIONAL_T par; /**< Pixel aspect ratio */
  53. MMAL_FOURCC_T color_space; /**< FourCC specifying the color space of the
  54. * video stream. See the \ref MmalColorSpace
  55. * "pre-defined color spaces" for some examples.
  56. */
  57. } MMAL_VIDEO_FORMAT_T;
  58. /** Definition of an audio format.
  59. * This describes the properties specific to an audio stream */
  60. typedef struct MMAL_AUDIO_FORMAT_T
  61. {
  62. uint32_t channels; /**< Number of audio channels */
  63. uint32_t sample_rate; /**< Sample rate */
  64. uint32_t bits_per_sample; /**< Bits per sample */
  65. uint32_t block_align; /**< Size of a block of data */
  66. /** \todo add channel mapping, gapless and replay-gain support */
  67. } MMAL_AUDIO_FORMAT_T;
  68. /** Definition of a subpicture format.
  69. * This describes the properties specific to a subpicture stream */
  70. typedef struct
  71. {
  72. uint32_t x_offset; /**< Width offset to the start of the subpicture */
  73. uint32_t y_offset; /**< Height offset to the start of the subpicture */
  74. /** \todo surely more things are needed here */
  75. } MMAL_SUBPICTURE_FORMAT_T;
  76. /** Definition of the type specific format.
  77. * This describes the type specific information of the elementary stream. */
  78. typedef union
  79. {
  80. MMAL_AUDIO_FORMAT_T audio; /**< Audio specific information */
  81. MMAL_VIDEO_FORMAT_T video; /**< Video specific information */
  82. MMAL_SUBPICTURE_FORMAT_T subpicture; /**< Subpicture specific information */
  83. } MMAL_ES_SPECIFIC_FORMAT_T;
  84. /** \name Elementary stream flags
  85. * \anchor elementarystreamflags
  86. * The following flags describe properties of an elementary stream */
  87. /* @{ */
  88. #define MMAL_ES_FORMAT_FLAG_FRAMED 0x1 /**< The elementary stream will already be framed */
  89. /* @} */
  90. /** \name Undefined encoding value.
  91. * This value indicates an unknown encoding
  92. */
  93. /* @{ */
  94. #define MMAL_ENCODING_UNKNOWN 0
  95. /* @} */
  96. /** \name Default encoding variant value.
  97. * This value indicates the default encoding variant is used
  98. */
  99. /* @{ */
  100. #define MMAL_ENCODING_VARIANT_DEFAULT 0
  101. /* @} */
  102. /** Definition of an elementary stream format */
  103. typedef struct MMAL_ES_FORMAT_T
  104. {
  105. MMAL_ES_TYPE_T type; /**< Type of the elementary stream */
  106. MMAL_FOURCC_T encoding; /**< FourCC specifying the encoding of the elementary stream.
  107. * See the \ref MmalEncodings "pre-defined encodings" for some
  108. * examples.
  109. */
  110. MMAL_FOURCC_T encoding_variant;/**< FourCC specifying the specific encoding variant of
  111. * the elementary stream. See the \ref MmalEncodingVariants
  112. * "pre-defined encoding variants" for some examples.
  113. */
  114. MMAL_ES_SPECIFIC_FORMAT_T *es; /**< Type specific information for the elementary stream */
  115. uint32_t bitrate; /**< Bitrate in bits per second */
  116. uint32_t flags; /**< Flags describing properties of the elementary stream.
  117. * See \ref elementarystreamflags "Elementary stream flags".
  118. */
  119. uint32_t extradata_size; /**< Size of the codec specific data */
  120. uint8_t *extradata; /**< Codec specific data */
  121. } MMAL_ES_FORMAT_T;
  122. /** Allocate and initialise a \ref MMAL_ES_FORMAT_T structure.
  123. *
  124. * @return a \ref MMAL_ES_FORMAT_T structure
  125. */
  126. MMAL_ES_FORMAT_T *mmal_format_alloc(void);
  127. /** Free a \ref MMAL_ES_FORMAT_T structure allocated by \ref mmal_format_alloc.
  128. *
  129. * @param format the \ref MMAL_ES_FORMAT_T structure to free
  130. */
  131. void mmal_format_free(MMAL_ES_FORMAT_T *format);
  132. /** Allocate the extradata buffer in \ref MMAL_ES_FORMAT_T.
  133. * This buffer will be freed automatically when the format is destroyed or
  134. * another allocation is done.
  135. *
  136. * @param format format structure for which the extradata buffer will be allocated
  137. * @param size size of the extradata buffer to allocate
  138. * @return MMAL_SUCCESS on success
  139. */
  140. MMAL_STATUS_T mmal_format_extradata_alloc(MMAL_ES_FORMAT_T *format, unsigned int size);
  141. /** Shallow copy a format structure.
  142. * It is worth noting that the extradata buffer will not be copied in the new format.
  143. *
  144. * @param format_dest destination \ref MMAL_ES_FORMAT_T for the copy
  145. * @param format_src source \ref MMAL_ES_FORMAT_T for the copy
  146. */
  147. void mmal_format_copy(MMAL_ES_FORMAT_T *format_dest, MMAL_ES_FORMAT_T *format_src);
  148. /** Fully copy a format structure, including the extradata buffer.
  149. *
  150. * @param format_dest destination \ref MMAL_ES_FORMAT_T for the copy
  151. * @param format_src source \ref MMAL_ES_FORMAT_T for the copy
  152. * @return MMAL_SUCCESS on success
  153. */
  154. MMAL_STATUS_T mmal_format_full_copy(MMAL_ES_FORMAT_T *format_dest, MMAL_ES_FORMAT_T *format_src);
  155. /** \name Comparison flags
  156. * \anchor comparisonflags
  157. * The following flags describe the differences between 2 format structures */
  158. /* @{ */
  159. #define MMAL_ES_FORMAT_COMPARE_FLAG_TYPE 0x01 /**< The type is different */
  160. #define MMAL_ES_FORMAT_COMPARE_FLAG_ENCODING 0x02 /**< The encoding is different */
  161. #define MMAL_ES_FORMAT_COMPARE_FLAG_BITRATE 0x04 /**< The bitrate is different */
  162. #define MMAL_ES_FORMAT_COMPARE_FLAG_FLAGS 0x08 /**< The flags are different */
  163. #define MMAL_ES_FORMAT_COMPARE_FLAG_EXTRADATA 0x10 /**< The extradata is different */
  164. #define MMAL_ES_FORMAT_COMPARE_FLAG_VIDEO_RESOLUTION 0x0100 /**< The video resolution is different */
  165. #define MMAL_ES_FORMAT_COMPARE_FLAG_VIDEO_CROPPING 0x0200 /**< The video cropping is different */
  166. #define MMAL_ES_FORMAT_COMPARE_FLAG_VIDEO_FRAME_RATE 0x0400 /**< The video frame rate is different */
  167. #define MMAL_ES_FORMAT_COMPARE_FLAG_VIDEO_ASPECT_RATIO 0x0800 /**< The video aspect ratio is different */
  168. #define MMAL_ES_FORMAT_COMPARE_FLAG_VIDEO_COLOR_SPACE 0x1000 /**< The video color space is different */
  169. #define MMAL_ES_FORMAT_COMPARE_FLAG_ES_OTHER 0x10000000 /**< Other ES specific parameters are different */
  170. /* @} */
  171. /** Compare 2 format structures and returns a set of flags describing the differences.
  172. * The result will be zero if the structures are the same, or a combination of
  173. * one or more of the \ref comparisonflags "Comparison flags" if different.
  174. *
  175. * @param format_1 first \ref MMAL_ES_FORMAT_T to compare
  176. * @param format_2 second \ref MMAL_ES_FORMAT_T to compare
  177. * @return set of flags describing the differences
  178. */
  179. uint32_t mmal_format_compare(MMAL_ES_FORMAT_T *format_1, MMAL_ES_FORMAT_T *format_2);
  180. /* @} */
  181. #ifdef __cplusplus
  182. }
  183. #endif
  184. #endif /* MMAL_FORMAT_H */