⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 video_rgb_org.c

📁 基于DM642平台的视频缩小放大功能 程序源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
#ifdef _LOOPBACK
    Int i;
    FVID_Handle capChan; 
    Int numPixels = EVMDM642_vCapParamsChan.fldXStop1 - 
       EVMDM642_vCapParamsChan.fldXStrt1+1;
    FVID_Frame *capFrameBuf;
    Int capLinePitch = EVMDM642_vCapParamsChan.fldXStop1 - 
       EVMDM642_vCapParamsChan.fldXStrt1+1;
    Int disLinePitch = EVMDM642_vDisParamsChan.imgHSizeFld1;


#ifdef _PIP
    VPORTCAP_Params EVMDM642_vCapParamsChan2 = EVMDM642_vCapParamsChan;
    FVID_Handle capChan2; 
    FVID_Frame *capFrameBuf2;
    Int yPitch = capLinePitch >> 1;
    Int cPitch = ((capLinePitch >> 2) + 7) & (~ 7);
    Int xOffset = disLinePitch - yPitch;
    Int yOffset = numLinesDis - numLines;
#endif
#endif                

 
    numLines *= 2; /* both fields */
    /******************************************************/
    /* allocate both capture and display frame buffers    */
    /* in external heap memory                            */
    /******************************************************/
        EVMDM642_vCapParamsChan.segId = EXTERNALHEAP;
        EVMDM642_vDisParamsChan.segId = EXTERNALHEAP;
        EVMDM642_vDisParamsSAA7105.hI2C = EVMDM642_I2C_hI2C;
        EVMDM642_vCapParamsSAA7115.hI2C = EVMDM642_I2C_hI2C;

    /******************************************************/
    /* initialization of capture driver                   */
    /******************************************************/
#ifdef _LOOPBACK
    capChan = FVID_create("/VP0CAPTURE/A/0", 
            IOM_INPUT, &status, (Ptr)&EVMDM642_vCapParamsChan, NULL);

#ifdef _PIP
    EVMDM642_vCapParamsChan2.scale = VPORT_SCALING_ENABLE;
        EVMDM642_vCapParamsChan2.fldOp = VPORT_FLDOP_FLD1;        
        EVMDM642_vCapParamsChan2.thrld >>=1;
    capChan2 = FVID_create("/VP1CAPTURE/A/1", 
            IOM_INPUT, &status, (Ptr)&EVMDM642_vCapParamsChan2, NULL);
#endif          

#endif          
    /******************************************************/
    /* initialization of display driver                   */
    /******************************************************/
    disChan = FVID_create("/VP2DISPLAY", IOM_OUTPUT, 
        &status, (Ptr)&EVMDM642_vDisParamsChan, NULL);

    
    /******************************************************/
    /* configure video encoder & decoder                  */
    /******************************************************/
    FVID_control(disChan, VPORT_CMD_EDC_BASE + EDC_CONFIG, 
        (Ptr)&EVMDM642_vDisParamsSAA7105);
#ifdef _LOOPBACK
    FVID_control(capChan, VPORT_CMD_EDC_BASE + EDC_CONFIG, 
        (Ptr)&EVMDM642_vCapParamsSAA7115);
#ifdef _PIP
    EVMDM642_vCapParamsSAA7115.aFmt = SAA7115_AFMT_COMPOSITE;
    FVID_control(capChan2, VPORT_CMD_EDC_BASE+EDC_CONFIG, 
        (Ptr)&EVMDM642_vCapParamsSAA7115);
#endif
#endif
    
    EVMDM642_rset(0x10, 0x20); /* unlock DLL */
    EVMDM642_rset(0x10, 0x00); /* set FPGA in 16-bit mode */
    while(!(EVMDM642_rget(0x13) & 0x40)); /* wait until DLL is locked */


    /******************************************************/
    /* start capture & display operation                  */    
    /******************************************************/
    FVID_control(disChan, VPORT_CMD_START, NULL);
#ifdef _LOOPBACK
    FVID_control(capChan, VPORT_CMD_START, NULL);
#ifdef _PIP
    FVID_control(capChan2, VPORT_CMD_START, NULL);
#endif    
#endif    
    
    /********************************************************/
    /* request a frame buffer from display & capture driver */
    /********************************************************/
    FVID_alloc(disChan, &disFrameBuf);
#ifdef _LOOPBACK
    FVID_alloc(capChan, &capFrameBuf);
#ifdef _PIP
    FVID_alloc(capChan2, &capFrameBuf2);
