172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng#include "NV12_resize.h"
272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng//#define LOG_NDEBUG 0
472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng#define LOG_NIDEBUG 0
572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng#define LOG_NDDEBUG 0
672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng#define LOG_TAG "NV12_resize"
872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng#define STRIDE 4096
972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng#include <utils/Log.h>
1072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
1172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng/*==========================================================================
1272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng* Function Name  : VT_resizeFrame_Video_opt2_lp
1372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng*
1472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng* Description    : Resize a yuv frame.
1572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng*
1672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng* Input(s)       : input_img_ptr        -> Input Image Structure
1772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng*                : output_img_ptr       -> Output Image Structure
1872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng*                : cropout             -> crop structure
1972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng*
2072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng* Value Returned : mmBool               -> FALSE on error TRUE on success
2172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng* NOTE:
2272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng*            Not tested for crop funtionallity.
2372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng*            faster version.
2472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng============================================================================*/
2572b0d2814165e633385bd87a838fc9c3a8250113Akwasi BoatengmmBool
2672b0d2814165e633385bd87a838fc9c3a8250113Akwasi BoatengVT_resizeFrame_Video_opt2_lp
2772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng(
2872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng structConvImage* i_img_ptr,        /* Points to the input image           */
2972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng structConvImage* o_img_ptr,        /* Points to the output image          */
3072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng IC_rect_type*  cropout,          /* how much to resize to in final image */
3172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng mmUint16 dummy                         /* Transparent pixel value              */
3272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng )
3372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng{
34ac837f2654f5a7a7fbecf05e4b085b87a7701714Steve Block  ALOGV("VT_resizeFrame_Video_opt2_lp+");
3572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
3672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  mmUint16 row,col;
3772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  mmUint32 resizeFactorX;
3872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  mmUint32 resizeFactorY;
3972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
4072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
4172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  mmUint16 x, y;
4272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
4372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  mmUchar* ptr8;
4472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  mmUchar *ptr8Cb, *ptr8Cr;
4572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
4672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
4772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  mmUint16 xf, yf;
4872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  mmUchar* inImgPtrY;
4972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  mmUchar* inImgPtrU;
5072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  mmUchar* inImgPtrV;
5172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  mmUint32 cox, coy, codx, cody;
5272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  mmUint16 idx,idy, idxC;
5372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
5472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  if(i_img_ptr->uWidth == o_img_ptr->uWidth)
5572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng	{
5672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng		if(i_img_ptr->uHeight == o_img_ptr->uHeight)
5772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng			{
58ac837f2654f5a7a7fbecf05e4b085b87a7701714Steve Block				ALOGV("************************f(i_img_ptr->uHeight == o_img_ptr->uHeight) are same *********************\n");
59ac837f2654f5a7a7fbecf05e4b085b87a7701714Steve Block				ALOGV("************************(i_img_ptr->width == %d" , i_img_ptr->uWidth );
60ac837f2654f5a7a7fbecf05e4b085b87a7701714Steve Block				ALOGV("************************(i_img_ptr->uHeight == %d" , i_img_ptr->uHeight );
61ac837f2654f5a7a7fbecf05e4b085b87a7701714Steve Block				ALOGV("************************(o_img_ptr->width == %d" ,o_img_ptr->uWidth );
62ac837f2654f5a7a7fbecf05e4b085b87a7701714Steve Block				ALOGV("************************(o_img_ptr->uHeight == %d" , o_img_ptr->uHeight );
6372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng			}
6472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng	}
6572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
6672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  if (!i_img_ptr || !i_img_ptr->imgPtr ||
6772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng    !o_img_ptr || !o_img_ptr->imgPtr)
6872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  {
6946de639b23db99d7b99ff1c676ac98b84b6336c6Steve Block	ALOGE("Image Point NULL");
70ac837f2654f5a7a7fbecf05e4b085b87a7701714Steve Block	ALOGV("VT_resizeFrame_Video_opt2_lp-");
7172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng	return FALSE;
7272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  }
7372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
7472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  inImgPtrY = (mmUchar *) i_img_ptr->imgPtr + i_img_ptr->uOffset;
7572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  inImgPtrU = (mmUchar *) i_img_ptr->clrPtr + i_img_ptr->uOffset/2;
7672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  inImgPtrV = (mmUchar*)inImgPtrU + 1;
7772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
7872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  if (cropout == NULL)
7972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  {
8072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng    cox = 0;
8172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng    coy = 0;
8272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng    codx = o_img_ptr->uWidth;
8372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng    cody = o_img_ptr->uHeight;
8472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  }
8572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  else
8672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  {
8772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng    cox = cropout->x;
8872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng    coy = cropout->y;
8972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng    codx = cropout->uWidth;
9072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng    cody = cropout->uHeight;
9172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  }
9272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  idx = i_img_ptr->uWidth;
9372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  idy = i_img_ptr->uHeight;
9472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
9572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  /* make sure valid input size */
96c160a1f85c70e49a7613d774e2d99035f3cb4851Tyler Luu  if (idx < 1 || idy < 1 || i_img_ptr->uStride < 1)
9772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng	{
9846de639b23db99d7b99ff1c676ac98b84b6336c6Steve Block	ALOGE("idx or idy less then 1 idx = %d idy = %d stride = %d", idx, idy, i_img_ptr->uStride);
99ac837f2654f5a7a7fbecf05e4b085b87a7701714Steve Block	ALOGV("VT_resizeFrame_Video_opt2_lp-");
10072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng	return FALSE;
10172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng	}
10272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
10372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  resizeFactorX = ((idx-1)<<9) / codx;
10472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  resizeFactorY = ((idy-1)<<9) / cody;
10572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
10672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  if(i_img_ptr->eFormat == IC_FORMAT_YCbCr420_lp &&
10772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng    o_img_ptr->eFormat == IC_FORMAT_YCbCr420_lp)
10872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  {
10972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng    ptr8 = (mmUchar*)o_img_ptr->imgPtr + cox + coy*o_img_ptr->uWidth;
11072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
11172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
11272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng    ////////////////////////////for Y//////////////////////////
11372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng    for (row=0; row < cody; row++)
11472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng    {
11572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng        mmUchar *pu8Yrow1 = NULL;
11672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng        mmUchar *pu8Yrow2 = NULL;
11772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng        y  = (mmUint16) ((mmUint32) (row*resizeFactorY) >> 9);
11872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng        yf = (mmUchar)  ((mmUint32)((row*resizeFactorY) >> 6) & 0x7);
119c160a1f85c70e49a7613d774e2d99035f3cb4851Tyler Luu        pu8Yrow1 = inImgPtrY + (y) * i_img_ptr->uStride;
120c160a1f85c70e49a7613d774e2d99035f3cb4851Tyler Luu        pu8Yrow2 = pu8Yrow1 + i_img_ptr->uStride;
12172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
12272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng        for (col=0; col < codx; col++)
12372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng        {
12472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            mmUchar in11, in12, in21, in22;
12572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            mmUchar *pu8ptr1 = NULL;
12672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            mmUchar *pu8ptr2 = NULL;
12772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            mmUchar w;
12872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            mmUint16 accum_1;
12972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            //mmUint32 accum_W;
13072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
13172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
13272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
13372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            x  = (mmUint16) ((mmUint32)  (col*resizeFactorX) >> 9);
13472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            xf = (mmUchar)  ((mmUint32) ((col*resizeFactorX) >> 6) & 0x7);
13572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
13672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
13772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            //accum_W = 0;
13872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            accum_1 =  0;
13972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
14072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            pu8ptr1 = pu8Yrow1 + (x);
14172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            pu8ptr2 = pu8Yrow2 + (x);
14272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
14372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            /* A pixel */
14472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            //in = *(inImgPtrY + (y)*idx + (x));
14572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            in11 = *(pu8ptr1);
14672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
14772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            w = bWeights[xf][yf][0];
14872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            accum_1 = (w * in11);
14972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            //accum_W += (w);
15072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
15172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            /* B pixel */
15272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            //in = *(inImgPtrY + (y)*idx + (x+1));
15372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            in12 = *(pu8ptr1+1);
15472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            w = bWeights[xf][yf][1];
15572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            accum_1 += (w * in12);
15672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            //accum_W += (w);
15772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
15872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            /* C pixel */
15972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            //in = *(inImgPtrY + (y+1)*idx + (x));
16072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            in21 = *(pu8ptr2);
16172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            w = bWeights[xf][yf][3];
16272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            accum_1 += (w * in21);
16372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            //accum_W += (w);
16472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
16572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            /* D pixel */
16672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            //in = *(inImgPtrY + (y+1)*idx + (x+1));
16772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            in22 = *(pu8ptr2+1);
16872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            w = bWeights[xf][yf][2];
16972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            accum_1 += (w * in22);
17072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            //accum_W += (w);
17172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
17272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            /* divide by sum of the weights */
17372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            //accum_1 /= (accum_W);
17472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            //accum_1 = (accum_1/64);
17572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            accum_1 = (accum_1>>6);
17672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            *ptr8 = (mmUchar)accum_1 ;
17772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
17872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
17972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            ptr8++;
18072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng        }
181c160a1f85c70e49a7613d774e2d99035f3cb4851Tyler Luu        ptr8 = ptr8 + (o_img_ptr->uStride - codx);
18272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng    }
18372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng    ////////////////////////////for Y//////////////////////////
18472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
18572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng    ///////////////////////////////for Cb-Cr//////////////////////
18672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
18772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng    ptr8Cb = (mmUchar*)o_img_ptr->clrPtr + cox + coy*o_img_ptr->uWidth;
18872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
18972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng    ptr8Cr = (mmUchar*)(ptr8Cb+1);
19072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
19172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng    idxC = (idx>>1);
19272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng    for (row=0; row < (((cody)>>1)); row++)
19372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng    {
19472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng        mmUchar *pu8Cbr1 = NULL;
19572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng        mmUchar *pu8Cbr2 = NULL;
19672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng        mmUchar *pu8Crr1 = NULL;
19772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng        mmUchar *pu8Crr2 = NULL;
19872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
19972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng        y  = (mmUint16) ((mmUint32) (row*resizeFactorY) >> 9);
20072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng        yf = (mmUchar)  ((mmUint32)((row*resizeFactorY) >> 6) & 0x7);
20172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
202c160a1f85c70e49a7613d774e2d99035f3cb4851Tyler Luu        pu8Cbr1 = inImgPtrU + (y) * i_img_ptr->uStride;
203c160a1f85c70e49a7613d774e2d99035f3cb4851Tyler Luu        pu8Cbr2 = pu8Cbr1 + i_img_ptr->uStride;
204c160a1f85c70e49a7613d774e2d99035f3cb4851Tyler Luu        pu8Crr1 = inImgPtrV + (y) * i_img_ptr->uStride;
205c160a1f85c70e49a7613d774e2d99035f3cb4851Tyler Luu        pu8Crr2 = pu8Crr1 + i_img_ptr->uStride;
20672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
20772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng        for (col=0; col < (((codx)>>1)); col++)
20872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng        {
20972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            mmUchar in11, in12, in21, in22;
21072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            mmUchar *pu8Cbc1 = NULL;
21172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            mmUchar *pu8Cbc2 = NULL;
21272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            mmUchar *pu8Crc1 = NULL;
21372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            mmUchar *pu8Crc2 = NULL;
21472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
21572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            mmUchar w;
21672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            mmUint16 accum_1Cb, accum_1Cr;
21772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            //mmUint32 accum_WCb, accum_WCr;
21872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
21972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
22072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            x  = (mmUint16) ((mmUint32)  (col*resizeFactorX) >> 9);
22172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            xf = (mmUchar)  ((mmUint32) ((col*resizeFactorX) >> 6) & 0x7);
22272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
22372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
22472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            //accum_WCb = accum_WCr =  0;
22572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            accum_1Cb = accum_1Cr =  0;
22672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
22772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            pu8Cbc1 = pu8Cbr1 + (x*2);
22872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            pu8Cbc2 = pu8Cbr2 + (x*2);
22972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng	    pu8Crc1 = pu8Crr1 + (x*2);
23072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            pu8Crc2 = pu8Crr2 + (x*2);
23172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
23272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
23372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
23472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            /* A pixel */
23572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            w = bWeights[xf][yf][0];
23672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
23772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            in11 = *(pu8Cbc1);
23872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            accum_1Cb = (w * in11);
23972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            //    accum_WCb += (w);
24072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
24172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng			in11 = *(pu8Crc1);
24272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            accum_1Cr = (w * in11);
24372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            //accum_WCr += (w);
24472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
24572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            /* B pixel */
24672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            w = bWeights[xf][yf][1];
24772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
24872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            in12 = *(pu8Cbc1+2);
24972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            accum_1Cb += (w * in12);
25072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            //accum_WCb += (w);
25172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
25272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            in12 = *(pu8Crc1+2);
25372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            accum_1Cr += (w * in12);
25472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            //accum_WCr += (w);
25572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
25672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            /* C pixel */
25772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            w = bWeights[xf][yf][3];
25872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
25972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            in21 = *(pu8Cbc2);
26072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            accum_1Cb += (w * in21);
26172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            //accum_WCb += (w);
26272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
26372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng			in21 = *(pu8Crc2);
26472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            accum_1Cr += (w * in21);
26572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            //accum_WCr += (w);
26672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
26772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            /* D pixel */
26872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            w = bWeights[xf][yf][2];
26972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
27072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            in22 = *(pu8Cbc2+2);
27172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            accum_1Cb += (w * in22);
27272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            //accum_WCb += (w);
27372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
27472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            in22 = *(pu8Crc2+2);
27572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            accum_1Cr += (w * in22);
27672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            //accum_WCr += (w);
27772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
27872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            /* divide by sum of the weights */
27972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            //accum_1Cb /= (accum_WCb);
28072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            accum_1Cb = (accum_1Cb>>6);
28172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            *ptr8Cb = (mmUchar)accum_1Cb ;
28272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
28372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
28472b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            accum_1Cr = (accum_1Cr >> 6);
28572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            *ptr8Cr = (mmUchar)accum_1Cr ;
28672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
28772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            ptr8Cb++;
28872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            ptr8Cr++;
28972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng
29072b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            ptr8Cb++;
29172b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng            ptr8Cr++;
29272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng        }
293c160a1f85c70e49a7613d774e2d99035f3cb4851Tyler Luu        ptr8Cb = ptr8Cb + (o_img_ptr->uStride-codx);
294c160a1f85c70e49a7613d774e2d99035f3cb4851Tyler Luu        ptr8Cr = ptr8Cr + (o_img_ptr->uStride-codx);
29572b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng    }
29672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng    ///////////////////For Cb- Cr////////////////////////////////////////
29772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  }
29872b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  else
29972b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  {
30046de639b23db99d7b99ff1c676ac98b84b6336c6Steve Block	ALOGE("eFormat not supported");
301ac837f2654f5a7a7fbecf05e4b085b87a7701714Steve Block	ALOGV("VT_resizeFrame_Video_opt2_lp-");
30272b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng	return FALSE;
30372b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  }
304ac837f2654f5a7a7fbecf05e4b085b87a7701714Steve Block  ALOGV("success");
305ac837f2654f5a7a7fbecf05e4b085b87a7701714Steve Block  ALOGV("VT_resizeFrame_Video_opt2_lp-");
30672b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng  return TRUE;
30772b0d2814165e633385bd87a838fc9c3a8250113Akwasi Boateng}
308