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

📄 basic_op.c

📁 基于dsp6416处理器的边缘检测算法
💻 C
字号:

//#include <stdio.h>
#include <csl.h>
#include <csl_edma.h>
#include <csl_dat.h>
#include <std.h>
#include <sys.h>
#include <tsk.h>
#include <log.h>

#include "iekc64.h"
#include "img_ycbcr422p_rgb565.h"     //header file for C64x IMGLIB

#include "agl.h"
#include "agl_string.h"
#include "agl_font.h"
#include "agl_font_lucida.h"

#include "basic_op.h"

//need implementation
void image_add(struct YUV422_image * in_image1,
   	     struct YUV422_image * in_image2,int x,int y)
 //  	     struct YUV422_image * out_image)
{return;
}   	     
//overlaid_image  must be large enough
void image_clip(struct YUV422_image * overlaid_image,
		int x,int y,
   	        struct YUV422_image * upper_layer_image)
{
#if 0	
 struct YUV422_image * YUV422_inf;
 Uint8 * p_overlaid,* p_upper;
 Uint8 * p_out;
 int i, j, len1,len2;
 int w,h;
 w=overlaid_image->width;
 h=overlaid_image->height;
//len1=in_image->width * in_image->height * 2;	

p_overlaid=overlaid_image->p_data;
p_upper=upper_layer_image->p_data;


j=0;
for(i=0;i< (in_image1->height+ in_image2->height-x);i+=2)
{ 
  for(j=0;j<(in_image1->width+in_image2->width) && j<WIDTH;j+=4)
      {
	  *p_out++=p_in[i*in_image->width+j];
	  p_out++;
      }
}
#endif
return;
}   	     

void half_size(struct YUV422_image * in_image,
   	     struct YUV422_image * out_image)
{
 struct YUV422_image * YUV422_inf;
 Uint8 * p_in,*pY1,*pU1,*pV1;
 Uint8 * p_out,*pY2,*pU2,*pV2;
 int i, j, len1,len2;
 
 len1=in_image->width * in_image->height * 2;
 len2=out_image->width * out_image->height * 2;
 
 /*pY1=(Uint8*)MEM_alloc(seg_sdrama,len/2 , 0);
 pU1=(Uint8*)MEM_alloc(seg_sdrama,len/4 , 0);
 pV1=(Uint8*)MEM_alloc(seg_sdrama,len/4 , 0);
 pY2=(Uint8*)MEM_alloc(seg_sdrama,len/2 , 0);
 pU2=(Uint8*)MEM_alloc(seg_sdrama,len/4 , 0);
 pV2=(Uint8*)MEM_alloc(seg_sdrama,len/4 , 0);
 
 YUV422_inf.p_data=temp_address3;
 YUV422_inf.width=WIDTH;
 YUV422_inf.height=HEIGHT;
 decompose_YUV(&in_image,original_Y,original_U,original_V);*/
p_in=in_image->p_data;
p_out=out_image->p_data;

j=0;
for(i=0;i<in_image->height;i+=2)
{ 
  for(j=0;j<in_image->width;j+=4)
      {
	  *p_out++=p_in[i*in_image->width+j];
	  p_out++;
      }
}
p_in=in_image->p_data;
p_out=out_image->p_data;
p_out++;
p_in++;

for(i=0;i<in_image->height;i+=2)
{ 
  for(j=1;j<in_image->width;j+=8)
      {   *p_out++=p_in[i*in_image->width+j];
	  p_out++;
      }
}
p_in=in_image->p_data;
p_out=out_image->p_data;
p_in+=3;
p_out+=3;

for(i=0;i<in_image->height;i+=2)
{ 
  for(j=3;j<in_image->width;j+=8)
      {
	  *p_out++=p_in[i*in_image->width+j];
	  p_out++;
      }
}

 out_image->width=in_image->width/2;
 out_image->height=in_image->height/2;
return;
}


/*
0  x  x  x  x  x  x              x x x 0 0 0 
1  0  0  0  0  0  0
2  x  x  x  x  x  x------------->x x x 0 0 0
3  0  0  0  0  0  0
*/

int decompose_YUV(struct YUV422_image * in_image,Uint8 * p_Y,Uint8 * p_U,Uint8 * p_V)
{
int i;
Uint8 * p_YUV;
int buf_len;

p_YUV=in_image->p_data;
buf_len=in_image->width * in_image->height * 2;

for (i=0;i<buf_len;i++)
	*(p_Y+i) = *(p_YUV+(i*2));
		
p_YUV++;						//point to U0
for (i=0;i<buf_len/2;i++)
	*(p_U+i) = *(p_YUV+(i*4));
	
p_YUV++;						//point to Y1
p_YUV++;						//point to V0
for (i=0;i<buf_len/2;i++)
	*(p_V+i) = *(p_YUV+(i*4));
return 0;	
}

