|
From: Joshua B. <jd...@jd...> - 2005-10-05 02:10:30
|
I'm trying to write my first decoding program using libdv. I'm flipping
back and forth between reppm.c and playdv.c.
I'm just trying to get my program to read each frame of pond.dv and toss
the results. My basic code looks like this:
#define READ_SIZE 144000
unsigned char dv_buffer[READ_SIZE];
dv_decoder_t *decoder;
/*I under stand that the application provides the buffer, but I don't
really understand why it needs to be so complicated. The next five
lines are pretty much from reppm.c.*/
unsigned char vb[720*576*3];
unsigned char *pixels[3];
int pitches[3];
pitches[0]=720*3;
pixels[0]=vb;
decoder = dv_decoder_new(TRUE, FALSE, FALSE);
if(!decoder) printf("decoder new failed\n");
if(READ_SIZE!=read(fd, dv_buffer, READ_SIZE))
{
printf("Read failed\n");
close(fd);
return 0;
}
if(dv_parse_header(decoder, dv_buffer)< 0)
printf("header parse error\n");
printf("x: %d y: %d\n", decoder->width, decoder->height);
dv_decode_full_frame(decoder, dv_buffer, e_dv_color_rgb, pixels, pitches);
while(go)
{
if(READ_SIZE==read(fd, dv_buffer, READ_SIZE))
{
printf("test3 %d %d\n", ret, count);
dv_decode_full_frame(decoder, dv_buffer, e_dv_color_rgb,
pixels,
pitches);
count++;
}else go =0;
}
printf("count: %d\n", count);
How I know this isn't working correctly is because at the end it prints
761 instead of 915.
I think the short of my questions are, first how much do I need to read
in each read? Second, how do I know for sure if dv_parse_header and
dv_decode_full_frame succeed? Third, what is the deal with having
pixels be a uchar*pixels[3], then always apparently using only
pixels[0]? Also, what is the pitches stuff about? I think that sums up
my confusion for the moment.
--
Joshua D. Boyd
jd...@jd...
http://www.jdboyd.net/
http://www.joshuaboyd.org/
|