2
0

mpp_meta.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /*
  2. * Copyright 2015 Rockchip Electronics Co. LTD
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef __MPP_META_H__
  17. #define __MPP_META_H__
  18. #include <stdint.h>
  19. #include "rk_type.h"
  20. #define FOURCC_META(a, b, c, d) ((RK_U32)(a) << 24 | \
  21. ((RK_U32)(b) << 16) | \
  22. ((RK_U32)(c) << 8) | \
  23. ((RK_U32)(d) << 0))
  24. /*
  25. * Mpp Metadata definition
  26. *
  27. * Metadata is for information transmision in mpp.
  28. * Mpp task will contain two meta data:
  29. *
  30. * 1. Data flow metadata
  31. * This metadata contains information of input / output data flow. For example
  32. * A. decoder input side task the input packet must be defined and output frame
  33. * may not be defined. Then decoder will try malloc or use committed buffer to
  34. * complete decoding.
  35. * B. decoder output side task
  36. *
  37. *
  38. * 2. Flow control metadata
  39. *
  40. */
  41. typedef enum MppMetaKey_e {
  42. /* data flow key */
  43. KEY_INPUT_FRAME = FOURCC_META('i', 'f', 'r', 'm'),
  44. KEY_INPUT_PACKET = FOURCC_META('i', 'p', 'k', 't'),
  45. KEY_OUTPUT_FRAME = FOURCC_META('o', 'f', 'r', 'm'),
  46. KEY_OUTPUT_PACKET = FOURCC_META('o', 'p', 'k', 't'),
  47. /* output motion information for motion detection */
  48. KEY_MOTION_INFO = FOURCC_META('m', 'v', 'i', 'f'),
  49. KEY_HDR_INFO = FOURCC_META('h', 'd', 'r', ' '),
  50. KEY_HDR_META_OFFSET = FOURCC_META('h', 'd', 'r', 'o'),
  51. KEY_HDR_META_SIZE = FOURCC_META('h', 'd', 'r', 'l'),
  52. /* flow control key */
  53. KEY_INPUT_BLOCK = FOURCC_META('i', 'b', 'l', 'k'),
  54. KEY_OUTPUT_BLOCK = FOURCC_META('o', 'b', 'l', 'k'),
  55. KEY_INPUT_IDR_REQ = FOURCC_META('i', 'i', 'd', 'r'), /* input idr frame request flag */
  56. KEY_OUTPUT_INTRA = FOURCC_META('o', 'i', 'd', 'r'), /* output intra frame indicator */
  57. /* mpp_frame / mpp_packet meta data info key */
  58. KEY_TEMPORAL_ID = FOURCC_META('t', 'l', 'i', 'd'),
  59. KEY_LONG_REF_IDX = FOURCC_META('l', 't', 'i', 'd'),
  60. KEY_ENC_AVERAGE_QP = FOURCC_META('a', 'v', 'g', 'q'),
  61. KEY_ENC_START_QP = FOURCC_META('s', 't', 'r', 'q'),
  62. KEY_ENC_BPS_RT = FOURCC_META('r', 't', 'b', 'r'), /* realtime bps */
  63. KEY_ROI_DATA = FOURCC_META('r', 'o', 'i', ' '),
  64. KEY_OSD_DATA = FOURCC_META('o', 's', 'd', ' '),
  65. KEY_OSD_DATA2 = FOURCC_META('o', 's', 'd', '2'),
  66. KEY_OSD_DATA3 = FOURCC_META('o', 's', 'd', '3'),
  67. KEY_USER_DATA = FOURCC_META('u', 's', 'r', 'd'),
  68. KEY_USER_DATAS = FOURCC_META('u', 'r', 'd', 's'),
  69. /* num of inter different size predicted block */
  70. KEY_LVL64_INTER_NUM = FOURCC_META('l', '6', '4', 'p'),
  71. KEY_LVL32_INTER_NUM = FOURCC_META('l', '3', '2', 'p'),
  72. KEY_LVL16_INTER_NUM = FOURCC_META('l', '1', '6', 'p'),
  73. KEY_LVL8_INTER_NUM = FOURCC_META('l', '8', 'p', ' '),
  74. /* num of intra different size predicted block */
  75. KEY_LVL32_INTRA_NUM = FOURCC_META('l', '3', '2', 'i'),
  76. KEY_LVL16_INTRA_NUM = FOURCC_META('l', '1', '6', 'i'),
  77. KEY_LVL8_INTRA_NUM = FOURCC_META('l', '8', 'i', ' '),
  78. KEY_LVL4_INTRA_NUM = FOURCC_META('l', '4', 'i', ' '),
  79. /* output P skip frame indicator */
  80. KEY_OUTPUT_PSKIP = FOURCC_META('o', 'p', 's', 'p'),
  81. /*
  82. * Input P-skip frame request
  83. * KEY_INPUT_PSKIP: The skip frame will be referenced in the next frame.
  84. * KEY_INPUT_PSKIP_NON_REF: The skip frame will not be referenced as a frame.
  85. */
  86. KEY_INPUT_PSKIP = FOURCC_META('i', 'p', 's', 'p'),
  87. KEY_INPUT_PSKIP_NON_REF = FOURCC_META('i', 'p', 'n', 'r'),
  88. KEY_ENC_SSE = FOURCC_META('e', 's', 's', 'e'),
  89. /*
  90. * For vepu580 roi buffer config mode
  91. * The encoder roi structure is so complex that we should provide a buffer
  92. * tunnel for externl user to config encoder hardware by direct sending
  93. * roi data buffer.
  94. * This way can reduce the config parsing and roi buffer data generating
  95. * overhead in mpp.
  96. */
  97. KEY_ROI_DATA2 = FOURCC_META('r', 'o', 'i', '2'),
  98. /*
  99. * qpmap for rv1109/1126 encoder qpmap config
  100. * Input data is a MppBuffer which contains an array of 16bit Vepu541RoiCfg.
  101. * And each 16bit represents a 16x16 block qp info.
  102. *
  103. * H.264 - 16x16 block qp is arranged in raster order:
  104. * each value is a 16bit data
  105. * 00 01 02 03 04 05 06 07 -> 00 01 02 03 04 05 06 07
  106. * 10 11 12 13 14 15 16 17 10 11 12 13 14 15 16 17
  107. * 20 21 22 23 24 25 26 27 20 21 22 23 24 25 26 27
  108. * 30 31 32 33 34 35 36 37 30 31 32 33 34 35 36 37
  109. *
  110. * H.265 - 16x16 block qp is reorder to 64x64/32x32 ctu order then 64x64 / 32x32 ctu raster order
  111. * 64x64 ctu
  112. * 00 01 02 03 04 05 06 07 -> 00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33 04 05 06 07 14 15 16 17 24 25 26 27 34 35 36 37
  113. * 10 11 12 13 14 15 16 17
  114. * 20 21 22 23 24 25 26 27
  115. * 30 31 32 33 34 35 36 37
  116. * 32x32 ctu
  117. * 00 01 02 03 04 05 06 07 -> 00 01 10 11 02 03 12 13 04 05 14 15 06 07 16 17
  118. * 10 11 12 13 14 15 16 17 20 21 30 31 22 23 32 33 24 25 34 35 26 27 36 37
  119. * 20 21 22 23 24 25 26 27
  120. * 30 31 32 33 34 35 36 37
  121. */
  122. KEY_QPMAP0 = FOURCC_META('e', 'q', 'm', '0'),
  123. /* input motion list for smart p rate control */
  124. KEY_MV_LIST = FOURCC_META('m', 'v', 'l', 't'),
  125. /* frame long-term reference frame operation */
  126. KEY_ENC_MARK_LTR = FOURCC_META('m', 'l', 't', 'r'),
  127. KEY_ENC_USE_LTR = FOURCC_META('u', 'l', 't', 'r'),
  128. /* MLVEC specified encoder feature */
  129. KEY_ENC_FRAME_QP = FOURCC_META('f', 'r', 'm', 'q'),
  130. KEY_ENC_BASE_LAYER_PID = FOURCC_META('b', 'p', 'i', 'd'),
  131. /* Thumbnail info for decoder output frame */
  132. KEY_DEC_TBN_EN = FOURCC_META('t', 'b', 'e', 'n'),
  133. KEY_DEC_TBN_Y_OFFSET = FOURCC_META('t', 'b', 'y', 'o'),
  134. KEY_DEC_TBN_UV_OFFSET = FOURCC_META('t', 'b', 'c', 'o'),
  135. } MppMetaKey;
  136. #define mpp_meta_get(meta) mpp_meta_get_with_tag(meta, MODULE_TAG, __FUNCTION__)
  137. #include "mpp_frame.h"
  138. #include "mpp_packet.h"
  139. #ifdef __cplusplus
  140. extern "C" {
  141. #endif
  142. MPP_RET mpp_meta_get_with_tag(MppMeta *meta, const char *tag, const char *caller);
  143. MPP_RET mpp_meta_put(MppMeta meta);
  144. RK_S32 mpp_meta_size(MppMeta meta);
  145. MPP_RET mpp_meta_set_s32(MppMeta meta, MppMetaKey key, RK_S32 val);
  146. MPP_RET mpp_meta_set_s64(MppMeta meta, MppMetaKey key, RK_S64 val);
  147. MPP_RET mpp_meta_set_ptr(MppMeta meta, MppMetaKey key, void *val);
  148. MPP_RET mpp_meta_get_s32(MppMeta meta, MppMetaKey key, RK_S32 *val);
  149. MPP_RET mpp_meta_get_s64(MppMeta meta, MppMetaKey key, RK_S64 *val);
  150. MPP_RET mpp_meta_get_ptr(MppMeta meta, MppMetaKey key, void **val);
  151. MPP_RET mpp_meta_set_frame (MppMeta meta, MppMetaKey key, MppFrame frame);
  152. MPP_RET mpp_meta_set_packet(MppMeta meta, MppMetaKey key, MppPacket packet);
  153. MPP_RET mpp_meta_set_buffer(MppMeta meta, MppMetaKey key, MppBuffer buffer);
  154. MPP_RET mpp_meta_get_frame (MppMeta meta, MppMetaKey key, MppFrame *frame);
  155. MPP_RET mpp_meta_get_packet(MppMeta meta, MppMetaKey key, MppPacket *packet);
  156. MPP_RET mpp_meta_get_buffer(MppMeta meta, MppMetaKey key, MppBuffer *buffer);
  157. MPP_RET mpp_meta_get_s32_d(MppMeta meta, MppMetaKey key, RK_S32 *val, RK_S32 def);
  158. MPP_RET mpp_meta_get_s64_d(MppMeta meta, MppMetaKey key, RK_S64 *val, RK_S64 def);
  159. MPP_RET mpp_meta_get_ptr_d(MppMeta meta, MppMetaKey key, void **val, void *def);
  160. MPP_RET mpp_meta_get_frame_d(MppMeta meta, MppMetaKey key, MppFrame *frame, MppFrame def);
  161. MPP_RET mpp_meta_get_packet_d(MppMeta meta, MppMetaKey key, MppPacket *packet, MppPacket def);
  162. MPP_RET mpp_meta_get_buffer_d(MppMeta meta, MppMetaKey key, MppBuffer *buffer, MppBuffer def);
  163. #ifdef __cplusplus
  164. }
  165. #endif
  166. #endif /*__MPP_META_H__*/