]> git.sesse.net Git - casparcg/blob - dependencies64/bluefish/include/BlueHancUtils.h
Move the Required header files from Bluefish/interop dir. back to the dependencies64...
[casparcg] / dependencies64 / bluefish / include / BlueHancUtils.h
1 #pragma once
2 #ifndef BLUE_LINUX_CODE
3 #ifndef HANCUTILS_USE_STATIC_LIB
4         #ifdef HANCUTILS_EXPORTS
5                 #define HANCUTILS_API __declspec(dllexport)
6         #elif defined(__APPLE__)
7                 #define HANCUTILS_API
8                 #define ATLTRACE        printf
9         #else
10                 #define HANCUTILS_API __declspec(dllimport)
11         #endif
12 #else
13         #define HANCUTILS_API
14 #endif
15 #else
16         #define HANCUTILS_API
17 typedef bool BOOL;      
18 #endif  
19 #include "BlueDriver_p.h"
20
21
22
23
24 extern "C"
25 {
26 /**
27 @defgroup hanc_manipilation_function Embedded audio
28 @{
29 */
30
31 #pragma pack(push, hanc_struct, 1)
32
33 /**
34 @brief The structure is used to extract/insert  Embedded audio to and from the HANC stream of Greed and Leon based cards.*/
35
36 struct hanc_stream_info_struct
37 {
38         BLUE_INT32 AudioDBNArray[4];                    /**< Contains the DBN values that should be used for each of the embedded audio groups*/
39         BLUE_INT32 AudioChannelStatusBlock[4];  /**< channel status block information for each of the embedded audio group*/
40         BLUE_UINT32 flag_valid_time_code;               /**< flag which identifies the validity of the time code member in the #hanc_stream_info_struct*/
41         BLUE_UINT64     time_code;                                      /**< RP188 time code that was extracted from the HANC buffer or RP188 timecode which should be inserted 
42                                                                                                  into the HANC buffer*/
43         BLUE_UINT32* hanc_data_ptr;                             /**< Hanc Buffer which should be used as the source or destination for either extraction or insertion */
44         BLUE_UINT32 video_mode;                                 /**< video mode which this hanc buffer which be used with. We need this information for do the required audio distribution 
45                                                                                                  especially NTSC */
46         BLUE_UINT64 ltc_time_code;
47         BLUE_UINT64 sd_vitc_time_code;
48         BLUE_UINT64 rp188_ltc_time_code;
49         BLUE_UINT32 pad[126];
50 };
51
52 #define AUDIO_INPUT_SOURCE_EMB  0
53 #define AUDIO_INPUT_SOURCE_AES  1
54 struct hanc_decode_struct
55 {
56         void* audio_pcm_data_ptr;                       // Buffer which would be used to store the extracted PCM
57                                                                                 // audio data. Must be filled in by app before calling function.
58         BLUE_UINT32 audio_ch_required_mask;     // which all audio channels should be extracted from the 
59                                                                                 // audio frame .Must be filled in by app before calling function.
60         BLUE_UINT32 type_of_sample_required;// type of destination  audio channel
61                                                                                 //ie 16 bit ,24 bit or 32 bit PCM data .
62                                                                                 //Must be filled in by app before calling function.
63         BLUE_UINT32 no_audio_samples;           // this would contain how many audio samples has been decoded from
64                                                                                 // the hanc buffer.
65         BLUE_UINT64 timecodes[7];                       // Would extract the timecode information from the audio frame.
66         void * raw_custom_anc_pkt_data_ptr;                     // This buffer  would contain the raw ANC packets that was found in the orac hanc buffer.
67                                                                                                 // this would contain any ANC packets that is not of type embedded audio and RP188 TC.
68                                                                                                 //Must be filled in by app before calling function. can be NULL
69         BLUE_UINT32 sizeof_custom_anc_pkt_data_ptr; // size of the ANC buffer array
70                                                                                                 //Must be filled in by app before calling function. can be NULL
71         BLUE_UINT32 avail_custom_anc_pkt_data_bytes;// how many custom ANC packets has been decoded into raw_hanc_pkt_data_ptr
72                                                                                                 //Must be filled in by app before calling function. can be NULL
73         BLUE_UINT32 audio_input_source;         // Used to select the audio input source. 
74                                                                                 // whether it is AES or Embedded.
75                                                                                 //Must be filled in by app before calling function.
76         BLUE_UINT32 audio_temp_buffer[16];      // this is used to store split audio sample 
77                                                                                 // which did not contain all its audio channels
78                                                                                 // in one audio frame
79                                                                                 //Must be initialised to zero by app before first instantiating the  function. 
80         BLUE_UINT32 audio_split_buffer_mask; // The mask would be used to make a note of 
81                                                                                 // split audio sample information for a frame.
82                                                                                 //Must be initialised to zero by app before first instantiating the  function. 
83         BLUE_UINT32 max_expected_audio_sample_count; // specify the maximum number of audio samples 
84                                                                                                  // that the audio pcm buffer can contain.
85                                                                                                 //Must be filled in by app before calling function.
86         BLUE_UINT32 pad[124];
87 };
88
89 #pragma pack(pop, hanc_struct)
90
91 HANCUTILS_API BLUE_UINT32 encode_hanc_frame(struct hanc_stream_info_struct* hanc_stream_ptr,
92                                                                                         void* audio_pcm_ptr,
93                                                                                         BLUE_UINT32 no_audio_ch,
94                                                                                         BLUE_UINT32 no_audio_samples,
95                                                                                         BLUE_UINT32 nTypeOfSample,
96                                                                                         BLUE_UINT32 emb_audio_flag);
97
98 HANCUTILS_API BLUE_UINT32 encode_hanc_frame_ex( BLUE_UINT32 card_type,
99                                                                                                 struct hanc_stream_info_struct* hanc_stream_ptr,
100                                                                                                 void* audio_pcm_ptr,
101                                                                                                 BLUE_UINT32 no_audio_ch,
102                                                                                                 BLUE_UINT32 no_audio_samples,
103                                                                                                 BLUE_UINT32 nTypeOfSample,
104                                                                                                 BLUE_UINT32 emb_audio_flag);
105
106
107 HANCUTILS_API BLUE_UINT32 encode_hanc_frame_with_ucz(   BLUE_UINT32 card_type,
108                                                                                                                 struct hanc_stream_info_struct* hanc_stream_ptr,
109                                                                                                                 void* audio_pcm_ptr,
110                                                                                                                 BLUE_UINT32 no_audio_ch,
111                                                                                                                 BLUE_UINT32 no_audio_samples,
112                                                                                                                 BLUE_UINT32 nTypeOfSample,
113                                                                                                                 BLUE_UINT32 emb_audio_flag,
114                                                                                                                 BLUE_UINT8* pUCZBuffer);
115
116 HANCUTILS_API BLUE_UINT32 create_embed_audiosample(     void* raw_data_ptr,
117                                                                                                         BLUE_UINT32* emb_data_ptr,
118                                                                                                         BLUE_UINT32 channels_per_audio_sample,
119                                                                                                         BLUE_UINT32 bytes_per_ch,
120                                                                                                         BLUE_UINT32 no_samples,
121                                                                                                         BLUE_UINT32 emb_audio_flags,
122                                                                                                         BLUE_UINT8* Audio_Groups_DBN_Array,
123                                                                                                         BLUE_UINT8* Audio_Groups_statusblock_Array);
124
125 HANCUTILS_API BLUE_UINT32* get_embed_audio_distribution_array(BLUE_UINT32 video_mode, BLUE_UINT32 sequence_no);
126 //HANCUTILS_API BLUE_UINT32 * GetAudioFrameSequence(BLUE_UINT32 video_output_standard);
127
128 HANCUTILS_API bool hanc_stream_analyzer(BLUE_UINT32 *src_hanc_buffer,struct hanc_stream_info_struct * hanc_stream_ptr);
129 HANCUTILS_API bool orac_hanc_stream_analyzer(BLUE_UINT32 card_type,BLUE_UINT32 *src_hanc_buffer,struct hanc_decode_struct * decode_ptr,char * analyzer_output_file);
130 HANCUTILS_API bool hanc_decoder_ex(     BLUE_UINT32 card_type,
131                                                                         BLUE_UINT32* src_hanc_buffer,
132                                                                         struct hanc_decode_struct* hanc_decode_struct_ptr);
133
134 /**
135 @}
136 */
137
138 /**
139 @defgroup vanc_manipilation_function vanc packet I/O 
140 @{
141 */
142
143
144 /**
145 @brief enumerator used by VANC manipulation function on HD cards to notify whether 
146                 VANC pakcet shoule be inserted/extracted from VANC Y buffers or VANC CbCr buffer.
147                 This enumerator will only be used on  HD video modes as it is the only with 
148                 2 type of ANC bufers ir Y and CbCr. On SD Modes the ANC data is inserted across 
149                 both Y anc CbCr values.
150                 
151 */
152 enum blue_vanc_pkt_type_enum
153 {
154         blue_vanc_pkt_y_comp=0, /**< ANC pkt should be inserted/extracted from the  Y component buffer*/
155         blue_vanc_pkt_cbcr_comp=1 /**< ANC pkt should be inserted/extracted from the  CbCr component buffer*/
156 };
157
158 /*!
159 @brief Use this function to initialise VANC buffer before inserting any packets into the buffer
160 @param CardType type of bluefish  card to which this vanc buffer was transferred to.
161 @param nVideoMode video mode under which this vanc buffer will be used.
162 @param pixels_per_line width in pixels of the vanc buffer that has to be initialised.
163 @param lines_per_frame height of the vanc buffer that has to be initialised.
164 @param pVancBuffer vanc buffer which has to be initialised.
165 @remarks.
166
167 */
168 HANCUTILS_API BLUE_UINT32 blue_init_vanc_buffer(BLUE_UINT32 CardType,BLUE_UINT32 nVideoMode,BLUE_UINT32 pixels_per_line,BLUE_UINT32 lines_per_frame,BLUE_UINT32 * pVancBuffer);
169 /*!
170 @brief this function can be used to extract ANC packet from HD cards. Currently we can only extract packets in the VANC space.
171 @param CardType type of the card from which the vanc buffer was captured.
172 @param vanc_pkt_type This parameter denotes whether to search for the VANC packet in Y Space or Cb/Cr Space.
173                                          The values this parameter accepts are defined in the enumerator #blue_vanc_pkt_type_enum
174 @param src_vanc_buffer Vanc buffer which was captured from bluefish card
175 @param src_vanc_buffer_size size of the vanc buffer which should be parsed for the specified vanc packet
176 @param pixels_per_line specifies how many pixels are there in each line of VANC buffer
177 @param vanc_pkt_did specifies the DID of the Vanc packet which should be extracted from the buffer
178 @param vanc_pkt_sdid Returns the SDID of the extracted VANC packet
179 @param vanc_pkt_data_length returns the size of the extracted VANC packet. The size is specifed as number of UDW words
180                                                         that was  contained in the packet
181 @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 
182                                                 16 bit word contains the UDW data.
183 @param vanc_pkt_line_no line number  where the packet was found .
184
185 @remarks.
186
187 */
188 HANCUTILS_API BLUE_INT32  vanc_pkt_extract( 
189                                                                                         BLUE_UINT32 CardType,
190                                                                                         BLUE_UINT32 vanc_pkt_type,
191                                                                                         BLUE_UINT32 * src_vanc_buffer,
192                                                                                         BLUE_UINT32 src_vanc_buffer_size,
193                                                                                         BLUE_UINT32 pixels_per_line,
194                                                                                         BLUE_UINT32             vanc_pkt_did,
195                                                                                         BLUE_UINT16 * vanc_pkt_sdid,
196                                                                                         BLUE_UINT16 * vanc_pkt_data_length,
197                                                                                         BLUE_UINT16 * vanc_pkt_data_ptr,
198                                                                                         BLUE_UINT16 * vanc_pkt_line_no);
199
200 /**
201 @brief use this function to insert ANC packets into the VANC space of the HD cards.
202 @param CardType type of the card from which the vanc buffer was captured.
203 @param vanc_pkt_type This parameter denotes whether to search for the VANC packet in Y Space or Cb/Cr Space.
204                                          The values this parameter accepts are defined in the enumerator #blue_vanc_pkt_type_enum
205 @param vanc_pkt_line_no line in th VANC buffer where the ANC packet should inserted.
206 @param vanc_pkt_buffer vanc ANC packet which should be inserted into the VANC buffer.
207 @param vanc_pkt_buffer_size size of the ANC packet including the checksum ,ADF , SDID, DID and Data Count
208 @param dest_vanc_buffer VANC buffer into which the ANC packet will be inserted into.
209 @param pixels_per_line specifies how many pixels are there in each line of VANC buffer
210 */
211 HANCUTILS_API BLUE_INT32  vanc_pkt_insert(
212                                                                                         BLUE_UINT32 CardType,
213                                                                                         BLUE_UINT32 vanc_pkt_type,
214                                                                                         BLUE_UINT32 vanc_pkt_line_no,
215                                                                                         BLUE_UINT32 * vanc_pkt_buffer,
216                                                                                         BLUE_UINT32 vanc_pkt_buffer_size,
217                                                                                         BLUE_UINT32 * dest_vanc_buffer,
218                                                                                         BLUE_UINT32 pixels_per_line);
219
220 /** @} */
221
222 /**
223 @defgroup vanc_decode_encoder_helper ANC encoder/decoder 
224         @{
225 */
226 HANCUTILS_API BLUE_UINT32 decode_eia_708b_pkt(BLUE_UINT32 CardType,BLUE_UINT16 * vanc_pkt_data_ptr,BLUE_UINT16 pkt_udw_count,BLUE_UINT16 eia_pkt_subtype,BLUE_UINT8 * decoded_ch_str);
227 //#ifndef BLUE_LINUX_CODE
228 //HANCUTILS_API BLUE_UINT64 decode_rp188_packet(BLUE_UINT32 CardType,BLUE_UINT32 * src_vanc_buffer,BLUE_UINT32 UDW_Count,BLUE_UINT64 *rp188_dbb);
229 //HANCUTILS_API bool blue_vitc_decoder_8bit_fmt(BLUE_UINT8 * raw_vbi_ptr,BLUE_UINT32 pixels_per_line,BLUE_UINT32 mem_fmt,BLUE_UINT32 vitc_line_no,BLUE_UINT64 * vitc_time_code);
230 //HANCUTILS_API bool blue_vitc_decoder_10bit_v210(BLUE_UINT8 * raw_vbi_ptr, BLUE_UINT32 vitc_line_no, BLUE_UINT64 * vitc_time_code);
231 //HANCUTILS_API unsigned int create_rp188_pkt(
232 //                                                        BLUE_UINT32 cardType,
233 //                                                        BLUE_UINT32 * emb_data_ptr,
234 //                                                        BLUE_UINT32 line_no,
235 //                                                        BLUE_UINT32 start_new_line,
236 //                                                        BLUE_UINT64 timecode,
237 //                                                        BLUE_UINT64 rp188_dbb);
238 //#endif
239
240
241 /** @} */
242 }