SF_OMX_video_common.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (C) 2021 StarFive Technology Co., Ltd.
  4. */
  5. #ifndef SF_OMX_VIDEO_COMMON
  6. #define SF_OMX_VIDEO_COMMON
  7. #include "OMX_Component.h"
  8. #include "OMX_Video.h"
  9. #include "OMX_VideoExt.h"
  10. #include "OMX_Index.h"
  11. #include "OMX_IndexExt.h"
  12. #include "SF_OMX_Core.h"
  13. #include "wave511/sample_v2/component/component.h"
  14. #include "wave511/sample_v2/component_encoder/encoder_listener.h"
  15. #include "wave511/sample_v2/component_decoder/decoder_listener.h"
  16. #define INIT_SET_SIZE_VERSION(_struct_, _structType_) \
  17. do \
  18. { \
  19. memset((_struct_), 0, sizeof(_structType_)); \
  20. (_struct_)->nSize = sizeof(_structType_); \
  21. (_struct_)->nVersion.s.nVersionMajor = 1; \
  22. (_struct_)->nVersion.s.nVersionMinor = 18; \
  23. (_struct_)->nVersion.s.nRevision = 1; \
  24. (_struct_)->nVersion.s.nStep = 0; \
  25. } while (0)
  26. #define DEFAULT_FRAME_WIDTH 3840
  27. #define DEFAULT_FRAME_HEIGHT 2160
  28. #define DEFAULT_VIDEO_INPUT_BUFFER_SIZE (DEFAULT_FRAME_WIDTH * DEFAULT_FRAME_HEIGHT) / 2
  29. #define DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE (DEFAULT_FRAME_WIDTH * DEFAULT_FRAME_HEIGHT * 3) / 2
  30. typedef struct _SF_COMPONENT_FUNCTIONS
  31. {
  32. Component (*ComponentCreate)(const char *componentName, CNMComponentConfig *componentParam);
  33. BOOL(*ComponentSetupTunnel)(Component fromComponent, Component toComponent);
  34. ComponentState (*ComponentExecute)(Component component);
  35. Int32 (*ComponentWait)(Component component);
  36. void (*ComponentStop)(Component component);
  37. void (*ComponentRelease)(Component component);
  38. BOOL(*ComponentChangeState)(Component component, Uint32 state);
  39. BOOL(*ComponentDestroy)(Component component, BOOL *ret);
  40. CNMComponentParamRet (*ComponentGetParameter)(Component from, Component to, GetParameterCMD commandType, void *data);
  41. CNMComponentParamRet (*ComponentSetParameter)(Component from, Component to, SetParameterCMD commandType, void *data);
  42. void (*ComponentNotifyListeners)(Component component, Uint64 event, void *data);
  43. BOOL(*ComponentRegisterListener)(Component component, Uint64 events, ComponentListenerFunc func, void *context);
  44. void (*ComponentPortCreate)(Port *port, Component owner, Uint32 depth, Uint32 size);
  45. void (*ComponentPortSetData)(Port *port, PortContainer *portData);
  46. PortContainer *(*ComponentPortPeekData)(Port *port);
  47. PortContainer *(*ComponentPortGetData)(Port *port);
  48. void *(*WaitBeforeComponentPortGetData)(Port *port);
  49. void (*ComponentPortWaitReadyStatus)(Port *port);
  50. void (*ComponentPortDestroy)(Port *port);
  51. BOOL(*ComponentPortHasInputData)(Port *port);
  52. Uint32 (*ComponentPortGetSize)(Port *port);
  53. void (*ComponentPortFlush)(Component component);
  54. ComponentState (*ComponentGetState)(Component component);
  55. BOOL(*ComponentParamReturnTest)(CNMComponentParamRet ret, BOOL *retry);
  56. // Listener
  57. BOOL(*SetupDecListenerContext)(DecListenerContext *ctx, CNMComponentConfig *config, Component renderer);
  58. BOOL(*SetupEncListenerContext)(EncListenerContext *ctx, CNMComponentConfig *config);
  59. void (*ClearDecListenerContext)(DecListenerContext *ctx);
  60. void (*HandleDecCompleteSeqEvent)(Component com, CNMComListenerDecCompleteSeq *param, DecListenerContext *ctx);
  61. void (*HandleDecRegisterFbEvent)(Component com, CNMComListenerDecRegisterFb *param, DecListenerContext *ctx);
  62. void (*HandleDecGetOutputEvent)(Component com, CNMComListenerDecDone *param, DecListenerContext *ctx);
  63. void (*HandleDecCloseEvent)(Component com, CNMComListenerDecClose *param, DecListenerContext *ctx);
  64. void (*ClearEncListenerContext)(EncListenerContext *ctx);
  65. void (*HandleEncFullEvent)(Component com, CNMComListenerEncFull *param, EncListenerContext *ctx);
  66. void (*HandleEncGetOutputEvent)(Component com, CNMComListenerEncDone *param, EncListenerContext *ctx);
  67. void (*HandleEncCompleteSeqEvent)(Component com, CNMComListenerEncCompleteSeq *param, EncListenerContext *ctx);
  68. void (*HandleEncGetEncCloseEvent)(Component com, CNMComListenerEncClose *param, EncListenerContext *ctx);
  69. void (*EncoderListener)(Component com, Uint64 event, void *data, void *context);
  70. void (*DecoderListener)(Component com, Uint64 event, void *data, void *context);
  71. // Helper
  72. void (*SetDefaultEncTestConfig)(TestEncConfig *testConfig);
  73. void (*SetDefaultDecTestConfig)(TestDecConfig *testConfig);
  74. Int32 (*LoadFirmware)(Int32 productId, Uint8 **retFirmware, Uint32 *retSizeInWord, const char *path);
  75. BOOL(*SetupEncoderOpenParam)(EncOpenParam *param, TestEncConfig *config, ENC_CFG *encCfg);
  76. RetCode (*SetUpDecoderOpenParam)(DecOpenParam *param, TestDecConfig *config);
  77. // VPU
  78. int (*VPU_GetProductId)(int coreIdx);
  79. BOOL(*Queue_Enqueue)(Queue *queue, void *data);
  80. Uint32 (*Queue_Get_Cnt)(Queue *queue);
  81. RetCode (*VPU_DecClrDispFlag)(DecHandle handle, int index);
  82. RetCode (*VPU_DecGetFrameBuffer)(DecHandle handle, int frameIdx, FrameBuffer* frameBuf);
  83. void (*Render_DecClrDispFlag)(void *context, int index);
  84. // VPU Log
  85. int (*InitLog)(void);
  86. void (*DeInitLog)(void);
  87. void (*SetMaxLogLevel)(int level);
  88. int (*GetMaxLogLevel)(void);
  89. // FrameBuffer
  90. void* (*AllocateFrameBuffer2)(ComponentImpl* com, Uint32 size);
  91. BOOL (*AttachDMABuffer)(ComponentImpl* com, Uint64 virtAddress, Uint32 size);
  92. void (*SetRenderTotalBufferNumber)(ComponentImpl* com, Uint32 number);
  93. void (*SetFeederTotalBufferNumber)(ComponentImpl* com, Uint32 number);
  94. void (*WaitForExecoderReady)(ComponentImpl *com)
  95. } SF_COMPONENT_FUNCTIONS;
  96. typedef struct _SF_WAVE5_IMPLEMEMT
  97. {
  98. SF_COMPONENT_FUNCTIONS *functions;
  99. Component *hSFComponentExecoder;
  100. Component *hSFComponentFeeder;
  101. Component *hSFComponentRender;
  102. void *testConfig;
  103. CNMComponentConfig *config;
  104. void *lsnCtx;
  105. Uint16 *pusBitCode;
  106. CodStd bitFormat;
  107. OMX_VIDEO_PARAM_AVCTYPE AVCComponent[2];
  108. OMX_VIDEO_PARAM_HEVCTYPE HEVCComponent[2];
  109. }SF_WAVE5_IMPLEMEMT;
  110. #ifdef __cplusplus
  111. extern "C"
  112. {
  113. #endif
  114. BOOL CheckEncTestConfig(TestEncConfig *testConfig);
  115. BOOL CheckDecTestConfig(TestDecConfig *testConfig);
  116. OMX_ERRORTYPE GetStateCommon(OMX_IN OMX_HANDLETYPE hComponent, OMX_OUT OMX_STATETYPE *pState);
  117. OMX_ERRORTYPE InitComponentStructorCommon(SF_OMX_COMPONENT *hComponent);
  118. OMX_ERRORTYPE ComponentClearCommon(SF_OMX_COMPONENT *hComponent);
  119. OMX_ERRORTYPE FlushBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U32 nPort);
  120. SF_OMX_COMPONENT *GetSFOMXComponrntByComponent(Component *pComponent);
  121. #ifdef __cplusplus
  122. }
  123. #endif
  124. #endif