AJA NTV2 SDK  17.5.0.1242
NTV2 SDK 17.5.0.1242
videoutilities.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
8 #include "common.h"
9 #include "videoutilities.h"
10 #include <string.h>
11 
12 
13 inline int FixedTrunc(int inFix)
14 {
15  return (inFix>>16);
16 }
17 
18 #define _ENDIAN_SWAP32(_data_) (((_data_<<24)&0xff000000)|((_data_<<8)&0x00ff0000)|((_data_>>8)&0x0000ff00)|((_data_>>24)&0x000000ff))
19 inline AJA_RGBAlphaPixel CubicInterPolate( AJA_RGBAlphaPixel *Input, int32_t Index);
20 inline int16_t CubicInterPolateWord( int16_t *Input, int32_t Index);
21 inline int16_t CubicInterPolateAudioWord( int16_t *Input, int32_t Index);
22 
23 // Cubic Coefficient Table for resampling
24 uint32_t CubicCoef[129] = {
25  0x00000000 , /* 0 */
26  0xFFFFFFE1 , /* 1 */
27  0xFFFFFF88 , /* 2 */
28  0xFFFFFEFB , /* 3 */
29  0xFFFFFE40 , /* 4 */
30  0xFFFFFD5D , /* 5 */
31  0xFFFFFC58 , /* 6 */
32  0xFFFFFB37 , /* 7 */
33  0xFFFFFA00 , /* 8 */
34  0xFFFFF8B9 , /* 9 */
35  0xFFFFF768 , /* 10 */
36  0xFFFFF613 , /* 11 */
37  0xFFFFF4C0 , /* 12 */
38  0xFFFFF375 , /* 13 */
39  0xFFFFF238 , /* 14 */
40  0xFFFFF10F , /* 15 */
41  0xFFFFF000 , /* 16 */
42  0xFFFFEF11 , /* 17 */
43  0xFFFFEE48 , /* 18 */
44  0xFFFFEDAB , /* 19 */
45  0xFFFFED40 , /* 20 */
46  0xFFFFED0D , /* 21 */
47  0xFFFFED18 , /* 22 */
48  0xFFFFED67 , /* 23 */
49  0xFFFFEE00 , /* 24 */
50  0xFFFFEEE9 , /* 25 */
51  0xFFFFF028 , /* 26 */
52  0xFFFFF1C3 , /* 27 */
53  0xFFFFF3C0 , /* 28 */
54  0xFFFFF625 , /* 29 */
55  0xFFFFF8F8 , /* 30 */
56  0xFFFFFC3F , /* 31 */
57  0x00000000 , /* 32 */
58  0x0000047D , /* 33 */
59  0x000009E8 , /* 34 */
60  0x0000102F , /* 35 */
61  0x00001740 , /* 36 */
62  0x00001F09 , /* 37 */
63  0x00002778 , /* 38 */
64  0x0000307B , /* 39 */
65  0x00003A00 , /* 40 */
66  0x000043F5 , /* 41 */
67  0x00004E48 , /* 42 */
68  0x000058E7 , /* 43 */
69  0x000063C0 , /* 44 */
70  0x00006EC1 , /* 45 */
71  0x000079D8 , /* 46 */
72  0x000084F3 , /* 47 */
73  0x00009000 , /* 48 */
74  0x00009AED , /* 49 */
75  0x0000A5A8 , /* 50 */
76  0x0000B01F , /* 51 */
77  0x0000BA40 , /* 52 */
78  0x0000C3F9 , /* 53 */
79  0x0000CD38 , /* 54 */
80  0x0000D5EB , /* 55 */
81  0x0000DE00 , /* 56 */
82  0x0000E565 , /* 57 */
83  0x0000EC08 , /* 58 */
84  0x0000F1D7 , /* 59 */
85  0x0000F6C0 , /* 60 */
86  0x0000FAB1 , /* 61 */
87  0x0000FD98 , /* 62 */
88  0x0000FF63 , /* 63 */
89  0x00010000 , /* 64 */
90  0x0000FF63 , /* 65 */
91  0x0000FD98 , /* 66 */
92  0x0000FAB1 , /* 67 */
93  0x0000F6C0 , /* 68 */
94  0x0000F1D7 , /* 69 */
95  0x0000EC08 , /* 70 */
96  0x0000E565 , /* 71 */
97  0x0000DE00 , /* 72 */
98  0x0000D5EB , /* 73 */
99  0x0000CD38 , /* 74 */
100  0x0000C3F9 , /* 75 */
101  0x0000BA40 , /* 76 */
102  0x0000B01F , /* 77 */
103  0x0000A5A8 , /* 78 */
104  0x00009AED , /* 79 */
105  0x00009000 , /* 80 */
106  0x000084F3 , /* 81 */
107  0x000079D8 , /* 82 */
108  0x00006EC1 , /* 83 */
109  0x000063C0 , /* 84 */
110  0x000058E7 , /* 85 */
111  0x00004E48 , /* 86 */
112  0x000043F5 , /* 87 */
113  0x00003A00 , /* 88 */
114  0x0000307B , /* 89 */
115  0x00002778 , /* 90 */
116  0x00001F09 , /* 91 */
117  0x00001740 , /* 92 */
118  0x0000102F , /* 93 */
119  0x000009E8 , /* 94 */
120  0x0000047D , /* 95 */
121  0x00000000 , /* 96 */
122  0xFFFFFC3F , /* 97 */
123  0xFFFFF8F8 , /* 98 */
124  0xFFFFF625 , /* 99 */
125  0xFFFFF3C0 , /* 100 */
126  0xFFFFF1C3 , /* 101 */
127  0xFFFFF028 , /* 102 */
128  0xFFFFEEE9 , /* 103 */
129  0xFFFFEE00 , /* 104 */
130  0xFFFFED67 , /* 105 */
131  0xFFFFED18 , /* 106 */
132  0xFFFFED0D , /* 107 */
133  0xFFFFED40 , /* 108 */
134  0xFFFFEDAB , /* 109 */
135  0xFFFFEE48 , /* 110 */
136  0xFFFFEF11 , /* 111 */
137  0xFFFFF000 , /* 112 */
138  0xFFFFF10F , /* 113 */
139  0xFFFFF238 , /* 114 */
140  0xFFFFF375 , /* 115 */
141  0xFFFFF4C0 , /* 116 */
142  0xFFFFF613 , /* 117 */
143  0xFFFFF768 , /* 118 */
144  0xFFFFF8B9 , /* 119 */
145  0xFFFFFA00 , /* 120 */
146  0xFFFFFB37 , /* 121 */
147  0xFFFFFC58 , /* 122 */
148  0xFFFFFD5D , /* 123 */
149  0xFFFFFE40 , /* 124 */
150  0xFFFFFEFB , /* 125 */
151  0xFFFFFF88 , /* 126 */
152  0xFFFFFFE1 , /* 127 */
153  0x00000000 , /* 128 */
154 };
155 
156 
157 
158 void createVideoFrame( uint32_t *buffer , uint64_t frameNumber,
159  AJA_PixelFormat pixFmt, uint32_t lines, uint32_t pixels, uint32_t linepitch,
160  uint16_t y, uint16_t cb, uint16_t cr )
161 {
162  AJA_UNUSED(buffer);
163  AJA_UNUSED(frameNumber);
164  AJA_UNUSED(pixFmt);
165  AJA_UNUSED(lines);
166  AJA_UNUSED(pixels);
167  AJA_UNUSED(linepitch);
168  AJA_UNUSED(y);
169  AJA_UNUSED(cb);
170  AJA_UNUSED(cr);
171 }
172 
173 
174 uint32_t AJA_CalcRowBytesForFormat(AJA_PixelFormat format, uint32_t width)
175 {
176  int rowBytes = 0;
177 
178  switch (format)
179  {
181  case AJA_PixelFormat_YUY28:
182  rowBytes = width * 2;
183  break;
184 
187  rowBytes = (( width % 48 == 0 ) ? width : (((width / 48 ) + 1) * 48)) * 8 / 3;
188  break;
189 
192  rowBytes = width * 3;
193  break;
194 
195  case AJA_PixelFormat_ARGB8:
202  rowBytes = width * 4;
203  break;
204 
206  // Note: not technically true but for now using this for bayer test patterns.
211  rowBytes = width * 6;
212  break;
213 
215  // 36 bits/pixel packed.
216  rowBytes = width * 36 / 8;
217  break;
218 
221  // 10 bits/pixel raw packed
222  rowBytes = width * 10 / 8;
223  break;
224 
227  // 10 bits/pixel packed planer
228  rowBytes = width * 20 / 16;
229  break;
230 
231  // planar format are average-effective
235  rowBytes = width * 3 / 2; // average-effective
236  break;
240  rowBytes = width * 2; // average-effective
241  break;
244  rowBytes = width * 3; // average-effective
245  break;
248  rowBytes = width * 4; // average-effective
249  break;
250 
251  default:
252  // TO DO.....add more
253  break;
254 
255  }
256 
257  return rowBytes;
258 }
259 
260 // UnPack10BitYCbCrBuffer
261 // UnPack 10 Bit YCbCr Data to 16 bit Word per component
262 void AJA_UnPack10BitYCbCrBuffer( uint32_t* packedBuffer, uint16_t* ycbcrBuffer, uint32_t numPixels )
263 {
264  for ( uint32_t sampleCount = 0, dataCount = 0;
265  sampleCount < (numPixels*2) ;
266  sampleCount+=3,dataCount++ )
267  {
268  ycbcrBuffer[sampleCount] = packedBuffer[dataCount]&0x3FF;
269  ycbcrBuffer[sampleCount+1] = (packedBuffer[dataCount]>>10)&0x3FF;
270  ycbcrBuffer[sampleCount+2] = (packedBuffer[dataCount]>>20)&0x3FF;
271  }
272 }
273 
274 // PackTo10BitYCbCrBuffer
275 // Pack 16 bit Word per component to 10 Bit YCbCr Data
276 void AJA_PackTo10BitYCbCrBuffer( uint16_t *ycbcrBuffer, uint32_t *packedBuffer,uint32_t numPixels )
277 {
278  for ( uint32_t inputCount=0, outputCount=0;
279  inputCount < (numPixels*2);
280  outputCount += 4,inputCount += 12 )
281  {
282  packedBuffer[outputCount] = ycbcrBuffer[inputCount+0] + (ycbcrBuffer[inputCount+1]<<10) + (ycbcrBuffer[inputCount+2]<<20);
283  packedBuffer[outputCount+1] = ycbcrBuffer[inputCount+3] + (ycbcrBuffer[inputCount+4]<<10) + (ycbcrBuffer[inputCount+5]<<20);
284  packedBuffer[outputCount+2] = ycbcrBuffer[inputCount+6] + (ycbcrBuffer[inputCount+7]<<10) + (ycbcrBuffer[inputCount+8]<<20);
285  packedBuffer[outputCount+3] = ycbcrBuffer[inputCount+9] + (ycbcrBuffer[inputCount+10]<<10) + (ycbcrBuffer[inputCount+11]<<20);
286  }
287 }
288 
289 // AJA_PackTo10BitYCbCrDPXBuffer
290 // Pack 16 bit Word per component to 10 Bit YCbCr Data
291 void AJA_PackTo10BitYCbCrDPXBuffer( uint16_t *ycbcrBuffer, uint32_t *packedBuffer,uint32_t numPixels , bool bigEndian)
292 {
293  for ( uint32_t inputCount=0, outputCount=0;
294  inputCount < (numPixels*2);
295  outputCount += 4,inputCount += 12 )
296  {
297  if ( bigEndian )
298  {
299  packedBuffer[outputCount] = AJA_ENDIAN_SWAP32(((ycbcrBuffer[inputCount+0]<<20) + (ycbcrBuffer[inputCount+1]<<10) + (ycbcrBuffer[inputCount+2]))<<2);
300  packedBuffer[outputCount+1] = AJA_ENDIAN_SWAP32(((ycbcrBuffer[inputCount+3]<<20) + (ycbcrBuffer[inputCount+4]<<10) + (ycbcrBuffer[inputCount+5]))<<2);
301  packedBuffer[outputCount+2] = AJA_ENDIAN_SWAP32(((ycbcrBuffer[inputCount+6]<<20) + (ycbcrBuffer[inputCount+7]<<10) + (ycbcrBuffer[inputCount+8]))<<2);
302  packedBuffer[outputCount+3] = AJA_ENDIAN_SWAP32(((ycbcrBuffer[inputCount+9]<<20) + (ycbcrBuffer[inputCount+10]<<10) + (ycbcrBuffer[inputCount+11]))<<2);
303  }
304  else
305  {
306  packedBuffer[outputCount] = (((ycbcrBuffer[inputCount+0]<<20) + (ycbcrBuffer[inputCount+1]<<10) + (ycbcrBuffer[inputCount+2]))<<2);
307  packedBuffer[outputCount+1] = (((ycbcrBuffer[inputCount+3]<<20) + (ycbcrBuffer[inputCount+4]<<10) + (ycbcrBuffer[inputCount+5]))<<2);
308  packedBuffer[outputCount+2] = (((ycbcrBuffer[inputCount+6]<<20) + (ycbcrBuffer[inputCount+7]<<10) + (ycbcrBuffer[inputCount+8]))<<2);
309  packedBuffer[outputCount+3] = (((ycbcrBuffer[inputCount+9]<<20) + (ycbcrBuffer[inputCount+10]<<10) + (ycbcrBuffer[inputCount+11]))<<2);
310  }
311  }
312 }
313 
314 // Pack 10 Bit RGBA to 10 Bit RGB Format for our board
315 void AJA_PackRGB10BitFor10BitRGB(AJA_RGBAlpha10BitPixel* rgba10BitBuffer,uint32_t numPixels)
316 {
317  uint32_t* outputBuffer = (uint32_t*)rgba10BitBuffer;
318  for ( uint32_t pixel=0;pixel<numPixels;pixel++)
319  {
320  uint16_t Red = rgba10BitBuffer[pixel].Red;
321  uint16_t Green = rgba10BitBuffer[pixel].Green;
322  uint16_t Blue = rgba10BitBuffer[pixel].Blue;
323  outputBuffer[pixel] = (Blue<<20) + (Green<<10) + Red;
324  }
325 }
326 
327 // Pack 10 Bit RGBA to NTV2_FBF_10BIT_RGB_PACKED Format for our board
328 void AJA_PackRGB10BitFor10BitRGBPacked(AJA_RGBAlpha10BitPixel* rgba10BitBuffer,uint32_t numPixels)
329 {
330  uint32_t* outputBuffer = (uint32_t*)rgba10BitBuffer;
331  for ( uint32_t pixel=0;pixel<numPixels;pixel++)
332  {
333  uint16_t Red = rgba10BitBuffer[pixel].Red;
334  uint16_t Green = rgba10BitBuffer[pixel].Green;
335  uint16_t Blue = rgba10BitBuffer[pixel].Blue;
336  uint32_t value = (((Red>>2)&0xFF)<<16) + (((Green>>2)&0xFF)<<8) + ((Blue>>2)&0xFF);
337  value |= ((Red&0x3)<<28) + ((Green&0x3)<<26) + ((Blue&0x3)<<24);
338 
339  outputBuffer[pixel] = value;
340  }
341 }
342 
343 // Pack 10 Bit RGBA to 10 Bit DPX Format for our board
344 void AJA_PackRGB10BitFor10BitDPX(AJA_RGBAlpha10BitPixel* rgba10BitBuffer,uint32_t numPixels, bool bigEndian)
345 {
346  uint32_t* outputBuffer = (uint32_t*)rgba10BitBuffer;
347  for ( uint32_t pixel=0;pixel<numPixels;pixel++)
348  {
349  uint16_t Red = rgba10BitBuffer[pixel].Red;
350  uint16_t Green = rgba10BitBuffer[pixel].Green;
351  uint16_t Blue = rgba10BitBuffer[pixel].Blue;
352  uint32_t value = (Red<<22) + (Green<<12) + (Blue<<2);
353  if ( bigEndian)
354  outputBuffer[pixel] = ((value&0xFF)<<24) + (((value>>8)&0xFF)<<16) + (((value>>16)&0xFF)<<8) + ((value>>24)&0xFF);
355  else
356  outputBuffer[pixel] =value;
357  }
358 }
359 
360 // UnPack 10 Bit DPX Format linebuffer to RGBAlpha10BitPixel linebuffer.
361 void AJA_UnPack10BitDPXtoRGBAlpha10BitPixel(AJA_RGBAlpha10BitPixel* rgba10BitBuffer,uint32_t* DPXLinebuffer ,uint32_t numPixels, bool bigEndian)
362 {
363  for ( uint32_t pixel=0;pixel<numPixels;pixel++)
364  {
365  uint32_t value = DPXLinebuffer[pixel];
366  if ( bigEndian)
367  {
368  value = _ENDIAN_SWAP32(value);
369  }
370  else
371  {
372  rgba10BitBuffer[pixel].Red = (value>>22)&0x3FF;
373  rgba10BitBuffer[pixel].Green = (value>>12)&0x3FF;
374  rgba10BitBuffer[pixel].Blue = (value>>2)&0x3FF;
375 
376  }
377  }
378 }
379 
380 // UnPack 10 Bit DPX Format linebuffer to AJA_RGBAlphaPixel linebuffer.
381 void AJA_UnPack10BitDPXtoRGBAlphaBitPixel(uint8_t* rgbaBuffer,uint32_t* DPXLinebuffer ,uint32_t numPixels, bool bigEndian)
382 {
383  for ( uint32_t pixel=0;pixel<numPixels;pixel++)
384  {
385  uint32_t value = DPXLinebuffer[pixel];
386  uint8_t R,G,B;
387  if ( bigEndian)
388  {
389  B = ((value & 0xF0000000)>>28) + ((value&0x000F0000)>>12);
390  G = ((value & 0x3F00)>>6) + ((value & 0xC00000)>>22);
391  R = (value&0xFF);
392  }
393  else
394  {
395  B = (value>>22)&0x3FF;
396  G = (value>>12)&0x3FF;
397  R = (value>>2)&0x3FF;
398  }
399  *rgbaBuffer++ = B;
400  *rgbaBuffer++ = G;
401  *rgbaBuffer++ = R;
402  *rgbaBuffer++ = 0xFF;
403 
404  }
405 }
406 void AJA_MakeUnPacked10BitYCbCrBuffer( uint16_t* buffer, uint16_t Y , uint16_t Cb , uint16_t Cr,uint32_t numPixels )
407 {
408  // assumes lineData is large enough for numPixels
409  for ( uint32_t count = 0; count < numPixels*2; count+=4 )
410  {
411  buffer[count] = Cb;
412  buffer[count+1] = Y;
413  buffer[count+2] = Cr;
414  buffer[count+3] = Y;
415  }
416 }
417 
418 void AJA_MakeUnPacked8BitYCbCrBuffer( uint8_t* buffer, uint8_t Y , uint8_t Cb , uint8_t Cr,uint32_t numPixels )
419 {
420  // assumes lineData is large enough for numPixels
421  for ( uint32_t count = 0; count < numPixels*2; count+=4 )
422  {
423  buffer[count] = Cb;
424  buffer[count+1] = Y;
425  buffer[count+2] = Cr;
426  buffer[count+3] = Y;
427  }
428 }
429 
430 // ConvertLineto8BitYCbCr
431 // 10 Bit YCbCr to 8 Bit YCbCr
432 void AJA_ConvertLineto8BitYCbCr(uint16_t * ycbcr10BitBuffer, uint8_t * ycbcr8BitBuffer, uint32_t numPixels)
433 {
434  for ( uint32_t pixel=0;pixel<numPixels*2;pixel++)
435  {
436  ycbcr8BitBuffer[pixel] = ycbcr10BitBuffer[pixel]>>2;
437  }
438 
439 }
440 
441 // ConvertLineto8BitYCbCr
442 // 10 Bit YCbCr to 8 Bit YCbCr
444  uint16_t* YCbCrLine,
445  int32_t numPixels ,
446  int32_t startPixel,
447  bool fUseSDMatrix)
448 {
449  AJA_YCbCr10BitPixel YCbCr;
450  uint16_t *pYCbCr = &YCbCrLine[(startPixel&~1)*2]; // startPixel needs to be even
451 
452  AJA_ConvertRGBAlphatoYCbCr convertRGBAlphatoYCbCr;
453  if ( fUseSDMatrix )
454  convertRGBAlphatoYCbCr = AJA_HDConvertRGBAlphatoYCbCr;
455  else
456  convertRGBAlphatoYCbCr = AJA_SDConvertRGBAlphatoYCbCr;
457 
458 
459 
460  for ( int32_t pixel = 0; pixel < numPixels; pixel++ )
461  {
462  convertRGBAlphatoYCbCr(&RGBLine[pixel],&YCbCr);
463 
464  if ( pixel & 0x1 )
465  {
466  // Just Y
467  *pYCbCr++ = YCbCr.y;
468  }
469  else
470  {
471  *pYCbCr++ = YCbCr.cb;
472  *pYCbCr++ = YCbCr.y;
473  *pYCbCr++ = YCbCr.cr;
474 
475  }
476 
477  }
478 
479 }
480 
481 // ConvertLineto8BitYCbCr
482 // 10 Bit RGB to 10 Bit YCbCr
484  uint16_t* YCbCrLine,
485  int32_t numPixels ,
486  int32_t startPixel,
487  bool fUseRGBFullRange)
488 {
489  AJA_YCbCr10BitPixel YCbCr;
490  uint16_t *pYCbCr = &YCbCrLine[(startPixel&~1)*2]; // startPixel needs to be even
491 
492  //AJA_ConvertRGBAlphatoYCbCr convertRGBAlphatoYCbCr;
493  //if ( fUseSDMatrix )
494  //convertRGBAlphatoYCbCr = AJA_HDConvertRGBAlpha10toYCbCr;
495 
496 
497 
498  for ( int32_t pixel = 0; pixel < numPixels; pixel++ )
499  {
500  AJA_HDConvertRGBAlpha10toYCbCr(&RGBLine[pixel],&YCbCr,fUseRGBFullRange);
501 
502  if ( pixel & 0x1 )
503  {
504  // Just Y
505  *pYCbCr++ = YCbCr.y;
506  }
507  else
508  {
509  *pYCbCr++ = YCbCr.cb;
510  *pYCbCr++ = YCbCr.y;
511  *pYCbCr++ = YCbCr.cr;
512 
513  }
514 
515  }
516 
517 }
518 // ConvertLineto10BitRGB
519 // 10 Bit YCbCr and 10 Bit RGB Version
520 void AJA_ConvertLineto10BitRGB(uint16_t * ycbcrBuffer, AJA_RGBAlpha10BitPixel * rgbaBuffer,uint32_t numPixels,bool fUseSDMatrix)
521 {
522  AJA_YCbCr10BitAlphaPixel ycbcrPixel;
523  uint16_t Cb1,Y1,Cr1,Cb2,Y2,Cr2;
524 
525  // take a line(CbYCrYCbYCrY....) to AJA_RGBAlphaPixels.
526  // 2 AJA_RGBAlphaPixels at a time.
527  Cb1 = *ycbcrBuffer++;
528  Y1 = *ycbcrBuffer++;
529  Cr1 = *ycbcrBuffer++;
530  for ( uint32_t count = 0; count < numPixels; count+=2 )
531  {
532  ycbcrPixel.cb = (uint16_t)Cb1;
533  ycbcrPixel.y = (uint16_t)Y1;
534  ycbcrPixel.cr = (uint16_t)Cr1;
535  ycbcrPixel.Alpha = CCIR601_10BIT_WHITE;
536 
537  if(fUseSDMatrix) {
538  AJA_SDConvert10BitYCbCrto10BitRGB(&ycbcrPixel,&rgbaBuffer[count]);
539  } else {
540  AJA_HDConvert10BitYCbCrto10BitRGB(&ycbcrPixel,&rgbaBuffer[count]);
541  }
542  // Read lone midde Y;
543  ycbcrPixel.y = *ycbcrBuffer++;
544 
545  // Read Next full bandwidth sample
546  // unless we are at the end of a line
547  if ( (count + 2 ) >= numPixels )
548  {
549  Cb2 = (uint16_t)Cb1;
550  Y2 = (uint16_t)Y1;
551  Cr2 = (uint16_t)Cr1;
552  }
553  else
554  {
555  Cb2 = *ycbcrBuffer++;
556  Y2 = *ycbcrBuffer++;
557  Cr2 = *ycbcrBuffer++;
558  }
559  // Interpolate and write Inpterpolated AJA_RGBAlphaPixel
560  ycbcrPixel.cb = (uint16_t)((Cb1+Cb2)/2);
561  ycbcrPixel.cr = (uint16_t)((Cr1+Cr2)/2);
562  if(fUseSDMatrix) {
563  AJA_SDConvert10BitYCbCrto10BitRGB(&ycbcrPixel,&rgbaBuffer[count+1]);
564  } else {
565  AJA_HDConvert10BitYCbCrto10BitRGB(&ycbcrPixel,&rgbaBuffer[count+1]);
566  }
567 
568  // Setup for next loop
569  Cb1 = Cb2;
570  Cr1 = Cr2;
571  Y1 = Y2;
572 
573  }
574 }
575 
576 // ConvertLinetoRGB
577 // 8 Bit YCbCr 8 Bit RGB version
578 void AJA_ConvertLinetoRGB(uint8_t * ycbcrBuffer,
579  AJA_RGBAlphaPixel * rgbaBuffer,
580  uint32_t numPixels,
581  bool fUseSDMatrix)
582 {
583  AJA_YCbCr10BitAlphaPixel ycbcrPixel;
584  uint16_t Cb1,Y1,Cr1,Cb2,Y2,Cr2;
585 
586  // take a line(CbYCrYCbYCrY....) to AJA_RGBAlphaPixels.
587  // 2 AJA_RGBAlphaPixels at a time.
588  Cb1 = (*ycbcrBuffer++)<<2;
589  Y1 = (*ycbcrBuffer++)<<2;
590  Cr1 = (*ycbcrBuffer++)<<2;
591  for ( uint32_t count = 0; count < numPixels; count+=2 )
592  {
593  ycbcrPixel.cb = (uint16_t)Cb1;
594  ycbcrPixel.y = (uint16_t)Y1;
595  ycbcrPixel.cr = (uint16_t)Cr1;
596  ycbcrPixel.Alpha = CCIR601_10BIT_WHITE;
597 
598  if(fUseSDMatrix) {
599  AJA_SDConvert10BitYCbCrtoRGB(&ycbcrPixel,&rgbaBuffer[count]);
600  } else {
601  AJA_HDConvert10BitYCbCrtoRGB(&ycbcrPixel,&rgbaBuffer[count]);
602  }
603  // Read lone midde Y;
604  ycbcrPixel.y = (*ycbcrBuffer++)<<2;
605 
606  // Read Next full bandwidth sample
607  // unless we are at the end of a line
608  if ( (count + 2 ) >= numPixels )
609  {
610  Cb2 = (uint16_t)(Cb1);
611  Y2 = (uint16_t)(Y1);
612  Cr2 = (uint16_t)(Cr1);
613  }
614  else
615  {
616  Cb2 = (*ycbcrBuffer++)<<2;
617  Y2 = (*ycbcrBuffer++)<<2;
618  Cr2 = (*ycbcrBuffer++)<<2;
619  }
620  // Interpolate and write Inpterpolated AJA_RGBAlphaPixel
621  ycbcrPixel.cb = (uint16_t)((Cb1+Cb2)/2);
622  ycbcrPixel.cr = (uint16_t)((Cr1+Cr2)/2);
623  if(fUseSDMatrix) {
624  AJA_SDConvert10BitYCbCrtoRGB(&ycbcrPixel,&rgbaBuffer[count+1]);
625  } else {
626  AJA_HDConvert10BitYCbCrtoRGB(&ycbcrPixel,&rgbaBuffer[count+1]);
627  }
628 
629  // Setup for next loop
630  Cb1 = Cb2;
631  Cr1 = Cr2;
632  Y1 = Y2;
633 
634  }
635 }
636 
637 // ConvertLinetoRGB
638 // 10 Bit YCbCr 8 Bit RGB version
639 void AJA_ConvertLinetoRGB(uint16_t * ycbcrBuffer,
640  AJA_RGBAlphaPixel * rgbaBuffer,
641  uint32_t numPixels,
642  bool fUseSDMatrix)
643 {
644  AJA_YCbCr10BitAlphaPixel ycbcrPixel;
645  uint16_t Cb1,Y1,Cr1,Cb2,Y2,Cr2;
646 
647  // take a line(CbYCrYCbYCrY....) to AJA_RGBAlphaPixels.
648  // 2 AJA_RGBAlphaPixels at a time.
649  Cb1 = *ycbcrBuffer++;
650  Y1 = *ycbcrBuffer++;
651  Cr1 = *ycbcrBuffer++;
652  for ( uint32_t count = 0; count < numPixels; count+=2 )
653  {
654  ycbcrPixel.cb = (uint16_t)Cb1;
655  ycbcrPixel.y = (uint16_t)Y1;
656  ycbcrPixel.cr = (uint16_t)Cr1;
657  ycbcrPixel.Alpha = CCIR601_10BIT_WHITE;
658 
659  if(fUseSDMatrix) {
660  AJA_SDConvert10BitYCbCrtoRGB(&ycbcrPixel,&rgbaBuffer[count]);
661  } else {
662  AJA_HDConvert10BitYCbCrtoRGB(&ycbcrPixel,&rgbaBuffer[count]);
663  }
664  // Read lone midde Y;
665  ycbcrPixel.y = *ycbcrBuffer++;
666 
667  // Read Next full bandwidth sample
668  // unless we are at the end of a line
669  if ( (count + 2 ) >= numPixels )
670  {
671  Cb2 = (uint16_t)Cb1;
672  Y2 = (uint16_t)Y1;
673  Cr2 = (uint16_t)Cr1;
674  }
675  else
676  {
677  Cb2 = *ycbcrBuffer++;
678  Y2 = *ycbcrBuffer++;
679  Cr2 = *ycbcrBuffer++;
680  }
681  // Interpolate and write Inpterpolated AJA_RGBAlphaPixel
682  ycbcrPixel.cb = (uint16_t)((Cb1+Cb2)/2);
683  ycbcrPixel.cr = (uint16_t)((Cr1+Cr2)/2);
684  if(fUseSDMatrix) {
685  AJA_SDConvert10BitYCbCrtoRGB(&ycbcrPixel,&rgbaBuffer[count+1]);
686  } else {
687  AJA_HDConvert10BitYCbCrtoRGB(&ycbcrPixel,&rgbaBuffer[count+1]);
688  }
689 
690  // Setup for next loop
691  Cb1 = Cb2;
692  Cr1 = Cr2;
693  Y1 = Y2;
694 
695  }
696 }
697 
698 // ConvertLinetoRGB
699 // 10 Bit YCbCr 16 Bit RGB version
700 void AJA_ConvertLineto16BitRGB(uint16_t * ycbcrBuffer, AJA_RGBAlpha16BitPixel * rgbaBuffer, uint32_t numPixels, bool fUseSDMatrix)
701 {
702  AJA_YCbCr10BitAlphaPixel ycbcrPixel;
703  uint16_t Cb1,Y1,Cr1,Cb2,Y2,Cr2;
704 
705  // take a line(CbYCrYCbYCrY....) to AJA_RGBAlpha16Pixels.
706  // 2 AJA_RGBAlpha16Pixels at a time.
707  Cb1 = *ycbcrBuffer++;
708  Y1 = *ycbcrBuffer++;
709  Cr1 = *ycbcrBuffer++;
710  for ( uint32_t count = 0; count < numPixels; count+=2 )
711  {
712  ycbcrPixel.cb = (uint16_t)Cb1;
713  ycbcrPixel.y = (uint16_t)Y1;
714  ycbcrPixel.cr = (uint16_t)Cr1;
715  ycbcrPixel.Alpha = CCIR601_10BIT_WHITE;
716 
717  if(fUseSDMatrix) {
718  AJA_SDConvert10BitYCbCrto10BitRGB(&ycbcrPixel,(AJA_RGBAlpha10BitPixel *)&rgbaBuffer[count]);
719  rgbaBuffer[count].Red = (rgbaBuffer[count].Red) << 6;
720  rgbaBuffer[count].Green = (rgbaBuffer[count].Green) << 6;
721  rgbaBuffer[count].Blue = (rgbaBuffer[count].Blue) << 6;
722  } else {
723  AJA_HDConvert10BitYCbCrto10BitRGB(&ycbcrPixel,(AJA_RGBAlpha10BitPixel *)&rgbaBuffer[count]);
724  rgbaBuffer[count].Red = (rgbaBuffer[count].Red) << 6;
725  rgbaBuffer[count].Green = (rgbaBuffer[count].Green) << 6;
726  rgbaBuffer[count].Blue = (rgbaBuffer[count].Blue) << 6;
727  }
728 
729  // Read lone midde Y;
730  ycbcrPixel.y = *ycbcrBuffer++;
731 
732  // Read Next full bandwidth sample
733  // unless we are at the end of a line
734  if ( (count + 2 ) >= numPixels )
735  {
736  Cb2 = (uint16_t)Cb1;
737  Y2 = (uint16_t)Y1;
738  Cr2 = (uint16_t)Cr1;
739  }
740  else
741  {
742  Cb2 = *ycbcrBuffer++;
743  Y2 = *ycbcrBuffer++;
744  Cr2 = *ycbcrBuffer++;
745  }
746  // Interpolate and write Inpterpolated AJA_RGBAlpha16Pixel
747  ycbcrPixel.cb = (uint16_t)((Cb1+Cb2)/2);
748  ycbcrPixel.cr = (uint16_t)((Cr1+Cr2)/2);
749  if(fUseSDMatrix) {
750  AJA_SDConvert10BitYCbCrto10BitRGB(&ycbcrPixel,(AJA_RGBAlpha10BitPixel *)&rgbaBuffer[count+1]);
751  rgbaBuffer[count+1].Red = (rgbaBuffer[count+1].Red) << 6;
752  rgbaBuffer[count+1].Green = (rgbaBuffer[count+1].Green) << 6;
753  rgbaBuffer[count+1].Blue = (rgbaBuffer[count+1].Blue) << 6;
754  } else {
755  AJA_HDConvert10BitYCbCrto10BitRGB(&ycbcrPixel,(AJA_RGBAlpha10BitPixel *)&rgbaBuffer[count+1]);
756  rgbaBuffer[count+1].Red = (rgbaBuffer[count+1].Red) << 6;
757  rgbaBuffer[count+1].Green = (rgbaBuffer[count+1].Green) << 6;
758  rgbaBuffer[count+1].Blue = (rgbaBuffer[count+1].Blue) << 6;
759  }
760 
761  // Setup for next loop
762  Cb1 = Cb2;
763  Cr1 = Cr2;
764  Y1 = Y2;
765 
766  }
767 }
768 
769 // ConvertLinetoBayer10BitDPXLJ
770 // 10 Bit YCbCr 10 Bit Bayer Left Justified version
771 void AJA_Convert16BitRGBtoBayer10BitDPXLJ(AJA_RGBAlpha16BitPixel * rgbaBuffer, uint32_t * bayerBuffer,
772  uint32_t numPixels, uint32_t line, AJA_BayerColorPhase phase)
773 {
774  uint32_t pixel0 = 0;
775  uint32_t pixel1 = 0;
776 
777  for ( uint32_t count = 0; count < numPixels; count++ )
778  {
779  switch (phase)
780  {
781  default:
783  if ((line & 0x1) == 0)
784  {
785  pixel0 = rgbaBuffer[count].Red;
786  pixel1 = rgbaBuffer[count].Green;
787  }
788  else
789  {
790  pixel0 = rgbaBuffer[count].Green;
791  pixel1 = rgbaBuffer[count].Blue;
792  }
793  break;
795  if ((line & 0x1) == 0)
796  {
797  pixel0 = rgbaBuffer[count].Green;
798  pixel1 = rgbaBuffer[count].Red;
799  }
800  else
801  {
802  pixel0 = rgbaBuffer[count].Blue;
803  pixel1 = rgbaBuffer[count].Green;
804  }
805  break;
807  if ((line & 0x1) == 0)
808  {
809  pixel0 = rgbaBuffer[count].Blue;
810  pixel1 = rgbaBuffer[count].Green;
811  }
812  else
813  {
814  pixel0 = rgbaBuffer[count].Green;
815  pixel1 = rgbaBuffer[count].Red;
816  }
817  break;
819  if ((line & 0x1) == 0)
820  {
821  pixel0 = rgbaBuffer[count].Green;
822  pixel1 = rgbaBuffer[count].Blue;
823  }
824  else
825  {
826  pixel0 = rgbaBuffer[count].Red;
827  pixel1 = rgbaBuffer[count].Green;
828  }
829  break;
830  }
831 
832  uint32_t ind = count/3;
833  uint32_t rem = count%6;
834 
835  switch (rem)
836  {
837  case 0:
838  bayerBuffer[ind] = ((pixel0 >> 6) & 0x3ff) << 2;
839  break;
840  case 1:
841  bayerBuffer[ind] |= ((pixel1 >> 6) & 0x3ff) << 12;
842  break;
843  case 2:
844  bayerBuffer[ind] |= ((pixel0 >> 6) & 0x3ff) << 22;
845  break;
846  case 3:
847  bayerBuffer[ind] = ((pixel1 >> 6) & 0x3ff) << 2;
848  break;
849  case 4:
850  bayerBuffer[ind] |= ((pixel0 >> 6) & 0x3ff) << 12;
851  break;
852  case 5:
853  bayerBuffer[ind] |= ((pixel1 >> 6) & 0x3ff) << 22;
854  break;
855  default:
856  break;
857  }
858  }
859 }
860 
861 // ConvertLinetoBayer12BitDPXLJ
862 // 10 Bit YCbCr 12 Bit Bayer Left Justified version
863 void AJA_Convert16BitRGBtoBayer12BitDPXLJ(AJA_RGBAlpha16BitPixel * rgbaBuffer, uint32_t * bayerBuffer,
864  uint32_t numPixels, uint32_t line, AJA_BayerColorPhase phase)
865 {
866  uint32_t pixel0 = 0;
867  uint32_t pixel1 = 0;
868  uint16_t* buffer = (uint16_t*)bayerBuffer;
869 
870  for ( uint32_t count = 0; count < numPixels; count++ )
871  {
872  switch (phase)
873  {
874  default:
876  if ((line & 0x1) == 0)
877  {
878  pixel0 = rgbaBuffer[count].Red;
879  pixel1 = rgbaBuffer[count].Green;
880  }
881  else
882  {
883  pixel0 = rgbaBuffer[count].Green;
884  pixel1 = rgbaBuffer[count].Blue;
885  }
886  break;
888  if ((line & 0x1) == 0)
889  {
890  pixel0 = rgbaBuffer[count].Green;
891  pixel1 = rgbaBuffer[count].Red;
892  }
893  else
894  {
895  pixel0 = rgbaBuffer[count].Blue;
896  pixel1 = rgbaBuffer[count].Green;
897  }
898  break;
900  if ((line & 0x1) == 0)
901  {
902  pixel0 = rgbaBuffer[count].Blue;
903  pixel1 = rgbaBuffer[count].Green;
904  }
905  else
906  {
907  pixel0 = rgbaBuffer[count].Green;
908  pixel1 = rgbaBuffer[count].Red;
909  }
910  break;
912  if ((line & 0x1) == 0)
913  {
914  pixel0 = rgbaBuffer[count].Green;
915  pixel1 = rgbaBuffer[count].Blue;
916  }
917  else
918  {
919  pixel0 = rgbaBuffer[count].Red;
920  pixel1 = rgbaBuffer[count].Green;
921  }
922  break;
923  }
924 
925  if ((count & 0x1) == 0)
926  {
927  buffer[count] = pixel0;
928  }
929  else
930  {
931  buffer[count] = pixel1;
932  }
933  }
934 }
935 
936 // ConvertLinetoBayer10BitDPXPacked
937 // 10 Bit YCbCr 10 Bit Bayer Packed version
938 void AJA_Convert16BitRGBtoBayer10BitDPXPacked(AJA_RGBAlpha16BitPixel * rgbaBuffer, uint8_t * bayerBuffer,
939  uint32_t numPixels, uint32_t line, AJA_BayerColorPhase phase)
940 {
941  uint32_t pixel0 = 0;
942  uint32_t pixel1 = 0;
943  uint32_t pack = 0;
944 
945  for ( uint32_t count = 0; count < numPixels; count++ )
946  {
947  switch (phase)
948  {
949  default:
951  if ((line & 0x1) == 0)
952  {
953  pixel0 = rgbaBuffer[count].Red;
954  pixel1 = rgbaBuffer[count].Green;
955  }
956  else
957  {
958  pixel0 = rgbaBuffer[count].Green;
959  pixel1 = rgbaBuffer[count].Blue;
960  }
961  break;
963  if ((line & 0x1) == 0)
964  {
965  pixel0 = rgbaBuffer[count].Green;
966  pixel1 = rgbaBuffer[count].Red;
967  }
968  else
969  {
970  pixel0 = rgbaBuffer[count].Blue;
971  pixel1 = rgbaBuffer[count].Green;
972  }
973  break;
975  if ((line & 0x1) == 0)
976  {
977  pixel0 = rgbaBuffer[count].Blue;
978  pixel1 = rgbaBuffer[count].Green;
979  }
980  else
981  {
982  pixel0 = rgbaBuffer[count].Green;
983  pixel1 = rgbaBuffer[count].Red;
984  }
985  break;
987  if ((line & 0x1) == 0)
988  {
989  pixel0 = rgbaBuffer[count].Green;
990  pixel1 = rgbaBuffer[count].Blue;
991  }
992  else
993  {
994  pixel0 = rgbaBuffer[count].Red;
995  pixel1 = rgbaBuffer[count].Green;
996  }
997  break;
998  }
999 
1000  switch (pack)
1001  {
1002  case 0:
1003  if ((count & 0x1) == 0)
1004  {
1005  *bayerBuffer++ = (uint8_t)((pixel0 >> 6) & 0xff);
1006  *bayerBuffer = (uint8_t)((pixel0 >> 14) & 0x3);
1007  }
1008  else
1009  {
1010  *bayerBuffer++ = (uint8_t)((pixel1 >> 6) & 0xff);
1011  *bayerBuffer = (uint8_t)((pixel1 >> 14) & 0x3);
1012  }
1013  pack = 2;
1014  break;
1015  case 2:
1016  if ((count & 0x1) == 0)
1017  {
1018  *bayerBuffer++ |= (uint8_t)(((pixel0 >> 6) & 0x3f) << 2);
1019  *bayerBuffer = (uint8_t)((pixel0 >> 12) & 0xf);
1020  }
1021  else
1022  {
1023  *bayerBuffer++ |= (uint8_t)(((pixel1 >> 6) & 0x3f) << 2);
1024  *bayerBuffer = (uint8_t)((pixel1 >> 12) & 0xf);
1025  }
1026  pack = 4;
1027  break;
1028  case 4:
1029  if ((count & 0x1) == 0)
1030  {
1031  *bayerBuffer++ |= (uint8_t)(((pixel0 >> 6) & 0xf) << 4);
1032  *bayerBuffer = (uint8_t)((pixel0 >> 10) & 0x3f);
1033  }
1034  else
1035  {
1036  *bayerBuffer++ |= (uint8_t)(((pixel1 >> 6) & 0xf) << 4);
1037  *bayerBuffer = (uint8_t)((pixel1 >> 10) & 0x3f);
1038  }
1039  pack = 6;
1040  break;
1041  case 6:
1042  if ((count & 0x1) == 0)
1043  {
1044  *bayerBuffer++ |= (uint8_t)(((pixel0 >> 6) & 0x3) << 6);
1045  *bayerBuffer++ = (uint8_t)((pixel0 >> 8) & 0xff);
1046  }
1047  else
1048  {
1049  *bayerBuffer++ |= (uint8_t)(((pixel1 >> 6) & 0x3) << 6);
1050  *bayerBuffer++ = (uint8_t)((pixel1 >> 8) & 0xff);
1051  }
1052  pack = 0;
1053  break;
1054  default:
1055  break;
1056  }
1057  }
1058 }
1059 
1060 // ConvertLinetoBayer12BitDPXPacked
1061 // 10 Bit YCbCr 12 Bit Bayer Packed version
1062 void AJA_Convert16BitRGBtoBayer12BitDPXPacked(AJA_RGBAlpha16BitPixel * rgbaBuffer, uint8_t * bayerBuffer,
1063  uint32_t numPixels, uint32_t line, AJA_BayerColorPhase phase)
1064 {
1065  uint32_t pixel0 = 0;
1066  uint32_t pixel1 = 0;
1067 
1068  for ( uint32_t count = 0; count < numPixels; count++ )
1069  {
1070  switch (phase)
1071  {
1072  default:
1074  if ((line & 0x1) == 0)
1075  {
1076  pixel0 = rgbaBuffer[count].Red;
1077  pixel1 = rgbaBuffer[count].Green;
1078  }
1079  else
1080  {
1081  pixel0 = rgbaBuffer[count].Green;
1082  pixel1 = rgbaBuffer[count].Blue;
1083  }
1084  break;
1086  if ((line & 0x1) == 0)
1087  {
1088  pixel0 = rgbaBuffer[count].Green;
1089  pixel1 = rgbaBuffer[count].Red;
1090  }
1091  else
1092  {
1093  pixel0 = rgbaBuffer[count].Blue;
1094  pixel1 = rgbaBuffer[count].Green;
1095  }
1096  break;
1098  if ((line & 0x1) == 0)
1099  {
1100  pixel0 = rgbaBuffer[count].Blue;
1101  pixel1 = rgbaBuffer[count].Green;
1102  }
1103  else
1104  {
1105  pixel0 = rgbaBuffer[count].Green;
1106  pixel1 = rgbaBuffer[count].Red;
1107  }
1108  break;
1110  if ((line & 0x1) == 0)
1111  {
1112  pixel0 = rgbaBuffer[count].Green;
1113  pixel1 = rgbaBuffer[count].Blue;
1114  }
1115  else
1116  {
1117  pixel0 = rgbaBuffer[count].Red;
1118  pixel1 = rgbaBuffer[count].Green;
1119  }
1120  break;
1121  }
1122 
1123  if ((count & 0x1) == 0)
1124  {
1125  *bayerBuffer++ = (uint8_t)(((pixel0 >> 4) & 0xff));
1126  *bayerBuffer = (uint8_t)(((pixel0 >> 12) & 0xf));
1127  }
1128  else
1129  {
1130  *bayerBuffer++ |= (uint8_t)(((pixel1 >> 4) & 0xf) << 4);
1131  *bayerBuffer++ = (uint8_t)(((pixel1 >> 8) & 0xff));
1132  }
1133 /*
1134  if ((count & 0x1) == 0)
1135  {
1136  *bayerBuffer = (uint8_t)(((pixel0 >> 12) & 0xf));
1137  *bayerBuffer++ |= (uint8_t)(((pixel0 >> 8) & 0xf) << 4);
1138  *bayerBuffer = (uint8_t)(((pixel0 >> 4) & 0xf));
1139  }
1140  else
1141  {
1142  *bayerBuffer++ |= (uint8_t)(((pixel1 >> 12) & 0xf) << 4);
1143  *bayerBuffer = (uint8_t)(((pixel1 >> 8) & 0xf));
1144  *bayerBuffer++ |= (uint8_t)(((pixel1 >> 4) & 0xf) << 4);
1145  }
1146 */
1147  }
1148 }
1149 
1150 // Converts 8 Bit ARGB 8 Bit RGBA in place
1151 void AJA_ConvertARGBToRGBA(uint8_t* rgbaBuffer,uint32_t numPixels)
1152 {
1153  for ( uint32_t pixel=0;pixel<numPixels*4;pixel+=4)
1154  {
1155  uint8_t B = rgbaBuffer[pixel];
1156  uint8_t G = rgbaBuffer[pixel+1];
1157  uint8_t R = rgbaBuffer[pixel+2];
1158  uint8_t A = rgbaBuffer[pixel+3];
1159  rgbaBuffer[pixel] = A;
1160  rgbaBuffer[pixel+1] = R;
1161  rgbaBuffer[pixel+2] = G;
1162  rgbaBuffer[pixel+3] = B;
1163  }
1164 }
1165 
1166 // Converts 8 Bit ARGB 8 Bit ABGR in place
1167 void AJA_ConvertARGBToABGR(uint8_t* rgbaBuffer,uint32_t numPixels)
1168 {
1169  for ( uint32_t pixel=0;pixel<numPixels*4;pixel+=4)
1170  {
1171  uint8_t B = rgbaBuffer[pixel];
1172  uint8_t G = rgbaBuffer[pixel+1];
1173  uint8_t R = rgbaBuffer[pixel+2];
1174  uint8_t A = rgbaBuffer[pixel+3];
1175  rgbaBuffer[pixel] = R;
1176  rgbaBuffer[pixel+1] = G;
1177  rgbaBuffer[pixel+2] = B;
1178  rgbaBuffer[pixel+3] = A;
1179  }
1180 }
1181 
1182 // Converts 8 Bit ARGB 8 Bit ABGR in place
1183 static void AJA_ConvertARGBToRGB(uint8_t* rgbaBuffer,uint8_t * rgbBuffer, uint32_t numPixels)
1184 {
1185  for ( uint32_t pixel=0;pixel<numPixels*4;pixel+=4)
1186  {
1187  uint8_t B = rgbaBuffer[pixel];
1188  uint8_t G = rgbaBuffer[pixel+1];
1189  uint8_t R = rgbaBuffer[pixel+2];
1190  *rgbBuffer++ = R;
1191  *rgbBuffer++ = G;
1192  *rgbBuffer++ = B;
1193  }
1194 }
1195 
1196 // Converts 8 Bit ARGB 8 Bit ABGR in place
1197 static void AJA_ConvertARGBToBGR(uint8_t* rgbaBuffer, uint8_t * rgbBuffer, uint32_t numPixels)
1198 {
1199  for ( uint32_t pixel=0;pixel<numPixels*4;pixel+=4)
1200  {
1201  uint8_t B = rgbaBuffer[pixel];
1202  uint8_t G = rgbaBuffer[pixel+1];
1203  uint8_t R = rgbaBuffer[pixel+2];
1204  *rgbBuffer++ = B;
1205  *rgbBuffer++ = G;
1206  *rgbBuffer++ = R;
1207  }
1208 }
1209 
1210 void AJA_Convert16BitARGBTo16BitRGB(AJA_RGBAlpha16BitPixel *rgbaLineBuffer ,uint16_t * rgbLineBuffer,uint32_t numPixels)
1211 {
1212  for ( uint32_t pixel=0;pixel<numPixels;pixel++)
1213  {
1214  AJA_RGBAlpha16BitPixel* pixelBuffer = &(rgbaLineBuffer[pixel]);
1215  uint16_t B = pixelBuffer->Blue;
1216  uint16_t G = pixelBuffer->Green;
1217  uint16_t R = pixelBuffer->Red;
1218  *rgbLineBuffer++ = R;
1219  *rgbLineBuffer++ = G;
1220  *rgbLineBuffer++ = B;
1221  }
1222 }
1223 
1224 void AJA_Convert16BitARGBTo12BitRGBPacked(AJA_RGBAlpha16BitPixel *rgbaLineBuffer ,uint8_t * rgbLineBuffer,uint32_t numPixels)
1225 {
1226  uint32_t numRowBytes = AJA_CalcRowBytesForFormat(AJA_PixelFormat_RGB12,numPixels);
1227 
1228  for ( uint32_t byteNumber = 0; byteNumber < numRowBytes; byteNumber += 9 )
1229  {
1230  AJA_RGBAlpha16BitPixel pixelValue = *rgbaLineBuffer++;
1231  uint16_t Blue1 = pixelValue.Blue>>4;
1232  uint16_t Green1 = pixelValue.Green>>4;
1233  uint16_t Red1 = pixelValue.Red>>4;
1234 
1235  pixelValue = *rgbaLineBuffer++;
1236  uint16_t Blue2 = pixelValue.Blue>>4;
1237  uint16_t Green2 = pixelValue.Green>>4;
1238  uint16_t Red2 = pixelValue.Red>>4;
1239  *rgbLineBuffer++ = (uint8_t)(Red1&0xFF);
1240  *rgbLineBuffer++ = (uint8_t)(((Red1>>8)&0xF) + ((Green1&0xF)<<4));
1241  *rgbLineBuffer++ = (uint8_t)((Green1>>4));
1242  *rgbLineBuffer++ = (uint8_t)(Blue1&0xFF);
1243  *rgbLineBuffer++ = (uint8_t)(((Blue1>>8)&0xF) + ((Red2&0xF)<<4));
1244  *rgbLineBuffer++ = (uint8_t)((Red2>>4));
1245  *rgbLineBuffer++ = (uint8_t)(Green2&0xFF);
1246  *rgbLineBuffer++ = (uint8_t)(((Green2>>8)&0xF) + ((Blue2&0xF)<<4));
1247  *rgbLineBuffer++ = (uint8_t)((Blue2>>4));
1248 
1249  }
1250 }
1251 
1252 // Converts UYVY(2yuv) -> YUY2(yuv2) in place
1253 void AJA_Convert8BitYCbCrToYUY2(uint8_t * ycbcrBuffer, uint32_t numPixels)
1254 {
1255  for ( uint32_t pixel=0;pixel<numPixels*2;pixel+=4)
1256  {
1257  uint8_t Cb = ycbcrBuffer[pixel];
1258  uint8_t Y1 = ycbcrBuffer[pixel+1];
1259  uint8_t Cr = ycbcrBuffer[pixel+2];
1260  uint8_t Y2 = ycbcrBuffer[pixel+3];
1261  ycbcrBuffer[pixel] = Y1;
1262  ycbcrBuffer[pixel+1] = Cb;
1263  ycbcrBuffer[pixel+2] = Y2;
1264  ycbcrBuffer[pixel+3] = Cr;
1265  }
1266 }
1267 
1268 // RePackLineDataForYCbCrDPX2
1269 void AJA_RePackLineDataForYCbCrDPX(uint32_t *packedycbcrLine, uint32_t numULWords)
1270 {
1271 
1272  for ( uint16_t count = 0; count < numULWords; count++)
1273  {
1274  uint32_t value = (packedycbcrLine[count])<<2;
1275  value = (value<<24) + ((value>>24)&0x000000FF) + ((value<<8)&0x00FF0000) + ((value>>8)&0x0000FF00);
1276 
1277  packedycbcrLine[count] = value;
1278  }
1279 }
1280 
1281 
1282 
1283 //***********************************************************************************************************
1284 
1285 // ConvertUnpacked10BitYCbCrToPixelFormat()
1286 // Converts a line of "unpacked" 10-bit Y/Cb/Cr pixels into a "packed" line in the pixel format
1287 // for the current frame buffer format.
1288 void AJA_ConvertUnpacked10BitYCbCrToPixelFormat(uint16_t *unPackedBuffer, uint32_t *packedBuffer, uint32_t numPixels, AJA_PixelFormat pixelFormat)
1289 {
1290  bool bIsSD = false;
1291  if(numPixels < 1280)
1292  bIsSD = true;
1293 
1294  switch(pixelFormat)
1295  {
1297  AJA_PackTo10BitYCbCrBuffer(unPackedBuffer, packedBuffer, numPixels);
1298  break;
1299 
1301  AJA_PackTo10BitYCbCrDPXBuffer(unPackedBuffer, packedBuffer, numPixels);
1302  break;
1303 
1305  AJA_ConvertLineto8BitYCbCr(unPackedBuffer,(uint8_t*)packedBuffer, numPixels);
1306  break;
1307 
1308  case AJA_PixelFormat_YUY28:
1309  AJA_ConvertLineto8BitYCbCr(unPackedBuffer,(uint8_t*)packedBuffer, numPixels);
1310  AJA_Convert8BitYCbCrToYUY2((uint8_t*)packedBuffer,numPixels);
1311  break;
1312 
1313  case AJA_PixelFormat_RGB10:
1314  AJA_ConvertLineto10BitRGB(unPackedBuffer,(AJA_RGBAlpha10BitPixel*)packedBuffer,numPixels, bIsSD);
1315  AJA_PackRGB10BitFor10BitRGB((AJA_RGBAlpha10BitPixel*)packedBuffer,numPixels);
1316  break;
1317 
1319  AJA_ConvertLineto10BitRGB(unPackedBuffer,(AJA_RGBAlpha10BitPixel*)packedBuffer,numPixels, bIsSD);
1321  break;
1322 
1324  AJA_ConvertLineto10BitRGB(unPackedBuffer,(AJA_RGBAlpha10BitPixel*)packedBuffer,numPixels, bIsSD);
1325  AJA_PackRGB10BitFor10BitDPX((AJA_RGBAlpha10BitPixel*)packedBuffer,numPixels);
1326  break;
1327 
1329  AJA_ConvertLineto10BitRGB(unPackedBuffer,(AJA_RGBAlpha10BitPixel*)packedBuffer,numPixels, bIsSD);
1330  AJA_PackRGB10BitFor10BitDPX((AJA_RGBAlpha10BitPixel*)packedBuffer,numPixels,false);
1331  break;
1332 
1333  case AJA_PixelFormat_ARGB8:
1334  AJA_ConvertLinetoRGB(unPackedBuffer,(AJA_RGBAlphaPixel*)packedBuffer,numPixels, bIsSD);
1335  break;
1336 
1337  case AJA_PixelFormat_RGBA8:
1338  AJA_ConvertLinetoRGB(unPackedBuffer,(AJA_RGBAlphaPixel*)packedBuffer,numPixels, bIsSD);
1339  AJA_ConvertARGBToRGBA((uint8_t*)packedBuffer,numPixels);
1340  break;
1341 
1342  case AJA_PixelFormat_ABGR8:
1343  AJA_ConvertLinetoRGB(unPackedBuffer,(AJA_RGBAlphaPixel*)packedBuffer,numPixels, bIsSD);
1344  AJA_ConvertARGBToABGR((uint8_t*)packedBuffer,numPixels);
1345  break;
1346 
1347  case AJA_PixelFormat_RGB16:
1348  AJA_ConvertLineto16BitRGB(unPackedBuffer,(AJA_RGBAlpha16BitPixel*)packedBuffer,numPixels, bIsSD);
1349  AJA_Convert16BitARGBTo16BitRGB((AJA_RGBAlpha16BitPixel*)packedBuffer ,(uint16_t*) packedBuffer, numPixels);
1350  break;
1351 
1352  case AJA_PixelFormat_RGB12:
1353  AJA_ConvertLineto16BitRGB(unPackedBuffer,(AJA_RGBAlpha16BitPixel*)packedBuffer,numPixels, bIsSD);
1354  AJA_Convert16BitARGBTo12BitRGBPacked((AJA_RGBAlpha16BitPixel*)packedBuffer ,(uint8_t*) packedBuffer, numPixels);
1355  break;
1356 
1358  AJA_ConvertLinetoRGB(unPackedBuffer, (AJA_RGBAlphaPixel*)packedBuffer,numPixels, bIsSD);
1359  AJA_ConvertARGBToRGB((uint8_t*)packedBuffer,(uint8_t*)packedBuffer, numPixels);
1360  break;
1361 
1363  AJA_ConvertLinetoRGB(unPackedBuffer, (AJA_RGBAlphaPixel*)packedBuffer,numPixels, bIsSD);
1364  AJA_ConvertARGBToBGR((uint8_t*)packedBuffer,(uint8_t*)packedBuffer, numPixels);
1365  break;
1366 
1368  AJA_ConvertLineto16BitRGB(unPackedBuffer,(AJA_RGBAlpha16BitPixel*)packedBuffer,numPixels, bIsSD);
1369  break;
1371  AJA_ConvertLineto16BitRGB(unPackedBuffer,(AJA_RGBAlpha16BitPixel*)packedBuffer,numPixels, bIsSD);
1372  break;
1374  AJA_ConvertLineto16BitRGB(unPackedBuffer,(AJA_RGBAlpha16BitPixel*)packedBuffer,numPixels, bIsSD);
1375  break;
1377  AJA_ConvertLineto16BitRGB(unPackedBuffer,(AJA_RGBAlpha16BitPixel*)packedBuffer,numPixels, bIsSD);
1378  break;
1379 
1380  default:
1381  // TO DO: add all other formats.
1382 
1383  break;
1384  }
1385 }
1386 
1387 // ConvertUnpacked10BitYCbCrToPixelFormat()
1388 // Converts a line of "unpacked" 10-bit Y/Cb/Cr pixels into a "packed" line in the pixel format
1389 // for the current frame buffer format.
1390 void AJA_ConvertPixelFormatToRGBA(uint32_t *buffer, AJA_RGBAlphaPixel* rgbBuffer, uint32_t numPixels, AJA_PixelFormat pixelFormat,bool bIsSD)
1391 {
1392 
1393  switch(pixelFormat)
1394  {
1396  {
1397  uint16_t* unPackedBuffer = new uint16_t[numPixels*2];
1398  AJA_UnPack10BitYCbCrBuffer(buffer,unPackedBuffer,numPixels);
1399  AJA_ConvertLinetoRGB(unPackedBuffer,(AJA_RGBAlphaPixel*)rgbBuffer,numPixels, bIsSD);
1400  delete [] unPackedBuffer;
1401  }
1402  break;
1404  AJA_ConvertLinetoRGB((uint8_t *)buffer,rgbBuffer,numPixels,bIsSD);
1405  //AJA_ConvertLineto8BitYCbCr(unPackedBuffer,(uint8_t*)packedBuffer, numPixels);
1406  break;
1407 
1408 #if 0
1409 
1412  break;
1413 
1414 
1415  case AJA_PixelFormat_YUY28:
1416  AJA_ConvertLineto8BitYCbCr(unPackedBuffer,(uint8_t*)packedBuffer, numPixels);
1417  AJA_Convert8BitYCbCrToYUY2((uint8_t*)packedBuffer,numPixels);
1418  break;
1419 
1420  case AJA_PixelFormat_RGB10:
1421  AJA_ConvertLineto10BitRGB(unPackedBuffer,(AJA_RGBAlpha10BitPixel*)packedBuffer,numPixels, bIsSD);
1422  AJA_PackRGB10BitFor10BitRGB((AJA_RGBAlpha10BitPixel*)packedBuffer,numPixels);
1423  break;
1424 
1426  AJA_ConvertLineto10BitRGB(unPackedBuffer,(AJA_RGBAlpha10BitPixel*)packedBuffer,numPixels, bIsSD);
1428  break;
1429 
1431  AJA_ConvertLineto10BitRGB(unPackedBuffer,(AJA_RGBAlpha10BitPixel*)packedBuffer,numPixels, bIsSD);
1432  AJA_PackRGB10BitFor10BitDPX((AJA_RGBAlpha10BitPixel*)packedBuffer,numPixels);
1433  break;
1434 
1435  case AJA_PixelFormat_ARGB8:
1436  AJA_ConvertLinetoRGB(unPackedBuffer,(AJA_RGBAlphaPixel*)packedBuffer,numPixels, bIsSD);
1437  break;
1438 
1439  case AJA_PixelFormat_RGBA8:
1440  AJA_ConvertLinetoRGB(unPackedBuffer,(AJA_RGBAlphaPixel*)packedBuffer,numPixels, bIsSD);
1441  AJA_ConvertARGBToRGBA((uint8_t*)packedBuffer,numPixels);
1442  break;
1443 
1444  case AJA_PixelFormat_ABGR8:
1445  AJA_ConvertLinetoRGB(unPackedBuffer,(AJA_RGBAlphaPixel*)packedBuffer,numPixels, bIsSD);
1446  AJA_ConvertARGBToABGR((uint8_t*)packedBuffer,numPixels);
1447  break;
1448 
1449  case AJA_PixelFormat_RGB16:
1450  AJA_ConvertLineto16BitRGB(unPackedBuffer,(AJA_RGBAlpha16BitPixel*)packedBuffer,numPixels, bIsSD);
1451  AJA_Convert16BitARGBTo16BitRGB((AJA_RGBAlpha16BitPixel*)packedBuffer ,(uint16_t*) packedBuffer, numPixels);
1452  break;
1453 #endif
1454  default:
1455  // TO DO: add all other formats.
1456 
1457  break;
1458  }
1459 
1460 }
1461 
1462 // MaskUnPacked10BitYCbCrBuffer
1463 // Mask Data In place based on signalMask
1464 void AJA_MaskUnPacked10BitYCbCrBuffer( uint16_t* ycbcrUnPackedBuffer, uint16_t signalMask , uint32_t numPixels )
1465 {
1466  uint32_t pixelCount;
1467 
1468  // Not elegant but fairly fast.
1469  switch ( signalMask )
1470  {
1471  case AJA_SIGNALMASK_NONE: // Output Black
1472  for ( pixelCount = 0; pixelCount < (numPixels*2); pixelCount += 4 )
1473  {
1474  ycbcrUnPackedBuffer[pixelCount] = CCIR601_10BIT_CHROMAOFFSET; // Cb
1475  ycbcrUnPackedBuffer[pixelCount+1] = CCIR601_10BIT_BLACK; // Y
1476  ycbcrUnPackedBuffer[pixelCount+2] = CCIR601_10BIT_CHROMAOFFSET; // Cr
1477  ycbcrUnPackedBuffer[pixelCount+3] = CCIR601_10BIT_BLACK; // Y
1478  }
1479  break;
1480  case AJA_SIGNALMASK_Y:
1481  for ( pixelCount = 0; pixelCount < (numPixels*2); pixelCount += 4 )
1482  {
1483  ycbcrUnPackedBuffer[pixelCount] = CCIR601_10BIT_CHROMAOFFSET; // Cb
1484  ycbcrUnPackedBuffer[pixelCount+2] = CCIR601_10BIT_CHROMAOFFSET; // Cr
1485  }
1486 
1487  break;
1488  case AJA_SIGNALMASK_Cb:
1489  for ( pixelCount = 0; pixelCount < (numPixels*2); pixelCount += 4 )
1490  {
1491  ycbcrUnPackedBuffer[pixelCount+1] = CCIR601_10BIT_BLACK; // Y
1492  ycbcrUnPackedBuffer[pixelCount+2] = CCIR601_10BIT_CHROMAOFFSET; // Cr
1493  ycbcrUnPackedBuffer[pixelCount+3] = CCIR601_10BIT_BLACK; // Y
1494  }
1495 
1496  break;
1498  for ( pixelCount = 0; pixelCount < (numPixels*2); pixelCount += 4 )
1499  {
1500  ycbcrUnPackedBuffer[pixelCount+2] = CCIR601_10BIT_CHROMAOFFSET; // Cr
1501  }
1502 
1503  break;
1504 
1505  case AJA_SIGNALMASK_Cr:
1506  for ( pixelCount = 0; pixelCount < (numPixels*2); pixelCount += 4 )
1507  {
1508  ycbcrUnPackedBuffer[pixelCount] = CCIR601_10BIT_CHROMAOFFSET; // Cb
1509  ycbcrUnPackedBuffer[pixelCount+1] = CCIR601_10BIT_BLACK; // Y
1510  ycbcrUnPackedBuffer[pixelCount+3] = CCIR601_10BIT_BLACK; // Y
1511  }
1512 
1513 
1514  break;
1516  for ( pixelCount = 0; pixelCount < (numPixels*2); pixelCount += 4 )
1517  {
1518  ycbcrUnPackedBuffer[pixelCount] = CCIR601_10BIT_CHROMAOFFSET; // Cb
1519  }
1520 
1521 
1522  break;
1524  for ( pixelCount = 0; pixelCount < (numPixels*2); pixelCount += 4 )
1525  {
1526  ycbcrUnPackedBuffer[pixelCount+1] = CCIR601_10BIT_BLACK; // Y
1527  ycbcrUnPackedBuffer[pixelCount+3] = CCIR601_10BIT_BLACK; // Y
1528  }
1529 
1530 
1531  break;
1533  // Do nothing
1534  break;
1535  }
1536 
1537 }
1538 
1539 void WriteLineToBuffer(AJA_PixelFormat pixelFormat, uint32_t currentLine, uint32_t numPixels, uint32_t linePitch,
1540  uint8_t* pOutputBuffer,uint32_t* pPackedLineBuffer )
1541 {
1542  switch (pixelFormat)
1543  {
1545  {
1546  uint32_t bayerLinePitch = ((numPixels + 2)/3) * 4;
1547  uint8_t *pBuffer = pOutputBuffer + (currentLine * bayerLinePitch);
1548  AJA_Convert16BitRGBtoBayer10BitDPXLJ((AJA_RGBAlpha16BitPixel*)pPackedLineBuffer ,(uint32_t*)pBuffer, numPixels, currentLine);
1549  }
1550  break;
1552  {
1553  uint32_t bayerLinePitch = (linePitch/3);
1554  uint8_t *pBuffer = pOutputBuffer + (currentLine * bayerLinePitch);
1555  AJA_Convert16BitRGBtoBayer12BitDPXLJ((AJA_RGBAlpha16BitPixel*)pPackedLineBuffer ,(uint32_t*)pBuffer, numPixels, currentLine);
1556 
1557  }
1558  break;
1560  {
1561  uint32_t bayerLinePitch = ((numPixels + 2)/3) * 4;
1562  uint8_t *pBuffer = pOutputBuffer + (currentLine * bayerLinePitch);
1563  AJA_Convert16BitRGBtoBayer10BitDPXPacked((AJA_RGBAlpha16BitPixel*)pPackedLineBuffer ,(uint8_t*)pBuffer, numPixels, currentLine);
1564 
1565  }
1566  break;
1568  {
1569  uint32_t bayerLinePitch = linePitch/3;
1570  uint8_t *pBuffer = pOutputBuffer + (currentLine * bayerLinePitch);
1571  AJA_Convert16BitRGBtoBayer12BitDPXPacked((AJA_RGBAlpha16BitPixel*)pPackedLineBuffer ,(uint8_t*)pBuffer, numPixels, currentLine);
1572 
1573  }
1574  break;
1575  default:
1576  {
1577  uint8_t *pBuffer = pOutputBuffer + (currentLine * linePitch);
1578  memcpy(pBuffer, pPackedLineBuffer, linePitch);
1579 
1580  }
1581  break;
1582  }
1583 }
1584 
1585 
1586 void WriteLineToBuffer(AJA_PixelFormat pixelFormat, AJA_BayerColorPhase bayerPhase, uint32_t currentLine,
1587  uint32_t numPixels, uint32_t linePitch, uint8_t* pOutputBuffer, uint32_t* pPackedLineBuffer )
1588 {
1589  switch (pixelFormat)
1590  {
1592  {
1593  uint32_t bayerLinePitch = ((numPixels + 2)/3) * 4;
1594  uint8_t *pBuffer = pOutputBuffer + (currentLine * bayerLinePitch);
1595  AJA_Convert16BitRGBtoBayer10BitDPXLJ((AJA_RGBAlpha16BitPixel*)pPackedLineBuffer ,(uint32_t*)pBuffer, numPixels, currentLine, bayerPhase);
1596  }
1597  break;
1599  {
1600  uint32_t bayerLinePitch = (linePitch/3);
1601  uint8_t *pBuffer = pOutputBuffer + (currentLine * bayerLinePitch);
1602  AJA_Convert16BitRGBtoBayer12BitDPXLJ((AJA_RGBAlpha16BitPixel*)pPackedLineBuffer ,(uint32_t*)pBuffer, numPixels, currentLine, bayerPhase);
1603 
1604  }
1605  break;
1607  {
1608  uint32_t bayerLinePitch = ((numPixels + 2)/3) * 4;
1609  uint8_t *pBuffer = pOutputBuffer + (currentLine * bayerLinePitch);
1610  AJA_Convert16BitRGBtoBayer10BitDPXPacked((AJA_RGBAlpha16BitPixel*)pPackedLineBuffer ,(uint8_t*)pBuffer, numPixels, currentLine, bayerPhase);
1611 
1612  }
1613  break;
1615  {
1616  uint32_t bayerLinePitch = linePitch/4;
1617  uint8_t *pBuffer = pOutputBuffer + (currentLine * bayerLinePitch);
1618  AJA_Convert16BitRGBtoBayer12BitDPXPacked((AJA_RGBAlpha16BitPixel*)pPackedLineBuffer ,(uint8_t*)pBuffer, numPixels, currentLine, bayerPhase);
1619 
1620  }
1621  break;
1622  default:
1623  {
1624  uint8_t *pBuffer = pOutputBuffer + (currentLine * linePitch);
1625  memcpy(pBuffer, pPackedLineBuffer, linePitch);
1626 
1627  }
1628  break;
1629  }
1630 }
1631 
1632 // ReSampleLine
1633 // RGBAlphaPixel Version
1634 // NOTE: Input buffer needs to have extra sample at start and 2 at end.
1636  AJA_RGBAlphaPixel *Output,
1637  uint16_t startPixel,
1638  uint16_t endPixel,
1639  int32_t numInputPixels,
1640  int32_t numOutputPixels)
1641 
1642 {
1643  int32_t count,inputIndex,reSampleStartPixel,reSampleEndPixel;
1644  int32_t accum = 0;
1645  int32_t increment,coefIndex;
1646 
1647  Input[-1] = Input[0];
1648  Input[numInputPixels] = Input[numInputPixels+1] = Input[numInputPixels-1];
1649 
1650  increment = (numInputPixels<<16)/numOutputPixels;
1651  reSampleStartPixel = (startPixel*numOutputPixels)/numInputPixels;
1652  reSampleEndPixel = (endPixel*numOutputPixels)/numInputPixels;
1653  for ( count = reSampleStartPixel; count < reSampleEndPixel; count++ )
1654  {
1655  accum = (increment*count);
1656  inputIndex = FixedTrunc(accum);
1657  coefIndex = (accum>>11) & 0x1F;
1658  Output[count] = CubicInterPolate(&Input[inputIndex],coefIndex);
1659  }
1660 
1661 }
1662 
1663 
1664 // ReSampleLine
1665 // Word Version
1666 // NOTE: Input buffer needs to have extra sample at start and 2 at end.
1667 void AJA_ReSampleLine(int16_t *Input,
1668  int16_t *Output,
1669  uint16_t startPixel,
1670  uint16_t endPixel,
1671  int32_t numInputPixels,
1672  int32_t numOutputPixels)
1673 
1674 {
1675  int32_t count,inputIndex,reSampleStartPixel,reSampleEndPixel;
1676  int32_t accum = 0;
1677  int32_t increment,coefIndex;
1678 
1679  Input[-1] = Input[0];
1680  Input[numInputPixels] = Input[numInputPixels+1] = Input[numInputPixels-1];
1681 
1682  increment = (numInputPixels<<16)/numOutputPixels;
1683  reSampleStartPixel = (startPixel*numOutputPixels)/numInputPixels;
1684  reSampleEndPixel = (endPixel*numOutputPixels)/numInputPixels;
1685  for ( count = reSampleStartPixel; count < reSampleEndPixel; count++ )
1686  {
1687  accum = (increment*count);
1688  inputIndex = FixedTrunc(accum);
1689  coefIndex = (accum>>11) & 0x1F;
1690  Output[count] = (int16_t)CubicInterPolateWord((int16_t *)&Input[inputIndex],coefIndex);
1691  }
1692 }
1693 
1694 // ReSampleLine
1695 // Word Version
1696 void AJA_ReSampleYCbCrSampleLine(int16_t *Input,
1697  int16_t *Output,
1698  int32_t numInputPixels,
1699  int32_t numOutputPixels)
1700 
1701 {
1702  int32_t count,inputIndex,reSampleStartPixel,reSampleEndPixel;
1703  int32_t accum = 0;
1704  int32_t increment,coefIndex;
1705 
1706  int16_t* yBuffer = new int16_t[numInputPixels+4];
1707  int16_t* cbBuffer = new int16_t[numInputPixels/2+4];
1708  int16_t* crBuffer = new int16_t[numInputPixels/2+4];
1709 
1710  // First Extract Y
1711  for ( count = 0; count < numInputPixels; count++ )
1712  {
1713  if ( count & 0x1)
1714  {
1715  crBuffer[count/2+1] = Input[count*2];
1716  }
1717  else
1718  {
1719  cbBuffer[count/2+1] = Input[count*2];
1720 
1721  }
1722  yBuffer[count+1] = Input[count*2+1];
1723  }
1724 
1725  yBuffer[0] = yBuffer[1];
1726  yBuffer[numInputPixels+1] = yBuffer[numInputPixels+2] = yBuffer[numInputPixels];
1727 
1728  increment = (numInputPixels<<16)/numOutputPixels;
1729  reSampleStartPixel = 0;
1730  reSampleEndPixel = numOutputPixels;
1731  for ( count = reSampleStartPixel; count < reSampleEndPixel; count++ )
1732  {
1733  accum = (increment*count);
1734  inputIndex = FixedTrunc(accum);
1735  coefIndex = (accum>>11) & 0x1F;
1736  Output[count*2+1] = (int16_t)CubicInterPolateWord((int16_t *)&yBuffer[inputIndex+1],coefIndex);
1737  }
1738 
1739  reSampleStartPixel = 0;
1740  reSampleEndPixel = numOutputPixels/2;
1741  cbBuffer[0] = cbBuffer[1];
1742  cbBuffer[numInputPixels/2+1] = cbBuffer[numInputPixels/2+2] = cbBuffer[numInputPixels/2];
1743  crBuffer[0] = crBuffer[1];
1744  crBuffer[numInputPixels/2+1] = crBuffer[numInputPixels/2+2] = crBuffer[numInputPixels/2];
1745 
1746  for ( count = reSampleStartPixel; count < reSampleEndPixel; count++ )
1747  {
1748  accum = (increment*count);
1749  inputIndex = FixedTrunc(accum);
1750  coefIndex = (accum>>11) & 0x1F;
1751  Output[count*4] = (int16_t)CubicInterPolateWord((int16_t *)&cbBuffer[inputIndex+1],coefIndex);
1752  Output[count*4+2] = (int16_t)CubicInterPolateWord((int16_t *)&crBuffer[inputIndex+1],coefIndex);
1753  }
1754 
1755  delete [] yBuffer;
1756  delete [] cbBuffer;
1757  delete [] crBuffer;
1758 }
1759 
1760 void AJA_ReSampleAudio(int16_t *Input,
1761  int16_t *Output,
1762  uint16_t startPixel,
1763  uint16_t endPixel,
1764  int32_t numInputPixels,
1765  int32_t numOutputPixels,
1766  int16_t channelInterleaveMulitplier)
1767 {
1768  int32_t count,inputIndex,reSampleStartPixel,reSampleEndPixel;
1769  int32_t accum = 0;
1770  int32_t increment,coefIndex;
1771 
1772  increment = (numInputPixels<<16)/numOutputPixels;
1773  reSampleStartPixel = (startPixel*numOutputPixels)/numInputPixels;
1774  reSampleEndPixel = (endPixel*numOutputPixels)/numInputPixels;
1775  for ( count = reSampleStartPixel; count < reSampleEndPixel; count++ )
1776  {
1777  accum = (increment*count);
1778  inputIndex = FixedTrunc(accum);
1779  coefIndex = (accum>>11) & 0x1F;
1780  Output[count*channelInterleaveMulitplier] = (int16_t)CubicInterPolateAudioWord((int16_t *)&Input[inputIndex],coefIndex);
1781  }
1782 }
1783 
1785 {
1786 
1787  AJA_RGBAlphaPixel InterPolatedValue;
1788  int32_t temp;
1789 
1790 
1791  temp = FixedTrunc(Input[-1].Red*CubicCoef[32-Index] +
1792  Input[0].Red*CubicCoef[64-Index] +
1793  Input[1].Red*CubicCoef[96-Index] +
1794  Input[2].Red*CubicCoef[128-Index]);
1795 
1796  InterPolatedValue.Red = (uint8_t)((temp < 0 ) ? 0 : (temp > 255 ) ? 255 : temp);
1797 
1798  temp= FixedTrunc(Input[-1].Green*CubicCoef[32-Index] +
1799  Input[0].Green*CubicCoef[64-Index] +
1800  Input[1].Green*CubicCoef[96-Index] +
1801  Input[2].Green*CubicCoef[128-Index]);
1802  InterPolatedValue.Green = (uint8_t)((temp < 0 ) ? 0 : (temp > 255 ) ? 255 : temp);
1803 
1804 
1805  temp = FixedTrunc(Input[-1].Blue*CubicCoef[32-Index] +
1806  Input[0].Blue*CubicCoef[64-Index] +
1807  Input[1].Blue*CubicCoef[96-Index] +
1808  Input[2].Blue*CubicCoef[128-Index]);
1809 
1810  InterPolatedValue.Blue = (uint8_t)((temp < 0 ) ? 0 : (temp > 255 ) ? 255 : temp);
1811 
1812  temp = FixedTrunc(Input[-1].Alpha*CubicCoef[32-Index] +
1813  Input[0].Alpha*CubicCoef[64-Index] +
1814  Input[1].Alpha*CubicCoef[96-Index] +
1815  Input[2].Alpha*CubicCoef[128-Index]);
1816 
1817  InterPolatedValue.Alpha = (uint8_t)((temp < 0 ) ? 0 : (temp > 255 ) ? 255 : temp);
1818 
1819  return InterPolatedValue;
1820 
1821 }
1822 
1823 inline int16_t CubicInterPolateWord( int16_t *Input, int32_t Index)
1824 {
1825  int16_t InterPolatedValue;
1826 
1827  InterPolatedValue = FixedTrunc(Input[-1]*CubicCoef[32-Index] +
1828  Input[0]*CubicCoef[64-Index] +
1829  Input[1]*CubicCoef[96-Index] +
1830  Input[2]*CubicCoef[128-Index]);
1831 
1832  // return (Word)(InterPolatedValue&0x3FF);
1833  return (int16_t)ClipYCbCr_10BIT(InterPolatedValue);
1834 }
1835 
1836 inline int16_t CubicInterPolateAudioWord( int16_t *Input, int32_t Index)
1837 {
1838  int32_t InterPolatedValue;
1839 
1840  InterPolatedValue = FixedTrunc(Input[-1]*CubicCoef[32-Index] +
1841  Input[0]*CubicCoef[64-Index] +
1842  Input[1]*CubicCoef[96-Index] +
1843  Input[2]*CubicCoef[128-Index]);
1844 
1845  if ( InterPolatedValue > 32767 )
1846  InterPolatedValue = 32767;
1847  if ( InterPolatedValue < -32767 )
1848  InterPolatedValue = -32767;
1849 
1850  return (int16_t)(InterPolatedValue&0xFFFF);
1851 }
ClipYCbCr_10BIT
#define ClipYCbCr_10BIT(X)
Definition: videoutilities.h:57
AJA_YCbCr10BitPixel::y
uint16_t y
Definition: videoutilities.h:107
AJA_PixelFormat_YCBCR8_420PL2
@ AJA_PixelFormat_YCBCR8_420PL2
Definition: videotypes.h:167
AJA_PixelFormat_BAYER12_HS
@ AJA_PixelFormat_BAYER12_HS
Definition: videotypes.h:152
AJA_PixelFormat_BAYER10_HS
@ AJA_PixelFormat_BAYER10_HS
Definition: videotypes.h:151
AJA_HDConvertRGBAlphatoYCbCr
void AJA_HDConvertRGBAlphatoYCbCr(AJA_RGBAlphaPixel *pSource, AJA_YCbCr10BitPixel *pTarget)
Definition: videoutilities.h:312
AJA_PixelFormat_YCBCR10_422PL
@ AJA_PixelFormat_YCBCR10_422PL
Definition: videotypes.h:157
AJA_SIGNALMASK_Y
@ AJA_SIGNALMASK_Y
Definition: videoutilities.h:62
AJA_BayerColorPhase_GreenRed
@ AJA_BayerColorPhase_GreenRed
Definition: videotypes.h:203
AJA_PixelFormat_RAW10
@ AJA_PixelFormat_RAW10
Definition: videotypes.h:154
AJA_PixelFormat_ARGB8
@ AJA_PixelFormat_ARGB8
Definition: videotypes.h:126
_ENDIAN_SWAP32
#define _ENDIAN_SWAP32(_data_)
Definition: videoutilities.cpp:18
AJA_PixelFormat_YUY28
@ AJA_PixelFormat_YUY28
Definition: videotypes.h:129
AJA_PixelFormat_YCBCR8_422PL3
@ AJA_PixelFormat_YCBCR8_422PL3
Definition: videotypes.h:162
AJA_MakeUnPacked8BitYCbCrBuffer
void AJA_MakeUnPacked8BitYCbCrBuffer(uint8_t *buffer, uint8_t Y, uint8_t Cb, uint8_t Cr, uint32_t numPixels)
Definition: videoutilities.cpp:418
AJA_SIGNALMASK_Cb
@ AJA_SIGNALMASK_Cb
Definition: videoutilities.h:63
AJA_PackTo10BitYCbCrDPXBuffer
void AJA_PackTo10BitYCbCrDPXBuffer(uint16_t *ycbcrBuffer, uint32_t *packedBuffer, uint32_t numPixels, bool bigEndian)
Definition: videoutilities.cpp:291
AJA_SDConvertRGBAlphatoYCbCr
void AJA_SDConvertRGBAlphatoYCbCr(AJA_RGBAlphaPixel *pSource, AJA_YCbCr10BitPixel *pTarget)
Definition: videoutilities.h:290
AJA_MakeUnPacked10BitYCbCrBuffer
void AJA_MakeUnPacked10BitYCbCrBuffer(uint16_t *buffer, uint16_t Y, uint16_t Cb, uint16_t Cr, uint32_t numPixels)
Definition: videoutilities.cpp:406
videoutilities.h
Declares the ajabase library's video utility functions.
AJA_ConvertRGBAlphatoYCbCr
void(* AJA_ConvertRGBAlphatoYCbCr)(AJA_RGBAlphaPixel *pSource, AJA_YCbCr10BitPixel *pTarget)
Definition: videoutilities.h:288
AJA_PackRGB10BitFor10BitRGB
void AJA_PackRGB10BitFor10BitRGB(AJA_RGBAlpha10BitPixel *rgba10BitBuffer, uint32_t numPixels)
Definition: videoutilities.cpp:315
AJA_PixelFormat_BGR8_PACK
@ AJA_PixelFormat_BGR8_PACK
Definition: videotypes.h:137
AJA_PixelFormat_YCbCr8
@ AJA_PixelFormat_YCbCr8
Definition: videotypes.h:125
AJA_PackRGB10BitFor10BitRGBPacked
void AJA_PackRGB10BitFor10BitRGBPacked(AJA_RGBAlpha10BitPixel *rgba10BitBuffer, uint32_t numPixels)
Definition: videoutilities.cpp:328
CubicInterPolateWord
int16_t CubicInterPolateWord(int16_t *Input, int32_t Index)
Definition: videoutilities.cpp:1823
AJA_PixelFormat_RGB10
@ AJA_PixelFormat_RGB10
Definition: videotypes.h:128
AJA_RGBAlpha10BitPixel::Green
uint16_t Green
Definition: videoutilities.h:84
AJA_PixelFormat_BAYER10_DPX_LJ
@ AJA_PixelFormat_BAYER10_DPX_LJ
Definition: videotypes.h:149
AJA_Convert16BitARGBTo12BitRGBPacked
void AJA_Convert16BitARGBTo12BitRGBPacked(AJA_RGBAlpha16BitPixel *rgbaLineBuffer, uint8_t *rgbLineBuffer, uint32_t numPixels)
Definition: videoutilities.cpp:1224
AJA_RGBAlpha10BitPixel
Definition: videoutilities.h:82
AJA_PixelFormat_YCBCR8_422PL
@ AJA_PixelFormat_YCBCR8_422PL
Definition: videotypes.h:159
AJA_BayerColorPhase_BlueGreen
@ AJA_BayerColorPhase_BlueGreen
Definition: videotypes.h:204
AJA_ReSampleYCbCrSampleLine
void AJA_ReSampleYCbCrSampleLine(int16_t *Input, int16_t *Output, int32_t numInputPixels, int32_t numOutputPixels)
Definition: videoutilities.cpp:1696
AJA_SDConvert10BitYCbCrto10BitRGB
void AJA_SDConvert10BitYCbCrto10BitRGB(AJA_YCbCr10BitAlphaPixel *pSource, AJA_RGBAlpha10BitPixel *pTarget)
Definition: videoutilities.h:180
AJA_ConvertPixelFormatToRGBA
void AJA_ConvertPixelFormatToRGBA(uint32_t *buffer, AJA_RGBAlphaPixel *rgbBuffer, uint32_t numPixels, AJA_PixelFormat pixelFormat, bool bIsSD)
Definition: videoutilities.cpp:1390
AJA_ConvertLinetoRGB
void AJA_ConvertLinetoRGB(uint8_t *ycbcrBuffer, AJA_RGBAlphaPixel *rgbaBuffer, uint32_t numPixels, bool fUseSDMatrix)
Definition: videoutilities.cpp:578
AJA_ConvertUnpacked10BitYCbCrToPixelFormat
void AJA_ConvertUnpacked10BitYCbCrToPixelFormat(uint16_t *unPackedBuffer, uint32_t *packedBuffer, uint32_t numPixels, AJA_PixelFormat pixelFormat)
Definition: videoutilities.cpp:1288
AJA_YCbCr10BitAlphaPixel::cr
uint16_t cr
Definition: videoutilities.h:101
AJA_UNUSED
#define AJA_UNUSED(_x_)
Definition: types.h:424
CubicInterPolateAudioWord
int16_t CubicInterPolateAudioWord(int16_t *Input, int32_t Index)
Definition: videoutilities.cpp:1836
AJA_HDConvertRGBAlpha10toYCbCr
void AJA_HDConvertRGBAlpha10toYCbCr(AJA_RGBAlpha10BitPixel *pSource, AJA_YCbCr10BitPixel *pTarget, bool rgbFullRange)
Definition: videoutilities.h:334
AJA_RGBAlphaPixel::Blue
uint8_t Blue
Definition: videoutilities.h:69
AJA_PixelFormat_YCBCR8_420PL3
@ AJA_PixelFormat_YCBCR8_420PL3
Definition: videotypes.h:161
AJA_Convert8BitYCbCrToYUY2
void AJA_Convert8BitYCbCrToYUY2(uint8_t *ycbcrBuffer, uint32_t numPixels)
Definition: videoutilities.cpp:1253
CCIR601_10BIT_WHITE
#define CCIR601_10BIT_WHITE
Definition: videoutilities.h:19
AJA_YCbCr10BitAlphaPixel
Definition: videoutilities.h:96
AJA_YCbCr10BitPixel
Definition: videoutilities.h:104
AJA_ConvertRGBAlpha10LineToYCbCr422
void AJA_ConvertRGBAlpha10LineToYCbCr422(AJA_RGBAlpha10BitPixel *RGBLine, uint16_t *YCbCrLine, int32_t numPixels, int32_t startPixel, bool fUseRGBFullRange)
Definition: videoutilities.cpp:483
AJA_RGBAlphaPixel::Alpha
uint8_t Alpha
Definition: videoutilities.h:72
AJA_PixelFormat_YCBCR8_422PL2
@ AJA_PixelFormat_YCBCR8_422PL2
Definition: videotypes.h:168
AJA_RGBAlphaPixel
Definition: videoutilities.h:68
AJA_PixelFormat_YCBCR10_420PL2LE
@ AJA_PixelFormat_YCBCR10_420PL2LE
FFmpeg related (see AVPixelFormat in libavutil/pixfmt.h, libavutil/pixdesc.c) - unpacked 16bpp,...
Definition: videotypes.h:171
AJA_PixelFormat_RGB_DPX_LE
@ AJA_PixelFormat_RGB_DPX_LE
Definition: videotypes.h:139
AJA_PixelFormat_YCbCr_DPX
@ AJA_PixelFormat_YCbCr_DPX
Definition: videotypes.h:132
AJA_PixelFormat_RGB16
@ AJA_PixelFormat_RGB16
Definition: videotypes.h:147
WriteLineToBuffer
void WriteLineToBuffer(AJA_PixelFormat pixelFormat, uint32_t currentLine, uint32_t numPixels, uint32_t linePitch, uint8_t *pOutputBuffer, uint32_t *pPackedLineBuffer)
Definition: videoutilities.cpp:1539
AJA_YCbCr10BitPixel::cb
uint16_t cb
Definition: videoutilities.h:106
AJA_PixelFormat_RGB8_PACK
@ AJA_PixelFormat_RGB8_PACK
Definition: videotypes.h:136
AJA_RGBAlphaPixel::Green
uint8_t Green
Definition: videoutilities.h:70
AJA_RGBAlpha16BitPixel
Definition: videoutilities.h:89
AJA_SDConvert10BitYCbCrtoRGB
void AJA_SDConvert10BitYCbCrtoRGB(AJA_YCbCr10BitAlphaPixel *pSource, AJA_RGBAlphaPixel *pTarget)
Definition: videoutilities.h:234
AJA_BayerColorPhase_RedGreen
@ AJA_BayerColorPhase_RedGreen
Definition: videotypes.h:202
AJA_ConvertLineto10BitRGB
void AJA_ConvertLineto10BitRGB(uint16_t *ycbcrBuffer, AJA_RGBAlpha10BitPixel *rgbaBuffer, uint32_t numPixels, bool fUseSDMatrix)
Definition: videoutilities.cpp:520
AJA_BayerColorPhase_GreenBlue
@ AJA_BayerColorPhase_GreenBlue
Definition: videotypes.h:205
AJA_PixelFormat_YCBCR10_420PL
@ AJA_PixelFormat_YCBCR10_420PL
Definition: videotypes.h:156
AJA_Convert16BitRGBtoBayer10BitDPXPacked
void AJA_Convert16BitRGBtoBayer10BitDPXPacked(AJA_RGBAlpha16BitPixel *rgbaBuffer, uint8_t *bayerBuffer, uint32_t numPixels, uint32_t line, AJA_BayerColorPhase phase)
Definition: videoutilities.cpp:938
AJA_Convert16BitRGBtoBayer12BitDPXPacked
void AJA_Convert16BitRGBtoBayer12BitDPXPacked(AJA_RGBAlpha16BitPixel *rgbaBuffer, uint8_t *bayerBuffer, uint32_t numPixels, uint32_t line, AJA_BayerColorPhase phase)
Definition: videoutilities.cpp:1062
AJA_RGBAlpha16BitPixel::Green
uint16_t Green
Definition: videoutilities.h:91
CubicInterPolate
AJA_RGBAlphaPixel CubicInterPolate(AJA_RGBAlphaPixel *Input, int32_t Index)
Definition: videoutilities.cpp:1784
AJA_PixelFormat_RGBA8
@ AJA_PixelFormat_RGBA8
Definition: videotypes.h:127
AJA_YCbCr10BitAlphaPixel::Alpha
uint16_t Alpha
Definition: videoutilities.h:98
AJA_PixelFormat_YCBCR10_422PL3LE
@ AJA_PixelFormat_YCBCR10_422PL3LE
Definition: videotypes.h:164
AJA_HDConvert10BitYCbCrto10BitRGB
void AJA_HDConvert10BitYCbCrto10BitRGB(AJA_YCbCr10BitAlphaPixel *pSource, AJA_RGBAlpha10BitPixel *pTarget)
Definition: videoutilities.h:207
AJA_PixelFormat_BAYER12_DPX_LJ
@ AJA_PixelFormat_BAYER12_DPX_LJ
Definition: videotypes.h:150
AJA_PixelFormat_YCBCR10_420PL3LE
@ AJA_PixelFormat_YCBCR10_420PL3LE
Definition: videotypes.h:163
createVideoFrame
void createVideoFrame(uint32_t *buffer, uint64_t frameNumber, AJA_PixelFormat pixFmt, uint32_t lines, uint32_t pixels, uint32_t linepitch, uint16_t y, uint16_t cb, uint16_t cr)
Definition: videoutilities.cpp:158
AJA_ConvertARGBToBGR
static void AJA_ConvertARGBToBGR(uint8_t *rgbaBuffer, uint8_t *rgbBuffer, uint32_t numPixels)
Definition: videoutilities.cpp:1197
AJA_ConvertARGBToRGB
static void AJA_ConvertARGBToRGB(uint8_t *rgbaBuffer, uint8_t *rgbBuffer, uint32_t numPixels)
Definition: videoutilities.cpp:1183
AJA_PixelFormat_RGB10_PACK
@ AJA_PixelFormat_RGB10_PACK
Definition: videotypes.h:144
AJA_PixelFormat_RGB_DPX
@ AJA_PixelFormat_RGB_DPX
Definition: videotypes.h:131
AJA_MaskUnPacked10BitYCbCrBuffer
void AJA_MaskUnPacked10BitYCbCrBuffer(uint16_t *ycbcrUnPackedBuffer, uint16_t signalMask, uint32_t numPixels)
Definition: videoutilities.cpp:1464
AJA_ConvertARGBToABGR
void AJA_ConvertARGBToABGR(uint8_t *rgbaBuffer, uint32_t numPixels)
Definition: videoutilities.cpp:1167
AJA_PixelFormat_RGB12
@ AJA_PixelFormat_RGB12
Definition: videotypes.h:140
CCIR601_10BIT_BLACK
#define CCIR601_10BIT_BLACK
Definition: videoutilities.h:18
AJA_Convert16BitRGBtoBayer12BitDPXLJ
void AJA_Convert16BitRGBtoBayer12BitDPXLJ(AJA_RGBAlpha16BitPixel *rgbaBuffer, uint32_t *bayerBuffer, uint32_t numPixels, uint32_t line, AJA_BayerColorPhase phase)
Definition: videoutilities.cpp:863
AJA_UnPack10BitDPXtoRGBAlpha10BitPixel
void AJA_UnPack10BitDPXtoRGBAlpha10BitPixel(AJA_RGBAlpha10BitPixel *rgba10BitBuffer, uint32_t *DPXLinebuffer, uint32_t numPixels, bool bigEndian)
Definition: videoutilities.cpp:361
AJA_SIGNALMASK_NONE
@ AJA_SIGNALMASK_NONE
Definition: videoutilities.h:61
AJA_YCbCr10BitAlphaPixel::cb
uint16_t cb
Definition: videoutilities.h:99
FixedTrunc
int FixedTrunc(int inFix)
Definition: videoutilities.cpp:13
AJA_RGBAlpha16BitPixel::Red
uint16_t Red
Definition: videoutilities.h:92
CubicCoef
uint32_t CubicCoef[129]
Definition: videoutilities.cpp:24
AJA_ConvertLineto8BitYCbCr
void AJA_ConvertLineto8BitYCbCr(uint16_t *ycbcr10BitBuffer, uint8_t *ycbcr8BitBuffer, uint32_t numPixels)
Definition: videoutilities.cpp:432
AJA_ReSampleAudio
void AJA_ReSampleAudio(int16_t *Input, int16_t *Output, uint16_t startPixel, uint16_t endPixel, int32_t numInputPixels, int32_t numOutputPixels, int16_t channelInterleaveMulitplier)
Definition: videoutilities.cpp:1760
AJA_SIGNALMASK_Cr
@ AJA_SIGNALMASK_Cr
Definition: videoutilities.h:64
AJA_RGBAlpha10BitPixel::Blue
uint16_t Blue
Definition: videoutilities.h:83
AJA_Convert16BitARGBTo16BitRGB
void AJA_Convert16BitARGBTo16BitRGB(AJA_RGBAlpha16BitPixel *rgbaLineBuffer, uint16_t *rgbLineBuffer, uint32_t numPixels)
Definition: videoutilities.cpp:1210
common.h
Private include file for all ajabase sources.
AJA_PixelFormat_ABGR8
@ AJA_PixelFormat_ABGR8
Definition: videotypes.h:130
AJA_UnPack10BitDPXtoRGBAlphaBitPixel
void AJA_UnPack10BitDPXtoRGBAlphaBitPixel(uint8_t *rgbaBuffer, uint32_t *DPXLinebuffer, uint32_t numPixels, bool bigEndian)
Definition: videoutilities.cpp:381
AJA_CalcRowBytesForFormat
uint32_t AJA_CalcRowBytesForFormat(AJA_PixelFormat format, uint32_t width)
Definition: videoutilities.cpp:174
AJA_ConvertARGBToRGBA
void AJA_ConvertARGBToRGBA(uint8_t *rgbaBuffer, uint32_t numPixels)
Definition: videoutilities.cpp:1151
AJA_PixelFormat_YCbCr10
@ AJA_PixelFormat_YCbCr10
Definition: videotypes.h:124
AJA_ReSampleLine
void AJA_ReSampleLine(AJA_RGBAlphaPixel *Input, AJA_RGBAlphaPixel *Output, uint16_t startPixel, uint16_t endPixel, int32_t numInputPixels, int32_t numOutputPixels)
Definition: videoutilities.cpp:1635
AJA_ConvertLineto16BitRGB
void AJA_ConvertLineto16BitRGB(uint16_t *ycbcrBuffer, AJA_RGBAlpha16BitPixel *rgbaBuffer, uint32_t numPixels, bool fUseSDMatrix)
Definition: videoutilities.cpp:700
CCIR601_10BIT_CHROMAOFFSET
#define CCIR601_10BIT_CHROMAOFFSET
Definition: videoutilities.h:20
AJA_PackTo10BitYCbCrBuffer
void AJA_PackTo10BitYCbCrBuffer(uint16_t *ycbcrBuffer, uint32_t *packedBuffer, uint32_t numPixels)
Definition: videoutilities.cpp:276
AJA_YCbCr10BitPixel::cr
uint16_t cr
Definition: videoutilities.h:108
AJA_UnPack10BitYCbCrBuffer
void AJA_UnPack10BitYCbCrBuffer(uint32_t *packedBuffer, uint16_t *ycbcrBuffer, uint32_t numPixels)
Definition: videoutilities.cpp:262
AJA_ENDIAN_SWAP32
#define AJA_ENDIAN_SWAP32(_data_)
Definition: types.h:435
AJA_ConvertLineToYCbCr422
void AJA_ConvertLineToYCbCr422(AJA_RGBAlphaPixel *RGBLine, uint16_t *YCbCrLine, int32_t numPixels, int32_t startPixel, bool fUseSDMatrix)
Definition: videoutilities.cpp:443
AJA_Convert16BitRGBtoBayer10BitDPXLJ
void AJA_Convert16BitRGBtoBayer10BitDPXLJ(AJA_RGBAlpha16BitPixel *rgbaBuffer, uint32_t *bayerBuffer, uint32_t numPixels, uint32_t line, AJA_BayerColorPhase phase)
Definition: videoutilities.cpp:771
AJA_PixelFormat
AJA_PixelFormat
Definition: videotypes.h:121
AJA_RGBAlphaPixel::Red
uint8_t Red
Definition: videoutilities.h:71
AJA_BayerColorPhase
AJA_BayerColorPhase
Definition: videotypes.h:199
AJA_HDConvert10BitYCbCrtoRGB
void AJA_HDConvert10BitYCbCrtoRGB(AJA_YCbCr10BitAlphaPixel *pSource, AJA_RGBAlphaPixel *pTarget)
Definition: videoutilities.h:261
AJA_YCbCr10BitAlphaPixel::y
uint16_t y
Definition: videoutilities.h:100
AJA_PixelFormat_RAW10_HS
@ AJA_PixelFormat_RAW10_HS
Definition: videotypes.h:155
AJA_PixelFormat_YCBCR10_422PL2LE
@ AJA_PixelFormat_YCBCR10_422PL2LE
Definition: videotypes.h:172
AJA_RePackLineDataForYCbCrDPX
void AJA_RePackLineDataForYCbCrDPX(uint32_t *packedycbcrLine, uint32_t numULWords)
Definition: videoutilities.cpp:1269
AJA_PixelFormat_YCBCR8_420PL
@ AJA_PixelFormat_YCBCR8_420PL
Definition: videotypes.h:158
AJA_RGBAlpha16BitPixel::Blue
uint16_t Blue
Definition: videoutilities.h:90
AJA_PackRGB10BitFor10BitDPX
void AJA_PackRGB10BitFor10BitDPX(AJA_RGBAlpha10BitPixel *rgba10BitBuffer, uint32_t numPixels, bool bigEndian)
Definition: videoutilities.cpp:344
AJA_RGBAlpha10BitPixel::Red
uint16_t Red
Definition: videoutilities.h:85