I have sets of individual 8 bit yuv files from High Sierra DDR's.
Each file is 720 x 486 x 2 bytes in size (699,840).
The chroma space is 422.
The FOURCC of the data is UYVY. (CbYCrY)
I wish to build an avi file.
This is my first attempt at usinmg the library functions in avifile.
I am using Friday's CVS avifile.
I hacked a copy of avimake (jpeg files -> avi stream)
I set up a bitmapinfo structure:
width = 720; height = 486;
memset(bi, 0, sizeof(*bi));
bi->biSize = sizeof(*bi);
bi->biWidth = width;
bi->biHeight = height;
bi->biSizeImage = bi->biWidth * bi->biHeight * 2;
bi->biPlanes = 1;
bi->biCompression = FOURCC_UYVY;
bi->biBitCount = 16;
The
avm::IWriteFile* outFile = avm::CreateWriteFile(outFn);
fps = 30;
codec = fccUYVY;
outFile->AddVideoStream(codec, &bi, 1000000/fps);
avm::IVideoWriteStream* vidStr =
outFile->AddVideoStream(codec, &bi, 1000000/fr);
vidStr->Start();
sequence succeeds.
I read a file:
unsigned int line_size = 2 * width;
uint8_t* data = new uint8_t[line_size*height];
uint8_t* line = new uint8_t[line_size];
FILE * infile = fopen(fname, "rb");
if (infile == NULL) {
cerr << "can't open " << fname
<< ": " << strerror(errno) << endl;
exit(1);
}
fread(data, 2, width * height, infile);
fclose(infile);
Fix the line order to be from bottom to top:
for(int y = 0; y < height; y++) {
// The damn BMP files are backwards!
// (first row at bottom of image, and BGR instead of RGB):
uint8_t* ptr1 = & data[line_size * y];
uint8_t* ptr2 = & data[line_size * (height-y - 2)];
memcpy(line, ptr1, line_size);
memcpy(ptr1, ptr2, line_size);
memcpy(ptr2, line, line_size);
}
delete [] line;
avm::CImage frame(data, width, height);
The addFrame(&frame); call failed producing the message:
<CImage> : Cannot convert from 24 bit image to unimplemented UYVY 0x59565955
I suspect
avm::CImage frame(data, width, height);
is not the correct call to set up 422 data.
I also tried a fourcc of YUY2 (byte swapped UYVY) but it did not make any difference.
I could flip from 422 to 444, but I want to avoid converting to RGB
Any suggestions?
Any documentation on avifile library functions?
... Greg
_______________________________________________
Avifile mailing list
[EMAIL PROTECTED]
http://prak.org/mailman/listinfo/avifile