MINT32
S3dshotClient::
CreateMotionSrc(MVOID * srcbufadr, int ImgWidth, int ImgHeight, MVOID * dstbufadr)
{
    bool ret = true;
    MY_LOGD("[CreateMotionSrc] +");
    DpBlitStream Motionstream; 

    unsigned int src_addr_list[3];
    unsigned int src_size_list[3];
    unsigned int dst_addr_list[3];
    unsigned int dst_size_list[3];
    
    unsigned char *src_yp;
    unsigned char *dst_rgb;
    
    int src_ysize = ImgWidth * ImgHeight;
    int src_usize, src_vsize;
    src_usize = src_vsize = src_ysize / 4;
    MY_LOGD("[CreateMotionSrc] src_ysize %d adr 0x%x w %d h %d",src_ysize,srcbufadr,ImgWidth,ImgHeight);
    int plane_num = 3;
    src_yp = (unsigned char *)srcbufadr;
    src_addr_list[0] = (unsigned int)src_yp;
    src_addr_list[1] = (unsigned int)(src_yp + src_ysize);
    src_addr_list[2] = (unsigned int)(src_yp + src_ysize + src_usize);
    
    src_size_list[0] = src_ysize;
    src_size_list[1] = src_vsize;
    src_size_list[2] = src_usize;
    //*****************************************************************************//
    Motionstream.setSrcBuffer((void**)src_addr_list, src_size_list, plane_num);
    Motionstream.setSrcConfig(ImgWidth,ImgHeight, eYUV_420_3P_YVU);
    
     //***************************dst RGB565********************************//
    dst_rgb = (unsigned char *)dstbufadr;
    MY_LOGD("[CreateMotionSrc] tar size %d adr 0x%x w %d h %d", (MOTION_MAX_IN_WIDTH * MOTION_MAX_IN_HEIGHT*2),dst_rgb,MOTION_MAX_IN_WIDTH,MOTION_MAX_IN_HEIGHT);
    Motionstream.setDstBuffer((void *)dst_rgb, (MOTION_MAX_IN_WIDTH * MOTION_MAX_IN_HEIGHT*2));
    Motionstream.setDstConfig(MOTION_MAX_IN_WIDTH, MOTION_MAX_IN_HEIGHT, eRGB565);
    Motionstream.setRotate(0);
    
    //*****************************************************************************//
    
     MY_LOGD("DDP_Performance_RGB565 Start");   
    
    // set & add pipe to stream
    if (!Motionstream.invalidate())  //trigger HW
    {
          MY_LOGD("FDstream invalidate failed");
          return false;
    }
    #ifdef debug
    char sourceFiles[80];
    sprintf(sourceFiles, "%s%d_%dx%d.rgb565", "/sdcard/motion", Mcount,MOTION_MAX_IN_WIDTH,MOTION_MAX_IN_HEIGHT);
    dumpBufToFile((char *) sourceFiles, (MUINT8 *)dst_rgb , (MOTION_MAX_IN_WIDTH * MOTION_MAX_IN_HEIGHT * 2));
    Mcount++;
    #endif
    MY_LOGD("DDP_Performance_RGB565 End");  
    return ret;    
}
Exemplo n.º 2
0
bool
ZsdShot::
imageTransform  (ImgBufInfo const & rSrcImgBufInfo, ImgBufInfo const & rDstImgBufInfo, int const & rot)
{
    FUNCTION_LOG_START;
    //return MFALSE;
    //AutoCPTLog cptlog(Event_MShot_convertImage);

    //MY_LOGD("convertImage, src (VA, PA, Size, ID) = (0x%x, 0x%x, %d, %d)", rSrcImgBufInfo.u4BufVA, rSrcImgBufInfo.u4BufPA, rSrcImgBufInfo.u4BufSize, rSrcImgBufInfo.i4MemID);
    //MY_LOGD("convertImage, dst (VA, PA, Size, ID) = (0x%x, 0x%x, %d, %d)", rDstImgBufInfo.u4BufVA, rDstImgBufInfo.u4BufPA, rDstImgBufInfo.u4BufSize, rDstImgBufInfo.i4MemID);
    MY_LOGD("%d@%dx%d->%d@%dx%d(rot:%d)",
        rSrcImgBufInfo.eImgFmt, rSrcImgBufInfo.u4ImgWidth, rSrcImgBufInfo.u4ImgHeight,
        rDstImgBufInfo.eImgFmt, rDstImgBufInfo.u4ImgWidth, rDstImgBufInfo.u4ImgHeight, rot);

    //MtkCamUtils::CamProfile profile("convertImage", "MultiShot");

    DpBlitStream thumbnailStream;
    DpColorFormat dp_in_fmt;
    DpColorFormat dp_out_fmt;
    DpInterlaceFormat dp_interlace_fmt = eInterlace_None;

    switch (rSrcImgBufInfo.eImgFmt) {
        case eImgFmt_YV12:
            dp_in_fmt = eYUV_420_3P;
            break;
        case eImgFmt_YUY2:
            dp_in_fmt = eYUY2;
            break;
        default:
            MY_LOGE("not support src format %d", rSrcImgBufInfo.eImgFmt);
            return false;
            break;
    }

    unsigned char *src_yp = (unsigned char *)(rSrcImgBufInfo.u4BufVA); //
    int src_ysize = rSrcImgBufInfo.u4ImgWidth * rSrcImgBufInfo.u4ImgHeight; //
    int src_usize, src_vsize;  //
    src_usize = src_vsize = src_ysize / 4;  //

    unsigned int src_addr_list[3];//
    unsigned int src_size_list[3];//
    int plane_num;//
    // set & register src buffer
    switch(rSrcImgBufInfo.eImgFmt) {
        case eImgFmt_YV12:
            src_addr_list[0] = (unsigned int)src_yp;
            src_addr_list[1] = (unsigned int)(src_yp + src_ysize * 5 / 4);
            src_addr_list[2] = (unsigned int)(src_yp + src_ysize);

            src_size_list[0] = src_ysize;
            src_size_list[1] = src_vsize;
            src_size_list[2] = src_usize;

            plane_num = 3;
            thumbnailStream.setSrcBuffer((void**)src_addr_list, src_size_list, plane_num);
            break;
        case eImgFmt_YUY2:
            src_addr_list[0] = (unsigned int)src_yp;

            src_size_list[0] = src_ysize*2;
            plane_num = 1;
            thumbnailStream.setSrcBuffer((void*)src_yp, src_ysize*2);
            break;
        default:
            return false;
            break;
    }

    unsigned char *dst_yp = (unsigned char *)(rDstImgBufInfo.u4BufVA);
    //unsigned char *ori_yp;
    //ori_yp  = (unsigned char *)(mPostViewImgBufInfoRead.u4BufVA);

    int dst_ysize = rDstImgBufInfo.u4ImgWidth*rDstImgBufInfo.u4ImgHeight;
    int dst_usize, dst_vsize;
    dst_usize = dst_vsize = dst_ysize / 4;
    unsigned int dst_addr_list[3];
    unsigned int dst_size_list[3];
    int plane_num_out;//
    switch(rDstImgBufInfo.eImgFmt) {
        case eImgFmt_YV12:
            dst_addr_list[0] = (unsigned int)dst_yp;
            dst_addr_list[1] = (unsigned int)(dst_yp + dst_ysize * 5 / 4);
            dst_addr_list[2] = (unsigned int)(dst_yp + dst_ysize);

            dst_size_list[0] = dst_ysize;
            dst_size_list[1] = dst_vsize;
            dst_size_list[2] = dst_usize;

            plane_num_out = 3;
            dp_out_fmt = eYUV_420_3P;
            thumbnailStream.setDstBuffer((void**)dst_addr_list, dst_size_list, plane_num_out);
            break;
         case eImgFmt_YUY2:
            dst_addr_list[0] = (unsigned int)dst_yp;

            dst_size_list[0] = dst_ysize*2;
            plane_num_out = 1;
            dp_out_fmt = eYUY2;

            thumbnailStream.setDstBuffer((void*)dst_yp, dst_ysize*2);
            break;
        default:
            return false;
            break;
    }


    //MY_LOGD("src addr (0, 1, 2) = (%p, %p, %p)", src_addr_list[0], src_addr_list[1], src_addr_list[2]);
    //MY_LOGD("dst addr (0, 1, 2) = (%p, %p, %p)", dst_addr_list[0], dst_addr_list[1], dst_addr_list[2]);

    //CPTLogStr(Event_MShot_convertImage, CPTFlagSeparator, "set src buffer");

    // set src buffer
    //thumbnailStream.setSrcBuffer((void**)src_addr_list, src_size_list, plane_num);

    //CPTLogStr(Event_MShot_convertImage, CPTFlagSeparator, "set src config");
    thumbnailStream.setSrcConfig(rSrcImgBufInfo.u4ImgWidth, rSrcImgBufInfo.u4ImgHeight, dp_in_fmt, dp_interlace_fmt);

    //CPTLogStr(Event_MShot_convertImage, CPTFlagSeparator, "set dst buffer");
    //thumbnailStream.setDstBuffer((void**)dst_addr_list, dst_size_list, plane_num_out);

   //CPTLogStr(Event_MShot_convertImage, CPTFlagSeparator, "set dst config");
    thumbnailStream.setDstConfig(rDstImgBufInfo.u4ImgWidth, rDstImgBufInfo.u4ImgHeight, dp_out_fmt);

    thumbnailStream.setRotate(rot);
    //*****************************************************************************//
    //CPTLogStr(Event_MShot_convertImage, CPTFlagSeparator, "invalidate");
    if (!thumbnailStream.invalidate())  //trigger HW
    {
          MY_LOGW("thumbnailStream invalidate failed");
          return false;
    }
    //CPTLogStr(Event_MShot_convertImage, CPTFlagSeparator, "invalidate end");
    //profile.print();
    if (mu4DumpFlag)
    {
        //char fileNames[256] = {'\0'};
        //sprintf(fileNames, "/sdcard/zsd_sub_src_%dx%d.bin", rSrcImgBufInfo.u4ImgWidth, rSrcImgBufInfo.u4ImgHeight);
        //android::MtkCamUtils::saveBufToFile(fileNames, reinterpret_cast<MUINT8*>( rSrcImgBufInfo.u4BufVA), rSrcImgBufInfo.u4BufSize);
        /*
        char fileName[256] = {'\0'};
        sprintf(fileName, ZSD_DUMP_PATH "zsd_cap_thumb_%dx%d.bin",  rDstImgBufInfo.u4ImgWidth, rDstImgBufInfo.u4ImgHeight);
        MtkCamUtils::saveBufToFile(fileName, reinterpret_cast<MUINT8*>( rDstImgBufInfo.u4BufVA), rDstImgBufInfo.u4BufSize);
        */
        usleep(1000*1000);
    }

    FUNCTION_LOG_END;

    return true;
}