} videoreader_vfw_internal_t;
static int avifile_initialized = 0;
+static int verbose;
-#define _TRACE_ {printf("%s: %d (%s)\n",__FILE__,__LINE__,__func__);fflush(stdout);}
+#define _TRACE_ {printf("vfw: %s: %d (%s)\n",__FILE__,__LINE__,__func__);fflush(stdout);}
static bool videoreader_vfw_eof(videoreader_t* vr)
{
int linex = ((bytesperpixel/8)+3)&~3;
memset(dest, 255, dest_width*dest_height*4);//pre-fill alpha channel
- int starty = flip? 0 : dest_height-1;
- int endy = flip? dest_height-1 : 0;
- int yinc = flip? 1 : -1;
+ const int starty = flip? 0 : dest_height-1;
+ const int endy = flip? dest_height : -1;
+ const int yinc = flip? 1 : -1;
+
+ if(verbose) {
+ printf("vfw: Convering scanlines %d to %d from bpp %d, %d stepping, flip=%d\n", starty, endy, bi->biBitCount, yinc, flip);
+ }
if(bi->biBitCount==1) {
UCHAR*img = data;
int y;
- for(y=starty;y<=endy;y+=yinc) {
+ for(y=starty;y!=endy;y+=yinc) {
UCHAR*line = &img[linex*y];
int x;
for(x=0;x<dest_width;x++) {
UCHAR*img = &data[bi->biClrUsed*4];
UCHAR*pal = data;
int y;
- for(y=starty;y<=endy;y+=yinc) {
+ for(y=starty;y!=endy;y+=yinc) {
UCHAR*line = &img[linex*y];
int x;
for(x=0;x<dest_width/2;x++) {
UCHAR*img = &data[bi->biClrUsed*4];
UCHAR*pal = data;
int y;
- for(y=starty;y<=endy;y+=yinc) {
+ for(y=starty;y!=endy;y+=yinc) {
UCHAR*line = &img[linex*y];
int x;
for(x=0;x<dest_width;x++) {
line++;
}
}
+ } else if(bi->biBitCount==16) {
+ UCHAR*img = data;
+ int y;
+ for(y=starty;y!=endy;y+=yinc) {
+ UCHAR*line = &img[linex*y];
+ int x;
+ for(x=0;x<dest_width;x++) {
+ U16 c = line[0]|line[1]<<8;
+ *dest++ = 255|(c&0x1f)<<(8+3)|(c>>5&0x1f)<<(16+3)|(c>>10&0x1f)<<(24+3);
+ line+=2;
+ }
+ }
} else if(bi->biBitCount==24) {
UCHAR*img = data;
int y;
- for(y=starty;y<=endy;y+=yinc) {
+ for(y=starty;y!=endy;y+=yinc) {
UCHAR*line = &img[linex*y];
int x;
for(x=0;x<dest_width;x++) {
} else if(bi->biBitCount==32) {
UCHAR*img = data;
int y;
- for(y=starty;y<=endy;y+=yinc) {
+ for(y=starty;y!=endy;y+=yinc) {
UCHAR*line = &img[linex*y];
int x;
for(x=0;x<dest_width;x++) {
videoreader_vfw_internal_t* i = (videoreader_vfw_internal_t*)vr->internal;
if(!strcmp(name, "flip")) {
i->flip = atoi(value);
+ } else if(!strcmp(name, "verbose")) {
+ verbose = atoi(value);
}
}
/* calculate framerate */
i->fps = (double)info.dwRate/(double)info.dwScale;
+ if(verbose) {
+ printf("vfw: file %s has %f fps, and %d streams\n", i->fps, info.dwStreams);
+ }
+
unsigned int t=0;
while(t<info.dwStreams) {
PAVISTREAM stream;
}
if(i->vs) {
+ if(verbose) {
+ printf("vfw: video stream: %dx%d, %.2f\n", i->width, i->height, i->fps);
+ }
vr->width = i->width;
vr->height = i->height;
vr->fps = i->fps;
fprintf(stderr, "AVIReader: Warning: No video stream\n");
}
if(i->as) {
+ if(verbose) {
+ printf("vfw: audio stream: %d channels, %d samples/sec", i->channels, i->samplerate);
+ }
vr->channels = i->channels;
vr->samplerate = i->samplerate;
} else {