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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2010-05-07 19:18:04 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2010-05-07 19:18:04 +0400
commit008863daec1249d1f17bc69e1105e336db690d63 (patch)
tree78a4001857b26a287125a3f5fa31496052f6ebdd /source/blender/imbuf/intern/util.c
parent1613829e8e821321da99cad4790b7e6a1d90cea8 (diff)
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine. Imbuf module: some small refactoring and removing a lot of unused or old code (about 6.5k lines). * Added a ImFileType struct with callbacks to make adding an file format type, or making changes to the API easier. * Move imbuf init/exit code into IMB_init()/IMB_exit() functions. * Increased mipmap levels from 10 to 20, you run into this limit already with a 2k image. * Removed hamx, amiga, anim5 format support. * Removed colormap saving, only simple colormap code now for reading tga. * Removed gen_dynlibtiff.py, editing this is almost as much work as just editing the code directly. * Functions removed that were only used for sequencer plugin API: IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp, IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace, IMB_dit0, IMB_dit2, IMB_cspace * Write metadata info into OpenEXR images. Can be viewed with the command line utility 'exrheader' For the image tile cache code, see this page: http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
Diffstat (limited to 'source/blender/imbuf/intern/util.c')
-rw-r--r--source/blender/imbuf/intern/util.c120
1 files changed, 28 insertions, 92 deletions
diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c
index b1ca414434f..aff05b4eaff 100644
--- a/source/blender/imbuf/intern/util.c
+++ b/source/blender/imbuf/intern/util.c
@@ -42,36 +42,16 @@
#include "BKE_global.h"
#include "imbuf.h"
-#include "imbuf_patch.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
-
-#include "IMB_targa.h"
-#include "IMB_png.h"
-
-#ifdef WITH_DDS
-#include "dds/dds_api.h"
-#endif
-
-#include "IMB_bmp.h"
-#include "IMB_tiff.h"
-#include "IMB_radiance_hdr.h"
-#include "IMB_dpxcineon.h"
+#include "IMB_filetype.h"
#include "IMB_anim.h"
-#ifdef WITH_OPENEXR
-#include "openexr/openexr_api.h"
-#endif
-
#ifdef WITH_QUICKTIME
#include "quicktime_import.h"
#endif
-#ifdef WITH_OPENJPEG
-#include "IMB_jp2.h"
-#endif
-
#ifdef WITH_FFMPEG
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
@@ -88,90 +68,46 @@
#define UTIL_DEBUG 0
-/* from misc_util: flip the bytes from x */
-#define GS(x) (((unsigned char *)(x))[0] << 8 | ((unsigned char *)(x))[1])
-
-/* this one is only def-ed once, strangely... */
-#define GSS(x) (((uchar *)(x))[1] << 8 | ((uchar *)(x))[0])
-
static int IMB_ispic_name(char *name)
{
+ ImFileType *type;
struct stat st;
int fp, buf[10];
- int ofs = 0;
if(UTIL_DEBUG) printf("IMB_ispic_name: loading %s\n", name);
- if (ib_stat(name,&st) == -1) return(0);
- if (((st.st_mode) & S_IFMT) == S_IFREG){
- if ((fp = open(name,O_BINARY|O_RDONLY)) >= 0){
- if (read(fp,buf,32)==32){
- close(fp);
- if (buf[ofs] == CAT) ofs += 3;
- if (buf[ofs] == FORM){
- if (buf[ofs + 2] == ILBM) return(AMI);
- if (buf[ofs + 2] == ANIM){
- if (buf[ofs + 3] == FORM){
- return(ANIM);
- }else{
- return(Anim);
- }
- }
- } else {
- if (GS(buf) == IMAGIC) return(IMAGIC);
- if (GSS(buf) == IMAGIC) return(IMAGIC);
- if ((BIG_LONG(buf[0]) & 0xfffffff0) == 0xffd8ffe0) return(JPG);
-
- /* at windows there are ".ffl" files with the same magic numnber...
- besides that, tim images are not really important anymore! */
- /* if ((BIG_LONG(buf[0]) == 0x10000000) && ((BIG_LONG(buf[1]) & 0xf0ffffff) == 0)) return(TIM); */
-
- }
- if (imb_is_a_png(buf)) return(PNG);
-#ifdef WITH_DDS
- if (imb_is_a_dds((uchar *)buf)) return(DDS);
-#endif
- if (imb_is_a_targa(buf)) return(TGA);
-#ifdef WITH_OPENEXR
- if (imb_is_a_openexr((uchar *)buf)) return(OPENEXR);
-#endif
- if (imb_is_a_tiff(buf)) return(TIF);
- if (imb_is_dpx(buf)) return (DPX);
- if (imb_is_cineon(buf)) return(CINEON);
- /* radhdr: check if hdr format */
- if (imb_is_a_hdr(buf)) return(RADHDR);
-
-/*
- if (imb_is_a_bmp(buf)) return(BMP);
-*/
-
-#ifdef WITH_OPENJPEG
- if (imb_is_a_jp2(buf)) return(JP2);
-#endif
-
-#ifdef WITH_QUICKTIME
-#if defined(_WIN32) || defined(__APPLE__)
- if(G.have_quicktime) {
- if (imb_is_a_quicktime(name)) return(QUICKTIME);
- }
-#endif
-#endif
+ if(stat(name,&st) == -1)
+ return FALSE;
+ if(((st.st_mode) & S_IFMT) != S_IFREG)
+ return FALSE;
- return(FALSE);
- }
- close(fp);
- }
+ if((fp = open(name,O_BINARY|O_RDONLY)) < 0)
+ return FALSE;
+
+ if(read(fp, buf, 32) != 32) {
+ close(fp);
+ return FALSE;
}
- return(FALSE);
-}
+ close(fp);
+
+ /* XXX move this exception */
+ if((BIG_LONG(buf[0]) & 0xfffffff0) == 0xffd8ffe0)
+ return JPG;
+ for(type=IMB_FILE_TYPES; type->is_a; type++)
+ if(type->is_a((uchar*)buf))
+ return type->filetype;
+
+ return FALSE;
+}
int IMB_ispic(char *filename)
{
if(U.uiflag & USER_FILTERFILEEXTS) {
if (G.have_libtiff && (BLI_testextensie(filename, ".tif")
- || BLI_testextensie(filename, ".tiff"))) {
+ || BLI_testextensie(filename, ".tiff")
+ || BLI_testextensie(filename, ".tx"))) {
return IMB_ispic_name(filename);
}
if (G.have_quicktime){
@@ -179,6 +115,7 @@ int IMB_ispic(char *filename)
|| BLI_testextensie(filename, ".jpeg")
|| BLI_testextensie(filename, ".tif")
|| BLI_testextensie(filename, ".tiff")
+ || BLI_testextensie(filename, ".tx")
|| BLI_testextensie(filename, ".hdr")
|| BLI_testextensie(filename, ".tga")
|| BLI_testextensie(filename, ".rgb")
@@ -391,14 +328,14 @@ int imb_get_anim_type(char * name) {
/* stat test below fails on large files > 4GB */
if (isffmpeg(name)) return (ANIM_FFMPEG);
# endif
- if (ib_stat(name,&st) == -1) return(0);
+ if (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);
#else
- if (ib_stat(name,&st) == -1) return(0);
+ if (stat(name,&st) == -1) return(0);
if (((st.st_mode) & S_IFMT) != S_IFREG) return(0);
if (ismovie(name)) return (ANIM_MOVIE);
@@ -414,7 +351,6 @@ int imb_get_anim_type(char * name) {
if (isredcode(name)) return (ANIM_REDCODE);
#endif
type = IMB_ispic(name);
- if (type == ANIM) return (ANIM_ANIM5);
if (type) return(ANIM_SEQUENCE);
return(0);
}