Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r--source/blender/imbuf/CMakeLists.txt25
-rw-r--r--source/blender/imbuf/IMB_imbuf_types.h12
-rw-r--r--source/blender/imbuf/Makefile2
-rw-r--r--source/blender/imbuf/SConscript6
-rw-r--r--source/blender/imbuf/intern/Makefile13
-rw-r--r--source/blender/imbuf/intern/allocimbuf.c3
-rw-r--r--source/blender/imbuf/intern/anim.c292
-rw-r--r--source/blender/imbuf/intern/cache.c2
-rw-r--r--source/blender/imbuf/intern/cineon/CMakeLists.txt1
-rw-r--r--source/blender/imbuf/intern/cineon/Makefile2
-rw-r--r--source/blender/imbuf/intern/dds/CMakeLists.txt5
-rw-r--r--source/blender/imbuf/intern/dds/Makefile2
-rw-r--r--source/blender/imbuf/intern/filetype.c4
-rw-r--r--source/blender/imbuf/intern/filter.c1
-rw-r--r--source/blender/imbuf/intern/imageprocess.c8
-rw-r--r--source/blender/imbuf/intern/imbuf.h2
-rw-r--r--source/blender/imbuf/intern/iris.c3
-rw-r--r--source/blender/imbuf/intern/jp2.c4
-rw-r--r--source/blender/imbuf/intern/jpeg.c5
-rw-r--r--source/blender/imbuf/intern/openexr/CMakeLists.txt5
-rw-r--r--source/blender/imbuf/intern/openexr/Makefile2
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.cpp4
-rw-r--r--source/blender/imbuf/intern/png.c10
-rw-r--r--source/blender/imbuf/intern/radiance_hdr.c6
-rw-r--r--source/blender/imbuf/intern/rotate.c3
-rw-r--r--source/blender/imbuf/intern/scaling.c1
-rw-r--r--source/blender/imbuf/intern/targa.c1
-rw-r--r--source/blender/imbuf/intern/thumbs.c13
-rw-r--r--source/blender/imbuf/intern/thumbs_blend.c92
-rw-r--r--source/blender/imbuf/intern/tiff.c125
-rw-r--r--source/blender/imbuf/intern/util.c154
31 files changed, 417 insertions, 391 deletions
diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt
index 98cb3dcefd9..49886bdc46f 100644
--- a/source/blender/imbuf/CMakeLists.txt
+++ b/source/blender/imbuf/CMakeLists.txt
@@ -44,19 +44,19 @@ IF(WIN32)
SET(INC ${INC} ${PTHREADS_INC})
ENDIF(WIN32)
-IF(WITH_OPENEXR)
+IF(WITH_IMAGE_OPENEXR)
ADD_DEFINITIONS(-DWITH_OPENEXR)
-ENDIF(WITH_OPENEXR)
+ENDIF(WITH_IMAGE_OPENEXR)
-IF(WITH_TIFF)
+IF(WITH_IMAGE_TIFF)
SET(INC ${INC} ${TIFF_INCLUDE_DIR})
ADD_DEFINITIONS(-DWITH_TIFF)
-ENDIF(WITH_TIFF)
+ENDIF(WITH_IMAGE_TIFF)
-IF(WITH_OPENJPEG)
+IF(WITH_IMAGE_OPENJPEG)
SET(INC ${INC} ${OPENJPEG_INC})
ADD_DEFINITIONS(-DWITH_OPENJPEG)
-ENDIF(WITH_OPENJPEG)
+ENDIF(WITH_IMAGE_OPENJPEG)
IF(WITH_QUICKTIME)
SET(INC ${INC} ../quicktime ${QUICKTIME_INC})
@@ -68,9 +68,16 @@ IF(WITH_FFMPEG)
ADD_DEFINITIONS(-DWITH_FFMPEG)
ENDIF(WITH_FFMPEG)
-IF(WITH_DDS)
+IF(WITH_IMAGE_DDS)
ADD_DEFINITIONS(-DWITH_DDS)
-ENDIF(WITH_DDS)
+ENDIF(WITH_IMAGE_DDS)
+
+IF(WITH_IMAGE_CINEON)
+ ADD_DEFINITIONS(-DWITH_CINEON)
+ENDIF(WITH_IMAGE_CINEON)
+
+IF(WITH_IMAGE_HDR)
+ ADD_DEFINITIONS(-DWITH_HDR)
+ENDIF(WITH_IMAGE_HDR)
BLENDERLIB(bf_imbuf "${SRC}" "${INC}")
-#env.BlenderLib ( libname = 'bf_imbuf', sources = sources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [80, 40] )
diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h
index e0dcc344016..203a7268581 100644
--- a/source/blender/imbuf/IMB_imbuf_types.h
+++ b/source/blender/imbuf/IMB_imbuf_types.h
@@ -173,16 +173,22 @@ typedef struct ImBuf {
#define QUICKTIME (1 << 25)
#endif
+#ifdef WITH_HDR
#define RADHDR (1 << 24)
+#endif
+#ifdef WITH_TIFF
#define TIF (1 << 23)
#define TIF_16BIT (1 << 8 )
+#endif
#define OPENEXR (1 << 22)
#define OPENEXR_HALF (1 << 8 )
#define OPENEXR_COMPRESS (7)
+#ifdef WITH_CINEON
#define CINEON (1 << 21)
#define DPX (1 << 20)
+#endif
#ifdef WITH_DDS
#define DDS (1 << 19)
@@ -216,5 +222,9 @@ typedef struct ImBuf {
#define IB_PROFILE_SRGB 2
#define IB_PROFILE_CUSTOM 3
-#endif
+extern const char *imb_ext_image[];
+extern const char *imb_ext_image_qt[];
+extern const char *imb_ext_movie[];
+extern const char *imb_ext_audio[];
+#endif
diff --git a/source/blender/imbuf/Makefile b/source/blender/imbuf/Makefile
index cc9b56b3cd8..78eea89173f 100644
--- a/source/blender/imbuf/Makefile
+++ b/source/blender/imbuf/Makefile
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
# All rights reserved.
diff --git a/source/blender/imbuf/SConscript b/source/blender/imbuf/SConscript
index 439cdecdf5b..6b3360a16c5 100644
--- a/source/blender/imbuf/SConscript
+++ b/source/blender/imbuf/SConscript
@@ -26,6 +26,12 @@ if env['WITH_BF_TIFF']:
if env['WITH_BF_DDS']:
defs.append('WITH_DDS')
+if env['WITH_BF_CINEON']:
+ defs.append('WITH_CINEON')
+
+if env['WITH_BF_HDR']:
+ defs.append('WITH_HDR')
+
if env['WITH_BF_FFMPEG']:
defs.append('WITH_FFMPEG')
incs += ' ' + env['BF_FFMPEG_INC']
diff --git a/source/blender/imbuf/intern/Makefile b/source/blender/imbuf/intern/Makefile
index 5f8029ddf72..8e7272100b9 100644
--- a/source/blender/imbuf/intern/Makefile
+++ b/source/blender/imbuf/intern/Makefile
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
# All rights reserved.
@@ -36,7 +36,12 @@ include nan_subdirs.mk
include nan_compile.mk
include nan_definitions.mk
-DIRS = cineon
+DIRS =
+
+ifeq ($(WITH_CINEON), true)
+ DIRS += cineon
+ CPPFLAGS += -DWITH_CINEON
+endif
ifeq ($(WITH_OPENEXR), true)
DIRS += openexr
@@ -89,3 +94,7 @@ ifeq ($(WITH_TIFF), true)
CPPFLAGS += -DWITH_TIFF
CPPFLAGS += -I$(NAN_TIFF)/include
endif
+
+ifeq ($(WITH_HDR), true)
+ CPPFLAGS += -DWITH_HDR
+endif
diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c
index 606913dd590..3f440c0bf6f 100644
--- a/source/blender/imbuf/intern/allocimbuf.c
+++ b/source/blender/imbuf/intern/allocimbuf.c
@@ -42,6 +42,7 @@
#include "imbuf.h"
#include "MEM_CacheLimiterC-Api.h"
+#include "MEM_guardedalloc.h"
void imb_freemipmapImBuf(ImBuf *ibuf)
{
@@ -77,7 +78,7 @@ void imb_freerectImBuf(ImBuf *ibuf)
{
if(ibuf==NULL) return;
- if(ibuf->crect && ibuf->crect != ibuf->rect)
+ if(ibuf->crect)
MEM_freeN(ibuf->crect);
if(ibuf->rect && (ibuf->mall & IB_rect))
diff --git a/source/blender/imbuf/intern/anim.c b/source/blender/imbuf/intern/anim.c
index bfc3433875d..096ed499f85 100644
--- a/source/blender/imbuf/intern/anim.c
+++ b/source/blender/imbuf/intern/anim.c
@@ -60,6 +60,8 @@
#include "BLI_blenlib.h" /* BLI_remlink BLI_filesize BLI_addtail
BLI_countlist BLI_stringdec */
+#include "MEM_guardedalloc.h"
+
#include "DNA_userdef_types.h"
#include "BKE_global.h"
#include "BKE_depsgraph.h"
@@ -685,6 +687,116 @@ static int startffmpeg(struct anim * anim) {
return (0);
}
+static void ffmpeg_postprocess(struct anim * anim, ImBuf * ibuf,
+ int * filter_y)
+{
+ AVFrame * input = anim->pFrame;
+
+ /* This means the data wasnt read properly,
+ this check stops crashing */
+ if (input->data[0]==0 && input->data[1]==0
+ && input->data[2]==0 && input->data[3]==0){
+ fprintf(stderr, "ffmpeg_fetchibuf: "
+ "data not read properly...\n");
+ return;
+ }
+
+ if (anim->ib_flags & IB_animdeinterlace) {
+ if (avpicture_deinterlace(
+ (AVPicture*)
+ anim->pFrameDeinterlaced,
+ (const AVPicture*)
+ anim->pFrame,
+ anim->pCodecCtx->pix_fmt,
+ anim->pCodecCtx->width,
+ anim->pCodecCtx->height)
+ < 0) {
+ *filter_y = 1;
+ } else {
+ input = anim->pFrameDeinterlaced;
+ }
+ }
+
+ if (ENDIAN_ORDER == B_ENDIAN) {
+ int * dstStride = anim->pFrameRGB->linesize;
+ uint8_t** dst = anim->pFrameRGB->data;
+ int dstStride2[4] = { dstStride[0], 0, 0, 0 };
+ uint8_t* dst2[4] = { dst[0], 0, 0, 0 };
+ int x,y,h,w;
+ unsigned char* bottom;
+ unsigned char* top;
+
+ sws_scale(anim->img_convert_ctx,
+ (const uint8_t * const *)input->data,
+ input->linesize,
+ 0,
+ anim->pCodecCtx->height,
+ dst2,
+ dstStride2);
+
+ /* workaround: sws_scale bug
+ sets alpha = 0 and compensate
+ for altivec-bugs and flipy... */
+
+ bottom = (unsigned char*) ibuf->rect;
+ top = bottom + ibuf->x * (ibuf->y-1) * 4;
+
+ h = (ibuf->y + 1) / 2;
+ w = ibuf->x;
+
+ for (y = 0; y < h; y++) {
+ unsigned char tmp[4];
+ unsigned int * tmp_l =
+ (unsigned int*) tmp;
+ tmp[3] = 0xff;
+
+ for (x = 0; x < w; x++) {
+ tmp[0] = bottom[0];
+ tmp[1] = bottom[1];
+ tmp[2] = bottom[2];
+
+ bottom[0] = top[0];
+ bottom[1] = top[1];
+ bottom[2] = top[2];
+ bottom[3] = 0xff;
+
+ *(unsigned int*) top = *tmp_l;
+
+ bottom +=4;
+ top += 4;
+ }
+ top -= 8 * w;
+ }
+ } else {
+ int * dstStride = anim->pFrameRGB->linesize;
+ uint8_t** dst = anim->pFrameRGB->data;
+ int dstStride2[4] = { -dstStride[0], 0, 0, 0 };
+ uint8_t* dst2[4] = { dst[0] + (anim->y - 1)*dstStride[0],
+ 0, 0, 0 };
+ int i;
+ unsigned char* r;
+
+ sws_scale(anim->img_convert_ctx,
+ (const uint8_t * const *)input->data,
+ input->linesize,
+ 0,
+ anim->pCodecCtx->height,
+ dst2,
+ dstStride2);
+
+ r = (unsigned char*) ibuf->rect;
+
+ /* workaround sws_scale bug: older version of
+ sws_scale set alpha = 0... */
+ if (r[3] == 0) {
+ for (i = 0; i < ibuf->x * ibuf->y; i++) {
+ r[3] = 0xff;
+ r += 4;
+ }
+ }
+ }
+}
+
static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) {
ImBuf * ibuf;
int frameFinished;
@@ -692,6 +804,8 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) {
int64_t pts_to_search = 0;
int pos_found = 1;
int filter_y = 0;
+ int seek_by_bytes= 0;
+ int preseek_count = 0;
if (anim == 0) return (0);
@@ -724,6 +838,8 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) {
}
}
+ seek_by_bytes = !!(anim->pFormatCtx->iformat->flags & AVFMT_TS_DISCONT);
+
if (position != anim->curposition + 1) {
#ifdef FFMPEG_OLD_FRAME_RATE
double frame_rate =
@@ -737,21 +853,41 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) {
double time_base =
av_q2d(anim->pFormatCtx->streams[anim->videoStream]
->time_base);
- long long pos = (long long) (position - anim->preseek)
- * AV_TIME_BASE / frame_rate;
+ long long pos;
long long st_time = anim->pFormatCtx
->streams[anim->videoStream]->start_time;
+ int ret;
- if (pos < 0) {
- pos = 0;
- }
+ if (seek_by_bytes) {
+ pos = position - anim->preseek;
+ if (pos < 0) {
+ pos = 0;
+ }
+ preseek_count = position - pos;
- if (st_time != AV_NOPTS_VALUE) {
- pos += st_time * AV_TIME_BASE * time_base;
+ pos *= anim->pFormatCtx->bit_rate / frame_rate;
+ pos /= 8;
+ } else {
+ pos = (long long) (position - anim->preseek)
+ * AV_TIME_BASE / frame_rate;
+ if (pos < 0) {
+ pos = 0;
+ }
+
+ if (st_time != AV_NOPTS_VALUE) {
+ pos += st_time * AV_TIME_BASE * time_base;
+ }
}
- av_seek_frame(anim->pFormatCtx, -1,
- pos, AVSEEK_FLAG_BACKWARD);
+ ret = av_seek_frame(anim->pFormatCtx, -1,
+ pos,
+ AVSEEK_FLAG_BACKWARD | (
+ seek_by_bytes
+ ? AVSEEK_FLAG_ANY
+ | AVSEEK_FLAG_BYTE : 0));
+ if (ret < 0) {
+ fprintf(stderr, "error while seeking: %d\n", ret);
+ }
pts_to_search = (long long)
(((double) position) / time_base / frame_rate);
@@ -769,132 +905,28 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) {
anim->pFrame, &frameFinished,
packet.data, packet.size);
- if (frameFinished && !pos_found) {
- if (packet.dts >= pts_to_search) {
- pos_found = 1;
- anim->curposition = position;
- }
- }
-
- if(frameFinished && pos_found == 1) {
- AVFrame * input = anim->pFrame;
-
- /* This means the data wasnt read properly,
- this check stops crashing */
- if (input->data[0]==0 && input->data[1]==0
- && input->data[2]==0 && input->data[3]==0){
- av_free_packet(&packet);
- break;
- }
-
- if (anim->ib_flags & IB_animdeinterlace) {
- if (avpicture_deinterlace(
- (AVPicture*)
- anim->pFrameDeinterlaced,
- (const AVPicture*)
- anim->pFrame,
- anim->pCodecCtx->pix_fmt,
- anim->pCodecCtx->width,
- anim->pCodecCtx->height)
- < 0) {
- filter_y = 1;
- } else {
- input = anim->pFrameDeinterlaced;
- }
- }
+ if (seek_by_bytes && preseek_count > 0) {
+ preseek_count--;
+ }
- if (ENDIAN_ORDER == B_ENDIAN) {
- int * dstStride
- = anim->pFrameRGB->linesize;
- uint8_t** dst = anim->pFrameRGB->data;
- int dstStride2[4]
- = { dstStride[0], 0, 0, 0 };
- uint8_t* dst2[4]= {
- dst[0], 0, 0, 0 };
- int x,y,h,w;
- unsigned char* bottom;
- unsigned char* top;
-
- sws_scale(anim->img_convert_ctx,
- (const uint8_t * const *)input->data,
- input->linesize,
- 0,
- anim->pCodecCtx->height,
- dst2,
- dstStride2);
-
- /* workaround: sws_scale
- sets alpha = 0 and compensate
- for altivec-bugs and flipy... */
-
- bottom = (unsigned char*) ibuf->rect;
- top = bottom
- + ibuf->x * (ibuf->y-1) * 4;
-
- h = (ibuf->y + 1) / 2;
- w = ibuf->x;
-
- for (y = 0; y < h; y++) {
- unsigned char tmp[4];
- unsigned int * tmp_l =
- (unsigned int*) tmp;
- tmp[3] = 0xff;
-
- for (x = 0; x < w; x++) {
- tmp[0] = bottom[0];
- tmp[1] = bottom[1];
- tmp[2] = bottom[2];
-
- bottom[0] = top[0];
- bottom[1] = top[1];
- bottom[2] = top[2];
- bottom[3] = 0xff;
-
- *(unsigned int*) top
- = *tmp_l;
-
- bottom +=4;
- top += 4;
- }
- top -= 8 * w;
+ if (frameFinished && !pos_found) {
+ if (seek_by_bytes) {
+ if (!preseek_count) {
+ pos_found = 1;
+ anim->curposition = position;
}
-
- av_free_packet(&packet);
- break;
} else {
- int * dstStride
- = anim->pFrameRGB->linesize;
- uint8_t** dst = anim->pFrameRGB->data;
- int dstStride2[4]
- = { -dstStride[0], 0, 0, 0 };
- uint8_t* dst2[4]= {
- dst[0]
- + (anim->y - 1)*dstStride[0],
- 0, 0, 0 };
- int i;
- unsigned char* r;
-
- sws_scale(anim->img_convert_ctx,
- (const uint8_t * const *)input->data,
- input->linesize,
- 0,
- anim->pCodecCtx->height,
- dst2,
- dstStride2);
-
- /* workaround: sws_scale
- sets alpha = 0... */
-
- r = (unsigned char*) ibuf->rect;
-
- for (i = 0; i < ibuf->x * ibuf->y;i++){
- r[3] = 0xff;
- r+=4;
+ if (packet.dts >= pts_to_search) {
+ pos_found = 1;
+ anim->curposition = position;
}
-
- av_free_packet(&packet);
- break;
}
+ }
+
+ if(frameFinished && pos_found == 1) {
+ ffmpeg_postprocess(anim, ibuf, &filter_y);
+ av_free_packet(&packet);
+ break;
}
}
diff --git a/source/blender/imbuf/intern/cache.c b/source/blender/imbuf/intern/cache.c
index d15826df2f0..77e01d8ebef 100644
--- a/source/blender/imbuf/intern/cache.c
+++ b/source/blender/imbuf/intern/cache.c
@@ -20,6 +20,8 @@
* ***** END GPL LICENSE BLOCK *****
*/
+#include "MEM_guardedalloc.h"
+
#include "BLI_ghash.h"
#include "BLI_listbase.h"
#include "BLI_memarena.h"
diff --git a/source/blender/imbuf/intern/cineon/CMakeLists.txt b/source/blender/imbuf/intern/cineon/CMakeLists.txt
index 588be3305d9..cd887b6fc4e 100644
--- a/source/blender/imbuf/intern/cineon/CMakeLists.txt
+++ b/source/blender/imbuf/intern/cineon/CMakeLists.txt
@@ -38,4 +38,3 @@ SET(INC
)
BLENDERLIB(bf_cineon "${SRC}" "${INC}")
-#env.BlenderLib ('bf_cineon', source_files, incs, defs, libtype=['core','player'], priority = [90, 200])
diff --git a/source/blender/imbuf/intern/cineon/Makefile b/source/blender/imbuf/intern/cineon/Makefile
index 99a9a5dbd46..6e940d530a9 100644
--- a/source/blender/imbuf/intern/cineon/Makefile
+++ b/source/blender/imbuf/intern/cineon/Makefile
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
# All rights reserved.
diff --git a/source/blender/imbuf/intern/dds/CMakeLists.txt b/source/blender/imbuf/intern/dds/CMakeLists.txt
index 364dd41e744..376dd3d61f4 100644
--- a/source/blender/imbuf/intern/dds/CMakeLists.txt
+++ b/source/blender/imbuf/intern/dds/CMakeLists.txt
@@ -37,9 +37,8 @@ SET(INC
../../../../../intern/guardedalloc
)
-if(WITH_DDS)
+if(WITH_IMAGE_DDS)
ADD_DEFINITIONS(-DWITH_DDS)
-ENDIF(WITH_DDS)
+ENDIF(WITH_IMAGE_DDS)
BLENDERLIB(bf_dds "${SRC}" "${INC}")
-#env.BlenderLib ('bf_dds', source_files, incs, defs, libtype=['core','player'], priority = [90, 200])
diff --git a/source/blender/imbuf/intern/dds/Makefile b/source/blender/imbuf/intern/dds/Makefile
index e14f9320d19..d4f04382899 100644
--- a/source/blender/imbuf/intern/dds/Makefile
+++ b/source/blender/imbuf/intern/dds/Makefile
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
# All rights reserved.
diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c
index c2140e12013..db2eef759dc 100644
--- a/source/blender/imbuf/intern/filetype.c
+++ b/source/blender/imbuf/intern/filetype.c
@@ -60,14 +60,18 @@ ImFileType IMB_FILE_TYPES[]= {
{NULL, NULL, imb_is_a_png, imb_ftype_default, imb_loadpng, imb_savepng, NULL, 0, PNG},
{NULL, NULL, imb_is_a_bmp, imb_ftype_default, imb_bmp_decode, imb_savebmp, NULL, 0, BMP},
{NULL, NULL, imb_is_a_targa, imb_ftype_default, imb_loadtarga, imb_savetarga, NULL, 0, TGA},
+#ifdef WITH_CINEON
{NULL, NULL, imb_is_dpx, imb_ftype_default, imb_loaddpx, imb_save_dpx, NULL, IM_FTYPE_FLOAT, DPX},
{NULL, NULL, imb_is_cineon, imb_ftype_default, imb_loadcineon, imb_savecineon, NULL, IM_FTYPE_FLOAT, CINEON},
+#endif
#ifdef WITH_TIFF
{imb_inittiff, NULL, imb_is_a_tiff, imb_ftype_default, imb_loadtiff, imb_savetiff, imb_loadtiletiff, 0, TIF},
#elif defined(__APPLE__) && defined(IMBUF_COCOA)
{NULL, NULL, imb_is_a_cocoa, imb_ftype_cocoa, imb_imb_cocoaLoadImage, imb_savecocoa, NULL, 0, TIF},
#endif
+#ifdef WITH_HDR
{NULL, NULL, imb_is_a_hdr, imb_ftype_default, imb_loadhdr, imb_savehdr, NULL, IM_FTYPE_FLOAT, RADHDR},
+#endif
#ifdef WITH_OPENEXR
{NULL, NULL, imb_is_a_openexr, imb_ftype_default, imb_load_openexr, imb_save_openexr, NULL, IM_FTYPE_FLOAT, OPENEXR},
#endif
diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c
index 3ee05da15c9..3cc266e460e 100644
--- a/source/blender/imbuf/intern/filter.c
+++ b/source/blender/imbuf/intern/filter.c
@@ -30,6 +30,7 @@
*/
#include "BKE_utildefines.h"
+#include "MEM_guardedalloc.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c
index 4450394e9e6..8fa76fa4502 100644
--- a/source/blender/imbuf/intern/imageprocess.c
+++ b/source/blender/imbuf/intern/imageprocess.c
@@ -129,7 +129,7 @@ void bicubic_interpolation_color(struct ImBuf *in, unsigned char *outI, float *o
unsigned char *dataI;
float a,b,w,wx,wy[4], outR,outG,outB,outA,*dataF;
- /* ImBuf in must have a valid rect or rect_float, assume this is alredy checked */
+ /* ImBuf in must have a valid rect or rect_float, assume this is already checked */
i= (int)floor(u);
j= (int)floor(v);
@@ -245,7 +245,7 @@ void bilinear_interpolation_color(struct ImBuf *in, unsigned char *outI, float *
int y1, y2, x1, x2;
- /* ImBuf in must have a valid rect or rect_float, assume this is alredy checked */
+ /* ImBuf in must have a valid rect or rect_float, assume this is already checked */
x1= (int)floor(u);
x2= (int)ceil(u);
@@ -319,7 +319,7 @@ void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char *outI, fl
int y1, y2, x1, x2;
- /* ImBuf in must have a valid rect or rect_float, assume this is alredy checked */
+ /* ImBuf in must have a valid rect or rect_float, assume this is already checked */
x1= (int)floor(u);
x2= (int)ceil(u);
@@ -393,7 +393,7 @@ void neareast_interpolation_color(struct ImBuf *in, unsigned char *outI, float *
unsigned char *dataI;
int y1, x1;
- /* ImBuf in must have a valid rect or rect_float, assume this is alredy checked */
+ /* ImBuf in must have a valid rect or rect_float, assume this is already checked */
x1= (int)(u);
y1= (int)(v);
diff --git a/source/blender/imbuf/intern/imbuf.h b/source/blender/imbuf/intern/imbuf.h
index 047795355b3..1e2f3ec461a 100644
--- a/source/blender/imbuf/intern/imbuf.h
+++ b/source/blender/imbuf/intern/imbuf.h
@@ -51,8 +51,6 @@
#include <sys/mman.h>
#endif
-#include "MEM_guardedalloc.h"
-
#if !defined(WIN32)
#define O_BINARY 0
#endif
diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c
index dc9c7a1dc3b..c676c401ccd 100644
--- a/source/blender/imbuf/intern/iris.c
+++ b/source/blender/imbuf/intern/iris.c
@@ -30,7 +30,10 @@
*/
#include <string.h>
+
#include "BLI_blenlib.h"
+#include "MEM_guardedalloc.h"
+
#include "imbuf.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c
index a76c6e780ca..558eaedf8b2 100644
--- a/source/blender/imbuf/intern/jp2.c
+++ b/source/blender/imbuf/intern/jp2.c
@@ -23,6 +23,8 @@
#ifdef WITH_OPENJPEG
+#include "MEM_guardedalloc.h"
+
#include "BLI_blenlib.h"
#include "BLI_math.h"
@@ -287,7 +289,7 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, int size, int flags)
/*
-2048x1080 (2K) at 24 fps or 48 fps, or 4096x2160 (4K) at 24 fps; 3×12 bits per pixel, XYZ color space
+2048x1080 (2K) at 24 fps or 48 fps, or 4096x2160 (4K) at 24 fps; 3x12 bits per pixel, XYZ color space
* In 2K, for Scope (2.39:1) presentation 2048x858 pixels of the imager is used
* In 2K, for Flat (1.85:1) presentation 1998x1080 pixels of the imager is used
diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c
index 3803aa9a8b2..2bae7228220 100644
--- a/source/blender/imbuf/intern/jpeg.c
+++ b/source/blender/imbuf/intern/jpeg.c
@@ -156,7 +156,10 @@ static void skip_input_data(j_decompress_ptr cinfo, long num_bytes)
{
my_src_ptr src = (my_src_ptr) cinfo->src;
- src->pub.next_input_byte = src->pub.next_input_byte + num_bytes;
+ if(num_bytes > 0) {
+ src->pub.next_input_byte = src->pub.next_input_byte + num_bytes;
+ src->pub.bytes_in_buffer = src->pub.bytes_in_buffer - num_bytes;
+ }
}
diff --git a/source/blender/imbuf/intern/openexr/CMakeLists.txt b/source/blender/imbuf/intern/openexr/CMakeLists.txt
index 7dc295a8aae..cfc977ff155 100644
--- a/source/blender/imbuf/intern/openexr/CMakeLists.txt
+++ b/source/blender/imbuf/intern/openexr/CMakeLists.txt
@@ -38,9 +38,8 @@ SET(INC
${OPENEXR_INC}
)
-IF(WITH_OPENEXR)
+IF(WITH_IMAGE_OPENEXR)
ADD_DEFINITIONS(-DWITH_OPENEXR)
-ENDIF(WITH_OPENEXR)
+ENDIF(WITH_IMAGE_OPENEXR)
BLENDERLIB(bf_openexr "${SRC}" "${INC}")
-#env.BlenderLib ('bf_openexr', source_files, incs, defs, libtype=['core','player'], priority = [90, 200])
diff --git a/source/blender/imbuf/intern/openexr/Makefile b/source/blender/imbuf/intern/openexr/Makefile
index 083089b11d5..820b2aeb003 100644
--- a/source/blender/imbuf/intern/openexr/Makefile
+++ b/source/blender/imbuf/intern/openexr/Makefile
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
# All rights reserved.
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index a0969979817..9b68e0e45eb 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -267,6 +267,8 @@ static int imb_save_openexr_half(struct ImBuf *ibuf, char *name, int flags)
if(ibuf->profile == IB_PROFILE_LINEAR_RGB) {
for (int i = ibuf->y-1; i >= 0; i--)
{
+ from= (unsigned char *)ibuf->rect + channels*i*width;
+
for (int j = ibuf->x; j > 0; j--)
{
to->r = (float)(from[0])/255.0;
@@ -280,6 +282,8 @@ static int imb_save_openexr_half(struct ImBuf *ibuf, char *name, int flags)
else {
for (int i = ibuf->y-1; i >= 0; i--)
{
+ from= (unsigned char *)ibuf->rect + channels*i*width;
+
for (int j = ibuf->x; j > 0; j--)
{
to->r = srgb_to_linearrgb((float)from[0] / 255.0);
diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c
index 68a3324816c..6344b227174 100644
--- a/source/blender/imbuf/intern/png.c
+++ b/source/blender/imbuf/intern/png.c
@@ -31,6 +31,7 @@
#include "png.h"
#include "BLI_blenlib.h"
+#include "MEM_guardedalloc.h"
#include "imbuf.h"
@@ -103,6 +104,11 @@ int imb_savepng(struct ImBuf *ibuf, char *name, int flags)
int i, bytesperpixel, color_type = PNG_COLOR_TYPE_GRAY;
FILE *fp = 0;
+ /* use the jpeg quality setting for compression */
+ int compression;
+ compression= (int)(((float)(ibuf->ftype & 0xff) / 11.1111f));
+ compression= compression < 0 ? 0 : (compression > 9 ? 9 : compression);
+
bytesperpixel = (ibuf->depth + 7) >> 3;
if ((bytesperpixel > 4) || (bytesperpixel == 2)) {
printf("imb_savepng: unsupported bytes per pixel: %d\n", bytesperpixel);
@@ -201,10 +207,10 @@ int imb_savepng(struct ImBuf *ibuf, char *name, int flags)
PNG_FILTER_AVG | PNG_FILTER_VALUE_AVG |
PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH|
PNG_ALL_FILTERS);
-
- png_set_compression_level(png_ptr, Z_BEST_COMPRESSION);
*/
+ png_set_compression_level(png_ptr, compression);
+
// png image settings
png_set_IHDR(png_ptr,
info_ptr,
diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c
index dabb6780ea3..c5122ebe46c 100644
--- a/source/blender/imbuf/intern/radiance_hdr.c
+++ b/source/blender/imbuf/intern/radiance_hdr.c
@@ -29,6 +29,8 @@
* ***** END GPL LICENSE BLOCK *****
*/
+#ifdef WITH_HDR
+
/* ----------------------------------------------------------------------
Radiance High Dynamic Range image file IO
For description and code for reading/writing of radiance hdr files
@@ -40,6 +42,9 @@
#ifdef WIN32
#include <io.h>
#endif
+
+#include "MEM_guardedalloc.h"
+
#include "BLI_blenlib.h"
#include "imbuf.h"
@@ -358,3 +363,4 @@ int imb_savehdr(struct ImBuf *ibuf, char *name, int flags)
return 1;
}
+#endif /* WITH_HDR */
diff --git a/source/blender/imbuf/intern/rotate.c b/source/blender/imbuf/intern/rotate.c
index e0e52bb7094..4edb7ac7877 100644
--- a/source/blender/imbuf/intern/rotate.c
+++ b/source/blender/imbuf/intern/rotate.c
@@ -30,7 +30,8 @@
*/
#include "BLI_blenlib.h"
-#include "BKE_utildefines.h"
+#include "BKE_utildefines.h"
+#include "MEM_guardedalloc.h"
#include "imbuf.h"
#include "IMB_imbuf_types.h"
diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c
index 335e16402f9..f26eec51b03 100644
--- a/source/blender/imbuf/intern/scaling.c
+++ b/source/blender/imbuf/intern/scaling.c
@@ -30,6 +30,7 @@
*/
#include "BLI_blenlib.h"
+#include "MEM_guardedalloc.h"
#include "imbuf.h"
#include "IMB_imbuf_types.h"
diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c
index 09aaccc1ab6..b5434b85b5a 100644
--- a/source/blender/imbuf/intern/targa.c
+++ b/source/blender/imbuf/intern/targa.c
@@ -31,6 +31,7 @@
#include <io.h>
#endif
#include "BLI_blenlib.h"
+#include "MEM_guardedalloc.h"
#include "imbuf.h"
diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c
index 234c8837b35..f3415d44ecb 100644
--- a/source/blender/imbuf/intern/thumbs.c
+++ b/source/blender/imbuf/intern/thumbs.c
@@ -29,7 +29,6 @@
#include <stdio.h>
-#include "BKE_global.h"
#include "BKE_utildefines.h"
#include "BLI_blenlib.h"
#include "MEM_guardedalloc.h"
@@ -243,14 +242,14 @@ void IMB_thumb_makedirs()
/* create thumbnail for file and returns new imbuf for thumbnail */
ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, ImBuf *img)
{
- char uri[URI_MAX];
+ char uri[URI_MAX]= "";
char desc[URI_MAX+22];
char tpath[FILE_MAX];
char tdir[FILE_MAX];
char temp[FILE_MAX];
- char mtime[40];
- char cwidth[40];
- char cheight[40];
+ char mtime[40]= "0"; /* incase we can't stat the file */
+ char cwidth[40]= "0"; /* incase images have no data */
+ char cheight[40]= "0";
char thumb[40];
short tsize = 128;
short ex, ey;
@@ -265,7 +264,7 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, Im
tsize = 256;
break;
case THB_FAIL:
- tsize = 0;
+ tsize = 1;
break;
default:
return 0; /* unknown size */
@@ -281,7 +280,7 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, Im
return NULL;
}
if (size == THB_FAIL) {
- img = IMB_allocImBuf(0,0,32, IB_rect | IB_metadata, 0);
+ img = IMB_allocImBuf(1,1,32, IB_rect | IB_metadata, 0);
if (!img) return 0;
} else {
if (THB_SOURCE_IMAGE == source || THB_SOURCE_BLEND == source) {
diff --git a/source/blender/imbuf/intern/thumbs_blend.c b/source/blender/imbuf/intern/thumbs_blend.c
index 7f1c903e9de..cb27b1a647f 100644
--- a/source/blender/imbuf/intern/thumbs_blend.c
+++ b/source/blender/imbuf/intern/thumbs_blend.c
@@ -40,16 +40,14 @@
static ImBuf *loadblend_thumb(gzFile gzfile)
{
- char buf[8];
- int code= 0;
+ char buf[12];
+ int bhead[24/sizeof(int)]; /* max size on 64bit */
char endian, pointer_size;
char endian_switch;
- int len, im_len, x, y;
- ImBuf *img= NULL;
-
+ int sizeof_bhead ;
/* read the blend file header */
- if(gzread(gzfile, buf, 8) != 8)
+ if(gzread(gzfile, buf, 12) != 12)
return NULL;
if(strncmp(buf, "BLENDER", 7))
return NULL;
@@ -61,38 +59,23 @@ static ImBuf *loadblend_thumb(gzFile gzfile)
else
return NULL;
- /* read the next 4 bytes, only need the first char, ignore the version */
- /* endian and vertsion (ignored) */
- if(gzread(gzfile, buf, 4) != 4)
- return NULL;
+ sizeof_bhead = 16 + pointer_size;
- if(buf[0]=='V')
+ if(buf[8]=='V')
endian= B_ENDIAN; /* big: PPC */
- else if(buf[0]=='v')
+ else if(buf[8]=='v')
endian= L_ENDIAN; /* little: x86 */
else
return NULL;
- while(gzread(gzfile, &code, sizeof(int)) == sizeof(int)) {
- endian_switch = ((ENDIAN_ORDER != endian)) ? 1 : 0;
-
- if(gzread(gzfile, buf, sizeof(int)) != sizeof(int))
- return NULL;
-
- len = *( (int *)((void *)buf) );
+ endian_switch = ((ENDIAN_ORDER != endian)) ? 1 : 0;
+ while(gzread(gzfile, bhead, sizeof_bhead) == sizeof_bhead) {
if(endian_switch)
- SWITCH_INT(len);
+ SWITCH_INT(bhead[1]); /* length */
- /* finally read the rest of the bhead struct, pointer and 2 ints */
- if(gzread(gzfile, buf, pointer_size) != pointer_size)
- return NULL;
- if(gzread(gzfile, buf, sizeof(int) * 2) != sizeof(int) * 2)
- return NULL;
-
- /* we dont actually care whats in the bhead */
- if (code==REND) {
- gzseek(gzfile, len, SEEK_CUR); /* skip to the next */
+ if (bhead[0]==REND) {
+ gzseek(gzfile, bhead[1], SEEK_CUR); /* skip to the next */
}
else {
break;
@@ -100,35 +83,36 @@ static ImBuf *loadblend_thumb(gzFile gzfile)
}
/* using 'TEST' since new names segfault when loading in old blenders */
- if(code != TEST)
- return NULL;
-
- if(gzread(gzfile, &x, sizeof(int)) != sizeof(int))
- return NULL;
- if(gzread(gzfile, &y, sizeof(int)) != sizeof(int))
- return NULL;
-
- len -= sizeof(int) * 2;
-
- if(endian_switch) {
- SWITCH_INT(x);
- SWITCH_INT(y);
- }
+ if(bhead[0] == TEST) {
+ ImBuf *img= NULL;
+ int size[2];
- /* inconsistant image size, quit early */
- im_len = x * y * sizeof(int);
- if(im_len != len)
- return NULL;
+ if(gzread(gzfile, size, sizeof(size)) != sizeof(size))
+ return NULL;
- /* finally malloc and read the data */
- img= IMB_allocImBuf(x, y, 32, IB_rect | IB_metadata, 0);
+ if(endian_switch) {
+ SWITCH_INT(size[0]);
+ SWITCH_INT(size[1]);
+ }
+ /* length */
+ bhead[1] -= sizeof(int) * 2;
- if(gzread(gzfile, img->rect, len) != len) {
- IMB_freeImBuf(img);
- img= NULL;
+ /* inconsistant image size, quit early */
+ if(bhead[1] != size[0] * size[1] * sizeof(int))
+ return NULL;
+
+ /* finally malloc and read the data */
+ img= IMB_allocImBuf(size[0], size[1], 32, IB_rect | IB_metadata, 0);
+
+ if(gzread(gzfile, img->rect, bhead[1]) != bhead[1]) {
+ IMB_freeImBuf(img);
+ img= NULL;
+ }
+
+ return img;
}
-
- return img;
+
+ return NULL;
}
ImBuf *IMB_loadblend_thumb(const char *path)
diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c
index 99f74fea640..6b94583f17d 100644
--- a/source/blender/imbuf/intern/tiff.c
+++ b/source/blender/imbuf/intern/tiff.c
@@ -301,17 +301,6 @@ int imb_is_a_tiff(unsigned char *mem)
(memcmp(lil_endian, mem, IMB_TIFF_NCB) == 0) );
}
-static void scanline_contig_8bit(unsigned char *rect, unsigned char *cbuf, int scanline_w, int spp)
-{
- int i;
- for (i=0; i < scanline_w; i++) {
- rect[i*4 + 0] = cbuf[i*spp + 0];
- rect[i*4 + 1] = cbuf[i*spp + 1];
- rect[i*4 + 2] = cbuf[i*spp + 2];
- rect[i*4 + 3] = (spp==4)?cbuf[i*spp + 3]:255;
- }
-}
-
static void scanline_contig_16bit(float *rectf, unsigned short *sbuf, int scanline_w, int spp)
{
int i;
@@ -334,13 +323,6 @@ static void scanline_contig_32bit(float *rectf, float *fbuf, int scanline_w, int
}
}
-static void scanline_separate_8bit(unsigned char *rect, unsigned char *cbuf, int scanline_w, int chan)
-{
- int i;
- for (i=0; i < scanline_w; i++)
- rect[i*4 + chan] = cbuf[i];
-}
-
static void scanline_separate_16bit(float *rectf, unsigned short *sbuf, int scanline_w, int chan)
{
int i;
@@ -356,40 +338,6 @@ static void scanline_separate_32bit(float *rectf, float *fbuf, int scanline_w, i
}
-#if 0
-/*
- * Use the libTIFF RGBAImage API to read a TIFF image.
- * This function uses the "RGBA Image" support from libtiff, which enables
- * it to load most commonly-encountered TIFF formats. libtiff handles format
- * conversion, color depth conversion, etc.
- */
-static int imb_read_tiff_pixels_rgba(ImBuf *ibuf, TIFF *image, int premul)
-{
- ImBuf *tmpibuf;
- int success;
-
- tmpibuf= IMB_allocImBuf(ibuf->x, ibuf->y, 32, IB_rect, 0);
- success= TIFFReadRGBAImage(image, ibuf->x, ibuf->y, tmpibuf->rect, 0);
-
- if(ENDIAN_ORDER == B_ENDIAN)
- IMB_convert_rgba_to_abgr(tmpibuf);
- if(premul) {
- IMB_premultiply_alpha(tmpibuf);
- ibuf->flags |= IB_premul;
- }
-
- /* assign rect last */
- ibuf->rect= tmpibuf->rect;
- ibuf->mall |= IB_rect;
- ibuf->flags |= IB_rect;
-
- tmpibuf->mall &= ~IB_rect;
- IMB_freeImBuf(tmpibuf);
-
- return success;
-}
-#endif
-
/*
* Use the libTIFF scanline API to read a TIFF image.
* This method is most flexible and can handle multiple different bit depths
@@ -398,13 +346,12 @@ static int imb_read_tiff_pixels_rgba(ImBuf *ibuf, TIFF *image, int premul)
static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul)
{
ImBuf *tmpibuf;
- int success;
+ int success= 0;
short bitspersample, spp, config;
size_t scanline;
int ib_flag=0, row, chan;
float *fbuf=NULL;
unsigned short *sbuf=NULL;
- unsigned char *cbuf=NULL;
TIFFGetField(image, TIFFTAG_BITSPERSAMPLE, &bitspersample);
TIFFGetField(image, TIFFTAG_SAMPLESPERPIXEL, &spp); /* number of 'channels' */
@@ -417,30 +364,28 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul)
} else if (bitspersample == 16) {
ib_flag = IB_rectfloat;
sbuf = (unsigned short *)_TIFFmalloc(scanline);
- } else if (bitspersample == 8) {
+ } else {
ib_flag = IB_rect;
- cbuf = (unsigned char *)_TIFFmalloc(scanline);
}
tmpibuf= IMB_allocImBuf(ibuf->x, ibuf->y, ibuf->depth, ib_flag, 0);
+ /* simple RGBA image */
+ if (!(bitspersample == 32 || bitspersample == 16)) {
+ success |= TIFFReadRGBAImage(image, ibuf->x, ibuf->y, tmpibuf->rect, 0);
+ }
/* contiguous channels: RGBRGBRGB */
- if (config == PLANARCONFIG_CONTIG) {
+ else if (config == PLANARCONFIG_CONTIG) {
for (row = 0; row < ibuf->y; row++) {
int ib_offset = ibuf->x*ibuf->y*4 - ibuf->x*4 * (row+1);
if (bitspersample == 32) {
- success = TIFFReadScanline(image, fbuf, row, 0);
+ success |= TIFFReadScanline(image, fbuf, row, 0);
scanline_contig_32bit(tmpibuf->rect_float+ib_offset, fbuf, ibuf->x, spp);
} else if (bitspersample == 16) {
- success = TIFFReadScanline(image, sbuf, row, 0);
+ success |= TIFFReadScanline(image, sbuf, row, 0);
scanline_contig_16bit(tmpibuf->rect_float+ib_offset, sbuf, ibuf->x, spp);
-
- } else if (bitspersample == 8) {
- unsigned char *crect = (unsigned char*)tmpibuf->rect;
- success = TIFFReadScanline(image, cbuf, row, 0);
- scanline_contig_8bit(crect+ib_offset, cbuf, ibuf->x, spp);
}
}
/* separate channels: RRRGGGBBB */
@@ -456,53 +401,47 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul)
if (chan == 3 && spp == 3) /* fill alpha if only RGB TIFF */
memset(fbuf, 1.0, sizeof(fbuf));
else
- success = TIFFReadScanline(image, fbuf, row, chan);
+ success |= TIFFReadScanline(image, fbuf, row, chan);
scanline_separate_32bit(tmpibuf->rect_float+ib_offset, fbuf, ibuf->x, chan);
} else if (bitspersample == 16) {
if (chan == 3 && spp == 3) /* fill alpha if only RGB TIFF */
memset(sbuf, 65535, sizeof(sbuf));
else
- success = TIFFReadScanline(image, sbuf, row, chan);
+ success |= TIFFReadScanline(image, sbuf, row, chan);
scanline_separate_16bit(tmpibuf->rect_float+ib_offset, sbuf, ibuf->x, chan);
- } else if (bitspersample == 8) {
- unsigned char *crect = (unsigned char*)tmpibuf->rect;
- if (chan == 3 && spp == 3) /* fill alpha if only RGB TIFF */
- memset(cbuf, 255, sizeof(cbuf));
- else
- success = TIFFReadScanline(image, cbuf, row, chan);
- scanline_separate_8bit(crect+ib_offset, cbuf, ibuf->x, chan);
}
}
}
}
- ibuf->profile = (bitspersample==32)?IB_PROFILE_LINEAR_RGB:IB_PROFILE_SRGB;
-
if (bitspersample == 32)
_TIFFfree(fbuf);
else if (bitspersample == 16)
_TIFFfree(sbuf);
- else if (bitspersample == 8)
- _TIFFfree(cbuf);
+
+ if(success) {
+ ibuf->profile = (bitspersample==32)?IB_PROFILE_LINEAR_RGB:IB_PROFILE_SRGB;
+
+ if(ENDIAN_ORDER == B_ENDIAN)
+ IMB_convert_rgba_to_abgr(tmpibuf);
+ if(premul) {
+ IMB_premultiply_alpha(tmpibuf);
+ ibuf->flags |= IB_premul;
+ }
- if(ENDIAN_ORDER == B_ENDIAN)
- IMB_convert_rgba_to_abgr(tmpibuf);
- if(premul) {
- IMB_premultiply_alpha(tmpibuf);
- ibuf->flags |= IB_premul;
+ /* assign rect last */
+ if (tmpibuf->rect_float)
+ ibuf->rect_float= tmpibuf->rect_float;
+ else
+ ibuf->rect= tmpibuf->rect;
+ ibuf->mall |= ib_flag;
+ ibuf->flags |= ib_flag;
+
+ tmpibuf->mall &= ~ib_flag;
}
-
- /* assign rect last */
- if (tmpibuf->rect_float)
- ibuf->rect_float= tmpibuf->rect_float;
- else
- ibuf->rect= tmpibuf->rect;
- ibuf->mall |= ib_flag;
- ibuf->flags |= ib_flag;
-
- tmpibuf->mall &= ~ib_flag;
+
IMB_freeImBuf(tmpibuf);
return success;
@@ -847,4 +786,4 @@ int imb_savetiff(ImBuf *ibuf, char *name, int flags)
return (1);
}
-#endif /* WITH_TIFF */ \ No newline at end of file
+#endif /* WITH_TIFF */
diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c
index e6f4e226caa..cd447e5e43a 100644
--- a/source/blender/imbuf/intern/util.c
+++ b/source/blender/imbuf/intern/util.c
@@ -68,6 +68,80 @@
#define UTIL_DEBUG 0
+const char *imb_ext_image[] = {
+ ".png",
+ ".tga",
+ ".bmp",
+ ".jpg", ".jpeg",
+ ".sgi", ".rgb", ".rgba",
+#ifdef WITH_TIFF
+ ".tif", ".tiff", ".tx",
+#endif
+#ifdef WITH_OPENJPEG
+ ".jp2",
+#endif
+#ifdef WITH_HDR
+ ".hdr",
+#endif
+#ifdef WITH_DDS
+ ".dds",
+#endif
+#ifdef WITH_CINEON
+ ".dpx",
+ ".cin",
+#endif
+#ifdef WITH_OPENEXR
+ ".exr",
+#endif
+ NULL};
+
+const char *imb_ext_image_qt[] = {
+ ".gif",
+ ".psd",
+ ".pct", ".pict",
+ ".pntg",
+ ".qtif",
+ NULL};
+
+const char *imb_ext_movie[] = {
+ ".avi",
+ ".flc",
+ ".mov",
+ ".movie",
+ ".mp4",
+ ".m4v",
+ ".m2v",
+ ".m2t",
+ ".mts",
+ ".mv",
+ ".avs",
+ ".wmv",
+ ".ogv",
+ ".dv",
+ ".mpeg",
+ ".mpg",
+ ".mpg2",
+ ".vob",
+ ".mkv",
+ ".flv",
+ ".divx",
+ ".xvid",
+ NULL};
+
+/* sort of wrong being here... */
+const char *imb_ext_audio[] = {
+ ".wav",
+ ".ogg",
+ ".oga",
+ ".mp3",
+ ".mp2",
+ ".ac3",
+ ".aac",
+ ".flac",
+ ".wma",
+ ".eac3",
+ NULL};
+
static int IMB_ispic_name(char *name)
{
ImFileType *type;
@@ -105,80 +179,16 @@ static int IMB_ispic_name(char *name)
int IMB_ispic(char *filename)
{
if(U.uiflag & USER_FILTERFILEEXTS) {
- if (BLI_testextensie(filename, ".tif")
- || BLI_testextensie(filename, ".tiff")
- || BLI_testextensie(filename, ".tx")) {
- return IMB_ispic_name(filename);
+ if( (BLI_testextensie_array(filename, imb_ext_image)) ||
+ (G.have_quicktime && BLI_testextensie_array(filename, imb_ext_image_qt))
+ ) {
+ return IMB_ispic_name(filename);
}
- if (G.have_quicktime){
- if( BLI_testextensie(filename, ".jpg")
- || BLI_testextensie(filename, ".jpeg")
-#ifdef WITH_TIFF
- || BLI_testextensie(filename, ".tif")
- || BLI_testextensie(filename, ".tiff")
- || BLI_testextensie(filename, ".tx")
-#endif
- || BLI_testextensie(filename, ".hdr")
- || BLI_testextensie(filename, ".tga")
- || BLI_testextensie(filename, ".rgb")
- || BLI_testextensie(filename, ".bmp")
- || BLI_testextensie(filename, ".png")
-#ifdef WITH_DDS
- || BLI_testextensie(filename, ".dds")
-#endif
- || BLI_testextensie(filename, ".iff")
- || BLI_testextensie(filename, ".lbm")
- || BLI_testextensie(filename, ".gif")
- || BLI_testextensie(filename, ".psd")
- || BLI_testextensie(filename, ".pct")
- || BLI_testextensie(filename, ".pict")
- || BLI_testextensie(filename, ".pntg") //macpaint
- || BLI_testextensie(filename, ".qtif")
- || BLI_testextensie(filename, ".cin")
-#ifdef WITH_BF_OPENEXR
- || BLI_testextensie(filename, ".exr")
-#endif
-#ifdef WITH_BF_OPENJPEG
- || BLI_testextensie(filename, ".jp2")
-#endif
- || BLI_testextensie(filename, ".sgi")) {
- return IMB_ispic_name(filename);
- } else {
- return(FALSE);
- }
- } else { /* no quicktime */
- if( BLI_testextensie(filename, ".jpg")
- || BLI_testextensie(filename, ".jpeg")
-#ifdef WITH_TIFF
- || BLI_testextensie(filename, ".tif")
- || BLI_testextensie(filename, ".tiff")
- || BLI_testextensie(filename, ".tx")
-#endif
- || BLI_testextensie(filename, ".hdr")
- || BLI_testextensie(filename, ".tga")
- || BLI_testextensie(filename, ".rgb")
- || BLI_testextensie(filename, ".bmp")
- || BLI_testextensie(filename, ".png")
- || BLI_testextensie(filename, ".cin")
-#ifdef WITH_DDS
- || BLI_testextensie(filename, ".dds")
-#endif
-#ifdef WITH_BF_OPENEXR
- || BLI_testextensie(filename, ".exr")
-#endif
-#ifdef WITH_BF_OPENJPEG
- || BLI_testextensie(filename, ".jp2")
-#endif
- || BLI_testextensie(filename, ".iff")
- || BLI_testextensie(filename, ".lbm")
- || BLI_testextensie(filename, ".sgi")) {
- return IMB_ispic_name(filename);
- }
- else {
- return(FALSE);
- }
+ else {
+ return FALSE;
}
- } else { /* no FILTERFILEEXTS */
+ }
+ else { /* no FILTERFILEEXTS */
return IMB_ispic_name(filename);
}
}