5 // Created by James on 21/05/2014.
6 // Copyright (c) 2014 Bluefish444. All rights reserved.
8 // A file that contains useful Util functions that can ssist in general development.
9 // indente to be included as-is into BlueVelvetC projects and not part of a library.
11 #ifndef BlueVelvetC_BlueVelvetCUtils_h
12 #define BlueVelvetC_BlueVelvetCUtils_h
14 #include "BlueVelvetC.h"
21 // Memory Allocation and Free'ing of page Aligned memory
22 BLUEVELVETC_API void* bfAlloc(unsigned int nMemorySize);
23 BLUEVELVETC_API void bfFree(unsigned int nMemSize, void* pMemory);
25 // Get strings that give information about the card or card state
26 BLUEVELVETC_API const char* bfcUtilsGetStringForCardType(const int iCardType);
27 BLUEVELVETC_API const wchar_t* bfcUtilsGetWStringForCardType(const int iCardType);
29 BLUEVELVETC_API const char* bfcUtilsGetStringForBlueProductId(const unsigned int nProductId);
30 BLUEVELVETC_API const wchar_t* bfcUtilsGetWStringForBlueProductId(const unsigned int nProductId);
32 BLUEVELVETC_API const char* bfcUtilsGetStringForVideoMode(const unsigned int nVideoMode);
33 BLUEVELVETC_API const wchar_t* bfcUtilsGetWStringForVideoMode(const unsigned int nVideoMode);
35 BLUEVELVETC_API const char* bfcUtilsGetStringForMemoryFormat(const unsigned int nMemoryFormat);
36 BLUEVELVETC_API const wchar_t* bfcUtilsGetWStringForMemoryFormat(const unsigned int nMemoryFormat);
38 // Get/Set MR2 Video mode info
39 BLUEVELVETC_API int bfcUtilsGetScalerVideoMode(const BLUEVELVETC_HANDLE pHandle, const unsigned int nScalerMR2Node, unsigned int& nVideoMode);
40 BLUEVELVETC_API int bfcUtilsSetScalerVideoMode(const BLUEVELVETC_HANDLE pHandle, const unsigned int nScalerMR2Node, unsigned int nVideoMode);
42 // Change MR2 Routing using the EEpochRoutingElements enum values as src and dest
43 BLUEVELVETC_API int bfcUtilsGetMR2Routing(const BLUEVELVETC_HANDLE pHandle, unsigned int& nSrcNode, const unsigned int nDestNode, unsigned int& nLinkType);
44 BLUEVELVETC_API int bfcUtilsSetMR2Routing(const BLUEVELVETC_HANDLE pHandle, const unsigned int nSrcNode, const unsigned int nDestNode, const unsigned int nLinkType);
46 // Get/Set Audio routing.
47 BLUEVELVETC_API int bfcUtilsGetAudioOutputRouting(const BLUEVELVETC_HANDLE pHandle, const unsigned int nAudioConnectorType, unsigned int& nAudioSourceChannelId, unsigned int nAudioConnectorId);
48 BLUEVELVETC_API int bfcUtilsSetAudioOutputRouting(const BLUEVELVETC_HANDLE pHandle, const unsigned int nAudioConnectorType, unsigned int nAudioSourceChannelId, unsigned int nAudioConnectorId);
50 // General Video format helper funcs
51 BLUEVELVETC_API bool bfcUtilsIsVideoModeProgressive(const unsigned int nVideoMode);
52 BLUEVELVETC_API bool bfcUtilsIsVideoMode1001Framerate(const unsigned int nVideoMode);
53 BLUEVELVETC_API int bfcUtilsGetFpsForVideoMode(const unsigned int nVideoMode); // returns closest interger FPS, use bfcUtilsIsVideoMode1001Framerate(), to determine if div 1001 is needed.
55 // Get the Bluefish _EVideoMode for the given width, height and fps
56 BLUEVELVETC_API int bfcUtilsGetVideoModeForFrameInfo(const BLUE_UINT32 nWidth, const BLUE_UINT32 nHeight, const BLUE_UINT32 nRate, const BLUE_UINT32 bIs1001, const BLUE_UINT32 bIsProgressive, BLUE_UINT32& nVideoMode);
57 BLUEVELVETC_API int bfcUtilsGetFrameInfoForVideoMode(const BLUE_UINT32 nVideoMode, BLUE_UINT32& nWidth, BLUE_UINT32& nHeight, BLUE_UINT32& nRate, BLUE_UINT32& bIs1001, BLUE_UINT32& bIsProgressive);
60 // Get the number of Audio Packets for a given frame of video in a specific mode.
61 BLUEVELVETC_API int bfcUtilsGetAudioSamplesPerFrame(const BLUE_UINT32 nVideoMode, const BLUE_UINT32 nFrameNo);
67 @brief enumerator used by VANC manipulation function on HD cards to notify whether
68 VANC pakcet shoule be inserted/extracted from VANC Y buffers or VANC CbCr buffer.
69 This enumerator will only be used on HD video modes as it is the only with
70 2 type of ANC bufers ir Y and CbCr. On SD Modes the ANC data is inserted across
71 both Y anc CbCr values.
74 enum BlueVancPktTypeEnum
76 BlueVancPktYComp=0, /**< ANC pkt should be inserted/extracted from the Y component buffer*/
77 BlueVancPktCbcrComp=1, /**< ANC pkt should be inserted/extracted from the CbCr component buffer*/
78 BlueVancPktAllComp=2 /**< ANC pkt should be inserted/extracted from all components (SD video modes)*/
82 @brief Use this function to initialise VANC buffer before inserting any packets into the buffer
83 @param CardType type of bluefish card to which this vanc buffer was transferred to.
84 @param nVideoMode video mode under which this vanc buffer will be used.
85 @param pixels_per_line width in pixels of the vanc buffer that has to be initialised.
86 @param lines_per_frame height of the vanc buffer that has to be initialised.
87 @param pVancBuffer vanc buffer which has to be initialised.
91 BLUEVELVETC_API BLUE_UINT32 bfcUtilsInitVancBuffer(BLUE_UINT32 nCardType,
92 BLUE_UINT32 nVideoMode,
93 BLUE_UINT32 nPixelsPerLine,
94 BLUE_UINT32 nLinesPerFrame,
95 BLUE_UINT32* pVancBuffer);
98 @brief this function can be used to extract ANC packet from HD cards. Currently we can only extract packets in the VANC space.
99 @param CardType type of the card from which the vanc buffer was captured.
100 @param vanc_pkt_type This parameter denotes whether to search for the VANC packet in Y Space or Cb/Cr Space.
101 The values this parameter accepts are defined in the enumerator #BlueVancPktTypeEnum
102 @param src_vanc_buffer Vanc buffer which was captured from bluefish card
103 @param src_vanc_buffer_size size of the vanc buffer which should be parsed for the specified vanc packet
104 @param pixels_per_line specifies how many pixels are there in each line of VANC buffer
105 @param vanc_pkt_did specifies the DID of the Vanc packet which should be extracted from the buffer
106 @param vanc_pkt_sdid Returns the SDID of the extracted VANC packet
107 @param vanc_pkt_data_length returns the size of the extracted VANC packet. The size is specifed as number of UDW words
108 that was contained in the packet
109 @param vanc_pkt_data_ptr pointer to UDW of the VANC packets . The 10 bit UDW words are packed in a 16 bit integer. The bottom 10 bit of the
110 16 bit word contains the UDW data.
111 @param vanc_pkt_line_no line number where the packet was found .
116 BLUEVELVETC_API BLUE_INT32 bfcUtilsVancPktExtract(BLUE_UINT32 nCardType,
117 BLUE_UINT32 nVancPktType,
118 BLUE_UINT32* pSrcVancBuffer,
119 BLUE_UINT32 nSrcVancBufferSize,
120 BLUE_UINT32 nPixelsPerLine,
121 BLUE_UINT32 nVancPktDid,
122 BLUE_UINT16* pVancPktSdid,
123 BLUE_UINT16* pVancPktDataLength,
124 BLUE_UINT16* pVancPktData,
125 BLUE_UINT16* pVancPktLineNo);
128 @brief use this function to insert ANC packets into the VANC space of the HD cards.
129 @param CardType type of the card from which the vanc buffer was captured.
130 @param vanc_pkt_type This parameter denotes whether to search for the VANC packet in Y Space or Cb/Cr Space.
131 The values this parameter accepts are defined in the enumerator #blue_vanc_pkt_type_enum
132 @param vanc_pkt_line_no line in th VANC buffer where the ANC packet should inserted.
133 @param vanc_pkt_buffer vanc ANC packet which should be inserted into the VANC buffer.
134 @param vanc_pkt_buffer_size size of the ANC packet including the checksum ,ADF , SDID, DID and Data Count
135 @param dest_vanc_buffer VANC buffer into which the ANC packet will be inserted into.
136 @param pixels_per_line specifies how many pixels are there in each line of VANC buffer
138 BLUEVELVETC_API BLUE_INT32 bfcUtilsVancPktInsert(BLUE_UINT32 nCardType,
139 BLUE_UINT32 nVancPktType,
140 BLUE_UINT32 nVancPktLineNumber,
141 BLUE_UINT32* pVancPktBuffer,
142 BLUE_UINT32 nVancPktBufferSize,
143 BLUE_UINT32* pDestVancBuffer,
144 BLUE_UINT32 nPixelsPerLine);
149 @defgroup vanc_decode_encoder_helper ANC encoder/decoder
152 BLUEVELVETC_API BLUE_UINT32 bfcUtilsDecodeEia708bPkt(BLUE_UINT32 nCardType, BLUE_UINT16* pVancPktData, BLUE_UINT16 usPktUdwCount, BLUE_UINT16 usEiaPktSubtype, BLUE_UINT8* pDecodedChStr);
158 #endif // BlueVelvetC_BlueVelvetCUtils_h