On Thu, 27 Apr 2000, James Bowman wrote:
> dvs *dvs_open(void *(*reader_func)(void*), void *s, enum frame_format)
> Initializes a dv stream, with a given read_func. reader_func(s)
> returns a pointer to the next 400 bytes in the stream. frame_format
> would be the target pixel format: 32-bit RGB, 16-bit RGB, raw YCrCb.
I would lean towards a very simple API that takes a bunch of bytes (in
multiples of 80) and a pointer to a memory region:
int dv_decode(unsigned char *dv,unsigned char *image);
Couple that with a few utility routines:
int dv_video_format(unsigned char *dv); (= DV_411, DV_420, ...)
int dv_video_size(unsigned char *dv,int &w,int &h);
int dv_bytes_per_frame(unsigned char *dv); (= 120,000, 144,000)
int dv_next_frame_offset(unsigned char *dv);
The idea is that this gives full control over the input and output streams
to the application calling the library. A decode loop could look like:
unsigned char *dv, *image;
int format,bpf,w,h;
/* assume that the next bytes are the head of a frame */
dv = malloc(DV_DIF_BLOCK_SIZE);
fread(dv,DV_DIF_BLOCK_SIZE,1,stdin);
format = dv_video_format(dv);
dv_video_size(dv,&w,&h);
switch (format) {
case DV_411, DV_420: image = malloc(w*h+(w*h/2));
...
}
bpf = dv_byte_per_frame(dv);
free(dv);
dv = malloc(bpf);
fread(dv,bpf-DV_DIF_BLOCK_SIZE,1,stdin);
dv_decode(dv,image);
/* go process the image now, yuv2rgb convert and display */
while (!feof(stdin)) {
fread(dv,bpf,1,stdin);
dv_decode(dv,image);
/* process image */
}
Now, this API needs a few more things, since the ideal case from the
performance point of view, on machines without hardware acceleration, is
to do yuv2rgb on a macroblock at a time basis during decode. That means
we'd want a switch (or just a dv_decode variation) to have it output
various forms of RGB, and thus do the specialization for speed.
One thing I do have somewhere is the header file from Adaptec's DV codec.
It's sitting in some mailbox of mine. I'll dig that out and we can see
what they do.
Erik Walthinsen <om...@cs...> - Staff Programmer @ OGI
Quasar project - http://www.cse.ogi.edu/DISC/projects/quasar/
Video4Linux Two drivers and stuff - http://www.cse.ogi.edu/~omega/v4l2/
__
/ \ SEUL: Simple End-User Linux - http://www.seul.org/
| | M E G A Helping Linux become THE choice
_\ /_ for the home or office user
|