svn merge ^/trunk/blender -r46684:46699

This commit is contained in:
Campbell Barton
2012-05-16 16:41:51 +00:00
41 changed files with 2551 additions and 1692 deletions

View File

@@ -838,14 +838,16 @@ elseif(WIN32)
set(GETTEXT_LIBRARIES gnu_gettext)
endif()
set(LAPACK ${LIBDIR}/lapack)
# set(LAPACK_INCLUDE_DIR ${LAPACK}/include)
set_lib_path(LAPACK_LIBPATH ${LAPACK}/lib)
set(LAPACK_LIBRARIES
${LIBDIR}/lapack/lib/libf2c.lib
${LIBDIR}/lapack/lib/clapack_nowrap.lib
${LIBDIR}/lapack/lib/BLAS_nowrap.lib
)
if(WITH_MOD_CLOTH_ELTOPO)
set(LAPACK ${LIBDIR}/lapack)
# set(LAPACK_INCLUDE_DIR ${LAPACK}/include)
set_lib_path(LAPACK_LIBPATH ${LAPACK}/lib)
set(LAPACK_LIBRARIES
${LIBDIR}/lapack/lib/libf2c.lib
${LIBDIR}/lapack/lib/clapack_nowrap.lib
${LIBDIR}/lapack/lib/BLAS_nowrap.lib
)
endif()
set(PNG_LIBRARIES libpng)
set(JPEG_LIBRARIES libjpeg)

View File

@@ -26,7 +26,7 @@ shader node_camera(
ViewVector = (vector)transform("world", "camera", P);
ViewZDepth = fabs(ViewVector[2]);
ViewDistance = lenght(ViewVector);
ViewDistance = length(ViewVector);
ViewVector = normalize(ViewVector);
}

View File

@@ -862,10 +862,15 @@ void BKE_mask_calc_handle_point_auto(Mask *mask, MaskSpline *spline, MaskSplineP
MaskSplinePoint *prev_point, *next_point;
const char h_back[2] = {point->bezt.h1, point->bezt.h2};
int i1=999, i2=999;
BKE_mask_get_handle_point_adjacent(mask, spline, point,
&prev_point, &next_point);
if (prev_point) i1 = (int)(prev_point - spline->points);
if (next_point) i2 = (int)(next_point - spline->points);
printf("found points %d %d : %d\n", i1, i2, (int)(point - spline->points));
point->bezt.h1 = HD_AUTO;
point->bezt.h2 = HD_AUTO;
mask_calc_point_handle(point, prev_point, next_point);
@@ -897,6 +902,34 @@ void BKE_mask_calc_handle_point_auto(Mask *mask, MaskSpline *spline, MaskSplineP
enforce_dist_v2_v2fl(point->bezt.vec[2], point->bezt.vec[1], length_average);
}
}
mask_calc_point_handle(point, prev_point, next_point);
// XXX
if ((point->bezt.h1 == HD_ALIGN || point->bezt.h2 == HD_ALIGN) ){
float vec[2];
sub_v2_v2(point->bezt.vec[0], point->bezt.vec[1]);
sub_v2_v2(point->bezt.vec[2], point->bezt.vec[1]);
copy_v2_v2(vec, point->bezt.vec[0]);
point->bezt.vec[0][0] = vec[1];
point->bezt.vec[0][0] = -vec[0];
add_v2_v2(point->bezt.vec[0], point->bezt.vec[1]);
copy_v2_v2(vec, point->bezt.vec[2]);
point->bezt.vec[2][0] = vec[1];
point->bezt.vec[2][0] = -vec[0];
add_v2_v2(point->bezt.vec[2], point->bezt.vec[1]);
copy_v2_v2(vec, point->bezt.vec[2]);
copy_v2_v2(point->bezt.vec[0], vec);
copy_v2_v2(point->bezt.vec[2], point->bezt.vec[0]);
}
mask_calc_point_handle(point, prev_point, next_point);
}
void BKE_mask_calc_handles(Mask *mask)

View File

@@ -127,6 +127,7 @@ void GeometryExporter::operator()(Object *ob)
createVertexColorSource(geom_id, me);
// <vertices>
COLLADASW::Vertices verts(mSW);
verts.setId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::VERTEX));
COLLADASW::InputList &input_list = verts.getInputList();
@@ -134,6 +135,8 @@ void GeometryExporter::operator()(Object *ob)
input_list.push_back(input);
verts.add();
createLooseEdgeList(ob, me, geom_id, norind);
// XXX slow
if (ob->totcol) {
for (int a = 0; a < ob->totcol; a++) {
@@ -149,7 +152,7 @@ void GeometryExporter::operator()(Object *ob)
if (me->flag & ME_TWOSIDED) {
mSW->appendTextBlock("<extra><technique profile=\"MAYA\"><double_sided>1</double_sided></technique></extra>");
}
closeGeometry();
if (this->export_settings->apply_modifiers)
@@ -157,11 +160,65 @@ void GeometryExporter::operator()(Object *ob)
BKE_libblock_free_us(&(G.main->mesh), me);
}
#if 0
dm->release(dm);
#endif
}
void GeometryExporter::createLooseEdgeList(Object *ob,
Mesh *me,
std::string& geom_id,
std::vector<Face>& norind)
{
MEdge *medges = me->medge;
int totedges = me->totedge;
int edges_in_linelist = 0;
std::vector<unsigned int> edge_list;
int index;
// Find all loose edges in Mesh
// and save vertex indices in edge_list
for (index = 0; index < totedges; index++)
{
MEdge *edge = &medges[index];
if (edge->flag & ME_LOOSEEDGE)
{
edges_in_linelist += 1;
edge_list.push_back(edge->v1);
edge_list.push_back(edge->v2);
}
}
if (edges_in_linelist > 0)
{
// Create the list of loose edges
COLLADASW::Lines lines(mSW);
lines.setCount(edges_in_linelist);
COLLADASW::InputList &til = lines.getInputList();
// creates <input> in <lines> for vertices
COLLADASW::Input input1(COLLADASW::InputSemantic::VERTEX, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::VERTEX), 0);
til.push_back(input1);
lines.prepareToAppendValues();
for (index = 0; index < edges_in_linelist; index++)
{
lines.appendValues(edge_list[2*index+1]);
lines.appendValues(edge_list[2*index]);
}
lines.finish();
}
}
// powerful because it handles both cases when there is material and when there's not
void GeometryExporter::createPolylist(short material_index,
bool has_uvs,
@@ -247,6 +304,8 @@ void GeometryExporter::createPolylist(short material_index,
// performs the actual writing
polylist.prepareToAppendValues();
// <p>
int texindex = 0;

View File

@@ -64,6 +64,11 @@ public:
void operator()(Object *ob);
void createLooseEdgeList(Object *ob,
Mesh *me,
std::string& geom_id,
std::vector<Face>& norind);
// powerful because it handles both cases when there is material and when there's not
void createPolylist(short material_index,
bool has_uvs,

View File

@@ -52,6 +52,7 @@ extern "C" {
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_string.h"
#include "BLI_edgehash.h"
#include "MEM_guardedalloc.h"
}
@@ -262,7 +263,7 @@ void MeshImporter::print_index_list(COLLADAFW::IndexList& index_list)
}
#endif
bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh) // checks if mesh has supported primitive types: polylist, triangles, triangle_fans
bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh) // checks if mesh has supported primitive types: lines, polylist, triangles, triangle_fans
{
COLLADAFW::MeshPrimitiveArray& prim_arr = mesh->getMeshPrimitives();
@@ -291,6 +292,12 @@ bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh) // checks if mesh has sup
}
}
else if ( type == COLLADAFW::MeshPrimitive::LINES )
{
// TODO: Add Checker for line syntax here
}
else if (type != COLLADAFW::MeshPrimitive::TRIANGLES && type!= COLLADAFW::MeshPrimitive::TRIANGLE_FANS) {
fprintf(stderr, "Primitive type %s is not supported.\n", type_str);
return false;
@@ -409,14 +416,202 @@ int MeshImporter::count_new_tris(COLLADAFW::Mesh *mesh, Mesh *me)
return tottri;
}
// =====================================================================
// condition 1: The Primitive has normals
// condition 2: The number of normals equals the number of faces.
// return true if both conditions apply.
// return false otherwise.
// =====================================================================
bool MeshImporter::primitive_has_useable_normals(COLLADAFW::MeshPrimitive *mp) {
bool has_useable_normals = false;
int normals_count = mp->getNormalIndices().getCount();
if (normals_count > 0) {
int index_count = mp->getPositionIndices().getCount();
if (index_count == normals_count)
has_useable_normals = true;
else {
fprintf(stderr,
"Warning: Number of normals %d is different from the number of vertices %d, skipping normals\n",
normals_count, index_count );
}
}
return has_useable_normals;
}
// =====================================================================
// Assume that only TRIANGLES, TRIANGLE_FANS, POLYLIST and POLYGONS
// have faces. (to be verified)
// =====================================================================
bool MeshImporter::primitive_has_faces(COLLADAFW::MeshPrimitive *mp) {
bool has_faces = false;
int type = mp->getPrimitiveType();
switch (type) {
case COLLADAFW::MeshPrimitive::TRIANGLES:
case COLLADAFW::MeshPrimitive::TRIANGLE_FANS:
case COLLADAFW::MeshPrimitive::POLYLIST:
case COLLADAFW::MeshPrimitive::POLYGONS: {
has_faces = true;
break;
}
default: {
has_faces = false;
break;
}
}
return has_faces;
}
// =================================================================
// Return the number of faces by summing up
// the facecounts of the parts.
// hint: This is done because mesh->getFacesCount() does
// count loose edges as extra faces, which is not what we want here.
// =================================================================
void MeshImporter::allocate_face_data(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) {
COLLADAFW::MeshPrimitiveArray& prim_arr = mesh->getMeshPrimitives();
int total_facecount = 0;
// collect edge_count and face_count from all parts
for (int i = 0; i < prim_arr.getCount(); i++) {
COLLADAFW::MeshPrimitive *mp = prim_arr[i];
int type = mp->getPrimitiveType();
switch (type) {
case COLLADAFW::MeshPrimitive::TRIANGLES:
case COLLADAFW::MeshPrimitive::TRIANGLE_FANS:
case COLLADAFW::MeshPrimitive::POLYLIST:
case COLLADAFW::MeshPrimitive::POLYGONS: {
size_t prim_totface = mp->getFaceCount();
total_facecount += prim_totface;
break;
}
default: break;
}
}
// allocate space for faces
if (total_facecount > 0) {
me->totface = total_facecount + new_tris;
me->mface = (MFace*)CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, me->totface);
}
}
unsigned int MeshImporter::get_loose_edge_count(COLLADAFW::Mesh *mesh) {
COLLADAFW::MeshPrimitiveArray& prim_arr = mesh->getMeshPrimitives();
int loose_edge_count = 0;
// collect edge_count and face_count from all parts
for (int i = 0; i < prim_arr.getCount(); i++) {
COLLADAFW::MeshPrimitive *mp = prim_arr[i];
int type = mp->getPrimitiveType();
switch (type) {
case COLLADAFW::MeshPrimitive::LINES: {
size_t prim_totface = mp->getFaceCount();
loose_edge_count += prim_totface;
break;
}
default: break;
}
}
return loose_edge_count;
}
// =================================================================
// This functin is copied from source/blender/editors/mesh/mesh_data.c
//
// TODO: (As discussed with sergey-) :
// Maybe move this function to blenderkernel/intern/mesh.c
// and add definition to BKE_mesh.c
// =================================================================
void MeshImporter::mesh_add_edges(Mesh *mesh, int len)
{
CustomData edata;
MEdge *medge;
int i, totedge;
if (len == 0)
return;
totedge = mesh->totedge + len;
/* update customdata */
CustomData_copy(&mesh->edata, &edata, CD_MASK_MESH, CD_DEFAULT, totedge);
CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge);
if (!CustomData_has_layer(&edata, CD_MEDGE))
CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
CustomData_free(&mesh->edata, mesh->totedge);
mesh->edata = edata;
mesh_update_customdata_pointers(mesh, FALSE); /* new edges don't change tessellation */
/* set default flags */
medge = &mesh->medge[mesh->totedge];
for (i = 0; i < len; i++, medge++)
medge->flag = ME_EDGEDRAW | ME_EDGERENDER | SELECT;
mesh->totedge = totedge;
}
// =================================================================
// Read all loose edges.
// Important: This function assumes that all edges from existing
// faces have allready been generated and added to me->medge
// So this function MUST be called after read_faces() (see below)
// =================================================================
void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh *me)
{
unsigned int loose_edge_count = get_loose_edge_count(mesh);
if(loose_edge_count > 0) {
unsigned int face_edge_count = me->totedge;
unsigned int total_edge_count = loose_edge_count + face_edge_count;
mesh_add_edges(me, loose_edge_count);
MEdge *med = me->medge + face_edge_count;
COLLADAFW::MeshPrimitiveArray& prim_arr = mesh->getMeshPrimitives();
for (int i = 0; i < prim_arr.getCount(); i++) {
COLLADAFW::MeshPrimitive *mp = prim_arr[i];
int type = mp->getPrimitiveType();
if (type == COLLADAFW::MeshPrimitive::LINES)
{
unsigned int edge_count = mp->getFaceCount();
unsigned int *indices = mp->getPositionIndices().getData();
for (int i = 0; i < edge_count; i++, med++) {
med->bweight= 0;
med->crease = 0;
med->flag = 0;
med->v1 = indices[ 2*i ];
med->v2 = indices[ 2*i + 1];
}
}
}
}
}
// =======================================================================
// Read all faces from TRIANGLES, TRIANGLE_FANS, POLYLIST, POLYGON
// Important: This function MUST be called before read_lines()
// Otherwise we will loose all edges from faces (see read_lines() above)
//
// TODO: import uv set names
// ========================================================================
void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //TODO:: Refactor. Possibly replace by iterators
{
unsigned int i;
// allocate faces
me->totface = mesh->getFacesCount() + new_tris;
me->mface = (MFace*)CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, me->totface);
allocate_face_data(mesh, me, new_tris);
// allocate UV Maps
unsigned int totuvset = mesh->getUVCoords().getInputInfosArray().getCount();
@@ -451,7 +646,6 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
COLLADAFW::MeshPrimitiveArray& prim_arr = mesh->getMeshPrimitives();
bool has_normals = mesh->hasNormals();
COLLADAFW::MeshVertexData& nor = mesh->getNormals();
for (i = 0; i < prim_arr.getCount(); i++) {
@@ -461,14 +655,11 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
// faces
size_t prim_totface = mp->getFaceCount();
unsigned int *indices = mp->getPositionIndices().getData();
unsigned int *nind = mp->getNormalIndices().getData();
unsigned int *nind = mp->getNormalIndices().getData();
if (has_normals && mp->getPositionIndices().getCount() != mp->getNormalIndices().getCount()) {
fprintf(stderr, "Warning: Number of normals is different from the number of vertcies, skipping normals\n");
has_normals = false;
}
bool mp_has_normals = primitive_has_useable_normals(mp);
bool mp_has_faces = primitive_has_faces(mp);
unsigned int j, k;
int type = mp->getPrimitiveType();
int index = 0;
@@ -479,20 +670,20 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
#ifdef COLLADA_DEBUG
/*
fprintf(stderr, "Primitive %d:\n", i);
for (int j = 0; j < totuvset; j++) {
for (unsigned int j = 0; j < totuvset; j++) {
print_index_list(*index_list_array[j]);
}
*/
#endif
if (type == COLLADAFW::MeshPrimitive::TRIANGLES) {
for (j = 0; j < prim_totface; j++) {
for (unsigned int j = 0; j < prim_totface; j++) {
set_face_indices(mface, indices, false);
indices += 3;
#if 0
for (k = 0; k < totuvset; k++) {
for (unsigned int k = 0; k < totuvset; k++) {
if (!index_list_array.empty() && index_list_array[k]) {
// get mtface by face index and uv set index
MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
@@ -500,7 +691,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
}
}
#else
for (k = 0; k < index_list_array.getCount(); k++) {
for (unsigned int k = 0; k < index_list_array.getCount(); k++) {
// get mtface by face index and uv set index
MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
set_face_uv(&mtface[face_index], uvs, *index_list_array[k], index, false);
@@ -509,7 +700,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
test_index_face(mface, &me->fdata, face_index, 3);
if (has_normals) {
if (mp_has_normals) {
if (!flat_face(nind, nor, 3))
mface->flag |= ME_SMOOTH;
@@ -538,7 +729,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
set_face_indices(mface, triangle_vertex_indices, false);
test_index_face(mface, &me->fdata, face_index, 3);
if (has_normals) { // vertex normals, same inplementation as for the triangles
if (mp_has_normals) { // vertex normals, same inplementation as for the triangles
// the same for vertces normals
unsigned int vertex_normal_indices[3]={first_normal, nind[1], nind[2]};
if (!flat_face(vertex_normal_indices, nor, 3))
@@ -553,7 +744,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
}
// Moving cursor to the next triangle fan.
if (has_normals)
if (mp_has_normals)
nind += 2;
indices += 2;
@@ -562,8 +753,8 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
else if (type == COLLADAFW::MeshPrimitive::POLYLIST || type == COLLADAFW::MeshPrimitive::POLYGONS) {
COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons*)mp;
COLLADAFW::Polygons::VertexCountArray& vcounta = mpvc->getGroupedVerticesVertexCountArray();
for (j = 0; j < prim_totface; j++) {
for (unsigned int j = 0; j < prim_totface; j++) {
// face
int vcount = vcounta[j];
@@ -573,9 +764,9 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
// set mtface for each uv set
// it is assumed that all primitives have equal number of UV sets
#if 0
for (k = 0; k < totuvset; k++) {
for (unsigned int k = 0; k < totuvset; k++) {
if (!index_list_array.empty() && index_list_array[k]) {
// get mtface by face index and uv set index
MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
@@ -583,7 +774,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
}
}
#else
for (k = 0; k < index_list_array.getCount(); k++) {
for (unsigned int k = 0; k < index_list_array.getCount(); k++) {
// get mtface by face index and uv set index
MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
set_face_uv(&mtface[face_index], uvs, *index_list_array[k], index, vcount == 4);
@@ -592,7 +783,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
test_index_face(mface, &me->fdata, face_index, vcount);
if (has_normals) {
if (mp_has_normals) {
if (!flat_face(nind, nor, vcount))
mface->flag |= ME_SMOOTH;
@@ -608,8 +799,8 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
std::vector<unsigned int> tri;
triangulate_poly(indices, vcount, me->mvert, tri);
for (k = 0; k < tri.size() / 3; k++) {
for (unsigned int k = 0; k < tri.size() / 3; k++) {
int v = k * 3;
unsigned int uv_indices[3] = {
index + tri[v],
@@ -645,7 +836,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
test_index_face(mface, &me->fdata, face_index, 3);
if (has_normals) {
if (mp_has_normals) {
unsigned int ntri[3] = {nind[tri[v]], nind[tri[v + 1]], nind[tri[v + 2]]};
if (!flat_face(ntri, nor, 3))
@@ -657,7 +848,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
prim.totface++;
}
if (has_normals)
if (mp_has_normals)
nind += vcount;
}
@@ -665,8 +856,13 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
indices += vcount;
}
}
mat_prim_map[mp->getMaterialId()].push_back(prim);
else if (type == COLLADAFW::MeshPrimitive::LINES)
{
continue; // read the lines later after all the rest is done
}
if (mp_has_faces)
mat_prim_map[mp->getMaterialId()].push_back(prim);
}
geom_uid_mat_mapping_map[mesh->getUniqueId()] = mat_prim_map;
@@ -978,5 +1174,9 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry* geom)
BKE_mesh_make_edges(me, 0);
// read_lines() must be called after the face edges have been generated.
// Oterwise the loose edges will be silently deleted again.
read_lines(mesh, me);
return true;
}

View File

@@ -50,6 +50,10 @@
#include "ArmatureImporter.h"
#include "collada_utils.h"
extern "C" {
#include "BLI_edgehash.h"
}
// only for ArmatureImporter to "see" MeshImporter::get_object_by_geom_uid
class MeshImporterBase
{
@@ -118,8 +122,20 @@ private:
int count_new_tris(COLLADAFW::Mesh *mesh, Mesh *me);
bool primitive_has_useable_normals(COLLADAFW::MeshPrimitive *mp);
bool primitive_has_faces(COLLADAFW::MeshPrimitive *mp);
static void mesh_add_edges(Mesh *mesh, int len);
unsigned int get_loose_edge_count(COLLADAFW::Mesh *mesh);
CustomData create_edge_custom_data(EdgeHash *eh);
void allocate_face_data(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris);
// TODO: import uv set names
void read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris);
void read_lines(COLLADAFW::Mesh *mesh, Mesh *me);
void get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i, int stride);

View File

@@ -267,6 +267,18 @@ void ED_mesh_mirrtopo_init(struct Mesh *me, const int ob_mode, MirrTopoStore_t *
const short skip_em_vert_array_init);
void ED_mesh_mirrtopo_free(MirrTopoStore_t *mesh_topo_store);
/* mesh backup */
typedef struct BMBackup {
struct BMesh *bmcopy;
} BMBackup;
/* save a copy of the bmesh for restoring later */
struct BMBackup EDBM_redo_state_store(struct BMEditMesh *em);
/* restore a bmesh from backup */
void EDBM_redo_state_restore(struct BMBackup, struct BMEditMesh *em, int recalctess);
/* delete the backup, optionally flushing it to an editmesh */
void EDBM_redo_state_free(struct BMBackup *, struct BMEditMesh *em, int recalctess);
#ifdef __cplusplus
}
#endif

View File

@@ -101,7 +101,7 @@ enum {
* returns 1 if successful, 0 otherwise (usually means there's no selection)
* (if 0 is returns, *vec is unmodified)
* */
int calculateTransformCenter(struct bContext *C, int centerMode, float *vec);
int calculateTransformCenter(struct bContext *C, int centerMode, float *cent3d, int *cent2d);
struct TransInfo;
struct ScrArea;

View File

@@ -1344,7 +1344,8 @@ void MESH_OT_flip_normals(wmOperatorType *ot)
static const EnumPropertyItem direction_items[] = {
{DIRECTION_CW, "CW", 0, "Clockwise", ""},
{DIRECTION_CCW, "CCW", 0, "Counter Clockwise", ""},
{0, NULL, 0, NULL, NULL}};
{0, NULL, 0, NULL, NULL}
};
/* only accepts 1 selected edge, or 2 selected faces */
static int edbm_edge_rotate_selected_exec(bContext *C, wmOperator *op)
@@ -1957,7 +1958,8 @@ static EnumPropertyItem merge_type_items[] = {
{3, "CENTER", 0, "At Center", ""},
{4, "CURSOR", 0, "At Cursor", ""},
{5, "COLLAPSE", 0, "Collapse", ""},
{0, NULL, 0, NULL, NULL}};
{0, NULL, 0, NULL, NULL}
};
static EnumPropertyItem *merge_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free)
{
@@ -2377,13 +2379,15 @@ void MESH_OT_select_axis(wmOperatorType *ot)
{0, "POSITIVE", 0, "Positive Axis", ""},
{1, "NEGATIVE", 0, "Negative Axis", ""},
{-1, "ALIGNED", 0, "Aligned Axis", ""},
{0, NULL, 0, NULL, NULL}};
{0, NULL, 0, NULL, NULL}
};
static EnumPropertyItem axis_items_xyz[] = {
{0, "X_AXIS", 0, "X Axis", ""},
{1, "Y_AXIS", 0, "Y Axis", ""},
{2, "Z_AXIS", 0, "Z Axis", ""},
{0, NULL, 0, NULL, NULL}};
{0, NULL, 0, NULL, NULL}
};
/* identifiers */
ot->name = "Select Axis";
@@ -2685,7 +2689,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op)
}
/* get the cut curve */
RNA_BEGIN (op->ptr, itemptr, "path")
RNA_BEGIN(op->ptr, itemptr, "path")
{
RNA_float_get_array(&itemptr, "loc", (float *)&curve[len]);
len++;
@@ -3566,7 +3570,8 @@ void MESH_OT_select_by_number_vertices(wmOperatorType *ot)
{1, "EQUAL", 0, "Equal To", ""},
{2, "GREATER", 0, "Greater Than", ""},
{3, "NOTEQUAL", 0, "Not Equal To", ""},
{0, NULL, 0, NULL, NULL}};
{0, NULL, 0, NULL, NULL}
};
/* identifiers */
ot->name = "Select by Number of Vertices";
@@ -3889,12 +3894,12 @@ static void sort_bmelem_flag(bContext *C, const int types, const int flag, const
mp = map[0] = MEM_callocN(sizeof(int) * totelem[0], "sort_bmelem vert map");
BM_ITER_MESH_INDEX (ve, &iter, em->bm, BM_VERTS_OF_MESH, i) {
if (BM_elem_flag_test(ve, flag)) {
mp[affected[0]++] = i;
}
else {
*tb = i;
tb++;
if (BM_elem_flag_test(ve, flag)) {
mp[affected[0]++] = i;
}
else {
*tb = i;
tb++;
}
}
}
@@ -3904,12 +3909,12 @@ static void sort_bmelem_flag(bContext *C, const int types, const int flag, const
mp = map[1] = MEM_callocN(sizeof(int) * totelem[1], "sort_bmelem edge map");
BM_ITER_MESH_INDEX (ed, &iter, em->bm, BM_EDGES_OF_MESH, i) {
if (BM_elem_flag_test(ed, flag)) {
mp[affected[1]++] = i;
}
else {
*tb = i;
tb++;
if (BM_elem_flag_test(ed, flag)) {
mp[affected[1]++] = i;
}
else {
*tb = i;
tb++;
}
}
}
@@ -3919,17 +3924,17 @@ static void sort_bmelem_flag(bContext *C, const int types, const int flag, const
mp = map[2] = MEM_callocN(sizeof(int) * totelem[2], "sort_bmelem face map");
BM_ITER_MESH_INDEX (fa, &iter, em->bm, BM_FACES_OF_MESH, i) {
if (BM_elem_flag_test(fa, flag)) {
mp[affected[2]++] = i;
}
else {
*tb = i;
tb++;
if (BM_elem_flag_test(fa, flag)) {
mp[affected[2]++] = i;
}
else {
*tb = i;
tb++;
}
}
}
for (j = 3; j--;) {
for (j = 3; j--; ) {
int tot = totelem[j];
int aff = affected[j];
tb = tbuf[j];
@@ -4069,7 +4074,7 @@ static void sort_bmelem_flag(bContext *C, const int types, const int flag, const
/* printf("%d edges: %d to be affected…\n", totelem[1], affected[1]);*/
/* printf("%d faces: %d to be affected…\n", totelem[2], affected[2]);*/
if (affected[0] == 0 && affected[1] == 0 && affected[2] == 0) {
for (j = 3; j--;) {
for (j = 3; j--; ) {
if (pblock[j])
MEM_freeN(pblock[j]);
if (sblock[j])
@@ -4081,7 +4086,7 @@ static void sort_bmelem_flag(bContext *C, const int types, const int flag, const
}
/* Sort affected elements, and populate mapping arrays, if needed. */
for (j = 3; j--;) {
for (j = 3; j--; ) {
pb = pblock[j];
sb = sblock[j];
if (pb && sb && !map[j]) {
@@ -4114,7 +4119,7 @@ static void sort_bmelem_flag(bContext *C, const int types, const int flag, const
BM_mesh_remap(em->bm, map[0], map[1], map[2]);
/* DAG_id_tag_update(ob->data, 0);*/
for (j = 3; j--;) {
for (j = 3; j--; ) {
if (map[j])
MEM_freeN(map[j]);
}
@@ -4303,21 +4308,79 @@ void MESH_OT_noise(wmOperatorType *ot)
RNA_def_float(ot->srna, "factor", 0.1f, -FLT_MAX, FLT_MAX, "Factor", "", 0.0f, 1.0f);
}
/* bevel! yay!!*/
static int edbm_bevel_exec(bContext *C, wmOperator *op)
typedef struct {
BMEditMesh *em;
BMBackup mesh_backup;
float *weights;
int li;
int mcenter[2];
float initial_length;
int is_modal;
} BevelData;
#define HEADER_LENGTH 180
static void edbm_bevel_update_header(wmOperator *op, bContext *C)
{
static char str[] = "Confirm: Enter/LClick, Cancel: (Esc/RClick), factor: %f, , Use Dist (D): %s: Use Even (E): %s";
char msg[HEADER_LENGTH];
ScrArea *sa = CTX_wm_area(C);
if (sa) {
BLI_snprintf(msg, HEADER_LENGTH, str,
RNA_float_get(op->ptr, "percent"),
RNA_boolean_get(op->ptr, "use_dist") ? "On" : "Off",
RNA_boolean_get(op->ptr, "use_even") ? "On" : "Off"
);
ED_area_headerprint(sa, msg);
}
}
static void edbm_bevel_recalc_weights(wmOperator *op)
{
float df, s, ftot;
int i;
int recursion = 1; /* RNA_int_get(op->ptr, "recursion"); */ /* temp removed, see comment below */
BevelData *opdata = op->customdata;
if (opdata->weights) {
/* TODO should change to free only when new recursion is greater than old */
MEM_freeN(opdata->weights);
}
opdata->weights = MEM_mallocN(sizeof(float) * recursion, "bevel weights");
/* ugh, stupid math depends somewhat on angles!*/
/* dfac = 1.0/(float)(recursion + 1); */ /* UNUSED */
df = 1.0;
for (i = 0, ftot = 0.0f; i < recursion; i++) {
s = powf(df, 1.25f);
opdata->weights[i] = s;
ftot += s;
df *= 2.0f;
}
mul_vn_fl(opdata->weights, recursion, 1.0f / (float)ftot);
}
static int edbm_bevel_init(bContext *C, wmOperator *op, int is_modal)
{
Object *obedit = CTX_data_edit_object(C);
BMEditMesh *em = BMEdit_FromObject(obedit);
BMIter iter;
BMEdge *eed;
BMOperator bmop;
float factor = RNA_float_get(op->ptr, "percent") /*, dfac */ /* UNUSED */, df, s;
int i, recursion = 1; /* RNA_int_get(op->ptr, "recursion"); */ /* temp removed, see comment below */
const int use_even = RNA_boolean_get(op->ptr, "use_even");
const int use_dist = RNA_boolean_get(op->ptr, "use_dist");
float *w = NULL, ftot;
BevelData *opdata;
int li;
if (em == NULL) {
return 0;
}
op->customdata = opdata = MEM_mallocN(sizeof(BevelData), "beveldata_mesh_operator");
BM_data_layer_add(em->bm, &em->bm->edata, CD_PROP_FLT);
li = CustomData_number_of_layers(&em->bm->edata, CD_PROP_FLT) - 1;
@@ -4328,52 +4391,201 @@ static int edbm_bevel_exec(bContext *C, wmOperator *op)
*dv = d;
}
if (em == NULL) {
return OPERATOR_CANCELLED;
}
opdata->em = em;
opdata->li = li;
opdata->weights = NULL;
opdata->is_modal = is_modal;
w = MEM_mallocN(sizeof(float) * recursion, "bevel weights");
/* avoid the cost of allocating a bm copy */
if (is_modal)
opdata->mesh_backup = EDBM_redo_state_store(em);
edbm_bevel_recalc_weights(op);
/* ugh, stupid math depends somewhat on angles!*/
/* dfac = 1.0/(float)(recursion + 1); */ /* UNUSED */
df = 1.0;
for (i = 0, ftot = 0.0f; i < recursion; i++) {
s = powf(df, 1.25f);
return 1;
}
w[i] = s;
ftot += s;
static int edbm_bevel_calc(bContext *C, wmOperator *op)
{
BevelData *opdata = op->customdata;
BMEditMesh *em = opdata->em;
BMOperator bmop;
int i;
df *= 2.0f;
float factor = RNA_float_get(op->ptr, "percent") /*, dfac */ /* UNUSED */;
int recursion = 1; /* RNA_int_get(op->ptr, "recursion"); */ /* temp removed, see comment below */
const int use_even = RNA_boolean_get(op->ptr, "use_even");
const int use_dist = RNA_boolean_get(op->ptr, "use_dist");
/* revert to original mesh */
if (opdata->is_modal) {
EDBM_redo_state_restore(opdata->mesh_backup, em, FALSE);
}
mul_vn_fl(w, recursion, 1.0f / (float)ftot);
for (i = 0; i < recursion; i++) {
float fac = w[recursion - i - 1] * factor;
float fac = opdata->weights[recursion - i - 1] * factor;
if (!EDBM_op_init(em, &bmop, op,
"bevel geom=%hev percent=%f lengthlayer=%i use_lengths=%b use_even=%b use_dist=%b",
BM_ELEM_SELECT, fac, li, TRUE, use_even, use_dist))
BM_ELEM_SELECT, fac, opdata->li, TRUE, use_even, use_dist))
{
return OPERATOR_CANCELLED;
return 0;
}
BMO_op_exec(em->bm, &bmop);
if (!EDBM_op_finish(em, &bmop, op, TRUE))
return OPERATOR_CANCELLED;
return 0;
}
BM_data_layer_free_n(em->bm, &em->bm->edata, CD_PROP_FLT, li);
EDBM_mesh_normals_update(opdata->em);
MEM_freeN(w);
EDBM_update_generic(C, opdata->em, TRUE);
EDBM_mesh_normals_update(em);
return 1;
}
EDBM_update_generic(C, em, TRUE);
static void edbm_bevel_exit(bContext *C, wmOperator *op)
{
BevelData *opdata = op->customdata;
ScrArea *sa = CTX_wm_area(C);
if (sa) {
ED_area_headerprint(sa, NULL);
}
BM_data_layer_free_n(opdata->em->bm, &opdata->em->bm->edata, CD_PROP_FLT, opdata->li);
if (opdata->weights)
MEM_freeN(opdata->weights);
if (opdata->is_modal) {
EDBM_redo_state_free(&opdata->mesh_backup, NULL, FALSE);
}
MEM_freeN(opdata);
op->customdata = NULL;
}
static int edbm_bevel_cancel(bContext *C, wmOperator *op)
{
BevelData *opdata = op->customdata;
if (opdata->is_modal) {
EDBM_redo_state_free(&opdata->mesh_backup, opdata->em, TRUE);
EDBM_update_generic(C, opdata->em, FALSE);
}
edbm_bevel_exit(C, op);
/* need to force redisplay or we may still view the modified result */
ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_CANCELLED;
}
/* bevel! yay!!*/
static int edbm_bevel_exec(bContext *C, wmOperator *op)
{
if (!edbm_bevel_init(C, op, FALSE)) {
edbm_bevel_exit(C, op);
return OPERATOR_CANCELLED;
}
if (!edbm_bevel_calc(C, op)) {
edbm_bevel_cancel(C, op);
return OPERATOR_CANCELLED;
}
edbm_bevel_exit(C, op);
return OPERATOR_FINISHED;
}
static int edbm_bevel_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
/* TODO make modal keymap (see fly mode) */
BevelData *opdata;
float mlen[2];
if (!edbm_bevel_init(C, op, TRUE))
return OPERATOR_CANCELLED;
/* initialize mouse values */
opdata = op->customdata;
calculateTransformCenter(C, V3D_CENTROID, NULL, opdata->mcenter);
mlen[0] = opdata->mcenter[0] - event->mval[0];
mlen[1] = opdata->mcenter[1] - event->mval[1];
opdata->initial_length = len_v2(mlen);
edbm_bevel_update_header(op, C);
if (!edbm_bevel_calc(C, op)) {
edbm_bevel_cancel(C, op);
return OPERATOR_CANCELLED;
}
WM_event_add_modal_handler(C, op);
return OPERATOR_RUNNING_MODAL;
}
static int edbm_bevel_modal(bContext *C, wmOperator *op, wmEvent *event)
{
BevelData *opdata = op->customdata;
// Scene *scene = CTX_data_scene(C);
switch (event->type) {
case ESCKEY:
case RIGHTMOUSE:
edbm_bevel_cancel(C, op);
return OPERATOR_CANCELLED;
case MOUSEMOVE:
{
float factor;
float mdiff[2];
mdiff[0] = opdata->mcenter[0] - event->mval[0];
mdiff[1] = opdata->mcenter[1] - event->mval[1];
factor = len_v2(mdiff) / opdata->initial_length;
factor = MAX2(1.0 - factor, 0.0);
RNA_float_set(op->ptr, "percent", factor);
edbm_bevel_calc(C, op);
edbm_bevel_update_header(op, C);
return OPERATOR_RUNNING_MODAL;
}
case LEFTMOUSE:
case PADENTER:
case RETKEY:
edbm_bevel_calc(C, op);
edbm_bevel_exit(C, op);
return OPERATOR_FINISHED;
case EKEY:
if (event->val == KM_PRESS) {
int use_even = RNA_boolean_get(op->ptr, "use_even");
RNA_boolean_set(op->ptr, "use_even", !use_even);
edbm_bevel_calc(C, op);
edbm_bevel_update_header(op, C);
}
return OPERATOR_RUNNING_MODAL;
case DKEY:
if (event->val == KM_PRESS) {
int use_dist = RNA_boolean_get(op->ptr, "use_dist");
RNA_boolean_set(op->ptr, "use_dist", !use_dist);
edbm_bevel_calc(C, op);
edbm_bevel_update_header(op, C);
}
return OPERATOR_RUNNING_MODAL;
}
return OPERATOR_RUNNING_MODAL;
}
void MESH_OT_bevel(wmOperatorType *ot)
{
/* identifiers */
@@ -4383,12 +4595,15 @@ void MESH_OT_bevel(wmOperatorType *ot)
/* api callbacks */
ot->exec = edbm_bevel_exec;
ot->invoke = edbm_bevel_invoke;
ot->modal = edbm_bevel_modal;
ot->cancel = edbm_bevel_cancel;
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_float(ot->srna, "percent", 0.5f, -FLT_MAX, FLT_MAX, "Percentage", "", 0.0f, 1.0f);
RNA_def_float(ot->srna, "percent", 0.0f, -FLT_MAX, FLT_MAX, "Percentage", "", 0.0f, 1.0f);
// XXX, disabled for 2.63 release, needs to work much better without overlap before we can give to users.
// RNA_def_int(ot->srna, "recursion", 1, 1, 50, "Recursion Level", "Recursion Level", 1, 8);
@@ -4427,20 +4642,112 @@ void MESH_OT_bridge_edge_loops(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "inside", 0, "Inside", "");
}
typedef struct {
float old_thickness;
float old_depth;
int mcenter[2];
int modify_depth;
int is_modal;
float initial_length;
BMBackup backup;
BMEditMesh *em;
} InsetData;
static int edbm_inset_exec(bContext *C, wmOperator *op)
static void edbm_inset_update_header(wmOperator *op, bContext *C)
{
InsetData *opdata = op->customdata;
static char str[] = "Confirm: Enter/LClick, Cancel: (Esc/RClick), thickness: %f, depth (Ctrl to tweak): %f (%s), Outset (O): (%s)";
char msg[HEADER_LENGTH];
ScrArea *sa = CTX_wm_area(C);
if (sa) {
BLI_snprintf(msg, HEADER_LENGTH, str,
RNA_float_get(op->ptr, "thickness"),
RNA_float_get(op->ptr, "depth"),
opdata->modify_depth ? "On" : "Off",
RNA_boolean_get(op->ptr, "use_outset") ? "On" : "Off"
);
ED_area_headerprint(sa, msg);
}
}
static int edbm_inset_init(bContext *C, wmOperator *op, int is_modal)
{
InsetData *opdata;
Object *obedit = CTX_data_edit_object(C);
BMEditMesh *em = BMEdit_FromObject(obedit);
op->customdata = opdata = MEM_mallocN(sizeof(InsetData), "inset_operator_data");
opdata->old_thickness = 0.01;
opdata->old_depth = 0.0;
opdata->modify_depth = FALSE;
opdata->is_modal = is_modal;
opdata->em = em;
if (is_modal)
opdata->backup = EDBM_redo_state_store(em);
return 1;
}
static void edbm_inset_exit(bContext *C, wmOperator *op)
{
InsetData *opdata;
ScrArea *sa = CTX_wm_area(C);
opdata = op->customdata;
if (opdata->is_modal)
EDBM_redo_state_free(&opdata->backup, NULL, FALSE);
if (sa) {
ED_area_headerprint(sa, NULL);
}
MEM_freeN(op->customdata);
}
static int edbm_inset_cancel(bContext *C, wmOperator *op)
{
InsetData *opdata;
opdata = op->customdata;
if (opdata->is_modal) {
EDBM_redo_state_free(&opdata->backup, opdata->em, TRUE);
EDBM_update_generic(C, opdata->em, FALSE);
}
edbm_inset_exit(C, op);
/* need to force redisplay or we may still view the modified result */
ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_CANCELLED;
}
static int edbm_inset_calc(bContext *C, wmOperator *op)
{
InsetData *opdata;
BMEditMesh *em;
BMOperator bmop;
const int use_boundary = RNA_boolean_get(op->ptr, "use_boundary");
const int use_even_offset = RNA_boolean_get(op->ptr, "use_even_offset");
const int use_relative_offset = RNA_boolean_get(op->ptr, "use_relative_offset");
const float thickness = RNA_float_get(op->ptr, "thickness");
const float depth = RNA_float_get(op->ptr, "depth");
const int use_outset = RNA_boolean_get(op->ptr, "use_outset");
const int use_select_inset = RNA_boolean_get(op->ptr, "use_select_inset"); /* not passed onto the BMO */
int use_boundary = RNA_boolean_get(op->ptr, "use_boundary");
int use_even_offset = RNA_boolean_get(op->ptr, "use_even_offset");
int use_relative_offset = RNA_boolean_get(op->ptr, "use_relative_offset");
float thickness = RNA_float_get(op->ptr, "thickness");
float depth = RNA_float_get(op->ptr, "depth");
int use_outset = RNA_boolean_get(op->ptr, "use_outset");
int use_select_inset = RNA_boolean_get(op->ptr, "use_select_inset"); /* not passed onto the BMO */
opdata = op->customdata;
em = opdata->em;
if (opdata->is_modal) {
EDBM_redo_state_restore(opdata->backup, em, FALSE);
}
EDBM_op_init(em, &bmop, op,
"inset faces=%hf use_boundary=%b use_even_offset=%b use_relative_offset=%b "
@@ -4463,14 +4770,142 @@ static int edbm_inset_exec(bContext *C, wmOperator *op)
}
if (!EDBM_op_finish(em, &bmop, op, TRUE)) {
return OPERATOR_CANCELLED;
return 0;
}
else {
EDBM_update_generic(C, em, TRUE);
return OPERATOR_FINISHED;
return 1;
}
}
static int edbm_inset_exec(bContext *C, wmOperator *op)
{
edbm_inset_init(C, op, FALSE);
if (!edbm_inset_calc(C, op)) {
edbm_inset_exit(C, op);
return OPERATOR_CANCELLED;
}
edbm_inset_exit(C, op);
return OPERATOR_FINISHED;
}
static int edbm_inset_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
InsetData *opdata;
float mlen[2];
edbm_inset_init(C, op, TRUE);
opdata = op->customdata;
calculateTransformCenter(C, V3D_CENTROID, NULL, opdata->mcenter);
/* initialize mouse values */
mlen[0] = opdata->mcenter[0] - event->mval[0];
mlen[1] = opdata->mcenter[1] - event->mval[1];
opdata->initial_length = len_v2(mlen);
edbm_inset_calc(C, op);
edbm_inset_update_header(op, C);
WM_event_add_modal_handler(C, op);
return OPERATOR_RUNNING_MODAL;
}
static int edbm_inset_modal(bContext *C, wmOperator *op, wmEvent *event)
{
InsetData *opdata;
opdata = op->customdata;
switch (event->type) {
case ESCKEY:
case RIGHTMOUSE:
edbm_inset_cancel(C, op);
return OPERATOR_CANCELLED;
case MOUSEMOVE:
{
float mdiff[2];
float amount;
mdiff[0] = opdata->mcenter[0] - event->mval[0];
mdiff[1] = opdata->mcenter[1] - event->mval[1];
if (opdata->modify_depth) {
amount = opdata->old_depth + (len_v2(mdiff)
- opdata->initial_length) / opdata->initial_length;
RNA_float_set(op->ptr, "depth", amount);
}
else {
amount = opdata->old_thickness - (len_v2(mdiff)
- opdata->initial_length) / opdata->initial_length;
amount = MAX2(amount, 0.0);
RNA_float_set(op->ptr, "thickness", amount);
}
if (edbm_inset_calc(C, op)) {
edbm_inset_update_header(op, C);
return OPERATOR_RUNNING_MODAL;
}
else {
edbm_inset_cancel(C, op);
return OPERATOR_CANCELLED;
}
}
case LEFTMOUSE:
case PADENTER:
case RETKEY:
edbm_inset_calc(C, op);
edbm_inset_exit(C, op);
return OPERATOR_FINISHED;
case LEFTCTRLKEY:
case RIGHTCTRLKEY:
{
float mlen[2];
mlen[0] = opdata->mcenter[0] - event->mval[0];
mlen[1] = opdata->mcenter[1] - event->mval[1];
if (event->val == KM_PRESS) {
opdata->old_thickness = RNA_float_get(op->ptr, "thickness");
opdata->modify_depth = TRUE;
}
else {
opdata->old_depth = RNA_float_get(op->ptr, "depth");
opdata->modify_depth = FALSE;
}
opdata->initial_length = len_v2(mlen);
edbm_inset_update_header(op, C);
return OPERATOR_RUNNING_MODAL;
}
case OKEY:
if (event->val == KM_PRESS) {
int use_outset = RNA_boolean_get(op->ptr, "use_outset");
RNA_boolean_set(op->ptr, "use_outset", !use_outset);
if (edbm_inset_calc(C, op)) {
edbm_inset_update_header(op, C);
return OPERATOR_RUNNING_MODAL;
}
else {
edbm_inset_cancel(C, op);
return OPERATOR_CANCELLED;
}
}
}
return OPERATOR_RUNNING_MODAL;
}
void MESH_OT_inset(wmOperatorType *ot)
{
PropertyRNA *prop;
@@ -4481,7 +4916,10 @@ void MESH_OT_inset(wmOperatorType *ot)
ot->description = "Inset new faces into selected faces";
/* api callbacks */
ot->invoke = edbm_inset_invoke;
ot->modal = edbm_inset_modal;
ot->exec = edbm_inset_exec;
ot->cancel = edbm_inset_cancel;
ot->poll = ED_operator_editmesh;
/* flags */
@@ -4578,9 +5016,9 @@ static int edbm_convex_hull_exec(bContext *C, wmOperator *op)
BMOperator bmop;
EDBM_op_init(em, &bmop, op, "convex_hull input=%hvef "
"use_existing_faces=%b",
BM_ELEM_SELECT,
RNA_boolean_get(op->ptr, "use_existing_faces"));
"use_existing_faces=%b",
BM_ELEM_SELECT,
RNA_boolean_get(op->ptr, "use_existing_faces"));
BMO_op_exec(em->bm, &bmop);
/* Hull fails if input is coplanar */
@@ -4647,20 +5085,20 @@ void MESH_OT_convex_hull(wmOperatorType *ot)
/* props */
RNA_def_boolean(ot->srna, "delete_unused", TRUE,
"Delete Unused",
"Delete selected elements that are not used by the hull");
"Delete Unused",
"Delete selected elements that are not used by the hull");
RNA_def_boolean(ot->srna, "use_existing_faces", TRUE,
"Use Existing Faces",
"Skip hull triangles that are covered by a pre-existing face");
"Use Existing Faces",
"Skip hull triangles that are covered by a pre-existing face");
RNA_def_boolean(ot->srna, "make_holes", FALSE,
"Make Holes",
"Delete selected faces that are used by the hull");
"Make Holes",
"Delete selected faces that are used by the hull");
RNA_def_boolean(ot->srna, "join_triangles", TRUE,
"Join Triangles",
"Merge adjacent triangles into quads");
"Join Triangles",
"Merge adjacent triangles into quads");
join_triangle_props(ot);
}

View File

@@ -58,6 +58,52 @@
#include "mesh_intern.h"
/* mesh backup implementation. This would greatly benefit from some sort of binary diffing
* just as the undo stack would. So leaving this as an interface for further work */
BMBackup EDBM_redo_state_store(BMEditMesh *em)
{
BMBackup backup;
backup.bmcopy = BM_mesh_copy(em->bm);
return backup;
}
void EDBM_redo_state_restore(BMBackup backup, BMEditMesh *em, int recalctess)
{
BMesh *tmpbm;
if (!em || !backup.bmcopy)
return;
BM_mesh_data_free(em->bm);
tmpbm = BM_mesh_copy(backup.bmcopy);
*em->bm = *tmpbm;
MEM_freeN(tmpbm);
tmpbm = NULL;
if (recalctess)
BMEdit_RecalcTessellation(em);
}
void EDBM_redo_state_free(BMBackup *backup, BMEditMesh *em, int recalctess)
{
if (em && backup->bmcopy) {
BM_mesh_data_free(em->bm);
*em->bm = *backup->bmcopy;
}
else if (backup->bmcopy) {
BM_mesh_data_free(backup->bmcopy);
}
if (backup->bmcopy)
MEM_freeN(backup->bmcopy);
backup->bmcopy = NULL;
if (recalctess && em)
BMEdit_RecalcTessellation(em);
}
void EDBM_mesh_normals_update(BMEditMesh *em)
{
BM_mesh_normals_update(em->bm, TRUE);

View File

@@ -255,6 +255,8 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
keymap->poll = ED_operator_editmesh;
WM_keymap_add_item(keymap, "MESH_OT_loopcut_slide", RKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "MESH_OT_bevel", BKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "MESH_OT_inset", IKEY, KM_PRESS, 0, 0);
/* selecting */
/* standard mouse selection goes via space_view3d */

View File

@@ -1323,7 +1323,7 @@ void SEQUENCER_OT_reload(struct wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER; /* no undo, the data changed is stored outside 'main' */
prop = RNA_def_boolean(ot->srna, "adjust_length", 0, "Adjust Length",
"Adjust lenght of strips to their data lenght");
"Adjust length of strips to their data length");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}

View File

@@ -3586,7 +3586,7 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
}
else {
/* ob->bb was set by derived mesh system, do NULL check just to be sure */
if (me->totpoly <= 4 || (ob->bb && ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb))) {
if (me->totpoly <= 4 || (!ob->bb || ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb))) {
glsl = draw_glsl_material(scene, ob, v3d, dt);
check_alpha = check_alpha_pass(base);

View File

@@ -431,7 +431,7 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event)
if (vod->use_dyn_ofs) {
/* If there's no selection, lastofs is unmodified and last value since static */
calculateTransformCenter(C, V3D_CENTROID, lastofs);
calculateTransformCenter(C, V3D_CENTROID, lastofs, NULL);
negate_v3_v3(vod->dyn_ofs, lastofs);
}
else if (U.uiflag & USER_ORBIT_ZBUF) {
@@ -1423,7 +1423,8 @@ void viewzoom_modal_keymap(wmKeyConfig *keyconf)
{VIEWROT_MODAL_SWITCH_ROTATE, "SWITCH_TO_ROTATE", 0, "Switch to Rotate"},
{VIEWROT_MODAL_SWITCH_MOVE, "SWITCH_TO_MOVE", 0, "Switch to Move"},
{0, NULL, 0, NULL, NULL}};
{0, NULL, 0, NULL, NULL}
};
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "View3D Zoom Modal");

View File

@@ -1169,7 +1169,7 @@ int transformEvent(TransInfo *t, wmEvent *event)
return OPERATOR_PASS_THROUGH;
}
int calculateTransformCenter(bContext *C, int centerMode, float *vec)
int calculateTransformCenter(bContext *C, int centerMode, float *cent3d, int *cent2d)
{
TransInfo *t = MEM_callocN(sizeof(TransInfo), "TransInfo data");
int success = 1;
@@ -1194,8 +1194,12 @@ int calculateTransformCenter(bContext *C, int centerMode, float *vec)
calculateCenter(t);
// Copy center from constraint center. Transform center can be local
copy_v3_v3(vec, t->con.center);
if(cent2d)
copy_v2_v2_int(cent2d, t->center2d);
if(cent3d) {
// Copy center from constraint center. Transform center can be local
copy_v3_v3(cent3d, t->con.center);
}
}

View File

@@ -4057,7 +4057,47 @@ static void freeSeqData(TransInfo *t)
}
}
#if 1 /* (mango hack! - for Ian) this is truely bad - should _never_ be in a release :| */
if (CTX_wm_window(t->context)->eventstate->alt) {
int minframe = MAXFRAME;
td= t->data;
seq_prev= NULL;
for (a=0; a<t->total; a++, td++) {
seq= ((TransDataSeq *)td->extra)->seq;
if ((seq != seq_prev)) {
minframe = MIN2(minframe, seq->startdisp);
}
}
for (seq= seqbasep->first; seq; seq= seq->next) {
if (!(seq->flag & SELECT)) {
if (seq->startdisp >= minframe) {
seq->machine += MAXSEQ * 2;
}
}
}
shuffle_seq_time(seqbasep, t->scene);
for (seq= seqbasep->first; seq; seq= seq->next) {
if (seq->machine >= MAXSEQ * 2) {
seq->machine -= MAXSEQ * 2;
seq->tmp= (void*)1;
}
else {
seq->tmp= NULL;
}
}
shuffle_seq_time(seqbasep, t->scene);
}
else {
shuffle_seq_time(seqbasep, t->scene);
}
#else
shuffle_seq_time(seqbasep, t->scene);
#endif
if (has_effect) {
/* update effects strips based on strips just moved in time */

View File

@@ -107,15 +107,15 @@
#endif
/* anim.curtype, runtime only */
#define ANIM_NONE 0
#define ANIM_SEQUENCE (1 << 0)
#define ANIM_MOVIE (1 << 4)
#define ANIM_AVI (1 << 6)
#define ANIM_QTIME (1 << 7)
#define ANIM_NONE 0
#define ANIM_SEQUENCE (1 << 0)
#define ANIM_MOVIE (1 << 4)
#define ANIM_AVI (1 << 6)
#define ANIM_QTIME (1 << 7)
#define ANIM_FFMPEG (1 << 8)
#define ANIM_REDCODE (1 << 9)
#define MAXNUMSTREAMS 50
#define MAXNUMSTREAMS 50
struct _AviMovie;
struct anim_index;
@@ -123,18 +123,18 @@ struct anim_index;
struct anim {
int ib_flags;
int curtype;
int curposition; /* index 0 = 1e, 1 = 2e, enz. */
int curposition; /* index 0 = 1e, 1 = 2e, enz. */
int duration;
short frs_sec;
float frs_sec_base;
int x, y;
/* voor op nummer */
/* voor op nummer */
char name[1024];
/* voor sequence */
/* voor sequence */
char first[1024];
/* movie */
/* movie */
void *movie;
void *track;
void *params;
@@ -144,21 +144,21 @@ struct anim {
int preseek;
int streamindex;
/* avi */
/* avi */
struct _AviMovie *avi;
#if defined(_WIN32) && !defined(FREE_WINDOWS)
/* windows avi */
/* windows avi */
int avistreams;
int firstvideo;
int pfileopen;
PAVIFILE pfile;
PAVISTREAM pavi[MAXNUMSTREAMS]; // the current streams
PGETFRAME pgf;
PAVIFILE pfile;
PAVISTREAM pavi[MAXNUMSTREAMS]; // the current streams
PGETFRAME pgf;
#endif
#ifdef WITH_QUICKTIME
/* quicktime */
/* quicktime */
struct _QuicktimeMovie *qtime;
#endif /* WITH_QUICKTIME */
@@ -173,14 +173,14 @@ struct anim {
struct SwsContext *img_convert_ctx;
int videoStream;
struct ImBuf * last_frame;
struct ImBuf *last_frame;
int64_t last_pts;
int64_t next_pts;
AVPacket next_packet;
#endif
#ifdef WITH_REDCODE
struct redcode_handle * redcodeCtx;
struct redcode_handle *redcodeCtx;
#endif
char index_dir[768];
@@ -188,10 +188,9 @@ struct anim {
int proxies_tried;
int indices_tried;
struct anim * proxy_anim[IMB_PROXY_MAX_SLOT];
struct anim_index * curr_idx[IMB_TC_MAX_SLOT];
struct anim *proxy_anim[IMB_PROXY_MAX_SLOT];
struct anim_index *curr_idx[IMB_TC_MAX_SLOT];
};
#endif

View File

@@ -37,8 +37,8 @@ struct ImBuf;
typedef struct ImMetaData {
struct ImMetaData *next, *prev;
char* key;
char* value;
char *key;
char *value;
int len;
} ImMetaData;
@@ -52,7 +52,7 @@ typedef struct ImMetaData {
/* free blender ImMetaData struct */
void IMB_metadata_free(struct ImBuf* img);
void IMB_metadata_free(struct ImBuf *img);
/** read the field from the image info into the field
* \param img - the ImBuf that contains the image data
@@ -62,7 +62,7 @@ void IMB_metadata_free(struct ImBuf* img);
* \param len - length of value buffer allocated by user.
* \return - 1 (true) if ImageInfo present and value for the key found, 0 (false) otherwise
*/
int IMB_metadata_get_field(struct ImBuf* img, const char* key, char* value, int len);
int IMB_metadata_get_field(struct ImBuf *img, const char *key, char *value, int len);
/** set user data in the ImMetaData struct, which has to be allocated with IMB_metadata_create
* before calling this function.
@@ -71,7 +71,7 @@ int IMB_metadata_get_field(struct ImBuf* img, const char* key, char* value, int
* \param value - the data to be written to the field. zero terminated string
* \return - 1 (true) if ImageInfo present, 0 (false) otherwise
*/
int IMB_metadata_add_field(struct ImBuf* img, const char* key, const char* value);
int IMB_metadata_add_field(struct ImBuf *img, const char *key, const char *value);
/** delete the key/field par in the ImMetaData struct.
* \param img - the ImBuf that contains the image data

View File

@@ -119,10 +119,16 @@ int ismovie(const char *UNUSED(filepath))
return 0;
}
/* never called, just keep the linker happy */
static int startmovie(struct anim *UNUSED(anim)) { return 1; }
static ImBuf * movie_fetchibuf(struct anim *UNUSED(anim), int UNUSED(position)) { return NULL; }
static void free_anim_movie(struct anim *UNUSED(anim)) { ; }
/* never called, just keep the linker happy */
static int startmovie(struct anim *UNUSED(anim)) {
return 1;
}
static ImBuf *movie_fetchibuf(struct anim *UNUSED(anim), int UNUSED(position)) {
return NULL;
}
static void free_anim_movie(struct anim *UNUSED(anim)) {
;
}
#if defined(_WIN32)
@@ -131,24 +137,24 @@ static void free_anim_movie(struct anim *UNUSED(anim)) { ; }
# define PATHSEPERATOR '/'
#endif
static int an_stringdec(const char *string, char* head, char *tail, unsigned short *numlen)
static int an_stringdec(const char *string, char *head, char *tail, unsigned short *numlen)
{
unsigned short len, nume, nums=0;
short i, found=FALSE;
unsigned short len, nume, nums = 0;
short i, found = FALSE;
len=strlen(string);
len = strlen(string);
nume = len;
for (i=len-1;i>=0;i--) {
if (string[i]==PATHSEPERATOR) break;
for (i = len - 1; i >= 0; i--) {
if (string[i] == PATHSEPERATOR) break;
if (isdigit(string[i])) {
if (found) {
nums=i;
nums = i;
}
else {
nume=i;
nums=i;
found=TRUE;
nume = i;
nums = i;
found = TRUE;
}
}
else {
@@ -156,15 +162,15 @@ static int an_stringdec(const char *string, char* head, char *tail, unsigned sho
}
}
if (found) {
strcpy(tail, &string[nume+1]);
strcpy(tail, &string[nume + 1]);
strcpy(head, string);
head[nums]= '\0';
*numlen=nume-nums+1;
head[nums] = '\0';
*numlen = nume - nums + 1;
return ((int)atoi(&(string[nums])));
}
tail[0]= '\0';
tail[0] = '\0';
strcpy(head, string);
*numlen=0;
*numlen = 0;
return TRUE;
}
@@ -174,7 +180,7 @@ static void an_stringenc(char *string, const char *head, const char *tail, unsig
BLI_stringenc(string, head, tail, numlen, pic);
}
static void free_anim_avi (struct anim *anim)
static void free_anim_avi(struct anim *anim)
{
#if defined(_WIN32) && !defined(FREE_WINDOWS)
int i;
@@ -183,8 +189,8 @@ static void free_anim_avi (struct anim *anim)
if (anim == NULL) return;
if (anim->avi == NULL) return;
AVI_close (anim->avi);
MEM_freeN (anim->avi);
AVI_close(anim->avi);
MEM_freeN(anim->avi);
anim->avi = NULL;
#if defined(_WIN32) && !defined(FREE_WINDOWS)
@@ -210,13 +216,13 @@ static void free_anim_avi (struct anim *anim)
}
#ifdef WITH_FFMPEG
static void free_anim_ffmpeg(struct anim * anim);
static void free_anim_ffmpeg(struct anim *anim);
#endif
#ifdef WITH_REDCODE
static void free_anim_redcode(struct anim * anim);
static void free_anim_redcode(struct anim *anim);
#endif
void IMB_free_anim(struct anim * anim)
void IMB_free_anim(struct anim *anim)
{
if (anim == NULL) {
printf("free anim, anim == NULL\n");
@@ -240,7 +246,7 @@ void IMB_free_anim(struct anim * anim)
MEM_freeN(anim);
}
void IMB_close_anim(struct anim * anim)
void IMB_close_anim(struct anim *anim)
{
if (anim == NULL) return;
@@ -255,11 +261,10 @@ void IMB_close_anim_proxies(struct anim *anim)
IMB_free_indices(anim);
}
struct anim * IMB_open_anim(const char * name, int ib_flags, int streamindex)
{
struct anim * anim;
struct anim *IMB_open_anim(const char *name, int ib_flags, int streamindex){
struct anim *anim;
anim = (struct anim*)MEM_callocN(sizeof(struct anim), "anim struct");
anim = (struct anim *)MEM_callocN(sizeof(struct anim), "anim struct");
if (anim != NULL) {
BLI_strncpy(anim->name, name, sizeof(anim->name));
anim->ib_flags = ib_flags;
@@ -269,12 +274,12 @@ struct anim * IMB_open_anim(const char * name, int ib_flags, int streamindex)
}
static int startavi (struct anim *anim)
static int startavi(struct anim *anim)
{
AviError avierror;
#if defined(_WIN32) && !defined(FREE_WINDOWS)
HRESULT hr;
HRESULT hr;
int i, firstvideo = -1;
int streamcount;
BYTE abFormat[1024];
@@ -285,14 +290,14 @@ static int startavi (struct anim *anim)
streamcount = anim->streamindex;
#endif
anim->avi = MEM_callocN (sizeof(AviMovie), "animavi");
anim->avi = MEM_callocN(sizeof(AviMovie), "animavi");
if (anim->avi == NULL) {
printf("Can't open avi: %s\n", anim->name);
return -1;
}
avierror = AVI_open_movie (anim->name, anim->avi);
avierror = AVI_open_movie(anim->name, anim->avi);
#if defined(_WIN32) && !defined(FREE_WINDOWS)
if (avierror == AVI_ERROR_COMPRESSION) {
@@ -329,8 +334,8 @@ static int startavi (struct anim *anim)
FIXCC(avis.fccHandler);
FIXCC(avis.fccType);
printf("Can't find AVI decoder for type : %4.4hs/%4.4hs\n",
(LPSTR)&avis.fccType,
(LPSTR)&avis.fccHandler);
(LPSTR)&avis.fccType,
(LPSTR)&avis.fccHandler);
}
}
}
@@ -357,7 +362,7 @@ static int startavi (struct anim *anim)
if (avierror != AVI_ERROR_NONE) {
AVI_print_error(avierror);
printf ("Error loading avi: %s\n", anim->name);
printf("Error loading avi: %s\n", anim->name);
free_anim_avi(anim);
return -1;
}
@@ -379,7 +384,7 @@ static int startavi (struct anim *anim)
return 0;
}
static ImBuf * avi_fetchibuf (struct anim *anim, int position)
static ImBuf *avi_fetchibuf(struct anim *anim, int position)
{
ImBuf *ibuf = NULL;
int *tmp;
@@ -403,23 +408,23 @@ static ImBuf * avi_fetchibuf (struct anim *anim, int position)
#else
if (1) {
#endif
ibuf = IMB_allocImBuf (anim->x, anim->y, 24, IB_rect);
ibuf = IMB_allocImBuf(anim->x, anim->y, 24, IB_rect);
tmp = AVI_read_frame (anim->avi, AVI_FORMAT_RGB32, position,
AVI_get_stream(anim->avi, AVIST_VIDEO, 0));
tmp = AVI_read_frame(anim->avi, AVI_FORMAT_RGB32, position,
AVI_get_stream(anim->avi, AVIST_VIDEO, 0));
if (tmp == NULL) {
printf ("Error reading frame from AVI");
IMB_freeImBuf (ibuf);
printf("Error reading frame from AVI");
IMB_freeImBuf(ibuf);
return NULL;
}
for (y=0; y < anim->y; y++) {
memcpy (&(ibuf->rect)[((anim->y-y)-1)*anim->x], &tmp[y*anim->x],
anim->x * 4);
for (y = 0; y < anim->y; y++) {
memcpy(&(ibuf->rect)[((anim->y - y) - 1) * anim->x], &tmp[y * anim->x],
anim->x * 4);
}
MEM_freeN (tmp);
MEM_freeN(tmp);
}
ibuf->profile = IB_PROFILE_SRGB;
@@ -431,9 +436,9 @@ static ImBuf * avi_fetchibuf (struct anim *anim, int position)
extern void do_init_ffmpeg(void);
static int startffmpeg(struct anim * anim)
static int startffmpeg(struct anim *anim)
{
int i, videoStream;
int i, videoStream;
AVCodec *pCodec;
AVFormatContext *pFormatCtx;
@@ -455,11 +460,11 @@ static int startffmpeg(struct anim * anim)
do_init_ffmpeg();
if (av_open_input_file(&pFormatCtx, anim->name, NULL, 0, NULL)!=0) {
if (av_open_input_file(&pFormatCtx, anim->name, NULL, 0, NULL) != 0) {
return -1;
}
if (av_find_stream_info(pFormatCtx)<0) {
if (av_find_stream_info(pFormatCtx) < 0) {
av_close_input_file(pFormatCtx);
return -1;
}
@@ -480,7 +485,7 @@ static int startffmpeg(struct anim * anim)
break;
}
if (videoStream==-1) {
if (videoStream == -1) {
av_close_input_file(pFormatCtx);
return -1;
}
@@ -505,7 +510,7 @@ static int startffmpeg(struct anim * anim)
av_q2d(pFormatCtx->streams[videoStream]->r_frame_rate) /
AV_TIME_BASE);
frs_num = pFormatCtx->streams[videoStream]->r_frame_rate.num;
frs_num = pFormatCtx->streams[videoStream]->r_frame_rate.num;
frs_den = pFormatCtx->streams[videoStream]->r_frame_rate.den;
frs_den *= AV_TIME_BASE;
@@ -543,9 +548,10 @@ static int startffmpeg(struct anim * anim)
anim->pFrameRGB = avcodec_alloc_frame();
if (avpicture_get_size(PIX_FMT_RGBA, anim->x, anim->y)
!= anim->x * anim->y * 4) {
fprintf (stderr,
"ffmpeg has changed alloc scheme ... ARGHHH!\n");
!= anim->x * anim->y * 4)
{
fprintf(stderr,
"ffmpeg has changed alloc scheme ... ARGHHH!\n");
avcodec_close(anim->pCodecCtx);
av_close_input_file(anim->pFormatCtx);
av_free(anim->pFrameRGB);
@@ -556,7 +562,7 @@ static int startffmpeg(struct anim * anim)
}
if (anim->ib_flags & IB_animdeinterlace) {
avpicture_fill((AVPicture*) anim->pFrameDeinterlaced,
avpicture_fill((AVPicture *) anim->pFrameDeinterlaced,
MEM_callocN(avpicture_get_size(
anim->pCodecCtx->pix_fmt,
anim->x, anim->y),
@@ -572,18 +578,18 @@ static int startffmpeg(struct anim * anim)
}
anim->img_convert_ctx = sws_getContext(
anim->pCodecCtx->width,
anim->pCodecCtx->height,
anim->pCodecCtx->pix_fmt,
anim->pCodecCtx->width,
anim->pCodecCtx->height,
PIX_FMT_RGBA,
SWS_FAST_BILINEAR | SWS_PRINT_INFO,
NULL, NULL, NULL);
anim->pCodecCtx->width,
anim->pCodecCtx->height,
anim->pCodecCtx->pix_fmt,
anim->pCodecCtx->width,
anim->pCodecCtx->height,
PIX_FMT_RGBA,
SWS_FAST_BILINEAR | SWS_PRINT_INFO,
NULL, NULL, NULL);
if (!anim->img_convert_ctx) {
fprintf (stderr,
"Can't transform color space??? Bailing out...\n");
fprintf(stderr,
"Can't transform color space??? Bailing out...\n");
avcodec_close(anim->pCodecCtx);
av_close_input_file(anim->pFormatCtx);
av_free(anim->pFrameRGB);
@@ -595,17 +601,17 @@ static int startffmpeg(struct anim * anim)
#ifdef FFMPEG_SWSCALE_COLOR_SPACE_SUPPORT
/* Try do detect if input has 0-255 YCbCR range (JFIF Jpeg MotionJpeg) */
if (!sws_getColorspaceDetails(anim->img_convert_ctx, (int**)&inv_table, &srcRange,
&table, &dstRange, &brightness, &contrast, &saturation)) {
if (!sws_getColorspaceDetails(anim->img_convert_ctx, (int **)&inv_table, &srcRange,
&table, &dstRange, &brightness, &contrast, &saturation)) {
srcRange = srcRange || anim->pCodecCtx->color_range == AVCOL_RANGE_JPEG;
inv_table = sws_getCoefficients(anim->pCodecCtx->colorspace);
if (sws_setColorspaceDetails(anim->img_convert_ctx, (int *)inv_table, srcRange,
table, dstRange, brightness, contrast, saturation)) {
table, dstRange, brightness, contrast, saturation)) {
printf("Warning: Could not set libswscale colorspace details.\n");
}
}
}
else {
printf("Warning: Could not set libswscale colorspace details.\n");
@@ -621,10 +627,10 @@ static int startffmpeg(struct anim * anim)
* Output is anim->last_frame
*/
static void ffmpeg_postprocess(struct anim * anim)
static void ffmpeg_postprocess(struct anim *anim)
{
AVFrame * input = anim->pFrame;
ImBuf * ibuf = anim->last_frame;
AVFrame *input = anim->pFrame;
ImBuf *ibuf = anim->last_frame;
int filter_y = 0;
ibuf->profile = IB_PROFILE_SRGB;
@@ -635,11 +641,11 @@ static void ffmpeg_postprocess(struct anim * anim)
/* 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)
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");
"data not read properly...\n");
return;
}
@@ -651,13 +657,13 @@ static void ffmpeg_postprocess(struct anim * anim)
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)
(AVPicture *)
anim->pFrameDeinterlaced,
(const AVPicture *)
anim->pFrame,
anim->pCodecCtx->pix_fmt,
anim->pCodecCtx->width,
anim->pCodecCtx->height) < 0)
{
filter_y = TRUE;
}
@@ -666,37 +672,37 @@ static void ffmpeg_postprocess(struct anim * anim)
}
}
avpicture_fill((AVPicture*) anim->pFrameRGB,
(unsigned char*) ibuf->rect,
avpicture_fill((AVPicture *) anim->pFrameRGB,
(unsigned char *) ibuf->rect,
PIX_FMT_RGBA, anim->x, anim->y);
if (ENDIAN_ORDER == B_ENDIAN) {
int * dstStride = anim->pFrameRGB->linesize;
uint8_t** dst = anim->pFrameRGB->data;
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 };
uint8_t *dst2[4] = { dst[0], 0, 0, 0 };
int x, y, h, w;
unsigned char* bottom;
unsigned char* top;
unsigned char *bottom;
unsigned char *top;
sws_scale(anim->img_convert_ctx,
(const uint8_t * const *)input->data,
(const uint8_t *const *)input->data,
input->linesize,
0,
anim->pCodecCtx->height,
dst2,
dstStride2);
bottom = (unsigned char*) ibuf->rect;
top = bottom + ibuf->x * (ibuf->y-1) * 4;
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;
unsigned int *tmp_l =
(unsigned int *) tmp;
for (x = 0; x < w; x++) {
tmp[0] = bottom[0];
@@ -709,23 +715,23 @@ static void ffmpeg_postprocess(struct anim * anim)
bottom[2] = top[2];
bottom[3] = top[3];
*(unsigned int*) top = *tmp_l;
*(unsigned int *) top = *tmp_l;
bottom +=4;
bottom += 4;
top += 4;
}
top -= 8 * w;
}
}
else {
int * dstStride = anim->pFrameRGB->linesize;
uint8_t** dst = anim->pFrameRGB->data;
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 };
uint8_t *dst2[4] = { dst[0] + (anim->y - 1) * dstStride[0],
0, 0, 0 };
sws_scale(anim->img_convert_ctx,
(const uint8_t * const *)input->data,
(const uint8_t *const *)input->data,
input->linesize,
0,
anim->pCodecCtx->height,
@@ -740,7 +746,7 @@ static void ffmpeg_postprocess(struct anim * anim)
/* decode one video frame also considering the packet read into next_packet */
static int ffmpeg_decode_video_frame(struct anim * anim)
static int ffmpeg_decode_video_frame(struct anim *anim)
{
int rval = 0;
@@ -760,9 +766,9 @@ static int ffmpeg_decode_video_frame(struct anim * anim)
? "->" : " ",
anim->next_packet.stream_index,
anim->videoStream,
(anim->next_packet.dts == AV_NOPTS_VALUE) ? -1:
(anim->next_packet.dts == AV_NOPTS_VALUE) ? -1 :
(long long int)anim->next_packet.dts,
(anim->next_packet.pts == AV_NOPTS_VALUE) ? -1:
(anim->next_packet.pts == AV_NOPTS_VALUE) ? -1 :
(long long int)anim->next_packet.pts,
(anim->next_packet.flags & AV_PKT_FLAG_KEY) ?
" KEY" : "");
@@ -770,13 +776,13 @@ static int ffmpeg_decode_video_frame(struct anim * anim)
anim->pFrameComplete = 0;
avcodec_decode_video2(
anim->pCodecCtx,
anim->pFrame, &anim->pFrameComplete,
&anim->next_packet);
anim->pCodecCtx,
anim->pFrame, &anim->pFrameComplete,
&anim->next_packet);
if (anim->pFrameComplete) {
anim->next_pts = av_get_pts_from_frame(
anim->pFormatCtx, anim->pFrame);
anim->pFormatCtx, anim->pFrame);
av_log(anim->pFormatCtx,
AV_LOG_DEBUG,
@@ -786,7 +792,7 @@ static int ffmpeg_decode_video_frame(struct anim * anim)
-1 : (long long int)anim->pFrame->pts,
(anim->pFrame->pkt_pts == AV_NOPTS_VALUE) ?
-1 : (long long int)anim->pFrame->pkt_pts,
(long long int)anim->next_pts);
(long long int)anim->next_pts);
break;
}
}
@@ -799,14 +805,14 @@ static int ffmpeg_decode_video_frame(struct anim * anim)
av_log(anim->pFormatCtx,
AV_LOG_ERROR, " DECODE READ FAILED: av_read_frame() "
"returned error: %d\n", rval);
"returned error: %d\n", rval);
}
return (rval >= 0);
}
static void ffmpeg_decode_video_frame_scan(
struct anim * anim, int64_t pts_to_search)
struct anim *anim, int64_t pts_to_search)
{
/* there seem to exist *very* silly GOP lengths out in the wild... */
int count = 1000;
@@ -843,7 +849,7 @@ static void ffmpeg_decode_video_frame_scan(
}
}
static int match_format(const char *name, AVFormatContext * pFormatCtx)
static int match_format(const char *name, AVFormatContext *pFormatCtx)
{
const char *p;
int len, namelen;
@@ -858,15 +864,15 @@ static int match_format(const char *name, AVFormatContext * pFormatCtx)
len = MAX2(p - names, namelen);
if (!BLI_strncasecmp(name, names, len))
return 1;
names = p+1;
names = p + 1;
}
return !BLI_strcasecmp(name, names);
}
static int ffmpeg_seek_by_byte(AVFormatContext *pFormatCtx)
{
static const char * byte_seek_list [] = { "mpegts", 0 };
const char ** p;
static const char *byte_seek_list[] = { "mpegts", 0 };
const char **p;
if (pFormatCtx->iformat->flags & AVFMT_TS_DISCONT) {
return TRUE;
@@ -883,14 +889,14 @@ static int ffmpeg_seek_by_byte(AVFormatContext *pFormatCtx)
return FALSE;
}
static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position,
IMB_Timecode_Type tc) {
static ImBuf *ffmpeg_fetchibuf(struct anim *anim, int position,
IMB_Timecode_Type tc) {
int64_t pts_to_search = 0;
double frame_rate;
double pts_time_base;
long long st_time;
struct anim_index * tc_index = 0;
AVStream * v_st;
struct anim_index *tc_index = 0;
AVStream *v_st;
int new_frame_index = 0; /* To quite gcc barking... */
int old_frame_index = 0; /* To quite gcc barking... */
@@ -911,16 +917,16 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position,
if (tc_index) {
new_frame_index = IMB_indexer_get_frame_index(
tc_index, position);
tc_index, position);
old_frame_index = IMB_indexer_get_frame_index(
tc_index, anim->curposition);
pts_to_search = IMB_indexer_get_pts(
tc_index, new_frame_index);
tc_index, anim->curposition);
pts_to_search = IMB_indexer_get_pts(
tc_index, new_frame_index);
}
else {
pts_to_search = (long long)
floor(((double) position) /
pts_time_base / frame_rate + 0.5);
floor(((double) position) /
pts_time_base / frame_rate + 0.5);
if (st_time != AV_NOPTS_VALUE) {
pts_to_search += st_time / pts_time_base / AV_TIME_BASE;
@@ -954,9 +960,9 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position,
ffmpeg_decode_video_frame_scan(anim, pts_to_search);
}
else if (tc_index &&
IMB_indexer_can_scan(tc_index, old_frame_index,
new_frame_index)) {
IMB_indexer_can_scan(tc_index, old_frame_index,
new_frame_index))
{
av_log(anim->pFormatCtx, AV_LOG_DEBUG,
"FETCH: within preseek interval "
"(index tells us)\n");
@@ -971,9 +977,9 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position,
unsigned long long dts;
pos = IMB_indexer_get_seek_pos(
tc_index, new_frame_index);
tc_index, new_frame_index);
dts = IMB_indexer_get_seek_pos_dts(
tc_index, new_frame_index);
tc_index, new_frame_index);
av_log(anim->pFormatCtx, AV_LOG_DEBUG,
"TC INDEX seek pos = %lld\n", pos);
@@ -985,21 +991,21 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position,
"... using BYTE pos\n");
ret = av_seek_frame(anim->pFormatCtx,
-1,
pos, AVSEEK_FLAG_BYTE);
-1,
pos, AVSEEK_FLAG_BYTE);
av_update_cur_dts(anim->pFormatCtx, v_st, dts);
}
else {
av_log(anim->pFormatCtx, AV_LOG_DEBUG,
"... using DTS pos\n");
ret = av_seek_frame(anim->pFormatCtx,
anim->videoStream,
dts, AVSEEK_FLAG_BACKWARD);
anim->videoStream,
dts, AVSEEK_FLAG_BACKWARD);
}
}
else {
pos = (long long) (position - anim->preseek) *
AV_TIME_BASE / frame_rate;
AV_TIME_BASE / frame_rate;
av_log(anim->pFormatCtx, AV_LOG_DEBUG,
"NO INDEX seek pos = %lld, st_time = %lld\n",
@@ -1017,7 +1023,7 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position,
"NO INDEX final seek pos = %lld\n", pos);
ret = av_seek_frame(anim->pFormatCtx, -1,
pos, AVSEEK_FLAG_BACKWARD);
pos, AVSEEK_FLAG_BACKWARD);
}
if (ret < 0) {
@@ -1068,7 +1074,7 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position,
return anim->last_frame;
}
static void free_anim_ffmpeg(struct anim * anim)
static void free_anim_ffmpeg(struct anim *anim)
{
if (anim == NULL) return;
@@ -1095,7 +1101,7 @@ static void free_anim_ffmpeg(struct anim * anim)
#ifdef WITH_REDCODE
static int startredcode(struct anim * anim)
static int startredcode(struct anim *anim)
{
anim->redcodeCtx = redcode_open(anim->name);
if (!anim->redcodeCtx) {
@@ -1106,11 +1112,11 @@ static int startredcode(struct anim * anim)
return 0;
}
static ImBuf * redcode_fetchibuf(struct anim * anim, int position)
static ImBuf *redcode_fetchibuf(struct anim *anim, int position)
{
struct ImBuf * ibuf;
struct redcode_frame * frame;
struct redcode_frame_raw * raw_frame;
struct ImBuf *ibuf;
struct redcode_frame *frame;
struct redcode_frame_raw *raw_frame;
if (!anim->redcodeCtx) {
return NULL;
@@ -1130,15 +1136,15 @@ static ImBuf * redcode_fetchibuf(struct anim * anim, int position)
return NULL;
}
ibuf = IMB_allocImBuf(raw_frame->width * 2,
raw_frame->height * 2, 32, IB_rectfloat);
ibuf = IMB_allocImBuf(raw_frame->width * 2,
raw_frame->height * 2, 32, IB_rectfloat);
redcode_decode_video_float(raw_frame, ibuf->rect_float, 1);
return ibuf;
}
static void free_anim_redcode(struct anim * anim)
static void free_anim_redcode(struct anim *anim)
{
if (anim->redcodeCtx) {
redcode_close(anim->redcodeCtx);
@@ -1153,7 +1159,7 @@ static void free_anim_redcode(struct anim * anim)
/* Geen plaatje, probeer dan volgende animatie te openen */
/* gelukt, haal dan eerste plaatje van animatie */
static struct ImBuf * anim_getnew(struct anim * anim)
static struct ImBuf *anim_getnew(struct anim *anim)
{
struct ImBuf *ibuf = NULL;
@@ -1176,49 +1182,48 @@ static struct ImBuf * anim_getnew(struct anim * anim)
anim->curtype = imb_get_anim_type(anim->name);
switch (anim->curtype) {
case ANIM_SEQUENCE:
ibuf = IMB_loadiffname(anim->name, anim->ib_flags);
if (ibuf) {
BLI_strncpy(anim->first, anim->name, sizeof(anim->first));
anim->duration = 1;
}
break;
case ANIM_MOVIE:
if (startmovie(anim)) return (NULL);
ibuf = IMB_allocImBuf (anim->x, anim->y, 24, 0); /* fake */
break;
case ANIM_AVI:
if (startavi(anim)) {
printf("couldnt start avi\n");
return (NULL);
}
ibuf = IMB_allocImBuf (anim->x, anim->y, 24, 0);
break;
case ANIM_SEQUENCE:
ibuf = IMB_loadiffname(anim->name, anim->ib_flags);
if (ibuf) {
BLI_strncpy(anim->first, anim->name, sizeof(anim->first));
anim->duration = 1;
}
break;
case ANIM_MOVIE:
if (startmovie(anim)) return (NULL);
ibuf = IMB_allocImBuf(anim->x, anim->y, 24, 0); /* fake */
break;
case ANIM_AVI:
if (startavi(anim)) {
printf("couldnt start avi\n");
return (NULL);
}
ibuf = IMB_allocImBuf(anim->x, anim->y, 24, 0);
break;
#ifdef WITH_QUICKTIME
case ANIM_QTIME:
if (startquicktime(anim)) return (0);
ibuf = IMB_allocImBuf (anim->x, anim->y, 24, 0);
break;
case ANIM_QTIME:
if (startquicktime(anim)) return (0);
ibuf = IMB_allocImBuf(anim->x, anim->y, 24, 0);
break;
#endif
#ifdef WITH_FFMPEG
case ANIM_FFMPEG:
if (startffmpeg(anim)) return (0);
ibuf = IMB_allocImBuf (anim->x, anim->y, 24, 0);
break;
case ANIM_FFMPEG:
if (startffmpeg(anim)) return (0);
ibuf = IMB_allocImBuf(anim->x, anim->y, 24, 0);
break;
#endif
#ifdef WITH_REDCODE
case ANIM_REDCODE:
if (startredcode(anim)) return (0);
ibuf = IMB_allocImBuf (8, 8, 32, 0);
break;
case ANIM_REDCODE:
if (startredcode(anim)) return (0);
ibuf = IMB_allocImBuf(8, 8, 32, 0);
break;
#endif
}
return(ibuf);
}
struct ImBuf * IMB_anim_previewframe(struct anim * anim)
{
struct ImBuf * ibuf = NULL;
struct ImBuf *IMB_anim_previewframe(struct anim *anim){
struct ImBuf *ibuf = NULL;
int position = 0;
ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
@@ -1226,15 +1231,15 @@ struct ImBuf * IMB_anim_previewframe(struct anim * anim)
IMB_freeImBuf(ibuf);
position = anim->duration / 2;
ibuf = IMB_anim_absolute(anim, position, IMB_TC_NONE,
IMB_PROXY_NONE);
IMB_PROXY_NONE);
}
return ibuf;
}
struct ImBuf * IMB_anim_absolute(struct anim * anim, int position,
IMB_Timecode_Type tc,
IMB_Proxy_Size preview_size) {
struct ImBuf * ibuf = NULL;
struct ImBuf *IMB_anim_absolute(struct anim *anim, int position,
IMB_Timecode_Type tc,
IMB_Proxy_Size preview_size) {
struct ImBuf *ibuf = NULL;
char head[256], tail[256];
unsigned short digits;
int pic;
@@ -1243,74 +1248,74 @@ struct ImBuf * IMB_anim_absolute(struct anim * anim, int position,
filter_y = (anim->ib_flags & IB_animdeinterlace);
if (anim->curtype == 0) {
if (anim->curtype == 0) {
ibuf = anim_getnew(anim);
if (ibuf == NULL) {
return(NULL);
}
IMB_freeImBuf(ibuf); /* ???? */
ibuf= NULL;
ibuf = NULL;
}
if (position < 0) return(NULL);
if (position >= anim->duration) return(NULL);
if (preview_size != IMB_PROXY_NONE) {
struct anim * proxy = IMB_anim_open_proxy(anim, preview_size);
struct anim *proxy = IMB_anim_open_proxy(anim, preview_size);
if (proxy) {
position = IMB_anim_index_get_frame_index(
anim, tc, position);
anim, tc, position);
return IMB_anim_absolute(
proxy, position,
IMB_TC_NONE, IMB_PROXY_NONE);
proxy, position,
IMB_TC_NONE, IMB_PROXY_NONE);
}
}
switch (anim->curtype) {
case ANIM_SEQUENCE:
pic = an_stringdec(anim->first, head, tail, &digits);
pic += position;
an_stringenc(anim->name, head, tail, digits, pic);
ibuf = IMB_loadiffname(anim->name, IB_rect);
if (ibuf) {
anim->curposition = position;
}
break;
case ANIM_MOVIE:
ibuf = movie_fetchibuf(anim, position);
if (ibuf) {
anim->curposition = position;
IMB_convert_rgba_to_abgr(ibuf);
ibuf->profile = IB_PROFILE_SRGB;
}
break;
case ANIM_AVI:
ibuf = avi_fetchibuf(anim, position);
if (ibuf)
anim->curposition = position;
break;
case ANIM_SEQUENCE:
pic = an_stringdec(anim->first, head, tail, &digits);
pic += position;
an_stringenc(anim->name, head, tail, digits, pic);
ibuf = IMB_loadiffname(anim->name, IB_rect);
if (ibuf) {
anim->curposition = position;
}
break;
case ANIM_MOVIE:
ibuf = movie_fetchibuf(anim, position);
if (ibuf) {
anim->curposition = position;
IMB_convert_rgba_to_abgr(ibuf);
ibuf->profile = IB_PROFILE_SRGB;
}
break;
case ANIM_AVI:
ibuf = avi_fetchibuf(anim, position);
if (ibuf)
anim->curposition = position;
break;
#ifdef WITH_QUICKTIME
case ANIM_QTIME:
ibuf = qtime_fetchibuf(anim, position);
if (ibuf)
anim->curposition = position;
break;
case ANIM_QTIME:
ibuf = qtime_fetchibuf(anim, position);
if (ibuf)
anim->curposition = position;
break;
#endif
#ifdef WITH_FFMPEG
case ANIM_FFMPEG:
ibuf = ffmpeg_fetchibuf(anim, position, tc);
if (ibuf)
anim->curposition = position;
filter_y = 0; /* done internally */
break;
case ANIM_FFMPEG:
ibuf = ffmpeg_fetchibuf(anim, position, tc);
if (ibuf)
anim->curposition = position;
filter_y = 0; /* done internally */
break;
#endif
#ifdef WITH_REDCODE
case ANIM_REDCODE:
ibuf = redcode_fetchibuf(anim, position);
if (ibuf) anim->curposition = position;
break;
case ANIM_REDCODE:
ibuf = redcode_fetchibuf(anim, position);
if (ibuf) anim->curposition = position;
break;
#endif
}
@@ -1326,7 +1331,7 @@ struct ImBuf * IMB_anim_absolute(struct anim * anim, int position,
int IMB_anim_get_duration(struct anim *anim, IMB_Timecode_Type tc)
{
struct anim_index * idx;
struct anim_index *idx;
if (tc == IMB_TC_NONE) {
return anim->duration;
}
@@ -1339,8 +1344,8 @@ int IMB_anim_get_duration(struct anim *anim, IMB_Timecode_Type tc)
return IMB_indexer_get_duration(idx);
}
int IMB_anim_get_fps(struct anim * anim,
short * frs_sec, float * frs_sec_base)
int IMB_anim_get_fps(struct anim *anim,
short *frs_sec, float *frs_sec_base)
{
if (anim->frs_sec) {
*frs_sec = anim->frs_sec;
@@ -1350,12 +1355,12 @@ int IMB_anim_get_fps(struct anim * anim,
return FALSE;
}
void IMB_anim_set_preseek(struct anim * anim, int preseek)
void IMB_anim_set_preseek(struct anim *anim, int preseek)
{
anim->preseek = preseek;
}
int IMB_anim_get_preseek(struct anim * anim)
int IMB_anim_get_preseek(struct anim *anim)
{
return anim->preseek;
}

View File

@@ -45,17 +45,17 @@
*/
typedef struct BMPINFOHEADER {
unsigned int biSize;
unsigned int biWidth;
unsigned int biHeight;
unsigned short biPlanes;
unsigned short biBitCount;
unsigned int biCompression;
unsigned int biSizeImage;
unsigned int biXPelsPerMeter;
unsigned int biYPelsPerMeter;
unsigned int biClrUsed;
unsigned int biClrImportant;
unsigned int biSize;
unsigned int biWidth;
unsigned int biHeight;
unsigned short biPlanes;
unsigned short biBitCount;
unsigned int biCompression;
unsigned int biSizeImage;
unsigned int biXPelsPerMeter;
unsigned int biYPelsPerMeter;
unsigned int biClrUsed;
unsigned int biClrImportant;
} BMPINFOHEADER;
typedef struct BMPHEADER {
@@ -160,7 +160,7 @@ struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags)
else if (depth == 24) {
for (i = y; i > 0; i--) {
int j;
for (j = x ; j > 0; j--) {
for (j = x; j > 0; j--) {
rect[0] = bmp[2];
rect[1] = bmp[1];
rect[2] = bmp[0];
@@ -194,16 +194,16 @@ struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags)
/* Couple of helper functions for writing our data */
static int putIntLSB(unsigned int ui, FILE *ofile)
{
putc((ui>>0)&0xFF, ofile);
putc((ui>>8)&0xFF, ofile);
putc((ui>>16)&0xFF, ofile);
return putc((ui>>24)&0xFF, ofile);
putc((ui >> 0) & 0xFF, ofile);
putc((ui >> 8) & 0xFF, ofile);
putc((ui >> 16) & 0xFF, ofile);
return putc((ui >> 24) & 0xFF, ofile);
}
static int putShortLSB(unsigned short us, FILE *ofile)
{
putc((us>>0)&0xFF, ofile);
return putc((us>>8)&0xFF, ofile);
putc((us >> 0) & 0xFF, ofile);
return putc((us >> 8) & 0xFF, ofile);
}
/* Found write info at http://users.ece.gatech.edu/~slabaugh/personal/c/bitmapUnix.c */
@@ -216,12 +216,12 @@ int imb_savebmp(struct ImBuf *ibuf, const char *name, int flags)
(void)flags; /* unused */
extrabytes = (4 - ibuf->x*3 % 4) % 4;
extrabytes = (4 - ibuf->x * 3 % 4) % 4;
bytesize = (ibuf->x * 3 + extrabytes) * ibuf->y;
data = (uchar *) ibuf->rect;
ofile = BLI_fopen(name, "wb");
if (!ofile) return 0;
if (!ofile) return 0;
putShortLSB(19778, ofile); /* "BM" */
putIntLSB(0, ofile); /* This can be 0 for BI_RGB bitmaps */
@@ -242,15 +242,15 @@ int imb_savebmp(struct ImBuf *ibuf, const char *name, int flags)
putIntLSB(0, ofile);
/* Need to write out padded image data in bgr format */
for (y=0;y<ibuf->y;y++) {
for (x=0;x<ibuf->x;x++) {
ptr=(x + y * ibuf->x) * 4;
if (putc(data[ptr+2], ofile) == EOF) return 0;
if (putc(data[ptr+1], ofile) == EOF) return 0;
for (y = 0; y < ibuf->y; y++) {
for (x = 0; x < ibuf->x; x++) {
ptr = (x + y * ibuf->x) * 4;
if (putc(data[ptr + 2], ofile) == EOF) return 0;
if (putc(data[ptr + 1], ofile) == EOF) return 0;
if (putc(data[ptr], ofile) == EOF) return 0;
}
/* add padding here */
for (t=0;t<extrabytes;t++) if (putc(0, ofile) == EOF) return 0;
for (t = 0; t < extrabytes; t++) if (putc(0, ofile) == EOF) return 0;
}
if (ofile) {
fflush(ofile);

View File

@@ -48,7 +48,7 @@
* back to the global cache every pixel, but not to big to keep too many tiles
* locked and using memory. */
#define IB_THREAD_CACHE_SIZE 100
#define IB_THREAD_CACHE_SIZE 100
typedef struct ImGlobalTile {
struct ImGlobalTile *next, *prev;
@@ -82,7 +82,7 @@ typedef struct ImGlobalTileCache {
MemArena *memarena;
uintptr_t totmem, maxmem;
ImThreadTileCache thread_cache[BLENDER_MAX_THREADS+1];
ImThreadTileCache thread_cache[BLENDER_MAX_THREADS + 1];
int totthread;
ThreadMutex mutex;
@@ -96,15 +96,15 @@ static ImGlobalTileCache GLOBAL_CACHE;
static unsigned int imb_global_tile_hash(const void *gtile_p)
{
const ImGlobalTile *gtile= gtile_p;
const ImGlobalTile *gtile = gtile_p;
return ((unsigned int)(intptr_t)gtile->ibuf)*769 + gtile->tx*53 + gtile->ty*97;
return ((unsigned int)(intptr_t)gtile->ibuf) * 769 + gtile->tx * 53 + gtile->ty * 97;
}
static int imb_global_tile_cmp(const void *a_p, const void *b_p)
{
const ImGlobalTile *a= a_p;
const ImGlobalTile *b= b_p;
const ImGlobalTile *a = a_p;
const ImGlobalTile *b = b_p;
if (a->ibuf == b->ibuf && a->tx == b->tx && a->ty == b->ty) return 0;
else if (a->ibuf < b->ibuf || a->tx < b->tx || a->ty < b->ty) return -1;
@@ -113,15 +113,15 @@ static int imb_global_tile_cmp(const void *a_p, const void *b_p)
static unsigned int imb_thread_tile_hash(const void *ttile_p)
{
const ImThreadTile *ttile= ttile_p;
const ImThreadTile *ttile = ttile_p;
return ((unsigned int)(intptr_t)ttile->ibuf)*769 + ttile->tx*53 + ttile->ty*97;
return ((unsigned int)(intptr_t)ttile->ibuf) * 769 + ttile->tx * 53 + ttile->ty * 97;
}
static int imb_thread_tile_cmp(const void *a_p, const void *b_p)
{
const ImThreadTile *a= a_p;
const ImThreadTile *b= b_p;
const ImThreadTile *a = a_p;
const ImThreadTile *b = b_p;
if (a->ibuf == b->ibuf && a->tx == b->tx && a->ty == b->ty) return 0;
else if (a->ibuf < b->ibuf || a->tx < b->tx || a->ty < b->ty) return -1;
@@ -132,24 +132,24 @@ static int imb_thread_tile_cmp(const void *a_p, const void *b_p)
static void imb_global_cache_tile_load(ImGlobalTile *gtile)
{
ImBuf *ibuf= gtile->ibuf;
int toffs= ibuf->xtiles*gtile->ty + gtile->tx;
ImBuf *ibuf = gtile->ibuf;
int toffs = ibuf->xtiles * gtile->ty + gtile->tx;
unsigned int *rect;
rect = MEM_callocN(sizeof(unsigned int)*ibuf->tilex*ibuf->tiley, "imb_tile");
rect = MEM_callocN(sizeof(unsigned int) * ibuf->tilex * ibuf->tiley, "imb_tile");
imb_loadtile(ibuf, gtile->tx, gtile->ty, rect);
ibuf->tiles[toffs]= rect;
ibuf->tiles[toffs] = rect;
}
static void imb_global_cache_tile_unload(ImGlobalTile *gtile)
{
ImBuf *ibuf= gtile->ibuf;
int toffs= ibuf->xtiles*gtile->ty + gtile->tx;
ImBuf *ibuf = gtile->ibuf;
int toffs = ibuf->xtiles * gtile->ty + gtile->tx;
MEM_freeN(ibuf->tiles[toffs]);
ibuf->tiles[toffs]= NULL;
ibuf->tiles[toffs] = NULL;
GLOBAL_CACHE.totmem -= sizeof(unsigned int)*ibuf->tilex*ibuf->tiley;
GLOBAL_CACHE.totmem -= sizeof(unsigned int) * ibuf->tilex * ibuf->tiley;
}
/* external free */
@@ -162,7 +162,7 @@ void imb_tile_cache_tile_free(ImBuf *ibuf, int tx, int ty)
lookuptile.ibuf = ibuf;
lookuptile.tx = tx;
lookuptile.ty = ty;
gtile= BLI_ghash_lookup(GLOBAL_CACHE.tilehash, &lookuptile);
gtile = BLI_ghash_lookup(GLOBAL_CACHE.tilehash, &lookuptile);
if (gtile) {
/* in case another thread is loading this */
@@ -186,11 +186,11 @@ static void imb_thread_cache_init(ImThreadTileCache *cache)
memset(cache, 0, sizeof(ImThreadTileCache));
cache->tilehash= BLI_ghash_new(imb_thread_tile_hash, imb_thread_tile_cmp, "imb_thread_cache_init gh");
cache->tilehash = BLI_ghash_new(imb_thread_tile_hash, imb_thread_tile_cmp, "imb_thread_cache_init gh");
/* pre-allocate all thread local tiles in unused list */
for (a=0; a<IB_THREAD_CACHE_SIZE; a++) {
ttile= BLI_memarena_alloc(GLOBAL_CACHE.memarena, sizeof(ImThreadTile));
for (a = 0; a < IB_THREAD_CACHE_SIZE; a++) {
ttile = BLI_memarena_alloc(GLOBAL_CACHE.memarena, sizeof(ImThreadTile));
BLI_addtail(&cache->unused, ttile);
}
}
@@ -219,10 +219,10 @@ void imb_tile_cache_exit(void)
int a;
if (GLOBAL_CACHE.initialized) {
for (gtile=GLOBAL_CACHE.tiles.first; gtile; gtile=gtile->next)
for (gtile = GLOBAL_CACHE.tiles.first; gtile; gtile = gtile->next)
imb_global_cache_tile_unload(gtile);
for (a=0; a<GLOBAL_CACHE.totthread; a++)
for (a = 0; a < GLOBAL_CACHE.totthread; a++)
imb_thread_cache_exit(&GLOBAL_CACHE.thread_cache[a]);
if (GLOBAL_CACHE.memarena)
@@ -253,15 +253,15 @@ void IMB_tile_cache_params(int totthread, int maxmem)
memset(&GLOBAL_CACHE, 0, sizeof(ImGlobalTileCache));
GLOBAL_CACHE.tilehash= BLI_ghash_new(imb_global_tile_hash, imb_global_tile_cmp, "tile_cache_params gh");
GLOBAL_CACHE.tilehash = BLI_ghash_new(imb_global_tile_hash, imb_global_tile_cmp, "tile_cache_params gh");
GLOBAL_CACHE.memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "ImTileCache arena");
GLOBAL_CACHE.memarena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "ImTileCache arena");
BLI_memarena_use_calloc(GLOBAL_CACHE.memarena);
GLOBAL_CACHE.maxmem= maxmem*1024*1024;
GLOBAL_CACHE.maxmem = maxmem * 1024 * 1024;
GLOBAL_CACHE.totthread= totthread;
for (a=0; a<totthread; a++)
GLOBAL_CACHE.totthread = totthread;
for (a = 0; a < totthread; a++)
imb_thread_cache_init(&GLOBAL_CACHE.thread_cache[a]);
BLI_mutex_init(&GLOBAL_CACHE.mutex);
@@ -282,7 +282,7 @@ static ImGlobalTile *imb_global_cache_get_tile(ImBuf *ibuf, int tx, int ty, ImGl
lookuptile.ibuf = ibuf;
lookuptile.tx = tx;
lookuptile.ty = ty;
gtile= BLI_ghash_lookup(GLOBAL_CACHE.tilehash, &lookuptile);
gtile = BLI_ghash_lookup(GLOBAL_CACHE.tilehash, &lookuptile);
if (gtile) {
/* found tile. however it may be in the process of being loaded
@@ -301,7 +301,7 @@ static ImGlobalTile *imb_global_cache_get_tile(ImBuf *ibuf, int tx, int ty, ImGl
/* first check if we hit the memory limit */
if (GLOBAL_CACHE.maxmem && GLOBAL_CACHE.totmem > GLOBAL_CACHE.maxmem) {
/* find an existing tile to unload */
for (gtile=GLOBAL_CACHE.tiles.last; gtile; gtile=gtile->prev)
for (gtile = GLOBAL_CACHE.tiles.last; gtile; gtile = gtile->prev)
if (gtile->refcount == 0 && gtile->loading == 0)
break;
}
@@ -315,25 +315,25 @@ static ImGlobalTile *imb_global_cache_get_tile(ImBuf *ibuf, int tx, int ty, ImGl
else {
/* allocate a new tile or reuse unused */
if (GLOBAL_CACHE.unused.first) {
gtile= GLOBAL_CACHE.unused.first;
gtile = GLOBAL_CACHE.unused.first;
BLI_remlink(&GLOBAL_CACHE.unused, gtile);
}
else
gtile= BLI_memarena_alloc(GLOBAL_CACHE.memarena, sizeof(ImGlobalTile));
gtile = BLI_memarena_alloc(GLOBAL_CACHE.memarena, sizeof(ImGlobalTile));
}
/* setup new tile */
gtile->ibuf= ibuf;
gtile->tx= tx;
gtile->ty= ty;
gtile->refcount= 1;
gtile->loading= 1;
gtile->ibuf = ibuf;
gtile->tx = tx;
gtile->ty = ty;
gtile->refcount = 1;
gtile->loading = 1;
BLI_ghash_insert(GLOBAL_CACHE.tilehash, gtile, gtile);
BLI_addhead(&GLOBAL_CACHE.tiles, gtile);
/* mark as being loaded and unlock to allow other threads to load too */
GLOBAL_CACHE.totmem += sizeof(unsigned int)*ibuf->tilex*ibuf->tiley;
GLOBAL_CACHE.totmem += sizeof(unsigned int) * ibuf->tilex * ibuf->tiley;
BLI_mutex_unlock(&GLOBAL_CACHE.mutex);
@@ -341,7 +341,7 @@ static ImGlobalTile *imb_global_cache_get_tile(ImBuf *ibuf, int tx, int ty, ImGl
imb_global_cache_tile_load(gtile);
/* mark as done loading */
gtile->loading= 0;
gtile->loading = 0;
}
return gtile;
@@ -353,10 +353,10 @@ static unsigned int *imb_thread_cache_get_tile(ImThreadTileCache *cache, ImBuf *
{
ImThreadTile *ttile, lookuptile;
ImGlobalTile *gtile, *replacetile;
int toffs= ibuf->xtiles*ty + tx;
int toffs = ibuf->xtiles * ty + tx;
/* test if it is already in our thread local cache */
if ((ttile=cache->tiles.first)) {
if ((ttile = cache->tiles.first)) {
/* check last used tile before going to hash */
if (ttile->ibuf == ibuf && ttile->tx == tx && ttile->ty == ty)
return ibuf->tiles[toffs];
@@ -366,7 +366,7 @@ static unsigned int *imb_thread_cache_get_tile(ImThreadTileCache *cache, ImBuf *
lookuptile.tx = tx;
lookuptile.ty = ty;
if ((ttile=BLI_ghash_lookup(cache->tilehash, &lookuptile))) {
if ((ttile = BLI_ghash_lookup(cache->tilehash, &lookuptile))) {
BLI_remlink(&cache->tiles, ttile);
BLI_addhead(&cache->tiles, ttile);
@@ -376,33 +376,33 @@ static unsigned int *imb_thread_cache_get_tile(ImThreadTileCache *cache, ImBuf *
/* not found, have to do slow lookup in global cache */
if (cache->unused.first == NULL) {
ttile= cache->tiles.last;
replacetile= ttile->global;
ttile = cache->tiles.last;
replacetile = ttile->global;
BLI_remlink(&cache->tiles, ttile);
BLI_ghash_remove(cache->tilehash, ttile, NULL, NULL);
}
else {
ttile= cache->unused.first;
replacetile= NULL;
ttile = cache->unused.first;
replacetile = NULL;
BLI_remlink(&cache->unused, ttile);
}
BLI_addhead(&cache->tiles, ttile);
BLI_ghash_insert(cache->tilehash, ttile, ttile);
gtile= imb_global_cache_get_tile(ibuf, tx, ty, replacetile);
gtile = imb_global_cache_get_tile(ibuf, tx, ty, replacetile);
ttile->ibuf= gtile->ibuf;
ttile->tx= gtile->tx;
ttile->ty= gtile->ty;
ttile->global= gtile;
ttile->ibuf = gtile->ibuf;
ttile->tx = gtile->tx;
ttile->ty = gtile->ty;
ttile->global = gtile;
return ibuf->tiles[toffs];
}
unsigned int *IMB_gettile(ImBuf *ibuf, int tx, int ty, int thread)
{
return imb_thread_cache_get_tile(&GLOBAL_CACHE.thread_cache[thread+1], ibuf, tx, ty);
return imb_thread_cache_get_tile(&GLOBAL_CACHE.thread_cache[thread + 1], ibuf, tx, ty);
}
void IMB_tiles_to_rect(ImBuf *ibuf)
@@ -412,12 +412,12 @@ void IMB_tiles_to_rect(ImBuf *ibuf)
unsigned int *to, *from;
int a, tx, ty, y, w, h;
for (a=0; a<ibuf->miptot; a++) {
mipbuf= IMB_getmipmap(ibuf, a);
for (a = 0; a < ibuf->miptot; a++) {
mipbuf = IMB_getmipmap(ibuf, a);
/* don't call imb_addrectImBuf, it frees all mipmaps */
if (!mipbuf->rect) {
if ((mipbuf->rect = MEM_mapallocN(ibuf->x*ibuf->y*sizeof(unsigned int), "imb_addrectImBuf"))) {
if ((mipbuf->rect = MEM_mapallocN(ibuf->x * ibuf->y * sizeof(unsigned int), "imb_addrectImBuf"))) {
mipbuf->mall |= IB_rect;
mipbuf->flags |= IB_rect;
}
@@ -425,22 +425,22 @@ void IMB_tiles_to_rect(ImBuf *ibuf)
break;
}
for (ty=0; ty<mipbuf->ytiles; ty++) {
for (tx=0; tx<mipbuf->xtiles; tx++) {
for (ty = 0; ty < mipbuf->ytiles; ty++) {
for (tx = 0; tx < mipbuf->xtiles; tx++) {
/* acquire tile through cache, this assumes cache is initialized,
* which it is always now but it's a weak assumption ... */
gtile= imb_global_cache_get_tile(mipbuf, tx, ty, NULL);
gtile = imb_global_cache_get_tile(mipbuf, tx, ty, NULL);
/* setup pointers */
from= mipbuf->tiles[mipbuf->xtiles*ty + tx];
to= mipbuf->rect + mipbuf->x*ty*mipbuf->tiley + tx*mipbuf->tilex;
from = mipbuf->tiles[mipbuf->xtiles * ty + tx];
to = mipbuf->rect + mipbuf->x * ty * mipbuf->tiley + tx * mipbuf->tilex;
/* exception in tile width/height for tiles at end of image */
w= (tx == mipbuf->xtiles-1)? mipbuf->x - tx*mipbuf->tilex: mipbuf->tilex;
h= (ty == mipbuf->ytiles-1)? mipbuf->y - ty*mipbuf->tiley: mipbuf->tiley;
w = (tx == mipbuf->xtiles - 1) ? mipbuf->x - tx * mipbuf->tilex : mipbuf->tilex;
h = (ty == mipbuf->ytiles - 1) ? mipbuf->y - ty * mipbuf->tiley : mipbuf->tiley;
for (y=0; y<h; y++) {
memcpy(to, from, sizeof(unsigned int)*w);
for (y = 0; y < h; y++) {
memcpy(to, from, sizeof(unsigned int) * w);
from += mipbuf->tilex;
to += mipbuf->x;
}

View File

@@ -45,18 +45,17 @@
static char magic[] = "BlenMIdx";
static char temp_ext [] = "_part";
static char temp_ext[] = "_part";
static int proxy_sizes[] = { IMB_PROXY_25, IMB_PROXY_50, IMB_PROXY_75,
IMB_PROXY_100 };
IMB_PROXY_100 };
static float proxy_fac[] = { 0.25, 0.50, 0.75, 1.00 };
#ifdef WITH_FFMPEG
static int tc_types[] = { IMB_TC_RECORD_RUN,
IMB_TC_FREE_RUN,
IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN,
IMB_TC_RECORD_RUN_NO_GAPS,
};
static int tc_types[] = {IMB_TC_RECORD_RUN,
IMB_TC_FREE_RUN,
IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN,
IMB_TC_RECORD_RUN_NO_GAPS};
#endif
#define INDEX_FILE_VERSION 1
@@ -65,11 +64,11 @@ static int tc_types[] = { IMB_TC_RECORD_RUN,
* - time code index functions
* ---------------------------------------------------------------------- */
anim_index_builder * IMB_index_builder_create(const char * name)
anim_index_builder *IMB_index_builder_create(const char *name)
{
anim_index_builder * rv = MEM_callocN(sizeof(struct anim_index_builder),
"index builder");
anim_index_builder *rv = MEM_callocN(sizeof(struct anim_index_builder),
"index builder");
fprintf(stderr, "Starting work on index: %s\n", name);
@@ -84,21 +83,21 @@ anim_index_builder * IMB_index_builder_create(const char * name)
if (!rv->fp) {
fprintf(stderr, "Couldn't open index target: %s! "
"Index build broken!\n", rv->temp_name);
"Index build broken!\n", rv->temp_name);
MEM_freeN(rv);
return NULL;
}
fprintf(rv->fp, "%s%c%.3d", magic, (ENDIAN_ORDER==B_ENDIAN)?'V':'v',
INDEX_FILE_VERSION);
fprintf(rv->fp, "%s%c%.3d", magic, (ENDIAN_ORDER == B_ENDIAN) ? 'V' : 'v',
INDEX_FILE_VERSION);
return rv;
}
void IMB_index_builder_add_entry(anim_index_builder * fp,
int frameno, unsigned long long seek_pos,
unsigned long long seek_pos_dts,
unsigned long long pts)
void IMB_index_builder_add_entry(anim_index_builder *fp,
int frameno, unsigned long long seek_pos,
unsigned long long seek_pos_dts,
unsigned long long pts)
{
fwrite(&frameno, sizeof(int), 1, fp->fp);
fwrite(&seek_pos, sizeof(unsigned long long), 1, fp->fp);
@@ -106,12 +105,12 @@ void IMB_index_builder_add_entry(anim_index_builder * fp,
fwrite(&pts, sizeof(unsigned long long), 1, fp->fp);
}
void IMB_index_builder_proc_frame(anim_index_builder * fp,
unsigned char * buffer,
int data_size,
int frameno, unsigned long long seek_pos,
unsigned long long seek_pos_dts,
unsigned long long pts)
void IMB_index_builder_proc_frame(anim_index_builder *fp,
unsigned char *buffer,
int data_size,
int frameno, unsigned long long seek_pos,
unsigned long long seek_pos_dts,
unsigned long long pts)
{
if (fp->proc_frame) {
anim_index_entry e;
@@ -124,11 +123,11 @@ void IMB_index_builder_proc_frame(anim_index_builder * fp,
}
else {
IMB_index_builder_add_entry(fp, frameno, seek_pos,
seek_pos_dts, pts);
seek_pos_dts, pts);
}
}
void IMB_index_builder_finish(anim_index_builder * fp, int rollback)
void IMB_index_builder_finish(anim_index_builder *fp, int rollback)
{
if (fp->delete_priv_data) {
fp->delete_priv_data(fp);
@@ -147,11 +146,11 @@ void IMB_index_builder_finish(anim_index_builder * fp, int rollback)
MEM_freeN(fp);
}
struct anim_index * IMB_indexer_open(const char * name)
struct anim_index *IMB_indexer_open(const char *name)
{
char header[13];
struct anim_index * idx;
FILE * fp = BLI_fopen(name, "rb");
struct anim_index *idx;
FILE *fp = BLI_fopen(name, "rb");
int i;
if (!fp) {
@@ -170,7 +169,7 @@ struct anim_index * IMB_indexer_open(const char * name)
return NULL;
}
if (atoi(header+9) != INDEX_FILE_VERSION) {
if (atoi(header + 9) != INDEX_FILE_VERSION) {
fclose(fp);
return NULL;
}
@@ -182,11 +181,11 @@ struct anim_index * IMB_indexer_open(const char * name)
fseek(fp, 0, SEEK_END);
idx->num_entries = (ftell(fp) - 12) /
(sizeof(int) + // framepos
sizeof(unsigned long long) + // seek_pos
sizeof(unsigned long long) + // seek_pos_dts
sizeof(unsigned long long) // pts
);
(sizeof(int) + // framepos
sizeof(unsigned long long) + // seek_pos
sizeof(unsigned long long) + // seek_pos_dts
sizeof(unsigned long long) // pts
);
fseek(fp, 12, SEEK_SET);
@@ -219,7 +218,7 @@ struct anim_index * IMB_indexer_open(const char * name)
}
unsigned long long IMB_indexer_get_seek_pos(
struct anim_index * idx, int frame_index)
struct anim_index *idx, int frame_index)
{
if (frame_index < 0) {
frame_index = 0;
@@ -231,7 +230,7 @@ unsigned long long IMB_indexer_get_seek_pos(
}
unsigned long long IMB_indexer_get_seek_pos_dts(
struct anim_index * idx, int frame_index)
struct anim_index *idx, int frame_index)
{
if (frame_index < 0) {
frame_index = 0;
@@ -242,7 +241,7 @@ unsigned long long IMB_indexer_get_seek_pos_dts(
return idx->entries[frame_index].seek_pos_dts;
}
int IMB_indexer_get_frame_index(struct anim_index * idx, int frameno)
int IMB_indexer_get_frame_index(struct anim_index *idx, int frameno)
{
int len = idx->num_entries;
int half;
@@ -275,8 +274,8 @@ int IMB_indexer_get_frame_index(struct anim_index * idx, int frameno)
}
}
unsigned long long IMB_indexer_get_pts(struct anim_index * idx,
int frame_index)
unsigned long long IMB_indexer_get_pts(struct anim_index *idx,
int frame_index)
{
if (frame_index < 0) {
frame_index = 0;
@@ -287,16 +286,16 @@ unsigned long long IMB_indexer_get_pts(struct anim_index * idx,
return idx->entries[frame_index].pts;
}
int IMB_indexer_get_duration(struct anim_index * idx)
int IMB_indexer_get_duration(struct anim_index *idx)
{
if (idx->num_entries == 0) {
return 0;
}
return idx->entries[idx->num_entries-1].frameno + 1;
return idx->entries[idx->num_entries - 1].frameno + 1;
}
int IMB_indexer_can_scan(struct anim_index * idx,
int old_frame_index, int new_frame_index)
int IMB_indexer_can_scan(struct anim_index *idx,
int old_frame_index, int new_frame_index)
{
/* makes only sense, if it is the same I-Frame and we are not
* trying to run backwards in time... */
@@ -304,7 +303,7 @@ int IMB_indexer_can_scan(struct anim_index * idx,
old_frame_index < new_frame_index);
}
void IMB_indexer_close(struct anim_index * idx)
void IMB_indexer_close(struct anim_index *idx)
{
MEM_freeN(idx->entries);
MEM_freeN(idx);
@@ -313,19 +312,19 @@ void IMB_indexer_close(struct anim_index * idx)
int IMB_proxy_size_to_array_index(IMB_Proxy_Size pr_size)
{
switch (pr_size) {
case IMB_PROXY_NONE: /* if we got here, something is broken anyways,
so sane defaults... */
return 0;
case IMB_PROXY_25:
return 0;
case IMB_PROXY_50:
return 1;
case IMB_PROXY_75:
return 2;
case IMB_PROXY_100:
return 3;
default:
return 0;
case IMB_PROXY_NONE: /* if we got here, something is broken anyways,
so sane defaults... */
return 0;
case IMB_PROXY_25:
return 0;
case IMB_PROXY_50:
return 1;
case IMB_PROXY_75:
return 2;
case IMB_PROXY_100:
return 3;
default:
return 0;
};
return 0;
}
@@ -333,19 +332,19 @@ int IMB_proxy_size_to_array_index(IMB_Proxy_Size pr_size)
int IMB_timecode_to_array_index(IMB_Timecode_Type tc)
{
switch (tc) {
case IMB_TC_NONE: /* if we got here, something is broken anyways,
so sane defaults... */
return 0;
case IMB_TC_RECORD_RUN:
return 0;
case IMB_TC_FREE_RUN:
return 1;
case IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN:
return 2;
case IMB_TC_RECORD_RUN_NO_GAPS:
return 3;
default:
return 0;
case IMB_TC_NONE: /* if we got here, something is broken anyways,
so sane defaults... */
return 0;
case IMB_TC_RECORD_RUN:
return 0;
case IMB_TC_FREE_RUN:
return 1;
case IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN:
return 2;
case IMB_TC_RECORD_RUN_NO_GAPS:
return 3;
default:
return 0;
};
return 0;
}
@@ -355,7 +354,7 @@ int IMB_timecode_to_array_index(IMB_Timecode_Type tc)
* - rebuild helper functions
* ---------------------------------------------------------------------- */
static void get_index_dir(struct anim * anim, char * index_dir)
static void get_index_dir(struct anim *anim, char *index_dir)
{
if (!anim->index_dir[0]) {
char fname[FILE_MAXFILE];
@@ -369,8 +368,8 @@ static void get_index_dir(struct anim * anim, char * index_dir)
}
}
static void get_proxy_filename(struct anim * anim, IMB_Proxy_Size preview_size,
char * fname, int temp)
static void get_proxy_filename(struct anim *anim, IMB_Proxy_Size preview_size,
char *fname, int temp)
{
char index_dir[FILE_MAXDIR];
int i = IMB_proxy_size_to_array_index(preview_size);
@@ -386,9 +385,9 @@ static void get_proxy_filename(struct anim * anim, IMB_Proxy_Size preview_size,
}
BLI_snprintf(proxy_name, sizeof(proxy_name), "proxy_%d%s.avi",
(int) (proxy_fac[i] * 100), stream_suffix);
(int) (proxy_fac[i] * 100), stream_suffix);
BLI_snprintf(proxy_temp_name, sizeof(proxy_temp_name), "proxy_%d%s_part.avi",
(int) (proxy_fac[i] * 100), stream_suffix);
(int) (proxy_fac[i] * 100), stream_suffix);
get_index_dir(anim, index_dir);
@@ -396,16 +395,17 @@ static void get_proxy_filename(struct anim * anim, IMB_Proxy_Size preview_size,
temp ? proxy_temp_name : proxy_name);
}
static void get_tc_filename(struct anim * anim, IMB_Timecode_Type tc,
char * fname)
static void get_tc_filename(struct anim *anim, IMB_Timecode_Type tc,
char *fname)
{
char index_dir[FILE_MAXDIR];
int i = IMB_timecode_to_array_index(tc);
const char * index_names[] = {
const char *index_names[] = {
"record_run%s.blen_tc",
"free_run%s.blen_tc",
"interp_free_run%s.blen_tc",
"record_run_no_gaps%s.blen_tc"};
"record_run_no_gaps%s.blen_tc"
};
char stream_suffix[20];
char index_name[256];
@@ -440,18 +440,18 @@ typedef struct IndexBuildContext {
#ifdef WITH_FFMPEG
struct proxy_output_ctx {
AVFormatContext* of;
AVStream* st;
AVCodecContext* c;
AVCodec* codec;
struct SwsContext * sws_ctx;
AVFrame* frame;
uint8_t* video_buffer;
AVFormatContext *of;
AVStream *st;
AVCodecContext *c;
AVCodec *codec;
struct SwsContext *sws_ctx;
AVFrame *frame;
uint8_t *video_buffer;
int video_buffersize;
int cfra;
int proxy_size;
int orig_height;
struct anim * anim;
struct anim *anim;
};
// work around stupid swscaler 16 bytes alignment bug...
@@ -461,13 +461,13 @@ static int round_up(int x, int mod)
return x + ((mod - (x % mod)) % mod);
}
static struct proxy_output_ctx * alloc_proxy_output_ffmpeg(
struct anim * anim,
AVStream * st, int proxy_size, int width, int height,
int quality)
static struct proxy_output_ctx *alloc_proxy_output_ffmpeg(
struct anim *anim,
AVStream *st, int proxy_size, int width, int height,
int quality)
{
struct proxy_output_ctx * rv = MEM_callocN(
sizeof(struct proxy_output_ctx), "alloc_proxy_output");
struct proxy_output_ctx *rv = MEM_callocN(
sizeof(struct proxy_output_ctx), "alloc_proxy_output");
char fname[FILE_MAX];
int ffmpeg_quality;
@@ -501,7 +501,7 @@ static struct proxy_output_ctx * alloc_proxy_output_ffmpeg(
if (!rv->codec) {
fprintf(stderr, "No ffmpeg MJPEG encoder available? "
"Proxy not built!\n");
"Proxy not built!\n");
av_free(rv->of);
return NULL;
}
@@ -514,7 +514,7 @@ static struct proxy_output_ctx * alloc_proxy_output_ffmpeg(
}
rv->c->sample_aspect_ratio =
rv->st->sample_aspect_ratio =
rv->st->sample_aspect_ratio =
st->codec->sample_aspect_ratio;
rv->c->time_base.den = 25;
@@ -533,14 +533,14 @@ static struct proxy_output_ctx * alloc_proxy_output_ffmpeg(
if (av_set_parameters(rv->of, NULL) < 0) {
fprintf(stderr, "Couldn't set output parameters? "
"Proxy not built!\n");
"Proxy not built!\n");
av_free(rv->of);
return 0;
}
if (avio_open(&rv->of->pb, fname, AVIO_FLAG_WRITE) < 0) {
fprintf(stderr, "Couldn't open outputfile! "
"Proxy not built!\n");
"Proxy not built!\n");
av_free(rv->of);
return 0;
}
@@ -548,16 +548,16 @@ static struct proxy_output_ctx * alloc_proxy_output_ffmpeg(
avcodec_open(rv->c, rv->codec);
rv->video_buffersize = 2000000;
rv->video_buffer = (uint8_t*)MEM_mallocN(
rv->video_buffersize, "FFMPEG video buffer");
rv->video_buffer = (uint8_t *)MEM_mallocN(
rv->video_buffersize, "FFMPEG video buffer");
rv->orig_height = st->codec->height;
if (st->codec->width != width || st->codec->height != height ||
st->codec->pix_fmt != rv->c->pix_fmt)
st->codec->pix_fmt != rv->c->pix_fmt)
{
rv->frame = avcodec_alloc_frame();
avpicture_fill((AVPicture*) rv->frame,
avpicture_fill((AVPicture *) rv->frame,
MEM_mallocN(avpicture_get_size(
rv->c->pix_fmt,
round_up(width, 16), height),
@@ -565,13 +565,13 @@ static struct proxy_output_ctx * alloc_proxy_output_ffmpeg(
rv->c->pix_fmt, round_up(width, 16), height);
rv->sws_ctx = sws_getContext(
st->codec->width,
st->codec->height,
st->codec->pix_fmt,
width, height,
rv->c->pix_fmt,
SWS_FAST_BILINEAR | SWS_PRINT_INFO,
NULL, NULL, NULL);
st->codec->width,
st->codec->height,
st->codec->pix_fmt,
width, height,
rv->c->pix_fmt,
SWS_FAST_BILINEAR | SWS_PRINT_INFO,
NULL, NULL, NULL);
}
av_write_header(rv->of);
@@ -580,7 +580,7 @@ static struct proxy_output_ctx * alloc_proxy_output_ffmpeg(
}
static int add_to_proxy_output_ffmpeg(
struct proxy_output_ctx * ctx, AVFrame * frame)
struct proxy_output_ctx *ctx, AVFrame *frame)
{
int outsize = 0;
@@ -588,11 +588,11 @@ static int add_to_proxy_output_ffmpeg(
return 0;
}
if ( ctx->sws_ctx && frame &&
(frame->data[0] || frame->data[1] ||
frame->data[2] || frame->data[3]))
if (ctx->sws_ctx && frame &&
(frame->data[0] || frame->data[1] ||
frame->data[2] || frame->data[3]))
{
sws_scale(ctx->sws_ctx, (const uint8_t * const*) frame->data,
sws_scale(ctx->sws_ctx, (const uint8_t *const *) frame->data,
frame->linesize, 0, ctx->orig_height,
ctx->frame->data, ctx->frame->linesize);
}
@@ -604,12 +604,12 @@ static int add_to_proxy_output_ffmpeg(
}
outsize = avcodec_encode_video(
ctx->c, ctx->video_buffer, ctx->video_buffersize,
frame);
ctx->c, ctx->video_buffer, ctx->video_buffersize,
frame);
if (outsize < 0) {
fprintf(stderr, "Error encoding proxy frame %d for '%s'\n",
ctx->cfra - 1, ctx->of->filename);
ctx->cfra - 1, ctx->of->filename);
return 0;
}
@@ -619,8 +619,8 @@ static int add_to_proxy_output_ffmpeg(
if (ctx->c->coded_frame->pts != AV_NOPTS_VALUE) {
packet.pts = av_rescale_q(ctx->c->coded_frame->pts,
ctx->c->time_base,
ctx->st->time_base);
ctx->c->time_base,
ctx->st->time_base);
}
if (ctx->c->coded_frame->key_frame)
packet.flags |= AV_PKT_FLAG_KEY;
@@ -631,8 +631,8 @@ static int add_to_proxy_output_ffmpeg(
if (av_interleaved_write_frame(ctx->of, &packet) != 0) {
fprintf(stderr, "Error writing proxy frame %d "
"into '%s'\n", ctx->cfra - 1,
ctx->of->filename);
"into '%s'\n", ctx->cfra - 1,
ctx->of->filename);
return 0;
}
@@ -643,8 +643,8 @@ static int add_to_proxy_output_ffmpeg(
}
}
static void free_proxy_output_ffmpeg(struct proxy_output_ctx * ctx,
int rollback)
static void free_proxy_output_ffmpeg(struct proxy_output_ctx *ctx,
int rollback)
{
int i;
char fname[FILE_MAX];
@@ -714,8 +714,8 @@ typedef struct FFmpegIndexBuilderContext {
int num_proxy_sizes;
int num_indexers;
struct proxy_output_ctx * proxy_ctx[IMB_PROXY_MAX_SLOT];
anim_index_builder * indexer [IMB_TC_MAX_SLOT];
struct proxy_output_ctx *proxy_ctx[IMB_PROXY_MAX_SLOT];
anim_index_builder *indexer[IMB_TC_MAX_SLOT];
IMB_Timecode_Type tcs_in_use;
IMB_Proxy_Size proxy_sizes_in_use;
@@ -790,10 +790,10 @@ static IndexBuildContext *index_ffmpeg_create_context(struct anim *anim, IMB_Tim
for (i = 0; i < num_proxy_sizes; i++) {
if (proxy_sizes_in_use & proxy_sizes[i]) {
context->proxy_ctx[i] = alloc_proxy_output_ffmpeg(
anim, context->iStream, proxy_sizes[i],
context->iCodecCtx->width * proxy_fac[i],
context->iCodecCtx->height * proxy_fac[i],
quality);
anim, context->iStream, proxy_sizes[i],
context->iCodecCtx->width * proxy_fac[i],
context->iCodecCtx->height * proxy_fac[i],
quality);
if (!context->proxy_ctx[i]) {
proxy_sizes_in_use &= ~proxy_sizes[i];
}
@@ -849,7 +849,7 @@ static int index_rebuild_ffmpeg(FFmpegIndexBuilderContext *context,
double pts_time_base;
int frameno = 0, frameno_gapless = 0;
int start_pts_set = FALSE;
AVFrame* in_frame = 0;
AVFrame *in_frame = 0;
AVPacket next_packet;
uint64_t stream_size;
@@ -863,7 +863,7 @@ static int index_rebuild_ffmpeg(FFmpegIndexBuilderContext *context,
while (av_read_frame(context->iFormatCtx, &next_packet) >= 0) {
int frame_finished = 0;
float next_progress = (float)((int)floor(((double) next_packet.pos) * 100 /
((double) stream_size)+0.5)) / 100;
((double) stream_size) + 0.5)) / 100;
if (*progress != next_progress) {
*progress = next_progress;
@@ -885,8 +885,8 @@ static int index_rebuild_ffmpeg(FFmpegIndexBuilderContext *context,
}
avcodec_decode_video2(
context->iCodecCtx, in_frame, &frame_finished,
&next_packet);
context->iCodecCtx, in_frame, &frame_finished,
&next_packet);
}
if (frame_finished) {
@@ -896,7 +896,7 @@ static int index_rebuild_ffmpeg(FFmpegIndexBuilderContext *context,
for (i = 0; i < context->num_proxy_sizes; i++) {
add_to_proxy_output_ffmpeg(
context->proxy_ctx[i], in_frame);
context->proxy_ctx[i], in_frame);
}
if (!start_pts_set) {
@@ -927,11 +927,11 @@ static int index_rebuild_ffmpeg(FFmpegIndexBuilderContext *context,
tc_frameno = frameno_gapless;
IMB_index_builder_proc_frame(
context->indexer[i],
next_packet.data,
next_packet.size,
tc_frameno,
s_pos, s_dts, pts);
context->indexer[i],
next_packet.data,
next_packet.size,
tc_frameno,
s_pos, s_dts, pts);
}
}
@@ -959,16 +959,16 @@ typedef struct FallbackIndexBuilderContext {
IMB_Proxy_Size proxy_sizes_in_use;
} FallbackIndexBuilderContext;
static AviMovie * alloc_proxy_output_avi(
struct anim * anim, char * filename, int width, int height,
int quality)
static AviMovie *alloc_proxy_output_avi(
struct anim *anim, char *filename, int width, int height,
int quality)
{
int x, y;
AviFormat format;
double framerate;
AviMovie * avi;
AviMovie *avi;
short frs_sec = 25; /* it doesn't really matter for proxies,
but sane defaults help anyways...*/
but sane defaults help anyways...*/
float frs_sec_base = 1.0;
IMB_anim_get_fps(anim, &frs_sec, &frs_sec_base);
@@ -976,24 +976,24 @@ static AviMovie * alloc_proxy_output_avi(
x = width;
y = height;
framerate= (double) frs_sec / (double) frs_sec_base;
framerate = (double) frs_sec / (double) frs_sec_base;
avi = MEM_mallocN (sizeof(AviMovie), "avimovie");
avi = MEM_mallocN(sizeof(AviMovie), "avimovie");
format = AVI_FORMAT_MJPEG;
if (AVI_open_compress (filename, avi, 1, format) != AVI_ERROR_NONE) {
if (AVI_open_compress(filename, avi, 1, format) != AVI_ERROR_NONE) {
MEM_freeN(avi);
return NULL;
}
AVI_set_compress_option (avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_WIDTH, &x);
AVI_set_compress_option (avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_HEIGHT, &y);
AVI_set_compress_option (avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_QUALITY, &quality);
AVI_set_compress_option (avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_FRAMERATE, &framerate);
AVI_set_compress_option(avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_WIDTH, &x);
AVI_set_compress_option(avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_HEIGHT, &y);
AVI_set_compress_option(avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_QUALITY, &quality);
AVI_set_compress_option(avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_FRAMERATE, &framerate);
avi->interlace= 0;
avi->odd_fields= 0;
avi->interlace = 0;
avi->odd_fields = 0;
return avi;
}
@@ -1005,10 +1005,10 @@ static IndexBuildContext *index_fallback_create_context(struct anim *anim, IMB_T
int i;
/* since timecode indices only work with ffmpeg right now,
don't know a sensible fallback here...
so no proxies, no game to play...
*/
* don't know a sensible fallback here...
*
* so no proxies, no game to play...
*/
if (proxy_sizes_in_use == IMB_PROXY_NONE) {
return NULL;
}
@@ -1028,7 +1028,7 @@ static IndexBuildContext *index_fallback_create_context(struct anim *anim, IMB_T
BLI_make_existing_file(fname);
context->proxy_ctx[i] = alloc_proxy_output_avi(anim, fname,
anim->x * proxy_fac[i], anim->y * proxy_fac[i], quality);
anim->x * proxy_fac[i], anim->y * proxy_fac[i], quality);
}
}
@@ -1089,15 +1089,15 @@ static void index_rebuild_fallback(FallbackIndexBuilderContext *context,
int x = anim->x * proxy_fac[i];
int y = anim->y * proxy_fac[i];
struct ImBuf * s_ibuf = IMB_dupImBuf(tmp_ibuf);
struct ImBuf *s_ibuf = IMB_dupImBuf(tmp_ibuf);
IMB_scalefastImBuf(s_ibuf, x, y);
IMB_convert_rgba_to_abgr(s_ibuf);
AVI_write_frame (context->proxy_ctx[i], pos,
AVI_FORMAT_RGB32,
s_ibuf->rect, x * y * 4);
AVI_write_frame(context->proxy_ctx[i], pos,
AVI_FORMAT_RGB32,
s_ibuf->rect, x * y * 4);
/* note that libavi free's the buffer... */
s_ibuf->rect = NULL;
@@ -1116,19 +1116,19 @@ static void index_rebuild_fallback(FallbackIndexBuilderContext *context,
* ---------------------------------------------------------------------- */
IndexBuildContext *IMB_anim_index_rebuild_context(struct anim *anim, IMB_Timecode_Type tcs_in_use,
IMB_Proxy_Size proxy_sizes_in_use, int quality)
IMB_Proxy_Size proxy_sizes_in_use, int quality)
{
IndexBuildContext *context = NULL;
switch (anim->curtype) {
#ifdef WITH_FFMPEG
case ANIM_FFMPEG:
context = index_ffmpeg_create_context(anim, tcs_in_use, proxy_sizes_in_use, quality);
break;
case ANIM_FFMPEG:
context = index_ffmpeg_create_context(anim, tcs_in_use, proxy_sizes_in_use, quality);
break;
#endif
default:
context = index_fallback_create_context(anim, tcs_in_use, proxy_sizes_in_use, quality);
break;
default:
context = index_fallback_create_context(anim, tcs_in_use, proxy_sizes_in_use, quality);
break;
}
if (context)
@@ -1142,13 +1142,13 @@ void IMB_anim_index_rebuild(struct IndexBuildContext *context,
{
switch (context->anim_type) {
#ifdef WITH_FFMPEG
case ANIM_FFMPEG:
index_rebuild_ffmpeg((FFmpegIndexBuilderContext*)context, stop, do_update, progress);
break;
case ANIM_FFMPEG:
index_rebuild_ffmpeg((FFmpegIndexBuilderContext *)context, stop, do_update, progress);
break;
#endif
default:
index_rebuild_fallback((FallbackIndexBuilderContext*)context, stop, do_update, progress);
break;
default:
index_rebuild_fallback((FallbackIndexBuilderContext *)context, stop, do_update, progress);
break;
}
}
@@ -1156,18 +1156,18 @@ void IMB_anim_index_rebuild_finish(IndexBuildContext *context, short stop)
{
switch (context->anim_type) {
#ifdef WITH_FFMPEG
case ANIM_FFMPEG:
index_rebuild_ffmpeg_finish((FFmpegIndexBuilderContext*)context, stop);
break;
case ANIM_FFMPEG:
index_rebuild_ffmpeg_finish((FFmpegIndexBuilderContext *)context, stop);
break;
#endif
default:
index_rebuild_fallback_finish((FallbackIndexBuilderContext*)context, stop);
break;
default:
index_rebuild_fallback_finish((FallbackIndexBuilderContext *)context, stop);
break;
}
}
void IMB_free_indices(struct anim * anim)
void IMB_free_indices(struct anim *anim)
{
int i;
@@ -1190,7 +1190,7 @@ void IMB_free_indices(struct anim * anim)
anim->indices_tried = 0;
}
void IMB_anim_set_index_dir(struct anim * anim, const char * dir)
void IMB_anim_set_index_dir(struct anim *anim, const char *dir)
{
if (strcmp(anim->index_dir, dir) == 0) {
return;
@@ -1200,8 +1200,8 @@ void IMB_anim_set_index_dir(struct anim * anim, const char * dir)
IMB_free_indices(anim);
}
struct anim * IMB_anim_open_proxy(
struct anim * anim, IMB_Proxy_Size preview_size)
struct anim *IMB_anim_open_proxy(
struct anim *anim, IMB_Proxy_Size preview_size)
{
char fname[FILE_MAX];
int i = IMB_proxy_size_to_array_index(preview_size);
@@ -1223,8 +1223,8 @@ struct anim * IMB_anim_open_proxy(
return anim->proxy_anim[i];
}
struct anim_index * IMB_anim_open_index(
struct anim * anim, IMB_Timecode_Type tc)
struct anim_index *IMB_anim_open_index(
struct anim *anim, IMB_Timecode_Type tc)
{
char fname[FILE_MAX];
int i = IMB_timecode_to_array_index(tc);
@@ -1246,10 +1246,10 @@ struct anim_index * IMB_anim_open_index(
return anim->curr_idx[i];
}
int IMB_anim_index_get_frame_index(struct anim * anim, IMB_Timecode_Type tc,
int position)
int IMB_anim_index_get_frame_index(struct anim *anim, IMB_Timecode_Type tc,
int position)
{
struct anim_index * idx = IMB_anim_open_index(anim, tc);
struct anim_index *idx = IMB_anim_open_index(anim, tc);
if (!idx) {
return position;

View File

@@ -28,11 +28,11 @@
#include <time.h>
typedef struct indexer_dv_bitstream {
unsigned char* buffer;
unsigned char *buffer;
int bit_pos;
} indexer_dv_bitstream;
static indexer_dv_bitstream bitstream_new(unsigned char* buffer_)
static indexer_dv_bitstream bitstream_new(unsigned char *buffer_)
{
indexer_dv_bitstream rv;
@@ -42,27 +42,27 @@ static indexer_dv_bitstream bitstream_new(unsigned char* buffer_)
return rv;
}
static unsigned long bitstream_get_bits(indexer_dv_bitstream * This, int num)
static unsigned long bitstream_get_bits(indexer_dv_bitstream *This, int num)
{
int byte_pos = This->bit_pos >> 3;
unsigned long i =
This->buffer[byte_pos] | (This->buffer[byte_pos + 1] << 8) |
(This->buffer[byte_pos + 2] << 16) |
(This->buffer[byte_pos + 3] << 24);
This->buffer[byte_pos] | (This->buffer[byte_pos + 1] << 8) |
(This->buffer[byte_pos + 2] << 16) |
(This->buffer[byte_pos + 3] << 24);
int rval = (i >> (This->bit_pos & 0x7)) & ((1 << num) - 1);
This->bit_pos += num;
return rval;
}
static int parse_num(indexer_dv_bitstream * b, int numbits)
static int parse_num(indexer_dv_bitstream *b, int numbits)
{
return bitstream_get_bits(b, numbits);
}
static int parse_bcd(indexer_dv_bitstream * b, int n)
static int parse_bcd(indexer_dv_bitstream *b, int n)
{
char s[256];
char * p = s + (n+3)/4;
char *p = s + (n + 3) / 4;
*p-- = 0;
@@ -93,8 +93,7 @@ static int parse_bcd(indexer_dv_bitstream * b, int n)
return atol(s);
}
typedef struct indexer_dv_context
{
typedef struct indexer_dv_context {
int rec_curr_frame;
int rec_curr_second;
int rec_curr_minute;
@@ -119,10 +118,10 @@ typedef struct indexer_dv_context
anim_index_entry backbuffer[31];
int fsize;
anim_index_builder * idx;
anim_index_builder *idx;
} indexer_dv_context;
static void parse_packet(indexer_dv_context * This, unsigned char * p)
static void parse_packet(indexer_dv_context *This, unsigned char *p)
{
indexer_dv_bitstream b;
int type = p[0];
@@ -158,7 +157,7 @@ static void parse_packet(indexer_dv_context * This, unsigned char * p)
}
}
static void parse_header_block(indexer_dv_context * This, unsigned char* target)
static void parse_header_block(indexer_dv_context *This, unsigned char *target)
{
int i;
for (i = 3; i < 80; i += 5) {
@@ -169,7 +168,7 @@ static void parse_header_block(indexer_dv_context * This, unsigned char* target)
}
static void parse_subcode_blocks(
indexer_dv_context * This, unsigned char* target)
indexer_dv_context *This, unsigned char *target)
{
int i, j;
@@ -183,7 +182,7 @@ static void parse_subcode_blocks(
}
static void parse_vaux_blocks(
indexer_dv_context * This, unsigned char* target)
indexer_dv_context *This, unsigned char *target)
{
int i, j;
@@ -198,7 +197,7 @@ static void parse_vaux_blocks(
}
static void parse_audio_headers(
indexer_dv_context * This, unsigned char* target)
indexer_dv_context *This, unsigned char *target)
{
int i;
@@ -210,11 +209,11 @@ static void parse_audio_headers(
}
}
static void parse_frame(indexer_dv_context * This,
unsigned char * framebuffer, int isPAL)
static void parse_frame(indexer_dv_context *This,
unsigned char *framebuffer, int isPAL)
{
int numDIFseq = isPAL ? 12 : 10;
unsigned char* target = framebuffer;
unsigned char *target = framebuffer;
int ds;
for (ds = 0; ds < numDIFseq; ds++) {
@@ -229,7 +228,7 @@ static void parse_frame(indexer_dv_context * This,
}
}
static void inc_frame(int * frame, time_t * t, int isPAL)
static void inc_frame(int *frame, time_t *t, int isPAL)
{
if ((isPAL && *frame >= 25) || (!isPAL && *frame >= 30)) {
fprintf(stderr, "Ouchie: inc_frame: invalid_frameno: %d\n",
@@ -246,20 +245,21 @@ static void inc_frame(int * frame, time_t * t, int isPAL)
}
}
static void write_index(indexer_dv_context * This, anim_index_entry * entry)
static void write_index(indexer_dv_context *This, anim_index_entry *entry)
{
IMB_index_builder_add_entry(
This->idx, entry->frameno + This->frameno_offset,
entry->seek_pos, entry->seek_pos_dts, entry->pts);
This->idx, entry->frameno + This->frameno_offset,
entry->seek_pos, entry->seek_pos_dts, entry->pts);
}
static void fill_gap(indexer_dv_context * This, int isPAL)
static void fill_gap(indexer_dv_context *This, int isPAL)
{
int i;
for (i = 0; i < This->fsize; i++) {
if (This->gap_start == This->ref_time_read &&
This->gap_frame == This->curr_frame) {
This->gap_frame == This->curr_frame)
{
fprintf(stderr,
"indexer_dv::fill_gap: "
"can't seek backwards !\n");
@@ -280,8 +280,8 @@ static void fill_gap(indexer_dv_context * This, int isPAL)
This->fsize = 0;
}
static void proc_frame(indexer_dv_context * This,
unsigned char* UNUSED(framebuffer), int isPAL)
static void proc_frame(indexer_dv_context *This,
unsigned char *UNUSED(framebuffer), int isPAL)
{
struct tm recDate;
time_t t;
@@ -332,14 +332,14 @@ static void proc_frame(indexer_dv_context * This,
}
}
static void indexer_dv_proc_frame(anim_index_builder * idx,
unsigned char * buffer,
static void indexer_dv_proc_frame(anim_index_builder *idx,
unsigned char *buffer,
int UNUSED(data_size),
struct anim_index_entry * entry)
struct anim_index_entry *entry)
{
int isPAL;
indexer_dv_context * This = (indexer_dv_context *) idx->private_data;
indexer_dv_context *This = (indexer_dv_context *) idx->private_data;
isPAL = (buffer[3] & 0x80);
@@ -362,29 +362,29 @@ static void indexer_dv_proc_frame(anim_index_builder * idx,
"backbuffer overrun, emergency flush");
for (i = 0; i < This->fsize; i++) {
write_index(This, This->backbuffer+i);
write_index(This, This->backbuffer + i);
}
This->fsize = 0;
}
}
}
static void indexer_dv_delete(anim_index_builder * idx)
static void indexer_dv_delete(anim_index_builder *idx)
{
int i = 0;
indexer_dv_context * This = (indexer_dv_context *) idx->private_data;
indexer_dv_context *This = (indexer_dv_context *) idx->private_data;
for (i = 0; i < This->fsize; i++) {
write_index(This, This->backbuffer+i);
write_index(This, This->backbuffer + i);
}
MEM_freeN(This);
}
void IMB_indexer_dv_new(anim_index_builder * idx)
void IMB_indexer_dv_new(anim_index_builder *idx)
{
indexer_dv_context * rv = MEM_callocN(
sizeof(indexer_dv_context), "index_dv builder context");
indexer_dv_context *rv = MEM_callocN(
sizeof(indexer_dv_context), "index_dv builder context");
rv->ref_time_read = -1;
rv->curr_frame = -1;

View File

@@ -42,58 +42,58 @@
#include "IMB_filetype.h"
typedef struct {
unsigned short imagic; /* stuff saved on disk . . */
unsigned short type;
unsigned short dim;
unsigned short xsize;
unsigned short ysize;
unsigned short zsize;
unsigned int min;
unsigned int max;
unsigned int wastebytes;
char name[80];
unsigned int colormap;
unsigned short imagic; /* stuff saved on disk . . */
unsigned short type;
unsigned short dim;
unsigned short xsize;
unsigned short ysize;
unsigned short zsize;
unsigned int min;
unsigned int max;
unsigned int wastebytes;
char name[80];
unsigned int colormap;
int file; /* stuff used in core only */
unsigned short flags;
short dorev;
short x;
short y;
short z;
short cnt;
unsigned short *ptr;
unsigned short *base;
unsigned short *tmpbuf;
unsigned int offset;
unsigned int rleend; /* for rle images */
unsigned int *rowstart; /* for rle images */
int *rowsize; /* for rle images */
int file; /* stuff used in core only */
unsigned short flags;
short dorev;
short x;
short y;
short z;
short cnt;
unsigned short *ptr;
unsigned short *base;
unsigned short *tmpbuf;
unsigned int offset;
unsigned int rleend; /* for rle images */
unsigned int *rowstart; /* for rle images */
int *rowsize; /* for rle images */
} IMAGE;
#define RINTLUM (79)
#define GINTLUM (156)
#define BINTLUM (21)
#define ILUM(r, g, b) ((int)(RINTLUM * (r) + GINTLUM * (g) + BINTLUM * (b)) >> 8)
#define ILUM(r, g, b) ((int)(RINTLUM * (r) + GINTLUM * (g) + BINTLUM * (b)) >> 8)
#define OFFSET_R 0 /* this is byte order dependent */
#define OFFSET_G 1
#define OFFSET_B 2
#define OFFSET_A 3
#define OFFSET_R 0 /* this is byte order dependent */
#define OFFSET_G 1
#define OFFSET_B 2
#define OFFSET_A 3
#define CHANOFFSET(z) (3-(z)) /* this is byte order dependent */
#define CHANOFFSET(z) (3 - (z)) /* this is byte order dependent */
#define TYPEMASK 0xff00
#define BPPMASK 0x00ff
#define ITYPE_VERBATIM 0x0000
#define ITYPE_RLE 0x0100
#define ISRLE(type) (((type) & 0xff00) == ITYPE_RLE)
#define ISVERBATIM(type) (((type) & 0xff00) == ITYPE_VERBATIM)
#define BPP(type) ((type) & BPPMASK)
#define RLE(bpp) (ITYPE_RLE | (bpp))
#define VERBATIM(bpp) (ITYPE_VERBATIM | (bpp))
#define IBUFSIZE(pixels) ((pixels+(pixels>>6))<<2)
#define RLE_NOP 0x00
#define TYPEMASK 0xff00
#define BPPMASK 0x00ff
#define ITYPE_VERBATIM 0x0000
#define ITYPE_RLE 0x0100
#define ISRLE(type) (((type) & 0xff00) == ITYPE_RLE)
#define ISVERBATIM(type) (((type) & 0xff00) == ITYPE_VERBATIM)
#define BPP(type) ((type) & BPPMASK)
#define RLE(bpp) (ITYPE_RLE | (bpp))
#define VERBATIM(bpp) (ITYPE_VERBATIM | (bpp))
#define IBUFSIZE(pixels) ((pixels + (pixels >> 6)) << 2)
#define RLE_NOP 0x00
/* funcs */
static void readheader(FILE *inf, IMAGE *image);
@@ -118,37 +118,37 @@ static void lumrow(unsigned char *rgbptr, unsigned char *lumptr, int n);
*
*/
static uchar * file_data;
static uchar *file_data;
static int file_offset;
static unsigned short getshort(FILE *inf)
{
unsigned char * buf;
unsigned char *buf;
(void)inf; /* unused */
buf = file_data + file_offset;
file_offset += 2;
return (buf[0]<<8)+(buf[1]<<0);
return (buf[0] << 8) + (buf[1] << 0);
}
static unsigned int getlong(FILE *inf)
{
unsigned char * buf;
unsigned char *buf;
(void)inf; /* unused */
buf = file_data + file_offset;
file_offset += 4;
return (buf[0]<<24)+(buf[1]<<16)+(buf[2]<<8)+(buf[3]<<0);
return (buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + (buf[3] << 0);
}
static void putshort(FILE *outf, unsigned short val)
{
unsigned char buf[2];
buf[0] = (val>>8);
buf[1] = (val>>0);
buf[0] = (val >> 8);
buf[1] = (val >> 0);
fwrite(buf, 2, 1, outf);
}
@@ -156,10 +156,10 @@ static int putlong(FILE *outf, unsigned int val)
{
unsigned char buf[4];
buf[0] = (val>>24);
buf[1] = (val>>16);
buf[2] = (val>>8);
buf[3] = (val>>0);
buf[0] = (val >> 24);
buf[1] = (val >> 16);
buf[2] = (val >> 8);
buf[3] = (val >> 0);
return fwrite(buf, 4, 1, outf);
}
@@ -176,7 +176,7 @@ static void readheader(FILE *inf, IMAGE *image)
static int writeheader(FILE *outf, IMAGE *image)
{
IMAGE t= {0};
IMAGE t = {0};
fwrite(&t, sizeof(IMAGE), 1, outf);
fseek(outf, 0, SEEK_SET);
@@ -216,14 +216,14 @@ static void test_endian_zbuf(struct ImBuf *ibuf)
int len;
int *zval;
if ( BIG_LONG(1) == 1 ) return;
if (BIG_LONG(1) == 1) return;
if (ibuf->zbuf == NULL) return;
len= ibuf->x*ibuf->y;
zval= ibuf->zbuf;
len = ibuf->x * ibuf->y;
zval = ibuf->zbuf;
while (len--) {
zval[0]= BIG_LONG(zval[0]);
zval[0] = BIG_LONG(zval[0]);
zval++;
}
}
@@ -258,7 +258,7 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags)
int x, y, z, tablen;
int xsize, ysize, zsize;
int bpp, rle, cur, badorder;
ImBuf * ibuf;
ImBuf *ibuf;
(void)size; /* unused */
@@ -294,7 +294,7 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags)
if (rle) {
tablen = ysize*zsize*sizeof(int);
tablen = ysize * zsize * sizeof(int);
starttab = (unsigned int *)MEM_mallocN(tablen, "iris starttab");
lengthtab = (unsigned int *)MEM_mallocN(tablen, "iris endtab");
file_offset = 512;
@@ -305,13 +305,13 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags)
/* check data order */
cur = 0;
badorder = 0;
for (y = 0; y<ysize; y++) {
for (z = 0; z<zsize; z++) {
if (starttab[y+z*ysize]<cur) {
for (y = 0; y < ysize; y++) {
for (z = 0; z < zsize; z++) {
if (starttab[y + z * ysize] < cur) {
badorder = 1;
break;
}
cur = starttab[y+z*ysize];
cur = starttab[y + z * ysize];
}
if (badorder)
break;
@@ -325,15 +325,15 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags)
zbase = (unsigned int *)ibuf->zbuf;
if (badorder) {
for (z=0; z<zsize; z++) {
for (z = 0; z < zsize; z++) {
lptr = base;
for (y=0; y<ysize; y++) {
file_offset = starttab[y+z*ysize];
for (y = 0; y < ysize; y++) {
file_offset = starttab[y + z * ysize];
rledat = file_data + file_offset;
file_offset += lengthtab[y+z*ysize];
file_offset += lengthtab[y + z * ysize];
expandrow((uchar *)lptr, rledat, 3-z);
expandrow((uchar *)lptr, rledat, 3 - z);
lptr += xsize;
}
}
@@ -341,17 +341,17 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags)
else {
lptr = base;
zptr = zbase;
for (y=0; y<ysize; y++) {
for (y = 0; y < ysize; y++) {
for (z=0; z<zsize; z++) {
for (z = 0; z < zsize; z++) {
file_offset = starttab[y+z*ysize];
file_offset = starttab[y + z * ysize];
rledat = file_data + file_offset;
file_offset += lengthtab[y+z*ysize];
file_offset += lengthtab[y + z * ysize];
if (z<4) expandrow((uchar *)lptr, rledat, 3-z);
else if (z<8) expandrow((uchar *)zptr, rledat, 7-z);
if (z < 4) expandrow((uchar *)lptr, rledat, 3 - z);
else if (z < 8) expandrow((uchar *)zptr, rledat, 7 - z);
}
lptr += xsize;
zptr += xsize;
@@ -360,22 +360,22 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags)
}
else { /* bpp == 2 */
else { /* bpp == 2 */
ibuf = IMB_allocImBuf(xsize, ysize, 32, (flags & IB_rect)|IB_rectfloat);
ibuf = IMB_allocImBuf(xsize, ysize, 32, (flags & IB_rect) | IB_rectfloat);
fbase = ibuf->rect_float;
if (badorder) {
for (z=0; z<zsize; z++) {
for (z = 0; z < zsize; z++) {
fptr = fbase;
for (y=0; y<ysize; y++) {
file_offset = starttab[y+z*ysize];
for (y = 0; y < ysize; y++) {
file_offset = starttab[y + z * ysize];
rledat = file_data + file_offset;
file_offset += lengthtab[y+z*ysize];
file_offset += lengthtab[y + z * ysize];
expandrow2(fptr, rledat, 3-z);
expandrow2(fptr, rledat, 3 - z);
fptr += xsize * 4;
}
}
@@ -383,16 +383,16 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags)
else {
fptr = fbase;
for (y=0; y<ysize; y++) {
for (y = 0; y < ysize; y++) {
for (z=0; z<zsize; z++) {
for (z = 0; z < zsize; z++) {
file_offset = starttab[y+z*ysize];
file_offset = starttab[y + z * ysize];
rledat = file_data + file_offset;
file_offset += lengthtab[y+z*ysize];
file_offset += lengthtab[y + z * ysize];
expandrow2(fptr, rledat, 3-z);
expandrow2(fptr, rledat, 3 - z);
}
fptr += xsize * 4;
@@ -418,12 +418,12 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags)
for (z = 0; z < zsize; z++) {
if (z<4) lptr = base;
else if (z<8) lptr= zbase;
if (z < 4) lptr = base;
else if (z < 8) lptr = zbase;
for (y = 0; y < ysize; y++) {
interleaverow((uchar *)lptr, rledat, 3-z, xsize);
interleaverow((uchar *)lptr, rledat, 3 - z, xsize);
rledat += xsize;
lptr += xsize;
@@ -431,9 +431,9 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags)
}
}
else { /* bpp == 2 */
else { /* bpp == 2 */
ibuf = IMB_allocImBuf(xsize, ysize, 32, (flags & IB_rect)|IB_rectfloat);
ibuf = IMB_allocImBuf(xsize, ysize, 32, (flags & IB_rect) | IB_rectfloat);
fbase = ibuf->rect_float;
@@ -446,7 +446,7 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags)
for (y = 0; y < ysize; y++) {
interleaverow2(fptr, rledat, 3-z, xsize);
interleaverow2(fptr, rledat, 3 - z, xsize);
rledat += xsize * 2;
fptr += xsize * 4;
@@ -458,7 +458,7 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags)
if (bpp == 1) {
uchar * rect;
uchar *rect;
if (image.zsize == 1) {
rect = (uchar *) ibuf->rect;
@@ -487,7 +487,7 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags)
}
}
else { /* bpp == 2 */
else { /* bpp == 2 */
if (image.zsize == 1) {
fbase = ibuf->rect_float;
@@ -550,7 +550,7 @@ 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;
*lptr = ((cptr[0] << 8) | (cptr[1] << 0)) / (float)0xFFFF;
cptr += 2;
lptr += 4;
}
@@ -563,50 +563,50 @@ static void expandrow2(float *optr, unsigned char *iptr, int z)
optr += z;
while (1) {
pixel = (iptr[0]<<8) | (iptr[1]<<0);
pixel = (iptr[0] << 8) | (iptr[1] << 0);
iptr += 2;
if ( !(count = (pixel & 0x7f)) )
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;
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;
*optr = ((iptr[0] << 8) | (iptr[1] << 0)) / (float)0xFFFF;
iptr += 2;
optr += 4;
}
}
else {
pixel_f = ((iptr[0]<<8) | (iptr[1]<<0))/(float)0xFFFF;
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;
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;
optr += 4;
}
}
}
@@ -619,44 +619,44 @@ static void expandrow(unsigned char *optr, unsigned char *iptr, int z)
optr += z;
while (1) {
pixel = *iptr++;
if ( !(count = (pixel & 0x7f)) )
if (!(count = (pixel & 0x7f)) )
return;
if (pixel & 0x80) {
while (count>=8) {
optr[0*4] = iptr[0];
optr[1*4] = iptr[1];
optr[2*4] = iptr[2];
optr[3*4] = iptr[3];
optr[4*4] = iptr[4];
optr[5*4] = iptr[5];
optr[6*4] = iptr[6];
optr[7*4] = iptr[7];
optr += 8*4;
while (count >= 8) {
optr[0 * 4] = iptr[0];
optr[1 * 4] = iptr[1];
optr[2 * 4] = iptr[2];
optr[3 * 4] = iptr[3];
optr[4 * 4] = iptr[4];
optr[5 * 4] = iptr[5];
optr[6 * 4] = iptr[6];
optr[7 * 4] = iptr[7];
optr += 8 * 4;
iptr += 8;
count -= 8;
}
while (count--) {
*optr = *iptr++;
optr+=4;
optr += 4;
}
}
else {
pixel = *iptr++;
while (count>=8) {
optr[0*4] = pixel;
optr[1*4] = pixel;
optr[2*4] = pixel;
optr[3*4] = pixel;
optr[4*4] = pixel;
optr[5*4] = pixel;
optr[6*4] = pixel;
optr[7*4] = pixel;
optr += 8*4;
while (count >= 8) {
optr[0 * 4] = pixel;
optr[1 * 4] = pixel;
optr[2 * 4] = pixel;
optr[3 * 4] = pixel;
optr[4 * 4] = pixel;
optr[5 * 4] = pixel;
optr[6 * 4] = pixel;
optr[7 * 4] = pixel;
optr += 8 * 4;
count -= 8;
}
while (count--) {
*optr = pixel;
optr+=4;
optr += 4;
}
}
}
@@ -689,19 +689,19 @@ static int output_iris(unsigned int *lptr, int xsize, int ysize, int zsize, cons
outf = BLI_fopen(name, "wb");
if (!outf) return 0;
tablen = ysize*zsize*sizeof(int);
tablen = ysize * zsize * sizeof(int);
image = (IMAGE *)MEM_mallocN(sizeof(IMAGE), "iris image");
starttab = (unsigned int *)MEM_mallocN(tablen, "iris starttab");
lengthtab = (unsigned int *)MEM_mallocN(tablen, "iris lengthtab");
rlebuflen = 1.05*xsize+10;
rlebuflen = 1.05 * xsize + 10;
rlebuf = (unsigned char *)MEM_mallocN(rlebuflen, "iris rlebuf");
lumbuf = (unsigned int *)MEM_mallocN(xsize*sizeof(int), "iris lumbuf");
lumbuf = (unsigned int *)MEM_mallocN(xsize * sizeof(int), "iris lumbuf");
memset(image, 0, sizeof(IMAGE));
image->imagic = IMAGIC;
image->type = RLE(1);
if (zsize>1)
if (zsize > 1)
image->dim = 3;
else
image->dim = 2;
@@ -711,8 +711,8 @@ static int output_iris(unsigned int *lptr, int xsize, int ysize, int zsize, cons
image->min = 0;
image->max = 255;
goodwrite *= writeheader(outf, image);
fseek(outf, 512+2*tablen, SEEK_SET);
pos = 512+2*tablen;
fseek(outf, 512 + 2 * tablen, SEEK_SET);
pos = 512 + 2 * tablen;
for (y = 0; y < ysize; y++) {
for (z = 0; z < zsize; z++) {
@@ -722,20 +722,20 @@ static int output_iris(unsigned int *lptr, int xsize, int ysize, int zsize, cons
len = compressrow((uchar *)lumbuf, rlebuf, CHANOFFSET(z), xsize);
}
else {
if (z<4) {
if (z < 4) {
len = compressrow((uchar *)lptr, rlebuf, CHANOFFSET(z), xsize);
}
else if (z<8 && zptr) {
len = compressrow((uchar *)zptr, rlebuf, CHANOFFSET(z-4), xsize);
else if (z < 8 && zptr) {
len = compressrow((uchar *)zptr, rlebuf, CHANOFFSET(z - 4), xsize);
}
}
if (len>rlebuflen) {
if (len > rlebuflen) {
fprintf(stderr, "output_iris: rlebuf is too small - bad poop\n");
exit(1);
}
goodwrite *= fwrite(rlebuf, len, 1, outf);
starttab[y+z*ysize] = pos;
lengthtab[y+z*ysize] = len;
starttab[y + z * ysize] = pos;
lengthtab[y + z * ysize] = len;
pos += len;
}
lptr += xsize;
@@ -779,32 +779,32 @@ static int compressrow(unsigned char *lbuf, unsigned char *rlebuf, int z, int cn
lbuf += z;
iptr = lbuf;
ibufend = iptr+cnt*4;
ibufend = iptr + cnt * 4;
optr = rlebuf;
while (iptr<ibufend) {
while (iptr < ibufend) {
sptr = iptr;
iptr += 8;
while ((iptr<ibufend)&& ((iptr[-8]!=iptr[-4])||(iptr[-4]!=iptr[0])))
iptr+=4;
while ((iptr < ibufend) && ((iptr[-8] != iptr[-4]) || (iptr[-4] != iptr[0])))
iptr += 4;
iptr -= 8;
count = (iptr-sptr)/4;
count = (iptr - sptr) / 4;
while (count) {
todo = count>126 ? 126:count;
todo = count > 126 ? 126 : count;
count -= todo;
*optr++ = 0x80|todo;
while (todo>8) {
optr[0] = sptr[0*4];
optr[1] = sptr[1*4];
optr[2] = sptr[2*4];
optr[3] = sptr[3*4];
optr[4] = sptr[4*4];
optr[5] = sptr[5*4];
optr[6] = sptr[6*4];
optr[7] = sptr[7*4];
*optr++ = 0x80 | todo;
while (todo > 8) {
optr[0] = sptr[0 * 4];
optr[1] = sptr[1 * 4];
optr[2] = sptr[2 * 4];
optr[3] = sptr[3 * 4];
optr[4] = sptr[4 * 4];
optr[5] = sptr[5 * 4];
optr[6] = sptr[6 * 4];
optr[7] = sptr[7 * 4];
optr += 8;
sptr += 8*4;
sptr += 8 * 4;
todo -= 8;
}
while (todo--) {
@@ -815,11 +815,11 @@ static int compressrow(unsigned char *lbuf, unsigned char *rlebuf, int z, int cn
sptr = iptr;
cc = *iptr;
iptr += 4;
while ( (iptr<ibufend) && (*iptr == cc) )
while ( (iptr < ibufend) && (*iptr == cc) )
iptr += 4;
count = (iptr-sptr)/4;
count = (iptr - sptr) / 4;
while (count) {
todo = count>126 ? 126:count;
todo = count > 126 ? 126 : count;
count -= todo;
*optr++ = todo;
*optr++ = cc;
@@ -829,7 +829,7 @@ static int compressrow(unsigned char *lbuf, unsigned char *rlebuf, int z, int cn
return optr - (unsigned char *)rlebuf;
}
int imb_saveiris(struct ImBuf * ibuf, const char *name, int flags)
int imb_saveiris(struct ImBuf *ibuf, const char *name, int flags)
{
short zsize;
int ret;

View File

@@ -40,7 +40,7 @@
#define JP2_FILEHEADER_SIZE 14
static char JP2_HEAD[]= {0x0, 0x0, 0x0, 0x0C, 0x6A, 0x50, 0x20, 0x20, 0x0D, 0x0A, 0x87, 0x0A};
static char JP2_HEAD[] = {0x0, 0x0, 0x0, 0x0C, 0x6A, 0x50, 0x20, 0x20, 0x0D, 0x0A, 0x87, 0x0A};
/* We only need this because of how the presets are set */
typedef struct img_folder {
@@ -72,7 +72,7 @@ int imb_is_a_jp2(unsigned char *buf)
*/
static void error_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
FILE *stream = (FILE *)client_data;
fprintf(stream, "[ERROR] %s", msg);
}
/**
@@ -80,7 +80,7 @@ static void error_callback(const char *msg, void *client_data)
*/
static void warning_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
FILE *stream = (FILE *)client_data;
fprintf(stream, "[WARNING] %s", msg);
}
/**
@@ -99,21 +99,21 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags)
struct ImBuf *ibuf = NULL;
int use_float = 0; /* for precision higher then 8 use float */
long signed_offsets[4]= {0, 0, 0, 0};
int float_divs[4]= {1, 1, 1, 1};
long signed_offsets[4] = {0, 0, 0, 0};
int float_divs[4] = {1, 1, 1, 1};
int index;
int w, h, planes;
opj_dparameters_t parameters; /* decompression parameters */
opj_dparameters_t parameters; /* decompression parameters */
opj_event_mgr_t event_mgr; /* event manager */
opj_event_mgr_t event_mgr; /* event manager */
opj_image_t *image = NULL;
int i;
opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */
opj_dinfo_t *dinfo = NULL; /* handle to a decompressor */
opj_cio_t *cio = NULL;
if (check_jp2(mem) == 0) return(NULL);
@@ -166,18 +166,18 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags)
h = image->comps[0].h;
switch (image->numcomps) {
case 1: /* Greyscale */
case 3: /* Color */
planes= 24;
break;
default: /* 2 or 4 - Greyscale or Color + alpha */
planes= 32; /* greyscale + alpha */
break;
case 1: /* Greyscale */
case 3: /* Color */
planes = 24;
break;
default: /* 2 or 4 - Greyscale or Color + alpha */
planes = 32; /* greyscale + alpha */
break;
}
i = image->numcomps;
if (i>4) i= 4;
if (i > 4) i = 4;
while (i) {
i--;
@@ -186,15 +186,15 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags)
use_float = 1;
if (image->comps[i].sgnd)
signed_offsets[i]= 1 << (image->comps[i].prec - 1);
signed_offsets[i] = 1 << (image->comps[i].prec - 1);
/* only needed for float images but dosnt hurt to calc this */
float_divs[i]= (1<<image->comps[i].prec)-1;
float_divs[i] = (1 << image->comps[i].prec) - 1;
}
ibuf= IMB_allocImBuf(w, h, planes, use_float ? IB_rectfloat : IB_rect);
ibuf = IMB_allocImBuf(w, h, planes, use_float ? IB_rectfloat : IB_rect);
if (ibuf==NULL) {
if (ibuf == NULL) {
if (dinfo)
opj_destroy_decompress(dinfo);
return NULL;
@@ -203,67 +203,67 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags)
ibuf->ftype = JP2;
if (use_float) {
float *rect_float= ibuf->rect_float;
float *rect_float = ibuf->rect_float;
if (image->numcomps < 3) {
/* greyscale 12bits+ */
for (i = 0; i < w * h; i++, rect_float+=4) {
for (i = 0; i < w * h; i++, rect_float += 4) {
index = w * h - ((i) / (w) + 1) * w + (i) % (w);
rect_float[0]= rect_float[1]= rect_float[2]= (float)(image->comps[0].data[index] + signed_offsets[0]) / float_divs[0];
rect_float[0] = rect_float[1] = rect_float[2] = (float)(image->comps[0].data[index] + signed_offsets[0]) / float_divs[0];
if (image->numcomps == 2)
rect_float[3]= (image->comps[1].data[index] + signed_offsets[1]) / float_divs[1];
rect_float[3] = (image->comps[1].data[index] + signed_offsets[1]) / float_divs[1];
else
rect_float[3]= 1.0f;
rect_float[3] = 1.0f;
}
}
else {
/* rgb or rgba 12bits+ */
for (i = 0; i < w * h; i++, rect_float+=4) {
for (i = 0; i < w * h; i++, rect_float += 4) {
index = w * h - ((i) / (w) + 1) * w + (i) % (w);
rect_float[0]= (float)(image->comps[0].data[index] + signed_offsets[0]) / float_divs[0];
rect_float[1]= (float)(image->comps[1].data[index] + signed_offsets[1]) / float_divs[1];
rect_float[2]= (float)(image->comps[2].data[index] + signed_offsets[2]) / float_divs[2];
rect_float[0] = (float)(image->comps[0].data[index] + signed_offsets[0]) / float_divs[0];
rect_float[1] = (float)(image->comps[1].data[index] + signed_offsets[1]) / float_divs[1];
rect_float[2] = (float)(image->comps[2].data[index] + signed_offsets[2]) / float_divs[2];
if (image->numcomps >= 4)
rect_float[3]= (float)(image->comps[3].data[index] + signed_offsets[3]) / float_divs[3];
rect_float[3] = (float)(image->comps[3].data[index] + signed_offsets[3]) / float_divs[3];
else
rect_float[3]= 1.0f;
rect_float[3] = 1.0f;
}
}
}
else {
unsigned char *rect= (unsigned char *)ibuf->rect;
unsigned char *rect = (unsigned char *)ibuf->rect;
if (image->numcomps < 3) {
/* greyscale */
for (i = 0; i < w * h; i++, rect+=4) {
for (i = 0; i < w * h; i++, rect += 4) {
index = w * h - ((i) / (w) + 1) * w + (i) % (w);
rect[0]= rect[1]= rect[2]= (image->comps[0].data[index] + signed_offsets[0]);
rect[0] = rect[1] = rect[2] = (image->comps[0].data[index] + signed_offsets[0]);
if (image->numcomps == 2)
rect[3]= image->comps[1].data[index] + signed_offsets[1];
rect[3] = image->comps[1].data[index] + signed_offsets[1];
else
rect[3]= 255;
rect[3] = 255;
}
}
else {
/* 8bit rgb or rgba */
for (i = 0; i < w * h; i++, rect+=4) {
for (i = 0; i < w * h; i++, rect += 4) {
int index = w * h - ((i) / (w) + 1) * w + (i) % (w);
rect[0]= image->comps[0].data[index] + signed_offsets[0];
rect[1]= image->comps[1].data[index] + signed_offsets[1];
rect[2]= image->comps[2].data[index] + signed_offsets[2];
rect[0] = image->comps[0].data[index] + signed_offsets[0];
rect[1] = image->comps[1].data[index] + signed_offsets[1];
rect[2] = image->comps[2].data[index] + signed_offsets[2];
if (image->numcomps >= 4)
rect[3]= image->comps[3].data[index] + signed_offsets[3];
rect[3] = image->comps[3].data[index] + signed_offsets[3];
else
rect[3]= 255;
rect[3] = 255;
}
}
}
@@ -286,12 +286,12 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags)
//static opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw_cparameters_t *raw_cp) {
/* prec can be 8, 12, 16 */
#define UPSAMPLE_8_TO_12(_val) ((_val<<4) | (_val & ((1<<4)-1)))
#define UPSAMPLE_8_TO_16(_val) ((_val<<8)+_val)
#define UPSAMPLE_8_TO_12(_val) ((_val << 4) | (_val & ((1 << 4) - 1)))
#define UPSAMPLE_8_TO_16(_val) ((_val << 8) + _val)
#define DOWNSAMPLE_FLOAT_TO_8BIT(_val) (_val)<=0.0f?0: ((_val)>=1.0f?255: (int)(255.0f*(_val)))
#define DOWNSAMPLE_FLOAT_TO_12BIT(_val) (_val)<=0.0f?0: ((_val)>=1.0f?4095: (int)(4095.0f*(_val)))
#define DOWNSAMPLE_FLOAT_TO_16BIT(_val) (_val)<=0.0f?0: ((_val)>=1.0f?65535: (int)(65535.0f*(_val)))
#define DOWNSAMPLE_FLOAT_TO_8BIT(_val) (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 255 : (int)(255.0f * (_val)))
#define DOWNSAMPLE_FLOAT_TO_12BIT(_val) (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 4095 : (int)(4095.0f * (_val)))
#define DOWNSAMPLE_FLOAT_TO_16BIT(_val) (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 65535 : (int)(65535.0f * (_val)))
/*
@@ -304,10 +304,10 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags)
/* ****************************** COPIED FROM image_to_j2k.c */
/* ----------------------------------------------------------------------- */
#define CINEMA_24_CS 1302083 /*Codestream length for 24fps*/
#define CINEMA_48_CS 651041 /*Codestream length for 48fps*/
#define COMP_24_CS 1041666 /*Maximum size per color component for 2K & 4K @ 24fps*/
#define COMP_48_CS 520833 /*Maximum size per color component for 2K @ 48fps*/
#define CINEMA_24_CS 1302083 /*Codestream length for 24fps*/
#define CINEMA_48_CS 651041 /*Codestream length for 48fps*/
#define COMP_24_CS 1041666 /*Maximum size per color component for 2K & 4K @ 24fps*/
#define COMP_48_CS 520833 /*Maximum size per color component for 2K @ 48fps*/
static int initialise_4K_poc(opj_poc_t *POC, int numres)
@@ -316,11 +316,11 @@ static int initialise_4K_poc(opj_poc_t *POC, int numres)
POC[0].resno0 = 0;
POC[0].compno0 = 0;
POC[0].layno1 = 1;
POC[0].resno1 = numres-1;
POC[0].resno1 = numres - 1;
POC[0].compno1 = 3;
POC[0].prg1 = CPRL;
POC[1].tile = 1;
POC[1].resno0 = numres-1;
POC[1].resno0 = numres - 1;
POC[1].compno0 = 0;
POC[1].layno1 = 1;
POC[1].resno1 = numres;
@@ -332,8 +332,8 @@ static int initialise_4K_poc(opj_poc_t *POC, int numres)
static void cinema_parameters(opj_cparameters_t *parameters)
{
parameters->tile_size_on = 0; /* FALSE */
parameters->cp_tdx=1;
parameters->cp_tdy=1;
parameters->cp_tdx = 1;
parameters->cp_tdy = 1;
/*Tile part*/
parameters->tp_flag = 'C';
@@ -356,7 +356,7 @@ static void cinema_parameters(opj_cparameters_t *parameters)
/* No ROI */
parameters->roi_compno = -1;
parameters->subsampling_dx = 1; parameters->subsampling_dy = 1;
parameters->subsampling_dx = 1; parameters->subsampling_dy = 1;
/* 9-7 transform */
parameters->irreversible = 1;
@@ -369,93 +369,93 @@ static void cinema_setup_encoder(opj_cparameters_t *parameters, opj_image_t *ima
float temp_rate;
switch (parameters->cp_cinema) {
case CINEMA2K_24:
case CINEMA2K_48:
if (parameters->numresolution > 6) {
parameters->numresolution = 6;
}
if (!((image->comps[0].w == 2048) || (image->comps[0].h == 1080))) {
fprintf(stdout, "Image coordinates %d x %d is not 2K compliant.\nJPEG Digital Cinema Profile-3 "
"(2K profile) compliance requires that at least one of coordinates match 2048 x 1080\n",
image->comps[0].w, image->comps[0].h);
parameters->cp_rsiz = STD_RSIZ;
}
break;
case CINEMA2K_24:
case CINEMA2K_48:
if (parameters->numresolution > 6) {
parameters->numresolution = 6;
}
if (!((image->comps[0].w == 2048) || (image->comps[0].h == 1080))) {
fprintf(stdout, "Image coordinates %d x %d is not 2K compliant.\nJPEG Digital Cinema Profile-3 "
"(2K profile) compliance requires that at least one of coordinates match 2048 x 1080\n",
image->comps[0].w, image->comps[0].h);
parameters->cp_rsiz = STD_RSIZ;
}
break;
case CINEMA4K_24:
if (parameters->numresolution < 1) {
parameters->numresolution = 1;
}
else if (parameters->numresolution > 7) {
parameters->numresolution = 7;
}
if (!((image->comps[0].w == 4096) || (image->comps[0].h == 2160))) {
fprintf(stdout, "Image coordinates %d x %d is not 4K compliant.\nJPEG Digital Cinema Profile-4"
"(4K profile) compliance requires that at least one of coordinates match 4096 x 2160\n",
image->comps[0].w, image->comps[0].h);
parameters->cp_rsiz = STD_RSIZ;
}
parameters->numpocs = initialise_4K_poc(parameters->POC, parameters->numresolution);
break;
case OFF:
/* do nothing */
break;
case CINEMA4K_24:
if (parameters->numresolution < 1) {
parameters->numresolution = 1;
}
else if (parameters->numresolution > 7) {
parameters->numresolution = 7;
}
if (!((image->comps[0].w == 4096) || (image->comps[0].h == 2160))) {
fprintf(stdout, "Image coordinates %d x %d is not 4K compliant.\nJPEG Digital Cinema Profile-4"
"(4K profile) compliance requires that at least one of coordinates match 4096 x 2160\n",
image->comps[0].w, image->comps[0].h);
parameters->cp_rsiz = STD_RSIZ;
}
parameters->numpocs = initialise_4K_poc(parameters->POC, parameters->numresolution);
break;
case OFF:
/* do nothing */
break;
}
switch (parameters->cp_cinema) {
case CINEMA2K_24:
case CINEMA4K_24:
for (i=0 ; i<parameters->tcp_numlayers ; i++) {
temp_rate = 0;
if (img_fol->rates[i]== 0) {
parameters->tcp_rates[0]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
(CINEMA_24_CS * 8 * image->comps[0].dx * image->comps[0].dy);
}
else {
temp_rate =((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
(img_fol->rates[i] * 8 * image->comps[0].dx * image->comps[0].dy);
if (temp_rate > CINEMA_24_CS ) {
parameters->tcp_rates[i]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
(CINEMA_24_CS * 8 * image->comps[0].dx * image->comps[0].dy);
case CINEMA2K_24:
case CINEMA4K_24:
for (i = 0; i < parameters->tcp_numlayers; i++) {
temp_rate = 0;
if (img_fol->rates[i] == 0) {
parameters->tcp_rates[0] = ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec)) /
(CINEMA_24_CS * 8 * image->comps[0].dx * image->comps[0].dy);
}
else {
parameters->tcp_rates[i]= img_fol->rates[i];
temp_rate = ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec)) /
(img_fol->rates[i] * 8 * image->comps[0].dx * image->comps[0].dy);
if (temp_rate > CINEMA_24_CS) {
parameters->tcp_rates[i] = ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec)) /
(CINEMA_24_CS * 8 * image->comps[0].dx * image->comps[0].dy);
}
else {
parameters->tcp_rates[i] = img_fol->rates[i];
}
}
}
}
parameters->max_comp_size = COMP_24_CS;
break;
parameters->max_comp_size = COMP_24_CS;
break;
case CINEMA2K_48:
for (i=0 ; i<parameters->tcp_numlayers ; i++) {
temp_rate = 0;
if (img_fol->rates[i]== 0) {
parameters->tcp_rates[0]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
(CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy);
}
else {
temp_rate =((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
(img_fol->rates[i] * 8 * image->comps[0].dx * image->comps[0].dy);
if (temp_rate > CINEMA_48_CS ) {
parameters->tcp_rates[0]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
(CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy);
case CINEMA2K_48:
for (i = 0; i < parameters->tcp_numlayers; i++) {
temp_rate = 0;
if (img_fol->rates[i] == 0) {
parameters->tcp_rates[0] = ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec)) /
(CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy);
}
else {
parameters->tcp_rates[i]= img_fol->rates[i];
temp_rate = ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec)) /
(img_fol->rates[i] * 8 * image->comps[0].dx * image->comps[0].dy);
if (temp_rate > CINEMA_48_CS) {
parameters->tcp_rates[0] = ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec)) /
(CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy);
}
else {
parameters->tcp_rates[i] = img_fol->rates[i];
}
}
}
}
parameters->max_comp_size = COMP_48_CS;
break;
case OFF:
/* do nothing */
break;
parameters->max_comp_size = COMP_48_CS;
break;
case OFF:
/* do nothing */
break;
}
parameters->cp_disto_alloc = 1;
}
static opj_image_t* ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
{
unsigned char *rect;
float *rect_float;
@@ -467,51 +467,51 @@ static opj_image_t* ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
int i, numcomps, w, h, prec;
int x, y, y_row;
OPJ_COLOR_SPACE color_space;
opj_image_cmptparm_t cmptparm[4]; /* maximum of 4 components */
opj_image_t * image = NULL;
opj_image_cmptparm_t cmptparm[4]; /* maximum of 4 components */
opj_image_t *image = NULL;
img_fol_t img_fol; /* only needed for cinema presets */
memset(&img_fol, 0, sizeof(img_fol_t));
if (ibuf->ftype & JP2_CINE) {
if (ibuf->x==4096 || ibuf->y==2160)
parameters->cp_cinema= CINEMA4K_24;
if (ibuf->x == 4096 || ibuf->y == 2160)
parameters->cp_cinema = CINEMA4K_24;
else {
if (ibuf->ftype & JP2_CINE_48FPS) {
parameters->cp_cinema= CINEMA2K_48;
parameters->cp_cinema = CINEMA2K_48;
}
else {
parameters->cp_cinema= CINEMA2K_24;
parameters->cp_cinema = CINEMA2K_24;
}
}
if (parameters->cp_cinema) {
img_fol.rates = (float*)MEM_mallocN(parameters->tcp_numlayers * sizeof(float), "jp2_rates");
for (i=0; i< parameters->tcp_numlayers; i++) {
img_fol.rates = (float *)MEM_mallocN(parameters->tcp_numlayers * sizeof(float), "jp2_rates");
for (i = 0; i < parameters->tcp_numlayers; i++) {
img_fol.rates[i] = parameters->tcp_rates[i];
}
cinema_parameters(parameters);
}
color_space= CLRSPC_SYCC;
prec= 12;
numcomps= 3;
color_space = CLRSPC_SYCC;
prec = 12;
numcomps = 3;
}
else {
/* Get settings from the imbuf */
color_space = (ibuf->ftype & JP2_YCC) ? CLRSPC_SYCC : CLRSPC_SRGB;
if (ibuf->ftype & JP2_16BIT) prec= 16;
else if (ibuf->ftype & JP2_12BIT) prec= 12;
else prec= 8;
if (ibuf->ftype & JP2_16BIT) prec = 16;
else if (ibuf->ftype & JP2_12BIT) prec = 12;
else prec = 8;
/* 32bit images == alpha channel */
/* grayscale not supported yet */
numcomps= (ibuf->planes==32) ? 4 : 3;
numcomps = (ibuf->planes == 32) ? 4 : 3;
}
w= ibuf->x;
h= ibuf->y;
w = ibuf->x;
h = ibuf->y;
/* initialize image components */
@@ -535,16 +535,16 @@ static opj_image_t* ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
/* set image offset and reference grid */
image->x0 = parameters->image_offset_x0;
image->y0 = parameters->image_offset_y0;
image->x1 = parameters->image_offset_x0 + (w - 1) * subsampling_dx + 1;
image->y1 = parameters->image_offset_y0 + (h - 1) * subsampling_dy + 1;
image->x1 = parameters->image_offset_x0 + (w - 1) * subsampling_dx + 1;
image->y1 = parameters->image_offset_y0 + (h - 1) * subsampling_dy + 1;
/* set image data */
rect = (unsigned char*) ibuf->rect;
rect_float= ibuf->rect_float;
rect = (unsigned char *) ibuf->rect;
rect_float = ibuf->rect_float;
if (rect_float && rect && prec==8) {
if (rect_float && rect && prec == 8) {
/* No need to use the floating point buffer, just write the 8 bits from the char buffer */
rect_float= NULL;
rect_float = NULL;
}
@@ -552,112 +552,112 @@ static opj_image_t* ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
float rgb[3];
switch (prec) {
case 8: /* Convert blenders float color channels to 8, 12 or 16bit ints */
for (y=h-1; y>=0; y--) {
y_row = y*w;
for (x=0; x<w; x++, rect_float+=4) {
i = y_row + x;
if (ibuf->profile == IB_PROFILE_LINEAR_RGB)
linearrgb_to_srgb_v3_v3(rgb, rect_float);
else
copy_v3_v3(rgb, rect_float);
image->comps[0].data[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rgb[0]);
image->comps[1].data[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rgb[1]);
image->comps[2].data[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rgb[2]);
if (numcomps>3)
image->comps[3].data[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[3]);
case 8: /* Convert blenders float color channels to 8, 12 or 16bit ints */
for (y = h - 1; y >= 0; y--) {
y_row = y * w;
for (x = 0; x < w; x++, rect_float += 4) {
i = y_row + x;
if (ibuf->profile == IB_PROFILE_LINEAR_RGB)
linearrgb_to_srgb_v3_v3(rgb, rect_float);
else
copy_v3_v3(rgb, rect_float);
image->comps[0].data[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rgb[0]);
image->comps[1].data[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rgb[1]);
image->comps[2].data[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rgb[2]);
if (numcomps > 3)
image->comps[3].data[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[3]);
}
}
}
break;
break;
case 12:
for (y=h-1; y>=0; y--) {
y_row = y*w;
for (x=0; x<w; x++, rect_float+=4) {
i = y_row + x;
if (ibuf->profile == IB_PROFILE_LINEAR_RGB)
linearrgb_to_srgb_v3_v3(rgb, rect_float);
else
copy_v3_v3(rgb, rect_float);
image->comps[0].data[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rgb[0]);
image->comps[1].data[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rgb[1]);
image->comps[2].data[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rgb[2]);
if (numcomps>3)
image->comps[3].data[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[3]);
case 12:
for (y = h - 1; y >= 0; y--) {
y_row = y * w;
for (x = 0; x < w; x++, rect_float += 4) {
i = y_row + x;
if (ibuf->profile == IB_PROFILE_LINEAR_RGB)
linearrgb_to_srgb_v3_v3(rgb, rect_float);
else
copy_v3_v3(rgb, rect_float);
image->comps[0].data[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rgb[0]);
image->comps[1].data[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rgb[1]);
image->comps[2].data[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rgb[2]);
if (numcomps > 3)
image->comps[3].data[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[3]);
}
}
}
break;
case 16:
for (y=h-1; y>=0; y--) {
y_row = y*w;
for (x=0; x<w; x++, rect_float+=4) {
i = y_row + x;
if (ibuf->profile == IB_PROFILE_LINEAR_RGB)
linearrgb_to_srgb_v3_v3(rgb, rect_float);
else
copy_v3_v3(rgb, rect_float);
image->comps[0].data[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rgb[0]);
image->comps[1].data[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rgb[1]);
image->comps[2].data[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rgb[2]);
if (numcomps>3)
image->comps[3].data[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[3]);
break;
case 16:
for (y = h - 1; y >= 0; y--) {
y_row = y * w;
for (x = 0; x < w; x++, rect_float += 4) {
i = y_row + x;
if (ibuf->profile == IB_PROFILE_LINEAR_RGB)
linearrgb_to_srgb_v3_v3(rgb, rect_float);
else
copy_v3_v3(rgb, rect_float);
image->comps[0].data[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rgb[0]);
image->comps[1].data[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rgb[1]);
image->comps[2].data[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rgb[2]);
if (numcomps > 3)
image->comps[3].data[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[3]);
}
}
}
break;
break;
}
}
else {
/* just use rect*/
switch (prec) {
case 8:
for (y=h-1; y>=0; y--) {
y_row = y*w;
for (x=0; x<w; x++, rect+=4) {
i = y_row + x;
image->comps[0].data[i] = rect[0];
image->comps[1].data[i] = rect[1];
image->comps[2].data[i] = rect[2];
if (numcomps>3)
image->comps[3].data[i] = rect[3];
case 8:
for (y = h - 1; y >= 0; y--) {
y_row = y * w;
for (x = 0; x < w; x++, rect += 4) {
i = y_row + x;
image->comps[0].data[i] = rect[0];
image->comps[1].data[i] = rect[1];
image->comps[2].data[i] = rect[2];
if (numcomps > 3)
image->comps[3].data[i] = rect[3];
}
}
}
break;
break;
case 12: /* Up Sampling, a bit pointless but best write the bit depth requested */
for (y=h-1; y>=0; y--) {
y_row = y*w;
for (x=0; x<w; x++, rect+=4) {
i = y_row + x;
image->comps[0].data[i]= UPSAMPLE_8_TO_12(rect[0]);
image->comps[1].data[i]= UPSAMPLE_8_TO_12(rect[1]);
image->comps[2].data[i]= UPSAMPLE_8_TO_12(rect[2]);
if (numcomps>3)
image->comps[3].data[i]= UPSAMPLE_8_TO_12(rect[3]);
case 12: /* Up Sampling, a bit pointless but best write the bit depth requested */
for (y = h - 1; y >= 0; y--) {
y_row = y * w;
for (x = 0; x < w; x++, rect += 4) {
i = y_row + x;
image->comps[0].data[i] = UPSAMPLE_8_TO_12(rect[0]);
image->comps[1].data[i] = UPSAMPLE_8_TO_12(rect[1]);
image->comps[2].data[i] = UPSAMPLE_8_TO_12(rect[2]);
if (numcomps > 3)
image->comps[3].data[i] = UPSAMPLE_8_TO_12(rect[3]);
}
}
}
break;
case 16:
for (y=h-1; y>=0; y--) {
y_row = y*w;
for (x=0; x<w; x++, rect+=4) {
i = y_row + x;
image->comps[0].data[i]= UPSAMPLE_8_TO_16(rect[0]);
image->comps[1].data[i]= UPSAMPLE_8_TO_16(rect[1]);
image->comps[2].data[i]= UPSAMPLE_8_TO_16(rect[2]);
if (numcomps>3)
image->comps[3].data[i]= UPSAMPLE_8_TO_16(rect[3]);
break;
case 16:
for (y = h - 1; y >= 0; y--) {
y_row = y * w;
for (x = 0; x < w; x++, rect += 4) {
i = y_row + x;
image->comps[0].data[i] = UPSAMPLE_8_TO_16(rect[0]);
image->comps[1].data[i] = UPSAMPLE_8_TO_16(rect[1]);
image->comps[2].data[i] = UPSAMPLE_8_TO_16(rect[2]);
if (numcomps > 3)
image->comps[3].data[i] = UPSAMPLE_8_TO_16(rect[3]);
}
}
}
break;
break;
}
}
@@ -681,8 +681,8 @@ int imb_savejp2(struct ImBuf *ibuf, const char *name, int flags)
int quality = ibuf->ftype & 0xff;
int bSuccess;
opj_cparameters_t parameters; /* compression parameters */
opj_event_mgr_t event_mgr; /* event manager */
opj_cparameters_t parameters; /* compression parameters */
opj_event_mgr_t event_mgr; /* event manager */
opj_image_t *image = NULL;
(void)flags; /* unused */
@@ -702,22 +702,22 @@ int imb_savejp2(struct ImBuf *ibuf, const char *name, int flags)
/* compression ratio */
/* invert range, from 10-100, 100-1
* where jpeg see's 1 and highest quality (lossless) and 100 is very low quality*/
parameters.tcp_rates[0]= ((100-quality)/90.0f*99.0f) + 1;
parameters.tcp_rates[0] = ((100 - quality) / 90.0f * 99.0f) + 1;
parameters.tcp_numlayers = 1; // only one resolution
parameters.cp_disto_alloc = 1;
image= ibuftoimage(ibuf, &parameters);
image = ibuftoimage(ibuf, &parameters);
{ /* JP2 format output */
{ /* JP2 format output */
int codestream_length;
opj_cio_t *cio = NULL;
FILE *f = NULL;
/* get a JP2 compressor handle */
opj_cinfo_t* cinfo = opj_create_compress(CODEC_JP2);
opj_cinfo_t *cinfo = opj_create_compress(CODEC_JP2);
/* catch events using our callbacks and give a local context */
opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);

View File

@@ -59,7 +59,7 @@ typedef struct MovieCache {
int keysize;
unsigned long curtime;
int totseg, *points, proxy, render_flags; /* for visual statistics optimization */
int totseg, *points, proxy, render_flags; /* for visual statistics optimization */
int pad;
} MovieCache;
@@ -71,35 +71,35 @@ typedef struct MovieCacheKey {
typedef struct MovieCacheItem {
MovieCache *cache_owner;
ImBuf *ibuf;
MEM_CacheLimiterHandleC * c_handle;
MEM_CacheLimiterHandleC *c_handle;
unsigned long last_access;
} MovieCacheItem;
static unsigned int moviecache_hashhash(const void *keyv)
{
MovieCacheKey *key = (MovieCacheKey*)keyv;
MovieCacheKey *key = (MovieCacheKey *)keyv;
return key->cache_owner->hashfp(key->userkey);
}
static int moviecache_hashcmp(const void *av, const void *bv)
{
const MovieCacheKey *a = (MovieCacheKey*)av;
const MovieCacheKey *b = (MovieCacheKey*)bv;
const MovieCacheKey *a = (MovieCacheKey *)av;
const MovieCacheKey *b = (MovieCacheKey *)bv;
return a->cache_owner->cmpfp(a->userkey, b->userkey);
}
static void moviecache_keyfree(void *val)
{
MovieCacheKey *key = (MovieCacheKey*)val;
MovieCacheKey *key = (MovieCacheKey *)val;
BLI_mempool_free(key->cache_owner->keys_pool, key);
}
static void moviecache_valfree(void *val)
{
MovieCacheItem *item = (MovieCacheItem*)val;
MovieCacheItem *item = (MovieCacheItem *)val;
if (item->ibuf) {
MEM_CacheLimiter_unmanage(item->c_handle);
@@ -160,7 +160,7 @@ static size_t IMB_get_size_in_memory(ImBuf *ibuf)
if (ibuf->rect_float)
channel_size += sizeof(float);
size += channel_size * ibuf->x * ibuf->y * ibuf->channels;
size += channel_size * ibuf->x * ibuf->y * ibuf->channels;
if (ibuf->miptot) {
for (a = 0; a < ibuf->miptot; a++) {
@@ -170,13 +170,13 @@ static size_t IMB_get_size_in_memory(ImBuf *ibuf)
}
if (ibuf->tiles) {
size += sizeof(unsigned int)*ibuf->ytiles*ibuf->xtiles;
size += sizeof(unsigned int) * ibuf->ytiles * ibuf->xtiles;
}
return size;
}
static size_t get_item_size (void *p)
static size_t get_item_size(void *p)
{
size_t size = sizeof(MovieCacheItem);
MovieCacheItem *item = (MovieCacheItem *) p;
@@ -199,8 +199,7 @@ void IMB_moviecache_destruct(void)
}
struct MovieCache *IMB_moviecache_create(int keysize, GHashHashFP hashfp, GHashCmpFP cmpfp,
MovieCacheGetKeyDataFP getdatafp)
{
MovieCacheGetKeyDataFP getdatafp){
MovieCache *cache;
cache = MEM_callocN(sizeof(MovieCache), "MovieCache");
@@ -257,14 +256,14 @@ void IMB_moviecache_put(MovieCache *cache, void *userkey, ImBuf *ibuf)
}
}
ImBuf* IMB_moviecache_get(MovieCache *cache, void *userkey)
ImBuf *IMB_moviecache_get(MovieCache *cache, void *userkey)
{
MovieCacheKey key;
MovieCacheItem *item;
key.cache_owner = cache;
key.userkey = userkey;
item = (MovieCacheItem*)BLI_ghash_lookup(cache->hash, &key);
item = (MovieCacheItem *)BLI_ghash_lookup(cache->hash, &key);
if (item) {
item->last_access = cache->curtime++;
@@ -316,7 +315,7 @@ void IMB_moviecache_get_cache_segments(MovieCache *cache, int proxy, int render_
}
else {
int totframe = BLI_ghash_size(cache->hash);
int *frames = MEM_callocN(totframe*sizeof(int), "movieclip cache frames");
int *frames = MEM_callocN(totframe * sizeof(int), "movieclip cache frames");
int a, totseg = 0;
GHashIterator *iter;
@@ -353,7 +352,7 @@ void IMB_moviecache_get_cache_segments(MovieCache *cache, int proxy, int render_
if (totseg) {
int b, *points;
points = MEM_callocN(2*sizeof(int)*totseg, "movieclip cache segments");
points = MEM_callocN(2 * sizeof(int) * totseg, "movieclip cache segments");
/* fill */
for (a = 0, b = 0; a < totframe; a++) {

View File

@@ -37,35 +37,35 @@
/* Note: as for now openexr only supports 32 chars in channel names.
* This api also supports max 8 channels per pass now. easy to fix! */
#define EXR_LAY_MAXNAME 19
#define EXR_PASS_MAXNAME 11
#define EXR_TOT_MAXNAME 32
#define EXR_PASS_MAXCHAN 8
#define EXR_LAY_MAXNAME 19
#define EXR_PASS_MAXNAME 11
#define EXR_TOT_MAXNAME 32
#define EXR_PASS_MAXCHAN 8
#ifdef __cplusplus
extern "C" {
#endif
void * IMB_exr_get_handle (void);
void IMB_exr_add_channel (void *handle, const char *layname, const char *passname, int xstride, int ystride, float *rect);
void *IMB_exr_get_handle(void);
void IMB_exr_add_channel(void *handle, const char *layname, const char *passname, int xstride, int ystride, float *rect);
int IMB_exr_begin_read (void *handle, const char *filename, int *width, int *height);
int IMB_exr_begin_write (void *handle, const char *filename, int width, int height, int compress);
void IMB_exrtile_begin_write (void *handle, const char *filename, int mipmap, int width, int height, int tilex, int tiley);
int IMB_exr_begin_read(void *handle, const char *filename, int *width, int *height);
int IMB_exr_begin_write(void *handle, const char *filename, int width, int height, int compress);
void IMB_exrtile_begin_write(void *handle, const char *filename, int mipmap, int width, int height, int tilex, int tiley);
void IMB_exr_set_channel (void *handle, const char *layname, const char *passname, int xstride, int ystride, float *rect);
void IMB_exr_set_channel(void *handle, const char *layname, const char *passname, int xstride, int ystride, float *rect);
void IMB_exr_read_channels (void *handle);
void IMB_exr_write_channels (void *handle);
void IMB_exrtile_write_channels (void *handle, int partx, int party, int level);
void IMB_exrtile_clear_channels (void *handle);
void IMB_exr_read_channels(void *handle);
void IMB_exr_write_channels(void *handle);
void IMB_exrtile_write_channels(void *handle, int partx, int party, int level);
void IMB_exrtile_clear_channels(void *handle);
void IMB_exr_multilayer_convert (void *handle, void *base,
void * (*addlayer)(void *base, char *str),
void (*addpass)(void *base, void *lay, char *str, float *rect, int totchan, char *chan_id));
void IMB_exr_multilayer_convert(void *handle, void *base,
void * (*addlayer)(void *base, char *str),
void (*addpass)(void *base, void *lay, char *str, float *rect, int totchan, char *chan_id));
void IMB_exr_close (void *handle);
void IMB_exr_close(void *handle);
#ifdef __cplusplus
} // extern "C"

View File

@@ -56,7 +56,7 @@
/* needed constants */
#define MINELEN 8
#define MAXELEN 0x7fff
#define MINRUN 4 /* minimum run length */
#define MINRUN 4 /* minimum run length */
#define RED 0
#define GRN 1
#define BLU 2
@@ -66,11 +66,11 @@
typedef unsigned char RGBE[4];
typedef float fCOLOR[3];
/* copy source -> dest */
#define copy_rgbe(c1, c2) (c2[RED]=c1[RED], c2[GRN]=c1[GRN], c2[BLU]=c1[BLU], c2[EXP]=c1[EXP])
#define copy_fcol(f1, f2) (f2[RED]=f1[RED], f2[GRN]=f1[GRN], f2[BLU]=f1[BLU])
#define copy_rgbe(c1, c2) (c2[RED] = c1[RED], c2[GRN] = c1[GRN], c2[BLU] = c1[BLU], c2[EXP] = c1[EXP])
#define copy_fcol(f1, f2) (f2[RED] = f1[RED], f2[GRN] = f1[GRN], f2[BLU] = f1[BLU])
/* read routines */
static unsigned char* oldreadcolrs(RGBE *scan, unsigned char *mem, int xmax)
static unsigned char *oldreadcolrs(RGBE *scan, unsigned char *mem, int xmax)
{
int i, rshift = 0, len = xmax;
while (len > 0) {
@@ -79,7 +79,7 @@ static unsigned char* oldreadcolrs(RGBE *scan, unsigned char *mem, int xmax)
scan[0][BLU] = *mem++;
scan[0][EXP] = *mem++;
if (scan[0][RED] == 1 && scan[0][GRN] == 1 && scan[0][BLU] == 1) {
for (i=scan[0][EXP]<<rshift;i>0;i--) {
for (i = scan[0][EXP] << rshift; i > 0; i--) {
copy_rgbe(scan[-1], scan[0]);
scan++;
len--;
@@ -95,14 +95,14 @@ static unsigned char* oldreadcolrs(RGBE *scan, unsigned char *mem, int xmax)
return mem;
}
static unsigned char* freadcolrs(RGBE *scan, unsigned char* mem, int xmax)
static unsigned char *freadcolrs(RGBE *scan, unsigned char *mem, int xmax)
{
int i, j, code, val;
if ((xmax < MINELEN) | (xmax > MAXELEN)) return oldreadcolrs(scan, mem, xmax);
i = *mem++;
if (i != 2) return oldreadcolrs(scan, mem-1, xmax);
if (i != 2) return oldreadcolrs(scan, mem - 1, xmax);
scan[0][GRN] = *mem++;
scan[0][BLU] = *mem++;
@@ -110,8 +110,8 @@ static unsigned char* freadcolrs(RGBE *scan, unsigned char* mem, int xmax)
i = *mem++;
if (((scan[0][BLU] << 8) | i) != xmax) return NULL;
for (i=0;i<4;i++)
for (j=0;j<xmax;) {
for (i = 0; i < 4; i++)
for (j = 0; j < xmax; ) {
code = *mem++;
if (code > 128) {
code &= 127;
@@ -131,14 +131,14 @@ static unsigned char* freadcolrs(RGBE *scan, unsigned char* mem, int xmax)
/* rgbe -> float color */
static void RGBE2FLOAT(RGBE rgbe, fCOLOR fcol)
{
if (rgbe[EXP]==0) {
if (rgbe[EXP] == 0) {
fcol[RED] = fcol[GRN] = fcol[BLU] = 0;
}
else {
float f = ldexp(1.0, rgbe[EXP]-(COLXS+8));
fcol[RED] = f*(rgbe[RED] + 0.5f);
fcol[GRN] = f*(rgbe[GRN] + 0.5f);
fcol[BLU] = f*(rgbe[BLU] + 0.5f);
float f = ldexp(1.0, rgbe[EXP] - (COLXS + 8));
fcol[RED] = f * (rgbe[RED] + 0.5f);
fcol[GRN] = f * (rgbe[GRN] + 0.5f);
fcol[BLU] = f * (rgbe[BLU] + 0.5f);
}
}
@@ -146,8 +146,8 @@ static void RGBE2FLOAT(RGBE rgbe, fCOLOR fcol)
static void FLOAT2RGBE(fCOLOR fcol, RGBE rgbe)
{
int e;
float d = (fcol[RED]>fcol[GRN]) ? fcol[RED] : fcol[GRN];
if (fcol[BLU]>d) d = fcol[BLU];
float d = (fcol[RED] > fcol[GRN]) ? fcol[RED] : fcol[GRN];
if (fcol[BLU] > d) d = fcol[BLU];
if (d <= 1e-32f)
rgbe[RED] = rgbe[GRN] = rgbe[BLU] = rgbe[EXP] = 0;
else {
@@ -166,63 +166,63 @@ int imb_is_a_hdr(unsigned char *buf)
// For recognition, Blender only loads first 32 bytes, so use #?RADIANCE id instead
// update: actually, the 'RADIANCE' part is just an optional program name, the magic word is really only the '#?' part
//if (strstr((char*)buf, "#?RADIANCE")) return 1;
if (strstr((char*)buf, "#?")) return 1;
if (strstr((char *)buf, "#?")) return 1;
// if (strstr((char*)buf, "32-bit_rle_rgbe")) return 1;
return 0;
}
struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags)
{
struct ImBuf* ibuf;
RGBE* sline;
struct ImBuf *ibuf;
RGBE *sline;
fCOLOR fcol;
float* rect_float;
int found=0;
int width=0, height=0;
float *rect_float;
int found = 0;
int width = 0, height = 0;
int x, y;
unsigned char* ptr;
unsigned char *ptr;
char oriY[80], oriX[80];
if (imb_is_a_hdr((void *)mem)) {
/* find empty line, next line is resolution info */
for (x=1;x<size;x++) {
if ((mem[x-1]=='\n') && (mem[x]=='\n')) {
for (x = 1; x < size; x++) {
if ((mem[x - 1] == '\n') && (mem[x] == '\n')) {
found = 1;
break;
}
}
if (found && (x<(size + 2))) {
if (found && (x < (size + 2))) {
if (sscanf((char *)&mem[x + 1], "%79s %d %79s %d", (char *)&oriY, &height,
(char*)&oriX, &width) != 4)
(char *)&oriX, &width) != 4)
{
return NULL;
}
/* find end of this line, data right behind it */
ptr = (unsigned char *)strchr((char*)&mem[x+1], '\n');
ptr = (unsigned char *)strchr((char *)&mem[x + 1], '\n');
ptr++;
if (flags & IB_test) ibuf = IMB_allocImBuf(width, height, 32, 0);
else ibuf = IMB_allocImBuf(width, height, 32, (flags & IB_rect)|IB_rectfloat);
else ibuf = IMB_allocImBuf(width, height, 32, (flags & IB_rect) | IB_rectfloat);
if (ibuf==NULL) return NULL;
if (ibuf == NULL) return NULL;
ibuf->ftype = RADHDR;
ibuf->profile = IB_PROFILE_LINEAR_RGB;
if (flags & IB_test) return ibuf;
/* read in and decode the actual data */
sline = (RGBE*)MEM_mallocN(sizeof(RGBE)*width, "radhdr_read_tmpscan");
sline = (RGBE *)MEM_mallocN(sizeof(RGBE) * width, "radhdr_read_tmpscan");
rect_float = (float *)ibuf->rect_float;
for (y=0;y<height;y++) {
for (y = 0; y < height; y++) {
ptr = freadcolrs(sline, ptr, width);
if (ptr==NULL) {
if (ptr == NULL) {
printf("HDR decode error\n");
MEM_freeN(sline);
return ibuf;
}
for (x=0;x<width;x++) {
for (x = 0; x < width; x++) {
/* convert to ldr */
RGBE2FLOAT(sline[x], fcol);
*rect_float++ = fcol[RED];
@@ -232,7 +232,7 @@ struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags)
}
}
MEM_freeN(sline);
if (oriY[0]=='-') IMB_flipy(ibuf);
if (oriY[0] == '-') IMB_flipy(ibuf);
if (flags & IB_rect) {
IMB_rect_from_float(ibuf);
@@ -248,36 +248,36 @@ struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags)
}
/* ImBuf write */
static int fwritecolrs(FILE* file, int width, int channels, unsigned char* ibufscan, float* fpscan)
static int fwritecolrs(FILE *file, int width, int channels, unsigned char *ibufscan, float *fpscan)
{
int x, i, j, beg, c2, cnt=0;
int x, i, j, beg, c2, cnt = 0;
fCOLOR fcol;
RGBE rgbe, *rgbe_scan;
if ((ibufscan==NULL) && (fpscan==NULL)) return 0;
if ((ibufscan == NULL) && (fpscan == NULL)) return 0;
rgbe_scan = (RGBE*)MEM_mallocN(sizeof(RGBE)*width, "radhdr_write_tmpscan");
rgbe_scan = (RGBE *)MEM_mallocN(sizeof(RGBE) * width, "radhdr_write_tmpscan");
/* convert scanline */
j= 0;
for (i=0;i<width;i++) {
j = 0;
for (i = 0; i < width; i++) {
if (fpscan) {
fcol[RED] = fpscan[j];
fcol[GRN] = (channels >= 2)? fpscan[j+1]: fpscan[j];
fcol[BLU] = (channels >= 3)? fpscan[j+2]: fpscan[j];
fcol[GRN] = (channels >= 2) ? fpscan[j + 1] : fpscan[j];
fcol[BLU] = (channels >= 3) ? fpscan[j + 2] : fpscan[j];
}
else {
fcol[RED] = (float)ibufscan[j] / 255.f;
fcol[GRN] = (float)((channels >= 2)? ibufscan[j+1]: ibufscan[j]) / 255.f;
fcol[BLU] = (float)((channels >= 3)? ibufscan[j+2]: ibufscan[j]) / 255.f;
fcol[GRN] = (float)((channels >= 2) ? ibufscan[j + 1] : ibufscan[j]) / 255.f;
fcol[BLU] = (float)((channels >= 3) ? ibufscan[j + 2] : ibufscan[j]) / 255.f;
}
FLOAT2RGBE(fcol, rgbe);
copy_rgbe(rgbe, rgbe_scan[i]);
j+=channels;
j += channels;
}
if ((width < MINELEN) | (width > MAXELEN)) { /* OOBs, write out flat */
x=fwrite((char *)rgbe_scan, sizeof(RGBE), width, file) - width;
if ((width < MINELEN) | (width > MAXELEN)) { /* OOBs, write out flat */
x = fwrite((char *)rgbe_scan, sizeof(RGBE), width, file) - width;
MEM_freeN(rgbe_scan);
return x;
}
@@ -287,29 +287,29 @@ static int fwritecolrs(FILE* file, int width, int channels, unsigned char* ibufs
putc((unsigned char)(width >> 8), file);
putc((unsigned char)(width & 255), file);
/* put components separately */
for (i=0;i<4;i++) {
for (j=0;j<width;j+=cnt) { /* find next run */
for (beg=j;beg<width;beg+=cnt) {
for (cnt=1;(cnt<127) && ((beg+cnt)<width) && (rgbe_scan[beg+cnt][i] == rgbe_scan[beg][i]); cnt++);
if (cnt>=MINRUN) break; /* long enough */
for (i = 0; i < 4; i++) {
for (j = 0; j < width; j += cnt) { /* find next run */
for (beg = j; beg < width; beg += cnt) {
for (cnt = 1; (cnt < 127) && ((beg + cnt) < width) && (rgbe_scan[beg + cnt][i] == rgbe_scan[beg][i]); cnt++) ;
if (cnt >= MINRUN) break; /* long enough */
}
if (((beg-j)>1) && ((beg-j) < MINRUN)) {
c2 = j+1;
if (((beg - j) > 1) && ((beg - j) < MINRUN)) {
c2 = j + 1;
while (rgbe_scan[c2++][i] == rgbe_scan[j][i])
if (c2 == beg) { /* short run */
putc((unsigned char)(128+beg-j), file);
putc((unsigned char)(128 + beg - j), file);
putc((unsigned char)(rgbe_scan[j][i]), file);
j = beg;
break;
}
}
while (j < beg) { /* write out non-run */
if ((c2 = beg-j) > 128) c2 = 128;
if ((c2 = beg - j) > 128) c2 = 128;
putc((unsigned char)(c2), file);
while (c2--) putc(rgbe_scan[j++][i], file);
}
if (cnt >= MINRUN) { /* write out run */
putc((unsigned char)(128+cnt), file);
putc((unsigned char)(128 + cnt), file);
putc(rgbe_scan[beg][i], file);
}
else cnt = 0;
@@ -336,30 +336,30 @@ static void writeHeader(FILE *file, int width, int height)
int imb_savehdr(struct ImBuf *ibuf, const char *name, int flags)
{
FILE* file = BLI_fopen(name, "wb");
float *fp= NULL;
int y, width=ibuf->x, height=ibuf->y;
unsigned char *cp= NULL;
FILE *file = BLI_fopen(name, "wb");
float *fp = NULL;
int y, width = ibuf->x, height = ibuf->y;
unsigned char *cp = NULL;
(void)flags; /* unused */
if (file==NULL) return 0;
if (file == NULL) return 0;
writeHeader(file, width, height);
if (ibuf->rect)
cp= (unsigned char *)ibuf->rect + ibuf->channels*(height-1)*width;
cp = (unsigned char *)ibuf->rect + ibuf->channels * (height - 1) * width;
if (ibuf->rect_float)
fp= ibuf->rect_float + ibuf->channels*(height-1)*width;
fp = ibuf->rect_float + ibuf->channels * (height - 1) * width;
for (y=height-1;y>=0;y--) {
for (y = height - 1; y >= 0; y--) {
if (fwritecolrs(file, width, ibuf->channels, cp, fp) < 0) {
fclose(file);
printf("HDR write error\n");
return 0;
}
if (cp) cp-= ibuf->channels*width;
if (fp) fp-= ibuf->channels*width;
if (cp) cp -= ibuf->channels * width;
if (fp) fp -= ibuf->channels * width;
}
fclose(file);

View File

@@ -59,27 +59,27 @@ struct ImBuf *IMB_half_x(struct ImBuf *ibuf1)
float af, rf, gf, bf, *p1f, *_p1f, *destf;
int do_rect, do_float;
if (ibuf1==NULL) return (NULL);
if (ibuf1->rect==NULL && ibuf1->rect_float==NULL) return (NULL);
if (ibuf1 == NULL) return (NULL);
if (ibuf1->rect == NULL && ibuf1->rect_float == NULL) return (NULL);
do_rect= (ibuf1->rect != NULL);
do_float= (ibuf1->rect_float != NULL);
do_rect = (ibuf1->rect != NULL);
do_float = (ibuf1->rect_float != NULL);
if (ibuf1->x <= 1) return(IMB_dupImBuf(ibuf1));
ibuf2 = IMB_allocImBuf((ibuf1->x)/2, ibuf1->y, ibuf1->planes, ibuf1->flags);
if (ibuf2==NULL) return (NULL);
ibuf2 = IMB_allocImBuf((ibuf1->x) / 2, ibuf1->y, ibuf1->planes, ibuf1->flags);
if (ibuf2 == NULL) return (NULL);
_p1 = (uchar *) ibuf1->rect;
dest=(uchar *) ibuf2->rect;
dest = (uchar *) ibuf2->rect;
_p1f = ibuf1->rect_float;
destf= ibuf2->rect_float;
destf = ibuf2->rect_float;
for (y=ibuf2->y;y>0;y--) {
for (y = ibuf2->y; y > 0; y--) {
p1 = _p1;
p1f = _p1f;
for (x = ibuf2->x; x>0; x--) {
for (x = ibuf2->x; x > 0; x--) {
if (do_rect) {
a = *(p1++);
b = *(p1++);
@@ -103,10 +103,10 @@ struct ImBuf *IMB_half_x(struct ImBuf *ibuf1)
bf += *(p1f++);
gf += *(p1f++);
rf += *(p1f++);
*(destf++) = 0.5f*af;
*(destf++) = 0.5f*bf;
*(destf++) = 0.5f*gf;
*(destf++) = 0.5f*rf;
*(destf++) = 0.5f * af;
*(destf++) = 0.5f * bf;
*(destf++) = 0.5f * gf;
*(destf++) = 0.5f * rf;
}
}
if (do_rect) _p1 += (ibuf1->x << 2);
@@ -122,17 +122,17 @@ struct ImBuf *IMB_double_fast_x(struct ImBuf *ibuf1)
int *p1, *dest, i, col, do_rect, do_float;
float *p1f, *destf;
if (ibuf1==NULL) return (NULL);
if (ibuf1->rect==NULL && ibuf1->rect_float==NULL) return (NULL);
if (ibuf1 == NULL) return (NULL);
if (ibuf1->rect == NULL && ibuf1->rect_float == NULL) return (NULL);
do_rect= (ibuf1->rect != NULL);
do_float= (ibuf1->rect_float != NULL);
do_rect = (ibuf1->rect != NULL);
do_float = (ibuf1->rect_float != NULL);
ibuf2 = IMB_allocImBuf(2 * ibuf1->x, ibuf1->y, ibuf1->planes, ibuf1->flags);
if (ibuf2==NULL) return (NULL);
if (ibuf2 == NULL) return (NULL);
p1 = (int *) ibuf1->rect;
dest=(int *) ibuf2->rect;
dest = (int *) ibuf2->rect;
p1f = (float *)ibuf1->rect_float;
destf = (float *)ibuf2->rect_float;
@@ -143,12 +143,12 @@ struct ImBuf *IMB_double_fast_x(struct ImBuf *ibuf1)
*dest++ = col;
}
if (do_float) {
destf[0]= destf[4] = p1f[0];
destf[1]= destf[5] = p1f[1];
destf[2]= destf[6] = p1f[2];
destf[3]= destf[7] = p1f[3];
destf+= 8;
p1f+= 4;
destf[0] = destf[4] = p1f[0];
destf[1] = destf[5] = p1f[1];
destf[2] = destf[6] = p1f[2];
destf[3] = destf[7] = p1f[3];
destf += 8;
p1f += 4;
}
}
@@ -159,8 +159,8 @@ struct ImBuf *IMB_double_x(struct ImBuf *ibuf1)
{
struct ImBuf *ibuf2;
if (ibuf1==NULL) return (NULL);
if (ibuf1->rect==NULL && ibuf1->rect_float==NULL) return (NULL);
if (ibuf1 == NULL) return (NULL);
if (ibuf1->rect == NULL && ibuf1->rect_float == NULL) return (NULL);
ibuf2 = IMB_double_fast_x(ibuf1);
@@ -178,24 +178,24 @@ struct ImBuf *IMB_half_y(struct ImBuf *ibuf1)
int do_rect, do_float;
float af, rf, gf, bf, *p1f, *p2f, *_p1f, *destf;
p1= p2= NULL;
p1f= p2f= NULL;
if (ibuf1==NULL) return (NULL);
if (ibuf1->rect==NULL && ibuf1->rect_float==NULL) return (NULL);
p1 = p2 = NULL;
p1f = p2f = NULL;
if (ibuf1 == NULL) return (NULL);
if (ibuf1->rect == NULL && ibuf1->rect_float == NULL) return (NULL);
if (ibuf1->y <= 1) return(IMB_dupImBuf(ibuf1));
do_rect= (ibuf1->rect != NULL);
do_float= (ibuf1->rect_float != NULL);
do_rect = (ibuf1->rect != NULL);
do_float = (ibuf1->rect_float != NULL);
ibuf2 = IMB_allocImBuf(ibuf1->x, (ibuf1->y) / 2, ibuf1->planes, ibuf1->flags);
if (ibuf2==NULL) return (NULL);
if (ibuf2 == NULL) return (NULL);
_p1 = (uchar *) ibuf1->rect;
dest=(uchar *) ibuf2->rect;
dest = (uchar *) ibuf2->rect;
_p1f = (float *) ibuf1->rect_float;
destf= (float *) ibuf2->rect_float;
destf = (float *) ibuf2->rect_float;
for (y=ibuf2->y; y>0; y--) {
for (y = ibuf2->y; y > 0; y--) {
if (do_rect) {
p1 = _p1;
p2 = _p1 + (ibuf1->x << 2);
@@ -228,10 +228,10 @@ struct ImBuf *IMB_half_y(struct ImBuf *ibuf1)
bf += *(p2f++);
gf += *(p2f++);
rf += *(p2f++);
*(destf++) = 0.5f*af;
*(destf++) = 0.5f*bf;
*(destf++) = 0.5f*gf;
*(destf++) = 0.5f*rf;
*(destf++) = 0.5f * af;
*(destf++) = 0.5f * bf;
*(destf++) = 0.5f * gf;
*(destf++) = 0.5f * rf;
}
}
if (do_rect) _p1 += (ibuf1->x << 3);
@@ -249,19 +249,19 @@ struct ImBuf *IMB_double_fast_y(struct ImBuf *ibuf1)
int x, y;
int do_rect, do_float;
if (ibuf1==NULL) return (NULL);
if (ibuf1->rect==NULL && ibuf1->rect_float==NULL) return (NULL);
if (ibuf1 == NULL) return (NULL);
if (ibuf1->rect == NULL && ibuf1->rect_float == NULL) return (NULL);
do_rect= (ibuf1->rect != NULL);
do_float= (ibuf1->rect_float != NULL);
do_rect = (ibuf1->rect != NULL);
do_float = (ibuf1->rect_float != NULL);
ibuf2 = IMB_allocImBuf(ibuf1->x, 2 * ibuf1->y, ibuf1->planes, ibuf1->flags);
if (ibuf2==NULL) return (NULL);
if (ibuf2 == NULL) return (NULL);
p1 = (int *) ibuf1->rect;
dest1= (int *) ibuf2->rect;
dest1 = (int *) ibuf2->rect;
p1f = (float *) ibuf1->rect_float;
dest1f= (float *) ibuf2->rect_float;
dest1f = (float *) ibuf2->rect_float;
for (y = ibuf1->y; y > 0; y--) {
if (do_rect) {
@@ -270,7 +270,7 @@ struct ImBuf *IMB_double_fast_y(struct ImBuf *ibuf1)
dest1 = dest2;
}
if (do_float) {
dest2f = dest1f + (4*ibuf2->x);
dest2f = dest1f + (4 * ibuf2->x);
for (x = ibuf2->x * 4; x > 0; x--) *dest1f++ = *dest2f++ = *p1f++;
dest1f = dest2f;
}
@@ -283,8 +283,8 @@ struct ImBuf *IMB_double_y(struct ImBuf *ibuf1)
{
struct ImBuf *ibuf2;
if (ibuf1==NULL) return (NULL);
if (ibuf1->rect==NULL) return (NULL);
if (ibuf1 == NULL) return (NULL);
if (ibuf1->rect == NULL) return (NULL);
ibuf2 = IMB_double_fast_y(ibuf1);
@@ -298,22 +298,22 @@ void imb_onehalf_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1)
uchar *p1, *p2 = NULL, *dest;
float *p1f, *destf, *p2f = NULL;
int x, y;
const short do_rect= (ibuf1->rect != NULL);
const short do_float= (ibuf1->rect_float != NULL) && (ibuf2->rect_float != NULL);
const short do_rect = (ibuf1->rect != NULL);
const short do_float = (ibuf1->rect_float != NULL) && (ibuf2->rect_float != NULL);
if (do_rect && (ibuf2->rect == NULL)) {
imb_addrectImBuf(ibuf2);
}
p1f = ibuf1->rect_float;
destf=ibuf2->rect_float;
destf = ibuf2->rect_float;
p1 = (uchar *) ibuf1->rect;
dest=(uchar *) ibuf2->rect;
dest = (uchar *) ibuf2->rect;
for (y=ibuf2->y;y>0;y--) {
for (y = ibuf2->y; y > 0; y--) {
if (do_rect) p2 = p1 + (ibuf1->x << 2);
if (do_float) p2f = p1f + (ibuf1->x << 2);
for (x=ibuf2->x;x>0;x--) {
for (x = ibuf2->x; x > 0; x--) {
if (do_rect) {
dest[0] = (p1[0] + p2[0] + p1[4] + p2[4]) >> 2;
dest[1] = (p1[1] + p2[1] + p1[5] + p2[5]) >> 2;
@@ -324,37 +324,36 @@ void imb_onehalf_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1)
dest += 4;
}
if (do_float) {
destf[0] = 0.25f*(p1f[0] + p2f[0] + p1f[4] + p2f[4]);
destf[1] = 0.25f*(p1f[1] + p2f[1] + p1f[5] + p2f[5]);
destf[2] = 0.25f*(p1f[2] + p2f[2] + p1f[6] + p2f[6]);
destf[3] = 0.25f*(p1f[3] + p2f[3] + p1f[7] + p2f[7]);
destf[0] = 0.25f * (p1f[0] + p2f[0] + p1f[4] + p2f[4]);
destf[1] = 0.25f * (p1f[1] + p2f[1] + p1f[5] + p2f[5]);
destf[2] = 0.25f * (p1f[2] + p2f[2] + p1f[6] + p2f[6]);
destf[3] = 0.25f * (p1f[3] + p2f[3] + p1f[7] + p2f[7]);
p1f += 8;
p2f += 8;
destf += 4;
}
}
if (do_rect) p1=p2;
if (do_float) p1f=p2f;
if (do_rect) p1 = p2;
if (do_float) p1f = p2f;
if (ibuf1->x & 1) {
if (do_rect) p1+=4;
if (do_float) p1f+=4;
if (do_rect) p1 += 4;
if (do_float) p1f += 4;
}
}
}
struct ImBuf *IMB_onehalf(struct ImBuf *ibuf1)
{
struct ImBuf *IMB_onehalf(struct ImBuf *ibuf1){
struct ImBuf *ibuf2;
if (ibuf1==NULL) return (NULL);
if (ibuf1->rect==NULL && ibuf1->rect_float==NULL) return (NULL);
if (ibuf1 == NULL) return (NULL);
if (ibuf1->rect == NULL && ibuf1->rect_float == NULL) return (NULL);
if (ibuf1->x <= 1) return(IMB_half_y(ibuf1));
if (ibuf1->y <= 1) return(IMB_half_x(ibuf1));
ibuf2=IMB_allocImBuf((ibuf1->x)/2, (ibuf1->y)/2, ibuf1->planes, ibuf1->flags);
if (ibuf2==NULL) return (NULL);
ibuf2 = IMB_allocImBuf((ibuf1->x) / 2, (ibuf1->y) / 2, ibuf1->planes, ibuf1->flags);
if (ibuf2 == NULL) return (NULL);
imb_onehalf_no_alloc(ibuf2, ibuf1);
@@ -364,8 +363,8 @@ struct ImBuf *IMB_onehalf(struct ImBuf *ibuf1)
/* q_scale_linear_interpolation helper functions */
static void enlarge_picture_byte(
unsigned char* src, unsigned char* dst, int src_width,
int src_height, int dst_width, int dst_height)
unsigned char *src, unsigned char *dst, int src_width,
int src_height, int dst_width, int dst_height)
{
double ratiox = (double) (dst_width - 1.0) / (double) (src_width - 1.001);
double ratioy = (double) (dst_height - 1.0) / (double) (src_height - 1.001);
@@ -377,8 +376,8 @@ static void enlarge_picture_byte(
y_src = 0;
for (y_dst = 0; y_dst < dst_height; y_dst++) {
unsigned char* line1 = src + (y_src >> 16) * 4 * src_width;
unsigned char* line2 = line1 + 4 * src_width;
unsigned char *line1 = src + (y_src >> 16) * 4 * src_width;
unsigned char *line2 = line1 + 4 * src_width;
uintptr_t weight1y = 65536 - (y_src & 0xffff);
uintptr_t weight2y = 65536 - weight1y;
@@ -429,25 +428,25 @@ struct scale_outpix_byte {
};
static void shrink_picture_byte(
unsigned char* src, unsigned char* dst, int src_width,
int src_height, int dst_width, int dst_height)
unsigned char *src, unsigned char *dst, int src_width,
int src_height, int dst_width, int dst_height)
{
double ratiox = (double) (dst_width) / (double) (src_width);
double ratioy = (double) (dst_height) / (double) (src_height);
uintptr_t x_src, dx_dst, x_dst;
uintptr_t y_src, dy_dst, y_dst;
intptr_t y_counter;
unsigned char * dst_begin = dst;
unsigned char *dst_begin = dst;
struct scale_outpix_byte * dst_line1 = NULL;
struct scale_outpix_byte * dst_line2 = NULL;
struct scale_outpix_byte *dst_line1 = NULL;
struct scale_outpix_byte *dst_line2 = NULL;
dst_line1 = (struct scale_outpix_byte*) MEM_callocN(
(dst_width + 1) * sizeof(struct scale_outpix_byte),
"shrink_picture_byte 1");
dst_line2 = (struct scale_outpix_byte*) MEM_callocN(
(dst_width + 1) * sizeof(struct scale_outpix_byte),
"shrink_picture_byte 2");
dst_line1 = (struct scale_outpix_byte *) MEM_callocN(
(dst_width + 1) * sizeof(struct scale_outpix_byte),
"shrink_picture_byte 1");
dst_line2 = (struct scale_outpix_byte *) MEM_callocN(
(dst_width + 1) * sizeof(struct scale_outpix_byte),
"shrink_picture_byte 2");
dx_dst = 65536.0 * ratiox;
dy_dst = 65536.0 * ratioy;
@@ -455,7 +454,7 @@ static void shrink_picture_byte(
y_dst = 0;
y_counter = 65536;
for (y_src = 0; y_src < src_height; y_src++) {
unsigned char* line = src + y_src * 4 * src_width;
unsigned char *line = src + y_src * 4 * src_width;
uintptr_t weight1y = 65535 - (y_dst & 0xffff);
uintptr_t weight2y = 65535 - weight1y;
x_dst = 0;
@@ -486,19 +485,19 @@ static void shrink_picture_byte(
w = (weight1y * weight2x) >> 16;
dst_line1[x+1].r += (line[0] * w + 32767) >> 16;
dst_line1[x+1].g += (line[1] * w + 32767) >> 16;
dst_line1[x+1].b += (line[2] * w + 32767) >> 16;
dst_line1[x+1].a += (line[3] * w + 32767) >> 16;
dst_line1[x+1].weight += w;
dst_line1[x + 1].r += (line[0] * w + 32767) >> 16;
dst_line1[x + 1].g += (line[1] * w + 32767) >> 16;
dst_line1[x + 1].b += (line[2] * w + 32767) >> 16;
dst_line1[x + 1].a += (line[3] * w + 32767) >> 16;
dst_line1[x + 1].weight += w;
w = (weight2y * weight2x) >> 16;
dst_line2[x+1].r += (line[0] * w + 32767) >> 16;
dst_line2[x+1].g += (line[1] * w + 32767) >> 16;
dst_line2[x+1].b += (line[2] * w + 32767) >> 16;
dst_line2[x+1].a += (line[3] * w + 32767) >> 16;
dst_line2[x+1].weight += w;
dst_line2[x + 1].r += (line[0] * w + 32767) >> 16;
dst_line2[x + 1].g += (line[1] * w + 32767) >> 16;
dst_line2[x + 1].b += (line[2] * w + 32767) >> 16;
dst_line2[x + 1].a += (line[3] * w + 32767) >> 16;
dst_line2[x + 1].weight += w;
x_dst += dx_dst;
line += 4;
@@ -509,16 +508,16 @@ static void shrink_picture_byte(
if (y_counter < 0) {
int val;
uintptr_t x;
struct scale_outpix_byte * temp;
struct scale_outpix_byte *temp;
y_counter += 65536;
for (x=0; x < dst_width; x++) {
for (x = 0; x < dst_width; x++) {
uintptr_t f = 0x80000000UL / dst_line1[x].weight;
*dst++ = (val= (dst_line1[x].r * f) >> 15) > 255 ? 255: val;
*dst++ = (val= (dst_line1[x].g * f) >> 15) > 255 ? 255: val;
*dst++ = (val= (dst_line1[x].b * f) >> 15) > 255 ? 255: val;
*dst++ = (val= (dst_line1[x].a * f) >> 15) > 255 ? 255: val;
*dst++ = (val = (dst_line1[x].r * f) >> 15) > 255 ? 255 : val;
*dst++ = (val = (dst_line1[x].g * f) >> 15) > 255 ? 255 : val;
*dst++ = (val = (dst_line1[x].b * f) >> 15) > 255 ? 255 : val;
*dst++ = (val = (dst_line1[x].a * f) >> 15) > 255 ? 255 : val;
}
memset(dst_line1, 0, dst_width *
sizeof(struct scale_outpix_byte));
@@ -532,10 +531,10 @@ static void shrink_picture_byte(
uintptr_t x;
for (x = 0; x < dst_width; x++) {
uintptr_t f = 0x80000000UL / dst_line1[x].weight;
*dst++ = (val= (dst_line1[x].r * f) >> 15) > 255 ? 255: val;
*dst++ = (val= (dst_line1[x].g * f) >> 15) > 255 ? 255: val;
*dst++ = (val= (dst_line1[x].b * f) >> 15) > 255 ? 255: val;
*dst++ = (val= (dst_line1[x].a * f) >> 15) > 255 ? 255: val;
*dst++ = (val = (dst_line1[x].r * f) >> 15) > 255 ? 255 : val;
*dst++ = (val = (dst_line1[x].g * f) >> 15) > 255 ? 255 : val;
*dst++ = (val = (dst_line1[x].b * f) >> 15) > 255 ? 255 : val;
*dst++ = (val = (dst_line1[x].a * f) >> 15) > 255 ? 255 : val;
}
}
MEM_freeN(dst_line1);
@@ -543,22 +542,22 @@ static void shrink_picture_byte(
}
static void q_scale_byte(unsigned char* in, unsigned char* out, int in_width,
int in_height, int dst_width, int dst_height)
static void q_scale_byte(unsigned char *in, unsigned char *out, int in_width,
int in_height, int dst_width, int dst_height)
{
if (dst_width > in_width && dst_height > in_height) {
enlarge_picture_byte(in, out, in_width, in_height,
dst_width, dst_height);
dst_width, dst_height);
}
else if (dst_width < in_width && dst_height < in_height) {
shrink_picture_byte(in, out, in_width, in_height,
dst_width, dst_height);
dst_width, dst_height);
}
}
static void enlarge_picture_float(
float* src, float* dst, int src_width,
int src_height, int dst_width, int dst_height)
float *src, float *dst, int src_width,
int src_height, int dst_width, int dst_height)
{
double ratiox = (double) (dst_width - 1.0) / (double) (src_width - 1.001);
double ratioy = (double) (dst_height - 1.0) / (double) (src_height - 1.001);
@@ -572,8 +571,8 @@ static void enlarge_picture_float(
y_src = 0;
for (y_dst = 0; y_dst < dst_height; y_dst++) {
float* line1 = src + ((int) y_src) * 4 * src_width;
float* line2 = line1 + 4 * src_width;
float *line1 = src + ((int) y_src) * 4 * src_width;
float *line2 = line1 + 4 * src_width;
const float weight1y = (float)(1.0 - (y_src - (int) y_src));
const float weight2y = 1.0f - weight1y;
@@ -593,7 +592,7 @@ static void enlarge_picture_float(
uintptr_t x = ((int) x_src) * 4;
*dst++ = line1[x] * w11 +
*dst++ = line1[x] * w11 +
line2[x] * w21 +
line1[4 + x] * w12 +
line2[4 + x] * w22;
@@ -629,27 +628,27 @@ struct scale_outpix_float {
};
static void shrink_picture_float(
float* src, float* dst, int src_width,
int src_height, int dst_width, int dst_height)
float *src, float *dst, int src_width,
int src_height, int dst_width, int dst_height)
{
double ratiox = (double) (dst_width) / (double) (src_width);
double ratioy = (double) (dst_height) / (double) (src_height);
uintptr_t x_src;
uintptr_t y_src;
float dx_dst, x_dst;
float dx_dst, x_dst;
float dy_dst, y_dst;
float y_counter;
float * dst_begin = dst;
float *dst_begin = dst;
struct scale_outpix_float * dst_line1;
struct scale_outpix_float * dst_line2;
struct scale_outpix_float *dst_line1;
struct scale_outpix_float *dst_line2;
dst_line1 = (struct scale_outpix_float*) MEM_callocN(
(dst_width + 1) * sizeof(struct scale_outpix_float),
"shrink_picture_float 1");
dst_line2 = (struct scale_outpix_float*) MEM_callocN(
(dst_width + 1) * sizeof(struct scale_outpix_float),
"shrink_picture_float 2");
dst_line1 = (struct scale_outpix_float *) MEM_callocN(
(dst_width + 1) * sizeof(struct scale_outpix_float),
"shrink_picture_float 1");
dst_line2 = (struct scale_outpix_float *) MEM_callocN(
(dst_width + 1) * sizeof(struct scale_outpix_float),
"shrink_picture_float 2");
dx_dst = ratiox;
dy_dst = ratioy;
@@ -657,7 +656,7 @@ static void shrink_picture_float(
y_dst = 0;
y_counter = 1.0;
for (y_src = 0; y_src < src_height; y_src++) {
float* line = src + y_src * 4 * src_width;
float *line = src + y_src * 4 * src_width;
uintptr_t weight1y = 1.0f - (y_dst - (int) y_dst);
uintptr_t weight2y = 1.0f - weight1y;
x_dst = 0;
@@ -687,19 +686,19 @@ static void shrink_picture_float(
w = weight1y * weight2x;
dst_line1[x+1].r += line[0] * w;
dst_line1[x+1].g += line[1] * w;
dst_line1[x+1].b += line[2] * w;
dst_line1[x+1].a += line[3] * w;
dst_line1[x+1].weight += w;
dst_line1[x + 1].r += line[0] * w;
dst_line1[x + 1].g += line[1] * w;
dst_line1[x + 1].b += line[2] * w;
dst_line1[x + 1].a += line[3] * w;
dst_line1[x + 1].weight += w;
w = weight2y * weight2x;
dst_line2[x+1].r += line[0] * w;
dst_line2[x+1].g += line[1] * w;
dst_line2[x+1].b += line[2] * w;
dst_line2[x+1].a += line[3] * w;
dst_line2[x+1].weight += w;
dst_line2[x + 1].r += line[0] * w;
dst_line2[x + 1].g += line[1] * w;
dst_line2[x + 1].b += line[2] * w;
dst_line2[x + 1].a += line[3] * w;
dst_line2[x + 1].weight += w;
x_dst += dx_dst;
line += 4;
@@ -709,11 +708,11 @@ static void shrink_picture_float(
y_counter -= dy_dst;
if (y_counter < 0) {
uintptr_t x;
struct scale_outpix_float * temp;
struct scale_outpix_float *temp;
y_counter += 1.0f;
for (x=0; x < dst_width; x++) {
for (x = 0; x < dst_width; x++) {
float f = 1.0f / dst_line1[x].weight;
*dst++ = dst_line1[x].r * f;
*dst++ = dst_line1[x].g * f;
@@ -742,16 +741,16 @@ static void shrink_picture_float(
}
static void q_scale_float(float* in, float* out, int in_width,
int in_height, int dst_width, int dst_height)
static void q_scale_float(float *in, float *out, int in_width,
int in_height, int dst_width, int dst_height)
{
if (dst_width > in_width && dst_height > in_height) {
enlarge_picture_float(in, out, in_width, in_height,
dst_width, dst_height);
dst_width, dst_height);
}
else if (dst_width < in_width && dst_height < in_height) {
shrink_picture_float(in, out, in_width, in_height,
dst_width, dst_height);
dst_width, dst_height);
}
}
@@ -777,16 +776,17 @@ static void q_scale_float(float* in, float* out, int in_width,
* NOTE: disabled, due to inacceptable inaccuracy and quality loss, see bug #18609 (ton)
*/
static int q_scale_linear_interpolation(
struct ImBuf *ibuf, int newx, int newy)
struct ImBuf *ibuf, int newx, int newy)
{
if ((newx >= ibuf->x && newy <= ibuf->y) ||
(newx <= ibuf->x && newy >= ibuf->y)) {
(newx <= ibuf->x && newy >= ibuf->y))
{
return FALSE;
}
if (ibuf->rect) {
unsigned char * newrect =
MEM_mallocN(newx * newy * sizeof(int), "q_scale rect");
unsigned char *newrect =
MEM_mallocN(newx * newy * sizeof(int), "q_scale rect");
q_scale_byte((unsigned char *)ibuf->rect, newrect, ibuf->x, ibuf->y,
newx, newy);
@@ -795,9 +795,9 @@ static int q_scale_linear_interpolation(
ibuf->rect = (unsigned int *) newrect;
}
if (ibuf->rect_float) {
float * newrect =
MEM_mallocN(newx * newy * 4 *sizeof(float),
"q_scale rectfloat");
float *newrect =
MEM_mallocN(newx * newy * 4 * sizeof(float),
"q_scale rectfloat");
q_scale_float(ibuf->rect_float, newrect, ibuf->x, ibuf->y,
newx, newy);
imb_freerectfloatImBuf(ibuf);
@@ -812,29 +812,29 @@ static int q_scale_linear_interpolation(
static struct ImBuf *scaledownx(struct ImBuf *ibuf, int newx)
{
const int do_rect= (ibuf->rect != NULL);
const int do_float= (ibuf->rect_float != NULL);
const size_t rect_size= ibuf->x * ibuf->y * 4;
const int do_rect = (ibuf->rect != NULL);
const int do_float = (ibuf->rect_float != NULL);
const size_t rect_size = ibuf->x * ibuf->y * 4;
uchar *rect, *_newrect, *newrect;
float *rectf, *_newrectf, *newrectf;
float sample, add, val[4], nval[4], valf[4], nvalf[4];
int x, y;
rectf= _newrectf= newrectf= NULL;
rect=_newrect= newrect= NULL;
nval[0]= nval[1]= nval[2]= nval[3]= 0.0f;
nvalf[0]=nvalf[1]=nvalf[2]=nvalf[3]= 0.0f;
rectf = _newrectf = newrectf = NULL;
rect = _newrect = newrect = NULL;
nval[0] = nval[1] = nval[2] = nval[3] = 0.0f;
nvalf[0] = nvalf[1] = nvalf[2] = nvalf[3] = 0.0f;
if (!do_rect && !do_float) return (ibuf);
if (do_rect) {
_newrect = MEM_mallocN(newx * ibuf->y * sizeof(uchar) * 4, "scaledownx");
if (_newrect==NULL) return(ibuf);
if (_newrect == NULL) return(ibuf);
}
if (do_float) {
_newrectf = MEM_mallocN(newx * ibuf->y * sizeof(float) * 4, "scaledownxf");
if (_newrectf==NULL) {
if (_newrectf == NULL) {
if (_newrect) MEM_freeN(_newrect);
return(ibuf);
}
@@ -853,21 +853,21 @@ static struct ImBuf *scaledownx(struct ImBuf *ibuf, int newx)
for (y = ibuf->y; y > 0; y--) {
sample = 0.0f;
val[0]= val[1]= val[2]= val[3]= 0.0f;
valf[0]=valf[1]=valf[2]=valf[3]= 0.0f;
val[0] = val[1] = val[2] = val[3] = 0.0f;
valf[0] = valf[1] = valf[2] = valf[3] = 0.0f;
for (x = newx; x > 0; x--) {
if (do_rect) {
nval[0] = - val[0] * sample;
nval[1] = - val[1] * sample;
nval[2] = - val[2] * sample;
nval[3] = - val[3] * sample;
nval[0] = -val[0] * sample;
nval[1] = -val[1] * sample;
nval[2] = -val[2] * sample;
nval[3] = -val[3] * sample;
}
if (do_float) {
nvalf[0] = - valf[0] * sample;
nvalf[1] = - valf[1] * sample;
nvalf[2] = - valf[2] * sample;
nvalf[3] = - valf[3] * sample;
nvalf[0] = -valf[0] * sample;
nvalf[1] = -valf[1] * sample;
nvalf[2] = -valf[2] * sample;
nvalf[3] = -valf[3] * sample;
}
sample += add;
@@ -892,25 +892,25 @@ static struct ImBuf *scaledownx(struct ImBuf *ibuf, int newx)
}
if (do_rect) {
val[0]= rect[0];val[1]= rect[1];val[2]= rect[2];val[3]= rect[3];
val[0] = rect[0]; val[1] = rect[1]; val[2] = rect[2]; val[3] = rect[3];
rect += 4;
newrect[0] = ((nval[0] + sample * val[0])/add + 0.5f);
newrect[1] = ((nval[1] + sample * val[1])/add + 0.5f);
newrect[2] = ((nval[2] + sample * val[2])/add + 0.5f);
newrect[3] = ((nval[3] + sample * val[3])/add + 0.5f);
newrect[0] = ((nval[0] + sample * val[0]) / add + 0.5f);
newrect[1] = ((nval[1] + sample * val[1]) / add + 0.5f);
newrect[2] = ((nval[2] + sample * val[2]) / add + 0.5f);
newrect[3] = ((nval[3] + sample * val[3]) / add + 0.5f);
newrect += 4;
}
if (do_float) {
valf[0]= rectf[0];valf[1]= rectf[1];valf[2]= rectf[2];valf[3]= rectf[3];
valf[0] = rectf[0]; valf[1] = rectf[1]; valf[2] = rectf[2]; valf[3] = rectf[3];
rectf += 4;
newrectf[0] = ((nvalf[0] + sample * valf[0])/add);
newrectf[1] = ((nvalf[1] + sample * valf[1])/add);
newrectf[2] = ((nvalf[2] + sample * valf[2])/add);
newrectf[3] = ((nvalf[3] + sample * valf[3])/add);
newrectf[0] = ((nvalf[0] + sample * valf[0]) / add);
newrectf[1] = ((nvalf[1] + sample * valf[1]) / add);
newrectf[2] = ((nvalf[2] + sample * valf[2]) / add);
newrectf[3] = ((nvalf[3] + sample * valf[3]) / add);
newrectf += 4;
}
@@ -942,29 +942,29 @@ static struct ImBuf *scaledownx(struct ImBuf *ibuf, int newx)
static struct ImBuf *scaledowny(struct ImBuf *ibuf, int newy)
{
const int do_rect= (ibuf->rect != NULL);
const int do_float= (ibuf->rect_float != NULL);
const size_t rect_size= ibuf->x * ibuf->y * 4;
const int do_rect = (ibuf->rect != NULL);
const int do_float = (ibuf->rect_float != NULL);
const size_t rect_size = ibuf->x * ibuf->y * 4;
uchar *rect, *_newrect, *newrect;
float *rectf, *_newrectf, *newrectf;
float sample, add, val[4], nval[4], valf[4], nvalf[4];
int x, y, skipx;
rectf= _newrectf= newrectf= NULL;
rect= _newrect= newrect= NULL;
nval[0]= nval[1]= nval[2]= nval[3]= 0.0f;
nvalf[0]=nvalf[1]=nvalf[2]=nvalf[3]= 0.0f;
rectf = _newrectf = newrectf = NULL;
rect = _newrect = newrect = NULL;
nval[0] = nval[1] = nval[2] = nval[3] = 0.0f;
nvalf[0] = nvalf[1] = nvalf[2] = nvalf[3] = 0.0f;
if (!do_rect && !do_float) return (ibuf);
if (do_rect) {
_newrect = MEM_mallocN(newy * ibuf->x * sizeof(uchar) * 4, "scaledowny");
if (_newrect==NULL) return(ibuf);
if (_newrect == NULL) return(ibuf);
}
if (do_float) {
_newrectf = MEM_mallocN(newy * ibuf->x * sizeof(float) * 4, "scaledownyf");
if (_newrectf==NULL) {
if (_newrectf == NULL) {
if (_newrect) MEM_freeN(_newrect);
return(ibuf);
}
@@ -984,21 +984,21 @@ static struct ImBuf *scaledowny(struct ImBuf *ibuf, int newy)
}
sample = 0.0f;
val[0]= val[1]= val[2]= val[3]= 0.0f;
valf[0]=valf[1]=valf[2]=valf[3]= 0.0f;
val[0] = val[1] = val[2] = val[3] = 0.0f;
valf[0] = valf[1] = valf[2] = valf[3] = 0.0f;
for (y = newy; y > 0; y--) {
if (do_rect) {
nval[0] = - val[0] * sample;
nval[1] = - val[1] * sample;
nval[2] = - val[2] * sample;
nval[3] = - val[3] * sample;
nval[0] = -val[0] * sample;
nval[1] = -val[1] * sample;
nval[2] = -val[2] * sample;
nval[3] = -val[3] * sample;
}
if (do_float) {
nvalf[0] = - valf[0] * sample;
nvalf[1] = - valf[1] * sample;
nvalf[2] = - valf[2] * sample;
nvalf[3] = - valf[3] * sample;
nvalf[0] = -valf[0] * sample;
nvalf[1] = -valf[1] * sample;
nvalf[2] = -valf[2] * sample;
nvalf[3] = -valf[3] * sample;
}
sample += add;
@@ -1023,25 +1023,25 @@ static struct ImBuf *scaledowny(struct ImBuf *ibuf, int newy)
}
if (do_rect) {
val[0]= rect[0];val[1]= rect[1];val[2]= rect[2];val[3]= rect[3];
val[0] = rect[0]; val[1] = rect[1]; val[2] = rect[2]; val[3] = rect[3];
rect += skipx;
newrect[0] = ((nval[0] + sample * val[0])/add + 0.5f);
newrect[1] = ((nval[1] + sample * val[1])/add + 0.5f);
newrect[2] = ((nval[2] + sample * val[2])/add + 0.5f);
newrect[3] = ((nval[3] + sample * val[3])/add + 0.5f);
newrect[0] = ((nval[0] + sample * val[0]) / add + 0.5f);
newrect[1] = ((nval[1] + sample * val[1]) / add + 0.5f);
newrect[2] = ((nval[2] + sample * val[2]) / add + 0.5f);
newrect[3] = ((nval[3] + sample * val[3]) / add + 0.5f);
newrect += skipx;
}
if (do_float) {
valf[0]= rectf[0];valf[1]= rectf[1];valf[2]= rectf[2];valf[3]= rectf[3];
valf[0] = rectf[0]; valf[1] = rectf[1]; valf[2] = rectf[2]; valf[3] = rectf[3];
rectf += skipx;
newrectf[0] = ((nvalf[0] + sample * valf[0])/add);
newrectf[1] = ((nvalf[1] + sample * valf[1])/add);
newrectf[2] = ((nvalf[2] + sample * valf[2])/add);
newrectf[3] = ((nvalf[3] + sample * valf[3])/add);
newrectf[0] = ((nvalf[0] + sample * valf[0]) / add);
newrectf[1] = ((nvalf[1] + sample * valf[1]) / add);
newrectf[2] = ((nvalf[2] + sample * valf[2]) / add);
newrectf[3] = ((nvalf[3] + sample * valf[3]) / add);
newrectf += skipx;
}
@@ -1073,8 +1073,8 @@ static struct ImBuf *scaledowny(struct ImBuf *ibuf, int newy)
static struct ImBuf *scaleupx(struct ImBuf *ibuf, int newx)
{
uchar *rect, *_newrect=NULL, *newrect;
float *rectf, *_newrectf=NULL, *newrectf;
uchar *rect, *_newrect = NULL, *newrect;
float *rectf, *_newrectf = NULL, *newrectf;
float sample, add;
float val_a, nval_a, diff_a;
float val_b, nval_b, diff_b;
@@ -1090,18 +1090,18 @@ static struct ImBuf *scaleupx(struct ImBuf *ibuf, int newx)
val_g = nval_g = diff_g = val_r = nval_r = diff_r = 0;
val_af = nval_af = diff_af = val_bf = nval_bf = diff_bf = 0;
val_gf = nval_gf = diff_gf = val_rf = nval_rf = diff_rf = 0;
if (ibuf==NULL) return(NULL);
if (ibuf->rect==NULL && ibuf->rect_float==NULL) return (ibuf);
if (ibuf == NULL) return(NULL);
if (ibuf->rect == NULL && ibuf->rect_float == NULL) return (ibuf);
if (ibuf->rect) {
do_rect = 1;
_newrect = MEM_mallocN(newx * ibuf->y * sizeof(int), "scaleupx");
if (_newrect==NULL) return(ibuf);
if (_newrect == NULL) return(ibuf);
}
if (ibuf->rect_float) {
do_float = 1;
_newrectf = MEM_mallocN(newx * ibuf->y * sizeof(float) * 4, "scaleupxf");
if (_newrectf==NULL) {
if (_newrectf == NULL) {
if (_newrect) MEM_freeN(_newrect);
return(ibuf);
}
@@ -1240,8 +1240,8 @@ static struct ImBuf *scaleupx(struct ImBuf *ibuf, int newx)
static struct ImBuf *scaleupy(struct ImBuf *ibuf, int newy)
{
uchar *rect, *_newrect=NULL, *newrect;
float *rectf, *_newrectf=NULL, *newrectf;
uchar *rect, *_newrect = NULL, *newrect;
float *rectf, *_newrectf = NULL, *newrectf;
float sample, add;
float val_a, nval_a, diff_a;
float val_b, nval_b, diff_b;
@@ -1257,18 +1257,18 @@ static struct ImBuf *scaleupy(struct ImBuf *ibuf, int newy)
val_g = nval_g = diff_g = val_r = nval_r = diff_r = 0;
val_af = nval_af = diff_af = val_bf = nval_bf = diff_bf = 0;
val_gf = nval_gf = diff_gf = val_rf = nval_rf = diff_rf = 0;
if (ibuf==NULL) return(NULL);
if (ibuf->rect==NULL && ibuf->rect_float==NULL) return (ibuf);
if (ibuf == NULL) return(NULL);
if (ibuf->rect == NULL && ibuf->rect_float == NULL) return (ibuf);
if (ibuf->rect) {
do_rect = 1;
_newrect = MEM_mallocN(ibuf->x * newy * sizeof(int), "scaleupy");
if (_newrect==NULL) return(ibuf);
if (_newrect == NULL) return(ibuf);
}
if (ibuf->rect_float) {
do_float = 1;
_newrectf = MEM_mallocN(ibuf->x * newy * sizeof(float) * 4, "scaleupyf");
if (_newrectf==NULL) {
if (_newrectf == NULL) {
if (_newrect) MEM_freeN(_newrect);
return(ibuf);
}
@@ -1286,8 +1286,8 @@ static struct ImBuf *scaleupy(struct ImBuf *ibuf, int newy)
sample = 0;
if (do_rect) {
rect = ((uchar *)ibuf->rect) + 4*(x-1);
newrect = _newrect + 4*(x-1);
rect = ((uchar *)ibuf->rect) + 4 * (x - 1);
newrect = _newrect + 4 * (x - 1);
val_a = rect[0];
nval_a = rect[skipx];
@@ -1295,43 +1295,43 @@ static struct ImBuf *scaleupy(struct ImBuf *ibuf, int newy)
val_a += 0.5f;
val_b = rect[1];
nval_b = rect[skipx+1];
nval_b = rect[skipx + 1];
diff_b = nval_b - val_b;
val_b += 0.5f;
val_g = rect[2];
nval_g = rect[skipx+2];
nval_g = rect[skipx + 2];
diff_g = nval_g - val_g;
val_g += 0.5f;
val_r = rect[3];
nval_r = rect[skipx+4];
nval_r = rect[skipx + 4];
diff_r = nval_r - val_r;
val_r += 0.5f;
rect += 2*skipx;
rect += 2 * skipx;
}
if (do_float) {
rectf = ((float *)ibuf->rect_float) + 4*(x-1);
newrectf = _newrectf + 4*(x-1);
rectf = ((float *)ibuf->rect_float) + 4 * (x - 1);
newrectf = _newrectf + 4 * (x - 1);
val_af = rectf[0];
nval_af = rectf[skipx];
diff_af = nval_af - val_af;
val_bf = rectf[1];
nval_bf = rectf[skipx+1];
nval_bf = rectf[skipx + 1];
diff_bf = nval_bf - val_bf;
val_gf = rectf[2];
nval_gf = rectf[skipx+2];
nval_gf = rectf[skipx + 2];
diff_gf = nval_gf - val_gf;
val_rf = rectf[3];
nval_rf = rectf[skipx+3];
nval_rf = rectf[skipx + 3];
diff_rf = nval_rf - val_rf;
rectf += 2*skipx;
rectf += 2 * skipx;
}
for (y = newy; y > 0; y--) {
@@ -1422,7 +1422,7 @@ static void scalefast_Z_ImBuf(ImBuf *ibuf, int newx, int newy)
if (ibuf->zbuf) {
_newrect = MEM_mallocN(newx * newy * sizeof(int), "z rect");
if (_newrect==NULL) return;
if (_newrect == NULL) return;
stepx = (65536.0 * (ibuf->x - 1.0) / (newx - 1.0)) + 0.5;
stepy = (65536.0 * (ibuf->y - 1.0) / (newy - 1.0)) + 0.5;
@@ -1431,7 +1431,7 @@ static void scalefast_Z_ImBuf(ImBuf *ibuf, int newx, int newy)
newrect = _newrect;
for (y = newy; y > 0; y--) {
rect = (unsigned int*) ibuf->zbuf;
rect = (unsigned int *) ibuf->zbuf;
rect += (ofsy >> 16) * ibuf->x;
ofsy += stepy;
ofsx = 32768;
@@ -1443,14 +1443,14 @@ static void scalefast_Z_ImBuf(ImBuf *ibuf, int newx, int newy)
IMB_freezbufImBuf(ibuf);
ibuf->mall |= IB_zbuf;
ibuf->zbuf = (int*) _newrect;
ibuf->zbuf = (int *) _newrect;
}
}
struct ImBuf *IMB_scaleImBuf(struct ImBuf * ibuf, unsigned int newx, unsigned int newy)
struct ImBuf *IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
{
if (ibuf==NULL) return (NULL);
if (ibuf->rect==NULL && ibuf->rect_float==NULL) return (ibuf);
if (ibuf == NULL) return (NULL);
if (ibuf->rect == NULL && ibuf->rect_float == NULL) return (ibuf);
if (newx == ibuf->x && newy == ibuf->y) { return ibuf; }
@@ -1480,28 +1480,28 @@ struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned
{
unsigned int *rect, *_newrect, *newrect;
struct imbufRGBA *rectf, *_newrectf, *newrectf;
int x, y, do_float=0, do_rect=0;
int x, y, do_float = 0, do_rect = 0;
int ofsx, ofsy, stepx, stepy;
rect = NULL; _newrect = NULL; newrect = NULL;
rectf = NULL; _newrectf = NULL; newrectf = NULL;
if (ibuf==NULL) return(NULL);
if (ibuf == NULL) return(NULL);
if (ibuf->rect) do_rect = 1;
if (ibuf->rect_float) do_float = 1;
if (do_rect==0 && do_float==0) return(ibuf);
if (do_rect == 0 && do_float == 0) return(ibuf);
if (newx == ibuf->x && newy == ibuf->y) return(ibuf);
if (do_rect) {
_newrect = MEM_mallocN(newx * newy * sizeof(int), "scalefastimbuf");
if (_newrect==NULL) return(ibuf);
if (_newrect == NULL) return(ibuf);
newrect = _newrect;
}
if (do_float) {
_newrectf = MEM_mallocN(newx * newy * sizeof(float) * 4, "scalefastimbuf f");
if (_newrectf==NULL) {
if (_newrectf == NULL) {
if (_newrect) MEM_freeN(_newrect);
return(ibuf);
}
@@ -1525,7 +1525,7 @@ struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned
ofsx = 32768;
if (do_rect) {
for (x = newx; x>0; x--) {
for (x = newx; x > 0; x--) {
*newrect++ = rect[ofsx >> 16];
ofsx += stepx;
}
@@ -1533,7 +1533,7 @@ struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned
if (do_float) {
ofsx = 32768;
for (x = newx; x>0; x--) {
for (x = newx; x > 0; x--) {
*newrectf++ = rectf[ofsx >> 16];
ofsx += stepx;
}

View File

@@ -67,19 +67,19 @@
# include <unistd.h>
#endif
#define URI_MAX FILE_MAX*3 + 8
#define URI_MAX FILE_MAX * 3 + 8
static int get_thumb_dir(char *dir, ThumbSize size)
{
#ifdef WIN32
wchar_t dir_16 [MAX_PATH];
wchar_t dir_16[MAX_PATH];
/* yes, applications shouldn't store data there, but so does GIMP :)*/
SHGetSpecialFolderPathW(0, dir_16, CSIDL_PROFILE, 0);
conv_utf_16_to_8(dir_16, dir, FILE_MAX);
#else
const char* home = getenv("HOME");
const char *home = getenv("HOME");
if (!home) return 0;
BLI_strncpy(dir, home, FILE_MAX);
#endif
@@ -105,11 +105,11 @@ static int get_thumb_dir(char *dir, ThumbSize size)
* released under the Gnu General Public License.
*/
typedef enum {
UNSAFE_ALL = 0x1, /* Escape all unsafe characters */
UNSAFE_ALLOW_PLUS = 0x2, /* Allows '+' */
UNSAFE_PATH = 0x8, /* Allows '/', '&', '=', ':', '@', '+', '$' and ',' */
UNSAFE_HOST = 0x10, /* Allows '/' and ':' and '@' */
UNSAFE_SLASHES = 0x20 /* Allows all characters except for '/' and '%' */
UNSAFE_ALL = 0x1, /* Escape all unsafe characters */
UNSAFE_ALLOW_PLUS = 0x2, /* Allows '+' */
UNSAFE_PATH = 0x8, /* Allows '/', '&', '=', ':', '@', '+', '$' and ',' */
UNSAFE_HOST = 0x10, /* Allows '/' and ':' and '@' */
UNSAFE_SLASHES = 0x20 /* Allows all characters except for '/' and '%' */
} UnsafeCharacterSet;
static const unsigned char acceptable[96] = {
@@ -132,9 +132,9 @@ static const char hex[17] = "0123456789abcdef";
/* Note: This escape function works on file: URIs, but if you want to
* escape something else, please read RFC-2396 */
static void escape_uri_string (const char *string, char* escaped_string, int len, UnsafeCharacterSet mask)
static void escape_uri_string(const char *string, char *escaped_string, int len, UnsafeCharacterSet mask)
{
#define ACCEPTABLE(a) ((a)>=32 && (a)<128 && (acceptable[(a)-32] & use_mask))
#define ACCEPTABLE(a) ((a) >= 32 && (a) < 128 && (acceptable[(a) - 32] & use_mask))
const char *p;
char *q;
@@ -146,7 +146,7 @@ static void escape_uri_string (const char *string, char* escaped_string, int len
c = (unsigned char) *p;
len--;
if (!ACCEPTABLE (c)) {
if (!ACCEPTABLE(c)) {
*q++ = '%'; /* means hex coming */
*q++ = hex[c >> 4];
*q++ = hex[c & 15];
@@ -159,7 +159,7 @@ static void escape_uri_string (const char *string, char* escaped_string, int len
*q = '\0';
}
static void to_hex_char(char* hexbytes, const unsigned char* bytes, int len)
static void to_hex_char(char *hexbytes, const unsigned char *bytes, int len)
{
const unsigned char *p;
char *q;
@@ -177,7 +177,7 @@ static void to_hex_char(char* hexbytes, const unsigned char* bytes, int len)
static int uri_from_filename(const char *path, char *uri)
{
char orig_uri[URI_MAX];
const char* dirstart = path;
const char *dirstart = path;
#ifdef WIN32
{
@@ -203,17 +203,17 @@ static int uri_from_filename(const char *path, char *uri)
#ifdef WITH_ICONV
{
char uri_utf8[FILE_MAX*3+8];
escape_uri_string(orig_uri, uri_utf8, FILE_MAX*3+8, UNSAFE_PATH);
char uri_utf8[FILE_MAX * 3 + 8];
escape_uri_string(orig_uri, uri_utf8, FILE_MAX * 3 + 8, UNSAFE_PATH);
BLI_string_to_utf8(uri_utf8, uri, NULL);
}
#else
escape_uri_string(orig_uri, uri, FILE_MAX*3+8, UNSAFE_PATH);
escape_uri_string(orig_uri, uri, FILE_MAX * 3 + 8, UNSAFE_PATH);
#endif
return 1;
}
static void thumbname_from_uri(const char* uri, char* thumb, const int thumb_len)
static void thumbname_from_uri(const char *uri, char *thumb, const int thumb_len)
{
char hexdigest[33];
unsigned char digest[16];
@@ -227,7 +227,7 @@ static void thumbname_from_uri(const char* uri, char* thumb, const int thumb_len
// printf("%s: '%s' --> '%s'\n", __func__, uri, thumb);
}
static int thumbpath_from_uri(const char* uri, char* path, const int path_len, ThumbSize size)
static int thumbpath_from_uri(const char *uri, char *path, const int path_len, ThumbSize size)
{
char tmppath[FILE_MAX];
int rv = 0;
@@ -253,16 +253,16 @@ void IMB_thumb_makedirs(void)
}
/* create thumbnail for file and returns new imbuf for thumbnail */
ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, ImBuf *img)
ImBuf *IMB_thumb_create(const char *path, ThumbSize size, ThumbSource source, ImBuf *img)
{
char uri[URI_MAX]= "";
char desc[URI_MAX+22];
char uri[URI_MAX] = "";
char desc[URI_MAX + 22];
char tpath[FILE_MAX];
char tdir[FILE_MAX];
char temp[FILE_MAX];
char mtime[40]= "0"; /* in case we can't stat the file */
char cwidth[40]= "0"; /* in case images have no data */
char cheight[40]= "0";
char mtime[40] = "0"; /* in case we can't stat the file */
char cwidth[40] = "0"; /* in case images have no data */
char cheight[40] = "0";
char thumb[40];
short tsize = 128;
short ex, ey;
@@ -285,7 +285,7 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, Im
/* exception, skip images over 100mb */
if (source == THB_SOURCE_IMAGE) {
const size_t size= BLI_file_size(path);
const size_t size = BLI_file_size(path);
if (size != -1 && size > THUMB_SIZE_MAX) {
// printf("file too big: %d, skipping %s\n", (int)size, path);
return NULL;
@@ -309,7 +309,7 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, Im
if (THB_SOURCE_IMAGE == source || THB_SOURCE_BLEND == source) {
/* only load if we didnt give an image */
if (img==NULL) {
if (img == NULL) {
if (THB_SOURCE_BLEND == source) {
img = IMB_loadblend_thumb(path);
}
@@ -326,7 +326,7 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, Im
}
}
else if (THB_SOURCE_MOVIE == source) {
struct anim * anim = NULL;
struct anim *anim = NULL;
anim = IMB_open_anim(path, IB_rect | IB_metadata, 0);
if (anim != NULL) {
img = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
@@ -346,11 +346,11 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, Im
if (img->x > img->y) {
scaledx = (float)tsize;
scaledy = ( (float)img->y/(float)img->x )*tsize;
scaledy = ( (float)img->y / (float)img->x) * tsize;
}
else {
scaledy = (float)tsize;
scaledx = ( (float)img->x/(float)img->y )*tsize;
scaledx = ( (float)img->x / (float)img->y) * tsize;
}
ex = (short)scaledx;
ey = (short)scaledy;
@@ -392,10 +392,10 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, Im
}
/* read thumbnail for file and returns new imbuf for thumbnail */
ImBuf* IMB_thumb_read(const char* path, ThumbSize size)
ImBuf *IMB_thumb_read(const char *path, ThumbSize size)
{
char thumb[FILE_MAX];
char uri[FILE_MAX*3+8];
char uri[FILE_MAX * 3 + 8];
ImBuf *img = NULL;
if (!uri_from_filename(path, uri)) {
@@ -409,10 +409,10 @@ ImBuf* IMB_thumb_read(const char* path, ThumbSize size)
}
/* delete all thumbs for the file */
void IMB_thumb_delete(const char* path, ThumbSize size)
void IMB_thumb_delete(const char *path, ThumbSize size)
{
char thumb[FILE_MAX];
char uri[FILE_MAX*3+8];
char uri[FILE_MAX * 3 + 8];
if (!uri_from_filename(path, uri)) {
return;
@@ -429,12 +429,12 @@ void IMB_thumb_delete(const char* path, ThumbSize size)
/* create the thumb if necessary and manage failed and old thumbs */
ImBuf* IMB_thumb_manage(const char* path, ThumbSize size, ThumbSource source)
ImBuf *IMB_thumb_manage(const char *path, ThumbSize size, ThumbSource source)
{
char thumb[FILE_MAX];
char uri[FILE_MAX*3+8];
char uri[FILE_MAX * 3 + 8];
struct stat st;
ImBuf* img = NULL;
ImBuf *img = NULL;
if (stat(path, &st)) {
return NULL;
@@ -507,5 +507,3 @@ ImBuf* IMB_thumb_manage(const char* path, ThumbSize size, ThumbSource source)
return img;
}

View File

@@ -47,7 +47,7 @@
static ImBuf *loadblend_thumb(gzFile gzfile)
{
char buf[12];
int bhead[24/sizeof(int)]; /* max size on 64bit */
int bhead[24 / sizeof(int)]; /* max size on 64bit */
char endian, pointer_size;
char endian_switch;
int sizeof_bhead;
@@ -58,19 +58,19 @@ static ImBuf *loadblend_thumb(gzFile gzfile)
if (strncmp(buf, "BLENDER", 7))
return NULL;
if (buf[7]=='-')
pointer_size= 8;
else if (buf[7]=='_')
pointer_size= 4;
if (buf[7] == '-')
pointer_size = 8;
else if (buf[7] == '_')
pointer_size = 4;
else
return NULL;
sizeof_bhead = 16 + pointer_size;
if (buf[8]=='V')
endian= B_ENDIAN; /* big: PPC */
else if (buf[8]=='v')
endian= L_ENDIAN; /* little: x86 */
if (buf[8] == 'V')
endian = B_ENDIAN; /* big: PPC */
else if (buf[8] == 'v')
endian = L_ENDIAN; /* little: x86 */
else
return NULL;
@@ -78,9 +78,9 @@ static ImBuf *loadblend_thumb(gzFile gzfile)
while (gzread(gzfile, bhead, sizeof_bhead) == sizeof_bhead) {
if (endian_switch)
SWITCH_INT(bhead[1]); /* length */
SWITCH_INT(bhead[1]); /* length */
if (bhead[0]==REND) {
if (bhead[0] == REND) {
gzseek(gzfile, bhead[1], SEEK_CUR); /* skip to the next */
}
else {
@@ -90,7 +90,7 @@ static ImBuf *loadblend_thumb(gzFile gzfile)
/* using 'TEST' since new names segfault when loading in old blenders */
if (bhead[0] == TEST) {
ImBuf *img= NULL;
ImBuf *img = NULL;
int size[2];
if (gzread(gzfile, size, sizeof(size)) != sizeof(size))
@@ -108,11 +108,11 @@ static ImBuf *loadblend_thumb(gzFile gzfile)
return NULL;
/* finally malloc and read the data */
img= IMB_allocImBuf(size[0], size[1], 32, IB_rect | IB_metadata);
img = IMB_allocImBuf(size[0], size[1], 32, IB_rect | IB_metadata);
if (gzread(gzfile, img->rect, bhead[1]) != bhead[1]) {
IMB_freeImBuf(img);
img= NULL;
img = NULL;
}
return img;
@@ -127,11 +127,11 @@ ImBuf *IMB_loadblend_thumb(const char *path)
/* not necessarily a gzip */
gzfile = BLI_gzopen(path, "rb");
if (NULL == gzfile ) {
if (NULL == gzfile) {
return NULL;
}
else {
ImBuf *img= loadblend_thumb(gzfile);
ImBuf *img = loadblend_thumb(gzfile);
/* read ok! */
gzclose(gzfile);
@@ -145,43 +145,43 @@ ImBuf *IMB_loadblend_thumb(const char *path)
void IMB_overlayblend_thumb(unsigned int *thumb, int width, int height, float aspect)
{
unsigned char *px= (unsigned char *)thumb;
unsigned char *px = (unsigned char *)thumb;
int margin_l = MARGIN;
int margin_b = MARGIN;
int margin_r = width - MARGIN;
int margin_t = height - MARGIN;
if (aspect < 1.0f) {
margin_l= (int)((width - ((float)width * aspect)) / 2.0f);
margin_l = (int)((width - ((float)width * aspect)) / 2.0f);
margin_l += MARGIN;
CLAMP(margin_l, MARGIN, (width/2));
CLAMP(margin_l, MARGIN, (width / 2));
margin_r = width - margin_l;
}
else if (aspect > 1.0f) {
margin_b= (int)((height - ((float)height / aspect)) / 2.0f);
margin_b = (int)((height - ((float)height / aspect)) / 2.0f);
margin_b += MARGIN;
CLAMP(margin_b, MARGIN, (height/2));
CLAMP(margin_b, MARGIN, (height / 2));
margin_t = height - margin_b;
}
{
int x, y;
int stride_x= (margin_r - margin_l) - 2;
int stride_x = (margin_r - margin_l) - 2;
for (y=0; y < height; y++) {
for (x=0; x < width; x++, px+=4) {
int hline= 0, vline= 0;
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++, px += 4) {
int hline = 0, vline = 0;
if ((x > margin_l && x < margin_r) && (y > margin_b && y < margin_t)) {
/* interior. skip */
x += stride_x;
px += stride_x * 4;
}
else if ((hline=(((x == margin_l || x == margin_r)) && y >= margin_b && y <= margin_t)) ||
(vline=(((y == margin_b || y == margin_t)) && x >= margin_l && x <= margin_r)))
else if ((hline = (((x == margin_l || x == margin_r)) && y >= margin_b && y <= margin_t)) ||
(vline = (((y == margin_b || y == margin_t)) && x >= margin_l && x <= margin_r)))
{
/* dashed line */
if ((hline && y % 2) || (vline && x % 2)) {
px[0]= px[1]= px[2]= 0;
px[0] = px[1] = px[2] = 0;
px[3] = 255;
}
}

View File

@@ -64,31 +64,31 @@
/***********************
* Local declarations. *
***********************/
* Local declarations. *
***********************/
/* Reading and writing of an in-memory TIFF file. */
static tsize_t imb_tiff_ReadProc(thandle_t handle, tdata_t data, tsize_t n);
static tsize_t imb_tiff_WriteProc(thandle_t handle, tdata_t data, tsize_t n);
static toff_t imb_tiff_SeekProc(thandle_t handle, toff_t ofs, int whence);
static int imb_tiff_CloseProc(thandle_t handle);
static toff_t imb_tiff_SizeProc(thandle_t handle);
static int imb_tiff_DummyMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize);
static int imb_tiff_DummyMapProc(thandle_t fd, tdata_t *pbase, toff_t *psize);
static void imb_tiff_DummyUnmapProc(thandle_t fd, tdata_t base, toff_t size);
/* Structure for in-memory TIFF file. */
typedef struct ImbTIFFMemFile {
unsigned char *mem; /* Location of first byte of TIFF file. */
toff_t offset; /* Current offset within the file. */
tsize_t size; /* Size of the TIFF file. */
unsigned char *mem; /* Location of first byte of TIFF file. */
toff_t offset; /* Current offset within the file. */
tsize_t size; /* Size of the TIFF file. */
} ImbTIFFMemFile;
#define IMB_TIFF_GET_MEMFILE(x) ((ImbTIFFMemFile*)(x))
#define IMB_TIFF_GET_MEMFILE(x) ((ImbTIFFMemFile *)(x))
/*****************************
* Function implementations. *
*****************************/
* Function implementations. *
*****************************/
static void imb_tiff_DummyUnmapProc(thandle_t fd, tdata_t base, toff_t size)
@@ -98,7 +98,7 @@ static void imb_tiff_DummyUnmapProc(thandle_t fd, tdata_t base, toff_t size)
(void)size;
}
static int imb_tiff_DummyMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize)
static int imb_tiff_DummyMapProc(thandle_t fd, tdata_t *pbase, toff_t *psize)
{
(void)fd;
(void)pbase;
@@ -115,12 +115,12 @@ static int imb_tiff_DummyMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize)
* \param n: Number of bytes to read.
*
* \return: Number of bytes actually read.
* 0 = EOF.
* 0 = EOF.
*/
static tsize_t imb_tiff_ReadProc(thandle_t handle, tdata_t data, tsize_t n)
{
tsize_t nRemaining, nCopy;
ImbTIFFMemFile* mfile;
ImbTIFFMemFile *mfile;
void *srcAddr;
/* get the pointer to the in-memory file */
@@ -145,9 +145,9 @@ static tsize_t imb_tiff_ReadProc(thandle_t handle, tdata_t data, tsize_t n)
return (0);
/* all set -> do the read (copy) */
srcAddr = (void*)(&(mfile->mem[mfile->offset]));
memcpy((void*)data, srcAddr, nCopy);
mfile->offset += nCopy; /* advance file ptr by copied bytes */
srcAddr = (void *)(&(mfile->mem[mfile->offset]));
memcpy((void *)data, srcAddr, nCopy);
mfile->offset += nCopy; /* advance file ptr by copied bytes */
return nCopy;
}
@@ -177,10 +177,10 @@ static tsize_t imb_tiff_WriteProc(thandle_t handle, tdata_t data, tsize_t n)
* \param handle: Handle of the TIFF file (pointer to ImbTIFFMemFile).
* \param ofs: Offset value (interpreted according to whence below).
* \param whence: This can be one of three values:
* SEEK_SET - The offset is set to ofs bytes.
* SEEK_CUR - The offset is set to its current location plus ofs bytes.
* SEEK_END - (This is unsupported and will return -1, indicating an
* error).
* SEEK_SET - The offset is set to ofs bytes.
* SEEK_CUR - The offset is set to its current location plus ofs bytes.
* SEEK_END - (This is unsupported and will return -1, indicating an
* error).
*
* \return: Resulting offset location within the file, measured in bytes from
* the beginning of the file. (-1) indicates an error.
@@ -208,8 +208,8 @@ static toff_t imb_tiff_SeekProc(thandle_t handle, toff_t ofs, int whence)
default:
/* no other types are supported - return an error */
fprintf(stderr,
"imb_tiff_SeekProc: "
"Unsupported TIFF SEEK type.\n");
"imb_tiff_SeekProc: "
"Unsupported TIFF SEEK type.\n");
return (-1);
}
@@ -260,7 +260,7 @@ static int imb_tiff_CloseProc(thandle_t handle)
*/
static toff_t imb_tiff_SizeProc(thandle_t handle)
{
ImbTIFFMemFile* mfile;
ImbTIFFMemFile *mfile;
/* get the pointer to the in-memory file */
mfile = IMB_TIFF_GET_MEMFILE(handle);
@@ -281,10 +281,10 @@ static TIFF *imb_tiff_client_open(ImbTIFFMemFile *memFile, unsigned char *mem, s
memFile->size = size;
return TIFFClientOpen("(Blender TIFF Interface Layer)",
"r", (thandle_t)(memFile),
imb_tiff_ReadProc, imb_tiff_WriteProc,
imb_tiff_SeekProc, imb_tiff_CloseProc,
imb_tiff_SizeProc, imb_tiff_DummyMapProc, imb_tiff_DummyUnmapProc);
"r", (thandle_t)(memFile),
imb_tiff_ReadProc, imb_tiff_WriteProc,
imb_tiff_SeekProc, imb_tiff_CloseProc,
imb_tiff_SizeProc, imb_tiff_DummyMapProc, imb_tiff_DummyUnmapProc);
}
/**
@@ -294,58 +294,58 @@ static TIFF *imb_tiff_client_open(ImbTIFFMemFile *memFile, unsigned char *mem, s
* http://www.faqs.org/faqs/graphics/fileformats-faq/part4/section-9.html
* The first four bytes of big-endian and little-endian TIFF files
* respectively are (hex):
* 4d 4d 00 2a
* 49 49 2a 00
* 4d 4d 00 2a
* 49 49 2a 00
* Note that TIFF files on *any* platform can be either big- or little-endian;
* it's not platform-specific.
*
* AFAICT, libtiff doesn't provide a method to do this automatically, and
* hence my manual comparison. - Jonathan Merritt (lancelet) 4th Sept 2005.
*/
#define IMB_TIFF_NCB 4 /* number of comparison bytes used */
#define IMB_TIFF_NCB 4 /* number of comparison bytes used */
int imb_is_a_tiff(unsigned char *mem)
{
char big_endian[IMB_TIFF_NCB] = { 0x4d, 0x4d, 0x00, 0x2a };
char lil_endian[IMB_TIFF_NCB] = { 0x49, 0x49, 0x2a, 0x00 };
return ( (memcmp(big_endian, mem, IMB_TIFF_NCB) == 0) ||
(memcmp(lil_endian, mem, IMB_TIFF_NCB) == 0) );
(memcmp(lil_endian, mem, IMB_TIFF_NCB) == 0) );
}
static void scanline_contig_16bit(float *rectf, unsigned short *sbuf, int scanline_w, int spp)
{
int i;
for (i=0; i < scanline_w; i++) {
rectf[i*4 + 0] = sbuf[i*spp + 0] / 65535.0;
rectf[i*4 + 1] = (spp>=3)? sbuf[i*spp + 1] / 65535.0: sbuf[i*spp + 0] / 65535.0;
rectf[i*4 + 2] = (spp>=3)? sbuf[i*spp + 2] / 65535.0: sbuf[i*spp + 0] / 65535.0;
rectf[i*4 + 3] = (spp==4)?(sbuf[i*spp + 3] / 65535.0):1.0;
for (i = 0; i < scanline_w; i++) {
rectf[i * 4 + 0] = sbuf[i * spp + 0] / 65535.0;
rectf[i * 4 + 1] = (spp >= 3) ? sbuf[i * spp + 1] / 65535.0 : sbuf[i * spp + 0] / 65535.0;
rectf[i * 4 + 2] = (spp >= 3) ? sbuf[i * spp + 2] / 65535.0 : sbuf[i * spp + 0] / 65535.0;
rectf[i * 4 + 3] = (spp == 4) ? (sbuf[i * spp + 3] / 65535.0) : 1.0;
}
}
static void scanline_contig_32bit(float *rectf, float *fbuf, int scanline_w, int spp)
{
int i;
for (i=0; i < scanline_w; i++) {
rectf[i*4 + 0] = fbuf[i*spp + 0];
rectf[i*4 + 1] = (spp>=3)? fbuf[i*spp + 1]: fbuf[i*spp + 0];
rectf[i*4 + 2] = (spp>=3)? fbuf[i*spp + 2]: fbuf[i*spp + 0];
rectf[i*4 + 3] = (spp==4)?fbuf[i*spp + 3]:1.0f;
for (i = 0; i < scanline_w; i++) {
rectf[i * 4 + 0] = fbuf[i * spp + 0];
rectf[i * 4 + 1] = (spp >= 3) ? fbuf[i * spp + 1] : fbuf[i * spp + 0];
rectf[i * 4 + 2] = (spp >= 3) ? fbuf[i * spp + 2] : fbuf[i * spp + 0];
rectf[i * 4 + 3] = (spp == 4) ? fbuf[i * spp + 3] : 1.0f;
}
}
static void scanline_separate_16bit(float *rectf, unsigned short *sbuf, int scanline_w, int chan)
{
int i;
for (i=0; i < scanline_w; i++)
rectf[i*4 + chan] = sbuf[i] / 65535.0;
for (i = 0; i < scanline_w; i++)
rectf[i * 4 + chan] = sbuf[i] / 65535.0;
}
static void scanline_separate_32bit(float *rectf, float *fbuf, int scanline_w, int chan)
{
int i;
for (i=0; i < scanline_w; i++)
rectf[i*4 + chan] = fbuf[i];
for (i = 0; i < scanline_w; i++)
rectf[i * 4 + chan] = fbuf[i];
}
static void imb_read_tiff_resolution(ImBuf *ibuf, TIFF *image)
@@ -359,12 +359,12 @@ static void imb_read_tiff_resolution(ImBuf *ibuf, TIFF *image)
TIFFGetFieldDefaulted(image, TIFFTAG_YRESOLUTION, &yres);
if (unit == RESUNIT_CENTIMETER) {
ibuf->ppm[0]= (double)xres * 100.0;
ibuf->ppm[1]= (double)yres * 100.0;
ibuf->ppm[0] = (double)xres * 100.0;
ibuf->ppm[1] = (double)yres * 100.0;
}
else {
ibuf->ppm[0]= (double)xres / 0.0254;
ibuf->ppm[1]= (double)yres / 0.0254;
ibuf->ppm[0] = (double)xres / 0.0254;
ibuf->ppm[1] = (double)yres / 0.0254;
}
}
@@ -376,15 +376,15 @@ static void imb_read_tiff_resolution(ImBuf *ibuf, TIFF *image)
static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul)
{
ImBuf *tmpibuf;
int success= 0;
int success = 0;
short bitspersample, spp, config;
size_t scanline;
int ib_flag=0, row, chan;
float *fbuf=NULL;
unsigned short *sbuf=NULL;
int ib_flag = 0, row, chan;
float *fbuf = NULL;
unsigned short *sbuf = NULL;
TIFFGetField(image, TIFFTAG_BITSPERSAMPLE, &bitspersample);
TIFFGetField(image, TIFFTAG_SAMPLESPERPIXEL, &spp); /* number of 'channels' */
TIFFGetField(image, TIFFTAG_SAMPLESPERPIXEL, &spp); /* number of 'channels' */
TIFFGetField(image, TIFFTAG_PLANARCONFIG, &config);
imb_read_tiff_resolution(ibuf, image);
@@ -403,7 +403,7 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul)
ib_flag = IB_rect;
}
tmpibuf= IMB_allocImBuf(ibuf->x, ibuf->y, ibuf->planes, ib_flag);
tmpibuf = IMB_allocImBuf(ibuf->x, ibuf->y, ibuf->planes, ib_flag);
/* simple RGBA image */
if (!(bitspersample == 32 || bitspersample == 16)) {
@@ -412,19 +412,19 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul)
/* contiguous channels: RGBRGBRGB */
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);
int ib_offset = ibuf->x * ibuf->y * 4 - ibuf->x * 4 * (row + 1);
if (bitspersample == 32) {
success |= TIFFReadScanline(image, fbuf, row, 0);
scanline_contig_32bit(tmpibuf->rect_float+ib_offset, fbuf, ibuf->x, spp);
scanline_contig_32bit(tmpibuf->rect_float + ib_offset, fbuf, ibuf->x, spp);
}
else if (bitspersample == 16) {
success |= TIFFReadScanline(image, sbuf, row, 0);
scanline_contig_16bit(tmpibuf->rect_float+ib_offset, sbuf, ibuf->x, spp);
scanline_contig_16bit(tmpibuf->rect_float + ib_offset, sbuf, ibuf->x, spp);
}
}
/* separate channels: RRRGGGBBB */
/* separate channels: RRRGGGBBB */
}
else if (config == PLANARCONFIG_SEPARATE) {
@@ -432,7 +432,7 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul)
* but only fill in from the TIFF scanline where necessary. */
for (chan = 0; chan < 4; chan++) {
for (row = 0; row < ibuf->y; row++) {
int ib_offset = ibuf->x*ibuf->y*4 - ibuf->x*4 * (row+1);
int ib_offset = ibuf->x * ibuf->y * 4 - ibuf->x * 4 * (row + 1);
if (bitspersample == 32) {
if (chan == 3 && spp == 3) /* fill alpha if only RGB TIFF */
@@ -441,7 +441,7 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul)
success |= TIFFReadScanline(image, fbuf, row, 0);
else
success |= TIFFReadScanline(image, fbuf, row, chan);
scanline_separate_32bit(tmpibuf->rect_float+ib_offset, fbuf, ibuf->x, chan);
scanline_separate_32bit(tmpibuf->rect_float + ib_offset, fbuf, ibuf->x, chan);
}
else if (bitspersample == 16) {
@@ -451,7 +451,7 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul)
success |= TIFFReadScanline(image, fbuf, row, 0);
else
success |= TIFFReadScanline(image, sbuf, row, chan);
scanline_separate_16bit(tmpibuf->rect_float+ib_offset, sbuf, ibuf->x, chan);
scanline_separate_16bit(tmpibuf->rect_float + ib_offset, sbuf, ibuf->x, chan);
}
}
@@ -464,7 +464,7 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul)
_TIFFfree(sbuf);
if (success) {
ibuf->profile = (bitspersample==32)?IB_PROFILE_LINEAR_RGB:IB_PROFILE_SRGB;
ibuf->profile = (bitspersample == 32) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_SRGB;
// Code seems to be not needed for 16 bits tif, on PPC G5 OSX (ton)
if (bitspersample < 16)
@@ -477,9 +477,9 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul)
/* assign rect last */
if (tmpibuf->rect_float)
ibuf->rect_float= tmpibuf->rect_float;
ibuf->rect_float = tmpibuf->rect_float;
else
ibuf->rect= tmpibuf->rect;
ibuf->rect = tmpibuf->rect;
ibuf->mall |= ib_flag;
ibuf->flags |= ib_flag;
@@ -539,7 +539,7 @@ ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags)
TIFFGetField(image, TIFFTAG_IMAGELENGTH, &height);
TIFFGetField(image, TIFFTAG_SAMPLESPERPIXEL, &spp);
ib_depth = (spp==3)?24:32;
ib_depth = (spp == 3) ? 24 : 32;
ibuf = IMB_allocImBuf(width, height, ib_depth, 0);
if (ibuf) {
@@ -547,8 +547,8 @@ ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags)
}
else {
fprintf(stderr,
"imb_loadtiff: could not allocate memory for TIFF "
"image.\n");
"imb_loadtiff: could not allocate memory for TIFF "
"image.\n");
TIFFClose(image);
return NULL;
}
@@ -562,39 +562,39 @@ ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags)
/* detect if we are reading a tiled/mipmapped texture, in that case
* we don't read pixels but leave it to the cache to load tiles */
if (flags & IB_tilecache) {
format= NULL;
format = NULL;
TIFFGetField(image, TIFFTAG_PIXAR_TEXTUREFORMAT, &format);
if (format && strcmp(format, "Plain Texture")==0 && TIFFIsTiled(image)) {
if (format && strcmp(format, "Plain Texture") == 0 && TIFFIsTiled(image)) {
int numlevel = TIFFNumberOfDirectories(image);
/* create empty mipmap levels in advance */
for (level=0; level<numlevel; level++) {
for (level = 0; level < numlevel; level++) {
if (!TIFFSetDirectory(image, level))
break;
if (level > 0) {
width= (width > 1)? width/2: 1;
height= (height > 1)? height/2: 1;
width = (width > 1) ? width / 2 : 1;
height = (height > 1) ? height / 2 : 1;
hbuf= IMB_allocImBuf(width, height, 32, 0);
hbuf->miplevel= level;
hbuf->ftype= ibuf->ftype;
ibuf->mipmap[level-1] = hbuf;
hbuf = IMB_allocImBuf(width, height, 32, 0);
hbuf->miplevel = level;
hbuf->ftype = ibuf->ftype;
ibuf->mipmap[level - 1] = hbuf;
if (flags & IB_premul)
hbuf->flags |= IB_premul;
}
else
hbuf= ibuf;
hbuf = ibuf;
hbuf->flags |= IB_tilecache;
TIFFGetField(image, TIFFTAG_TILEWIDTH, &hbuf->tilex);
TIFFGetField(image, TIFFTAG_TILELENGTH, &hbuf->tiley);
hbuf->xtiles= ceil(hbuf->x/(float)hbuf->tilex);
hbuf->ytiles= ceil(hbuf->y/(float)hbuf->tiley);
hbuf->xtiles = ceil(hbuf->x / (float)hbuf->tilex);
hbuf->ytiles = ceil(hbuf->y / (float)hbuf->tiley);
imb_addtilesImBuf(hbuf);
@@ -637,9 +637,9 @@ void imb_loadtiletiff(ImBuf *ibuf, unsigned char *mem, size_t size, int tx, int
if (width == ibuf->x && height == ibuf->y) {
if (rect) {
/* tiff pixels are bottom to top, tiles are top to bottom */
if (TIFFReadRGBATile(image, tx*ibuf->tilex, (ibuf->ytiles - 1 - ty)*ibuf->tiley, rect) == 1) {
if (TIFFReadRGBATile(image, tx * ibuf->tilex, (ibuf->ytiles - 1 - ty) * ibuf->tiley, rect) == 1) {
if (ibuf->tiley > ibuf->y)
memmove(rect, rect+ibuf->tilex*(ibuf->tiley - ibuf->y), sizeof(int)*ibuf->tilex*ibuf->y);
memmove(rect, rect + ibuf->tilex * (ibuf->tiley - ibuf->y), sizeof(int) * ibuf->tilex * ibuf->y);
if (ibuf->flags & IB_premul)
IMB_premultiply_rect(rect, 32, ibuf->tilex, ibuf->tiley);
@@ -694,8 +694,8 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags)
samplesperpixel = (uint16)((ibuf->planes + 7) >> 3);
if ((samplesperpixel > 4) || (samplesperpixel == 2)) {
fprintf(stderr,
"imb_savetiff: unsupported number of bytes per "
"pixel: %d\n", samplesperpixel);
"imb_savetiff: unsupported number of bytes per "
"pixel: %d\n", samplesperpixel);
return (0);
}
@@ -708,8 +708,8 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags)
if (flags & IB_mem) {
/* bork at the creation of a TIFF in memory */
fprintf(stderr,
"imb_savetiff: creation of in-memory TIFF files is "
"not yet supported.\n");
"imb_savetiff: creation of in-memory TIFF files is "
"not yet supported.\n");
return (0);
}
else {
@@ -718,22 +718,22 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags)
}
if (image == NULL) {
fprintf(stderr,
"imb_savetiff: could not open TIFF for writing.\n");
"imb_savetiff: could not open TIFF for writing.\n");
return (0);
}
/* allocate array for pixel data */
npixels = ibuf->x * ibuf->y;
if (bitspersample == 16)
pixels16 = (unsigned short*)_TIFFmalloc(npixels *
samplesperpixel * sizeof(unsigned short));
pixels16 = (unsigned short *)_TIFFmalloc(npixels *
samplesperpixel * sizeof(unsigned short));
else
pixels = (unsigned char*)_TIFFmalloc(npixels *
samplesperpixel * sizeof(unsigned char));
pixels = (unsigned char *)_TIFFmalloc(npixels *
samplesperpixel * sizeof(unsigned char));
if (pixels == NULL && pixels16 == NULL) {
fprintf(stderr,
"imb_savetiff: could not allocate pixels array.\n");
"imb_savetiff: could not allocate pixels array.\n");
TIFFClose(image);
return (0);
}
@@ -744,7 +744,7 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags)
to16 = pixels16;
}
else {
from = (unsigned char*)ibuf->rect;
from = (unsigned char *)ibuf->rect;
to = pixels;
}
@@ -755,26 +755,26 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags)
if (samplesperpixel == 4) {
/* RGBA images */
TIFFSetField(image, TIFFTAG_EXTRASAMPLES, 1,
extraSampleTypes);
extraSampleTypes);
TIFFSetField(image, TIFFTAG_PHOTOMETRIC,
PHOTOMETRIC_RGB);
PHOTOMETRIC_RGB);
}
else if (samplesperpixel == 3) {
/* RGB images */
TIFFSetField(image, TIFFTAG_PHOTOMETRIC,
PHOTOMETRIC_RGB);
PHOTOMETRIC_RGB);
}
else if (samplesperpixel == 1) {
/* greyscale images, 1 channel */
TIFFSetField(image, TIFFTAG_PHOTOMETRIC,
PHOTOMETRIC_MINISBLACK);
PHOTOMETRIC_MINISBLACK);
}
/* copy pixel data. While copying, we flip the image vertically. */
for (x = 0; x < ibuf->x; x++) {
for (y = 0; y < ibuf->y; y++) {
from_i = 4*(y*ibuf->x+x);
to_i = samplesperpixel*((ibuf->y-y-1)*ibuf->x+x);
from_i = 4 * (y * ibuf->x + x);
to_i = samplesperpixel * ((ibuf->y - y - 1) * ibuf->x + x);
if (pixels16) {
/* convert from float source */
@@ -785,7 +785,7 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags)
else
copy_v3_v3(rgb, &fromf[from_i]);
rgb[3] = fromf[from_i+3];
rgb[3] = fromf[from_i + 3];
for (i = 0; i < samplesperpixel; i++, to_i++)
to16[to_i] = FTOUSHORT(rgb[i]);
@@ -807,21 +807,21 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags)
if (ibuf->ppm[0] > 0.0 && ibuf->ppm[1] > 0.0) {
xres= (float)(ibuf->ppm[0] * 0.0254);
yres= (float)(ibuf->ppm[1] * 0.0254);
xres = (float)(ibuf->ppm[0] * 0.0254);
yres = (float)(ibuf->ppm[1] * 0.0254);
}
else {
xres= yres= 150.0f;
xres = yres = 150.0f;
}
TIFFSetField(image, TIFFTAG_XRESOLUTION, xres);
TIFFSetField(image, TIFFTAG_YRESOLUTION, yres);
TIFFSetField(image, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);
if (TIFFWriteEncodedStrip(image, 0,
(bitspersample == 16)? (unsigned char*)pixels16: pixels,
ibuf->x*ibuf->y*samplesperpixel*bitspersample/8) == -1) {
(bitspersample == 16) ? (unsigned char *)pixels16 : pixels,
ibuf->x * ibuf->y * samplesperpixel * bitspersample / 8) == -1) {
fprintf(stderr,
"imb_savetiff: Could not write encoded TIFF.\n");
"imb_savetiff: Could not write encoded TIFF.\n");
TIFFClose(image);
if (pixels) _TIFFfree(pixels);
if (pixels16) _TIFFfree(pixels16);

View File

@@ -84,7 +84,7 @@ typedef struct MovieClip {
struct MovieClipProxy proxy; /* proxy to clip data */
int flag;
int len; /* lenght of movie */
int len; /* length of movie */
} MovieClip;
typedef struct MovieClipScopes {

View File

@@ -213,7 +213,7 @@ void dna_write(FILE *file, void *pntr, int size);
/**
* Report all structures found so far, and print their lengths.
*/
void printStructLenghts(void);
void printStructLengths(void);
@@ -902,7 +902,7 @@ void dna_write(FILE *file, void *pntr, int size)
}
}
void printStructLenghts(void)
void printStructLengths(void)
{
int a, unknown = nr_structs, structtype;
/*int lastunknown;*/ /*UNUSED*/

View File

@@ -833,7 +833,7 @@ static PointerRNA rna_NodeOutputFile_slot_file_get(CollectionPropertyIterator *i
{
PointerRNA ptr;
bNodeSocket *sock = rna_iterator_listbase_get(iter);
RNA_pointer_create(iter->ptr.id.data, &RNA_NodeOutputFileSlotFile, sock->storage, &ptr);
RNA_pointer_create(iter->parent.id.data, &RNA_NodeOutputFileSlotFile, sock->storage, &ptr);
return ptr;
}
@@ -841,7 +841,7 @@ static PointerRNA rna_NodeOutputFile_slot_layer_get(CollectionPropertyIterator *
{
PointerRNA ptr;
bNodeSocket *sock = rna_iterator_listbase_get(iter);
RNA_pointer_create(iter->ptr.id.data, &RNA_NodeOutputFileSlotLayer, sock->storage, &ptr);
RNA_pointer_create(iter->parent.id.data, &RNA_NodeOutputFileSlotLayer, sock->storage, &ptr);
return ptr;
}

View File

@@ -72,16 +72,16 @@ static void foreach_nodetree(Main *main, void *calldata, bNodeTreeCallback func)
static void foreach_nodeclass(Scene *UNUSED(scene), void *calldata, bNodeClassCallback func)
{
func(calldata, NODE_CLASS_INPUT, IFACE_("Input"));
func(calldata, NODE_CLASS_OUTPUT, IFACE_("Output"));
func(calldata, NODE_CLASS_OP_COLOR, IFACE_("Color"));
func(calldata, NODE_CLASS_OP_VECTOR, IFACE_("Vector"));
func(calldata, NODE_CLASS_OP_FILTER, IFACE_("Filter"));
func(calldata, NODE_CLASS_CONVERTOR, IFACE_("Convertor"));
func(calldata, NODE_CLASS_MATTE, IFACE_("Matte"));
func(calldata, NODE_CLASS_DISTORT, IFACE_("Distort"));
func(calldata, NODE_CLASS_GROUP, IFACE_("Group"));
func(calldata, NODE_CLASS_LAYOUT, IFACE_("Layout"));
func(calldata, NODE_CLASS_INPUT, N_("Input"));
func(calldata, NODE_CLASS_OUTPUT, N_("Output"));
func(calldata, NODE_CLASS_OP_COLOR, N_("Color"));
func(calldata, NODE_CLASS_OP_VECTOR, N_("Vector"));
func(calldata, NODE_CLASS_OP_FILTER, N_("Filter"));
func(calldata, NODE_CLASS_CONVERTOR, N_("Convertor"));
func(calldata, NODE_CLASS_MATTE, N_("Matte"));
func(calldata, NODE_CLASS_DISTORT, N_("Distort"));
func(calldata, NODE_CLASS_GROUP, N_("Group"));
func(calldata, NODE_CLASS_LAYOUT, N_("Layout"));
}
static void free_node_cache(bNodeTree *UNUSED(ntree), bNode *node)

View File

@@ -105,7 +105,7 @@ static void do_displace(bNode *node, CompBuf *stackbuf, CompBuf *cbuf, CompBuf *
qd_getPixel(vecbuf, x-vecbuf->xof+1, y-vecbuf->yof, vecdx);
qd_getPixel(vecbuf, x-vecbuf->xof, y-vecbuf->yof+1, vecdy);
d_dx = vecdx[0] * xs;
d_dy = vecdy[0] * ys;
d_dy = vecdy[1] * ys;
/* clamp derivatives to minimum displacement distance in UV space */
dxt = p_dx - d_dx;

View File

@@ -80,19 +80,19 @@ static void foreach_nodetree(Main *main, void *calldata, bNodeTreeCallback func)
static void foreach_nodeclass(Scene *scene, void *calldata, bNodeClassCallback func)
{
func(calldata, NODE_CLASS_INPUT, IFACE_("Input"));
func(calldata, NODE_CLASS_OUTPUT, IFACE_("Output"));
func(calldata, NODE_CLASS_INPUT, N_("Input"));
func(calldata, NODE_CLASS_OUTPUT, N_("Output"));
if (BKE_scene_use_new_shading_nodes(scene)) {
func(calldata, NODE_CLASS_SHADER, IFACE_("Shader"));
func(calldata, NODE_CLASS_TEXTURE, IFACE_("Texture"));
func(calldata, NODE_CLASS_SHADER, N_("Shader"));
func(calldata, NODE_CLASS_TEXTURE, N_("Texture"));
}
func(calldata, NODE_CLASS_OP_COLOR, IFACE_("Color"));
func(calldata, NODE_CLASS_OP_VECTOR, IFACE_("Vector"));
func(calldata, NODE_CLASS_CONVERTOR, IFACE_("Convertor"));
func(calldata, NODE_CLASS_GROUP, IFACE_("Group"));
func(calldata, NODE_CLASS_LAYOUT, IFACE_("Layout"));
func(calldata, NODE_CLASS_OP_COLOR, N_("Color"));
func(calldata, NODE_CLASS_OP_VECTOR, N_("Vector"));
func(calldata, NODE_CLASS_CONVERTOR, N_("Convertor"));
func(calldata, NODE_CLASS_GROUP, N_("Group"));
func(calldata, NODE_CLASS_LAYOUT, N_("Layout"));
}
static void localize(bNodeTree *localtree, bNodeTree *UNUSED(ntree))

View File

@@ -66,15 +66,15 @@ static void foreach_nodetree(Main *main, void *calldata, bNodeTreeCallback func)
static void foreach_nodeclass(Scene *UNUSED(scene), void *calldata, bNodeClassCallback func)
{
func(calldata, NODE_CLASS_INPUT, IFACE_("Input"));
func(calldata, NODE_CLASS_OUTPUT, IFACE_("Output"));
func(calldata, NODE_CLASS_OP_COLOR, IFACE_("Color"));
func(calldata, NODE_CLASS_PATTERN, IFACE_("Patterns"));
func(calldata, NODE_CLASS_TEXTURE, IFACE_("Textures"));
func(calldata, NODE_CLASS_CONVERTOR, IFACE_("Convertor"));
func(calldata, NODE_CLASS_DISTORT, IFACE_("Distort"));
func(calldata, NODE_CLASS_GROUP, IFACE_("Group"));
func(calldata, NODE_CLASS_LAYOUT, IFACE_("Layout"));
func(calldata, NODE_CLASS_INPUT, N_("Input"));
func(calldata, NODE_CLASS_OUTPUT, N_("Output"));
func(calldata, NODE_CLASS_OP_COLOR, N_("Color"));
func(calldata, NODE_CLASS_PATTERN, N_("Patterns"));
func(calldata, NODE_CLASS_TEXTURE, N_("Textures"));
func(calldata, NODE_CLASS_CONVERTOR, N_("Convertor"));
func(calldata, NODE_CLASS_DISTORT, N_("Distort"));
func(calldata, NODE_CLASS_GROUP, N_("Group"));
func(calldata, NODE_CLASS_LAYOUT, N_("Layout"));
}
static void localize(bNodeTree *localtree, bNodeTree *UNUSED(ntree))

View File

@@ -52,7 +52,7 @@ class SCA_RandomNumberGenerator {
/* unsigned long mt[N]; */
unsigned long mt[624];
/** mti==N+1 means mt[KX_MT_VectorLenght] is not initialized */
/** mti==N+1 means mt[KX_MT_VectorLength] is not initialized */
int mti; /* initialized in the cpp file */
/** Calculate a start vector */