Thanks for ur reply,
This is my code
char dev_name[2][20] = { "/dev/video2", "/dev/video3" };
int main(int argc, char *argv[])
{
char shortoptions[] = "c:f:t:w:h:";
int mode = O_RDWR, c, ret,ret1, j, i,k;
int index=0, found = 0;
int fd, ch_no = 0, numbuffers = 3, a;
struct v4l2_requestbuffers req;
struct v4l2_buffer buf;
struct buf_info *buff_info;
struct v4l2_format fmt;
enum v4l2_buf_type type;
void *addr1;
int counter=0;
static int captFrmCnt = 0;
v4l2_std_id std;
struct v4l2_crop crop;
char *src, *dest;
char in_file[100] = "";
FILE *inp_f, *out_f;
int width = 720 , height = 480, size, expected_size;
int format = 0; //UYVY
char temp;
for (;;) {
c = getopt_long(argc, argv, shortoptions, (void *) NULL,
&index);
if (-1 == c)
break;
switch (c) {
case 'c':
ch_no = atoi(optarg);
break;
case 'f':
strcpy(in_file,optarg);
break;
case 'w':
width = atoi(optarg);
break;
case 'h':
height = atoi(optarg);
break;
case 't':
format = atoi(optarg);
break;
default:
usage();
exit(1);
}
}
if (!IS_VALID_CHANNEL(ch_no)) {
printf("Invalid channel id");
exit(0);
}
if (!strcmp(in_file, "")) {
printf("Use -f option to provide an input file\n"
"An example input is located with the sources: "
"video_720p (1280x720 UYVY format)\n");
usage();
exit(1);
}
printf("displaying in_file = %s with width = %d, height = %d
\n",in_file,width,height);
expected_size = width * height * BYTESPERLINE;
bzero (&fmt, sizeof(fmt));
if (format == 1) {
// 420 output display. round width to next 32 byte boundary
width = (width + 31) & (~31);
printf("width = %d\n", width);
expected_size = (width * height) + (width * height / 2);
}
inp_f = fopen(in_file, "rb");
if (inp_f == NULL) {
perror("Error in opening input file \n");
exit(1);
}
/* Now choose the display output mode based on resolution of the
image */
if (width <= 720 && height <= 480) {
if (change_sysfs_attrib(ATTRIB_OUTPUT,
DISPLAY_INTERFACE_COMPOSITE)
< 0) {
printf("Unable to change display output to %s\n",
DISPLAY_INTERFACE_COMPOSITE);
fclose(inp_f);
exit(1);
}
if (change_sysfs_attrib(ATTRIB_MODE, DISPLAY_MODE_NTSC) < 0) {
printf("Unable to change display mode to %s\n",
DISPLAY_MODE_NTSC);
fclose(inp_f);
exit(1);
}
fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
} else if (width <= 720 && height <= 576) {
if (change_sysfs_attrib(ATTRIB_OUTPUT,
DISPLAY_INTERFACE_COMPOSITE)
< 0) {
printf("Unable to change display output to %s\n",
DISPLAY_INTERFACE_COMPOSITE);
fclose(inp_f);
exit(1);
}
if (change_sysfs_attrib(ATTRIB_MODE, DISPLAY_MODE_PAL) < 0) {
printf("Unable to change display mode to %s\n",
DISPLAY_MODE_PAL);
fclose(inp_f);
exit(1);
}
fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
} else if (width <= 1280 && height <= 720) {
if (change_sysfs_attrib(ATTRIB_OUTPUT,
DISPLAY_INTERFACE_COMPONENT)
< 0) {
printf("Unable to change display output to %s\n",
DISPLAY_INTERFACE_COMPONENT);
fclose(inp_f);
exit(1);
}
if (change_sysfs_attrib(ATTRIB_MODE, DISPLAY_MODE_720P) < 0) {
printf("Unable to change display mode to %s\n",
DISPLAY_MODE_720P);
fclose(inp_f);
exit(1);
}
fmt.fmt.pix.field = V4L2_FIELD_NONE;
} else if (width <= 1920 && height <= 1080) {
if (change_sysfs_attrib(ATTRIB_OUTPUT,
DISPLAY_INTERFACE_COMPONENT)
< 0) {
printf("Unable to change display output to %s\n",
DISPLAY_INTERFACE_COMPONENT);
fclose(inp_f);
exit(1);
}
if (change_sysfs_attrib(ATTRIB_MODE, DISPLAY_MODE_1080I) < 0) {
printf("Unable to change display mode to %s\n",
DISPLAY_MODE_1080I);
fclose(inp_f);
exit(1);
}
fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
} else {
printf("Unable to display this resolution image\n");
exit(1);
}
bzero((void *)&req,sizeof(struct v4l2_requestbuffers));
fd = open((const char *)dev_name[ch_no], mode);
if (fd <= 0) {
printf("Cannot open = %s device\n", dev_name[ch_no]);
exit(1);
}
req.count = numbuffers;
req.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
req.memory = V4L2_MEMORY_MMAP;
ret = ioctl(fd, VIDIOC_REQBUFS, &req);
if (ret) {
perror("cannot allocate memory\n");
close(fd);
exit(1);
}
if (req.count <numbuffers)
{
printf("init_capture_buffers only:"
"%d buffers avilable, can't proceed\n", req.count);
return -1;
}
buffers = (struct buffer *)calloc(req.count, sizeof(struct
buffer));
if (!buffers)
{
printf("display buffers :calloc:\n");
return -1;
}
/* Enqueue buffers */
ftell(inp_f);
i=0;
for (index = 0; index < req.count; index++)
{
bzero(&buf, sizeof(struct v4l2_buffer));
buf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
buf.index = index;
buf.memory =V4L2_MEMORY_MMAP;
if (-1 == ioctl(fd, VIDIOC_QUERYBUF, &buf))
{
printf("init_capture_buffers:VIDIOC_QUERYBUF:\n\n");
return -1;
}
buffers[index].length = buf.length;
buffers[index].start =mmap(NULL, buf.length, PROT_READ |
PROT_WRITE,
MAP_SHARED,fd, buf.m.offset);
//memcpy(buffers[index].start, in_buf, size);
printf("buffer:%d phy:%x mmap:%p length:%d\n", buf.index,
buf.m.offset, buffers[index].start, buf.length);
if (MAP_FAILED == buffers[index].start)
{
printf("init_capture_buffers:mmap:\n");
return -1;
}
ret = ioctl(fd, VIDIOC_QBUF, &buf);
if (ret)
{
perror("VIDIOC_QBUF\n");
close(fd);
exit(1);
}
fseek(inp_f,i,SEEK_SET);
size = fread(in_buf,1, expected_size, inp_f);
i=i+size;
printf("read size = %d, expected size = %d\n", size, expected_size);
if (size < expected_size) {
printf("mismatch between file size and expected size\n");
printf("size = %d, expected size = %d\n", size, expected_size);
// fclose(inp_f);
exit(1);
}
memcpy(buffers[index].start, in_buf, size);
}
fclose(inp_f);
fmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
if (format == 0) {
width += 15;
width &= (~15);
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_UYVY;
}
else {
width += 31;
width &= (~31);
fmt.fmt.pix.bytesperline = width;
fmt.fmt.pix.sizeimage = width * height * 1.5;
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_NV12;
}
fmt.fmt.pix.height = height;
fmt.fmt.pix.width = width;
ret = ioctl(fd, VIDIOC_S_FMT, &fmt);
if (ret) {
perror("VIDIOC_S_FMT\n");
close(fd);
exit(1);
}
On Dec 8, 1:42 pm, 袁堂夫 <[email protected]> wrote:
> Can you show me your key codes for displaying? Then I maybe give u
> some useful information.
>
> 2010/12/8 venu <[email protected]>:
>
> > Hi everyone,
>
> > I am playing a yuv file on my hardware using my one own c
> > application(using v4l2 interface).It is playing but display is not
> > comming.If i play the samething on linux its gets display on lcd. In
> > android just some blinking is there on lcd apart from that nothing is
> > showing. How to play yuv file in android using own application or
> > using android application.
>
> > Any suggestion welcome..........
>
> > Thanks in advance
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en