Author: akhaldi Date: Fri Nov 20 10:39:43 2015 New Revision: 69956
URL: http://svn.reactos.org/svn/reactos?rev=69956&view=rev Log: [ICCVID] Sync with Wine Staging 1.7.55. CORE-10536
Modified: trunk/reactos/dll/win32/iccvid/iccvid.c trunk/reactos/media/doc/README.WINE
Modified: trunk/reactos/dll/win32/iccvid/iccvid.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/iccvid/iccvid.c?r... ============================================================================== --- trunk/reactos/dll/win32/iccvid/iccvid.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/iccvid/iccvid.c [iso-8859-1] Fri Nov 20 10:39:43 2015 @@ -145,6 +145,15 @@ } }
+static inline long get_addr(BOOL inverted, unsigned long x, unsigned long y, + int frm_stride, int bpp, unsigned int out_height) +{ + /* Returns the starting position of a line from top-down or bottom-up */ + if (inverted) + return y * frm_stride + x * bpp; + else + return (out_height - 1 - y) * frm_stride + x * bpp; +}
#define MAKECOLOUR32(r,g,b) (((r) << 16) | ((g) << 8) | (b)) /*#define MAKECOLOUR24(r,g,b) (((r) << 16) | ((g) << 8) | (b))*/ @@ -152,15 +161,17 @@ #define MAKECOLOUR15(r,g,b) (((r) >> 3) << 10)| (((g) >> 3) << 5)| (((b) >> 3) << 0)
/* ------------------------------------------------------------------------ */ -static void cvid_v1_32(unsigned char *frm, unsigned char *limit, int stride, cvid_codebook *cb) +static void cvid_v1_32(unsigned char *frm, unsigned char *limit, int stride, BOOL inverted, + cvid_codebook *cb) { unsigned long *vptr = (unsigned long *)frm; -#ifndef ORIGINAL -int row_inc = -stride/4; -#else -int row_inc = stride/4; -#endif +int row_inc; int x, y; + + if (!inverted) + row_inc = -stride/4; + else + row_inc = stride/4;
/* fill 4x4 block of pixels with colour values from codebook */ for (y = 0; y < 4; y++) @@ -173,17 +184,18 @@
/* ------------------------------------------------------------------------ */ -static void cvid_v4_32(unsigned char *frm, unsigned char *limit, int stride, cvid_codebook *cb0, - cvid_codebook *cb1, cvid_codebook *cb2, cvid_codebook *cb3) +static void cvid_v4_32(unsigned char *frm, unsigned char *limit, int stride, BOOL inverted, + cvid_codebook *cb0, cvid_codebook *cb1, cvid_codebook *cb2, cvid_codebook *cb3) { unsigned long *vptr = (unsigned long *)frm; -#ifndef ORIGINAL -int row_inc = -stride/4; -#else -int row_inc = stride/4; -#endif +int row_inc; int x, y; cvid_codebook * cb[] = {cb0,cb1,cb2,cb3}; + + if (!inverted) + row_inc = -stride/4; + else + row_inc = stride/4;
/* fill 4x4 block of pixels with colour values from codebooks */ for (y = 0; y < 4; y++) @@ -196,14 +208,16 @@
/* ------------------------------------------------------------------------ */ -static void cvid_v1_24(unsigned char *vptr, unsigned char *limit, int stride, cvid_codebook *cb) -{ -#ifndef ORIGINAL -int row_inc = -stride; -#else -int row_inc = stride; -#endif +static void cvid_v1_24(unsigned char *vptr, unsigned char *limit, int stride, BOOL inverted, + cvid_codebook *cb) +{ +int row_inc; int x, y; + + if (!inverted) + row_inc = -stride; + else + row_inc = stride;
/* fill 4x4 block of pixels with colour values from codebook */ for (y = 0; y < 4; y++) @@ -220,16 +234,17 @@
/* ------------------------------------------------------------------------ */ -static void cvid_v4_24(unsigned char *vptr, unsigned char *limit, int stride, cvid_codebook *cb0, - cvid_codebook *cb1, cvid_codebook *cb2, cvid_codebook *cb3) -{ -#ifndef ORIGINAL -int row_inc = -stride; -#else -int row_inc = stride; -#endif +static void cvid_v4_24(unsigned char *vptr, unsigned char *limit, int stride, BOOL inverted, + cvid_codebook *cb0, cvid_codebook *cb1, cvid_codebook *cb2, cvid_codebook *cb3) +{ +int row_inc; cvid_codebook * cb[] = {cb0,cb1,cb2,cb3}; int x, y; + + if (!inverted) + row_inc = -stride; + else + row_inc = stride;
/* fill 4x4 block of pixels with colour values from codebooks */ for (y = 0; y < 4; y++) @@ -246,15 +261,17 @@
/* ------------------------------------------------------------------------ */ -static void cvid_v1_16(unsigned char *frm, unsigned char *limit, int stride, cvid_codebook *cb) +static void cvid_v1_16(unsigned char *frm, unsigned char *limit, int stride, BOOL inverted, + cvid_codebook *cb) { unsigned short *vptr = (unsigned short *)frm; -#ifndef ORIGINAL -int row_inc = -stride/2; -#else -int row_inc = stride/2; -#endif +int row_inc; int x, y; + + if (!inverted) + row_inc = -stride/2; + else + row_inc = stride/2;
/* fill 4x4 block of pixels with colour values from codebook */ for (y = 0; y < 4; y++) @@ -267,17 +284,18 @@
/* ------------------------------------------------------------------------ */ -static void cvid_v4_16(unsigned char *frm, unsigned char *limit, int stride, cvid_codebook *cb0, - cvid_codebook *cb1, cvid_codebook *cb2, cvid_codebook *cb3) +static void cvid_v4_16(unsigned char *frm, unsigned char *limit, int stride, BOOL inverted, + cvid_codebook *cb0, cvid_codebook *cb1, cvid_codebook *cb2, cvid_codebook *cb3) { unsigned short *vptr = (unsigned short *)frm; -#ifndef ORIGINAL -int row_inc = -stride/2; -#else -int row_inc = stride/2; -#endif +int row_inc; cvid_codebook * cb[] = {cb0,cb1,cb2,cb3}; int x, y; + + if (!inverted) + row_inc = -stride/2; + else + row_inc = stride/2;
/* fill 4x4 block of pixels with colour values from codebooks */ for (y = 0; y < 4; y++) @@ -289,15 +307,17 @@ }
/* ------------------------------------------------------------------------ */ -static void cvid_v1_15(unsigned char *frm, unsigned char *limit, int stride, cvid_codebook *cb) +static void cvid_v1_15(unsigned char *frm, unsigned char *limit, int stride, BOOL inverted, + cvid_codebook *cb) { unsigned short *vptr = (unsigned short *)frm; -#ifndef ORIGINAL -int row_inc = -stride/2; -#else -int row_inc = stride/2; -#endif +int row_inc; int x, y; + + if (!inverted) + row_inc = -stride/2; + else + row_inc = stride/2;
/* fill 4x4 block of pixels with colour values from codebook */ for (y = 0; y < 4; y++) @@ -310,17 +330,18 @@
/* ------------------------------------------------------------------------ */ -static void cvid_v4_15(unsigned char *frm, unsigned char *limit, int stride, cvid_codebook *cb0, - cvid_codebook *cb1, cvid_codebook *cb2, cvid_codebook *cb3) +static void cvid_v4_15(unsigned char *frm, unsigned char *limit, int stride, BOOL inverted, + cvid_codebook *cb0, cvid_codebook *cb1, cvid_codebook *cb2, cvid_codebook *cb3) { unsigned short *vptr = (unsigned short *)frm; -#ifndef ORIGINAL -int row_inc = -stride/2; -#else -int row_inc = stride/2; -#endif +int row_inc; cvid_codebook * cb[] = {cb0,cb1,cb2,cb3}; int x, y; + + if (!inverted) + row_inc = -stride/2; + else + row_inc = stride/2;
/* fill 4x4 block of pixels with colour values from codebooks */ for (y = 0; y < 4; y++) @@ -369,8 +390,9 @@ }
typedef void (*fn_cvid_v1)(unsigned char *frm, unsigned char *limit, - int stride, cvid_codebook *cb); -typedef void (*fn_cvid_v4)(unsigned char *frm, unsigned char *limit, int stride, + int stride, BOOL inverted, cvid_codebook *cb); +typedef void (*fn_cvid_v4)(unsigned char *frm, unsigned char *limit, + int stride, BOOL inverted, cvid_codebook *cb0, cvid_codebook *cb1, cvid_codebook *cb2, cvid_codebook *cb3);
@@ -380,33 +402,42 @@ * context - the context created by decode_cinepak_init(). * buf - the input buffer to be decoded * size - the size of the input buffer - * frame - the output frame buffer (24 or 32 bit per pixel) - * width - the width of the output frame - * height - the height of the output frame + * output - the output frame buffer (24 or 32 bit per pixel) + * out_width - the width of the output frame + * out_height - the height of the output frame * bit_per_pixel - the number of bits per pixel allocated to the output * frame (only 24 or 32 bpp are supported) + * inverted - if true the output frame is written top-down */ static void decode_cinepak(cinepak_info *cvinfo, unsigned char *buf, int size, - unsigned char *frame, unsigned int width, unsigned int height, int bit_per_pixel) + unsigned char *output, unsigned int out_width, unsigned int out_height, int bit_per_pixel, BOOL inverted) { cvid_codebook *v4_codebook, *v1_codebook, *codebook = NULL; - unsigned long x, y, y_bottom, frame_flags, strips, cv_width, cv_height, - cnum, strip_id, chunk_id, x0, y0, x1, y1, ci, flag, mask; - long len, top_size, chunk_size; + unsigned long x, y, y_bottom, cnum, strip_id, chunk_id, + x0, y0, x1, y1, ci, flag, mask; + long top_size, chunk_size; unsigned char *frm_ptr; - unsigned int i, cur_strip; + unsigned int i, cur_strip, addr; int d0, d1, d2, d3, frm_stride, bpp = 3; fn_cvid_v1 cvid_v1 = cvid_v1_24; fn_cvid_v4 cvid_v4 = cvid_v4_24; + struct frame_header + { + unsigned char flags; + unsigned long length; + unsigned short width; + unsigned short height; + unsigned short strips; + } frame;
y = 0; y_bottom = 0; in_buffer = buf;
- frame_flags = get_byte(); - len = get_byte() << 16; - len |= get_byte() << 8; - len |= get_byte(); + frame.flags = get_byte(); + frame.length = get_byte() << 16; + frame.length |= get_byte() << 8; + frame.length |= get_byte();
switch(bit_per_pixel) { @@ -432,32 +463,32 @@ break; }
- frm_stride = width * bpp; - frm_ptr = frame; - - if(len != size) - { - if(len & 0x01) len++; /* AVIs tend to have a size mismatch */ - if(len != size) + frm_stride = out_width * bpp; + frm_ptr = output; + + if(frame.length != size) + { + if(frame.length & 0x01) frame.length++; /* AVIs tend to have a size mismatch */ + if(frame.length != size) { - ERR("CVID: corruption %d (QT/AVI) != %ld (CV)\n", size, len); + ERR("CVID: corruption %d (QT/AVI) != %ld (CV)\n", size, frame.length); /* return; */ } }
- cv_width = get_word(); - cv_height = get_word(); - strips = get_word(); - - if(strips > cvinfo->strip_num) - { - if(strips >= MAX_STRIPS) + frame.width = get_word(); + frame.height = get_word(); + frame.strips = get_word(); + + if(frame.strips > cvinfo->strip_num) + { + if(frame.strips >= MAX_STRIPS) { ERR("CVID: strip overflow (more than %d)\n", MAX_STRIPS); return; }
- for(i = cvinfo->strip_num; i < strips; i++) + for(i = cvinfo->strip_num; i < frame.strips; i++) { if((cvinfo->v4_codebook[i] = heap_alloc(sizeof(cvid_codebook) * 260)) == NULL) { @@ -472,16 +503,17 @@ } } } - cvinfo->strip_num = strips; - - TRACE("CVID: <%ld,%ld> strips %ld\n", cv_width, cv_height, strips); - - for(cur_strip = 0; cur_strip < strips; cur_strip++) + cvinfo->strip_num = frame.strips; + + TRACE("CVID: %ux%u, strips %u, length %lu\n", + frame.width, frame.height, frame.strips, frame.length); + + for(cur_strip = 0; cur_strip < frame.strips; cur_strip++) { v4_codebook = cvinfo->v4_codebook[cur_strip]; v1_codebook = cvinfo->v1_codebook[cur_strip];
- if((cur_strip > 0) && (!(frame_flags & 0x01))) + if((cur_strip > 0) && (!(frame.flags & 0x01))) { memcpy(cvinfo->v4_codebook[cur_strip], cvinfo->v4_codebook[cur_strip-1], 260 * sizeof(cvid_codebook)); memcpy(cvinfo->v1_codebook[cur_strip], cvinfo->v1_codebook[cur_strip-1], 260 * sizeof(cvid_codebook)); @@ -497,8 +529,8 @@ y_bottom += y1; top_size -= 12; x = 0; - if(x1 != width) - WARN("CVID: Warning x1 (%ld) != width (%d)\n", x1, width); + if(x1 != out_width) + WARN("CVID: Warning x1 (%ld) != width (%d)\n", x1, out_width);
TRACE(" %d) %04lx %04ld <%ld,%ld> <%ld,%ld> yt %ld\n", cur_strip, strip_id, top_size, x0, y0, x1, y1, y_bottom); @@ -596,24 +628,20 @@ d2 = get_byte(); d3 = get_byte(); chunk_size -= 4; -#ifdef ORIGINAL - cvid_v4(frm_ptr + (y * frm_stride + x * bpp), frm_end, frm_stride, v4_codebook+d0, v4_codebook+d1, v4_codebook+d2, v4_codebook+d3); -#else - cvid_v4(frm_ptr + ((height - 1 - y) * frm_stride + x * bpp), frame, frm_stride, v4_codebook+d0, v4_codebook+d1, v4_codebook+d2, v4_codebook+d3); -#endif + + addr = get_addr(inverted, x, y, frm_stride, bpp, out_height); + cvid_v4(frm_ptr + addr, output, frm_stride, inverted, v4_codebook+d0, v4_codebook+d1, v4_codebook+d2, v4_codebook+d3); } else /* 1 byte per block */ { -#ifdef ORIGINAL - cvid_v1(frm_ptr + (y * frm_stride + x * bpp), frm_end, frm_stride, v1_codebook + get_byte()); -#else - cvid_v1(frm_ptr + ((height - 1 - y) * frm_stride + x * bpp), frame, frm_stride, v1_codebook + get_byte()); -#endif + addr = get_addr(inverted, x, y, frm_stride, bpp, out_height); + cvid_v1(frm_ptr + addr, output, frm_stride, inverted, v1_codebook + get_byte()); + chunk_size--; }
x += 4; - if(x >= width) + if(x >= out_width) { x = 0; y += 4; @@ -652,26 +680,22 @@ d2 = get_byte(); d3 = get_byte(); chunk_size -= 4; -#ifdef ORIGINAL - cvid_v4(frm_ptr + (y * frm_stride + x * bpp), frm_end, frm_stride, v4_codebook+d0, v4_codebook+d1, v4_codebook+d2, v4_codebook+d3); -#else - cvid_v4(frm_ptr + ((height - 1 - y) * frm_stride + x * bpp), frame, frm_stride, v4_codebook+d0, v4_codebook+d1, v4_codebook+d2, v4_codebook+d3); -#endif + + addr = get_addr(inverted, x, y, frm_stride, bpp, out_height); + cvid_v4(frm_ptr + addr, output, frm_stride, inverted, v4_codebook+d0, v4_codebook+d1, v4_codebook+d2, v4_codebook+d3); } else /* V1 */ { chunk_size--; -#ifdef ORIGINAL - cvid_v1(frm_ptr + (y * frm_stride + x * bpp), frm_end, frm_stride, v1_codebook + get_byte()); -#else - cvid_v1(frm_ptr + ((height - 1 - y) * frm_stride + x * bpp), frame, frm_stride, v1_codebook + get_byte()); -#endif + + addr = get_addr(inverted, x, y, frm_stride, bpp, out_height); + cvid_v1(frm_ptr + addr, output, frm_stride, inverted, v1_codebook + get_byte()); } } /* else SKIP */
mask >>= 1; x += 4; - if(x >= width) + if(x >= out_width) { x = 0; y += 4; @@ -685,14 +709,12 @@ case 0x3200: /* each byte is a V1 codebook */ while((chunk_size > 0) && (y < y_bottom)) { -#ifdef ORIGINAL - cvid_v1(frm_ptr + (y * frm_stride + x * bpp), frm_end, frm_stride, v1_codebook + get_byte()); -#else - cvid_v1(frm_ptr + ((height - 1 - y) * frm_stride + x * bpp), frame, frm_stride, v1_codebook + get_byte()); -#endif + addr = get_addr(inverted, x, y, frm_stride, bpp, out_height); + cvid_v1(frm_ptr + addr, output, frm_stride, inverted, v1_codebook + get_byte()); + chunk_size--; x += 4; - if(x >= width) + if(x >= out_width) { x = 0; y += 4; @@ -709,10 +731,10 @@ } }
- if(len != size) - { - if(len & 0x01) len++; /* AVIs tend to have a size mismatch */ - if(len != size) + if(frame.length != size) + { + if(frame.length & 0x01) frame.length++; /* AVIs tend to have a size mismatch */ + if(frame.length != size) { long xlen; skip_byte(); @@ -720,7 +742,7 @@ xlen |= get_byte() << 8; xlen |= get_byte(); /* Read Len */ WARN("CVID: END INFO chunk size %d cvid size1 %ld cvid size2 %ld\n", - size, len, xlen); + size, frame.length, xlen); } } } @@ -777,7 +799,11 @@ if( in->bmiHeader.biPlanes != out->bmiHeader.biPlanes ) return ICERR_BADFORMAT; if( in->bmiHeader.biHeight != out->bmiHeader.biHeight ) - return ICERR_BADFORMAT; + { + if( in->bmiHeader.biHeight != -out->bmiHeader.biHeight ) + return ICERR_BADFORMAT; + TRACE("Detected inverted height for video output\n"); + } if( in->bmiHeader.biWidth != out->bmiHeader.biWidth ) return ICERR_BADFORMAT;
@@ -869,6 +895,7 @@ static LRESULT ICCVID_Decompress( ICCVID_Info *info, ICDECOMPRESS *icd, DWORD size ) { LONG width, height; + BOOL inverted;
TRACE("ICM_DECOMPRESS %p %p %d\n", info, icd, size);
@@ -882,9 +909,10 @@
width = icd->lpbiInput->biWidth; height = icd->lpbiInput->biHeight; + inverted = -icd->lpbiOutput->biHeight == height;
decode_cinepak(info->cvinfo, icd->lpInput, icd->lpbiInput->biSizeImage, - icd->lpOutput, width, height, info->bits_per_pixel); + icd->lpOutput, width, height, info->bits_per_pixel, inverted);
return ICERR_OK; } @@ -892,6 +920,7 @@ static LRESULT ICCVID_DecompressEx( ICCVID_Info *info, ICDECOMPRESSEX *icd, DWORD size ) { LONG width, height; + BOOL inverted;
TRACE("ICM_DECOMPRESSEX %p %p %d\n", info, icd, size);
@@ -907,9 +936,10 @@
width = icd->lpbiSrc->biWidth; height = icd->lpbiSrc->biHeight; + inverted = -icd->lpbiDst->biHeight == height;
decode_cinepak(info->cvinfo, icd->lpSrc, icd->lpbiSrc->biSizeImage, - icd->lpDst, width, height, info->bits_per_pixel); + icd->lpDst, width, height, info->bits_per_pixel, inverted);
return ICERR_OK; }
Modified: trunk/reactos/media/doc/README.WINE URL: http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=6... ============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Fri Nov 20 10:39:43 2015 @@ -74,7 +74,7 @@ reactos/dll/win32/hlink # Synced to WineStaging-1.7.47 reactos/dll/win32/hnetcfg # Synced to WineStaging-1.7.55 reactos/dll/win32/httpapi # Synced to WineStaging-1.7.47 -reactos/dll/win32/iccvid # Synced to WineStaging-1.7.47 +reactos/dll/win32/iccvid # Synced to WineStaging-1.7.55 reactos/dll/win32/icmp # Out of sync reactos/dll/win32/ieframe # Synced to WineStaging-1.7.55 reactos/dll/win32/imaadp32.acm # Synced to WineStaging-1.7.47