cache gxp

IPU direct display bitmap BMP

Discussion created by cache gxp on Jun 8, 2012
Latest reply on Jun 25, 2012 by Qiang Li - Mpu Se

I hope imx-lib the IPU direct display bitmap BMP, in accordance with the following code, the resultsSegmegtation fault.I estimate the parameters fill in error, may I ask how to fill it?

 

int read_bmp_file(char* filename, unsigned char * const buffer, unsigned char** data, int* width, int* height, int* depth)
{
FILE* fd;
int rt;
int channel;
unsigned char* bits;

BITMAPFILEHEADER bmfh;
BITMAPINFOHEADER bmih;
fd = fopen(filename, "rb");
if(fd == NULL) {
printf("NO such file %s. ", filename);
return -1;
}
rt = fread(buffer, 1, 10*1024*1024, fd);
printf("read image ->%d. ", rt);
fclose(fd);
printf("sizeof(bmfh)->%d. ", sizeof(bmfh));
printf("sizeof(bmih)->%d. ", sizeof(bmih));
memcpy(&bmfh, buffer, sizeof(bmfh));
memcpy(&bmih, buffer + sizeof(bmfh), sizeof(bmih));
if(bmfh.bfType != 19778) {
return -1;
}
bits = (unsigned char*) (buffer+bmfh.bfOffBits);
channel = bmih.biBitCount/8;
*depth = bmih.biBitCount;
*width = bmih.biWidth;
*height = bmih.biHeight;
*data = bits;
printf(" size(%dx%d) channel:%d --- ", *width, *height, channel);
return 0;
}

int main(int argc, char *argv[])
{
int ret, test, i;
unsigned char *ptr;
ipu_lib_handle_t handle;
ipu_lib_input_param_t input;
ipu_lib_output_param_t output;
unsigned int w = 1440, h = 900;

char filename[256] = "\0";
unsigned char* data;
unsigned char* buffer;
int width, height, depth;

printf("IPU Test\n" );

strcpy(filename, "24.bmp");
buffer = (unsigned char*) malloc(10*1024*1024);
if(buffer == NULL) {
printf("malloc buuf fail\n");
return -1;
}
data = NULL;
read_bmp_file(filename, buffer, &data, &width, &height, &depth);
if(data == NULL) {
free(buffer);
return -1;
}
printf("Need DisPlay int date:width:%d,height:%d,depth:%d\n",width,height,depth);

memset(&input, 0x00, sizeof(input));
input.width = w;
input.height = h;
input.fmt = v4l2_fourcc('B', 'G', 'R', '3');
input.motion_sel = HIGH_MOTION;
input.input_crop_win.pos.x = 0;
input.input_crop_win.pos.y = 0;
input.input_crop_win.win_w = w;
input.input_crop_win.win_h = h;
input.user_def_paddr[0] = data;// NULL means that a buffer will be allocated

memset(&output, 0x00, sizeof(output));
output.width = w;
output.height = h;
output.fmt = v4l2_fourcc('B', 'G', 'R', '3');// IPU_PIX_FMT_RGB24;
output.rot = IPU_ROTATE_NONE;
output.show_to_fb = 1;
output.fb_disp.pos.x = 0;
output.fb_disp.pos.y = 0;
output.fb_disp.fb_num = 0;
output.output_win.pos.x = 0;
output.output_win.pos.y = 0;
output.output_win.win_w = w;
output.output_win.win_h = h;
output.user_def_paddr[0] = NULL;// NULL means that a buffer will be allocated

memset(&handle, 0x00, sizeof(handle));

ret = mxc_ipu_lib_task_init(&input, NULL, &output, OP_NORMAL_MODE,&handle);

printf("mxc_ipu_lib_task_init ret:%d"
" inbuf_start: 0x%X outbuf_start: 0x%X\n"
" ifr_size: %d ofr_size: %d\n",
ret,
(unsigned int)handle.inbuf_start[0], (unsigned int)handle.outbuf_start[0],
handle.ifr_size, handle.ofr_size);

if (ret == 0) // zero means the init worked
{
printf("DOING IPU TASK\n");
ret = mxc_ipu_lib_task_buf_update(&handle, NULL, 0, 0, NULL, NULL);
//ret = mxc_ipu_lib_task_buf_update(&handle, f->fb()->YCrCb.physical_base(),0,0, NULL, NULL);
printf("mxc_ipu_lib_task_buf_update returned:%d\n", ret);

// now print some outbuf contents after the task
ptr = (unsigned char *)handle.outbuf_start[0];
if (*ptr)// check for any non-zero value in output
printf("************* IPU DID CONVERT *************\n");// very rarely prints this!
printf("outbuf after: ");
for (i = 0; i < 10; i++, ptr++)printf("%02X ", *ptr);
printf("\n");

}
else
{
printf("mxc_ipu_lib_task_init FAILED:%d\n", ret);
return(0);
}

mxc_ipu_lib_task_uninit(&handle);
free(buffer);
return 0;

}

 

dbmp.c

Outcomes