diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-05-07 19:18:04 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-05-07 19:18:04 +0400 |
commit | 008863daec1249d1f17bc69e1105e336db690d63 (patch) | |
tree | 78a4001857b26a287125a3f5fa31496052f6ebdd /source/blender/blenkernel | |
parent | 1613829e8e821321da99cad4790b7e6a1d90cea8 (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/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_image.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/blender.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/bmfont.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 110 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/multires.c | 53 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sequencer.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/writeavi.c | 5 |
7 files changed, 47 insertions, 128 deletions
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index 915f59be01a..7bdb9aaf709 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -55,7 +55,6 @@ int BKE_imtype_is_movie(int imtype); struct anim *openanim(char * name, int flags); -void converttopremul(struct ImBuf *ibuf); void image_de_interlace(struct Image *ima, int odd); void tag_image_time(struct Image *ima); diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 3ccf068d6c8..42c492d3237 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -100,7 +100,7 @@ void free_blender(void) BKE_spacetypes_free(); /* after free main, it uses space callbacks */ - IMB_freeImBufdata(); /* imbuf lib */ + IMB_exit(); free_nodesystem(); } diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c index 1b053b45859..e2a6c04450b 100644 --- a/source/blender/blenkernel/intern/bmfont.c +++ b/source/blender/blenkernel/intern/bmfont.c @@ -174,7 +174,7 @@ void detectBitmapFont(ImBuf *ibuf) unsigned short version; int i; - if (ibuf != NULL) { + if (ibuf != NULL && ibuf->rect != NULL) { // bitmap must have an x size that is a power of two if (is_power_of_two(ibuf->x)) { rect = (unsigned char *) (ibuf->rect + (ibuf->x * (ibuf->y - 1))); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 2c71cc9310a..a377bbed24c 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -92,58 +92,6 @@ /* ******** IMAGE PROCESSING ************* */ -/* used by sequencer and image premul option - IMA_DO_PREMUL */ -void converttopremul(struct ImBuf *ibuf) -{ - int x, y; - - if(ibuf==0) return; - if (ibuf->rect) { - int val; - char *cp; - if(ibuf->depth==24) { /* put alpha at 255 */ - cp= (char *)(ibuf->rect); - for(y=0; y<ibuf->y; y++) { - for(x=0; x<ibuf->x; x++, cp+=4) { - cp[3]= 255; - } - } - } else { - cp= (char *)(ibuf->rect); - for(y=0; y<ibuf->y; y++) { - for(x=0; x<ibuf->x; x++, cp+=4) { - val= cp[3]; - cp[0]= (cp[0]*val)>>8; - cp[1]= (cp[1]*val)>>8; - cp[2]= (cp[2]*val)>>8; - } - } - } - } - if (ibuf->rect_float) { - float val; - float *cp; - if(ibuf->depth==24) { /* put alpha at 1.0 */ - cp= ibuf->rect_float;; - for(y=0; y<ibuf->y; y++) { - for(x=0; x<ibuf->x; x++, cp+=4) { - cp[3]= 1.0; - } - } - } else { - cp= ibuf->rect_float; - for(y=0; y<ibuf->y; y++) { - for(x=0; x<ibuf->x; x++, cp+=4) { - val= cp[3]; - cp[0]= cp[0]*val; - cp[1]= cp[1]*val; - cp[2]= cp[2]*val; - } - } - } - } -} - static void de_interlace_ng(struct ImBuf *ibuf) /* neogeo fields */ { struct ImBuf * tbuf1, * tbuf2; @@ -735,8 +683,6 @@ int BKE_imtype_to_ftype(int imtype) return TGA; else if(imtype==R_RAWTGA) return RAWTGA; - else if(imtype==R_HAMX) - return AN_hamx; #ifdef WITH_OPENJPEG else if(imtype==R_JP2) return JP2; @@ -773,8 +719,6 @@ int BKE_ftype_to_imtype(int ftype) return R_TARGA; else if(ftype & RAWTGA) return R_RAWTGA; - else if(ftype == AN_hamx) - return R_HAMX; #ifdef WITH_OPENJPEG else if(ftype & JP2) return R_JP2; @@ -787,7 +731,6 @@ int BKE_ftype_to_imtype(int ftype) int BKE_imtype_is_movie(int imtype) { switch(imtype) { - case R_MOVIE: case R_AVIRAW: case R_AVIJPEG: case R_AVICODEC: @@ -864,7 +807,7 @@ void BKE_add_image_extension(char *string, int imtype) extension= ".jp2"; } #endif - else { // R_MOVIE, R_AVICODEC, R_AVIRAW, R_AVIJPEG, R_JPEG90, R_QUICKTIME etc + else { // R_AVICODEC, R_AVIRAW, R_AVIJPEG, R_JPEG90, R_QUICKTIME etc if(!( BLI_testextensie(string, ".jpg") || BLI_testextensie(string, ".jpeg"))) extension= ".jpg"; } @@ -1211,15 +1154,15 @@ void BKE_stamp_info(Scene *scene, struct ImBuf *ibuf) /* fill all the data values, no prefix */ stampdata(scene, &stamp_data, 0); - if (stamp_data.file[0]) IMB_imginfo_change_field (ibuf, "File", stamp_data.file); - if (stamp_data.note[0]) IMB_imginfo_change_field (ibuf, "Note", stamp_data.note); - if (stamp_data.date[0]) IMB_imginfo_change_field (ibuf, "Date", stamp_data.date); - if (stamp_data.marker[0]) IMB_imginfo_change_field (ibuf, "Marker", stamp_data.marker); - if (stamp_data.time[0]) IMB_imginfo_change_field (ibuf, "Time", stamp_data.time); - if (stamp_data.frame[0]) IMB_imginfo_change_field (ibuf, "Frame", stamp_data.frame); - if (stamp_data.camera[0]) IMB_imginfo_change_field (ibuf, "Camera", stamp_data.camera); - if (stamp_data.scene[0]) IMB_imginfo_change_field (ibuf, "Scene", stamp_data.scene); - if (stamp_data.strip[0]) IMB_imginfo_change_field (ibuf, "Strip", stamp_data.strip); + if (stamp_data.file[0]) IMB_metadata_change_field (ibuf, "File", stamp_data.file); + if (stamp_data.note[0]) IMB_metadata_change_field (ibuf, "Note", stamp_data.note); + if (stamp_data.date[0]) IMB_metadata_change_field (ibuf, "Date", stamp_data.date); + if (stamp_data.marker[0]) IMB_metadata_change_field (ibuf, "Marker", stamp_data.marker); + if (stamp_data.time[0]) IMB_metadata_change_field (ibuf, "Time", stamp_data.time); + if (stamp_data.frame[0]) IMB_metadata_change_field (ibuf, "Frame", stamp_data.frame); + if (stamp_data.camera[0]) IMB_metadata_change_field (ibuf, "Camera", stamp_data.camera); + if (stamp_data.scene[0]) IMB_metadata_change_field (ibuf, "Scene", stamp_data.scene); + if (stamp_data.strip[0]) IMB_metadata_change_field (ibuf, "Strip", stamp_data.strip); } int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, char *name, int imtype, int subimtype, int quality) @@ -1273,9 +1216,6 @@ int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, char *name, int imtype, int subimt else if(imtype==R_RAWTGA) { ibuf->ftype= RAWTGA; } - else if(imtype==R_HAMX) { - ibuf->ftype= AN_hamx; - } #ifdef WITH_OPENJPEG else if(imtype==R_JP2) { if(quality < 10) quality= 90; @@ -1299,7 +1239,7 @@ int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, char *name, int imtype, int subimt } #endif else { - /* R_JPEG90, R_MOVIE, etc. default we save jpegs */ + /* R_JPEG90, etc. default we save jpegs */ if(quality < 10) quality= 90; ibuf->ftype= JPG|quality; if(ibuf->depth==32) ibuf->depth= 24; /* unsupported feature only confuses other s/w */ @@ -1595,6 +1535,7 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) struct ImBuf *ibuf; unsigned short numlen; char name[FILE_MAX], head[FILE_MAX], tail[FILE_MAX]; + int flag; /* XXX temp stuff? */ if(ima->lastframe != frame) @@ -1611,8 +1552,12 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) else BLI_path_abs(name, G.sce); + flag= IB_rect|IB_multilayer; + if(ima->flag & IMA_DO_PREMUL) + flag |= IB_premul; + /* read ibuf */ - ibuf = IMB_loadiffname(name, IB_rect|IB_multilayer); + ibuf = IMB_loadiffname(name, flag); if(G.f & G_DEBUG) printf("loaded %s\n", name); if (ibuf) { @@ -1632,10 +1577,6 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) image_initialize_after_load(ima, ibuf); image_assign_ibuf(ima, ibuf, 0, frame); #endif - - if(ima->flag & IMA_DO_PREMUL) - converttopremul(ibuf); - } else ima->ok= 0; @@ -1718,7 +1659,7 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame) else BLI_path_abs(str, G.sce); - ima->anim = openanim(str, IB_cmap | IB_rect); + ima->anim = openanim(str, IB_rect); /* let's initialize this user */ if(ima->anim && iuser && iuser->frames==0) @@ -1749,21 +1690,25 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame) return ibuf; } -/* cfra used for # code, Image can only have this # for all its users */ +/* cfra used for # code, Image can only have this # for all its users + * warning, 'iuser' can be NULL */ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) { struct ImBuf *ibuf; char str[FILE_MAX]; - int assign = 0; + int assign = 0, flag; /* always ensure clean ima */ image_free_buffers(ima); /* is there a PackedFile with this image ? */ if (ima->packedfile) { - ibuf = IMB_ibImageFromMemory((int *) ima->packedfile->data, ima->packedfile->size, IB_rect|IB_multilayer); + ibuf = IMB_ibImageFromMemory((unsigned char*)ima->packedfile->data, ima->packedfile->size, IB_rect|IB_multilayer); } else { + flag= IB_rect|IB_multilayer|IB_metadata; + if(ima->flag & IMA_DO_PREMUL) + flag |= IB_premul; /* get the right string */ BLI_strncpy(str, ima->name, sizeof(str)); @@ -1775,7 +1720,7 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) BLI_path_frame(str, cfra, 0); /* read ibuf */ - ibuf = IMB_loadiffname(str, IB_rect|IB_multilayer|IB_imginfo); + ibuf = IMB_loadiffname(str, flag); } if (ibuf) { @@ -1797,9 +1742,6 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) if ((ima->packedfile == NULL) && (G.fileflags & G_AUTOPACK)) ima->packedfile = newPackedFile(NULL, str); } - - if(ima->flag & IMA_DO_PREMUL) - converttopremul(ibuf); } else ima->ok= 0; diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 52c6f9355a3..9e95581b211 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -264,38 +264,6 @@ int multiresModifier_reshapeFromDeformMod(MultiresModifierData *mmd, Object *ob, return result; } -static void multires_set_tot_mdisps(Mesh *me, int lvl) -{ - MDisps *mdisps= CustomData_get_layer(&me->fdata, CD_MDISPS); - int i; - - if(mdisps) { - for(i = 0; i < me->totface; i++) { - if(mdisps[i].totdisp == 0) { - int nvert = (me->mface[i].v4)? 4: 3; - mdisps[i].totdisp = multires_grid_tot[lvl]*nvert; - } - } - } -} - -static void multires_reallocate_mdisps(Mesh *me, MDisps *mdisps, int lvl) -{ - int i; - - /* reallocate displacements to be filled in */ - for(i = 0; i < me->totface; ++i) { - int nvert = (me->mface[i].v4)? 4: 3; - int totdisp = multires_grid_tot[lvl]*nvert; - float (*disps)[3] = MEM_callocN(sizeof(float) * 3 * totdisp, "multires disps"); - - if(mdisps[i].disps) - MEM_freeN(mdisps[i].disps); - - mdisps[i].disps = disps; - mdisps[i].totdisp = totdisp; - } -} static void column_vectors_to_mat3(float mat[][3], float v1[3], float v2[3], float v3[3]) { @@ -352,7 +320,6 @@ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int dire int levels = mmd->totlvl - lvl; MDisps *mdisps; - multires_set_tot_mdisps(me, mmd->totlvl); CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); mdisps= CustomData_get_layer(&me->fdata, CD_MDISPS); @@ -426,6 +393,24 @@ static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl return subsurf_make_derived_from_derived(dm, &smd, 0, NULL, 0, 0); } +static void multires_reallocate_mdisps(Mesh *me, MDisps *mdisps, int lvl) +{ + int i; + + /* reallocate displacements to be filled in */ + for(i = 0; i < me->totface; ++i) { + int nvert = (me->mface[i].v4)? 4: 3; + int totdisp = multires_grid_tot[lvl]*nvert; + float (*disps)[3] = MEM_callocN(sizeof(float) * 3 * totdisp, "multires disps"); + + if(mdisps[i].disps) + MEM_freeN(mdisps[i].disps); + + mdisps[i].disps = disps; + mdisps[i].totdisp = totdisp; + } +} + void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int updateblock, int simple) { Mesh *me = ob->data; @@ -630,7 +615,6 @@ static void multiresModifier_update(DerivedMesh *dm) ob = ccgdm->multires.ob; me = ccgdm->multires.ob->data; mmd = ccgdm->multires.mmd; - multires_set_tot_mdisps(me, mmd->totlvl); CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); mdisps = CustomData_get_layer(&me->fdata, CD_MDISPS); @@ -766,7 +750,6 @@ DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, int loca memcpy(subGridData[i], gridData[i], sizeof(DMGridData)*gridSize*gridSize); } - multires_set_tot_mdisps(me, mmd->totlvl); CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); multiresModifier_disp_run(result, ob->data, 0, 0, subGridData, mmd->totlvl); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index e48c4ea718c..4a9624036ff 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1777,7 +1777,7 @@ static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cf if(seq->flag & SEQ_MAKE_PREMUL) { if(se->ibuf->depth == 32 && se->ibuf->zbuf == 0) { - converttopremul(se->ibuf); + IMB_premultiply_alpha(se->ibuf); } } diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index f4bcb6d412f..00614ef0f4f 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -75,11 +75,6 @@ bMovieHandle *BKE_get_movie_handle(int imtype) mh.get_movie_path = filepath_avi; /* do the platform specific handles */ -#ifdef __sgi - if (imtype == R_MOVIE) { - - } -#endif #if defined(_WIN32) && !defined(FREE_WINDOWS) if (imtype == R_AVICODEC) { //XXX mh.start_movie= start_avi_codec; |