int samplerate;
int channels;
+ int flip;
} videoreader_vfw_internal_t;
static int avifile_initialized = 0;
#define _TRACE_ {printf("%s: %d (%s)\n",__FILE__,__LINE__,__func__);fflush(stdout);}
-bool videoreader_vfw_eof(videoreader_t* vr)
+static bool videoreader_vfw_eof(videoreader_t* vr)
{
videoreader_vfw_internal_t* i = (videoreader_vfw_internal_t*)vr->internal;
return (i->video_pos >= i->video_end);
int bytesperpixel = ((bi->biWidth*bi->biBitCount)+7)&~7;
int linex = ((bytesperpixel/8)+3)&~3;
memset(dest, 255, dest_width*dest_height*4);//pre-fill alpha channel
+
+ int starty = i->flip? 0 : dest_height-1;
+ int endy = i->flip? dest_height-1 : 0;
+ int yinc = i->flip? 1 : -1;
+
if(bi->biBitCount==1) {
- int y;
UCHAR*img = data;
- for(y=0;y<dest_height;y++) {
+ int y;
+ 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==4) {
- int y;
UCHAR*img = &data[bi->biClrUsed*4];
UCHAR*pal = data;
- for(y=0;y<dest_height;y++) {
+ int y;
+ for(y=starty;y<=endy;y+=yinc) {
UCHAR*line = &img[linex*y];
int x;
for(x=0;x<dest_width/2;x++) {
}
}
} else if(bi->biBitCount==8) {
- int y;
UCHAR*img = &data[bi->biClrUsed*4];
UCHAR*pal = data;
- for(y=0;y<dest_height;y++) {
+ int y;
+ 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==24) {
UCHAR*img = data;
int y;
- for(y=0;y<dest_height;y++) {
+ 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=0;y<dest_height;y++) {
+ for(y=starty;y<=endy;y+=yinc) {
UCHAR*line = &img[linex*y];
int x;
for(x=0;x<dest_width;x++) {
return 1;
}
-int videoreader_vfw_getimage(videoreader_t* vr, void*buffer)
+static int videoreader_vfw_getimage(videoreader_t* vr, void*buffer)
{
videoreader_vfw_internal_t* i = (videoreader_vfw_internal_t*)vr->internal;
return bytes;
}
-int videoreader_vfw_getsamples(videoreader_t* vr, void*buf, int num)
+static int videoreader_vfw_getsamples(videoreader_t* vr, void*buf, int num)
{
videoreader_vfw_internal_t* i = (videoreader_vfw_internal_t*)vr->internal;
}
}
-void videoreader_vfw_close(videoreader_t* vr)
+static void videoreader_vfw_close(videoreader_t* vr)
{
videoreader_vfw_internal_t* i = (videoreader_vfw_internal_t*)vr->internal;
free(vr->internal); vr->internal = 0;
}
-void videoreader_vfw_setparameter(videoreader_t* vr, char*name, char*value) {}
+static void videoreader_vfw_setparameter(videoreader_t*vr, char*name, char*value)
+{
+ videoreader_vfw_internal_t* i = (videoreader_vfw_internal_t*)vr->internal;
+ if(!strcmp(name, "flip")) {
+ i->flip = atoi(value);
+ }
+}
int videoreader_vfw_open(videoreader_t* vr, char* filename)
{