From 4dec9f3cb620098aba742c43b69031eb6b3f4591 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sun, 21 Jun 2009 12:02:40 +0000 Subject: == Sequencer == Very, very last minute patch for Blender on Windows systems: move blender's internal AVI reader the last try in the list of codecs, when opening movie files. Otherwise, it will fail on Movie Maker captured DV-AVI files. (isavi() seems to mistreat these files as RAW/MJPEG AVI and fails later on IMB_anim_absolute() ) --- source/blender/imbuf/intern/util.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source/blender/imbuf') diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index ffd5d3431af..26434583118 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -401,8 +401,6 @@ int imb_get_anim_type(char * name) { if (ib_stat(name,&st) == -1) return(0); if (((st.st_mode) & S_IFMT) != S_IFREG) return(0); - if (isavi(name)) return (ANIM_AVI); - if (ismovie(name)) return (ANIM_MOVIE); # ifdef WITH_QUICKTIME if (isqtime(name)) return (ANIM_QTIME); @@ -410,6 +408,7 @@ int imb_get_anim_type(char * name) { # ifdef WITH_FFMPEG if (isffmpeg(name)) return (ANIM_FFMPEG); # endif + if (isavi(name)) return (ANIM_AVI); #endif #ifdef WITH_REDCODE if (isredcode(name)) return (ANIM_REDCODE); -- cgit v1.2.3 From 431a388ae72bc21eff47ed616913e30920a2ce47 Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Fri, 24 Jul 2009 17:17:04 +0000 Subject: =?UTF-8?q?This=20is=20patch#=2019017=2016bit=20SGI=20image=20load?= =?UTF-8?q?ing=20submitted=20by=20Albertas=20Vy=C5=A1niauskas=20(thezbyg)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Improves SGI image support. Kent --- source/blender/imbuf/intern/iris.c | 310 ++++++++++++++++++++++++++++--------- 1 file changed, 240 insertions(+), 70 deletions(-) (limited to 'source/blender/imbuf') diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c index aa3015812fc..eba148cb8a5 100644 --- a/source/blender/imbuf/intern/iris.c +++ b/source/blender/imbuf/intern/iris.c @@ -104,7 +104,9 @@ static int writetab(FILE *outf, unsigned int *tab, int len); static void readtab(FILE *inf, unsigned int *tab, int len); static void expandrow(unsigned char *optr, unsigned char *iptr, int z); +static void expandrow2(float *optr, unsigned char *iptr, int z); static void interleaverow(unsigned char *lptr, unsigned char *cptr, int z, int n); +static void interleaverow2(float *lptr, unsigned char *cptr, int z, int n); static int compressrow(unsigned char *lbuf, unsigned char *rlebuf, int z, int cnt); static void lumrow(unsigned char *rgbptr, unsigned char *lumptr, int n); @@ -233,6 +235,7 @@ static void test_endian_zbuf(struct ImBuf *ibuf) struct ImBuf *imb_loadiris(unsigned char *mem, int flags) { unsigned int *base, *lptr = NULL; + float *fbase, *fptr = NULL; unsigned int *zbase, *zptr; unsigned char *rledat; unsigned int *starttab, *lengthtab; @@ -257,8 +260,8 @@ struct ImBuf *imb_loadiris(unsigned char *mem, int flags) rle = ISRLE(image.type); bpp = BPP(image.type); - if(bpp != 1 ) { - fprintf(stderr,"longimagedata: image must have 1 byte per pix chan\n"); + if(bpp != 1 && bpp != 2) { + fprintf(stderr,"longimagedata: image must have 1 or 2 byte per pix chan\n"); return(0); } @@ -273,6 +276,7 @@ struct ImBuf *imb_loadiris(unsigned char *mem, int flags) } if (rle) { + tablen = ysize*zsize*sizeof(int); starttab = (unsigned int *)malloc(tablen); lengthtab = (unsigned int *)malloc(tablen); @@ -280,7 +284,7 @@ struct ImBuf *imb_loadiris(unsigned char *mem, int flags) readtab(inf,starttab,tablen); readtab(inf,lengthtab,tablen); - + /* check data order */ cur = 0; badorder = 0; @@ -295,99 +299,200 @@ struct ImBuf *imb_loadiris(unsigned char *mem, int flags) if(badorder) break; } - - ibuf = IMB_allocImBuf(xsize, ysize, 8 * zsize, IB_rect, 0); - if (ibuf->depth > 32) ibuf->depth = 32; - base = ibuf->rect; - zbase = (unsigned int *)ibuf->zbuf; - - if (badorder) { - for(z=0; zdepth > 32) ibuf->depth = 32; + base = ibuf->rect; + zbase = (unsigned int *)ibuf->zbuf; + + if (badorder) { + for(z=0; zrect_float; + + if (badorder) { for(z=0; zdepth > 32) ibuf->depth = 32; + free(lengthtab); - base = ibuf->rect; - zbase = (unsigned int *)ibuf->zbuf; - - file_offset = 512; - rledat = file_data + file_offset; - - for(z = 0; z < zsize; z++) { + } else { + if (bpp == 1) { + + ibuf = IMB_allocImBuf(xsize, ysize, 8 * zsize, IB_rect, 0); + if (ibuf->depth > 32) ibuf->depth = 32; + + base = ibuf->rect; + zbase = (unsigned int *)ibuf->zbuf; - if(z<4) lptr = base; - else if(z<8) lptr= zbase; + file_offset = 512; + rledat = file_data + file_offset; - for(y = 0; y < ysize; y++) { + for(z = 0; z < zsize; z++) { + + if(z<4) lptr = base; + else if(z<8) lptr= zbase; + + for(y = 0; y < ysize; y++) { - interleaverow((uchar *)lptr, rledat, 3-z, xsize); - rledat += xsize; + interleaverow((uchar *)lptr, rledat, 3-z, xsize); + rledat += xsize; + + lptr += xsize; + } + } + + } else { /* bpp == 2 */ + + ibuf = IMB_allocImBuf(xsize, ysize, 32, (flags & IB_rect)|IB_rectfloat, 0); + + fbase = ibuf->rect_float; + + file_offset = 512; + rledat = file_data + file_offset; + + for(z = 0; z < zsize; z++) { + + fptr = fbase; - lptr += xsize; + for(y = 0; y < ysize; y++) { + + interleaverow2(fptr, rledat, 3-z, xsize); + rledat += xsize * 2; + + fptr += xsize * 4; + } } + } } - if (image.zsize == 1){ - rect = (uchar *) ibuf->rect; - for (x = ibuf->x * ibuf->y; x > 0; x--) { - rect[0] = 255; - rect[1] = rect[2] = rect[3]; - rect += 4; + + if (bpp == 1) { + + if (image.zsize == 1){ + rect = (uchar *) ibuf->rect; + for (x = ibuf->x * ibuf->y; x > 0; x--) { + rect[0] = 255; + rect[1] = rect[2] = rect[3]; + rect += 4; + } + } else if (image.zsize == 2){ + /* grayscale with alpha */ + rect = (uchar *) ibuf->rect; + for (x = ibuf->x * ibuf->y; x > 0; x--) { + rect[0] = rect[2]; + rect[1] = rect[2] = rect[3]; + rect += 4; + } + } else if (image.zsize == 3){ + /* add alpha */ + rect = (uchar *) ibuf->rect; + for (x = ibuf->x * ibuf->y; x > 0; x--) { + rect[0] = 255; + rect += 4; + } } - } else if (image.zsize == 2){ - /* grayscale with alpha */ - rect = (uchar *) ibuf->rect; - for (x = ibuf->x * ibuf->y; x > 0; x--) { - rect[0] = rect[2]; - rect[1] = rect[2] = rect[3]; - rect += 4; + + } else { /* bpp == 2 */ + + if (image.zsize == 1){ + fbase = ibuf->rect_float; + for (x = ibuf->x * ibuf->y; x > 0; x--) { + fbase[0] = 1; + fbase[1] = rect[2] = rect[3]; + fbase += 4; + } + } else if (image.zsize == 2){ + /* grayscale with alpha */ + fbase = ibuf->rect_float; + for (x = ibuf->x * ibuf->y; x > 0; x--) { + fbase[0] = fbase[2]; + fbase[1] = fbase[2] = fbase[3]; + fbase += 4; + } + } else if (image.zsize == 3){ + /* add alpha */ + fbase = ibuf->rect_float; + for (x = ibuf->x * ibuf->y; x > 0; x--) { + fbase[0] = 1; + fbase += 4; + } } - } else if (image.zsize == 3){ - /* add alpha */ - rect = (uchar *) ibuf->rect; - for (x = ibuf->x * ibuf->y; x > 0; x--) { - rect[0] = 255; - rect += 4; + + if (flags & IB_rect) { + IMB_rect_from_float(ibuf); } + } - + ibuf->ftype = IMAGIC; if (flags & IB_ttob) IMB_flipy(ibuf); @@ -412,6 +517,71 @@ static void interleaverow(unsigned char *lptr, unsigned char *cptr, int z, int n } } +static void interleaverow2(float *lptr, unsigned char *cptr, int z, int n) +{ + lptr += z; + while(n--) { + *lptr = ((cptr[0]<<8) | (cptr[1]<<0)) / (float)0xFFFF; + cptr += 2; + lptr += 4; + } +} + +static void expandrow2(float *optr, unsigned char *iptr, int z) +{ + unsigned short pixel, count; + float pixel_f; + + optr += z; + while(1) { + pixel = (iptr[0]<<8) | (iptr[1]<<0); + iptr += 2; + + if ( !(count = (pixel & 0x7f)) ) + return; + if(pixel & 0x80) { + while(count>=8) { + optr[0*4] = ((iptr[0]<<8) | (iptr[1]<<0))/(float)0xFFFF; + optr[1*4] = ((iptr[2]<<8) | (iptr[3]<<0))/(float)0xFFFF; + optr[2*4] = ((iptr[4]<<8) | (iptr[5]<<0))/(float)0xFFFF; + optr[3*4] = ((iptr[6]<<8) | (iptr[7]<<0))/(float)0xFFFF; + optr[4*4] = ((iptr[8]<<8) | (iptr[9]<<0))/(float)0xFFFF; + optr[5*4] = ((iptr[10]<<8) | (iptr[11]<<0))/(float)0xFFFF; + optr[6*4] = ((iptr[12]<<8) | (iptr[13]<<0))/(float)0xFFFF; + optr[7*4] = ((iptr[14]<<8) | (iptr[15]<<0))/(float)0xFFFF; + optr += 8*4; + iptr += 8*2; + count -= 8; + } + while(count--) { + *optr = ((iptr[0]<<8) | (iptr[1]<<0))/(float)0xFFFF; + iptr+=2; + optr+=4; + } + } else { + pixel_f = ((iptr[0]<<8) | (iptr[1]<<0))/(float)0xFFFF; + iptr += 2; + + while(count>=8) { + optr[0*4] = pixel_f; + optr[1*4] = pixel_f; + optr[2*4] = pixel_f; + optr[3*4] = pixel_f; + optr[4*4] = pixel_f; + optr[5*4] = pixel_f; + optr[6*4] = pixel_f; + optr[7*4] = pixel_f; + optr += 8*4; + count -= 8; + } + while(count--) { + *optr = pixel_f; + optr+=4; + } + } + } +} + static void expandrow(unsigned char *optr, unsigned char *iptr, int z) { unsigned char pixel, count; -- cgit v1.2.3 From 88097e99099b8bea9c9e435d7c728afaa8bc24ff Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 25 Jul 2009 19:34:38 +0000 Subject: - BGE Python API converting a mesh from a python arg was broken but happened to work if the uninitialized pointer was not NULL. - iris.c - looks like a copy/paste error, was using rect where it could not have been initialized. --- source/blender/imbuf/intern/iris.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/imbuf') diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c index eba148cb8a5..7b8c383ddb9 100644 --- a/source/blender/imbuf/intern/iris.c +++ b/source/blender/imbuf/intern/iris.c @@ -245,7 +245,6 @@ struct ImBuf *imb_loadiris(unsigned char *mem, int flags) int xsize, ysize, zsize; int bpp, rle, cur, badorder; ImBuf * ibuf; - uchar * rect; /*printf("new iris\n");*/ @@ -436,6 +435,7 @@ struct ImBuf *imb_loadiris(unsigned char *mem, int flags) if (bpp == 1) { + uchar * rect; if (image.zsize == 1){ rect = (uchar *) ibuf->rect; @@ -467,7 +467,7 @@ struct ImBuf *imb_loadiris(unsigned char *mem, int flags) fbase = ibuf->rect_float; for (x = ibuf->x * ibuf->y; x > 0; x--) { fbase[0] = 1; - fbase[1] = rect[2] = rect[3]; + fbase[1] = fbase[2] = fbase[3]; fbase += 4; } } else if (image.zsize == 2){ -- cgit v1.2.3