#ifndef mmioFOURCC #define mmioFOURCC( ch0, ch1, ch2, ch3 ) \ ( (ch0&0xff) | ( (ch1&0xff) << 8 ) | \ ( (ch2&0xff) << 16 ) | ( (ch3&0xff) << 24 ) ) #endif #include #include #include "colormodels.h" #include "config.h" #ifdef DYNAMIC_LOADING #define GLOBAL_ /* used by global.h, supposed to occur once */ #endif #include "global.h" #include "aviplugin.h" #include #ifndef fccYUY2 #include #endif void conv444to422(src,dst); #ifdef DYNAMIC_LOADING void read_avi(unsigned char **frame, unsigned int number); void video_in(){} void read_frame(unsigned char *frame[], unsigned int number) { read_avi(frame,number); } #endif void read_avi(frame, number) unsigned char *frame[]; unsigned int number; { int i, j; int r, g, b; double y, u, v; double cr, cg, cb, cu, cv; char name[128]; unsigned char *p_image, **pp_image; unsigned char *yp, *up, *vp; static unsigned char *u444, *v444, *u422, *v422; static unsigned int outputtype; static double coef[7][3] = { {0.2125,0.7154,0.0721}, /* ITU-R Rec. 709 (1990) */ {0.299, 0.587, 0.114}, /* unspecified */ {0.299, 0.587, 0.114}, /* reserved */ {0.30, 0.59, 0.11}, /* FCC */ {0.299, 0.587, 0.114}, /* ITU-R Rec. 624-4 System B, G */ {0.299, 0.587, 0.114}, /* SMPTE 170M */ {0.212, 0.701, 0.087}}; /* SMPTE 240M (1987) */ char buf[32]; static int mostrecentp = 0; static int mostrecent = 0; static size_t bufsize; static int avi_read_width, avi_read_height; i = matrix_coefficients; if (i>8) i = 3; cr = coef[i-1][0]; cg = coef[i-1][1]; cb = coef[i-1][2]; cu = 0.5/(1.0-cb); cv = 0.5/(1.0-cr); if (!outputtype) { outputtype=avi_outputtype(); #ifdef DYNAMIC_LOADING avi_read_width=get_video_width(); avi_read_height=get_video_height(); #else avi_read_width=avi_video_width(); avi_read_height=avi_video_height(); #endif fprintf(stderr,"\noutput format %c%c%c%c\n\n",(outputtype&0xff),(outputtype&0xff00)>>8,(outputtype&0xff0000)>>16, (outputtype&0xff000000)>>24); } if (outputtype==mmioFOURCC('R','G','B','A')) { if (chroma_format==CHROMA444) { u444 = frame[1]; v444 = frame[2]; } else { if (!u444) { if (!(u444 = (unsigned char *)malloc(avi_read_width*avi_read_height))) error("malloc failed"); if (!(v444 = (unsigned char *)malloc(avi_read_width*avi_read_height))) error("malloc failed"); if (chroma_format==CHROMA420) { if (!(u422 = (unsigned char *)malloc((avi_read_width>>1)*avi_read_height))) error("malloc failed"); if (!(v422 = (unsigned char *)malloc((avi_read_width>>1)*avi_read_height))) error("malloc failed"); } } } p_image = avi_get_frame(number); for (i=0; i>1; *yp++=*p_image++; *vp++=((*p_image++)+(*vp))>>1; } } else { for (j=0; j