1 /* ------------------------------------------------------------------
2 * Copyright (C) 1998-2009 PacketVideo
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13 * express or implied.
14 * See the License for the specific language governing permissions
15 * and limitations under the License.
16 * -------------------------------------------------------------------
17 */
18 /** Class ColorConvert16, convert YUV to RGB16 in 5-6-5 format. */
19 #include "colorconv_config.h"
20 #include "cczoomrotation16.h"
21
22 #define pvcc_abs(x) ((x)>0? (x): -(x))
23
24 #define DITHER_ON
25 #ifdef DITHER_ON
26
27 #define OFFSET_5_0 2
28 #define OFFSET_6_0 (1+1024)
29 #define OFFSET_5_1 6
30 #define OFFSET_6_1 (3+1024)
31
32 #else //for the rounding case (no dither)
33
34 #define OFFSET_5_0 0 // Set to zero for performance4
35 #define OFFSET_6_0 (0+1024) //(2+1024)
36 #define OFFSET_5_1 0 //4
37 #define OFFSET_6_1 (0+1024) //(2+1024)
38
39 #endif
40
NewL(void)41 OSCL_EXPORT_REF ColorConvertBase* ColorConvert16::NewL(void)
42 {
43 ColorConvert16* self = OSCL_NEW(ColorConvert16, ());
44 return OSCL_STATIC_CAST(ColorConvertBase*, self);
45 }
46
47
ColorConvert16()48 ColorConvert16::ColorConvert16()
49 {
50 mCoefTbl = (uint8*)mCoefTbl32;
51 }
52
53
~ColorConvert16()54 OSCL_EXPORT_REF ColorConvert16::~ColorConvert16()
55 {
56 }
57
58
Init(int32 Src_width,int32 Src_height,int32 Src_pitch,int32 Dst_width,int32 Dst_height,int32 Dst_pitch,int32 nRotation)59 int32 ColorConvert16::Init(int32 Src_width, int32 Src_height, int32 Src_pitch, int32 Dst_width, int32 Dst_height, int32 Dst_pitch, int32 nRotation)
60 {
61 //nRotation = 1;
62 //Dst_pitch = Dst_width = Src_height;
63 //Dst_height = Src_width;
64
65 if (ColorConvertBase::Init(Src_width, Src_height, Src_pitch, Dst_width, Dst_height, Dst_pitch, nRotation) == 0)
66 {
67 return 0;
68 }
69
70 _mInitialized = false;
71
72 if ((nRotation&1) == 0) // check for either shrinking or zooming both horz and vert. No combination..
73 {
74 if ((Src_width > Dst_width && Src_height < Dst_height) ||
75 (Src_width < Dst_width && Src_height > Dst_height))
76 {
77 return 0;
78 }
79 }
80 else
81 {
82 if ((Src_width > Dst_height && Src_height < Dst_width) ||
83 (Src_width < Dst_height && Src_height > Dst_width))
84 {
85 return 0;
86 }
87 }
88
89 _mInitialized = true;
90
91 // set default
92 SetYuvFullRange(false);
93 SetMode(0);
94
95 return 1;
96 }
97
98
SetYuvFullRange(bool range)99 int32 ColorConvert16::SetYuvFullRange(bool range)
100 {
101 uint8 *clip;
102 int32 tmp, i;
103
104 OSCL_ASSERT(_mInitialized == true);
105
106 _mYuvRange = range;
107
108 //local init
109 if (_mYuvRange == false) // default Yuv range from 16-235, BT.709
110 {
111 *((uint32*)mCoefTbl) = 0x0000b2ce; //65536*0.813/1.164; // 0.533
112 *((uint32*)(mCoefTbl + 4)) = 0x00015f03; //65536*1.596/1.164; // 1.793
113 *((uint32*)(mCoefTbl + 8)) = 0x000055fe; //65536*0.391/1.164; // 0.213
114 *((uint32*)(mCoefTbl + 12)) = 0x0001bbd2; //65536*2.018/1.164; // 2.112
115
116 clip = mCoefTbl + 400;
117 /* do 5 bit conversion */
118
119 oscl_memset(&clip[-384], 0, 401*sizeof(*clip));
120 oscl_memset(&clip[ 640], 0, 401*sizeof(*clip));
121
122 for (i = 17; i < 236; i++)
123 { // range of (x>>3) between -24 and 56
124 tmp = (int32)(1.164 * (i - 16)); // clip[1.164*((x>>3) - (16>>3))]
125 clip[i] = (uint8)(tmp >> 3);
126 clip[i+1024] = (uint8)(tmp >> 2);
127 }
128
129 oscl_memset(&clip[236], 31, 404*sizeof(*clip));
130 oscl_memset(&clip[1260], 63, 404*sizeof(*clip));
131
132 }
133 else // full range 0-255
134 {
135 *((uint32*)mCoefTbl) = (int)(65536 * 0.4681); //0.714);
136 *((uint32*)(mCoefTbl + 4)) = (int)(65536 * 1.5748);//1.402);
137 *((uint32*)(mCoefTbl + 8)) = (int)(65536 * 0.1873);//0.344);
138 *((uint32*)(mCoefTbl + 12)) = (int)(65536 * 1.8556);//1.772);
139
140 clip = mCoefTbl + 400;
141 /* do 5 bit conversion */
142 oscl_memset(&clip[-384], 0, 385*sizeof(*clip));
143 oscl_memset(&clip[ 640], 0, 385*sizeof(*clip));
144
145 for (i = 1; i < 255; i++) // range of (x>>3) between -24 and 56
146 {
147 clip[i] = i >> 3;
148 clip[i+1024] = i >> 2;
149 }
150 oscl_memset(&clip[255], 31, 385*sizeof(*clip));
151 oscl_memset(&clip[1279], 63, 385*sizeof(*clip));
152 }
153
154 return 1; // success
155 }
156
157
SetMode(int32 nMode)158 int32 ColorConvert16::SetMode(int32 nMode) //nMode : 0 Off, 1 On
159 {
160 OSCL_ASSERT(_mInitialized == true);
161
162 if (nMode == 0)
163 {
164 // mPtrYUV2RGB = cc16Rotate;
165 // _mState = 1;
166 mPtrYUV2RGB = &ColorConvert16::get_frame16;
167 _mState = 0;
168 _mDisp.src_pitch = _mSrc_pitch ;
169 _mDisp.dst_pitch = _mDst_pitch ;
170 _mDisp.src_width = _mSrc_width ;
171 _mDisp.src_height = _mSrc_height ;
172 _mDisp.dst_width = _mSrc_width ;
173 _mDisp.dst_height = _mSrc_height ;
174 }
175 else
176 {
177 if (_mIsZoom)
178 {
179 if (_mRotation&0x1) /* zoom and rotate */
180 {
181 mPtrYUV2RGB = &ColorConvert16::cc16ZoomRotate;
182 }
183 else /* zoom only */
184 {
185 mPtrYUV2RGB = &ColorConvert16::cc16ZoomIn;
186 }
187 }
188 else
189 {
190 if (_mRotation&0x1) /* rotate only*/
191 {
192 mPtrYUV2RGB = &ColorConvert16::cc16Rotate;
193 }
194 else /* no zoom, no rotate, SetMode(1) = SetMode(0) */
195 {
196 mPtrYUV2RGB = &ColorConvert16::get_frame16;
197 }
198 }
199 _mState = nMode;
200 _mDisp.src_pitch = _mSrc_pitch ;
201 _mDisp.dst_pitch = _mDst_pitch ;
202 _mDisp.src_width = _mSrc_width ;
203 _mDisp.src_height = _mSrc_height ;
204 _mDisp.dst_width = _mDst_width ;
205 _mDisp.dst_height = _mDst_height ;
206 }
207
208 return 1;
209 }
210
211
GetOutputBufferSize(void)212 int32 ColorConvert16::GetOutputBufferSize(void)
213 {
214 OSCL_ASSERT(_mInitialized == true);
215
216 return _mState ? (_mDst_height*_mDst_pitch*2) : (_mSrc_width*_mSrc_height*2);
217 }
218
219
Convert(uint8 ** yuvBuf,uint8 * rgbBuf)220 int32 ColorConvert16::Convert(uint8 **yuvBuf, uint8 *rgbBuf)
221 {
222 OSCL_ASSERT(_mInitialized == true);
223 OSCL_ASSERT(yuvBuf);
224 OSCL_ASSERT(yuvBuf[0]);
225 OSCL_ASSERT(yuvBuf[1]);
226 OSCL_ASSERT(yuvBuf[2]);
227 OSCL_ASSERT(rgbBuf);
228
229 if (((uint32)rgbBuf)&0x3 || ((uint32)yuvBuf[0])&0x3) /* address is not word align */
230 {
231 return 0;
232 }
233
234 (*this.*mPtrYUV2RGB)(yuvBuf, rgbBuf, &_mDisp, (uint8 *)mCoefTbl);
235
236 return 1;
237 }
238
239
Convert(uint8 * yuvBuf,uint8 * rgbBuf)240 int32 ColorConvert16::Convert(uint8 *yuvBuf, uint8 *rgbBuf)
241 {
242 //this conversion will cause problems when do src clipping. However, if they want, they must give more info
243 uint8 *TmpYuvBuf[3];
244
245 OSCL_ASSERT(_mInitialized == true);
246 OSCL_ASSERT(yuvBuf);
247 OSCL_ASSERT(rgbBuf);
248
249 if (((uint32)rgbBuf)&0x3 || ((uint32)yuvBuf)&0x3) /* address is not word align */
250 {
251 return 0;
252 }
253
254 TmpYuvBuf[0] = yuvBuf;
255 TmpYuvBuf[1] = yuvBuf + (_mSrc_pitch) * (_mSrc_mheight);
256 TmpYuvBuf[2] = TmpYuvBuf[1] + (_mSrc_pitch * _mSrc_mheight) / 4;
257
258 (*this.*mPtrYUV2RGB)(TmpYuvBuf, rgbBuf, &_mDisp, (uint8 *)mCoefTbl);
259
260 return 1;
261 }
262
263
264 int32 cc16(uint8 **src, uint8 *dst, int32 *disp_prop, uint8 *coeff_tbl);
265 int32 cc16Reverse(uint8 **src, uint8 *dst, int32 *disp_prop, uint8 *coeff_tbl);
266
get_frame16(uint8 ** src,uint8 * dst,DisplayProperties * disp,uint8 * coff_tbl)267 int32 ColorConvert16::get_frame16(uint8 **src, uint8 *dst, DisplayProperties *disp, uint8 *coff_tbl)
268 {
269 int32 disp_prop[8];
270
271 disp_prop[0] = disp->src_pitch;
272 disp_prop[1] = disp->dst_pitch;
273 disp_prop[2] = disp->src_width;
274 disp_prop[3] = disp->src_height;
275 disp_prop[4] = disp->dst_width;
276 disp_prop[5] = disp->dst_height;
277 disp_prop[6] = (_mRotation > 0 ? 1 : 0);
278 disp_prop[7] = _mIsFlip;
279
280 if (disp_prop[6] ^ disp_prop[7]) /* flip and rotate 180*/
281 {
282 return cc16Reverse(src, dst, disp_prop, coff_tbl);
283 }
284 else
285 {
286 return cc16(src, dst, disp_prop, coff_tbl);
287 }
288 }
289
cc16(uint8 ** src,uint8 * dst,int32 * disp,uint8 * coff_tbl)290 int32 cc16(uint8 **src, uint8 *dst, int32 *disp, uint8 *coff_tbl)
291 {
292
293 uint8 *pCb, *pCr;
294 uint16 *pY;
295 uint16 *pDst;
296 int32 src_pitch, dst_pitch, src_width;
297 int32 Y, Cb, Cr, Cg;
298 int32 deltaY, deltaDst, deltaCbCr;
299 int32 row, col;
300 int32 tmp0, tmp1, tmp2;
301 uint32 rgb;
302 uint8 *clip = coff_tbl + 400;
303 int32 cc1 = (*((int32*)(clip - 400)));
304 int32 cc3 = (*((int32*)(clip - 396)));
305 int32 cc2 = (*((int32*)(clip - 392)));
306 int32 cc4 = (*((int32*)(clip - 388)));
307
308 src_pitch = disp[0];
309 dst_pitch = disp[1];
310 src_width = disp[2];
311
312 if (disp[6]) /* rotate 180 and flip */
313 { /* move the starting point to the bottom-left corner of the picture */
314 deltaY = src_pitch * (disp[3] - 1);
315 pY = (uint16*)(src[0] + deltaY);
316 deltaY = (src_pitch >> 1) * ((disp[3] >> 1) - 1);
317 pCb = src[1] + deltaY;
318 pCr = src[2] + deltaY;
319 deltaY = -src_width - (src_pitch << 1);
320 deltaCbCr = -((src_width + src_pitch) >> 1);
321 src_pitch = -(src_pitch >> 1);
322 }
323 else
324 {
325 deltaY = (src_pitch << 1) - src_width;
326 deltaCbCr = (src_pitch - src_width) >> 1;
327 pY = (uint16 *) src[0];
328 src_pitch >>= 1;
329 pCb = src[1];
330 pCr = src[2];
331 }
332
333 deltaDst = (dst_pitch << 1) - src_width;
334 pDst = (uint16 *)dst;
335
336 for (row = disp[3]; row > 0; row -= 2)
337 {
338
339 for (col = src_width - 1; col >= 0; col -= 2)
340 {
341
342 Cb = *pCb++;
343 Cr = *pCr++;
344 Y = pY[src_pitch];
345
346 Cb -= 128;
347 Cr -= 128;
348 Cg = Cr * cc1;
349 Cr *= cc3;
350
351 Cg += Cb * cc2;
352 Cb *= cc4;
353
354 tmp0 = (Y & 0xFF); //Low endian left pixel
355 tmp0 += OFFSET_5_0;
356
357 tmp1 = tmp0 - (Cg >> 16);
358 tmp2 = tmp0 + (Cb >> 16);
359 tmp0 = tmp0 + (Cr >> 16);
360
361 tmp0 = clip[tmp0];
362 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
363 tmp2 = clip[tmp2];
364 //RGB_565
365
366 rgb = tmp1 | (tmp0 << 6);
367 rgb = tmp2 | (rgb << 5);
368
369 Y = (Y >> 8) & 0xFF;
370
371 Y += OFFSET_5_1;
372 tmp1 = (Y) - (Cg >> 16);
373 tmp2 = (Y) + (Cb >> 16);
374 tmp0 = (Y) + (Cr >> 16);
375
376 tmp0 = clip[tmp0];
377 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
378 tmp2 = clip[tmp2];
379
380 //RGB_565
381
382 tmp0 = tmp1 | (tmp0 << 6);
383 tmp0 = tmp2 | (tmp0 << 5);
384
385 rgb |= (tmp0 << 16);
386
387 *((uint32*)(pDst + dst_pitch)) = rgb;
388
389 //load the top two pixels
390 Y = *pY++;
391
392 tmp0 = (Y & 0xFF); //Low endian left pixel
393 tmp0 += OFFSET_5_1;
394
395 tmp1 = tmp0 - (Cg >> 16);
396 tmp2 = tmp0 + (Cb >> 16);
397 tmp0 = tmp0 + (Cr >> 16);
398
399 tmp0 = clip[tmp0];
400 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
401 tmp2 = clip[tmp2];
402 //RGB_565
403
404 rgb = tmp1 | (tmp0 << 6);
405 rgb = tmp2 | (rgb << 5);
406
407 Y = (Y >> 8) & 0xFF;
408
409 Y += OFFSET_5_0;
410 tmp1 = (Y) - (Cg >> 16);
411 tmp2 = (Y) + (Cb >> 16);
412 tmp0 = (Y) + (Cr >> 16);
413
414 tmp0 = clip[tmp0];
415 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
416 tmp2 = clip[tmp2];
417
418 //RGB_565
419
420 tmp0 = tmp1 | (tmp0 << 6);
421 tmp0 = tmp2 | (tmp0 << 5);
422
423 rgb |= (tmp0 << 16);
424 *((uint32 *)pDst) = rgb;
425 pDst += 2;
426
427 }//end of COL
428
429 pY += (deltaY >> 1);
430 pCb += deltaCbCr;
431 pCr += deltaCbCr;
432 pDst += (deltaDst); //coz pDst defined as UINT *
433 }
434 return 1;
435 }
436
cc16Reverse(uint8 ** src,uint8 * dst,int32 * disp,uint8 * coff_tbl)437 int32 cc16Reverse(uint8 **src, uint8 *dst, int32 *disp, uint8 *coff_tbl)
438 {
439 uint8 *pCb, *pCr;
440 uint16 *pY;
441 uint16 *pDst;
442 int32 src_pitch, dst_pitch, src_width;
443 int32 Y, Cb, Cr, Cg;
444 int32 deltaY, deltaDst, deltaCbCr;
445 int row, col;
446 int32 tmp0, tmp1, tmp2;
447 uint32 rgb;
448 uint8 *clip = coff_tbl + 400;
449 // int32 mRotation;
450 int nextrow, mIsFlip;
451 int32 cc1 = (*((int32*)(clip - 400)));
452 int32 cc3 = (*((int32*)(clip - 396)));
453 int32 cc2 = (*((int32*)(clip - 392)));
454 int32 cc4 = (*((int32*)(clip - 388)));
455
456
457 src_pitch = disp[0];
458 dst_pitch = disp[1];
459 src_width = disp[2];
460 mIsFlip = disp[7];
461
462 deltaDst = (dst_pitch << 1) - src_width;
463
464 if (disp[6]) /* rotation, only */
465 { /* move the starting point to the bottom-right corner of the picture */
466 nextrow = src_pitch * (disp[3] - 1);
467 pY = (uint16*)(src[0] + nextrow + src_width - 2);
468 nextrow = (src_pitch >> 1) * ((disp[3] >> 1) - 1);
469 pCb = src[1] + nextrow + (src_width >> 1) - 1;
470 pCr = src[2] + nextrow + (src_width >> 1) - 1;
471 nextrow = -(src_pitch >> 1);
472 deltaY = src_width - (src_pitch << 1);
473 deltaCbCr = (src_width - src_pitch) >> 1;
474 }
475 else /* flip only */
476 { /* move the starting point to the top-right corner of the picture */
477 pY = (uint16 *)(src[0] + src_width - 2);
478 pCb = src[1] + (src_width >> 1) - 1;
479 pCr = src[2] + (src_width >> 1) - 1;
480 nextrow = src_pitch >> 1;
481 deltaY = src_width + (src_pitch << 1);
482 deltaCbCr = (src_width + src_pitch) >> 1;
483 }
484
485 pDst = (uint16 *)dst;
486
487 for (row = disp[3]; row > 0; row -= 2)
488 {
489
490 for (col = src_width - 1; col >= 0; col -= 2)
491 {
492
493 Cb = *pCb--;
494 Cr = *pCr--;
495 //load the bottom two pixels
496 //Y = *(((uint16 *)pY)+src_pitch);
497 //Y = *((uint16 *)(((uint16 *)pY) + src_pitch));
498 Y = pY[nextrow];
499
500 Cb -= 128;
501 Cr -= 128;
502 //Cg = Cr*JCoeff[0];//*((int32*)(clip - 40))
503 Cg = Cr * cc1;
504 Cr *= cc3;
505
506 Cg += Cb * cc2;
507 Cb *= cc4;
508
509 tmp0 = (Y & 0xFF); //Low endian left pixel
510 tmp0 += OFFSET_5_0;
511
512 tmp1 = tmp0 - (Cg >> 16);
513 tmp2 = tmp0 + (Cb >> 16);
514 tmp0 = tmp0 + (Cr >> 16);
515
516 tmp0 = clip[tmp0];
517 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
518 tmp2 = clip[tmp2];
519 //RGB_565
520
521 rgb = tmp1 | (tmp0 << 6);
522 rgb = tmp2 | (rgb << 5);
523
524 Y = (Y >> 8) & 0xFF;
525
526 Y += OFFSET_5_1;
527 tmp1 = (Y) - (Cg >> 16);
528 tmp2 = (Y) + (Cb >> 16);
529 tmp0 = (Y) + (Cr >> 16);
530
531 tmp0 = clip[tmp0];
532 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
533 tmp2 = clip[tmp2];
534 //RGB_565
535
536 tmp0 = tmp1 | (tmp0 << 6);
537 tmp0 = tmp2 | (tmp0 << 5);
538
539 rgb = (rgb << 16) | tmp0;
540
541 *((uint32*)(pDst + dst_pitch)) = rgb;
542
543 //load the top two pixels
544 //Y = *((uint16 *)pY)++;
545 Y = *pY--;
546
547 tmp0 = (Y & 0xFF); //Low endian left pixel
548 tmp0 += OFFSET_5_1;
549
550 tmp1 = tmp0 - (Cg >> 16);
551 tmp2 = tmp0 + (Cb >> 16);
552 tmp0 = tmp0 + (Cr >> 16);
553
554 tmp0 = clip[tmp0];
555 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
556 tmp2 = clip[tmp2];
557 //RGB_565
558
559 rgb = tmp1 | (tmp0 << 6);
560 rgb = tmp2 | (rgb << 5);
561
562 Y = (Y >> 8) & 0xFF;
563
564 Y += OFFSET_5_0;
565 tmp1 = (Y) - (Cg >> 16);
566 tmp2 = (Y) + (Cb >> 16);
567 tmp0 = (Y) + (Cr >> 16);
568
569 tmp0 = clip[tmp0];
570 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
571 tmp2 = clip[tmp2];
572
573 tmp0 = tmp1 | (tmp0 << 6);
574 tmp0 = tmp2 | (tmp0 << 5);
575
576 rgb = (rgb << 16) | tmp0;
577
578 // *( (unsigned int32 *)pDst)++ = rgb;
579 *((uint32 *)pDst) = rgb;
580 pDst += 2;
581
582 }//end of COL
583
584 pY += (deltaY >> 1);
585 pCb += deltaCbCr;
586 pCr += deltaCbCr;
587 pDst += (deltaDst); //coz pDst defined as UINT *
588 }
589 return 1;
590 }
591
592
593 int32 cc16rotate_P(uint8 **src, uint8 *dst, int32 src_pitch, int32 dst_pitch, int32 src_width, int32 src_height,
594 int32 deltaY, int32 deltaCbCr, int32 deltaDst, uint8 *coeff_tbl);
595 int32 cc16rotate_N(uint8 **src, uint8 *dst, int32 src_pitch, int32 dst_pitch, int32 src_width, int32 src_height,
596 int32 deltaY, int32 deltaCbCr, int32 deltaDst, uint8 *coeff_tbl);
597
cc16Rotate(uint8 ** src,uint8 * dst,DisplayProperties * disp,uint8 * COFF_TBL)598 int32 ColorConvert16::cc16Rotate(uint8 **src, uint8 *dst, DisplayProperties *disp, uint8 *COFF_TBL)
599 {
600 int32 src_pitch, dst_pitch, src_width, src_height;
601 int32 deltaY, deltaCbCr, deltaDst;
602
603 src_pitch = disp->src_pitch;
604 dst_pitch = disp->dst_pitch;
605 src_width = disp->src_width;
606 src_height = disp->src_height;
607
608 deltaY = (src_pitch << 1) - src_width;
609 deltaCbCr = (src_pitch - src_width) >> 1;
610
611 if (_mRotation == CCROTATE_CLKWISE)
612 {
613 if (!_mIsFlip)
614 { // go from upper-right down and left
615 dst += ((src_height - 1) << 1);
616 deltaDst = -(dst_pitch * src_width) - 2;
617
618 return cc16rotate_N(src, dst, src_pitch, dst_pitch, src_width, src_height, deltaY,
619 deltaCbCr, deltaDst, COFF_TBL);
620 }
621 else
622 { // go from origin down and right
623 deltaDst = -(dst_pitch * src_width) + 2;
624 return cc16rotate_P(src, dst, src_pitch, dst_pitch, src_width, src_height, deltaY,
625 deltaCbCr, deltaDst, COFF_TBL);
626 }
627
628 }
629 else // rotate counterclockwise
630 {
631 if (!_mIsFlip)
632 { // go from bottom-left to up right
633 dst += (((src_width - 1) * dst_pitch) << 1);
634 deltaDst = (dst_pitch * src_width + 2);
635 dst_pitch = -dst_pitch;
636
637 return cc16rotate_P(src, dst, src_pitch, dst_pitch, src_width, src_height, deltaY,
638 deltaCbCr, deltaDst, COFF_TBL);
639 }
640 else
641 { // go from bottom right to top and left
642 dst += (((src_height - 1) << 1) + (((src_width - 1) * dst_pitch) << 1));
643 deltaDst = (dst_pitch * src_width - 2);
644 dst_pitch = -dst_pitch;
645
646 return cc16rotate_N(src, dst, src_pitch, dst_pitch, src_width, src_height, deltaY,
647 deltaCbCr, deltaDst, COFF_TBL);
648 }
649 }
650
651 }
652
cc16rotate_P(uint8 ** src,uint8 * dst,int32 src_pitch,int32 dst_pitch,int32 src_width,int32 src_height,int32 deltaY,int32 deltaCbCr,int32 deltaDst,uint8 * coeff_tbl)653 int32 cc16rotate_P(uint8 **src, uint8 *dst, int32 src_pitch, int32 dst_pitch, int32 src_width, int32 src_height,
654 int32 deltaY, int32 deltaCbCr, int32 deltaDst, uint8 *coeff_tbl)
655 {
656 #if CCROTATE
657 uint8 *pCb, *pCr;
658 uint16 *pY;
659 uint16 *pDst;
660 int32 Y, Cb, Cr, Cg;
661 int32 row, col;
662 int32 tmp0, tmp1, tmp2;
663 uint32 rgb;
664 uint8 *clip = coeff_tbl + 400;
665 int32 cc1 = (*((int32*)(clip - 400)));
666 int32 cc3 = (*((int32*)(clip - 396)));
667 int32 cc2 = (*((int32*)(clip - 392)));
668 int32 cc4 = (*((int32*)(clip - 388)));
669
670 pY = (uint16*) src[0];
671 src_pitch >>= 1;
672 pCb = src[1];
673 pCr = src[2];
674
675 pDst = (uint16 *)dst;
676
677 for (row = src_height; row > 0; row -= 2)
678 {
679
680 for (col = src_width - 1; col >= 0; col -= 2)
681 {
682
683 Cb = *pCb++;
684 Cr = *pCr++;
685 //load the bottom two pixels
686 Y = pY[src_pitch];
687
688 Cb -= 128;
689 Cr -= 128;
690 Cg = Cr * cc1;
691 Cr *= cc3;
692
693 Cg += Cb * cc2;
694 Cb *= cc4;
695
696 tmp0 = (Y & 0xFF); //Low endian left pixel
697 tmp0 += OFFSET_5_0;
698
699 tmp1 = tmp0 - (Cg >> 16);
700 tmp2 = tmp0 + (Cb >> 16);
701 tmp0 = tmp0 + (Cr >> 16);
702
703 tmp0 = clip[tmp0];
704 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
705 tmp2 = clip[tmp2];
706 //RGB_565
707
708 rgb = tmp1 | (tmp0 << 6);
709 rgb = tmp2 | (rgb << 5);
710
711 *(pDst += 1) = rgb;
712
713 Y = (Y >> 8);
714 Y += OFFSET_5_1;
715
716 tmp1 = (Y) - (Cg >> 16);
717 tmp2 = (Y) + (Cb >> 16);
718 tmp0 = (Y) + (Cr >> 16);
719
720 tmp0 = clip[tmp0];
721 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
722 tmp2 = clip[tmp2];
723 //RGB_565
724
725 tmp0 = tmp1 | (tmp0 << 6);
726 tmp0 = tmp2 | (tmp0 << 5);
727
728 *(pDst += dst_pitch) = tmp0;
729
730 //load the top two pixels
731 Y = *pY++;
732
733 tmp0 = (Y >> 8); //Low endian right pixel
734 tmp0 += OFFSET_5_0;
735
736 tmp1 = tmp0 - (Cg >> 16);
737 tmp2 = tmp0 + (Cb >> 16);
738 tmp0 = tmp0 + (Cr >> 16);
739
740 tmp0 = clip[tmp0];
741 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
742 tmp2 = clip[tmp2];
743
744 rgb = tmp1 | (tmp0 << 6);
745 rgb = tmp2 | (rgb << 5);
746 *(pDst -= 1) = rgb;
747
748 tmp0 = Y & 0xFF;
749 tmp0 += OFFSET_5_1;
750
751 tmp1 = (tmp0) - (Cg >> 16);
752 tmp2 = (tmp0) + (Cb >> 16);
753 tmp0 = (tmp0) + (Cr >> 16);
754
755 tmp0 = clip[tmp0];
756 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
757 tmp2 = clip[tmp2];
758
759 tmp0 = tmp1 | (tmp0 << 6);
760 tmp0 = tmp2 | (tmp0 << 5);
761
762 pDst[-dst_pitch] = tmp0;
763 pDst += dst_pitch;
764
765 }//end of COL
766
767 pY += (deltaY >> 1);
768 pCb += deltaCbCr;
769 pCr += deltaCbCr;
770 pDst += (deltaDst); //coz pDst defined as UINT *
771 }
772 return 1;
773 #else
774 OSCL_UNUSED_ARG(src);
775 OSCL_UNUSED_ARG(dst);
776 OSCL_UNUSED_ARG(src_pitch);
777 OSCL_UNUSED_ARG(dst_pitch);
778 OSCL_UNUSED_ARG(src_width);
779 OSCL_UNUSED_ARG(src_height);
780 OSCL_UNUSED_ARG(deltaY);
781 OSCL_UNUSED_ARG(deltaCbCr);
782 OSCL_UNUSED_ARG(deltaDst);
783 OSCL_UNUSED_ARG(coeff_tbl);
784
785 return 0;
786 #endif // CCROTATE
787 }
788
cc16rotate_N(uint8 ** src,uint8 * dst,int32 src_pitch,int32 dst_pitch,int32 src_width,int32 src_height,int32 deltaY,int32 deltaCbCr,int32 deltaDst,uint8 * coeff_tbl)789 int32 cc16rotate_N(uint8 **src, uint8 *dst, int32 src_pitch, int32 dst_pitch, int32 src_width, int32 src_height,
790 int32 deltaY, int32 deltaCbCr, int32 deltaDst, uint8 *coeff_tbl)
791 {
792 #if CCROTATE
793 uint8 *pCb, *pCr;
794 uint16 *pY;
795 uint16 *pDst;
796 int32 Y, Cb, Cr, Cg;
797 int32 row, col;
798 int32 tmp0, tmp1, tmp2;
799 uint32 rgb;
800 uint8 *clip = coeff_tbl + 400;
801 int32 cc1 = (*((int32*)(clip - 400)));
802 int32 cc3 = (*((int32*)(clip - 396)));
803 int32 cc2 = (*((int32*)(clip - 392)));
804 int32 cc4 = (*((int32*)(clip - 388)));
805
806 pY = (uint16*) src[0];
807 src_pitch >>= 1;
808 pCb = src[1];
809 pCr = src[2];
810
811 pDst = (uint16 *)dst;
812
813 for (row = src_height; row > 0; row -= 2)
814 {
815
816 for (col = src_width - 1; col >= 0; col -= 2)
817 {
818
819 Cb = *pCb++;
820 Cr = *pCr++;
821 //load the bottom two pixels
822 Y = pY[src_pitch];
823
824 Cb -= 128;
825 Cr -= 128;
826 Cg = Cr * cc1;
827 Cr *= cc3;
828
829 Cg += Cb * cc2;
830 Cb *= cc4;
831
832 tmp0 = (Y & 0xFF); //Low endian left pixel
833 tmp0 += OFFSET_5_0;
834
835 tmp1 = tmp0 - (Cg >> 16);
836 tmp2 = tmp0 + (Cb >> 16);
837 tmp0 = tmp0 + (Cr >> 16);
838
839 tmp0 = clip[tmp0];
840 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
841 tmp2 = clip[tmp2];
842 //RGB_565
843
844 rgb = tmp1 | (tmp0 << 6);
845 rgb = tmp2 | (rgb << 5);
846
847 *(pDst -= 1) = rgb;
848
849 Y = (Y >> 8) & 0xFF;
850
851 Y += OFFSET_5_1;
852 tmp1 = (Y) - (Cg >> 16);
853 tmp2 = (Y) + (Cb >> 16);
854 tmp0 = (Y) + (Cr >> 16);
855
856 tmp0 = clip[tmp0];
857 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
858 tmp2 = clip[tmp2];
859 //RGB_565
860
861 tmp0 = tmp1 | (tmp0 << 6);
862 tmp0 = tmp2 | (tmp0 << 5);
863
864 *(pDst += dst_pitch) = tmp0;
865
866 //load the top two pixels
867 Y = *pY++;
868
869 tmp0 = (Y >> 8) & 0xFF; //Low endian right pixel
870 tmp0 += OFFSET_5_0;
871
872 tmp1 = tmp0 - (Cg >> 16);
873 tmp2 = tmp0 + (Cb >> 16);
874 tmp0 = tmp0 + (Cr >> 16);
875
876 tmp0 = clip[tmp0];
877 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
878 tmp2 = clip[tmp2];
879
880 rgb = tmp1 | (tmp0 << 6);
881 rgb = tmp2 | (rgb << 5);
882 *(pDst += 1) = rgb;
883
884 Y = (Y & 0xFF);
885
886 Y += OFFSET_5_1;
887 tmp1 = (Y) - (Cg >> 16);
888 tmp2 = (Y) + (Cb >> 16);
889 tmp0 = (Y) + (Cr >> 16);
890
891 tmp0 = clip[tmp0];
892 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
893 tmp2 = clip[tmp2];
894
895 tmp0 = tmp1 | (tmp0 << 6);
896 tmp0 = tmp2 | (tmp0 << 5);
897
898 pDst[-dst_pitch] = tmp0;
899 pDst += dst_pitch;
900
901 }//end of COL
902
903 pY += (deltaY >> 1);
904 pCb += deltaCbCr;
905 pCr += deltaCbCr;
906 pDst += (deltaDst); //coz pDst defined as UINT *
907 }
908 return 1;
909 #else
910 OSCL_UNUSED_ARG(src);
911 OSCL_UNUSED_ARG(dst);
912 OSCL_UNUSED_ARG(src_pitch);
913 OSCL_UNUSED_ARG(dst_pitch);
914 OSCL_UNUSED_ARG(src_width);
915 OSCL_UNUSED_ARG(src_height);
916 OSCL_UNUSED_ARG(deltaY);
917 OSCL_UNUSED_ARG(deltaCbCr);
918 OSCL_UNUSED_ARG(deltaDst);
919 OSCL_UNUSED_ARG(coeff_tbl);
920
921 return 0;
922 #endif // CCROTATE
923 }
924
925
926
927 int32 cc16scaledown(uint8 **src, uint8 *dst, int32 *disp,
928 uint8 *coff_tbl, uint8 *_mRowPix, uint8 *_mColPix);
929 int32 cc16scalingHalf(uint8 **src, uint8 *dst, int32 *disp,
930 uint8 *coff_tbl);
931 int32 cc16scaling34(uint8 **src, uint8 *dst,
932 int32 *disp, uint8 *coff_tbl);
933 int32 cc16scaleup(uint8 **src, uint8 *dst, int32 *disp,
934 uint8 *coff_tbl, uint8 *_mRowPix, uint8 *_mColPix);
935 int32 cc16scaling54(uint8 **src, uint8 *dst,
936 int32 *disp, uint8 *coff_tbl);
937 int32 cc16scaling43(uint8 **src, uint8 *dst,
938 int32 *disp, uint8 *coff_tbl);
939 int32 cc16scaling128x96(uint8 **src, uint8 *dst,
940 int32 *disp, uint8 *coff_tbl);
941
942 // Note:: This zoom algorithm needs an extra line of RGB buffer. So, users
943 // have to use GetOutputBufferSize API to get the size it needs. See GetOutputBufferSize().
cc16ZoomIn(uint8 ** src,uint8 * dst,DisplayProperties * disp,uint8 * coff_tbl)944 int32 ColorConvert16::cc16ZoomIn(uint8 **src, uint8 *dst, DisplayProperties *disp, uint8 *coff_tbl)
945 {
946 int32 disp_prop[8];
947 int32 src_width, src_height, dst_width, dst_height;
948 int32 tempw, temph;
949
950 disp_prop[0] = disp->src_pitch;
951 disp_prop[1] = disp->dst_pitch;
952 disp_prop[2] = src_width = disp->src_width;
953 disp_prop[3] = src_height = disp->src_height;
954 disp_prop[4] = dst_width = disp->dst_width;
955 disp_prop[5] = dst_height = disp->dst_height;
956 disp_prop[6] = (_mRotation > 0 ? 1 : 0);
957 disp_prop[7] = _mIsFlip;
958
959 if (src_width > dst_width) /* scale down in width */
960 {
961 tempw = (3 * src_width) >> 2;
962 temph = (3 * src_height) >> 2;
963 /* check for special zoom-out case, 3:4 scaling down */
964 if (dst_width == tempw && dst_height == temph && !(src_width&3))
965 {
966 return cc16scaling34(src, dst, disp_prop, coff_tbl);
967 }
968 else
969 {
970 if ((dst_width == (src_width >> 1)) && (dst_height == (src_height >> 1)))
971 {
972 return cc16scalingHalf(src, dst, disp_prop, coff_tbl);
973 }
974 else
975 {
976 return cc16scaledown(src, dst, disp_prop, coff_tbl, _mRowPix, _mColPix);
977 }
978 }
979 }
980 else
981 {
982 tempw = (5 * src_width) / 4;
983 temph = (5 * src_height) / 4;
984
985 /* check for special zoom-out case, 5:4 scaling up */
986 if (dst_width == tempw && dst_height == temph && !(src_width&3))
987 {
988 return cc16scaling54(src, dst, disp_prop, coff_tbl);
989 }
990 else
991 {
992 tempw = (4 * src_width) / 3;
993 temph = (4 * src_height) / 3;
994 if (dst_width == tempw && dst_height == temph && !(src_width&3))
995 {
996 return cc16scaling43(src, dst, disp_prop, coff_tbl);
997 }
998 else
999 {
1000 tempw = (15 * src_width) / 8;
1001 temph = (15 * src_height) / 8;
1002 #ifdef SPECIAL_SCALE_128x96
1003 if (dst_width == tempw && dst_height == temph && !(src_width&7))
1004 {
1005 return cc16scaling128x96(src, dst, disp_prop, coff_tbl);
1006 }
1007 else
1008 #endif
1009 {
1010 return cc16scaleup(src, dst, disp_prop, coff_tbl, _mRowPix, _mColPix);
1011 }
1012 }
1013 }
1014
1015 }
1016 }
1017
1018 #ifdef SPECIAL_SCALE_128x96
cc16scaling128x96(uint8 ** src,uint8 * dst,int32 * disp,uint8 * coff_tbl)1019 int32 cc16scaling128x96(uint8 **src, uint8 *dst, int32 *disp, uint8 *coff_tbl)
1020 {
1021 #if CCSCALING
1022 uint8 *pCb, *pCr;
1023 uint16 *pY;
1024 uint16 *pDst;
1025 int32 src_pitch, dst_pitch, src_width, nextrow;
1026 int32 Y, Cb, Cr, Cg;
1027 int32 deltaY, deltaCbCr;
1028 int32 row, col;
1029 int32 tmp0, tmp1, tmp2;
1030 uint32 rgb;
1031 uint8 *clip = coff_tbl + 400;
1032 int32 cc1 = (*((int32*)(clip - 400)));
1033 int32 cc3 = (*((int32*)(clip - 396)));
1034 int32 cc2 = (*((int32*)(clip - 392)));
1035 int32 cc4 = (*((int32*)(clip - 388)));
1036 #ifdef INTERPOLATE
1037 int i, offset = 0;
1038 uint16 *pI2, *pU2, *pIn, *pNext;
1039 int32 tmp02, tmp01;
1040 #endif
1041
1042 src_pitch = disp[0];
1043 dst_pitch = disp[1];
1044 src_width = disp[2];
1045
1046 if (((disp[6] == 1) && (disp[7] == 1)) || ((disp[6] == 0) && (disp[7] == 0)))
1047 {
1048 if (disp[6])/* rotate 180 and flip */
1049 { /* move the starting point to the bottom-left corner of the picture */
1050 deltaY = src_pitch * (disp[3] - 1);
1051 pY = (uint16*)(src[0] + deltaY);
1052 deltaY = (src_pitch >> 1) * ((disp[3] >> 1) - 1);
1053 pCb = src[1] + deltaY;
1054 pCr = src[2] + deltaY;
1055 deltaY = -src_width - (src_pitch << 1);
1056 deltaCbCr = -((src_width + src_pitch) >> 1);
1057 src_pitch = -(src_pitch >> 1);
1058 }
1059 else // no rotate,no flip
1060 {
1061 deltaY = (src_pitch << 1) - src_width;
1062 deltaCbCr = (src_pitch - src_width) >> 1;
1063 pY = (uint16 *) src[0];
1064 src_pitch >>= 1;
1065 pCb = src[1];
1066 pCr = src[2];
1067 }
1068
1069 pDst = (uint16 *)dst;
1070
1071 for (row = 0; row < disp[3] - 1; row += 2)
1072 {
1073 for (col = 0; col <= src_width - 1; col += 8)
1074 {
1075 Cb = *pCb++;
1076 Cr = *pCr++;
1077 //load the bottom two pixels
1078 Y = pY[src_pitch];
1079
1080 Cb -= 128;
1081 Cr -= 128;
1082 Cg = Cr * cc1;
1083 Cr *= cc3;
1084
1085 Cg += Cb * cc2;
1086 Cb *= cc4;
1087
1088 tmp0 = (Y & 0xFF); //Low endian left pixel
1089 tmp0 += OFFSET_5_0;
1090
1091 tmp1 = tmp0 - (Cg >> 16);
1092 tmp2 = tmp0 + (Cb >> 16);
1093 tmp0 = tmp0 + (Cr >> 16);
1094
1095 tmp0 = clip[tmp0];
1096 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
1097 tmp2 = clip[tmp2];
1098 //RGB_565
1099
1100 rgb = tmp1 | (tmp0 << 6);
1101 rgb = tmp2 | (rgb << 5);
1102 *((pDst + (dst_pitch << 1))) = rgb;
1103 #ifndef INTERPOLATE
1104 *((pDst + (dst_pitch << 1) + 1)) = rgb;
1105 #endif
1106
1107 Y = (Y >> 8) & 0xFF;
1108
1109 Y += OFFSET_5_1;
1110 tmp1 = (Y) - (Cg >> 16);
1111 tmp2 = (Y) + (Cb >> 16);
1112 tmp0 = (Y) + (Cr >> 16);
1113
1114 tmp0 = clip[tmp0];
1115 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
1116 tmp2 = clip[tmp2];
1117 //RGB_565
1118
1119 tmp0 = tmp1 | (tmp0 << 6);
1120 #ifdef INTERPOLATE
1121 tmp02 = tmp2 | (tmp0 << 5);
1122 *(pDst + (dst_pitch << 1) + 2) = tmp02;
1123 *((pDst + (dst_pitch << 1) + 1)) = (((((tmp02 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1124 | ((((((tmp02 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1125 | ((((((tmp02 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1126 pI2 = ((pDst + (dst_pitch << 1) + 3));
1127 #else
1128 tmp0 = tmp2 | (tmp0 << 5);
1129 *(pDst + (dst_pitch << 1) + 2) = tmp0;
1130 *(pDst + (dst_pitch << 1) + 3) = tmp0;
1131 #endif
1132 //load the top two pixels
1133 Y = *pY++;
1134
1135 tmp0 = (Y & 0xFF); //Low endian left pixel
1136 tmp0 += OFFSET_5_1;
1137
1138 tmp1 = tmp0 - (Cg >> 16);
1139 tmp2 = tmp0 + (Cb >> 16);
1140 tmp0 = tmp0 + (Cr >> 16);
1141
1142 tmp0 = clip[tmp0];
1143 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
1144 tmp2 = clip[tmp2];
1145
1146 rgb = tmp1 | (tmp0 << 6);
1147 rgb = tmp2 | (rgb << 5);
1148
1149 *((pDst)) = rgb;
1150 #ifndef INTERPOLATE
1151 *((pDst + 1)) = rgb;
1152 #endif
1153 Y = (Y >> 8) & 0xFF;
1154
1155 Y += OFFSET_5_0;
1156 tmp1 = (Y) - (Cg >> 16);
1157 tmp2 = (Y) + (Cb >> 16);
1158 tmp0 = (Y) + (Cr >> 16);
1159
1160 tmp0 = clip[tmp0];
1161 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
1162 tmp2 = clip[tmp2];
1163
1164 tmp0 = tmp1 | (tmp0 << 6);
1165 #ifdef INTERPOLATE
1166 tmp01 = tmp2 | (tmp0 << 5);
1167 *(pDst + 2) = tmp01;
1168 *((pDst + 1)) = (((((tmp01 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1169 | ((((((tmp01 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1170 | ((((((tmp01 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1171 pU2 = (pDst + 3);
1172 #else
1173 tmp0 = tmp2 | (tmp0 << 5);
1174 *(pDst + 2) = tmp0;
1175 *(pDst + 3) = tmp0;
1176 #endif
1177 pDst += 4;
1178
1179 Cb = *pCb++;
1180 Cr = *pCr++;
1181 //load the bottom two pixels
1182 Y = pY[src_pitch];
1183
1184 Cb -= 128;
1185 Cr -= 128;
1186 Cg = Cr * cc1;
1187 Cr *= cc3;
1188
1189 Cg += Cb * cc2;
1190 Cb *= cc4;
1191
1192 tmp0 = (Y & 0xFF); //Low endian left pixel
1193 tmp0 += OFFSET_5_0;
1194
1195 tmp1 = tmp0 - (Cg >> 16);
1196 tmp2 = tmp0 + (Cb >> 16);
1197 tmp0 = tmp0 + (Cr >> 16);
1198
1199 tmp0 = clip[tmp0];
1200 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
1201 tmp2 = clip[tmp2];
1202 //RGB_565
1203
1204 rgb = tmp1 | (tmp0 << 6);
1205 rgb = tmp2 | (rgb << 5);
1206
1207 *((pDst + (dst_pitch << 1))) = rgb;
1208 #ifdef INTERPOLATE
1209 *pI2 = (((((tmp02 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1210 | ((((((tmp02 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1211 | ((((((tmp02 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1212 #else
1213 *((pDst + (dst_pitch << 1) + 1)) = rgb;
1214 #endif
1215
1216 Y = (Y >> 8) & 0xFF;
1217
1218 Y += OFFSET_5_1;
1219 tmp1 = (Y) - (Cg >> 16);
1220 tmp2 = (Y) + (Cb >> 16);
1221 tmp0 = (Y) + (Cr >> 16);
1222
1223 tmp0 = clip[tmp0];
1224 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
1225 tmp2 = clip[tmp2];
1226 //RGB_565
1227
1228 tmp0 = tmp1 | (tmp0 << 6);
1229 #ifdef INTERPOLATE
1230 tmp02 = tmp2 | (tmp0 << 5);
1231 *(pDst + (dst_pitch << 1) + 2) = tmp02;
1232 *((pDst + (dst_pitch << 1) + 1)) = (((((tmp02 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1233 | ((((((tmp02 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1234 | ((((((tmp02 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1235 pI2 = (pDst + (dst_pitch << 1) + 3);
1236 #else
1237 tmp0 = tmp2 | (tmp0 << 5);
1238 *(pDst + (dst_pitch << 1) + 2) = tmp0;
1239 *(pDst + (dst_pitch << 1) + 3) = tmp0;
1240 #endif
1241 //load the top two pixels
1242 Y = *pY++;
1243
1244 tmp0 = (Y & 0xFF); //Low endian left pixel
1245 tmp0 += OFFSET_5_1;
1246
1247 tmp1 = tmp0 - (Cg >> 16);
1248 tmp2 = tmp0 + (Cb >> 16);
1249 tmp0 = tmp0 + (Cr >> 16);
1250
1251 tmp0 = clip[tmp0];
1252 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
1253 tmp2 = clip[tmp2];
1254
1255 rgb = tmp1 | (tmp0 << 6);
1256 rgb = tmp2 | (rgb << 5);
1257
1258 *((pDst)) = rgb;
1259 #ifdef INTERPOLATE
1260 *pU2 = (((((tmp01 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1261 | ((((((tmp01 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1262 | ((((((tmp01 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1263 #else
1264 *((pDst + 1)) = rgb;
1265 #endif
1266 Y = (Y >> 8) & 0xFF;
1267
1268 Y += OFFSET_5_0;
1269 tmp1 = (Y) - (Cg >> 16);
1270 tmp2 = (Y) + (Cb >> 16);
1271 tmp0 = (Y) + (Cr >> 16);
1272
1273 tmp0 = clip[tmp0];
1274 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
1275 tmp2 = clip[tmp2];
1276
1277 tmp0 = tmp1 | (tmp0 << 6);
1278 #ifdef INTERPOLATE
1279 tmp01 = tmp2 | (tmp0 << 5);
1280 *(pDst + 2) = tmp01;
1281 *((pDst + 1)) = (((((tmp01 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1282 | ((((((tmp01 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1283 | ((((((tmp01 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1284 pU2 = (pDst + 3);
1285 #else
1286 tmp0 = tmp2 | (tmp0 << 5);
1287 *(pDst + 2) = tmp0;
1288 *(pDst + 3) = tmp0;
1289 #endif
1290 pDst += 4;
1291
1292 Cb = *pCb++;
1293 Cr = *pCr++;
1294 //load the bottom two pixels
1295 Y = pY[src_pitch];
1296
1297 Cb -= 128;
1298 Cr -= 128;
1299 Cg = Cr * cc1;
1300 Cr *= cc3;
1301
1302 Cg += Cb * cc2;
1303 Cb *= cc4;
1304
1305 tmp0 = (Y & 0xFF); //Low endian left pixel
1306 tmp0 += OFFSET_5_0;
1307
1308 tmp1 = tmp0 - (Cg >> 16);
1309 tmp2 = tmp0 + (Cb >> 16);
1310 tmp0 = tmp0 + (Cr >> 16);
1311
1312 tmp0 = clip[tmp0];
1313 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
1314 tmp2 = clip[tmp2];
1315 //RGB_565
1316
1317 rgb = tmp1 | (tmp0 << 6);
1318 rgb = tmp2 | (rgb << 5);
1319
1320 *((pDst + (dst_pitch << 1))) = rgb;
1321 #ifdef INTERPOLATE
1322 *pI2 = (((((tmp02 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1323 | ((((((tmp02 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1324 | ((((((tmp02 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1325 #else
1326 *((pDst + (dst_pitch << 1) + 1)) = rgb;
1327 #endif
1328 Y = (Y >> 8) & 0xFF;
1329
1330 Y += OFFSET_5_1;
1331 tmp1 = (Y) - (Cg >> 16);
1332 tmp2 = (Y) + (Cb >> 16);
1333 tmp0 = (Y) + (Cr >> 16);
1334
1335 tmp0 = clip[tmp0];
1336 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
1337 tmp2 = clip[tmp2];
1338 //RGB_565
1339
1340 tmp0 = tmp1 | (tmp0 << 6);
1341 #ifdef INTERPOLATE
1342 tmp02 = tmp2 | (tmp0 << 5);
1343 *(pDst + (dst_pitch << 1) + 2) = tmp02;
1344 *((pDst + (dst_pitch << 1) + 1)) = (((((tmp02 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1345 | ((((((tmp02 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1346 | ((((((tmp02 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1347 pI2 = (pDst + (dst_pitch << 1) + 3);
1348 #else
1349 tmp0 = tmp2 | (tmp0 << 5);
1350 *(pDst + (dst_pitch << 1) + 2) = tmp0;
1351 *(pDst + (dst_pitch << 1) + 3) = tmp0;
1352 #endif
1353 //load the top two pixels
1354 Y = *pY++;
1355
1356 tmp0 = (Y & 0xFF); //Low endian left pixel
1357 tmp0 += OFFSET_5_1;
1358
1359 tmp1 = tmp0 - (Cg >> 16);
1360 tmp2 = tmp0 + (Cb >> 16);
1361 tmp0 = tmp0 + (Cr >> 16);
1362
1363 tmp0 = clip[tmp0];
1364 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
1365 tmp2 = clip[tmp2];
1366
1367 rgb = tmp1 | (tmp0 << 6);
1368 rgb = tmp2 | (rgb << 5);
1369
1370 *((pDst)) = rgb;
1371 #ifdef INTERPOLATE
1372 *pU2 = (((((tmp01 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1373 | ((((((tmp01 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1374 | ((((((tmp01 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1375 #else
1376 *((pDst + 1)) = rgb;
1377 #endif
1378 Y = (Y >> 8) & 0xFF;
1379
1380 Y += OFFSET_5_0;
1381 tmp1 = (Y) - (Cg >> 16);
1382 tmp2 = (Y) + (Cb >> 16);
1383 tmp0 = (Y) + (Cr >> 16);
1384
1385 tmp0 = clip[tmp0];
1386 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
1387 tmp2 = clip[tmp2];
1388
1389 tmp0 = tmp1 | (tmp0 << 6);
1390 #ifdef INTERPOLATE
1391 tmp01 = tmp2 | (tmp0 << 5);
1392 *(pDst + 2) = tmp01;
1393 *((pDst + 1)) = (((((tmp01 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1394 | ((((((tmp01 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1395 | ((((((tmp01 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1396 pU2 = (pDst + 3);
1397 #else
1398 tmp0 = tmp2 | (tmp0 << 5);
1399 *(pDst + 2) = tmp0;
1400 *(pDst + 3) = tmp0;
1401 #endif
1402 pDst += 4;
1403
1404 Cb = *pCb++;
1405 Cr = *pCr++;
1406 //load the bottom two pixels
1407 Y = pY[src_pitch];
1408
1409 Cb -= 128;
1410 Cr -= 128;
1411 Cg = Cr * cc1;
1412 Cr *= cc3;
1413
1414 Cg += Cb * cc2;
1415 Cb *= cc4;
1416
1417 tmp0 = (Y & 0xFF); //Low endian left pixel
1418 tmp0 += OFFSET_5_0;
1419
1420 tmp1 = tmp0 - (Cg >> 16);
1421 tmp2 = tmp0 + (Cb >> 16);
1422 tmp0 = tmp0 + (Cr >> 16);
1423
1424 tmp0 = clip[tmp0];
1425 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
1426 tmp2 = clip[tmp2];
1427 //RGB_565
1428
1429 rgb = tmp1 | (tmp0 << 6);
1430 rgb = tmp2 | (rgb << 5);
1431 *((pDst + (dst_pitch << 1))) = rgb;
1432 #ifdef INTERPOLATE
1433 *pI2 = (((((tmp02 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1434 | ((((((tmp02 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1435 | ((((((tmp02 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1436 #else
1437 *((pDst + (dst_pitch << 1) + 1)) = rgb;
1438 #endif
1439
1440 Y = (Y >> 8) & 0xFF;
1441
1442 Y += OFFSET_5_1;
1443 tmp1 = (Y) - (Cg >> 16);
1444 tmp2 = (Y) + (Cb >> 16);
1445 tmp0 = (Y) + (Cr >> 16);
1446
1447 tmp0 = clip[tmp0];
1448 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
1449 tmp2 = clip[tmp2];
1450 //RGB_565
1451
1452 tmp0 = tmp1 | (tmp0 << 6);
1453 tmp0 = tmp2 | (tmp0 << 5);
1454
1455 *(pDst + (dst_pitch << 1) + 2) = tmp0;
1456 #ifdef INTERPOLATE
1457 *((pDst + (dst_pitch << 1) + 1)) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1458 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1459 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1460 #endif
1461 //load the top two pixels
1462 Y = *pY++;
1463
1464 tmp0 = (Y & 0xFF); //Low endian left pixel
1465 tmp0 += OFFSET_5_1;
1466
1467 tmp1 = tmp0 - (Cg >> 16);
1468 tmp2 = tmp0 + (Cb >> 16);
1469 tmp0 = tmp0 + (Cr >> 16);
1470
1471 tmp0 = clip[tmp0];
1472 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
1473 tmp2 = clip[tmp2];
1474
1475 rgb = tmp1 | (tmp0 << 6);
1476 rgb = tmp2 | (rgb << 5);
1477
1478 *((pDst)) = rgb;
1479 #ifdef INTERPOLATE
1480 *pU2 = (((((tmp01 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1481 | ((((((tmp01 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1482 | ((((((tmp01 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1483 #else
1484 *((pDst + 1)) = rgb;
1485 #endif
1486 Y = (Y >> 8) & 0xFF;
1487
1488 Y += OFFSET_5_0;
1489 tmp1 = (Y) - (Cg >> 16);
1490 tmp2 = (Y) + (Cb >> 16);
1491 tmp0 = (Y) + (Cr >> 16);
1492
1493 tmp0 = clip[tmp0];
1494 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
1495 tmp2 = clip[tmp2];
1496
1497 tmp0 = tmp1 | (tmp0 << 6);
1498 tmp0 = tmp2 | (tmp0 << 5);
1499
1500 *(pDst + 2) = tmp0;
1501 #ifdef INTERPOLATE
1502 *((pDst + 1)) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1503 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1504 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1505 #endif
1506 pDst += 3;
1507
1508 }//end of COL
1509
1510 pY += (deltaY >> 1);
1511 pCb += deltaCbCr;
1512 pCr += deltaCbCr;
1513
1514 pDst -= (disp[4]);
1515 #ifdef INTERPOLATE
1516 /* vertically - 1 1' 2 2' 3 3' 4 4' 5 5' 6 6' 7 7' 8 1 1'2 2'........*/
1517 if ((row & 0x7))
1518 {
1519 pIn = pDst - dst_pitch;
1520 pNext = pIn - dst_pitch;
1521 for (i = 0; i < disp[4]; i++)
1522 {
1523 int32 curr = pDst[i];
1524 int32 below = pNext[i];
1525 pIn[i] = (((((curr & 0x1F) + (below & 0x1F)) / 2) & 0x1F)
1526 | ((((((curr >> 5) & 0x3F) + ((below >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1527 | ((((((curr >> 11) & 0x1F) + ((below >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1528 }
1529 offset++;
1530 }
1531
1532 pNext = pDst + (dst_pitch * 2);
1533 pIn = pDst + dst_pitch;
1534 for (i = 0; i < disp[4]; i++)
1535 {
1536 int32 curr = pDst[i];
1537 int32 below = pNext[i];
1538 pIn[i] = (((((curr & 0x1F) + (below & 0x1F)) / 2) & 0x1F)
1539 | ((((((curr >> 5) & 0x3F) + ((below >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1540 | ((((((curr >> 11) & 0x1F) + ((below >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1541 }
1542
1543 if (offset == 3)
1544 {
1545 pDst = pNext + dst_pitch;
1546 offset = 0;
1547 }
1548 else
1549 pDst = pNext + dst_pitch * 2;
1550 #else
1551 oscl_memcpy(pDst + dst_pitch, pDst, (disp[4] << 1));
1552 pDst += (dst_pitch << 1);
1553
1554 if (row & 0x7)
1555 {
1556 oscl_memcpy(pDst + dst_pitch, pDst, (disp[4] << 1));
1557 pDst += dst_pitch; //coz pDst defined as UINT *
1558 }
1559 pDst += dst_pitch;
1560 #endif
1561 }
1562 }
1563 else
1564 {
1565 if (disp[6])/* rotation 180 only */
1566 {
1567 /* move the starting point to the bottom-right corner of the picture */
1568 nextrow = src_pitch * (disp[3] - 1);
1569 pY = (uint16*)(src[0] + nextrow + src_width - 2);
1570 nextrow = (src_pitch >> 1) * ((disp[3] >> 1) - 1);
1571 pCb = src[1] + nextrow + (src_width >> 1) - 1;
1572 pCr = src[2] + nextrow + (src_width >> 1) - 1;
1573 nextrow = -(src_pitch >> 1);
1574 deltaY = src_width - (src_pitch << 1);
1575 deltaCbCr = (src_width - src_pitch) >> 1;
1576 }
1577 else /* flip only */
1578 {
1579 /* move the starting point to the top-right corner of the picture */
1580 pY = (uint16 *)(src[0] + src_width - 2);
1581 pCb = src[1] + (src_width >> 1) - 1;
1582 pCr = src[2] + (src_width >> 1) - 1;
1583 nextrow = src_pitch >> 1;
1584 deltaY = src_width + (src_pitch << 1);
1585 deltaCbCr = (src_width + src_pitch) >> 1;
1586 }
1587 pDst = (uint16 *)dst;
1588 for (row = 0; row < disp[3] - 1; row += 2)
1589 {
1590 for (col = 0; col <= src_width - 1; col += 8)
1591 {
1592 Cb = *pCb--;
1593 Cr = *pCr--;
1594 //load the bottom two pixels
1595 Y = pY[nextrow];
1596
1597 Cb -= 128;
1598 Cr -= 128;
1599 Cg = Cr * cc1;
1600 Cr *= cc3;
1601
1602 Cg += Cb * cc2;
1603 Cb *= cc4;
1604
1605 tmp0 = (Y >> 8) & 0xFF; //Low endian left pixel
1606 tmp0 += OFFSET_5_1;
1607
1608 tmp1 = tmp0 - (Cg >> 16);
1609 tmp2 = tmp0 + (Cb >> 16);
1610 tmp0 = tmp0 + (Cr >> 16);
1611
1612 tmp0 = clip[tmp0];
1613 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
1614 tmp2 = clip[tmp2];
1615 //RGB_565
1616
1617 rgb = tmp1 | (tmp0 << 6);
1618 rgb = tmp2 | (rgb << 5);
1619 *((pDst + (dst_pitch << 1))) = rgb;
1620 #ifndef INTERPOLATE
1621 *((pDst + (dst_pitch << 1) + 1)) = rgb;
1622 #endif
1623
1624 Y = Y & 0xFF;
1625 Y += OFFSET_5_0;
1626 tmp1 = (Y) - (Cg >> 16);
1627 tmp2 = (Y) + (Cb >> 16);
1628 tmp0 = (Y) + (Cr >> 16);
1629
1630 tmp0 = clip[tmp0];
1631 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
1632 tmp2 = clip[tmp2];
1633 //RGB_565
1634
1635 tmp0 = tmp1 | (tmp0 << 6);
1636 #ifdef INTERPOLATE
1637 tmp02 = tmp2 | (tmp0 << 5);
1638 *(pDst + (dst_pitch << 1) + 2) = tmp02;
1639 *((pDst + (dst_pitch << 1) + 1)) = (((((tmp02 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1640 | ((((((tmp02 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1641 | ((((((tmp02 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1642 pI2 = ((pDst + (dst_pitch << 1) + 3));
1643 #else
1644 tmp0 = tmp2 | (tmp0 << 5);
1645 *(pDst + (dst_pitch << 1) + 2) = tmp0;
1646 *(pDst + (dst_pitch << 1) + 3) = tmp0;
1647 #endif
1648 //load the top two pixels
1649 Y = *pY--;
1650
1651 tmp0 = (Y >> 8) & 0xFF; //Low endian left pixel
1652 //tmp0 = *pY++;
1653 tmp0 += OFFSET_5_0;
1654
1655 tmp1 = tmp0 - (Cg >> 16);
1656 tmp2 = tmp0 + (Cb >> 16);
1657 tmp0 = tmp0 + (Cr >> 16);
1658
1659 tmp0 = clip[tmp0];
1660 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
1661 tmp2 = clip[tmp2];
1662
1663 rgb = tmp1 | (tmp0 << 6);
1664 rgb = tmp2 | (rgb << 5);
1665
1666 *((pDst)) = rgb;
1667 #ifndef INTERPOLATE
1668 *((pDst + 1)) = rgb;
1669 #endif
1670
1671 Y = Y & 0xFF;
1672 Y += OFFSET_5_1;
1673 tmp1 = (Y) - (Cg >> 16);
1674 tmp2 = (Y) + (Cb >> 16);
1675 tmp0 = (Y) + (Cr >> 16);
1676
1677 tmp0 = clip[tmp0];
1678 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
1679 tmp2 = clip[tmp2];
1680
1681 tmp0 = tmp1 | (tmp0 << 6);
1682 #ifdef INTERPOLATE
1683 tmp01 = tmp2 | (tmp0 << 5);
1684 *(pDst + 2) = tmp01;
1685 *((pDst + 1)) = (((((tmp01 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1686 | ((((((tmp01 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1687 | ((((((tmp01 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1688 pU2 = (pDst + 3);
1689 #else
1690 tmp0 = tmp2 | (tmp0 << 5);
1691 *(pDst + 2) = tmp0;
1692 *(pDst + 3) = tmp0;
1693 #endif
1694 pDst += 4;
1695
1696 Cb = *pCb--;
1697 Cr = *pCr--;
1698 //load the bottom two pixels
1699 Y = pY[nextrow];
1700
1701 Cb -= 128;
1702 Cr -= 128;
1703 Cg = Cr * cc1;
1704 Cr *= cc3;
1705
1706 Cg += Cb * cc2;
1707 Cb *= cc4;
1708
1709 tmp0 = (Y >> 8) & 0xFF; //Low endian left pixel
1710 tmp0 += OFFSET_5_1;
1711
1712 tmp1 = tmp0 - (Cg >> 16);
1713 tmp2 = tmp0 + (Cb >> 16);
1714 tmp0 = tmp0 + (Cr >> 16);
1715
1716 tmp0 = clip[tmp0];
1717 tmp1 = clip[tmp1 + OFFSET_6_1- OFFSET_5_1];
1718 tmp2 = clip[tmp2];
1719 //RGB_565
1720
1721 rgb = tmp1 | (tmp0 << 6);
1722 rgb = tmp2 | (rgb << 5);
1723 *((pDst + (dst_pitch << 1))) = rgb;
1724 #ifdef INTERPOLATE
1725 *pI2 = (((((tmp02 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1726 | ((((((tmp02 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1727 | ((((((tmp02 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1728 #else
1729 *((pDst + (dst_pitch << 1) + 1)) = rgb;
1730 #endif
1731 Y = Y & 0xFF;
1732 Y += OFFSET_5_0;
1733 tmp1 = (Y) - (Cg >> 16);
1734 tmp2 = (Y) + (Cb >> 16);
1735 tmp0 = (Y) + (Cr >> 16);
1736
1737 tmp0 = clip[tmp0];
1738 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
1739 tmp2 = clip[tmp2];
1740 //RGB_565
1741
1742 tmp0 = tmp1 | (tmp0 << 6);
1743 #ifdef INTERPOLATE
1744 tmp02 = tmp2 | (tmp0 << 5);
1745 *(pDst + (dst_pitch << 1) + 2) = tmp02;
1746 *((pDst + (dst_pitch << 1) + 1)) = (((((tmp02 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1747 | ((((((tmp02 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1748 | ((((((tmp02 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1749 pI2 = (pDst + (dst_pitch << 1) + 3);
1750 #else
1751 tmp0 = tmp2 | (tmp0 << 5);
1752 *(pDst + (dst_pitch << 1) + 2) = tmp0;
1753 *(pDst + (dst_pitch << 1) + 3) = tmp0;
1754 #endif
1755
1756 //load the top two pixels
1757 Y = *pY--;
1758
1759 tmp0 = (Y >> 8) & 0xFF; //Low endian left pixel
1760 //tmp0 = *pY++;
1761 tmp0 += OFFSET_5_0;
1762
1763 tmp1 = tmp0 - (Cg >> 16);
1764 tmp2 = tmp0 + (Cb >> 16);
1765 tmp0 = tmp0 + (Cr >> 16);
1766
1767 tmp0 = clip[tmp0];
1768 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
1769 tmp2 = clip[tmp2];
1770
1771 rgb = tmp1 | (tmp0 << 6);
1772 rgb = tmp2 | (rgb << 5);
1773
1774 *((pDst)) = rgb;
1775 #ifdef INTERPOLATE
1776 *pU2 = (((((tmp01 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1777 | ((((((tmp01 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1778 | ((((((tmp01 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1779 #else
1780 *((pDst + 1)) = rgb;
1781 #endif
1782
1783 Y = Y & 0xFF;
1784 Y += OFFSET_5_1;
1785 tmp1 = (Y) - (Cg >> 16);
1786 tmp2 = (Y) + (Cb >> 16);
1787 tmp0 = (Y) + (Cr >> 16);
1788
1789 tmp0 = clip[tmp0];
1790 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
1791 tmp2 = clip[tmp2];
1792
1793 tmp0 = tmp1 | (tmp0 << 6);
1794 #ifdef INTERPOLATE
1795 tmp01 = tmp2 | (tmp0 << 5);
1796 *(pDst + 2) = tmp01;
1797 *((pDst + 1)) = (((((tmp01 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1798 | ((((((tmp01 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1799 | ((((((tmp01 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1800 pU2 = (pDst + 3);
1801 #else
1802 tmp0 = tmp2 | (tmp0 << 5);
1803 *(pDst + 2) = tmp0;
1804 *(pDst + 3) = tmp0;
1805 #endif
1806 pDst += 4;
1807
1808 Cb = *pCb--;
1809 Cr = *pCr--;
1810 //load the bottom two pixels
1811 Y = pY[nextrow];
1812
1813 Cb -= 128;
1814 Cr -= 128;
1815 Cg = Cr * cc1;
1816 Cr *= cc3;
1817
1818 Cg += Cb * cc2;
1819 Cb *= cc4;
1820
1821 tmp0 = (Y >> 8) & 0xFF; //Low endian left pixel
1822 tmp0 += OFFSET_5_1;
1823
1824 tmp1 = tmp0 - (Cg >> 16);
1825 tmp2 = tmp0 + (Cb >> 16);
1826 tmp0 = tmp0 + (Cr >> 16);
1827
1828 tmp0 = clip[tmp0];
1829 tmp1 = clip[tmp1 + OFFSET_6_1- OFFSET_5_1];
1830 tmp2 = clip[tmp2];
1831 //RGB_565
1832
1833 rgb = tmp1 | (tmp0 << 6);
1834 rgb = tmp2 | (rgb << 5);
1835 *((pDst + (dst_pitch << 1))) = rgb;
1836 #ifdef INTERPOLATE
1837 *pI2 = (((((tmp02 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1838 | ((((((tmp02 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1839 | ((((((tmp02 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1840 #else
1841 *((pDst + (dst_pitch << 1) + 1)) = rgb;
1842 #endif
1843
1844 Y = Y & 0xFF;
1845 Y += OFFSET_5_0;
1846 tmp1 = (Y) - (Cg >> 16);
1847 tmp2 = (Y) + (Cb >> 16);
1848 tmp0 = (Y) + (Cr >> 16);
1849
1850 tmp0 = clip[tmp0];
1851 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
1852 tmp2 = clip[tmp2];
1853 //RGB_565
1854
1855 tmp0 = tmp1 | (tmp0 << 6);
1856 #ifdef INTERPOLATE
1857 tmp02 = tmp2 | (tmp0 << 5);
1858 *(pDst + (dst_pitch << 1) + 2) = tmp02;
1859 *((pDst + (dst_pitch << 1) + 1)) = (((((tmp02 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1860 | ((((((tmp02 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1861 | ((((((tmp02 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1862 pI2 = (pDst + (dst_pitch << 1) + 3);
1863 #else
1864 tmp0 = tmp2 | (tmp0 << 5);
1865 *(pDst + (dst_pitch << 1) + 2) = tmp0;
1866 *(pDst + (dst_pitch << 1) + 3) = tmp0;
1867 #endif
1868
1869 //load the top two pixels
1870 Y = *pY--;
1871
1872 tmp0 = (Y >> 8) & 0xFF; //Low endian left pixel
1873 //tmp0 = *pY++;
1874 tmp0 += OFFSET_5_0;
1875
1876 tmp1 = tmp0 - (Cg >> 16);
1877 tmp2 = tmp0 + (Cb >> 16);
1878 tmp0 = tmp0 + (Cr >> 16);
1879
1880 tmp0 = clip[tmp0];
1881 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
1882 tmp2 = clip[tmp2];
1883
1884 rgb = tmp1 | (tmp0 << 6);
1885 rgb = tmp2 | (rgb << 5);
1886
1887 *((pDst)) = rgb;
1888 #ifdef INTERPOLATE
1889 *pU2 = (((((tmp01 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1890 | ((((((tmp01 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1891 | ((((((tmp01 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1892 #else
1893 *((pDst + 1)) = rgb;
1894 #endif
1895
1896 Y = Y & 0xFF;
1897 Y += OFFSET_5_1;
1898 tmp1 = (Y) - (Cg >> 16);
1899 tmp2 = (Y) + (Cb >> 16);
1900 tmp0 = (Y) + (Cr >> 16);
1901
1902 tmp0 = clip[tmp0];
1903 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
1904 tmp2 = clip[tmp2];
1905
1906 tmp0 = tmp1 | (tmp0 << 6);
1907 #ifdef INTERPOLATE
1908 tmp01 = tmp2 | (tmp0 << 5);
1909 *(pDst + 2) = tmp01;
1910 *((pDst + 1)) = (((((tmp01 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1911 | ((((((tmp01 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1912 | ((((((tmp01 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1913 pU2 = (pDst + 3);
1914 #else
1915 tmp0 = tmp2 | (tmp0 << 5);
1916 *(pDst + 2) = tmp0;
1917 *(pDst + 3) = tmp0;
1918 #endif
1919 pDst += 4;
1920
1921 Cb = *pCb--;
1922 Cr = *pCr--;
1923 //load the bottom two pixels
1924 Y = pY[nextrow];
1925
1926 Cb -= 128;
1927 Cr -= 128;
1928 Cg = Cr * cc1;
1929 Cr *= cc3;
1930
1931 Cg += Cb * cc2;
1932 Cb *= cc4;
1933
1934 tmp0 = (Y >> 8) & 0xFF; //Low endian left pixel
1935 tmp0 += OFFSET_5_1;
1936
1937 tmp1 = tmp0 - (Cg >> 16);
1938 tmp2 = tmp0 + (Cb >> 16);
1939 tmp0 = tmp0 + (Cr >> 16);
1940
1941 tmp0 = clip[tmp0];
1942 tmp1 = clip[tmp1 + OFFSET_6_1- OFFSET_5_1];
1943 tmp2 = clip[tmp2];
1944 //RGB_565
1945
1946 rgb = tmp1 | (tmp0 << 6);
1947 rgb = tmp2 | (rgb << 5);
1948 *((pDst + (dst_pitch << 1))) = rgb;
1949 #ifdef INTERPOLATE
1950 *pI2 = (((((tmp02 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1951 | ((((((tmp02 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1952 | ((((((tmp02 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1953 #else
1954 *((pDst + (dst_pitch << 1) + 1)) = rgb;
1955 #endif
1956
1957 Y = Y & 0xFF;
1958 Y += OFFSET_5_0;
1959 tmp1 = (Y) - (Cg >> 16);
1960 tmp2 = (Y) + (Cb >> 16);
1961 tmp0 = (Y) + (Cr >> 16);
1962
1963 tmp0 = clip[tmp0];
1964 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
1965 tmp2 = clip[tmp2];
1966 //RGB_565
1967
1968 tmp0 = tmp1 | (tmp0 << 6);
1969 tmp0 = tmp2 | (tmp0 << 5);
1970
1971 *(pDst + (dst_pitch << 1) + 2) = tmp0;
1972 #ifdef INTERPOLATE
1973 *((pDst + (dst_pitch << 1) + 1)) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1974 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1975 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
1976 #endif
1977 //load the top two pixels
1978 Y = *pY--;
1979
1980 tmp0 = (Y >> 8) & 0xFF; //Low endian left pixel
1981 //tmp0 = *pY++;
1982 tmp0 += OFFSET_5_0;
1983
1984 tmp1 = tmp0 - (Cg >> 16);
1985 tmp2 = tmp0 + (Cb >> 16);
1986 tmp0 = tmp0 + (Cr >> 16);
1987
1988 tmp0 = clip[tmp0];
1989 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
1990 tmp2 = clip[tmp2];
1991
1992 rgb = tmp1 | (tmp0 << 6);
1993 rgb = tmp2 | (rgb << 5);
1994
1995 *((pDst)) = rgb;
1996 #ifdef INTERPOLATE
1997 *pU2 = (((((tmp01 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
1998 | ((((((tmp01 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
1999 | ((((((tmp01 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
2000 #else
2001 *((pDst + 1)) = rgb;
2002 #endif
2003
2004 Y = Y & 0xFF;
2005 Y += OFFSET_5_1;
2006 tmp1 = (Y) - (Cg >> 16);
2007 tmp2 = (Y) + (Cb >> 16);
2008 tmp0 = (Y) + (Cr >> 16);
2009
2010 tmp0 = clip[tmp0];
2011 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
2012 tmp2 = clip[tmp2];
2013
2014 tmp0 = tmp1 | (tmp0 << 6);
2015 tmp0 = tmp2 | (tmp0 << 5);
2016
2017 *(pDst + 2) = tmp0;
2018 #ifdef INTERPOLATE
2019 *((pDst + 1)) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
2020 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
2021 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
2022 #endif
2023 pDst += 3;
2024
2025 }//end of COL
2026
2027 pY += (deltaY >> 1);
2028 pCb += deltaCbCr;
2029 pCr += deltaCbCr;
2030
2031 pDst -= (disp[4]);
2032 #ifdef INTERPOLATE
2033 /* vertically - 1 1' 2 2' 3 3' 4 4' 5 5' 6 6' 7 7' 8 1 1'2 2'........*/
2034 if ((row & 0x7))
2035 {
2036 pIn = pDst - dst_pitch;
2037 pNext = pIn - dst_pitch;
2038 for (i = 0; i < disp[4]; i++)
2039 {
2040 int32 curr = pDst[i];
2041 int32 below = pNext[i];
2042 pIn[i] = (((((curr & 0x1F) + (below & 0x1F)) / 2) & 0x1F)
2043 | ((((((curr >> 5) & 0x3F) + ((below >> 5) & 0x3F)) / 2) & 0x3F) << 5)
2044 | ((((((curr >> 11) & 0x1F) + ((below >> 11) & 0x1F)) / 2) & 0x1F) << 11));
2045 }
2046 offset++;
2047 }
2048
2049 pNext = pDst + (dst_pitch * 2);
2050 pIn = pDst + dst_pitch;
2051 for (i = 0; i < disp[4]; i++)
2052 {
2053 int32 curr = pDst[i];
2054 int32 below = pNext[i];
2055 pIn[i] = (((((curr & 0x1F) + (below & 0x1F)) / 2) & 0x1F)
2056 | ((((((curr >> 5) & 0x3F) + ((below >> 5) & 0x3F)) / 2) & 0x3F) << 5)
2057 | ((((((curr >> 11) & 0x1F) + ((below >> 11) & 0x1F)) / 2) & 0x1F) << 11));
2058 }
2059
2060 if (offset == 3)
2061 {
2062 pDst = pNext + dst_pitch;
2063 offset = 0;
2064 }
2065 else
2066 pDst = pNext + dst_pitch * 2;
2067 #else
2068 oscl_memcpy(pDst + dst_pitch, pDst, (disp[4] << 1));
2069 pDst += (dst_pitch << 1);
2070
2071 if (row & 0x7)
2072 {
2073 oscl_memcpy(pDst + dst_pitch, pDst, (disp[4] << 1));
2074 pDst += dst_pitch; //coz pDst defined as UINT *
2075 }
2076 pDst += dst_pitch;
2077 #endif
2078 }
2079 }
2080
2081 return 1;
2082 #else
2083 OSCL_UNUSED_ARG(src);
2084 OSCL_UNUSED_ARG(dst);
2085 OSCL_UNUSED_ARG(disp);
2086 OSCL_UNUSED_ARG(coeff_tbl);
2087 return 0;
2088 #endif // CCSCALING
2089 }
2090 #endif
2091
2092 /* special function when scale down in width */
cc16scaledown(uint8 ** src,uint8 * dst,int32 * disp,uint8 * coff_tbl,uint8 * _mRowPix,uint8 * _mColPix)2093 int32 cc16scaledown(uint8 **src, uint8 *dst, int32 *disp,
2094 uint8 *coff_tbl, uint8 *_mRowPix, uint8 *_mColPix)
2095 {
2096 #if CCSCALING
2097 /* 1. move the dst pointer to the line above the border
2098 2. do 2 line conversion
2099 3. copy both up & down
2100 */
2101 uint8 *pCb, *pCr;
2102 uint8 *pY;
2103 uint16 *pDst;
2104 int32 src_pitch, dst_pitch, src_width;
2105 int32 Y, Cb, Cr, Cg;
2106 int32 deltaY, dst_width, deltaCbCr, src_inc;
2107 int32 row, col;
2108 int32 tmp0, tmp1, tmp2;
2109 uint8 *clip = coff_tbl + 400;
2110 uint8 *rowpix, *colpix;
2111 int32 cc1 = (*((int32*)(clip - 400)));
2112 int32 cc3 = (*((int32*)(clip - 396)));
2113 int32 cc2 = (*((int32*)(clip - 392)));
2114 int32 cc4 = (*((int32*)(clip - 388)));
2115
2116 src_pitch = disp[0];
2117 dst_pitch = disp[1];
2118 src_width = disp[2];
2119
2120
2121 if (((disp[6] == 0) && (disp[7] == 1)) || ((disp[6] == 1) && (disp[7] == 0))) // rotate 0 and flip || // rotate 180 and no flip
2122 {
2123 if (disp[6])/* rotation 180 only */
2124 {
2125 /* move the starting point to the bottom-right corner of the picture */
2126 deltaY = src_pitch * (disp[3] - 1);
2127 pY = (src[0] + deltaY + src_width - 2);
2128 deltaY = (src_pitch >> 1) * ((disp[3] >> 1) - 1);
2129 pCb = src[1] + deltaY + (src_width >> 1) - 1;
2130 pCr = src[2] + deltaY + (src_width >> 1) - 1;
2131 deltaY = src_width - (src_pitch << 1);
2132 deltaCbCr = (src_width - src_pitch) >> 1;
2133 src_pitch = -src_pitch;
2134 }
2135 else /* flip only */
2136 {
2137 /* move the starting point to the top-right corner of the picture */
2138 pY = (src[0] + src_width - 2);
2139 pCb = src[1] + (src_width >> 1) - 1;
2140 pCr = src[2] + (src_width >> 1) - 1;
2141 deltaY = src_width + (src_pitch << 1);
2142 deltaCbCr = (src_width + src_pitch) >> 1;
2143 }
2144
2145 src_inc = -1;
2146 }
2147 else // rotate 180 and flip || no rotate, no flip
2148 {
2149 if (disp[6]) // rotate 180 and flip
2150 {
2151 /* move the starting point to the bottom-left corner of the picture */
2152 deltaY = src_pitch * (disp[3] - 1);
2153 pY = src[0] + deltaY;
2154 deltaY = (src_pitch >> 1) * ((disp[3] >> 1) - 1);
2155 pCb = src[1] + deltaY;
2156 pCr = src[2] + deltaY;
2157 deltaY = -src_width - (src_pitch << 1);
2158 deltaCbCr = -((src_width + src_pitch) >> 1);
2159 src_pitch = - src_pitch;
2160 }
2161 else // no rotate, no flip
2162 {
2163 deltaY = (src_pitch << 1) - src_width;
2164 deltaCbCr = (src_pitch - src_width) >> 1;
2165 dst_width = disp[4];
2166 pY = src[0];
2167 pCb = src[1];
2168 pCr = src[2];
2169 }
2170
2171 src_inc = 1;
2172 }
2173
2174 pDst = (uint16 *)dst;
2175
2176 colpix = _mColPix + disp[3] - 1;
2177
2178 for (row = disp[3] - 1; row >= 0; row -= 2)
2179 {/* decrement index, _mColPix[.] is
2180 symmetric to increment index */
2181 if (colpix[-1] + colpix[0] == 0)
2182 {
2183 pCb += (src_pitch >> 1);
2184 pCr += (src_pitch >> 1);
2185 pY += (src_pitch << 1);
2186 colpix -= 2;
2187 continue;
2188 }
2189
2190 rowpix = _mRowPix + src_width - 1;
2191
2192 if (colpix[-1] + colpix[0] == 1) // one line not skipped
2193 {
2194 for (col = src_width - 2; col >= 0; col -= 2)
2195 { /* decrement index, _mRowPix[.] is
2196 symmetric to increment index */
2197
2198 Cb = *pCb;
2199 (pCb += src_inc);
2200 Cr = *pCr;
2201 (pCr += src_inc);
2202
2203 Cb -= 128;
2204 Cr -= 128;
2205 Cg = Cr * cc1;
2206 Cr *= cc3;
2207
2208 Cg += Cb * cc2;
2209 Cb *= cc4;
2210
2211 if (*rowpix) /* compute this pixel */
2212 {
2213 Y = *pY;
2214 (pY += src_inc); //upper left
2215
2216 tmp1 = Y - (Cg >> 16);
2217 tmp2 = Y + (Cb >> 16);
2218 tmp0 = Y + (Cr >> 16);
2219
2220 tmp0 = clip[tmp0];
2221 tmp1 = clip[tmp1 + 1024];
2222 tmp2 = clip[tmp2];
2223
2224 //RGB_565
2225 tmp0 = tmp1 | (tmp0 << 6);
2226 tmp0 = tmp2 | (tmp0 << 5);
2227
2228 *(pDst) = (uint16)tmp0;
2229
2230 }
2231 else /* if(_mRowPix[col]) */
2232 {
2233 pY += src_inc;
2234 }
2235 pDst += *rowpix--;
2236
2237 if (*rowpix) /* compute this pixel */
2238 {
2239 Y = *pY;
2240 (pY += src_inc); //upper right
2241
2242 tmp1 = Y - (Cg >> 16);
2243 tmp2 = Y + (Cb >> 16);
2244 tmp0 = Y + (Cr >> 16);
2245
2246 tmp0 = clip[tmp0];
2247 tmp1 = clip[tmp1 + 1024];
2248 tmp2 = clip[tmp2];
2249
2250 tmp0 = tmp1 | (tmp0 << 6);
2251 tmp0 = tmp2 | (tmp0 << 5);
2252
2253 *(pDst) = (uint16)tmp0;
2254 }
2255 else /* if(_mRowPix[col+1]) */
2256 {
2257 pY += src_inc;
2258 }
2259
2260 pDst += *rowpix--;
2261 }//end of COL
2262
2263 } // one line not skipped
2264
2265 else //both lines not skipped
2266
2267 {
2268 for (col = src_width - 2; col >= 0; col -= 2)
2269 { /* decrement index, _mRowPix[.] is
2270 symmetric to increment index */
2271
2272 Cb = *pCb;
2273 (pCb += src_inc);
2274 Cr = *pCr;
2275 (pCr += src_inc);
2276
2277 Cb -= 128;
2278 Cr -= 128;
2279 Cg = Cr * cc1;
2280 Cr *= cc3;
2281
2282 Cg += Cb * cc2;
2283 Cb *= cc4;
2284
2285 if (*rowpix) /* compute this pixel */
2286 {
2287 Y = pY[src_pitch]; //lower left
2288
2289 Y += OFFSET_5_1;
2290 tmp1 = Y - (Cg >> 16);
2291 tmp2 = Y + (Cb >> 16);
2292 tmp0 = Y + (Cr >> 16);
2293
2294 tmp0 = clip[tmp0];
2295 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
2296 tmp2 = clip[tmp2];
2297
2298 //RGB_565
2299 tmp0 = tmp1 | (tmp0 << 6);
2300 tmp0 = tmp2 | (tmp0 << 5);
2301
2302 *(pDst + dst_pitch) = (uint16)tmp0;
2303
2304 Y = *pY;
2305 (pY += src_inc); //upper left
2306
2307 Y += OFFSET_5_0;
2308 tmp1 = Y - (Cg >> 16);
2309 tmp2 = Y + (Cb >> 16);
2310 tmp0 = Y + (Cr >> 16);
2311
2312 tmp0 = clip[tmp0];
2313 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
2314 tmp2 = clip[tmp2];
2315
2316 //RGB_565
2317 tmp0 = tmp1 | (tmp0 << 6);
2318 tmp0 = tmp2 | (tmp0 << 5);
2319
2320 *(pDst) = (uint16)tmp0;
2321
2322 }
2323 else /* if(_mRowPix[col]) */
2324 {
2325 pY += src_inc;
2326 }
2327 pDst += *rowpix--;
2328
2329 if (*rowpix) /* compute this pixel */
2330 {
2331 Y = pY[src_pitch]; //lower left
2332
2333 Y += OFFSET_5_0;
2334 tmp1 = Y - (Cg >> 16);
2335 tmp2 = Y + (Cb >> 16);
2336 tmp0 = Y + (Cr >> 16);
2337
2338 tmp0 = clip[tmp0];
2339 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
2340 tmp2 = clip[tmp2];
2341
2342 //RGB_565
2343 tmp0 = tmp1 | (tmp0 << 6);
2344 tmp0 = tmp2 | (tmp0 << 5);
2345
2346 *(pDst + dst_pitch) = (uint16)tmp0;
2347
2348 Y = *pY;
2349 (pY += src_inc); //upper right
2350
2351 Y += OFFSET_5_1;
2352 tmp1 = Y - (Cg >> 16);
2353 tmp2 = Y + (Cb >> 16);
2354 tmp0 = Y + (Cr >> 16);
2355
2356 tmp0 = clip[tmp0];
2357 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
2358 tmp2 = clip[tmp2];
2359
2360 tmp0 = tmp1 | (tmp0 << 6);
2361 tmp0 = tmp2 | (tmp0 << 5);
2362
2363 *(pDst) = (uint16)tmp0;
2364 }
2365 else /* if(_mRowPix[col+1]) */
2366 {
2367 pY += src_inc;
2368 }
2369
2370 pDst += *rowpix--;
2371 }//end of COL
2372
2373 pDst += dst_pitch;
2374
2375 }
2376
2377 pY += (deltaY);
2378 pCb += deltaCbCr;
2379 pCr += deltaCbCr;
2380
2381 pDst += dst_pitch - disp[4];
2382 colpix -= 2;
2383
2384 }
2385
2386 return 1;
2387 #else
2388 OSCL_UNUSED_ARG(src);
2389 OSCL_UNUSED_ARG(dst);
2390 OSCL_UNUSED_ARG(disp);
2391 OSCL_UNUSED_ARG(coff_tbl);
2392 OSCL_UNUSED_ARG(_mRowPix);
2393 OSCL_UNUSED_ARG(_mColPix);
2394 return 0;
2395 #endif // CCSCALING
2396 }
2397
2398 /* special scaling by one-half */
cc16scalingHalf(uint8 ** src,uint8 * dst,int32 * disp,uint8 * coff_tbl)2399 int32 cc16scalingHalf(uint8 **src, uint8 *dst, int32 *disp, uint8 *coff_tbl)
2400 {
2401 #if CCSCALING
2402 uint8 *pCb, *pCr;
2403 uint16 *pY;
2404 uint16 *pDst;
2405 int32 src_pitch, dst_pitch, src_width, nextrow;
2406 int32 Y, Cb, Cr, Cg;
2407 int32 deltaY, deltaCbCr;
2408 int32 row, col;
2409 int32 tmp0, tmp1, tmp2;
2410 uint32 rgb;
2411 uint8 *clip = coff_tbl + 400;
2412 int32 cc1 = (*((int32*)(clip - 400)));
2413 int32 cc3 = (*((int32*)(clip - 396)));
2414 int32 cc2 = (*((int32*)(clip - 392)));
2415 int32 cc4 = (*((int32*)(clip - 388)));
2416
2417 src_pitch = disp[0];
2418 dst_pitch = disp[1];
2419 src_width = disp[2];
2420
2421 if (((disp[6] == 1) && (disp[7] == 1)) || ((disp[6] == 0) && (disp[7] == 0)))
2422 {
2423 if (disp[6])/* rotate 180 and flip */
2424 { /* move the starting point to the bottom-left corner of the picture */
2425 deltaY = src_pitch * (disp[3] - 1);
2426 pY = (uint16*)(src[0] + deltaY);
2427 deltaY = (src_pitch >> 1) * ((disp[3] >> 1) - 1);
2428 pCb = src[1] + deltaY;
2429 pCr = src[2] + deltaY;
2430 deltaY = -src_width - (src_pitch << 1);
2431 deltaCbCr = -((src_width + src_pitch) >> 1);
2432 src_pitch = -(src_pitch >> 1);
2433 }
2434 else // no rotate,no flip
2435 {
2436 deltaY = (src_pitch << 1) - src_width;
2437 deltaCbCr = (src_pitch - src_width) >> 1;
2438 pY = (uint16 *) src[0];
2439 src_pitch >>= 1;
2440 pCb = src[1];
2441 pCr = src[2];
2442 }
2443
2444 pDst = (uint16 *)dst;
2445
2446 for (row = 0; row < disp[3] - 1; row += 2)
2447 {
2448 for (col = 0; col <= src_width - 1; col += 2)
2449 {
2450 Cb = *pCb++;
2451 Cr = *pCr++;
2452 Y = *pY++;
2453
2454 Cb -= 128;
2455 Cr -= 128;
2456 Cg = Cr * cc1;
2457 Cr *= cc3;
2458
2459 Cg += Cb * cc2;
2460 Cb *= cc4;
2461 tmp0 = Y & 0xFF; //Low endian left pixel
2462 tmp1 = tmp0 - (Cg >> 16);
2463 tmp2 = tmp0 + (Cb >> 16);
2464 tmp0 = tmp0 + (Cr >> 16);
2465
2466 tmp0 = clip[tmp0];
2467 tmp1 = clip[tmp1 + 1024];
2468 tmp2 = clip[tmp2];
2469
2470
2471 rgb = tmp1 | (tmp0 << 6);
2472 rgb = tmp2 | (rgb << 5);
2473
2474 *pDst++ = rgb;
2475 }//end of COL
2476
2477 pY += (deltaY >> 1);
2478 pCb += deltaCbCr;
2479 pCr += deltaCbCr;
2480 pDst -= (disp[4]);
2481 pDst += dst_pitch;
2482 }
2483 }
2484 else
2485 {
2486 if (disp[6])/* rotation 180 only */
2487 {
2488 /* move the starting point to the bottom-right corner of the picture */
2489 nextrow = src_pitch * (disp[3] - 1);
2490 pY = (uint16*)(src[0] + nextrow + src_width - 2);
2491 nextrow = (src_pitch >> 1) * ((disp[3] >> 1) - 1);
2492 pCb = src[1] + nextrow + (src_width >> 1) - 1;
2493 pCr = src[2] + nextrow + (src_width >> 1) - 1;
2494 nextrow = -(src_pitch >> 1);
2495 deltaY = src_width - (src_pitch << 1);
2496 deltaCbCr = (src_width - src_pitch) >> 1;
2497 }
2498 else /* flip only */
2499 {
2500 /* move the starting point to the top-right corner of the picture */
2501 pY = (uint16 *)(src[0] + src_width - 2);
2502 pCb = src[1] + (src_width >> 1) - 1;
2503 pCr = src[2] + (src_width >> 1) - 1;
2504 nextrow = src_pitch >> 1;
2505 deltaY = src_width + (src_pitch << 1);
2506 deltaCbCr = (src_width + src_pitch) >> 1;
2507 }
2508 pDst = (uint16 *)dst;
2509 for (row = 0; row < disp[3] - 1; row += 2)
2510 {
2511 for (col = 0; col <= src_width - 1; col += 2)
2512 {
2513 Cb = *pCb--;
2514 Cr = *pCr--;
2515 Y = *pY--;
2516
2517 Cb -= 128;
2518 Cr -= 128;
2519 Cg = Cr * cc1;
2520 Cr *= cc3;
2521
2522 Cg += Cb * cc2;
2523 Cb *= cc4;
2524 tmp0 = Y & 0xFF; //Low endian left pixel
2525 tmp1 = tmp0 - (Cg >> 16);
2526 tmp2 = tmp0 + (Cb >> 16);
2527 tmp0 = tmp0 + (Cr >> 16);
2528
2529 tmp0 = clip[tmp0];
2530 tmp1 = clip[tmp1 + 1024];
2531 tmp2 = clip[tmp2];
2532
2533 rgb = tmp1 | (tmp0 << 6);
2534 rgb = tmp2 | (rgb << 5);
2535
2536 *pDst++ = rgb;
2537 }//end of COL
2538
2539 pY += (deltaY >> 1);
2540 pCb += deltaCbCr;
2541 pCr += deltaCbCr;
2542
2543 pDst -= (disp[4]);
2544 pDst += dst_pitch;
2545 }
2546 }
2547
2548 return 1;
2549 #else
2550 OSCL_UNUSED_ARG(src);
2551 OSCL_UNUSED_ARG(dst);
2552 OSCL_UNUSED_ARG(disp);
2553 OSCL_UNUSED_ARG(coff_tbl);
2554 return 0;
2555 #endif // CCSCALING
2556 }
2557
2558
2559 /* special 3:4 scale-down color conversion */
cc16scaling34(uint8 ** src,uint8 * dst,int32 * disp,uint8 * coff_tbl)2560 int32 cc16scaling34(uint8 **src, uint8 *dst,
2561 int32 *disp, uint8 *coff_tbl)
2562 {
2563 #if CCSCALING
2564 uint8 *pCb, *pCr;
2565 uint16 *pY;
2566 uint16 *pDst;
2567 int32 src_pitch, dst_pitch, src_width;
2568 int32 Y, Cb, Cr, Cg;
2569 int32 deltaY, deltaDst, deltaCbCr;
2570 int32 row, col;
2571 int32 tmp0, tmp1, tmp2;
2572 uint32 rgb;
2573 uint8 *clip = coff_tbl + 400;
2574 int32 cc1 = (*((int32*)(clip - 400)));
2575 int32 cc3 = (*((int32*)(clip - 396)));
2576 int32 cc2 = (*((int32*)(clip - 392)));
2577 int32 cc4 = (*((int32*)(clip - 388)));
2578
2579 src_pitch = disp[0];
2580 dst_pitch = disp[1];
2581 src_width = disp[2];
2582
2583 if (((disp[6] == 0) && (disp[7] == 1)) || ((disp[6] == 1) && (disp[7] == 0))) /* rotate 180 and no flip, rotate 0 and flip *///Ankur
2584 {
2585 if (disp[6] == 0)
2586 {
2587 deltaY = (src_pitch << 1) - src_width;
2588 deltaCbCr = (src_pitch - src_width) >> 1;
2589 pY = (uint16 *) src[0];
2590 src_pitch >>= 1;
2591 pCb = src[1];
2592 pCr = src[2];
2593 }
2594 else
2595 {
2596 /* move the starting point to the bottom-left corner of the picture */
2597 deltaY = src_pitch * (disp[3] - 1);
2598 pY = (uint16*)(src[0] + deltaY);
2599 deltaY = (src_pitch >> 1) * ((disp[3] >> 1) - 1);
2600 pCb = src[1] + deltaY;
2601 pCr = src[2] + deltaY;
2602 deltaY = -src_width - (src_pitch << 1);
2603 deltaCbCr = -((src_width + src_pitch) >> 1);
2604 src_pitch = -(src_pitch >> 1);
2605 }
2606
2607 pDst = (uint16 *)dst + disp[4] - 1;
2608 deltaDst = (dst_pitch << 1) + disp[4]; /* disp[4] is dst_width */
2609
2610 for (row = disp[3]; row > 0; row -= 2)
2611 {
2612
2613 for (col = src_width - 1; col >= 0; col -= 4) /* do 8 pixels at a time, 4 ups 4 downs */
2614 {
2615
2616 Cb = *pCb++;
2617 Cr = *pCr++;
2618 Cb -= 128;
2619 Cr -= 128;
2620 Cg = Cr * cc1;
2621 Cr *= cc3;
2622
2623 Cg += Cb * cc2;
2624 Cb *= cc4;
2625
2626 if (!(row&0x2)) /* do the bottom row every other times */
2627 {
2628 //load the bottom two pixels
2629 Y = pY[src_pitch];
2630
2631 tmp0 = Y & 0xFF; //Low endian left pixel
2632 tmp0 += OFFSET_5_0;
2633
2634 tmp1 = tmp0 - (Cg >> 16);
2635 tmp2 = tmp0 + (Cb >> 16);
2636 tmp0 = tmp0 + (Cr >> 16);
2637
2638 tmp0 = clip[tmp0];
2639 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
2640 tmp2 = clip[tmp2];
2641 //RGB_565
2642
2643 rgb = tmp1 | (tmp0 << 6);
2644 rgb = tmp2 | (rgb << 5);
2645 *(pDst + dst_pitch) = rgb; /* save left pixel, have to save separately */
2646
2647 Y >>= 8;
2648 Y += OFFSET_5_1;
2649 tmp1 = (Y) - (Cg >> 16);
2650 tmp2 = (Y) + (Cb >> 16);
2651 tmp0 = (Y) + (Cr >> 16);
2652
2653 tmp0 = clip[tmp0];
2654 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
2655 tmp2 = clip[tmp2];
2656 //RGB_565
2657 tmp0 = tmp1 | (tmp0 << 6);
2658 tmp0 = tmp2 | (tmp0 << 5);
2659
2660 *(pDst + dst_pitch - 1) = tmp0; /* save right pixel */
2661 }
2662 //load the top two pixels
2663 Y = *pY++;
2664
2665 tmp0 = Y & 0xFF; //Low endian left pixel
2666 tmp0 += OFFSET_5_1;
2667
2668 tmp1 = tmp0 - (Cg >> 16);
2669 tmp2 = tmp0 + (Cb >> 16);
2670 tmp0 = tmp0 + (Cr >> 16);
2671
2672 tmp0 = clip[tmp0];
2673 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
2674 tmp2 = clip[tmp2];
2675
2676 rgb = tmp1 | (tmp0 << 6);
2677 rgb = tmp2 | (rgb << 5);
2678 *pDst-- = rgb; /* save left pixel */
2679
2680 Y >>= 8;
2681
2682 Y += OFFSET_5_0;
2683 tmp1 = (Y) - (Cg >> 16);
2684 tmp2 = (Y) + (Cb >> 16);
2685 tmp0 = (Y) + (Cr >> 16);
2686
2687 tmp0 = clip[tmp0];
2688 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
2689 tmp2 = clip[tmp2];
2690
2691 tmp0 = tmp1 | (tmp0 << 6);
2692 tmp0 = tmp2 | (tmp0 << 5);
2693
2694 *pDst-- = tmp0; /* save right pixel */
2695
2696 /* now do another 4 pixels but drop 2 pixels in the last column */
2697 Cb = *pCb++;
2698 Cr = *pCr++;
2699 Cb -= 128;
2700 Cr -= 128;
2701 Cg = Cr * cc1;
2702 Cr *= cc3;
2703
2704 Cg += Cb * cc2;
2705 Cb *= cc4;
2706 //load the bottom two pixels
2707 if (!(row&0x2)) /* do the bottom row every other times */
2708 {
2709 Y = pY[src_pitch];
2710
2711 tmp0 = Y & 0xFF; //Low endian left pixel
2712 tmp0 += OFFSET_5_0;
2713
2714 tmp1 = tmp0 - (Cg >> 16);
2715 tmp2 = tmp0 + (Cb >> 16);
2716 tmp0 = tmp0 + (Cr >> 16);
2717
2718 tmp0 = clip[tmp0];
2719 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
2720 tmp2 = clip[tmp2];
2721 //RGB_565
2722
2723 rgb = tmp1 | (tmp0 << 6);
2724 rgb = tmp2 | (rgb << 5);
2725
2726 *(pDst + dst_pitch) = rgb; /* save only one pixel, 2 bytes */
2727 }
2728 //load the top two pixels
2729 Y = *pY++;
2730
2731 tmp0 = Y & 0xFF; //Low endian left pixel
2732 tmp0 += OFFSET_5_1;
2733
2734 tmp1 = tmp0 - (Cg >> 16);
2735 tmp2 = tmp0 + (Cb >> 16);
2736 tmp0 = tmp0 + (Cr >> 16);
2737
2738 tmp0 = clip[tmp0];
2739 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
2740 tmp2 = clip[tmp2];
2741
2742 rgb = tmp1 | (tmp0 << 6);
2743 rgb = tmp2 | (rgb << 5);
2744
2745 *pDst = rgb;
2746 pDst--; /* save only one pixel, 2 bytes */
2747 }//end of COL
2748
2749 pY += (deltaY >> 1);
2750 pCb += deltaCbCr;
2751 pCr += deltaCbCr;
2752 pDst += (deltaDst); //coz pDst defined as UINT *
2753 if (row&0x2)
2754 {
2755 pDst -= dst_pitch;
2756 }
2757 }
2758 }
2759 else /* rotate 180 and flip || no rotation,no flip*/
2760 {
2761 if (disp[6]) /* rotate 180 and flip */
2762 {
2763 /* move the starting point to the bottom-left corner of the picture */
2764 deltaY = src_pitch * (disp[3] - 1);
2765 pY = (uint16*)(src[0] + deltaY);
2766 deltaY = (src_pitch >> 1) * ((disp[3] >> 1) - 1);
2767 pCb = src[1] + deltaY;
2768 pCr = src[2] + deltaY;
2769 deltaY = -src_width - (src_pitch << 1);
2770 deltaCbCr = -((src_width + src_pitch) >> 1);
2771 src_pitch = -(src_pitch >> 1);
2772 }
2773 else // no rotation,no flip
2774 {
2775 deltaY = (src_pitch << 1) - src_width;
2776 deltaCbCr = (src_pitch - src_width) >> 1;
2777 pY = (uint16 *) src[0];
2778 src_pitch >>= 1;
2779 pCb = src[1];
2780 pCr = src[2];
2781 }
2782
2783 deltaDst = (dst_pitch << 1) - disp[4]; /* disp[4] is dst_width */
2784 pDst = (uint16 *)dst;
2785
2786 for (row = disp[3]; row > 0; row -= 2)
2787 {
2788
2789 for (col = src_width - 1; col >= 0; col -= 4) /* do 8 pixels at a time, 4 ups 4 downs */
2790 {
2791
2792 Cb = *pCb++;
2793 Cr = *pCr++;
2794 Cb -= 128;
2795 Cr -= 128;
2796 Cg = Cr * cc1;
2797 Cr *= cc3;
2798
2799 Cg += Cb * cc2;
2800 Cb *= cc4;
2801
2802 if (!(row&0x2)) /* do the bottom row every other times */
2803 { //load the bottom two pixels
2804 Y = pY[src_pitch];
2805
2806 tmp0 = Y & 0xFF; //Low endian left pixel
2807 tmp0 += OFFSET_5_0;
2808
2809 tmp1 = tmp0 - (Cg >> 16);
2810 tmp2 = tmp0 + (Cb >> 16);
2811 tmp0 = tmp0 + (Cr >> 16);
2812
2813 tmp0 = clip[tmp0];
2814 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
2815 tmp2 = clip[tmp2];
2816 //RGB_565
2817
2818 rgb = tmp1 | (tmp0 << 6);
2819 rgb = tmp2 | (rgb << 5);
2820 *(pDst + dst_pitch) = rgb; /* save left pixel, have to save separately */
2821
2822 Y >>= 8;
2823 Y += OFFSET_5_1;
2824 tmp1 = (Y) - (Cg >> 16);
2825 tmp2 = (Y) + (Cb >> 16);
2826 tmp0 = (Y) + (Cr >> 16);
2827
2828 tmp0 = clip[tmp0];
2829 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
2830 tmp2 = clip[tmp2];
2831 //RGB_565
2832 tmp0 = tmp1 | (tmp0 << 6);
2833 tmp0 = tmp2 | (tmp0 << 5);
2834
2835 *(pDst + dst_pitch + 1) = tmp0; /* save right pixel */
2836 }
2837 //load the top two pixels
2838 Y = *pY++;
2839
2840 tmp0 = Y & 0xFF; //Low endian left pixel
2841 tmp0 += OFFSET_5_1;
2842
2843 tmp1 = tmp0 - (Cg >> 16);
2844 tmp2 = tmp0 + (Cb >> 16);
2845 tmp0 = tmp0 + (Cr >> 16);
2846
2847 tmp0 = clip[tmp0];
2848 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
2849 tmp2 = clip[tmp2];
2850
2851
2852 rgb = tmp1 | (tmp0 << 6);
2853 rgb = tmp2 | (rgb << 5);
2854 *pDst++ = rgb; /* save left pixel */
2855
2856 Y >>= 8;
2857 Y += OFFSET_5_0;
2858 tmp1 = (Y) - (Cg >> 16);
2859 tmp2 = (Y) + (Cb >> 16);
2860 tmp0 = (Y) + (Cr >> 16);
2861
2862 tmp0 = clip[tmp0];
2863 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
2864 tmp2 = clip[tmp2];
2865
2866 tmp0 = tmp1 | (tmp0 << 6);
2867 tmp0 = tmp2 | (tmp0 << 5);
2868
2869 *pDst++ = tmp0; /* save right pixel */
2870
2871 /* now do another 4 pixels but drop 2 pixels in the last column */
2872 Cb = *pCb++;
2873 Cr = *pCr++;
2874 Cb -= 128;
2875 Cr -= 128;
2876 Cg = Cr * cc1;
2877 Cr *= cc3;
2878
2879 Cg += Cb * cc2;
2880 Cb *= cc4;
2881 //load the bottom two pixels
2882 if (!(row&0x2)) /* do the bottom row every other times */
2883 {
2884 Y = pY[src_pitch];
2885
2886 tmp0 = Y & 0xFF; //Low endian left pixel
2887 tmp0 += OFFSET_5_0;
2888
2889 tmp1 = tmp0 - (Cg >> 16);
2890 tmp2 = tmp0 + (Cb >> 16);
2891 tmp0 = tmp0 + (Cr >> 16);
2892
2893 tmp0 = clip[tmp0];
2894 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
2895 tmp2 = clip[tmp2];
2896 //RGB_565
2897
2898 rgb = tmp1 | (tmp0 << 6);
2899 rgb = tmp2 | (rgb << 5);
2900
2901 *(pDst + dst_pitch) = rgb; /* save only one pixel, 2 bytes */
2902 }
2903 //load the top two pixels
2904 Y = *pY++;
2905
2906 tmp0 = Y & 0xFF; //Low endian left pixel
2907 tmp0 += OFFSET_5_1;
2908
2909 tmp1 = tmp0 - (Cg >> 16);
2910 tmp2 = tmp0 + (Cb >> 16);
2911 tmp0 = tmp0 + (Cr >> 16);
2912
2913 tmp0 = clip[tmp0];
2914 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
2915 tmp2 = clip[tmp2];
2916
2917 rgb = tmp1 | (tmp0 << 6);
2918 rgb = tmp2 | (rgb << 5);
2919
2920 *pDst = rgb;
2921 pDst++; /* save only one pixel, 2 bytes */
2922 }//end of COL
2923
2924 pY += (deltaY >> 1);
2925 pCb += deltaCbCr;
2926 pCr += deltaCbCr;
2927 pDst += (deltaDst); //coz pDst defined as UINT *
2928 if (row&0x2)
2929 {
2930 pDst -= dst_pitch;
2931 }
2932 }
2933 }
2934 return 1;
2935 #else
2936 OSCL_UNUSED_ARG(src);
2937 OSCL_UNUSED_ARG(dst);
2938 OSCL_UNUSED_ARG(disp);
2939 OSCL_UNUSED_ARG(coff_tbl);
2940 return 0;
2941 #endif // CCSCALING
2942 }
2943
2944
cc16scaleup(uint8 ** src,uint8 * dst,int32 * disp,uint8 * coff_tbl,uint8 * _mRowPix,uint8 * _mColPix)2945 int32 cc16scaleup(uint8 **src, uint8 *dst, int32 *disp,
2946 uint8 *coff_tbl, uint8 *_mRowPix, uint8 *_mColPix)
2947 {
2948 #if CCSCALING
2949 /* 1. move the dst pointer to the line above the border
2950 2. do 2 line conversion
2951 3. copy both up & down
2952 */
2953 uint8 *pCb, *pCr;
2954 uint16 *pY;
2955 uint16 *pDst;
2956 int32 src_pitch, dst_pitch, src_width;
2957 int32 Y, Cb, Cr, Cg;
2958 int32 deltaY, dst_width, deltaCbCr;
2959 int32 row, col;
2960 int32 tmp0, tmp1, tmp2, temp;
2961 uint32 rgb;
2962 uint8 *clip = coff_tbl + 400;
2963 int32 offset;
2964 uint8 *rowpix, *colpix;
2965 int32 cc1 = (*((int32*)(clip - 400)));
2966 int32 cc3 = (*((int32*)(clip - 396)));
2967 int32 cc2 = (*((int32*)(clip - 392)));
2968 int32 cc4 = (*((int32*)(clip - 388)));
2969
2970 src_pitch = disp[0];
2971 dst_pitch = disp[1];
2972 src_width = disp[2];
2973
2974 #ifdef INTERPOLATE
2975 int i;
2976 uint32 copyline = 0; //maru
2977 uint16 *prev_pDst = 0; //maru
2978 int32 prev_offset = 0; //maru
2979 #endif
2980
2981 if (((disp[6] == 0) && (disp[7] == 1)) || ((disp[6] == 1) && (disp[7] == 0))) /* rotate 180 and no flip || rotate 0 and with flip */ //Ankur
2982 {
2983 if (disp[6] == 0) /*rotate 0 and with flip */
2984 pDst = (uint16 *)dst + disp[4] - 1;
2985 else /* rotate 180 and no flip */
2986 {
2987 pDst = ((uint16 *)dst) + disp[1] * (disp[5] - 1) + disp[4] - 1;
2988 dst_pitch = -dst_pitch;
2989 }
2990
2991 deltaY = (src_pitch << 1) - src_width;
2992 deltaCbCr = (src_pitch - src_width) >> 1;
2993 dst_width = disp[4];
2994 pY = (uint16*)src[0];
2995 pCb = src[1];
2996 pCr = src[2];
2997 src_pitch >>= 1;
2998 colpix = _mColPix + disp[3] - 1;
2999
3000 for (row = disp[3] - 1; row >= 0; row -= 2)
3001 {/* decrement index, _mColPix[.] is
3002 symmetric to increment index */
3003 rowpix = _mRowPix + src_width - 1;
3004
3005 for (col = src_width - 2; col >= 0; col -= 2)
3006 { /* decrement index, _mRowPix[.] is
3007 symmetric to increment index */
3008 Cb = *pCb++;
3009 Cr = *pCr++;
3010 Y = pY[src_pitch];
3011
3012 Cb -= 128;
3013 Cr -= 128;
3014 Cg = Cr * cc1;
3015 Cr *= cc3;
3016
3017 Cg += Cb * cc2;
3018 Cb *= cc4;
3019
3020 tmp0 = Y & 0xFF; //bottom left
3021 tmp0 += OFFSET_5_0;
3022
3023 tmp1 = tmp0 - (Cg >> 16);
3024 tmp2 = tmp0 + (Cb >> 16);
3025 tmp0 = tmp0 + (Cr >> 16);
3026
3027 tmp0 = clip[tmp0];
3028 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
3029 tmp2 = clip[tmp2];
3030
3031 //RGB_565
3032
3033 rgb = tmp1 | (tmp0 << 6);
3034 rgb = tmp2 | (rgb << 5);
3035
3036 Y >>= 8; //bottom right
3037 Y += OFFSET_5_1;
3038 tmp1 = (Y) - (Cg >> 16);
3039 tmp2 = (Y) + (Cb >> 16);
3040 tmp0 = (Y) + (Cr >> 16);
3041
3042 tmp0 = clip[tmp0];
3043 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
3044 tmp2 = clip[tmp2];
3045
3046 //RGB_565
3047 tmp0 = tmp1 | (tmp0 << 6);
3048 tmp0 = tmp2 | (tmp0 << 5);
3049
3050 pDst += dst_pitch;
3051 temp = rowpix[0] + rowpix[-1];
3052 rowpix -= 2;
3053 if (temp == 2)
3054 {
3055 *pDst = rgb;
3056 *(pDst - 1) = tmp0;
3057 }
3058 else if (temp == 3)
3059 {
3060 *pDst = rgb;
3061 #ifndef INTERPOLATE
3062 *(pDst - 1) = tmp0;
3063 #else
3064 *(pDst - 1) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
3065 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
3066 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
3067 #endif
3068 *(pDst - 2) = tmp0;
3069 }
3070 else if (temp == 4)
3071 {
3072 *pDst = rgb;
3073 #ifndef INTERPOLATE
3074 *(pDst - 1) = rgb;
3075 *(pDst - 2) = tmp0;
3076 #else
3077 *(pDst - 1) = (((((tmp0 & 0x1F) + (rgb & 0x1F) * 2) / 3) & 0x1F)
3078 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F) * 2) / 3) & 0x3F) << 5)
3079 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F) * 2) / 3) & 0x1F) << 11));
3080 *(pDst - 2) = (((((tmp0 & 0x1F) * 2 + (rgb & 0x1F)) / 3) & 0x1F)
3081 | ((((((tmp0 >> 5) & 0x3F) * 2 + ((rgb >> 5) & 0x3F)) / 3) & 0x3F) << 5)
3082 | ((((((tmp0 >> 11) & 0x1F) * 2 + ((rgb >> 11) & 0x1F)) / 3) & 0x1F) << 11));
3083 #endif
3084 *(pDst - 3) = tmp0;
3085 }
3086 else if (temp == 5)
3087 {
3088 *pDst = rgb;
3089 #ifndef INTERPOLATE
3090 *(pDst - 1) = rgb;
3091 *(pDst - 2) = tmp0;
3092 *(pDst - 3) = tmp0;
3093 #else
3094 *(pDst - 1) = (((((tmp0 & 0x1F) + (rgb & 0x1F) * 3) / 4) & 0x1F)
3095 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F) * 3) / 4) & 0x3F) << 5)
3096 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F) * 3) / 4) & 0x1F) << 11));
3097 *(pDst - 2) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
3098 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
3099 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
3100 *(pDst - 3) = (((((tmp0 & 0x1F) * 3 + (rgb & 0x1F)) / 4) & 0x1F)
3101 | ((((((tmp0 >> 5) & 0x3F) * 3 + ((rgb >> 5) & 0x3F)) / 4) & 0x3F) << 5)
3102 | ((((((tmp0 >> 11) & 0x1F) * 3 + ((rgb >> 11) & 0x1F)) / 4) & 0x1F) << 11));
3103 #endif
3104 *(pDst - 4) = tmp0;
3105 }
3106 else /* temp ==6 */
3107 {
3108 *pDst = rgb;
3109 #ifndef INTERPOLATE
3110 *(pDst - 1) = rgb;
3111 *(pDst - 2) = rgb;
3112 *(pDst - 3) = tmp0;
3113 *(pDst - 4) = tmp0;
3114 #else
3115 *(pDst - 1) = (((((tmp0 & 0x1F) + (rgb & 0x1F) * 4) / 5) & 0x1F)
3116 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F) * 4) / 5) & 0x3F) << 5)
3117 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F) * 4) / 5) & 0x1F) << 11));
3118 *(pDst - 2) = (((((tmp0 & 0x1F) * 2 + (rgb & 0x1F) * 3) / 5) & 0x1F)
3119 | ((((((tmp0 >> 5) & 0x3F) * 2 + ((rgb >> 5) & 0x3F) * 3) / 5) & 0x3F) << 5)
3120 | ((((((tmp0 >> 11) & 0x1F) * 2 + ((rgb >> 11) & 0x1F) * 3) / 5) & 0x1F) << 11));
3121 *(pDst - 3) = (((((tmp0 & 0x1F) * 3 + (rgb & 0x1F) * 2) / 5) & 0x1F)
3122 | ((((((tmp0 >> 5) & 0x3F) * 3 + ((rgb >> 5) & 0x3F) * 2) / 5) & 0x3F) << 5)
3123 | ((((((tmp0 >> 11) & 0x1F) * 3 + ((rgb >> 11) & 0x1F) * 2) / 5) & 0x1F) << 11));
3124 *(pDst - 4) = (((((tmp0 & 0x1F) * 4 + (rgb & 0x1F)) / 5) & 0x1F)
3125 | ((((((tmp0 >> 5) & 0x3F) * 4 + ((rgb >> 5) & 0x3F)) / 5) & 0x3F) << 5)
3126 | ((((((tmp0 >> 11) & 0x1F) * 4 + ((rgb >> 11) & 0x1F)) / 5) & 0x1F) << 11));
3127 #endif
3128 *(pDst - 5) = tmp0;
3129 }
3130
3131 pDst -= dst_pitch;
3132
3133 Y = *pY++;
3134 tmp0 = Y & 0xFF; //top left
3135 tmp0 += OFFSET_5_1;
3136
3137 tmp1 = tmp0 - (Cg >> 16);
3138 tmp2 = tmp0 + (Cb >> 16);
3139 tmp0 = tmp0 + (Cr >> 16);
3140
3141 tmp0 = clip[tmp0];
3142 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
3143 tmp2 = clip[tmp2];
3144
3145
3146 rgb = tmp1 | (tmp0 << 6);
3147 rgb = tmp2 | (rgb << 5);
3148
3149 Y >>= 8; //top right
3150
3151 Y += OFFSET_5_0;
3152 tmp1 = (Y) - (Cg >> 16);
3153 tmp2 = (Y) + (Cb >> 16);
3154 tmp0 = (Y) + (Cr >> 16);
3155
3156 tmp0 = clip[tmp0];
3157 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
3158 tmp2 = clip[tmp2];
3159
3160 tmp0 = tmp1 | (tmp0 << 6);
3161 tmp0 = tmp2 | (tmp0 << 5);
3162 if (temp == 2)
3163 {
3164 *pDst = rgb;
3165 *(pDst - 1) = tmp0;
3166 }
3167 else if (temp == 3)
3168 {
3169 *pDst = rgb;
3170 #ifndef INTERPOLATE
3171 *(pDst - 1) = tmp0;
3172 #else
3173 *(pDst - 1) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
3174 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
3175 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
3176 #endif
3177 *(pDst - 2) = tmp0;
3178 }
3179 else if (temp == 4)
3180 {
3181 *pDst = rgb;
3182 #ifndef INTERPOLATE
3183 *(pDst - 1) = rgb;
3184 *(pDst - 2) = tmp0;
3185 #else
3186 *(pDst - 1) = (((((tmp0 & 0x1F) + (rgb & 0x1F) * 2) / 3) & 0x1F)
3187 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F) * 2) / 3) & 0x3F) << 5)
3188 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F) * 2) / 3) & 0x1F) << 11));
3189 *(pDst - 2) = (((((tmp0 & 0x1F) * 2 + (rgb & 0x1F)) / 3) & 0x1F)
3190 | ((((((tmp0 >> 5) & 0x3F) * 2 + ((rgb >> 5) & 0x3F)) / 3) & 0x3F) << 5)
3191 | ((((((tmp0 >> 11) & 0x1F) * 2 + ((rgb >> 11) & 0x1F)) / 3) & 0x1F) << 11));
3192 #endif
3193 *(pDst - 3) = tmp0;
3194 }
3195 else if (temp == 5)
3196 {
3197 *pDst = rgb;
3198 #ifndef INTERPOLATE
3199 *(pDst - 1) = rgb;
3200 *(pDst - 2) = tmp0;
3201 *(pDst - 3) = tmp0;
3202 #else
3203 *(pDst - 1) = (((((tmp0 & 0x1F) + (rgb & 0x1F) * 3) / 4) & 0x1F)
3204 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F) * 3) / 4) & 0x3F) << 5)
3205 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F) * 3) / 4) & 0x1F) << 11));
3206 *(pDst - 2) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
3207 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
3208 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
3209 *(pDst - 3) = (((((tmp0 & 0x1F) * 3 + (rgb & 0x1F)) / 4) & 0x1F)
3210 | ((((((tmp0 >> 5) & 0x3F) * 3 + ((rgb >> 5) & 0x3F)) / 4) & 0x3F) << 5)
3211 | ((((((tmp0 >> 11) & 0x1F) * 3 + ((rgb >> 11) & 0x1F)) / 4) & 0x1F) << 11));
3212 #endif
3213 *(pDst - 4) = tmp0;
3214 }
3215 else /* temp ==6 */
3216 {
3217 *pDst = rgb;
3218 #ifndef INTERPOLATE
3219 *(pDst - 1) = rgb;
3220 *(pDst - 2) = rgb;
3221 *(pDst - 3) = tmp0;
3222 *(pDst - 4) = tmp0;
3223 #else
3224 *(pDst - 1) = (((((tmp0 & 0x1F) + (rgb & 0x1F) * 4) / 5) & 0x1F)
3225 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F) * 4) / 5) & 0x3F) << 5)
3226 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F) * 4) / 5) & 0x1F) << 11));
3227 *(pDst - 2) = (((((tmp0 & 0x1F) * 2 + (rgb & 0x1F) * 3) / 5) & 0x1F)
3228 | ((((((tmp0 >> 5) & 0x3F) * 2 + ((rgb >> 5) & 0x3F) * 3) / 5) & 0x3F) << 5)
3229 | ((((((tmp0 >> 11) & 0x1F) * 2 + ((rgb >> 11) & 0x1F) * 3) / 5) & 0x1F) << 11));
3230 *(pDst - 3) = (((((tmp0 & 0x1F) * 3 + (rgb & 0x1F) * 2) / 5) & 0x1F)
3231 | ((((((tmp0 >> 5) & 0x3F) * 3 + ((rgb >> 5) & 0x3F) * 2) / 5) & 0x3F) << 5)
3232 | ((((((tmp0 >> 11) & 0x1F) * 3 + ((rgb >> 11) & 0x1F) * 2) / 5) & 0x1F) << 11));
3233 *(pDst - 4) = (((((tmp0 & 0x1F) * 4 + (rgb & 0x1F)) / 5) & 0x1F)
3234 | ((((((tmp0 >> 5) & 0x3F) * 4 + ((rgb >> 5) & 0x3F)) / 5) & 0x3F) << 5)
3235 | ((((((tmp0 >> 11) & 0x1F) * 4 + ((rgb >> 11) & 0x1F)) / 5) & 0x1F) << 11));
3236 #endif
3237 *(pDst - 5) = tmp0;
3238 }
3239 pDst -= temp;
3240
3241 }//end of COL
3242
3243 pY += (deltaY >> 1);
3244 pCb += deltaCbCr;
3245 pCr += deltaCbCr;
3246
3247 pDst++; // goes back to the beginning of the line
3248
3249 #ifdef INTERPOLATE
3250
3251 if (copyline&0x1) //Maruyama comment:BLACK line in SubQCIF.bmp
3252 {
3253 oscl_memcpy(prev_pDst + offset, prev_pDst + dst_pitch, dst_width*2);
3254 }
3255 if (copyline&0x2) //Maruyama comment:BLUE line in SubQCIF.bmp
3256 {
3257 for (i = 0 ; i < dst_width ; i++)
3258 {
3259 int32 coltemp;
3260 int32 pretemp = *(prev_pDst + dst_pitch + i);
3261 // int32 curtemp = *(pDst+dst_pitch+i);
3262 int32 curtemp = *(pDst + i);
3263 coltemp = (((((pretemp & 0x1F) + (curtemp & 0x1F)) / 2) & 0x1F)
3264 | ((((((pretemp >> 5) & 0x3F) + ((curtemp >> 5) & 0x3F)) / 2) & 0x3F) << 5)
3265 | ((((((pretemp >> 11) & 0x1F) + ((curtemp >> 11) & 0x1F)) / 2) & 0x1F) << 11));
3266 *(prev_pDst + prev_offset + dst_pitch + i) = (uint16)coltemp;
3267 // *(prev_pDst+prev_offset+dst_pitch+i) = 0x1F;
3268 }
3269 }
3270
3271 if (copyline&0x4)
3272 {
3273 for (i = 0 ; i < dst_width ; i++) //Maruyama comment:Not appeared in SubQCIF.bmp
3274 {
3275 int32 coltemp;
3276 int32 pretemp = *(prev_pDst + dst_pitch + i);
3277 // int32 curtemp = *(pDst+dst_pitch+i);
3278 int32 curtemp = *(pDst + i);
3279 coltemp = (((((pretemp & 0x1F) + (curtemp & 0x1F)) / 2) & 0x1F)
3280 | ((((((pretemp >> 5) & 0x3F) + ((curtemp >> 5) & 0x3F)) / 2) & 0x3F) << 5)
3281 | ((((((pretemp >> 11) & 0x1F) + ((curtemp >> 11) & 0x1F)) / 2) & 0x1F) << 11));
3282 *(prev_pDst + prev_offset + dst_pitch + i) = (uint16)coltemp;
3283 // *(prev_pDst+prev_offset+dst_pitch+i) = 0x3F<<5;
3284 }
3285 for (i = 0 ; i < dst_width ; i++) //Maruyama comment:Not appeared in SubQCIF.bmp
3286 {
3287 int32 coltemp;
3288 int32 pretemp = *(prev_pDst + dst_pitch + i);
3289 int32 curtemp = *(pDst + dst_pitch + i);
3290 coltemp = (((((pretemp & 0x1F) + (curtemp & 0x1F)) / 2) & 0x1F)
3291 | ((((((pretemp >> 5) & 0x3F) + ((curtemp >> 5) & 0x3F)) / 2) & 0x3F) << 5)
3292 | ((((((pretemp >> 11) & 0x1F) + ((curtemp >> 11) & 0x1F)) / 2) & 0x1F) << 11));
3293 *(prev_pDst + prev_offset + dst_pitch*2 + i) = (uint16)coltemp;
3294 // *(prev_pDst+prev_offset+dst_pitch*2+i) = 0x1F<<11;
3295 }
3296 }
3297
3298 if (copyline&0x8) //Maruyama comment:WHITE line in SubQCIF.bmp
3299 {
3300 for (i = 0 ; i < dst_width ; i++)
3301 {
3302 int32 coltemp;
3303 int32 pretemp = *(prev_pDst + i);
3304 int32 curtemp = *(pDst - dst_pitch + i);
3305 coltemp = (((((pretemp & 0x1F) + (curtemp & 0x1F)) / 2) & 0x1F)
3306 | ((((((pretemp >> 5) & 0x3F) + ((curtemp >> 5) & 0x3F)) / 2) & 0x3F) << 5)
3307 | ((((((pretemp >> 11) & 0x1F) + ((curtemp >> 11) & 0x1F)) / 2) & 0x1F) << 11));
3308 *(prev_pDst + dst_pitch + i) = (uint16)coltemp;
3309 // *(prev_pDst+dst_pitch+i) = 0xFFFF;
3310 }
3311 }
3312
3313 if (copyline&0x10)
3314 {
3315 for (i = 0 ; i < dst_width ; i++) //Maruyama comment:Not appeared in SubQCIF.bmp
3316 {
3317 int32 coltemp;
3318 int32 pretemp = *(prev_pDst + i);
3319 // int32 curtemp = *(pDst+i);
3320 int32 curtemp = *(pDst - dst_pitch + i);
3321 coltemp = (((((pretemp & 0x1F) + (curtemp & 0x1F)) / 2) & 0x1F)
3322 | ((((((pretemp >> 5) & 0x3F) + ((curtemp >> 5) & 0x3F)) / 2) & 0x3F) << 5)
3323 | ((((((pretemp >> 11) & 0x1F) + ((curtemp >> 11) & 0x1F)) / 2) & 0x1F) << 11));
3324 *(prev_pDst + dst_pitch + i) = (uint16)coltemp;
3325 // *(prev_pDst+dst_pitch+i) = 0x1F|(0x3F<<5);
3326 }
3327 for (i = 0 ; i < dst_width ; i++) //Maruyama comment:Not appeared in SubQCIF.bmp
3328 {
3329 int32 coltemp;
3330 int32 pretemp = *(prev_pDst + i);
3331 int32 curtemp = *(pDst + i);
3332 coltemp = (((((pretemp & 0x1F) + (curtemp & 0x1F)) / 2) & 0x1F)
3333 | ((((((pretemp >> 5) & 0x3F) + ((curtemp >> 5) & 0x3F)) / 2) & 0x3F) << 5)
3334 | ((((((pretemp >> 11) & 0x1F) + ((curtemp >> 11) & 0x1F)) / 2) & 0x1F) << 11));
3335 *(prev_pDst + dst_pitch*2 + i) = (uint16)coltemp;
3336 // *(prev_pDst+dst_pitch*2+i) = 0x1F|(0x1F<<11);
3337 }
3338 }
3339 #endif
3340 //copy down
3341 offset = (colpix[0] * dst_pitch);
3342
3343 #ifdef INTERPOLATE
3344 copyline = 0; //maru
3345 prev_pDst = pDst; //maru
3346 prev_offset = offset; //maru
3347 #endif
3348 if (colpix[-1] && colpix[0] != 1)
3349 {
3350 #ifndef INTERPOLATE
3351 oscl_memcpy(pDst + offset, pDst + dst_pitch, dst_width*2);
3352 #else
3353 copyline |= 0x1; //maru
3354 #endif
3355 }
3356 if (colpix[-1] == 2)
3357 {
3358 #ifndef INTERPOLATE
3359 oscl_memcpy(pDst + offset + dst_pitch, pDst + dst_pitch, dst_width*2);
3360 #else
3361 copyline |= 0x2; //maru
3362 #endif
3363 }
3364 else if (colpix[-1] == 3)
3365 {
3366 #ifndef INTERPOLATE
3367 oscl_memcpy(pDst + offset + dst_pitch, pDst + dst_pitch, dst_width*2);
3368 oscl_memcpy(pDst + offset + dst_pitch*2, pDst + dst_pitch, dst_width*2);
3369 #else
3370 copyline |= 0x4; //maru
3371 #endif
3372 }
3373 //copy up
3374 if (colpix[0] == 2)
3375 {
3376 #ifndef INTERPOLATE
3377 oscl_memcpy(pDst + dst_pitch, pDst, dst_width*2);
3378 #else
3379 copyline |= 0x8; //maru
3380 #endif
3381 }
3382 else if (colpix[0] == 3)
3383 {
3384 #ifndef INTERPOLATE
3385 oscl_memcpy(pDst + dst_pitch, pDst, dst_width*2);
3386 oscl_memcpy(pDst + dst_pitch*2, pDst, dst_width*2);
3387 #else
3388 copyline |= 0x10; //maru
3389 #endif
3390 }
3391
3392 pDst += dst_pitch * (colpix[-1] + colpix[0]) + dst_width - 1;
3393 colpix -= 2;
3394 }//end of row
3395
3396 #ifdef INTERPOLATE
3397
3398 if (copyline&0x1) //Maruyama comment:BLACK line in SubQCIF.bmp
3399 {
3400 oscl_memcpy(prev_pDst + offset, prev_pDst + dst_pitch, dst_width*2);
3401 }
3402 if (copyline&0x2) //Maruyama comment:BLUE line in SubQCIF.bmp
3403 {
3404 oscl_memcpy(prev_pDst + offset + dst_pitch, prev_pDst + dst_pitch, dst_width*2);
3405 }
3406
3407 if (copyline&0x4)
3408 {
3409 oscl_memcpy(prev_pDst + offset + dst_pitch, prev_pDst + dst_pitch, dst_width*2);
3410 oscl_memcpy(prev_pDst + offset + dst_pitch*2, prev_pDst + dst_pitch, dst_width*2);
3411 }
3412 #endif
3413 }
3414 else /* rotate 180 and with flip || no rotation ,no flip */
3415 {
3416 if (disp[6] == 1) /* rotate 180 and with flip */ //Ankur
3417 {
3418 /* move the starting point to the bottom-left corner of the picture */
3419 deltaY = src_pitch * (disp[3] - 1);
3420 pY = (uint16 *)src[0] + (deltaY >> 1);
3421 deltaY = (src_pitch >> 1) * ((disp[3] >> 1) - 1);
3422 pCb = src[1] + (deltaY >> 0);
3423 pCr = src[2] + (deltaY >> 0);
3424 deltaY = -src_width - (src_pitch << 1);
3425 deltaCbCr = -((src_width + src_pitch) >> 1);
3426 dst_width = disp[4];
3427 src_pitch >>= 1;
3428 src_pitch = -src_pitch;
3429 }
3430 else
3431 { // only scale up, no rotation ,no flip
3432 deltaY = (src_pitch << 1) - src_width;
3433 deltaCbCr = (src_pitch - src_width) >> 1;
3434 dst_width = disp[4];
3435 src_pitch >>= 1;
3436 pY = (uint16*)src[0];
3437 pCb = src[1];
3438 pCr = src[2];
3439 }
3440
3441 pDst = (uint16 *)dst;
3442 colpix = _mColPix + disp[3] - 1;
3443
3444 for (row = disp[3] - 1; row >= 0; row -= 2)
3445 {/* decrement index, _mColPix[.] is
3446 symmetric to increment index */
3447 rowpix = _mRowPix + src_width - 1;
3448
3449 for (col = src_width - 2; col >= 0; col -= 2)
3450 { /* decrement index, _mRowPix[.] is
3451 symmetric to increment index */
3452 Cb = *pCb++;
3453 Cr = *pCr++;
3454 Y = pY[src_pitch];
3455
3456 Cb -= 128;
3457 Cr -= 128;
3458 Cg = Cr * cc1;
3459 Cr *= cc3;
3460
3461 Cg += Cb * cc2;
3462 Cb *= cc4;
3463
3464 tmp0 = Y & 0xFF; //bottom left
3465 tmp0 += OFFSET_5_0;
3466
3467 tmp1 = tmp0 - (Cg >> 16);
3468 tmp2 = tmp0 + (Cb >> 16);
3469 tmp0 = tmp0 + (Cr >> 16);
3470
3471 tmp0 = clip[tmp0];
3472 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
3473 tmp2 = clip[tmp2];
3474
3475 //RGB_565
3476
3477 rgb = tmp1 | (tmp0 << 6);
3478 rgb = tmp2 | (rgb << 5);
3479
3480 Y >>= 8; //bottom right
3481 Y += OFFSET_5_1;
3482 tmp1 = (Y) - (Cg >> 16);
3483 tmp2 = (Y) + (Cb >> 16);
3484 tmp0 = (Y) + (Cr >> 16);
3485
3486 tmp0 = clip[tmp0];
3487 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
3488 tmp2 = clip[tmp2];
3489
3490 //RGB_565
3491 tmp0 = tmp1 | (tmp0 << 6);
3492 tmp0 = tmp2 | (tmp0 << 5);
3493
3494 pDst += dst_pitch;
3495 temp = rowpix[0] + rowpix[-1];
3496 rowpix -= 2;
3497 if (temp == 2)
3498 {
3499 *pDst = (uint16)rgb;
3500 *(pDst + 1) = (uint16)tmp0;
3501 }
3502 else if (temp == 3)
3503 {
3504 *pDst = (uint16)rgb;
3505 #ifndef INTERPOLATE
3506 *(pDst + 1) = (uint16)tmp0;
3507 #else
3508 *(pDst + 1) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
3509 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
3510 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
3511 #endif
3512 *(pDst + 2) = (uint16)tmp0;
3513 }
3514 else if (temp == 4)
3515 {
3516 *pDst = (uint16)rgb;
3517 #ifndef INTERPOLATE
3518 *(pDst + 1) = (uint16)rgb;
3519 *(pDst + 2) = (uint16)tmp0;
3520 #else
3521 *(pDst + 1) = (((((tmp0 & 0x1F) + (rgb & 0x1F) * 2) / 3) & 0x1F)
3522 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F) * 2) / 3) & 0x3F) << 5)
3523 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F) * 2) / 3) & 0x1F) << 11));
3524 *(pDst + 2) = (((((tmp0 & 0x1F) * 2 + (rgb & 0x1F)) / 3) & 0x1F)
3525 | ((((((tmp0 >> 5) & 0x3F) * 2 + ((rgb >> 5) & 0x3F)) / 3) & 0x3F) << 5)
3526 | ((((((tmp0 >> 11) & 0x1F) * 2 + ((rgb >> 11) & 0x1F)) / 3) & 0x1F) << 11));
3527 #endif
3528 *(pDst + 3) = (uint16)tmp0;
3529 }
3530 else if (temp == 5)
3531 {
3532 *pDst = (uint16)rgb;
3533 #ifndef INTERPOLATE
3534 *(pDst + 1) = (uint16)rgb;
3535 *(pDst + 2) = (uint16)tmp0;
3536 *(pDst + 3) = (uint16)tmp0;
3537 #else
3538 *(pDst + 1) = (((((tmp0 & 0x1F) + (rgb & 0x1F) * 3) / 4) & 0x1F)
3539 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F) * 3) / 4) & 0x3F) << 5)
3540 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F) * 3) / 4) & 0x1F) << 11));
3541 *(pDst + 2) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
3542 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
3543 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
3544 *(pDst + 3) = (((((tmp0 & 0x1F) * 3 + (rgb & 0x1F)) / 4) & 0x1F)
3545 | ((((((tmp0 >> 5) & 0x3F) * 3 + ((rgb >> 5) & 0x3F)) / 4) & 0x3F) << 5)
3546 | ((((((tmp0 >> 11) & 0x1F) * 3 + ((rgb >> 11) & 0x1F)) / 4) & 0x1F) << 11));
3547 #endif
3548 *(pDst + 4) = (uint16)tmp0;
3549 }
3550 else /* temp ==6 */
3551 {
3552 *pDst = (uint16)rgb;
3553 #ifndef INTERPOLATE
3554 *(pDst + 1) = (uint16)rgb;
3555 *(pDst + 2) = (uint16)rgb;
3556 *(pDst + 3) = (uint16)tmp0;
3557 *(pDst + 4) = (uint16)tmp0;
3558 #else
3559 *(pDst + 1) = (((((tmp0 & 0x1F) + (rgb & 0x1F) * 4) / 5) & 0x1F)
3560 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F) * 4) / 5) & 0x3F) << 5)
3561 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F) * 4) / 5) & 0x1F) << 11));
3562 *(pDst + 2) = (((((tmp0 & 0x1F) * 2 + (rgb & 0x1F) * 3) / 5) & 0x1F)
3563 | ((((((tmp0 >> 5) & 0x3F) * 2 + ((rgb >> 5) & 0x3F) * 3) / 5) & 0x3F) << 5)
3564 | ((((((tmp0 >> 11) & 0x1F) * 2 + ((rgb >> 11) & 0x1F) * 3) / 5) & 0x1F) << 11));
3565 *(pDst + 3) = (((((tmp0 & 0x1F) * 3 + (rgb & 0x1F) * 2) / 5) & 0x1F)
3566 | ((((((tmp0 >> 5) & 0x3F) * 3 + ((rgb >> 5) & 0x3F) * 2) / 5) & 0x3F) << 5)
3567 | ((((((tmp0 >> 11) & 0x1F) * 3 + ((rgb >> 11) & 0x1F) * 2) / 5) & 0x1F) << 11));
3568 *(pDst + 4) = (((((tmp0 & 0x1F) * 4 + (rgb & 0x1F)) / 5) & 0x1F)
3569 | ((((((tmp0 >> 5) & 0x3F) * 4 + ((rgb >> 5) & 0x3F)) / 5) & 0x3F) << 5)
3570 | ((((((tmp0 >> 11) & 0x1F) * 4 + ((rgb >> 11) & 0x1F)) / 5) & 0x1F) << 11));
3571 #endif
3572 *(pDst + 5) = (uint16)tmp0;
3573 }
3574
3575 pDst -= dst_pitch;
3576
3577 Y = *pY++;
3578 tmp0 = Y & 0xFF; //top left
3579 tmp0 += OFFSET_5_1;
3580
3581 tmp1 = tmp0 - (Cg >> 16);
3582 tmp2 = tmp0 + (Cb >> 16);
3583 tmp0 = tmp0 + (Cr >> 16);
3584
3585 tmp0 = clip[tmp0];
3586 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
3587 tmp2 = clip[tmp2];
3588
3589 rgb = tmp1 | (tmp0 << 6);
3590 rgb = tmp2 | (rgb << 5);
3591
3592 Y >>= 8; //top right
3593 Y += OFFSET_5_0;
3594 tmp1 = (Y) - (Cg >> 16);
3595 tmp2 = (Y) + (Cb >> 16);
3596 tmp0 = (Y) + (Cr >> 16);
3597
3598 tmp0 = clip[tmp0];
3599 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
3600 tmp2 = clip[tmp2];
3601
3602 tmp0 = tmp1 | (tmp0 << 6);
3603 tmp0 = tmp2 | (tmp0 << 5);
3604 if (temp == 2)
3605 {
3606 *pDst = (uint16)rgb;
3607 *(pDst + 1) = (uint16)tmp0;
3608 }
3609 else if (temp == 3)
3610 {
3611 *pDst = (uint16)rgb;
3612 #ifndef INTERPOLATE
3613 *(pDst + 1) = (uint16)tmp0;
3614 #else
3615 *(pDst + 1) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
3616 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
3617 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
3618 #endif
3619 *(pDst + 2) = (uint16)tmp0;
3620 }
3621 else if (temp == 4)
3622 {
3623 *pDst = (uint16)rgb;
3624 #ifndef INTERPOLATE
3625 *(pDst + 1) = (uint16)rgb;
3626 *(pDst + 2) = (uint16)tmp0;
3627 #else
3628 *(pDst + 1) = (((((tmp0 & 0x1F) + (rgb & 0x1F) * 2) / 3) & 0x1F)
3629 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F) * 2) / 3) & 0x3F) << 5)
3630 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F) * 2) / 3) & 0x1F) << 11));
3631 *(pDst + 2) = (((((tmp0 & 0x1F) * 2 + (rgb & 0x1F)) / 3) & 0x1F)
3632 | ((((((tmp0 >> 5) & 0x3F) * 2 + ((rgb >> 5) & 0x3F)) / 3) & 0x3F) << 5)
3633 | ((((((tmp0 >> 11) & 0x1F) * 2 + ((rgb >> 11) & 0x1F)) / 3) & 0x1F) << 11));
3634 #endif
3635 *(pDst + 3) = (uint16)tmp0;
3636 }
3637 else if (temp == 5)
3638 {
3639 *pDst = (uint16)rgb;
3640 #ifndef INTERPOLATE
3641 *(pDst + 1) = (uint16)rgb;
3642 *(pDst + 2) = (uint16)tmp0;
3643 *(pDst + 3) = (uint16)tmp0;
3644 #else
3645 *(pDst + 1) = (((((tmp0 & 0x1F) + (rgb & 0x1F) * 3) / 4) & 0x1F)
3646 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F) * 3) / 4) & 0x3F) << 5)
3647 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F) * 3) / 4) & 0x1F) << 11));
3648 *(pDst + 2) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
3649 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
3650 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
3651 *(pDst + 3) = (((((tmp0 & 0x1F) * 3 + (rgb & 0x1F)) / 4) & 0x1F)
3652 | ((((((tmp0 >> 5) & 0x3F) * 3 + ((rgb >> 5) & 0x3F)) / 4) & 0x3F) << 5)
3653 | ((((((tmp0 >> 11) & 0x1F) * 3 + ((rgb >> 11) & 0x1F)) / 4) & 0x1F) << 11));
3654 #endif
3655 *(pDst + 4) = (uint16)tmp0;
3656 }
3657 else /* temp ==6 */
3658 {
3659 *pDst = (uint16)rgb;
3660 #ifndef INTERPOLATE
3661 *(pDst + 1) = (uint16)rgb;
3662 *(pDst + 2) = (uint16)rgb;
3663 *(pDst + 3) = (uint16)tmp0;
3664 *(pDst + 4) = (uint16)tmp0;
3665 #else
3666 *(pDst + 1) = (((((tmp0 & 0x1F) + (rgb & 0x1F) * 4) / 5) & 0x1F)
3667 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F) * 4) / 5) & 0x3F) << 5)
3668 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F) * 4) / 5) & 0x1F) << 11));
3669 *(pDst + 2) = (((((tmp0 & 0x1F) * 2 + (rgb & 0x1F) * 3) / 5) & 0x1F)
3670 | ((((((tmp0 >> 5) & 0x3F) * 2 + ((rgb >> 5) & 0x3F) * 3) / 5) & 0x3F) << 5)
3671 | ((((((tmp0 >> 11) & 0x1F) * 2 + ((rgb >> 11) & 0x1F) * 3) / 5) & 0x1F) << 11));
3672 *(pDst + 3) = (((((tmp0 & 0x1F) * 3 + (rgb & 0x1F) * 2) / 5) & 0x1F)
3673 | ((((((tmp0 >> 5) & 0x3F) * 3 + ((rgb >> 5) & 0x3F) * 2) / 5) & 0x3F) << 5)
3674 | ((((((tmp0 >> 11) & 0x1F) * 3 + ((rgb >> 11) & 0x1F) * 2) / 5) & 0x1F) << 11));
3675 *(pDst + 4) = (((((tmp0 & 0x1F) * 4 + (rgb & 0x1F)) / 5) & 0x1F)
3676 | ((((((tmp0 >> 5) & 0x3F) * 4 + ((rgb >> 5) & 0x3F)) / 5) & 0x3F) << 5)
3677 | ((((((tmp0 >> 11) & 0x1F) * 4 + ((rgb >> 11) & 0x1F)) / 5) & 0x1F) << 11));
3678 #endif
3679 *(pDst + 5) = (uint16)tmp0;
3680 }
3681 pDst += temp;
3682
3683 }//end of COL
3684
3685 pY += (deltaY >> 1);
3686 pCb += deltaCbCr;
3687 pCr += deltaCbCr;
3688
3689 pDst -= (disp[4]); //goes back to the beginning of the line;
3690
3691 #ifdef INTERPOLATE
3692
3693 if (copyline&0x1) //Maruyama comment:BLACK line in SubQCIF.bmp
3694 {
3695 oscl_memcpy(prev_pDst + offset, prev_pDst + dst_pitch, dst_width*2);
3696 }
3697 if (copyline&0x2) //Maruyama comment:BLUE line in SubQCIF.bmp
3698 {
3699 for (i = 0 ; i < dst_width ; i++)
3700 {
3701 int32 coltemp;
3702 int32 pretemp = *(prev_pDst + dst_pitch + i);
3703 // int32 curtemp = *(pDst+dst_pitch+i);
3704 int32 curtemp = *(pDst + i);
3705 coltemp = (((((pretemp & 0x1F) + (curtemp & 0x1F)) / 2) & 0x1F)
3706 | ((((((pretemp >> 5) & 0x3F) + ((curtemp >> 5) & 0x3F)) / 2) & 0x3F) << 5)
3707 | ((((((pretemp >> 11) & 0x1F) + ((curtemp >> 11) & 0x1F)) / 2) & 0x1F) << 11));
3708 *(prev_pDst + prev_offset + dst_pitch + i) = (uint16)coltemp;
3709 // *(prev_pDst+prev_offset+dst_pitch+i) = 0x1F;
3710 }
3711 }
3712
3713 if (copyline&0x4)
3714 {
3715 for (i = 0 ; i < dst_width ; i++) //Maruyama comment:Not appeared in SubQCIF.bmp
3716 {
3717 int32 coltemp;
3718 int32 pretemp = *(prev_pDst + dst_pitch + i);
3719 // int32 curtemp = *(pDst+dst_pitch+i);
3720 int32 curtemp = *(pDst + i);
3721 coltemp = (((((pretemp & 0x1F) + (curtemp & 0x1F)) / 2) & 0x1F)
3722 | ((((((pretemp >> 5) & 0x3F) + ((curtemp >> 5) & 0x3F)) / 2) & 0x3F) << 5)
3723 | ((((((pretemp >> 11) & 0x1F) + ((curtemp >> 11) & 0x1F)) / 2) & 0x1F) << 11));
3724 *(prev_pDst + prev_offset + dst_pitch + i) = (uint16)coltemp;
3725 // *(prev_pDst+prev_offset+dst_pitch+i) = 0x3F<<5;
3726 }
3727 for (i = 0 ; i < dst_width ; i++) //Maruyama comment:Not appeared in SubQCIF.bmp
3728 {
3729 int32 coltemp;
3730 int32 pretemp = *(prev_pDst + dst_pitch + i);
3731 int32 curtemp = *(pDst + dst_pitch + i);
3732 coltemp = (((((pretemp & 0x1F) + (curtemp & 0x1F)) / 2) & 0x1F)
3733 | ((((((pretemp >> 5) & 0x3F) + ((curtemp >> 5) & 0x3F)) / 2) & 0x3F) << 5)
3734 | ((((((pretemp >> 11) & 0x1F) + ((curtemp >> 11) & 0x1F)) / 2) & 0x1F) << 11));
3735 *(prev_pDst + prev_offset + dst_pitch*2 + i) = (uint16)coltemp;
3736 // *(prev_pDst+prev_offset+dst_pitch*2+i) = 0x1F<<11;
3737 }
3738 }
3739
3740 if (copyline&0x8) //Maruyama comment:WHITE line in SubQCIF.bmp
3741 {
3742 for (i = 0 ; i < dst_width ; i++)
3743 {
3744 int32 coltemp;
3745 int32 pretemp = *(prev_pDst + i);
3746 int32 curtemp = *(pDst - dst_pitch + i);
3747 coltemp = (((((pretemp & 0x1F) + (curtemp & 0x1F)) / 2) & 0x1F)
3748 | ((((((pretemp >> 5) & 0x3F) + ((curtemp >> 5) & 0x3F)) / 2) & 0x3F) << 5)
3749 | ((((((pretemp >> 11) & 0x1F) + ((curtemp >> 11) & 0x1F)) / 2) & 0x1F) << 11));
3750 *(prev_pDst + dst_pitch + i) = (uint16)coltemp;
3751 // *(prev_pDst+dst_pitch+i) = 0xFFFF;
3752 }
3753 }
3754
3755 if (copyline&0x10)
3756 {
3757 for (i = 0 ; i < dst_width ; i++) //Maruyama comment:Not appeared in SubQCIF.bmp
3758 {
3759 int32 coltemp;
3760 int32 pretemp = *(prev_pDst + i);
3761 // int32 curtemp = *(pDst+i);
3762 int32 curtemp = *(pDst - dst_pitch + i);
3763 coltemp = (((((pretemp & 0x1F) + (curtemp & 0x1F)) / 2) & 0x1F)
3764 | ((((((pretemp >> 5) & 0x3F) + ((curtemp >> 5) & 0x3F)) / 2) & 0x3F) << 5)
3765 | ((((((pretemp >> 11) & 0x1F) + ((curtemp >> 11) & 0x1F)) / 2) & 0x1F) << 11));
3766 *(prev_pDst + dst_pitch + i) = (uint16)coltemp;
3767 // *(prev_pDst+dst_pitch+i) = 0x1F|(0x3F<<5);
3768 }
3769 for (i = 0 ; i < dst_width ; i++) //Maruyama comment:Not appeared in SubQCIF.bmp
3770 {
3771 int32 coltemp;
3772 int32 pretemp = *(prev_pDst + i);
3773 int32 curtemp = *(pDst + i);
3774 coltemp = (((((pretemp & 0x1F) + (curtemp & 0x1F)) / 2) & 0x1F)
3775 | ((((((pretemp >> 5) & 0x3F) + ((curtemp >> 5) & 0x3F)) / 2) & 0x3F) << 5)
3776 | ((((((pretemp >> 11) & 0x1F) + ((curtemp >> 11) & 0x1F)) / 2) & 0x1F) << 11));
3777 *(prev_pDst + dst_pitch*2 + i) = (uint16)coltemp;
3778 // *(prev_pDst+dst_pitch*2+i) = 0x1F|(0x1F<<11);
3779 }
3780 }
3781 #endif
3782 //copy down
3783 offset = (colpix[0] * dst_pitch);
3784
3785 #ifdef INTERPOLATE
3786 copyline = 0; //maru
3787 prev_pDst = pDst; //maru
3788 prev_offset = offset; //maru
3789 #endif
3790 if (colpix[-1] && colpix[0] != 1)
3791 {
3792 #ifndef INTERPOLATE
3793 oscl_memcpy(pDst + offset, pDst + dst_pitch, dst_width*2);
3794 #else
3795 copyline |= 0x1; //maru
3796 #endif
3797 }
3798 if (colpix[-1] == 2)
3799 {
3800 #ifndef INTERPOLATE
3801 oscl_memcpy(pDst + offset + dst_pitch, pDst + dst_pitch, dst_width*2);
3802 #else
3803 copyline |= 0x2; //maru
3804 #endif
3805 }
3806 else if (colpix[-1] == 3)
3807 {
3808 #ifndef INTERPOLATE
3809 oscl_memcpy(pDst + offset + dst_pitch, pDst + dst_pitch, dst_width*2);
3810 oscl_memcpy(pDst + offset + dst_pitch*2, pDst + dst_pitch, dst_width*2);
3811 #else
3812 copyline |= 0x4; //maru
3813 #endif
3814 }
3815
3816 //copy up
3817 if (colpix[0] == 2)
3818 {
3819 #ifndef INTERPOLATE
3820 oscl_memcpy(pDst + dst_pitch, pDst, dst_width*2);
3821 #else
3822 copyline |= 0x8; //maru
3823 #endif
3824 }
3825 else if (colpix[0] == 3)
3826 {
3827 #ifndef INTERPOLATE
3828 oscl_memcpy(pDst + dst_pitch, pDst, dst_width*2);
3829 oscl_memcpy(pDst + dst_pitch*2, pDst, dst_width*2);
3830 #else
3831 copyline |= 0x10; //maru
3832 #endif
3833 }
3834
3835 pDst += dst_pitch * (colpix[-1] + colpix[0]);
3836 colpix -= 2;
3837 }//end of row
3838
3839 #ifdef INTERPOLATE
3840 if (copyline&0x1) //Maruyama comment:BLACK line in SubQCIF.bmp
3841 {
3842 oscl_memcpy(prev_pDst + offset, prev_pDst + dst_pitch, dst_width*2);
3843 }
3844 if (copyline&0x2) //Maruyama comment:BLUE line in SubQCIF.bmp
3845 {
3846 oscl_memcpy(prev_pDst + offset + dst_pitch, prev_pDst + dst_pitch, dst_width*2);
3847 }
3848
3849 if (copyline&0x4)
3850 {
3851 oscl_memcpy(prev_pDst + offset + dst_pitch, prev_pDst + dst_pitch, dst_width*2);
3852 oscl_memcpy(prev_pDst + offset + dst_pitch*2, prev_pDst + dst_pitch, dst_width*2);
3853 }
3854 #endif
3855 }
3856
3857 return 1;
3858 #else
3859 OSCL_UNUSED_ARG(src);
3860 OSCL_UNUSED_ARG(dst);
3861 OSCL_UNUSED_ARG(disp);
3862 OSCL_UNUSED_ARG(coff_tbl);
3863 OSCL_UNUSED_ARG(_mRowPix);
3864 OSCL_UNUSED_ARG(_mColPix);
3865
3866 return 0;
3867 #endif // CCSCALING
3868 }
3869
3870 /* special 5:4 scale-up color conversion */
cc16scaling54(uint8 ** src,uint8 * dst,int32 * disp,uint8 * coff_tbl)3871 int32 cc16scaling54(uint8 **src, uint8 *dst,
3872 int32 *disp, uint8 *coff_tbl)
3873 {
3874 #if CCSCALING
3875 uint8 *pCb, *pCr;
3876 uint16 *pY;
3877 uint16 *pDst;
3878 int32 src_pitch, dst_pitch, src_width;
3879 int32 Y, Cb, Cr, Cg;
3880 int32 deltaY, deltaDst, deltaCbCr;
3881 int32 row, col;
3882 int32 tmp0, tmp1, tmp2;
3883 uint32 rgb1, rgb2;
3884 int32 tmp01, tmp02;
3885 uint32 rgb;
3886 uint8 *clip = coff_tbl + 400;
3887 int32 cc1 = (*((int32*)(clip - 400)));
3888 int32 cc3 = (*((int32*)(clip - 396)));
3889 int32 cc2 = (*((int32*)(clip - 392)));
3890 int32 cc4 = (*((int32*)(clip - 388)));
3891 #ifdef INTERPOLATE
3892 int copyline = 0, i;
3893 uint16 *pFifth, *previous, *current;
3894 #endif
3895
3896 src_pitch = disp[0];
3897 dst_pitch = disp[1];
3898 src_width = disp[2];
3899
3900
3901 if (((disp[6] == 1) && (disp[7] == 0)) || ((disp[6] == 0) && (disp[7] == 1))) /* rotate 180, no flip || rotate 0 and flip */
3902 {
3903 if (disp[6])
3904 {
3905 deltaY = src_pitch * (disp[3] - 1);
3906 pY = (uint16*)(src[0] + deltaY);
3907 deltaY = (src_pitch >> 1) * ((disp[3] >> 1) - 1);
3908 pCb = src[1] + deltaY;
3909 pCr = src[2] + deltaY;
3910 deltaY = -src_width - (src_pitch << 1);
3911 deltaCbCr = -((src_width + src_pitch) >> 1);
3912 src_pitch = -(src_pitch >> 1);
3913 }
3914 else
3915 {
3916 deltaY = (src_pitch << 1) - src_width;
3917 deltaCbCr = (src_pitch - src_width) >> 1;
3918 pY = (uint16 *) src[0];
3919 src_pitch >>= 1;
3920 pCb = src[1];
3921 pCr = src[2];
3922 }
3923
3924 deltaDst = (dst_pitch << 1) + disp[4] - 1; /* disp[4] is dst_width */
3925 pDst = (uint16 *)dst + disp[4] - 1;
3926 for (row = disp[3]; row > 0; row -= 2)
3927 {
3928
3929 for (col = src_width - 1; col >= 0; col -= 4) /* do 8 pixels at a time, 4 ups 2 downs */
3930 {
3931
3932 Cb = *pCb++;
3933 Cr = *pCr++;
3934
3935 Cb -= 128;
3936 Cr -= 128;
3937 Cg = Cr * cc1;
3938 Cr *= cc3;
3939
3940 Cg += Cb * cc2;
3941 Cb *= cc4;
3942 //load the bottom two pixels
3943 Y = pY[src_pitch];
3944
3945 tmp0 = Y & 0xFF; //Low endian left pixel
3946 tmp0 += OFFSET_5_0;
3947
3948 tmp1 = tmp0 - (Cg >> 16);
3949 tmp2 = tmp0 + (Cb >> 16);
3950 tmp0 = tmp0 + (Cr >> 16);
3951
3952 tmp0 = clip[tmp0];
3953 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
3954 tmp2 = clip[tmp2];
3955 //RGB_565
3956
3957 rgb = tmp1 | (tmp0 << 6);
3958 rgb = tmp2 | (rgb << 5);
3959 *(pDst + dst_pitch) = rgb; // i1 = p1;/* save left pixel, have to save separately */
3960
3961 Y >>= 8;
3962 Y += OFFSET_5_1;
3963 tmp1 = (Y) - (Cg >> 16);
3964 tmp2 = (Y) + (Cb >> 16);
3965 tmp0 = (Y) + (Cr >> 16);
3966
3967 tmp0 = clip[tmp0];
3968 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
3969 tmp2 = clip[tmp2];
3970 //RGB_565
3971 tmp0 = tmp1 | (tmp0 << 6);
3972 tmp02 = tmp2 | (tmp0 << 5);
3973
3974 #ifdef INTERPOLATE
3975 *(pDst + dst_pitch - 1) = (((((tmp02 & 0x1F) * 3 + (rgb & 0x1F) + 2) / 4) & 0x1F)
3976 | ((((((tmp02 >> 5) & 0x3F) * 3 + ((rgb >> 5) & 0x3F) + 2) / 4) & 0x3F) << 5)
3977 | ((((((tmp02 >> 11) & 0x1F) * 3 + ((rgb >> 11) & 0x1F) + 2) / 4) & 0x1F) << 11));
3978 //i2 = (p1 + 3*p2 + 2)>>2;
3979 #else
3980 *(pDst + dst_pitch - 1) = tmp02; /* save right pixel */
3981 #endif
3982 //load the top two pixels
3983 Y = *pY++;
3984
3985 tmp0 = Y & 0xFF; //Low endian left pixel
3986 tmp0 += OFFSET_5_1;
3987
3988 tmp1 = tmp0 - (Cg >> 16);
3989 tmp2 = tmp0 + (Cb >> 16);
3990 tmp0 = tmp0 + (Cr >> 16);
3991
3992 tmp0 = clip[tmp0];
3993 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
3994 tmp2 = clip[tmp2];
3995
3996
3997 rgb = tmp1 | (tmp0 << 6);
3998 rgb = tmp2 | (rgb << 5);
3999 *pDst-- = rgb; // i1 = p1; /* save left pixel */
4000
4001 Y >>= 8;
4002
4003 Y += OFFSET_5_0;
4004 tmp1 = (Y) - (Cg >> 16);
4005 tmp2 = (Y) + (Cb >> 16);
4006 tmp0 = (Y) + (Cr >> 16);
4007
4008 tmp0 = clip[tmp0];
4009 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
4010 tmp2 = clip[tmp2];
4011
4012 tmp0 = tmp1 | (tmp0 << 6);
4013 tmp01 = tmp2 | (tmp0 << 5);
4014
4015 #ifdef INTERPOLATE
4016 *(pDst--) = (((((tmp01 & 0x1F) * 3 + (rgb & 0x1F) + 2) / 4) & 0x1F)
4017 | ((((((tmp01 >> 5) & 0x3F) * 3 + ((rgb >> 5) & 0x3F) + 2) / 4) & 0x3F) << 5)
4018 | ((((((tmp01 >> 11) & 0x1F) * 3 + ((rgb >> 11) & 0x1F) + 2) / 4) & 0x1F) << 11));
4019 //i2 = (p1 + 3*p2 + 2)>>2;
4020 #else
4021 *pDst-- = tmp01; /* save right pixel */
4022 #endif
4023 /* now do another 4 pixels add 1 pixels in the last column */
4024 Cb = *pCb++;
4025 Cr = *pCr++;
4026
4027 Cb -= 128;
4028 Cr -= 128;
4029 Cg = Cr * cc1;
4030 Cr *= cc3;
4031
4032 Cg += Cb * cc2;
4033 Cb *= cc4;
4034 //load the bottom two pixels
4035 Y = pY[src_pitch];
4036
4037 tmp0 = Y & 0xFF; //Low endian left pixel
4038 tmp0 += OFFSET_5_0;
4039
4040 tmp1 = tmp0 - (Cg >> 16);
4041 tmp2 = tmp0 + (Cb >> 16);
4042 tmp0 = tmp0 + (Cr >> 16);
4043
4044 tmp0 = clip[tmp0];
4045 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
4046 tmp2 = clip[tmp2];
4047 //RGB_565
4048
4049 rgb = tmp1 | (tmp0 << 6);
4050 rgb2 = tmp2 | (rgb << 5);
4051
4052 #ifdef INTERPOLATE
4053 // i3 = (p2 + p3 + 1)>>1;
4054 *(pDst + dst_pitch) = (((((tmp02 & 0x1F) + (rgb2 & 0x1F) + 1) / 2) & 0x1F)
4055 | ((((((tmp02 >> 5) & 0x3F) + ((rgb2 >> 5) & 0x3F) + 1) / 2) & 0x3F) << 5)
4056 | ((((((tmp02 >> 11) & 0x1F) + ((rgb2 >> 11) & 0x1F) + 1) / 2) & 0x1F) << 11));
4057 #else
4058 *(pDst + dst_pitch) = rgb2; /* save left pixel, have to save separately */
4059 #endif
4060
4061 Y >>= 8;
4062 Y += OFFSET_5_1;
4063 tmp1 = (Y) - (Cg >> 16);
4064 tmp2 = (Y) + (Cb >> 16);
4065 tmp0 = (Y) + (Cr >> 16);
4066
4067 tmp0 = clip[tmp0];
4068 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
4069 tmp2 = clip[tmp2];
4070 //RGB_565
4071 tmp0 = tmp1 | (tmp0 << 6);
4072 tmp0 = tmp2 | (tmp0 << 5);
4073
4074 #ifdef INTERPOLATE
4075 //i4 = (3*p3 + p4 + 2)>>2;
4076 *(pDst + dst_pitch - 1) = (((((tmp0 & 0x1F) + (rgb2 & 0x1F) * 3 + 1) / 4) & 0x1F)
4077 | ((((((tmp0 >> 5) & 0x3F) + ((rgb2 >> 5) & 0x3F) * 3 + 1) / 4) & 0x3F) << 5)
4078 | ((((((tmp0 >> 11) & 0x1F) + ((rgb2 >> 11) & 0x1F) * 3 + 1) / 4) & 0x1F) << 11));
4079 #else
4080 *(pDst + dst_pitch - 1) = tmp0; /* save right pixel */
4081 #endif
4082 *(pDst + dst_pitch - 2) = tmp0; // i5 = p4; /* save right pixel */
4083
4084 //load the top two pixels
4085 Y = *pY++;
4086
4087 tmp0 = Y & 0xFF; //Low endian left pixel
4088 tmp0 += OFFSET_5_1;
4089
4090 tmp1 = tmp0 - (Cg >> 16);
4091 tmp2 = tmp0 + (Cb >> 16);
4092 tmp0 = tmp0 + (Cr >> 16);
4093
4094 tmp0 = clip[tmp0];
4095 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
4096 tmp2 = clip[tmp2];
4097
4098
4099 rgb = tmp1 | (tmp0 << 6);
4100 rgb1 = tmp2 | (rgb << 5);
4101
4102 #ifdef INTERPOLATE
4103 *pDst-- = (((((tmp01 & 0x1F) + (rgb1 & 0x1F) + 1) / 2) & 0x1F)
4104 | ((((((tmp01 >> 5) & 0x3F) + ((rgb1 >> 5) & 0x3F) + 1) / 2) & 0x3F) << 5)
4105 | ((((((tmp01 >> 11) & 0x1F) + ((rgb1 >> 11) & 0x1F) + 1) / 2) & 0x1F) << 11));
4106 #else
4107 *pDst-- = rgb1; /* save left pixel */
4108 #endif
4109
4110 Y >>= 8;
4111 Y += OFFSET_5_0;
4112 tmp1 = (Y) - (Cg >> 16);
4113 tmp2 = (Y) + (Cb >> 16);
4114 tmp0 = (Y) + (Cr >> 16);
4115
4116 tmp0 = clip[tmp0];
4117 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
4118 tmp2 = clip[tmp2];
4119
4120 tmp0 = tmp1 | (tmp0 << 6);
4121 tmp0 = tmp2 | (tmp0 << 5);
4122
4123 #ifdef INTERPOLATE
4124 *pDst-- = (((((tmp0 & 0x1F) + (rgb1 & 0x1F) * 3 + 1) / 4) & 0x1F)
4125 | ((((((tmp0 >> 5) & 0x3F) + ((rgb1 >> 5) & 0x3F) * 3 + 1) / 4) & 0x3F) << 5)
4126 | ((((((tmp0 >> 11) & 0x1F) + ((rgb1 >> 11) & 0x1F) * 3 + 1) / 4) & 0x1F) << 11));
4127 #else
4128 *pDst-- = tmp0; /* save right pixel */
4129 #endif
4130 *pDst-- = tmp0; /* save right pixel */
4131
4132 }//end of COL
4133
4134 pY += (deltaY >> 1);
4135 pCb += deltaCbCr;
4136 pCr += deltaCbCr;
4137 pDst++; // go back to the beginning of the line
4138 if (!(row&0x3))
4139 {
4140 oscl_memcpy(pDst + (dst_pitch << 1), pDst + dst_pitch, 2*disp[4]);
4141 pDst += dst_pitch;
4142 #ifdef INTERPOLATE
4143 previous = pDst - dst_pitch;
4144
4145 for (i = 0; i < disp[4]; i++) // linear interpolation
4146 {
4147 int32 last = previous[i];
4148 int32 curr = pDst[i];
4149 pDst[i] = (((((last & 0x1F) + (curr & 0x1F)) / 2) & 0x1F)
4150 | ((((((last >> 5) & 0x3F) + ((curr >> 5) & 0x3F)) / 2) & 0x3F) << 5)
4151 | ((((((last >> 11) & 0x1F) + ((curr >> 11) & 0x1F)) / 2) & 0x1F) << 11));
4152 }
4153 #endif
4154 }
4155
4156 pDst += (deltaDst); //coz pDst defined as UINT *
4157 }
4158 }
4159 else
4160 {
4161 if (disp[6]) /* rotate 180 and flip */
4162 {
4163 /* move the starting point to the bottom-left corner of the picture */
4164 deltaY = src_pitch * (disp[3] - 1);
4165 pY = (uint16*)(src[0] + deltaY);
4166 deltaY = (src_pitch >> 1) * ((disp[3] >> 1) - 1);
4167 pCb = src[1] + deltaY;
4168 pCr = src[2] + deltaY;
4169 deltaY = -src_width - (src_pitch << 1);
4170 deltaCbCr = -((src_width + src_pitch) >> 1);
4171 src_pitch = -(src_pitch >> 1);
4172 }
4173 else // no rotation,no flip,only scale
4174 {
4175 deltaY = (src_pitch << 1) - src_width;
4176 deltaCbCr = (src_pitch - src_width) >> 1;
4177 pY = (uint16 *) src[0];
4178 src_pitch >>= 1;
4179 pCb = src[1];
4180 pCr = src[2];
4181
4182 }
4183
4184 deltaDst = (dst_pitch << 1) - disp[4]; /* disp[4] is dst_width */
4185 pDst = (uint16 *)dst;
4186
4187 for (row = disp[3]; row > 0; row -= 2)
4188 {
4189
4190 for (col = src_width - 1; col >= 0; col -= 4) /* do 8 pixels at a time, 4 ups 2 downs */
4191 {
4192
4193 Cb = *pCb++;
4194 Cr = *pCr++;
4195 Cb -= 128;
4196 Cr -= 128;
4197 Cg = Cr * cc1;
4198 Cr *= cc3;
4199
4200 Cg += Cb * cc2;
4201 Cb *= cc4;
4202
4203 //load the bottom two pixels
4204 Y = pY[src_pitch];
4205
4206 tmp0 = Y & 0xFF; //Low endian left pixel
4207 tmp0 += OFFSET_5_0;
4208
4209 tmp1 = tmp0 - (Cg >> 16);
4210 tmp2 = tmp0 + (Cb >> 16);
4211 tmp0 = tmp0 + (Cr >> 16);
4212
4213 tmp0 = clip[tmp0];
4214 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
4215 tmp2 = clip[tmp2];
4216 //RGB_565
4217
4218 rgb = tmp1 | (tmp0 << 6);
4219 rgb = tmp2 | (rgb << 5);
4220 *(pDst + dst_pitch) = rgb; /* save left pixel, have to save separately */
4221
4222 Y >>= 8;
4223 Y += OFFSET_5_1;
4224 tmp1 = (Y) - (Cg >> 16);
4225 tmp2 = (Y) + (Cb >> 16);
4226 tmp0 = (Y) + (Cr >> 16);
4227
4228 tmp0 = clip[tmp0];
4229 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
4230 tmp2 = clip[tmp2];
4231 //RGB_565
4232 tmp0 = tmp1 | (tmp0 << 6);
4233 tmp02 = tmp2 | (tmp0 << 5);
4234
4235 #ifdef INTERPOLATE
4236 *(pDst + dst_pitch + 1) = (((((tmp02 & 0x1F) * 3 + (rgb & 0x1F) + 2) / 4) & 0x1F)
4237 | ((((((tmp02 >> 5) & 0x3F) * 3 + ((rgb >> 5) & 0x3F) + 2) / 4) & 0x3F) << 5)
4238 | ((((((tmp02 >> 11) & 0x1F) * 3 + ((rgb >> 11) & 0x1F) + 2) / 4) & 0x1F) << 11));
4239 //i2 = (p1 + 3*p2 + 2)>>2;
4240 #else
4241 *(pDst + dst_pitch + 1) = tmp02; /* save right pixel */
4242 #endif
4243 //load the top two pixels
4244 Y = *pY++;
4245
4246 tmp0 = Y & 0xFF; //Low endian left pixel
4247 tmp0 += OFFSET_5_1;
4248
4249 tmp1 = tmp0 - (Cg >> 16);
4250 tmp2 = tmp0 + (Cb >> 16);
4251 tmp0 = tmp0 + (Cr >> 16);
4252
4253 tmp0 = clip[tmp0];
4254 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
4255 tmp2 = clip[tmp2];
4256
4257
4258 rgb = tmp1 | (tmp0 << 6);
4259 rgb = tmp2 | (rgb << 5);
4260
4261 *pDst++ = rgb; /* save left pixel */
4262
4263 Y >>= 8;
4264
4265 Y += OFFSET_5_0;
4266 tmp1 = (Y) - (Cg >> 16);
4267 tmp2 = (Y) + (Cb >> 16);
4268 tmp0 = (Y) + (Cr >> 16);
4269
4270 tmp0 = clip[tmp0];
4271 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
4272 tmp2 = clip[tmp2];
4273
4274 tmp0 = tmp1 | (tmp0 << 6);
4275 tmp01 = tmp2 | (tmp0 << 5);
4276
4277 #ifdef INTERPOLATE
4278 *(pDst++) = (((((tmp01 & 0x1F) * 3 + (rgb & 0x1F) + 2) / 4) & 0x1F)
4279 | ((((((tmp01 >> 5) & 0x3F) * 3 + ((rgb >> 5) & 0x3F) + 2) / 4) & 0x3F) << 5)
4280 | ((((((tmp01 >> 11) & 0x1F) * 3 + ((rgb >> 11) & 0x1F) + 2) / 4) & 0x1F) << 11));
4281 //i2 = (p1 + 3*p2 + 2)>>2;
4282 #else
4283 *pDst++ = tmp01; /* save right pixel */
4284 #endif
4285 /* now do another 4 pixels add 1 pixels in the last column */
4286 Cb = *pCb++;
4287 Cr = *pCr++;
4288
4289 Cb -= 128;
4290 Cr -= 128;
4291 Cg = Cr * cc1;
4292 Cr *= cc3;
4293
4294 Cg += Cb * cc2;
4295 Cb *= cc4;
4296 //load the bottom two pixels
4297 Y = pY[src_pitch];
4298
4299 tmp0 = Y & 0xFF; //Low endian left pixel
4300 tmp0 += OFFSET_5_0;
4301
4302 tmp1 = tmp0 - (Cg >> 16);
4303 tmp2 = tmp0 + (Cb >> 16);
4304 tmp0 = tmp0 + (Cr >> 16);
4305
4306 tmp0 = clip[tmp0];
4307 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
4308 tmp2 = clip[tmp2];
4309 //RGB_565
4310
4311 rgb = tmp1 | (tmp0 << 6);
4312 rgb2 = tmp2 | (rgb << 5);
4313 #ifdef INTERPOLATE
4314 // i3 = (p2 + p3 + 1)>>1;
4315 *(pDst + dst_pitch) = (((((tmp02 & 0x1F) + (rgb2 & 0x1F) + 1) / 2) & 0x1F)
4316 | ((((((tmp02 >> 5) & 0x3F) + ((rgb2 >> 5) & 0x3F) + 1) / 2) & 0x3F) << 5)
4317 | ((((((tmp02 >> 11) & 0x1F) + ((rgb2 >> 11) & 0x1F) + 1) / 2) & 0x1F) << 11));
4318 #else
4319 *(pDst + dst_pitch) = rgb2; /* save left pixel, have to save separately */
4320 #endif
4321 Y >>= 8;
4322 Y += OFFSET_5_1;
4323 tmp1 = (Y) - (Cg >> 16);
4324 tmp2 = (Y) + (Cb >> 16);
4325 tmp0 = (Y) + (Cr >> 16);
4326
4327 tmp0 = clip[tmp0];
4328 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
4329 tmp2 = clip[tmp2];
4330 //RGB_565
4331 tmp0 = tmp1 | (tmp0 << 6);
4332 tmp0 = tmp2 | (tmp0 << 5);
4333
4334 #ifdef INTERPOLATE
4335 *(pDst + dst_pitch + 1) = (((((tmp0 & 0x1F) + (rgb2 & 0x1F) * 3 + 1) / 4) & 0x1F)
4336 | ((((((tmp0 >> 5) & 0x3F) + ((rgb2 >> 5) & 0x3F) * 3 + 1) / 4) & 0x3F) << 5)
4337 | ((((((tmp0 >> 11) & 0x1F) + ((rgb2 >> 11) & 0x1F) * 3 + 1) / 4) & 0x1F) << 11));
4338 #else
4339 *(pDst + dst_pitch + 1) = tmp0; /* save right pixel */
4340 #endif
4341 *(pDst + dst_pitch + 2) = tmp0; /* save right pixel */ //Ankur
4342 //load the top two pixels
4343 Y = *pY++;
4344
4345 tmp0 = Y & 0xFF; //Low endian left pixel
4346 tmp0 += OFFSET_5_1;
4347
4348 tmp1 = tmp0 - (Cg >> 16);
4349 tmp2 = tmp0 + (Cb >> 16);
4350 tmp0 = tmp0 + (Cr >> 16);
4351
4352 tmp0 = clip[tmp0];
4353 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
4354 tmp2 = clip[tmp2];
4355
4356
4357 rgb = tmp1 | (tmp0 << 6);
4358 rgb1 = tmp2 | (rgb << 5);
4359 #ifdef INTERPOLATE
4360 *pDst++ = (((((tmp01 & 0x1F) + (rgb1 & 0x1F) + 1) / 2) & 0x1F)
4361 | ((((((tmp01 >> 5) & 0x3F) + ((rgb1 >> 5) & 0x3F) + 1) / 2) & 0x3F) << 5)
4362 | ((((((tmp01 >> 11) & 0x1F) + ((rgb1 >> 11) & 0x1F) + 1) / 2) & 0x1F) << 11));
4363 #else
4364 *pDst++ = rgb1; /* save left pixel */
4365 #endif
4366 Y >>= 8;
4367 Y += OFFSET_5_0;
4368 tmp1 = (Y) - (Cg >> 16);
4369 tmp2 = (Y) + (Cb >> 16);
4370 tmp0 = (Y) + (Cr >> 16);
4371
4372 tmp0 = clip[tmp0];
4373 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
4374 tmp2 = clip[tmp2];
4375
4376 tmp0 = tmp1 | (tmp0 << 6);
4377 tmp0 = tmp2 | (tmp0 << 5);
4378
4379 #ifdef INTERPOLATE
4380 *pDst++ = (((((tmp0 & 0x1F) + (rgb1 & 0x1F) * 3 + 1) / 4) & 0x1F)
4381 | ((((((tmp0 >> 5) & 0x3F) + ((rgb1 >> 5) & 0x3F) * 3 + 1) / 4) & 0x3F) << 5)
4382 | ((((((tmp0 >> 11) & 0x1F) + ((rgb1 >> 11) & 0x1F) * 3 + 1) / 4) & 0x1F) << 11));
4383 #else
4384 *pDst++ = tmp0; /* save right pixel */
4385 #endif
4386 *pDst++ = tmp0; /* save right pixel */ // Ankur
4387 }//end of COL
4388
4389 pY += (deltaY >> 1);
4390 pCb += deltaCbCr;
4391 pCr += deltaCbCr;
4392 pDst += (deltaDst); //coz pDst defined as UINT *
4393
4394 /************
4395 interpolating 3rd row in between
4396 row1
4397 row2
4398 inter1
4399 row3
4400 row4
4401 **************/
4402
4403 if (!(row&0x3))
4404 {
4405 #ifdef INTERPOLATE
4406 pFifth = pDst; // interpolating 3rd line in between
4407 copyline = 0;
4408 #else
4409 oscl_memcpy(pDst, pDst - dst_pitch, 2*disp[4]);
4410 #endif
4411 pDst += dst_pitch;
4412 }
4413 #ifdef INTERPOLATE
4414 if (copyline)
4415 {
4416 previous = pFifth - dst_pitch;
4417 current = pDst - (dst_pitch * 2);
4418
4419 for (i = 0; i < disp[4]; i++) // linear interpolation
4420 {
4421 int32 last = previous[i];
4422 int32 curr = current[i];
4423 pFifth[i] = (((((last & 0x1F) + (curr & 0x1F)) / 2) & 0x1F)
4424 | ((((((last >> 5) & 0x3F) + ((curr >> 5) & 0x3F)) / 2) & 0x3F) << 5)
4425 | ((((((last >> 11) & 0x1F) + ((curr >> 11) & 0x1F)) / 2) & 0x1F) << 11));
4426 }
4427
4428 }
4429
4430 copyline++;
4431 #endif
4432 }
4433 }
4434 return 1;
4435 #else
4436 OSCL_UNUSED_ARG(src);
4437 OSCL_UNUSED_ARG(dst);
4438 OSCL_UNUSED_ARG(disp);
4439 OSCL_UNUSED_ARG(coff_tbl);
4440
4441 return 0;
4442 #endif // CCSCALING
4443 }
4444
4445 /* special 4:3 scale-up color conversion */
cc16scaling43(uint8 ** src,uint8 * dst,int32 * disp,uint8 * coff_tbl)4446 int32 cc16scaling43(uint8 **src, uint8 *dst,
4447 int32 *disp, uint8 *coff_tbl)
4448 {
4449 #if CCSCALING
4450 uint8 *pCb, *pCr;
4451 uint16 *pY;
4452 uint16 *pDst;
4453 int32 src_pitch, dst_pitch, src_width;
4454 int32 Y, Cb, Cr, Cg;
4455 int32 deltaY, deltaCbCr;
4456 int32 row, col;
4457 int32 tmp0, tmp1, tmp2;
4458 uint32 rgb;
4459 uint8 *clip = coff_tbl + 400;
4460 int32 col3, row3;
4461 int32 cc1 = (*((int32*)(clip - 400)));
4462 int32 cc3 = (*((int32*)(clip - 396)));
4463 int32 cc2 = (*((int32*)(clip - 392)));
4464 int32 cc4 = (*((int32*)(clip - 388)));
4465
4466 #ifdef INTERPOLATE
4467 int i;
4468 uint32 copyline = 0; //maru
4469 uint16 *prev_pDst = 0; //maru
4470 int32 prev_offset = 0; //maru
4471 #endif
4472
4473 src_pitch = disp[0];
4474 dst_pitch = disp[1];
4475 src_width = disp[2];
4476
4477 if (((disp[6] == 0 && disp[7] == 1)) || ((disp[6] == 1) && (disp[7] == 0))) /* rotate 0 and flip // rotate 180, no flip*/
4478 {
4479 if (disp[6] == 0)
4480 {
4481 deltaY = (src_pitch << 1) - src_width;
4482 deltaCbCr = (src_pitch - src_width) >> 1;
4483 pY = (uint16 *) src[0];
4484 src_pitch >>= 1;
4485 pCb = src[1];
4486 pCr = src[2];
4487 }
4488 else
4489 { /* move the starting point to the bottom-left corner of the picture */
4490 deltaY = src_pitch * (disp[3] - 1);
4491 pY = (uint16*)(src[0] + deltaY);
4492 deltaY = (src_pitch >> 1) * ((disp[3] >> 1) - 1);
4493 pCb = src[1] + deltaY;
4494 pCr = src[2] + deltaY;
4495 deltaY = -src_width - (src_pitch << 1);
4496 deltaCbCr = -((src_width + src_pitch) >> 1);
4497 src_pitch = -(src_pitch >> 1);
4498 }
4499
4500 pDst = ((uint16 *)dst) + disp[4] - 1;
4501 row3 = 2;
4502 for (row = disp[3]; row > 0; row -= 2)
4503 {
4504 col3 = 2;
4505 if (row3 == 1)
4506 {
4507 dst_pitch <<= 1;
4508 }
4509
4510 for (col = src_width - 1; col >= 0; col -= 4)
4511 { /* do 8 pixels at a time, 2 ups 2 downs */
4512 Cb = *pCb++;
4513 Cr = *pCr++;
4514 Cb -= 128;
4515 Cr -= 128;
4516 Cg = Cr * cc1;
4517 Cr *= cc3;
4518
4519 Cg += Cb * cc2;
4520 Cb *= cc4;
4521
4522 //load the bottom two pixels
4523 Y = pY[src_pitch];
4524
4525 tmp0 = Y & 0xFF; //Low endian left pixel
4526 tmp0 += OFFSET_5_0;
4527
4528 tmp1 = tmp0 - (Cg >> 16);
4529 tmp2 = tmp0 + (Cb >> 16);
4530 tmp0 = tmp0 + (Cr >> 16);
4531
4532 tmp0 = clip[tmp0];
4533 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
4534 tmp2 = clip[tmp2];
4535 //RGB_565
4536
4537 rgb = tmp1 | (tmp0 << 6);
4538 rgb = tmp2 | (rgb << 5);
4539 *(pDst += dst_pitch) = rgb; /* save left pixel, have to save separately */
4540
4541 Y >>= 8;
4542 Y += OFFSET_5_1;
4543 tmp1 = (Y) - (Cg >> 16);
4544 tmp2 = (Y) + (Cb >> 16);
4545 tmp0 = (Y) + (Cr >> 16);
4546
4547 tmp0 = clip[tmp0];
4548 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
4549 tmp2 = clip[tmp2];
4550 //RGB_565
4551 tmp0 = tmp1 | (tmp0 << 6);
4552 tmp0 = tmp2 | (tmp0 << 5);
4553
4554 if (col3 == 0)
4555 {
4556 #ifndef INTERPOLATE
4557 //*(++pDst) = rgb; /* repeat this pixel */
4558 *(--pDst) = rgb; /* repeat this pixel */
4559 #else
4560 *(--pDst) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
4561 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
4562 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
4563 #endif
4564 }
4565 #ifndef INTERPOLATE
4566 //*(pDst+1) = tmp0; /* save right pixel */Ankur
4567 *(pDst - 1) = tmp0; /* save right pixel */
4568 if (col3 == 1)
4569 {
4570 //*(pDst+2) = tmp0; /* repeat this pixel */Ankur
4571 *(pDst - 2) = tmp0; /* repeat this pixel */
4572 }
4573 #else
4574 if (col3 != 1)
4575 {
4576 *(pDst - 1) = tmp0;
4577 }
4578 else
4579 {
4580 *(pDst - 2) = tmp0;
4581 *(pDst - 1) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
4582 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
4583 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
4584 }
4585 #endif
4586
4587 //load the top two pixels
4588 Y = *pY++;
4589
4590 tmp0 = Y & 0xFF; //Low endian left pixel
4591 tmp0 += OFFSET_5_1;
4592
4593 tmp1 = tmp0 - (Cg >> 16);
4594 tmp2 = tmp0 + (Cb >> 16);
4595 tmp0 = tmp0 + (Cr >> 16);
4596
4597 tmp0 = clip[tmp0];
4598 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
4599 tmp2 = clip[tmp2];
4600
4601
4602 rgb = tmp1 | (tmp0 << 6);
4603 rgb = tmp2 | (rgb << 5);
4604
4605 Y >>= 8;
4606 Y += OFFSET_5_0;
4607 tmp1 = (Y) - (Cg >> 16);
4608 tmp2 = (Y) + (Cb >> 16);
4609 tmp0 = (Y) + (Cr >> 16);
4610
4611 tmp0 = clip[tmp0];
4612 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
4613 tmp2 = clip[tmp2];
4614
4615 tmp0 = tmp1 | (tmp0 << 6);
4616 tmp0 = tmp2 | (tmp0 << 5);
4617
4618 #ifndef INTERPOLATE
4619 *(pDst -= dst_pitch) = rgb; /* save left pixel */
4620 if (col3 == 0)
4621 {
4622 pDst[1] = rgb; /* repeat this pixel */
4623 }
4624 #else
4625 if (col3 != 0)
4626 {
4627 *(pDst -= dst_pitch) = rgb; /* save left pixel */
4628 }
4629 else
4630 {
4631 *(pDst -= dst_pitch) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
4632 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
4633 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
4634 pDst[1] = rgb;
4635 }
4636 #endif
4637 #ifndef INTERPOLATE
4638 *(--pDst) = tmp0; /* save right pixel */
4639 if (col3 == 1)
4640 {
4641 *(--pDst) = tmp0; /* save right pixel */
4642 }
4643 #else
4644 if (col3 != 1)
4645 {
4646 *(--pDst) = tmp0; /* save right pixel */
4647 }
4648 else
4649 {
4650 *(--pDst) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
4651 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
4652 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
4653 *(--pDst) = tmp0;
4654 }
4655 #endif
4656
4657 pDst--;
4658
4659 Cb = *pCb++;
4660 Cr = *pCr++;
4661 Cb -= 128;
4662 Cr -= 128;
4663 Cg = Cr * cc1;
4664 Cr *= cc3;
4665
4666 Cg += Cb * cc2;
4667 Cb *= cc4;
4668
4669 //load the bottom two pixels
4670 Y = pY[src_pitch];
4671
4672 tmp0 = Y & 0xFF; //Low endian left pixel
4673 tmp0 += OFFSET_5_0;
4674
4675 tmp1 = tmp0 - (Cg >> 16);
4676 tmp2 = tmp0 + (Cb >> 16);
4677 tmp0 = tmp0 + (Cr >> 16);
4678
4679 tmp0 = clip[tmp0];
4680 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
4681 tmp2 = clip[tmp2];
4682 //RGB_565
4683
4684 rgb = tmp1 | (tmp0 << 6);
4685 rgb = tmp2 | (rgb << 5);
4686 *(pDst += dst_pitch) = rgb; /* save left pixel, have to save separately */
4687
4688 Y >>= 8;
4689 Y += OFFSET_5_1;
4690 tmp1 = (Y) - (Cg >> 16);
4691 tmp2 = (Y) + (Cb >> 16);
4692 tmp0 = (Y) + (Cr >> 16);
4693
4694 tmp0 = clip[tmp0];
4695 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
4696 tmp2 = clip[tmp2];
4697
4698 //RGB_565
4699 tmp0 = tmp1 | (tmp0 << 6);
4700 tmp0 = tmp2 | (tmp0 << 5);
4701
4702 if (col3 == 2)
4703 {
4704 #ifndef INTERPOLATE
4705 *(--pDst) = rgb;
4706 #else
4707 *(--pDst) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
4708 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
4709 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
4710 #endif
4711 }
4712
4713 #ifndef INTERPOLATE
4714 *(pDst - 1) = tmp0; /* save right pixel */
4715 if (col3 == 0)
4716 {
4717 *(pDst - 2) = tmp0; /* repeat this pixel */
4718 }
4719 #else
4720 if (col3 != 0)
4721 {
4722 *(pDst - 1) = tmp0; /* save right pixel */
4723 }
4724 else
4725 {
4726 *(pDst - 2) = tmp0; /* save right pixel */
4727 *(pDst - 1) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
4728 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
4729 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
4730 }
4731 #endif
4732
4733 //load the top two pixels
4734 Y = *pY++;
4735
4736 tmp0 = Y & 0xFF; //Low endian left pixel
4737 tmp0 += OFFSET_5_1;
4738
4739 tmp1 = tmp0 - (Cg >> 16);
4740 tmp2 = tmp0 + (Cb >> 16);
4741 tmp0 = tmp0 + (Cr >> 16);
4742
4743 tmp0 = clip[tmp0];
4744 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
4745 tmp2 = clip[tmp2];
4746
4747
4748 rgb = tmp1 | (tmp0 << 6);
4749 rgb = tmp2 | (rgb << 5);
4750
4751 Y >>= 8;
4752 Y += OFFSET_5_0;
4753 tmp1 = (Y) - (Cg >> 16);
4754 tmp2 = (Y) + (Cb >> 16);
4755 tmp0 = (Y) + (Cr >> 16);
4756
4757 tmp0 = clip[tmp0];
4758 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
4759 tmp2 = clip[tmp2];
4760
4761 tmp0 = tmp1 | (tmp0 << 6);
4762 tmp0 = tmp2 | (tmp0 << 5);
4763 #ifndef INTERPOLATE
4764 *(pDst -= dst_pitch) = rgb; /* save left pixel */
4765 if (col3 == 2)
4766 {
4767 pDst[1] = rgb; /* repeat this pixel */
4768 }
4769 #else
4770 if (col3 != 2)
4771 {
4772 *(pDst -= dst_pitch) = rgb; /* save left pixel */
4773 }
4774 else
4775 {
4776 *(pDst -= dst_pitch) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
4777 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
4778 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
4779 pDst[1] = rgb;
4780 }
4781 #endif
4782
4783 #ifndef INTERPOLATE
4784 *(--pDst) = tmp0; /* save right pixel */
4785 if (col3 == 0)
4786 {
4787 *(--pDst) = tmp0;
4788 }
4789 #else
4790 if (col3 != 0)
4791 {
4792 *(--pDst) = tmp0; /* save right pixel */
4793 }
4794 else
4795 {
4796 *(--pDst) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
4797 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
4798 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
4799 *(--pDst) = tmp0; /* save right pixel */
4800 }
4801 #endif
4802
4803 pDst--;
4804
4805 col3--;
4806 if (col3 < 0)
4807 {
4808 col3 = 2;
4809 }
4810 }//end of COL
4811
4812 pY += (deltaY >> 1);
4813 pCb += deltaCbCr;
4814 pCr += deltaCbCr;
4815 if (row3 == 1)
4816 {
4817 dst_pitch >>= 1;
4818 }
4819 dst += (dst_pitch << 2);
4820
4821 if (row3 == 1)
4822 {
4823 #ifndef INTERPOLATE
4824 oscl_memcpy(dst - (dst_pitch << 1), dst - (dst_pitch << 2), 2*disp[4]);
4825 #else
4826 prev_pDst = (uint16*)(dst - (dst_pitch << 2));
4827 for (i = 0; i < dst_pitch; i++)
4828 {
4829 int32 coltemp;
4830 int32 pretemp = *(prev_pDst + i);
4831 int32 curtemp = *((uint16*)dst + i);
4832 coltemp = (((((pretemp & 0x1F) + (curtemp & 0x1F)) / 2) & 0x1F)
4833 | ((((((pretemp >> 5) & 0x3F) + ((curtemp >> 5) & 0x3F)) / 2) & 0x3F) << 5)
4834 | ((((((pretemp >> 11) & 0x1F) + ((curtemp >> 11) & 0x1F)) / 2) & 0x1F) << 11));
4835 *(prev_pDst + dst_pitch + i) = (uint16)coltemp;
4836 }
4837 #endif
4838 dst += (dst_pitch << 1);
4839 }
4840 else if (row3 == 0)
4841 {
4842 oscl_memcpy(dst, dst - (dst_pitch << 1), 2*disp[4]);
4843 #ifdef INTERPOLATE
4844 prev_pDst = (uint16*)(dst - (dst_pitch << 2));
4845 for (i = 0; i < dst_pitch; i++)
4846 {
4847 int32 coltemp;
4848 int32 pretemp = *(prev_pDst + i);
4849 int32 curtemp = *((uint16*)dst + i);
4850 coltemp = (((((pretemp & 0x1F) + (curtemp & 0x1F)) / 2) & 0x1F)
4851 | ((((((pretemp >> 5) & 0x3F) + ((curtemp >> 5) & 0x3F)) / 2) & 0x3F) << 5)
4852 | ((((((pretemp >> 11) & 0x1F) + ((curtemp >> 11) & 0x1F)) / 2) & 0x1F) << 11));
4853 *(prev_pDst + dst_pitch + i) = (uint16)coltemp;
4854 }
4855 #endif
4856 dst += (dst_pitch << 1);
4857 }
4858 row3--;
4859
4860 if (row3 < 0)
4861 {
4862 row3 = 2;
4863 }
4864
4865 pDst = ((uint16*)dst) + disp[4] - 1;
4866 }
4867 }
4868 else /* rotate 180 and flip || no rotation,no flip */
4869 {
4870 if (disp[6]) /* rotate 180 and flip */
4871 {
4872 /* move the starting point to the bottom-left corner of the picture */
4873 deltaY = src_pitch * (disp[3] - 1);
4874 pY = (uint16*)(src[0] + deltaY);
4875 deltaY = (src_pitch >> 1) * ((disp[3] >> 1) - 1);
4876 pCb = src[1] + deltaY;
4877 pCr = src[2] + deltaY;
4878 deltaY = -src_width - (src_pitch << 1);
4879 deltaCbCr = -((src_width + src_pitch) >> 1);
4880 src_pitch = -(src_pitch >> 1);
4881 }
4882 else // no rotation,no flip
4883 {
4884 deltaY = (src_pitch << 1) - src_width;
4885 deltaCbCr = (src_pitch - src_width) >> 1;
4886 pY = (uint16 *) src[0];
4887 src_pitch >>= 1;
4888 pCb = src[1];
4889 pCr = src[2];
4890 }
4891 pDst = (uint16 *)dst;
4892 row3 = 2;
4893
4894 for (row = disp[3]; row > 0; row -= 2)
4895 {
4896 col3 = 2;
4897
4898 if (row3 == 1)
4899 {
4900 dst_pitch <<= 1;
4901 }
4902
4903 for (col = src_width - 1; col >= 0; col -= 4)
4904 { /* do 8 pixels at a time, 2 ups 2 downs */
4905 Cb = *pCb++;
4906 Cr = *pCr++;
4907 Cb -= 128;
4908 Cr -= 128;
4909 Cg = Cr * cc1;
4910 Cr *= cc3;
4911
4912 Cg += Cb * cc2;
4913 Cb *= cc4;
4914
4915 //load the bottom two pixels
4916 Y = pY[src_pitch];
4917
4918 tmp0 = Y & 0xFF; //Low endian left pixel
4919 tmp0 += OFFSET_5_0;
4920
4921 tmp1 = tmp0 - (Cg >> 16);
4922 tmp2 = tmp0 + (Cb >> 16);
4923 tmp0 = tmp0 + (Cr >> 16);
4924
4925 tmp0 = clip[tmp0];
4926 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
4927 tmp2 = clip[tmp2];
4928 //RGB_565
4929
4930 rgb = tmp1 | (tmp0 << 6);
4931 rgb = tmp2 | (rgb << 5);
4932 *(pDst += dst_pitch) = rgb; /* save left pixel, have to save separately */
4933
4934 Y >>= 8;
4935 Y += OFFSET_5_1;
4936 tmp1 = (Y) - (Cg >> 16);
4937 tmp2 = (Y) + (Cb >> 16);
4938 tmp0 = (Y) + (Cr >> 16);
4939
4940 tmp0 = clip[tmp0];
4941 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
4942 tmp2 = clip[tmp2];
4943 //RGB_565
4944 tmp0 = tmp1 | (tmp0 << 6);
4945 tmp0 = tmp2 | (tmp0 << 5);
4946
4947 if (col3 == 0)
4948 {
4949 #ifndef INTERPOLATE
4950 *(++pDst) = rgb; /* repeat this pixel */
4951 #else
4952 *(++pDst) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
4953 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
4954 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
4955 #endif
4956 }
4957
4958 #ifndef INTERPOLATE
4959 *(pDst + 1) = tmp0; /* save right pixel */
4960 if (col3 == 1)
4961 {
4962 *(pDst + 2) = tmp0; /* repeat this pixel */
4963 }
4964 #else
4965 if (col3 != 1)
4966 {
4967 *(pDst + 1) = tmp0;
4968 }
4969 else
4970 {
4971 *(pDst + 2) = tmp0;
4972 *(pDst + 1) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
4973 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
4974 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
4975 }
4976 #endif
4977 //load the top two pixels
4978 Y = *pY++;
4979
4980 tmp0 = Y & 0xFF; //Low endian left pixel
4981 tmp0 += OFFSET_5_1;
4982
4983 tmp1 = tmp0 - (Cg >> 16);
4984 tmp2 = tmp0 + (Cb >> 16);
4985 tmp0 = tmp0 + (Cr >> 16);
4986
4987 tmp0 = clip[tmp0];
4988 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
4989 tmp2 = clip[tmp2];
4990
4991
4992 rgb = tmp1 | (tmp0 << 6);
4993 rgb = tmp2 | (rgb << 5);
4994 Y >>= 8;
4995 Y += OFFSET_5_0;
4996 tmp1 = (Y) - (Cg >> 16);
4997 tmp2 = (Y) + (Cb >> 16);
4998 tmp0 = (Y) + (Cr >> 16);
4999
5000 tmp0 = clip[tmp0];
5001 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
5002 tmp2 = clip[tmp2];
5003
5004 tmp0 = tmp1 | (tmp0 << 6);
5005 tmp0 = tmp2 | (tmp0 << 5);
5006
5007 #ifndef INTERPOLATE
5008 *(pDst -= dst_pitch) = rgb; /* save left pixel */
5009 if (col3 == 0)
5010 {
5011 pDst[-1] = rgb; /* repeat this pixel */
5012 }
5013 #else
5014 if (col3 != 0)
5015 {
5016 *(pDst -= dst_pitch) = rgb; /* save left pixel */
5017 }
5018 else
5019 {
5020 *(pDst -= dst_pitch) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
5021 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
5022 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
5023 pDst[-1] = rgb;
5024 }
5025 #endif
5026
5027 #ifndef INTERPOLATE
5028 *(++pDst) = tmp0; /* save right pixel */
5029 if (col3 == 1)
5030 {
5031 *(++pDst) = tmp0; /* save right pixel */
5032 }
5033 #else
5034 if (col3 != 1)
5035 {
5036 *(++pDst) = tmp0; /* save right pixel */
5037 }
5038 else
5039 {
5040 *(++pDst) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
5041 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
5042 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
5043 *(++pDst) = tmp0;
5044 }
5045 #endif
5046 pDst++;
5047
5048 Cb = *pCb++;
5049 Cr = *pCr++;
5050 Cb -= 128;
5051 Cr -= 128;
5052 Cg = Cr * cc1;
5053 Cr *= cc3;
5054
5055 Cg += Cb * cc2;
5056 Cb *= cc4;
5057
5058 //load the bottom two pixels
5059 Y = pY[src_pitch];
5060
5061 tmp0 = Y & 0xFF; //Low endian left pixel
5062 tmp0 += OFFSET_5_0;
5063
5064 tmp1 = tmp0 - (Cg >> 16);
5065 tmp2 = tmp0 + (Cb >> 16);
5066 tmp0 = tmp0 + (Cr >> 16);
5067
5068 tmp0 = clip[tmp0];
5069 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
5070 tmp2 = clip[tmp2];
5071
5072 //RGB_565
5073
5074 rgb = tmp1 | (tmp0 << 6);
5075 rgb = tmp2 | (rgb << 5);
5076
5077 *(pDst += dst_pitch) = rgb;
5078
5079 Y >>= 8;
5080 Y += OFFSET_5_1;
5081 tmp1 = (Y) - (Cg >> 16);
5082 tmp2 = (Y) + (Cb >> 16);
5083 tmp0 = (Y) + (Cr >> 16);
5084
5085 tmp0 = clip[tmp0];
5086 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
5087 tmp2 = clip[tmp2];
5088 //RGB_565
5089 tmp0 = tmp1 | (tmp0 << 6);
5090 tmp0 = tmp2 | (tmp0 << 5);
5091 if (col3 == 2)
5092 {
5093 #ifndef INTERPOLATE
5094 *(++pDst) = rgb; /* repeat this pixel */
5095 #else
5096 *(++pDst) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
5097 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
5098 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
5099 #endif
5100 }
5101
5102 #ifndef INTERPOLATE
5103 *(pDst + 1) = tmp0; /* save right pixel */
5104 if (col3 == 0)
5105 {
5106 *(pDst + 2) = tmp0; /* repeat this pixel */
5107 }
5108 #else
5109 if (col3 != 0)
5110 {
5111 *(pDst + 1) = tmp0; /* save right pixel */
5112 }
5113 else
5114 {
5115 *(pDst + 2) = tmp0; /* save right pixel */
5116 *(pDst + 1) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
5117 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
5118 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
5119 }
5120 #endif
5121 //load the top two pixels
5122 Y = *pY++;
5123
5124 tmp0 = Y & 0xFF; //Low endian left pixel
5125 tmp0 += OFFSET_5_1;
5126
5127 tmp1 = tmp0 - (Cg >> 16);
5128 tmp2 = tmp0 + (Cb >> 16);
5129 tmp0 = tmp0 + (Cr >> 16);
5130
5131 tmp0 = clip[tmp0];
5132 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
5133 tmp2 = clip[tmp2];
5134
5135
5136 rgb = tmp1 | (tmp0 << 6);
5137 rgb = tmp2 | (rgb << 5);
5138
5139 Y >>= 8;
5140 Y += OFFSET_5_0;
5141 tmp1 = (Y) - (Cg >> 16);
5142 tmp2 = (Y) + (Cb >> 16);
5143 tmp0 = (Y) + (Cr >> 16);
5144
5145 tmp0 = clip[tmp0];
5146 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
5147 tmp2 = clip[tmp2];
5148
5149 tmp0 = tmp1 | (tmp0 << 6);
5150 tmp0 = tmp2 | (tmp0 << 5);
5151 #ifndef INTERPOLATE
5152 *(pDst -= dst_pitch) = rgb; /* save left pixel */
5153 if (col3 == 2)
5154 {
5155 pDst[-1] = rgb; /* repeat this pixel */
5156 }
5157 #else
5158 if (col3 != 2)
5159 {
5160 *(pDst -= dst_pitch) = rgb; /* save left pixel */
5161 }
5162 else
5163 {
5164 *(pDst -= dst_pitch) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
5165 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
5166 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
5167 pDst[-1] = rgb;
5168 }
5169 #endif
5170
5171 #ifndef INTERPOLATE
5172 *(++pDst) = tmp0; /* save right pixel */
5173 if (col3 == 0)
5174 {
5175 *(++pDst) = tmp0; /* save right pixel */
5176 }
5177 #else
5178 if (col3 != 0)
5179 {
5180 *(++pDst) = tmp0; /* save right pixel */
5181 }
5182 else
5183 {
5184 *(++pDst) = (((((tmp0 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
5185 | ((((((tmp0 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
5186 | ((((((tmp0 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
5187 *(++pDst) = tmp0; /* save right pixel */
5188 }
5189 #endif
5190 pDst++;
5191
5192 col3--;
5193 if (col3 < 0)
5194 {
5195 col3 = 2;
5196 }
5197 }//end of COL
5198
5199 pY += (deltaY >> 1);
5200 pCb += deltaCbCr;
5201 pCr += deltaCbCr;
5202 if (row3 == 1)
5203 {
5204 dst_pitch >>= 1;
5205 }
5206 dst += (dst_pitch << 2);
5207 if (row3 == 1)
5208 {
5209 #ifndef INTERPOLATE
5210 oscl_memcpy(dst - (dst_pitch << 1), dst - (dst_pitch << 2), 2*disp[4]);
5211 #else
5212 prev_pDst = (uint16*)(dst - (dst_pitch << 2));
5213 for (i = 0; i < dst_pitch; i++)
5214 {
5215 int32 coltemp;
5216 int32 pretemp = *(prev_pDst + i);
5217 int32 curtemp = *((uint16*)dst + i);
5218 coltemp = (((((pretemp & 0x1F) + (curtemp & 0x1F)) / 2) & 0x1F)
5219 | ((((((pretemp >> 5) & 0x3F) + ((curtemp >> 5) & 0x3F)) / 2) & 0x3F) << 5)
5220 | ((((((pretemp >> 11) & 0x1F) + ((curtemp >> 11) & 0x1F)) / 2) & 0x1F) << 11));
5221 *(prev_pDst + dst_pitch + i) = (uint16)coltemp;
5222 }
5223 #endif
5224 dst += (dst_pitch << 1);
5225 }
5226 else if (row3 == 0)
5227 {
5228 oscl_memcpy(dst, dst - (dst_pitch << 1), 2*disp[4]);
5229
5230 #ifdef INTERPOLATE
5231 prev_pDst = (uint16*)(dst - (dst_pitch << 2));
5232 for (i = 0; i < dst_pitch; i++)
5233 {
5234 int32 coltemp;
5235 int32 pretemp = *(prev_pDst + i);
5236 int32 curtemp = *((uint16*)dst + i);
5237 coltemp = (((((pretemp & 0x1F) + (curtemp & 0x1F)) / 2) & 0x1F)
5238 | ((((((pretemp >> 5) & 0x3F) + ((curtemp >> 5) & 0x3F)) / 2) & 0x3F) << 5)
5239 | ((((((pretemp >> 11) & 0x1F) + ((curtemp >> 11) & 0x1F)) / 2) & 0x1F) << 11));
5240 *(prev_pDst + dst_pitch + i) = (uint16)coltemp;
5241 }
5242 #endif
5243 dst += (dst_pitch << 1);
5244 }
5245
5246 row3--;
5247 if (row3 < 0)
5248 {
5249 row3 = 2;
5250 }
5251
5252 pDst = (uint16*)dst;
5253 }
5254 }
5255
5256 return 1;
5257 #else
5258 OSCL_UNUSED_ARG(src);
5259 OSCL_UNUSED_ARG(dst);
5260 OSCL_UNUSED_ARG(disp);
5261 OSCL_UNUSED_ARG(coff_tbl);
5262
5263 return 0;
5264 #endif // CCSCALING
5265 }
5266
5267
5268 // platform specfic function in C
5269 int32 cc16sc_rotate(uint8 **src, uint8 *dst, int32 *disp,
5270 uint8 *coff_tbl, uint8 *_mRowPix,
5271 uint8 *_mColPix, bool _mIsRotateClkwise, int32 flip); // ankur
5272
5273 /////////////////////////////////////////////////////////////////////////////
5274 // Note:: This zoom algorithm needs an extra line of RGB buffer. So, users
5275 // have to use GetRGBBufferSize API to get the size it needs. See GetRGBBufferSize().
cc16ZoomRotate(uint8 ** src,uint8 * dst,DisplayProperties * disp,uint8 * coff_tbl)5276 int32 ColorConvert16::cc16ZoomRotate(uint8 **src, uint8 *dst,
5277 DisplayProperties *disp, uint8 *coff_tbl)
5278 {
5279 int32 disp_prop[6];
5280 int32 flip; // ankur
5281
5282 disp_prop[0] = disp->src_pitch;
5283 disp_prop[1] = disp->dst_pitch;
5284 disp_prop[2] = disp->src_width;
5285 disp_prop[3] = disp->src_height;
5286 disp_prop[4] = disp->dst_width;
5287 disp_prop[5] = disp->dst_height;
5288
5289 flip = _mIsFlip;
5290 return cc16sc_rotate(src, dst, disp_prop, coff_tbl, _mRowPix, _mColPix, (_mRotation == CCROTATE_CLKWISE), flip);
5291 }
5292
cc16sc_rotate(uint8 ** src,uint8 * dst,int32 * disp,uint8 * coff_tbl,uint8 * _mRowPix,uint8 * _mColPix,bool _mIsRotateClkwise,int32 flip)5293 int32 cc16sc_rotate(uint8 **src, uint8 *dst, int32 *disp,
5294 uint8 *coff_tbl, uint8 *_mRowPix,
5295 uint8 *_mColPix, bool _mIsRotateClkwise, int32 flip) // ankur
5296 {
5297 #if (CCROTATE && CCSCALING)
5298 /* 1. move the dst pointer to the line above the border
5299 2. do 2 line conversion
5300 3. copy both up & down
5301 */
5302 uint8 *pCb, *pCr;
5303 uint8 *pY;
5304 uint16 *pDst;
5305 int32 src_pitch, dst_pitch, src_width;
5306 int32 Y, Cb, Cr, Cg;
5307 int32 deltaY, dst_width, deltaCbCr, dst_inc, dst_start_pos;
5308 int32 row, col;
5309 int32 tmp0, tmp1, tmp2;
5310 uint32 rgb;
5311 uint8 *clip = coff_tbl + 400;
5312 int32 offset;
5313 int32 cc1 = (*((int32*)(clip - 400)));
5314 int32 cc3 = (*((int32*)(clip - 396)));
5315 int32 cc2 = (*((int32*)(clip - 392)));
5316 int32 cc4 = (*((int32*)(clip - 388)));
5317
5318 src_pitch = disp[0];
5319 dst_pitch = disp[1];
5320 src_width = disp[2];
5321 dst_width = disp[4];
5322
5323 #ifdef INTERPOLATE
5324 int32 prgb1;
5325 int32 prgb2;
5326 int32 prgb3;
5327 int32 prgb4;
5328 #endif
5329
5330 if (_mIsRotateClkwise)
5331 {
5332 deltaY = src_pitch * disp[3] + 2;
5333 deltaCbCr = ((src_pitch * disp[3]) >> 2) + 1;
5334 }
5335 else // rotate counterclockwise
5336 {
5337 deltaY = -(src_pitch * disp[3] + 2);
5338 deltaCbCr = -(((src_pitch * disp[3]) >> 2) + 1);
5339 }
5340
5341 // map origin of the destination to the source
5342 if (_mIsRotateClkwise)
5343 {
5344 pY = src[0] + src_pitch * (disp[3] - 1);
5345 pCb = src[1] + ((src_pitch >> 1) * ((disp[3] >> 1) - 1));
5346 pCr = src[2] + ((src_pitch >> 1) * ((disp[3] >> 1) - 1));
5347 }
5348 else // rotate counterclockwise
5349 {
5350 pY = src[0] + src_width - 1;
5351 pCb = src[1] + (src_width >> 1) - 1;
5352 pCr = src[2] + (src_width >> 1) - 1;
5353 }
5354
5355 int32 half_src_pitch, read_idx, tmp_src_pitch;
5356 if (_mIsRotateClkwise)
5357 {
5358 half_src_pitch = -(src_pitch >> 1);
5359 read_idx = 1;
5360 tmp_src_pitch = -src_pitch;
5361 }
5362 else // rotate counterclockwise
5363 {
5364 half_src_pitch = (src_pitch >> 1);
5365 read_idx = -1;
5366 tmp_src_pitch = src_pitch;
5367 }
5368
5369 if (flip == 0)
5370 {
5371 dst_start_pos = 0;
5372 dst_inc = 1;
5373 }
5374 else
5375 {
5376 dst_start_pos = disp[4] - 1;
5377 dst_inc = -1;
5378 }
5379
5380 pDst = (uint16 *)dst + dst_start_pos;
5381
5382 for (row = src_width - 1; row > 0; row -= 2)
5383 { /* decrement index, _mColPix[.] is symmetric to increment index */
5384
5385 if ((_mColPix[row-1] == 0) && (_mColPix[row] == 0))
5386 {
5387 pCb += read_idx;
5388 pCr += read_idx;
5389 pY += (read_idx * 2);
5390 continue;
5391 }
5392
5393 if (_mColPix[row-1] + _mColPix[row] == 1) // do only one row, scale down
5394 {
5395 for (col = disp[3] - 2; col >= 0; col -= 2)
5396 {/* decrement index, _mRowPix[.] is symmetric to increment index */
5397 Cb = *pCb;
5398 pCb += half_src_pitch;
5399 Cr = *pCr;
5400 pCr += half_src_pitch;
5401
5402 Cb -= 128;
5403 Cr -= 128;
5404 Cg = Cr * cc1;
5405 Cr *= cc3;
5406
5407 Cg += Cb * cc2;
5408 Cb *= cc4;
5409
5410 if (_mRowPix[col]) /* compute this pixel */
5411 {
5412 tmp0 = pY[read_idx]; //bottom left
5413
5414 tmp0 += OFFSET_5_0;
5415
5416 tmp1 = tmp0 - (Cg >> 16);
5417 tmp2 = tmp0 + (Cb >> 16);
5418 tmp0 = tmp0 + (Cr >> 16);
5419
5420 tmp0 = clip[tmp0];
5421 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
5422 tmp2 = clip[tmp2];
5423
5424 //RGB_565
5425
5426 rgb = tmp1 | (tmp0 << 6);
5427 rgb = tmp2 | (rgb << 5);
5428
5429 Y = *pY;
5430 pY += tmp_src_pitch; //upper left
5431
5432 Y += OFFSET_5_1;
5433 tmp1 = (Y) - (Cg >> 16);
5434 tmp2 = (Y) + (Cb >> 16);
5435 tmp0 = (Y) + (Cr >> 16);
5436
5437 tmp0 = clip[tmp0];
5438 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
5439 tmp2 = clip[tmp2];
5440
5441 //RGB_565
5442 tmp0 = tmp1 | (tmp0 << 6);
5443 tmp0 = tmp2 | (tmp0 << 5);
5444
5445 *(pDst) = (uint16)tmp0;
5446
5447 } /* if(_mRowPix[col]) */
5448 else
5449 {
5450 pY += tmp_src_pitch;
5451 }
5452
5453 pDst += (dst_inc > 0 ? _mRowPix[col] : -_mRowPix[col]);
5454
5455 if (_mRowPix[col+1]) /* compute this pixel */
5456 {
5457 tmp0 = pY[read_idx]; //bottom right
5458
5459 tmp0 += OFFSET_5_1;
5460
5461 tmp1 = tmp0 - (Cg >> 16);
5462 tmp2 = tmp0 + (Cb >> 16);
5463 tmp0 = tmp0 + (Cr >> 16);
5464
5465 tmp0 = clip[tmp0];
5466 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
5467 tmp2 = clip[tmp2];
5468
5469
5470 rgb = tmp1 | (tmp0 << 6);
5471 rgb = tmp2 | (rgb << 5);
5472
5473 Y = *pY;
5474 pY += tmp_src_pitch; //upper right
5475
5476 Y += OFFSET_5_0;
5477 tmp1 = (Y) - (Cg >> 16);
5478 tmp2 = (Y) + (Cb >> 16);
5479 tmp0 = (Y) + (Cr >> 16);
5480
5481 tmp0 = clip[tmp0];
5482 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
5483 tmp2 = clip[tmp2];
5484
5485 tmp0 = tmp1 | (tmp0 << 6);
5486 tmp0 = tmp2 | (tmp0 << 5);
5487
5488 *(pDst) = (uint16)tmp0;
5489 }/* if(_mRowPix[col]) */
5490 else
5491 {
5492 pY += tmp_src_pitch;
5493 }
5494 pDst += (dst_inc > 0 ? _mRowPix[col+1] : -_mRowPix[col+1]);
5495 }//end of COL
5496 //oscl_memcpy() both up & down
5497
5498 pY += (deltaY);
5499 pCb += deltaCbCr;
5500 pCr += deltaCbCr;
5501
5502 pDst += dst_pitch;
5503
5504 if (dst_inc > 0)
5505 {
5506 pDst -= dst_width; //goes back to the beginning of the line;
5507 }
5508 else
5509 {
5510 pDst += dst_width;
5511 }
5512 }
5513 else // do two rows at least, scale up or down
5514 {
5515
5516 #ifdef INTERPOLATE
5517 prgb1 = 0;
5518 prgb2 = 0;
5519 prgb3 = 0;
5520 prgb4 = 0;
5521 #endif
5522 for (col = disp[3] - 2; col >= 0; col -= 2)
5523 {/* decrement index, _mRowPix[.] is symmetric to increment index */
5524 Cb = *pCb;
5525 pCb += half_src_pitch;
5526 Cr = *pCr;
5527 pCr += half_src_pitch;
5528
5529 Cb -= 128;
5530 Cr -= 128;
5531 Cg = Cr * cc1;
5532 Cr *= cc3;
5533
5534 Cg += Cb * cc2;
5535 Cb *= cc4;
5536
5537 if (_mRowPix[col]) /* compute this pixel */
5538 {
5539 tmp0 = pY[read_idx]; //bottom left
5540
5541 tmp0 += OFFSET_5_0;
5542
5543 tmp1 = tmp0 - (Cg >> 16);
5544 tmp2 = tmp0 + (Cb >> 16);
5545 tmp0 = tmp0 + (Cr >> 16);
5546
5547 tmp0 = clip[tmp0];
5548 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
5549 tmp2 = clip[tmp2];
5550
5551 //RGB_565
5552
5553 rgb = tmp1 | (tmp0 << 6);
5554 rgb = tmp2 | (rgb << 5);
5555
5556 Y = *pY;
5557 pY += tmp_src_pitch; //upper left
5558
5559 Y += OFFSET_5_1;
5560 tmp1 = (Y) - (Cg >> 16);
5561 tmp2 = (Y) + (Cb >> 16);
5562 tmp0 = (Y) + (Cr >> 16);
5563
5564 tmp0 = clip[tmp0];
5565 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
5566 tmp2 = clip[tmp2];
5567
5568 //RGB_565
5569 tmp0 = tmp1 | (tmp0 << 6);
5570 tmp0 = tmp2 | (tmp0 << 5);
5571
5572 #ifdef INTERPOLATE
5573 prgb3 = rgb;
5574 prgb4 = tmp0;
5575 #endif
5576
5577 if (_mRowPix[col] == 2)
5578 {
5579 #ifdef INTERPOLATE
5580 *(pDst + dst_pitch) = (((((prgb1 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
5581 | ((((((prgb1 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
5582 | ((((((prgb1 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
5583
5584 *(pDst + dst_pitch + dst_inc) = (uint16)rgb;
5585
5586 *(pDst) = (((((prgb2 & 0x1F) + (tmp0 & 0x1F)) / 2) & 0x1F)
5587 | ((((((prgb2 >> 5) & 0x3F) + ((tmp0 >> 5) & 0x3F)) / 2) & 0x3F) << 5)
5588 | ((((((prgb2 >> 11) & 0x1F) + ((tmp0 >> 11) & 0x1F)) / 2) & 0x1F) << 11));
5589
5590 *(pDst + dst_inc) = (uint16)tmp0;
5591
5592 #else
5593 *(pDst + dst_pitch) = (uint16)rgb;
5594 *(pDst + dst_pitch + dst_inc) = (uint16)rgb;
5595 *(pDst) = (uint16)tmp0;
5596 *(pDst + dst_inc) = (uint16)tmp0;
5597 #endif
5598 }
5599 else if (_mRowPix[col] == 3)
5600 {
5601 #ifdef INTERPOLATE
5602 *(pDst + dst_pitch) = (((((prgb1 & 0x1F) + (rgb & 0x1F) * 2) / 3) & 0x1F)
5603 | ((((((prgb1 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F) * 2) / 3) & 0x3F) << 5)
5604 | ((((((prgb1 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F) * 2) / 3) & 0x1F) << 11));
5605
5606 *((pDst + dst_pitch + dst_inc)) = (((((prgb1 & 0x1F) * 2 + (rgb & 0x1F)) / 3) & 0x1F)
5607 | ((((((prgb1 >> 5) & 0x3F) * 2 + ((rgb >> 5) & 0x3F)) / 3) & 0x3F) << 5)
5608 | ((((((prgb1 >> 11) & 0x1F) * 2 + ((rgb >> 11) & 0x1F)) / 3) & 0x1F) << 11));
5609
5610 *((pDst + dst_pitch + (dst_inc << 1))) = (uint16)rgb ;
5611
5612 *(pDst) = (((((prgb2 & 0x1F) + (tmp0 & 0x1F) * 2) / 3) & 0x1F)
5613 | ((((((prgb2 >> 5) & 0x3F) + ((tmp0 >> 5) & 0x3F) * 2) / 3) & 0x3F) << 5)
5614 | ((((((prgb2 >> 11) & 0x1F) + ((tmp0 >> 11) & 0x1F) * 2) / 3) & 0x1F) << 11));
5615
5616 *((pDst + dst_inc)) = (((((prgb2 & 0x1F) * 2 + (tmp0 & 0x1F)) / 3) & 0x1F)
5617 | ((((((prgb2 >> 5) & 0x3F) * 2 + ((tmp0 >> 5) & 0x3F)) / 3) & 0x3F) << 5)
5618 | ((((((prgb2 >> 11) & 0x1F) * 2 + ((tmp0 >> 11) & 0x1F)) / 3) & 0x1F) << 11));
5619
5620 *((pDst + (dst_inc << 1))) = (uint16)tmp0;
5621 #else
5622 *(pDst + dst_pitch) = (uint16)rgb;
5623 *((pDst + dst_pitch + dst_inc)) = (uint16)rgb ;
5624 *((pDst + dst_pitch + (dst_inc << 1))) = (uint16)rgb ;
5625
5626 *(pDst) = (uint16)tmp0;
5627 *((pDst + dst_inc)) = (uint16)tmp0;
5628 *((pDst + (dst_inc << 1))) = (uint16)tmp0;
5629 #endif
5630 }
5631 else
5632 {
5633 *(pDst + dst_pitch) = (uint16)rgb;
5634 *(pDst) = (uint16)tmp0;
5635 }
5636
5637 } /* if(_mRowPix[col]) */
5638 else
5639 {
5640 pY += tmp_src_pitch;
5641 }
5642
5643 pDst += (dst_inc > 0 ? _mRowPix[col] : -_mRowPix[col]);
5644
5645 if (_mRowPix[col+1]) /* compute this pixel */
5646 {
5647 tmp0 = pY[read_idx]; //bottom right
5648
5649 tmp0 += OFFSET_5_1;
5650
5651 tmp1 = tmp0 - (Cg >> 16);
5652 tmp2 = tmp0 + (Cb >> 16);
5653 tmp0 = tmp0 + (Cr >> 16);
5654
5655 tmp0 = clip[tmp0];
5656 tmp1 = clip[tmp1 + OFFSET_6_1 - OFFSET_5_1];
5657 tmp2 = clip[tmp2];
5658
5659
5660 rgb = tmp1 | (tmp0 << 6);
5661 rgb = tmp2 | (rgb << 5);
5662
5663 Y = *pY;
5664 pY += tmp_src_pitch; //upper right
5665
5666 Y += OFFSET_5_0;
5667 tmp1 = (Y) - (Cg >> 16);
5668 tmp2 = (Y) + (Cb >> 16);
5669 tmp0 = (Y) + (Cr >> 16);
5670
5671 tmp0 = clip[tmp0];
5672 tmp1 = clip[tmp1 + OFFSET_6_0 - OFFSET_5_0];
5673 tmp2 = clip[tmp2];
5674
5675 tmp0 = tmp1 | (tmp0 << 6);
5676 tmp0 = tmp2 | (tmp0 << 5);
5677
5678 #ifdef INTERPOLATE
5679 prgb1 = rgb;
5680 prgb2 = tmp0;
5681 #endif
5682 if (_mRowPix[col+1] == 2)
5683 {
5684 #ifdef INTERPOLATE
5685 *(pDst + dst_pitch) = (((((prgb3 & 0x1F) + (rgb & 0x1F)) / 2) & 0x1F)
5686 | ((((((prgb3 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F)) / 2) & 0x3F) << 5)
5687 | ((((((prgb3 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F)) / 2) & 0x1F) << 11));
5688
5689 *(pDst + dst_pitch + dst_inc) = (uint16)rgb;
5690
5691 *(pDst) = (((((prgb4 & 0x1F) + (tmp0 & 0x1F)) / 2) & 0x1F)
5692 | ((((((prgb4 >> 5) & 0x3F) + ((tmp0 >> 5) & 0x3F)) / 2) & 0x3F) << 5)
5693 | ((((((prgb4 >> 11) & 0x1F) + ((tmp0 >> 11) & 0x1F)) / 2) & 0x1F) << 11));
5694
5695 *(pDst + dst_inc) = (uint16)tmp0;
5696
5697 #else
5698 *(pDst + dst_pitch) = (uint16)rgb;
5699 *(pDst + dst_pitch + dst_inc) = (uint16)rgb;
5700 *(pDst) = (uint16)tmp0;
5701 *(pDst + dst_inc) = (uint16)tmp0;
5702 #endif
5703 }
5704 else if (_mRowPix[col+1] == 3)
5705 {
5706 #ifdef INTERPOLATE
5707 *(pDst + dst_pitch) = (((((prgb3 & 0x1F) + (rgb & 0x1F) * 2) / 3) & 0x1F)
5708 | ((((((prgb3 >> 5) & 0x3F) + ((rgb >> 5) & 0x3F) * 2) / 3) & 0x3F) << 5)
5709 | ((((((prgb3 >> 11) & 0x1F) + ((rgb >> 11) & 0x1F) * 2) / 3) & 0x1F) << 11));
5710
5711 *((pDst + dst_pitch + dst_inc)) = (((((prgb3 & 0x1F) * 2 + (rgb & 0x1F)) / 3) & 0x1F)
5712 | ((((((prgb3 >> 5) & 0x3F) * 2 + ((rgb >> 5) & 0x3F)) / 3) & 0x3F) << 5)
5713 | ((((((prgb3 >> 11) & 0x1F) * 2 + ((rgb >> 11) & 0x1F)) / 3) & 0x1F) << 11));
5714
5715 *((pDst + dst_pitch + (dst_inc << 1))) = (uint16)rgb ;
5716
5717 *(pDst) = (((((prgb4 & 0x1F) + (tmp0 & 0x1F) * 2) / 3) & 0x1F)
5718 | ((((((prgb4 >> 5) & 0x3F) + ((tmp0 >> 5) & 0x3F) * 2) / 3) & 0x3F) << 5)
5719 | ((((((prgb4 >> 11) & 0x1F) + ((tmp0 >> 11) & 0x1F) * 2) / 3) & 0x1F) << 11));
5720
5721 *((pDst + dst_inc)) = (((((prgb4 & 0x1F) * 2 + (tmp0 & 0x1F)) / 3) & 0x1F)
5722 | ((((((prgb4 >> 5) & 0x3F) * 2 + ((tmp0 >> 5) & 0x3F)) / 3) & 0x3F) << 5)
5723 | ((((((prgb4 >> 11) & 0x1F) * 2 + ((tmp0 >> 11) & 0x1F)) / 3) & 0x1F) << 11));
5724
5725 *((pDst + (dst_inc << 1))) = (uint16)tmp0;
5726 #else
5727 *(pDst + dst_pitch) = (uint16)rgb;
5728 *((pDst + dst_pitch + dst_inc)) = (uint16)rgb ;
5729 *((pDst + dst_pitch + (dst_inc << 1))) = (uint16)rgb ;
5730
5731 *(pDst) = (uint16)tmp0;
5732 *((pDst + dst_inc)) = (uint16)tmp0;
5733 *((pDst + (dst_inc << 1))) = (uint16)tmp0;
5734 #endif
5735 }
5736 else
5737 {
5738 *(pDst + dst_pitch) = (uint16)rgb;
5739 *(pDst) = (uint16)tmp0;
5740 }
5741 }/* if(_mRowPix[col]) */
5742 else
5743 {
5744 pY += tmp_src_pitch;
5745 }
5746 pDst += (dst_inc > 0 ? _mRowPix[col+1] : -_mRowPix[col+1]);
5747 }//end of COL
5748 //oscl_memcpy() both up & down
5749
5750 pY += (deltaY);
5751 pCb += deltaCbCr;
5752 pCr += deltaCbCr;
5753
5754 if (dst_inc > 0)
5755 {
5756 pDst -= (dst_width); //goes back to the beginning of the line;
5757 }
5758 else
5759 {
5760 pDst += 1;
5761 }
5762
5763 //copy down
5764 offset = (_mColPix[row] * dst_pitch);
5765
5766 if (_mColPix[row-1] && _mColPix[row] != 1)
5767 {
5768 oscl_memcpy(pDst + offset, pDst + dst_pitch, dst_width*2);
5769 }
5770 if (_mColPix[row-1] == 2)
5771 {
5772 oscl_memcpy(pDst + offset + dst_pitch, pDst + dst_pitch, dst_width*2);
5773 }
5774 else if (_mColPix[row-1] == 3)
5775 {
5776 oscl_memcpy(pDst + offset + dst_pitch, pDst + dst_pitch, dst_width*2);
5777 oscl_memcpy(pDst + offset + dst_pitch*2, pDst + dst_pitch, dst_width*2);
5778 }
5779
5780 if (_mColPix[row] > 1)
5781 {
5782 oscl_memcpy(pDst + dst_pitch, pDst, dst_width*2);
5783 if (_mColPix[row] > 2)
5784 {
5785 oscl_memcpy(pDst + dst_pitch*2, pDst, dst_width*2);
5786 }
5787 }
5788
5789 pDst += dst_pitch * (_mColPix[row-1] + _mColPix[row]);
5790 if (dst_inc < 0)
5791 {
5792 pDst += (dst_width - 1);
5793 }
5794 }
5795 } // row
5796
5797 return 1;
5798 #else
5799 OSCL_UNUSED_ARG(src);
5800 OSCL_UNUSED_ARG(dst);
5801 OSCL_UNUSED_ARG(disp);
5802 OSCL_UNUSED_ARG(coff_tbl);
5803 OSCL_UNUSED_ARG(_mRowPix);
5804 OSCL_UNUSED_ARG(_mColPix);
5805 OSCL_UNUSED_ARG(_mIsRotateClkwise);
5806 OSCL_UNUSED_ARG(flip);
5807
5808 return 0;
5809 #endif // defined(CCROTATE) && defined(CCSCALING)
5810 }
5811
5812
5813