int compose_YUV(Uint8 * p_Y,int Y_len,Uint8 * p_U,Uint8 * p_V,Uint8 * p_YUV)
{
return 0;	
}

Bool myDRAW_line  (  Uint8 *    pFrame,  
  Uint32    width, Uint32 height,  
  DRAW_Point  start, DRAW_Point    end,  
  Uint32    color )  
{
int i;
DRAW_Point    point;
Bool bStatus;  

point.x=start.x;
point.y=start.y;

if(start.x==end.x)	
	{
	if(start.y>end.y)
		{start.y=end.y;		 //supose start is smaller
		 end.y=point.y;		 
		}		
	for(i=start.y;i<=end.y;i++)
	{	    
    	bStatus = DRAW_setPixel(pFrame, width, height, start, color);        
    	start.y++;
    	if(bStatus == false)
                return false;        
	}      
	}
else if(start.y==start.y)
	{
	if(start.x>end.x)
		{start.x=end.x;		 
		 end.x=point.x;		 
		}		
	for(i=start.x;i<=end.x;i++)
	{	    
    	bStatus = DRAW_setPixel(pFrame, width, height, start, color);        
    	start.x++;
    	if(bStatus == false)
                return false;        
	}      
	}	
else{
	return false;
    }
return true;	
}  


void gen_drawpoint(x, y, color)
{
DRAW_Point    point;
point.x=x;
point.y=y;
//DRAW_setPixel(pFrame, width, height, start, color);        
}






/*
0  x  x  x  x  x  x              x x x 0 0 0 
1  0  0  0  0  0  0
2  x  x  x  x  x  x------------->x x x 0 0 0
3  0  0  0  0  0  0
*/
#if 0
void aaaaaaaaa(void)
{
		p_original_Y=&original_Y[0];
		p_original_U=&original_U[0];
		p_original_V=&original_V[0];

half_resize(p_original_Y,HEIGHT,WIDTH);
half_resize(p_original_U,HEIGHT,WIDTH/2);
half_resize(p_original_V,HEIGHT,WIDTH/2);

memset(p_original_Y+WIDTH*HEIGHT/2,0x1f,(WIDTH*HEIGHT)/2);
memset(p_original_U+(WIDTH*HEIGHT)/4,0x0e,(WIDTH*HEIGHT)/4);
memset(p_original_V+(WIDTH*HEIGHT)/4,0x09,WIDTH*HEIGHT/4);
}
#endif

void half_resize(Uint8 * p,int height,int width)
{int i,j,k;
 
 for(i=0;i<height-2;i++)
 {if(i%2==1) 		
 	{for(j=0;j<width;j++)
 		p[i*width+j]=0;
 	}
 }
 k=0;
 for(i=0;i<height*width;i++)
 	{
 	 p[k++]=p[i++];
 	}//end for
}

#if 0
void aaaaaaaaaaa(Uint8 * pInBufferY,Uint8 * pInBufferU,Uint8 *	pInBufferV,
		Uint8 * pOutBufferY,Uint8 * pOutBufferU,Uint8 *	pOutBufferV,
		Uint8 * OutputBuffer)
{
	int i,j;
	Uint8* 	temp_address2;	
		// To contrast the original image/processed image, we merge the two images
		// so that they could be simultaneously observed on the output screen.
		// The original image is on the left side while the processed image is on the right.
		temp_address2=OutputBuffer+(HEIGHT*WIDTH/4);
		
		// To output two images simultaneously, each image matrix is downsampled by 2.
		for (j=0;j<HEIGHT/2;j++)
		{
			for (i=0;i<WIDTH/4;i++)
			{
				*temp_address2 = (Uint16)(*pInBufferY)+(Uint16)((*pInBufferU)*256);
				*((Uint16*)(temp_address2+WIDTH/2)) = (Uint16)(*pOutBufferY)+(Uint16)((*pOutBufferU)*256);
				temp_address2++;
				pInBufferY+=2;	
				pOutBufferY+=2;
				pInBufferU+=2;
				pOutBufferU+=2;
				*temp_address2 = (Uint16)(*pInBufferY)+(Uint16)((*pInBufferV)*256);
				*((Uint16*)(temp_address2+WIDTH/2)) = (Uint16)(*pOutBufferY)+(Uint16)((*pOutBufferV)*256);
				temp_address2++;
				pInBufferY+=2;
				pOutBufferY+=2;
				pInBufferV+=2;
				pOutBufferV+=2;
			}			
			temp_address2+=(WIDTH/2);
			pInBufferY+=WIDTH;
			pOutBufferY+=WIDTH;
			pInBufferU+=(WIDTH/2);
			pOutBufferU+=(WIDTH/2);
			pInBufferV+=(WIDTH/2);
			pOutBufferV+=(WIDTH/2);
				
	    }
}	
#endif    

⌨️ 快捷键说明

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