54 |
#include "2pass.h" |
#include "2pass.h" |
55 |
|
|
56 |
int pmvfast_presets[7] = { |
int pmvfast_presets[7] = { |
57 |
0, PMV_QUICKSTOP16, 0, 0, |
0, PMV_QUICKSTOP16, PMV_EARLYSTOP16, PMV_EARLYSTOP16 | PMV_EARLYSTOP8, |
58 |
0 | PMV_HALFPELREFINE16 | PMV_HALFPELDIAMOND8, |
PMV_EARLYSTOP16 | PMV_HALFPELREFINE16 | PMV_EARLYSTOP8 | PMV_HALFPELDIAMOND8, |
59 |
0 | PMV_HALFPELREFINE16 | PMV_HALFPELDIAMOND8 | |
PMV_EARLYSTOP16 | PMV_HALFPELREFINE16 | PMV_EARLYSTOP8 | PMV_HALFPELDIAMOND8 | |
60 |
PMV_ADVANCEDDIAMOND16, PMV_HALFPELREFINE16 | PMV_EXTSEARCH16 | |
PMV_ADVANCEDDIAMOND16, PMV_EARLYSTOP16 | PMV_HALFPELREFINE16 | PMV_EXTSEARCH16 | |
61 |
PMV_HALFPELREFINE8 | PMV_HALFPELDIAMOND8 | PMV_USESQUARES16 |
PMV_EARLYSTOP8 | PMV_HALFPELREFINE8 | PMV_HALFPELDIAMOND8 | PMV_USESQUARES16 |
62 |
}; |
}; |
63 |
|
|
64 |
/* return xvid compatbile colorspace, |
/* return xvid compatbile colorspace, |
67 |
|
|
68 |
int get_colorspace(BITMAPINFOHEADER * hdr) |
int get_colorspace(BITMAPINFOHEADER * hdr) |
69 |
{ |
{ |
70 |
/* rgb only: negative height specifies top down image */ |
if (hdr->biHeight < 0) |
71 |
int rgb_flip = (hdr->biHeight < 0 ? 0 : XVID_CSP_VFLIP); |
{ |
72 |
|
DEBUGERR("colorspace: inverted input format not supported"); |
73 |
|
return XVID_CSP_NULL; |
74 |
|
} |
75 |
|
|
76 |
switch(hdr->biCompression) |
switch(hdr->biCompression) |
77 |
{ |
{ |
79 |
if (hdr->biBitCount == 16) |
if (hdr->biBitCount == 16) |
80 |
{ |
{ |
81 |
DEBUG("RGB16 (RGB555)"); |
DEBUG("RGB16 (RGB555)"); |
82 |
return rgb_flip | XVID_CSP_RGB555; |
return XVID_CSP_VFLIP | XVID_CSP_RGB555; |
83 |
} |
} |
84 |
if (hdr->biBitCount == 24) |
if (hdr->biBitCount == 24) |
85 |
{ |
{ |
86 |
DEBUG("RGB24"); |
DEBUG("RGB24"); |
87 |
return rgb_flip | XVID_CSP_RGB24; |
return XVID_CSP_VFLIP | XVID_CSP_RGB24; |
88 |
} |
} |
89 |
if (hdr->biBitCount == 32) |
if (hdr->biBitCount == 32) |
90 |
{ |
{ |
91 |
DEBUG("RGB32"); |
DEBUG("RGB32"); |
92 |
return rgb_flip | XVID_CSP_RGB32; |
return XVID_CSP_VFLIP | XVID_CSP_RGB32; |
93 |
} |
} |
94 |
|
|
95 |
DEBUG1("unsupported BI_RGB biBitCount", hdr->biBitCount); |
DEBUG1("BI_RGB unsupported", hdr->biBitCount); |
96 |
return XVID_CSP_NULL; |
return XVID_CSP_NULL; |
97 |
|
|
98 |
case BI_BITFIELDS : |
// how do these work in BITMAPINFOHEADER ??? |
99 |
if (hdr->biSize >= sizeof(BITMAPV4HEADER)) |
/* case BI_BITFIELDS : |
100 |
{ |
if (hdr->biBitCount == 16 |
101 |
BITMAPV4HEADER * hdr4 = (BITMAPV4HEADER *)hdr; |
if(hdr->biBitCount == 16 && |
102 |
|
hdr->bV4RedMask == 0x7c00 && |
103 |
if (hdr4->bV4BitCount == 16 && |
hdr->bV4GreenMask == 0x3e0 && |
104 |
hdr4->bV4RedMask == 0x7c00 && |
hdr->bV4BlueMask == 0x1f) |
|
hdr4->bV4GreenMask == 0x3e0 && |
|
|
hdr4->bV4BlueMask == 0x1f) |
|
105 |
{ |
{ |
106 |
DEBUG("RGB555"); |
DEBUG("RGB555"); |
107 |
return rgb_flip | XVID_CSP_RGB555; |
return XVID_CSP_VFLIP | XVID_CSP_RGB555; |
108 |
} |
} |
109 |
|
if(hdr->bV4BitCount == 16 && |
110 |
if(hdr4->bV4BitCount == 16 && |
hdr->bV4RedMask == 0xf800 && |
111 |
hdr4->bV4RedMask == 0xf800 && |
hdr->bV4GreenMask == 0x7e0 && |
112 |
hdr4->bV4GreenMask == 0x7e0 && |
hdr->bV4BlueMask == 0x1f) |
|
hdr4->bV4BlueMask == 0x1f) |
|
113 |
{ |
{ |
114 |
DEBUG("RGB565"); |
DEBUG("RGB565"); |
115 |
return rgb_flip | XVID_CSP_RGB565; |
return XVID_CSP_VFLIP | XVID_CSP_RGB565; |
|
} |
|
|
|
|
|
DEBUG("unsupported BI_BITFIELDS mode"); |
|
|
return XVID_CSP_NULL; |
|
116 |
} |
} |
117 |
|
|
118 |
DEBUG("unsupported BI_BITFIELDS/BITMAPHEADER combination"); |
DEBUG1("BI_FIELDS unsupported", hdr->bV4BitCount); |
119 |
return XVID_CSP_NULL; |
return XVID_CSP_NULL; |
120 |
|
*/ |
121 |
case FOURCC_I420 : |
case FOURCC_I420 : |
122 |
case FOURCC_IYUV : |
case FOURCC_IYUV : |
123 |
DEBUG("IYUY"); |
DEBUG("IYUY"); |
129 |
|
|
130 |
case FOURCC_YUYV : |
case FOURCC_YUYV : |
131 |
case FOURCC_YUY2 : |
case FOURCC_YUY2 : |
132 |
|
case FOURCC_V422 : |
133 |
DEBUG("YUY2"); |
DEBUG("YUY2"); |
134 |
return XVID_CSP_YUY2; |
return XVID_CSP_YUY2; |
135 |
|
|
141 |
DEBUG("UYVY"); |
DEBUG("UYVY"); |
142 |
return XVID_CSP_UYVY; |
return XVID_CSP_UYVY; |
143 |
|
|
|
default : |
|
|
DEBUGFOURCC("unsupported colorspace", hdr->biCompression); |
|
|
return XVID_CSP_NULL; |
|
144 |
} |
} |
145 |
|
DEBUGFOURCC("colorspace: unknown", hdr->biCompression); |
146 |
|
return XVID_CSP_NULL; |
147 |
} |
} |
148 |
|
|
149 |
|
|
194 |
|
|
195 |
memcpy(outhdr, inhdr, sizeof(BITMAPINFOHEADER)); |
memcpy(outhdr, inhdr, sizeof(BITMAPINFOHEADER)); |
196 |
outhdr->biSize = sizeof(BITMAPINFOHEADER); |
outhdr->biSize = sizeof(BITMAPINFOHEADER); |
197 |
|
outhdr->biBitCount = 24; // or 16 |
198 |
outhdr->biSizeImage = compress_get_size(codec, lpbiInput, lpbiOutput); |
outhdr->biSizeImage = compress_get_size(codec, lpbiInput, lpbiOutput); |
199 |
outhdr->biXPelsPerMeter = 0; |
outhdr->biXPelsPerMeter = 0; |
200 |
outhdr->biYPelsPerMeter = 0; |
outhdr->biYPelsPerMeter = 0; |