#endif      
#endif
    frames ++;
    
    in_image_luma_ev.img_cols = capLinePitch;
    in_image_luma_ev.img_rows = numLines/2;
    in_image_luma_od.img_cols = capLinePitch;
    in_image_luma_od.img_rows = numLines/2;
  
    in_image_Cr_ev.img_cols = in_image_Cb_ev.img_cols = capLinePitch/2;
    in_image_Cr_ev.img_rows = in_image_Cb_ev.img_rows = numLines/2;
    in_image_Cr_od.img_cols = in_image_Cb_od.img_cols = capLinePitch/2;
    in_image_Cr_od.img_rows = in_image_Cb_od.img_rows = numLines/2;
    
  
    scratch_pad.ext_data   = (char *) (ext_mem);
    scratch_pad.ext_size   = sizeof(ext_mem);
    scratch_pad.int_data   = (char *) int_mem;
    scratch_pad.int_size   = sizeof(int_mem);
    
    for (i = 0; i < 3; i++)
    {
        
        memset(disFrameBuf->frame.rpFrm.buf, 0x0, 2 * disLinePitch * 768);
        CACHE_clean(CACHE_L2ALL, 0, 0);
        FVID_exchange(disChan, &disFrameBuf);
    }
       
    
    while(1){/* loop forever */
#ifdef _LOOPBACK
        /* copy data from capture buffer to display buffer */
        /***************************************************/
        
      
            
           
		  
     
            in_image_luma_ev.img_data =  capFrameBuf->frame.iFrm.y1;
            in_image_Cr_ev.img_data   =  capFrameBuf->frame.iFrm.cb1;
            in_image_Cb_ev.img_data   =  capFrameBuf->frame.iFrm.cr1;
            in_image_luma_od.img_data =  in_image_luma_ev.img_data + capLinePitch;
            in_image_Cr_od.img_data   =  in_image_Cr_ev.img_data   + (capLinePitch/2);
            in_image_Cb_od.img_data   =  in_image_Cb_ev.img_data   + (capLinePitch/2);
            out_image.img_data        =  ext_mem;
            out_image.img_cols        =  capLinePitch;
            out_image.img_rows        =  (numLines >> 1); 
            
            
            color_convert(&in_image_luma_ev, &in_image_Cr_ev, &in_image_Cb_ev, 
                  &in_image_luma_od, &in_image_Cr_od, &in_image_Cb_od,
                  &out_image,     &scratch_pad,  disLinePitch);
                  
            
                  
            temp = (char *) L2scratch_pad;
 
            
		    for (i=0; i  < 40; i++) 
		    {
		        id0 = DAT_copy(clean, &temp[i*1024], 1024);
		        DAT_wait(id0);
		    }
	
	
	        #if 1
		    
		    counter ++; 
                
		    if ((counter% 4) == 0)
		    {
		        
		        q_h = (q_h - (sign * 2));
		        q_v = (q_v - (sign * 2));      
		        
		        if ((q_h <= 5) || (q_v <= 5))
		        {         
		            sign = sign * -1;
		            
		        }
		        
		        if ((q_h >= 280) || (q_v >= 280))
		        {           
		            sign = sign * -1;		           
		        }
		        		                               
		    }
		    #endif
		    
		    
		    
		  
		    
		    hpatch1 = jump_table1; 
		    vpatch1 = guide_table2;
		   
		    filt_gen(p, q_h, hh1, guide_table1, jump_table1);
		    filt_gen(p, q_v, hh2, guide_table2, jump_table2); 
		    
		    
		     
		    /*----------------------------------------------------------------------*/
		    /* Configure capture hardware for square pixel and display hardware for */
		    /* RGB data of packed 565 format.                                       */
		    /*----------------------------------------------------------------------*/
		  
		    display_width  = 1024;
		    in_pic_width   = 720;
		    display_height = 768; 
		    in_pic_height  = 240;
		    
		    ext_y  = ext_mem;
            ext_cr = ext_y   + (720 * 240);
            ext_cb = ext_cr  + (360 * 240);
		
		  /*------------------------------------------------------------------*/
		  /*  The current set of input and output pointers are obtained by    */
		  /* calls to the getFrame and putFrame routine.                      */
		  /*------------------------------------------------------------------*/
		      
		  /*------------------------------------------------------------------*/
		  /* The input frame pointer contains six pointers, two each for the  */
		  /* Y, Cr and Cb data. These pointers are used to copy/capture data  */
		  /* (both fields) from daughter card to SDRAM (external memory)      */ 
		  /* by firing DMA transfers from these locations to arrays in        */
		  /* external memory. Wait on the transfer id of the last transfer    */
		  /* id to make sure tyhat transfers completed.                       */
		  /*------------------------------------------------------------------*/
		      #if 1
		            
		      scale_2d_ycrcb (
		        f4_2_2,         /* 4:4:4 == 2, 4:2:2 == 1, 4:2:0 == 0            */
		  
		        p,              /* numerator for horizontal scale factor p/q     */
		        q_h,            /* denominator for horizontal scale factor p/q   */
		
		        hpatch1,        /* stride table for horizontal scaling jumps     */
		        hh1,            /* pntr to horz filter bank                      */
		        l_hh,           /* number of taps in each horz filter            */
		        n_hh,           /* number of filters in horz filter bank         */
		
		        p,              /* numerator for vertical scale factor p/q       */
		        q_v,            /* denominator for vertical scale factor p/q     */
		
		        vpatch1,        /* stride table for vertical scaling jumps       */
		        hh2,            /* pntr to vert filter bank                      */
		        l_hh,           /* number of taps in each vert filter            */
		        n_hh,           /* number of filters in vert filter bank         */
		
		        in_pic_height,  /* height of picture in Pixels multiple of 2     */
		        in_pic_width,   /* width  of picture in Pixels multiple of 8     */
		    
		        display_height, /* height of picture in Pixels multiple of 2     */
		        display_width,  /* width  of picture in Pixels multiple of 8     */
		
		        ext_y,       /* pntr to input image planar y values  */
		        ext_cr,      /* pntr to input image planar cr values */
		        ext_cb,      /* pntr to input image planar cb values */
		        L2scratch_pad,  /* temp space for internal buffers s    */
		                        /* aligned to a double boundary         */
		        (unsigned char *) disFrameBuf->frame.rpFrm.buf 
		        ); /* pntr to output image, scaled in color*/  
		        
       
        #endif
            
           
	    
        
        FVID_exchange(capChan, &capFrameBuf);
        

#endif
       // CACHE_clean(CACHE_L2ALL, 0, 0);
        
        
        FVID_exchange(disChan, &disFrameBuf); 
        
        frames ++;              
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -