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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2012-11-26 06:32:34 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2012-11-26 06:32:34 +0400
commit53840c7db5114da8b35fb12c1cfa49427802b0d7 (patch)
treee1676e61881c903baff02bd69290ef0393a13465 /source/blender/blenkernel
parentb7cd9ec3ada529bf1d57cf08cc96851ceb67a47d (diff)
parent97b8a1f752fbe729c20c8398dfa9fdbc2e2e4ff3 (diff)
Merged changes in the trunk up to revision 52546.
Conflicts resolved: release/datafiles/startup.blend release/scripts/startup/bl_ui/space_view3d.py source/blender/blenkernel/intern/idcode.c
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_text.h12
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c2
-rw-r--r--source/blender/blenkernel/intern/action.c4
-rw-r--r--source/blender/blenkernel/intern/armature.c9
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c13
-rw-r--r--source/blender/blenkernel/intern/collision.c10
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c6
-rw-r--r--source/blender/blenkernel/intern/idcode.c67
-rw-r--r--source/blender/blenkernel/intern/image.c15
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c3
-rw-r--r--source/blender/blenkernel/intern/sequencer.c11
-rw-r--r--source/blender/blenkernel/intern/text.c321
-rw-r--r--source/blender/blenkernel/intern/writeffmpeg.c35
13 files changed, 125 insertions, 383 deletions
diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h
index aaf88e4924d..accac8694a9 100644
--- a/source/blender/blenkernel/BKE_text.h
+++ b/source/blender/blenkernel/BKE_text.h
@@ -100,14 +100,6 @@ void txt_move_lines (struct Text *text, const int direction);
void txt_duplicate_line (struct Text *text);
int setcurr_tab_spaces (struct Text *text, int space);
-void txt_add_marker (struct Text *text, struct TextLine *line, int start, int end, const unsigned char color[4], int group, int flags);
-short txt_clear_marker_region (struct Text *text, struct TextLine *line, int start, int end, int group, int flags);
-short txt_clear_markers (struct Text *text, int group, int flags);
-struct TextMarker *txt_find_marker (struct Text *text, struct TextLine *line, int curs, int group, int flags);
-struct TextMarker *txt_find_marker_region (struct Text *text, struct TextLine *line, int start, int end, int group, int flags);
-struct TextMarker *txt_prev_marker (struct Text *text, struct TextMarker *marker);
-struct TextMarker *txt_next_marker (struct Text *text, struct TextMarker *marker);
-
/* utility functions, could be moved somewhere more generic but are python/text related */
int text_check_bracket(const char ch);
int text_check_delim(const char ch);
@@ -161,10 +153,6 @@ enum {
#define UNDO_DUPLICATE 040
-/* Marker flags */
-#define TMARK_TEMP 0x01 /* Remove on non-editing events, don't save */
-#define TMARK_EDITALL 0x02 /* Edit all markers of the same group as one */
-
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index cca425a63d8..3736395313d 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -2167,6 +2167,8 @@ static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask,
/* weight paint and face select need original indices because of selection buffer drawing */
int needMapping = (ob == obact) && (editing || (ob->mode & (OB_MODE_WEIGHT_PAINT | OB_MODE_VERTEX_PAINT | OB_MODE_TEXTURE_PAINT)));
+ BLI_assert(ob->type == OB_MESH);
+
clear_mesh_caches(ob);
mesh_calc_modifiers(scene, ob, NULL, &ob->derivedDeform,
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index e95451252d0..dd27cc70ba3 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -512,7 +512,7 @@ const char *BKE_pose_ikparam_get_name(bPose *pose)
{
if (pose) {
switch (pose->iksolver) {
- case IKSOLVER_LEGACY:
+ case IKSOLVER_STANDARD:
return NULL;
case IKSOLVER_ITASC:
return "bItasc";
@@ -587,7 +587,7 @@ void BKE_pose_ikparam_init(bPose *pose)
BKE_pose_itasc_init(itasc);
pose->ikparam = itasc;
break;
- case IKSOLVER_LEGACY:
+ case IKSOLVER_STANDARD:
default:
pose->ikparam = NULL;
break;
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index b3cbc1f2b16..1970df54339 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -1822,8 +1822,15 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos
*/
/* only happens on reload file, but violates depsgraph still... fix! */
- if ((cu->path == NULL) || (cu->path->data == NULL))
+ if (ELEM(NULL, cu->path, cu->path->data)) {
BKE_displist_make_curveTypes(scene, ikData->tar, 0);
+
+ /* path building may fail in EditMode after removing verts [#33268]*/
+ if (ELEM(NULL, cu->path, cu->path->data)) {
+ /* BLI_assert(cu->path != NULL); */
+ return;
+ }
+ }
}
/* find the root bone and the chain of bones from the root to the tip
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 3ade51d13eb..9b1720787ed 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -2516,7 +2516,7 @@ void CDDM_calc_edges(DerivedMesh *dm)
EdgeHashIterator *ehi;
MPoly *mp = cddm->mpoly;
MLoop *ml;
- MEdge *med;
+ MEdge *med, *origmed;
EdgeHash *eh = BLI_edgehash_new();
int v1, v2;
int *eindex;
@@ -2549,6 +2549,7 @@ void CDDM_calc_edges(DerivedMesh *dm)
CustomData_add_layer(&edgeData, CD_MEDGE, CD_CALLOC, NULL, numEdges);
CustomData_add_layer(&edgeData, CD_ORIGINDEX, CD_CALLOC, NULL, numEdges);
+ origmed = cddm->medge;
med = CustomData_get_layer(&edgeData, CD_MEDGE);
index = CustomData_get_layer(&edgeData, CD_ORIGINDEX);
@@ -2559,8 +2560,14 @@ void CDDM_calc_edges(DerivedMesh *dm)
BLI_edgehashIterator_getKey(ehi, &med->v1, &med->v2);
j = GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi));
- med->flag = ME_EDGEDRAW | ME_EDGERENDER;
- *index = j == 0 ? ORIGINDEX_NONE : eindex[j - 1];
+ if (j == 0) {
+ med->flag = ME_EDGEDRAW | ME_EDGERENDER;
+ *index = ORIGINDEX_NONE;
+ }
+ else {
+ med->flag = ME_EDGEDRAW | ME_EDGERENDER | origmed[j - 1].flag;
+ *index = eindex[j - 1];
+ }
BLI_edgehashIterator_setValue(ehi, SET_INT_IN_POINTER(i));
}
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index b488e683947..4641a02265a 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -198,8 +198,10 @@ static void collision_compute_barycentric ( float pv[3], float p1[3], float p2[3
w3[0] = 1.0f - w1[0] - w2[0];
}
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdouble-promotion"
+#ifdef __GNUC__
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wdouble-promotion"
+#endif
DO_INLINE void collision_interpolateOnTriangle ( float to[3], float v1[3], float v2[3], float v3[3], double w1, double w2, double w3 )
{
@@ -371,7 +373,9 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM
return result;
}
-#pragma GCC diagnostic pop
+#ifdef __GNUC__
+# pragma GCC diagnostic pop
+#endif
//Determines collisions on overlap, collisions are written to collpair[i] and collision+number_collision_found is returned
static CollPair* cloth_collision(ModifierData *md1, ModifierData *md2,
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index 89d728c0419..bb3836e3c08 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -86,11 +86,13 @@
#include "RE_shader_ext.h"
#ifdef _OPENMP
-#include <omp.h>
+# include <omp.h>
#endif
/* could enable at some point but for now there are far too many conversions */
-#pragma GCC diagnostic ignored "-Wdouble-promotion"
+#ifdef __GNUC__
+# pragma GCC diagnostic ignored "-Wdouble-promotion"
+#endif
/* precalculated gaussian factors for 5x super sampling */
static float gaussianFactors[5] = {0.996849f,
diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c
index 828f752eaa5..75c22d06042 100644
--- a/source/blender/blenkernel/intern/idcode.c
+++ b/source/blender/blenkernel/intern/idcode.c
@@ -47,40 +47,41 @@ typedef struct {
} IDType;
/* plural need to match rna_main.c's MainCollectionDef */
+/* WARNING! Keep it in sync with i18n contexts in BLF_translation.h */
static IDType idtypes[] = {
- { ID_AC, "Action", "actions", IDTYPE_FLAGS_ISLINKABLE},
- { ID_AR, "Armature", "armatures", IDTYPE_FLAGS_ISLINKABLE},
- { ID_BR, "Brush", "brushes", IDTYPE_FLAGS_ISLINKABLE},
- { ID_CA, "Camera", "cameras", IDTYPE_FLAGS_ISLINKABLE},
- { ID_CU, "Curve", "curves", IDTYPE_FLAGS_ISLINKABLE},
- { ID_GD, "GPencil", "grease_pencil", IDTYPE_FLAGS_ISLINKABLE}, /* rename gpencil */
- { ID_GR, "Group", "groups", IDTYPE_FLAGS_ISLINKABLE},
- { ID_ID, "ID", "ids", 0}, /* plural is fake */
- { ID_IM, "Image", "images", IDTYPE_FLAGS_ISLINKABLE},
- { ID_IP, "Ipo", "ipos", IDTYPE_FLAGS_ISLINKABLE}, /* deprecated */
- { ID_KE, "Key", "shape_keys", 0},
- { ID_LA, "Lamp", "lamps", IDTYPE_FLAGS_ISLINKABLE},
- { ID_LI, "Library", "libraries", 0},
- { ID_LS, "FreestyleLineStyle", "linestyles", IDTYPE_FLAGS_ISLINKABLE},
- { ID_LT, "Lattice", "lattices", IDTYPE_FLAGS_ISLINKABLE},
- { ID_MA, "Material", "materials", IDTYPE_FLAGS_ISLINKABLE},
- { ID_MB, "Metaball", "metaballs", IDTYPE_FLAGS_ISLINKABLE},
- { ID_ME, "Mesh", "meshes", IDTYPE_FLAGS_ISLINKABLE},
- { ID_NT, "NodeTree", "node_groups", IDTYPE_FLAGS_ISLINKABLE},
- { ID_OB, "Object", "objects", IDTYPE_FLAGS_ISLINKABLE},
- { ID_PA, "ParticleSettings", "particles", 0},
- { ID_SCE, "Scene", "scenes", IDTYPE_FLAGS_ISLINKABLE},
- { ID_SCR, "Screen", "screens", 0},
- { ID_SEQ, "Sequence", "sequences", 0}, /* not actually ID data */
- { ID_SPK, "Speaker", "speakers", IDTYPE_FLAGS_ISLINKABLE},
- { ID_SO, "Sound", "sounds", IDTYPE_FLAGS_ISLINKABLE},
- { ID_TE, "Texture", "textures", IDTYPE_FLAGS_ISLINKABLE},
- { ID_TXT, "Text", "texts", IDTYPE_FLAGS_ISLINKABLE},
- { ID_VF, "VFont", "fonts", IDTYPE_FLAGS_ISLINKABLE},
- { ID_WO, "World", "worlds", IDTYPE_FLAGS_ISLINKABLE},
- { ID_WM, "WindowManager", "window_managers", 0},
- { ID_MC, "MovieClip", "movieclips", IDTYPE_FLAGS_ISLINKABLE},
- { ID_MSK, "Mask", "masks", IDTYPE_FLAGS_ISLINKABLE},
+ { ID_AC, "Action", "actions", IDTYPE_FLAGS_ISLINKABLE },
+ { ID_AR, "Armature", "armatures", IDTYPE_FLAGS_ISLINKABLE },
+ { ID_BR, "Brush", "brushes", IDTYPE_FLAGS_ISLINKABLE },
+ { ID_CA, "Camera", "cameras", IDTYPE_FLAGS_ISLINKABLE },
+ { ID_CU, "Curve", "curves", IDTYPE_FLAGS_ISLINKABLE },
+ { ID_GD, "GPencil", "grease_pencil", IDTYPE_FLAGS_ISLINKABLE }, /* rename gpencil */
+ { ID_GR, "Group", "groups", IDTYPE_FLAGS_ISLINKABLE },
+ { ID_ID, "ID", "ids", 0 }, /* plural is fake */
+ { ID_IM, "Image", "images", IDTYPE_FLAGS_ISLINKABLE },
+ { ID_IP, "Ipo", "ipos", IDTYPE_FLAGS_ISLINKABLE }, /* deprecated */
+ { ID_KE, "Key", "shape_keys", 0 },
+ { ID_LA, "Lamp", "lamps", IDTYPE_FLAGS_ISLINKABLE },
+ { ID_LI, "Library", "libraries", 0 },
+ { ID_LS, "FreestyleLineStyle", "linestyles", IDTYPE_FLAGS_ISLINKABLE },
+ { ID_LT, "Lattice", "lattices", IDTYPE_FLAGS_ISLINKABLE },
+ { ID_MA, "Material", "materials", IDTYPE_FLAGS_ISLINKABLE },
+ { ID_MB, "Metaball", "metaballs", IDTYPE_FLAGS_ISLINKABLE },
+ { ID_MC, "MovieClip", "movieclips", IDTYPE_FLAGS_ISLINKABLE },
+ { ID_ME, "Mesh", "meshes", IDTYPE_FLAGS_ISLINKABLE },
+ { ID_MSK, "Mask", "masks", IDTYPE_FLAGS_ISLINKABLE },
+ { ID_NT, "NodeTree", "node_groups", IDTYPE_FLAGS_ISLINKABLE },
+ { ID_OB, "Object", "objects", IDTYPE_FLAGS_ISLINKABLE },
+ { ID_PA, "ParticleSettings", "particles", 0 },
+ { ID_SCE, "Scene", "scenes", IDTYPE_FLAGS_ISLINKABLE },
+ { ID_SCR, "Screen", "screens", 0 },
+ { ID_SEQ, "Sequence", "sequences", 0 }, /* not actually ID data */
+ { ID_SPK, "Speaker", "speakers", IDTYPE_FLAGS_ISLINKABLE },
+ { ID_SO, "Sound", "sounds", IDTYPE_FLAGS_ISLINKABLE },
+ { ID_TE, "Texture", "textures", IDTYPE_FLAGS_ISLINKABLE },
+ { ID_TXT, "Text", "texts", IDTYPE_FLAGS_ISLINKABLE },
+ { ID_VF, "VFont", "fonts", IDTYPE_FLAGS_ISLINKABLE },
+ { ID_WO, "World", "worlds", IDTYPE_FLAGS_ISLINKABLE },
+ { ID_WM, "WindowManager", "window_managers", 0 },
};
static int nidtypes = sizeof(idtypes) / sizeof(idtypes[0]);
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index d98c2bc2f8b..e4b9edacc7e 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -2920,7 +2920,20 @@ void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
/* checks whether there's an image buffer for given image and user */
int BKE_image_has_ibuf(Image *ima, ImageUser *iuser)
{
- ImBuf *ibuf = image_get_ibuf_threadsafe(ima, iuser, NULL, NULL);
+ ImBuf *ibuf;
+
+ /* quick reject tests */
+ if (ima == NULL)
+ return FALSE;
+
+ if (iuser) {
+ if (iuser->ok == 0)
+ return FALSE;
+ }
+ else if (ima->ok == 0)
+ return FALSE;
+
+ ibuf = image_get_ibuf_threadsafe(ima, iuser, NULL, NULL);
if (!ibuf) {
BLI_spin_lock(&image_spin);
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index 469881020c1..0b7fdaa7c1d 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -139,6 +139,9 @@ static ImBuf *prepare_effect_imbufs(SeqRenderData context, ImBuf *ibuf1, ImBuf *
IMB_rect_from_float(ibuf3);
}
+ if (out->rect_float)
+ IMB_colormanagement_assign_float_colorspace(out, context.scene->sequencer_colorspace_settings.name);
+
return out;
}
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index 547ca96e10a..e023a3e20ae 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -2338,11 +2338,13 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float
*/
const short is_rendering = G.is_rendering;
+ const short is_background = G.background;
const int do_seq_gl = G.is_rendering ?
0 /* (context.scene->r.seq_flag & R_SEQ_GL_REND) */ :
(context.scene->r.seq_flag & R_SEQ_GL_PREV);
int do_seq;
int have_seq = FALSE;
+ int have_comp = FALSE;
Scene *scene;
int is_thread_main = BLI_thread_is_main();
@@ -2355,6 +2357,7 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float
frame = scene->r.sfra + nr + seq->anim_startofs;
have_seq = (scene->r.scemode & R_DOSEQ) && scene->ed && scene->ed->seqbase.first;
+ have_comp = (scene->r.scemode & R_DOCOMP) && scene->use_nodes && scene->nodetree;
oldcfra = scene->r.cfra;
scene->r.cfra = frame;
@@ -2367,7 +2370,7 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float
camera = scene->camera;
}
- if (have_seq == FALSE && camera == NULL) {
+ if (have_comp == FALSE && camera == NULL) {
scene->r.cfra = oldcfra;
return NULL;
}
@@ -2407,11 +2410,15 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float
*
* disable rendered preview for sequencer while rendering -- it's very much possible
* that preview render will went into conflict with final render
+ *
+ * When rendering from command line renderer is called from main thread, in this
+ * case it's always safe to render scene here
*/
- if (!is_thread_main || is_rendering == FALSE) {
+ if (!is_thread_main || is_rendering == FALSE || is_background) {
if (re == NULL)
re = RE_NewRender(scene->id.name);
+ BKE_scene_update_for_newframe(context.bmain, scene, scene->lay);
RE_BlenderFrame(re, context.bmain, scene, NULL, camera, scene->lay, frame, FALSE);
/* restore previous state after it was toggled on & off by RE_BlenderFrame */
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index d166592424d..e6339d07e66 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -96,17 +96,6 @@
* If the user moves the cursor the st containing that cursor should
* be popped ... other st's retain their own top location.
*
- * Markers
- * --
- * The mrk->flags define the behavior and relationships between markers. The
- * upper two bytes are used to hold a group ID, the lower two are normal flags. If
- * TMARK_EDITALL is set the group ID defines which other markers should be edited.
- *
- * The mrk->clr field is used to visually group markers where the flags may not
- * match. A template system, for example, may allow editing of repeating tokens
- * (in one group) but include other marked positions (in another group) all in the
- * same template with the same color.
- *
* Undo
* --
* Undo/Redo works by storing
@@ -174,7 +163,6 @@ void BKE_text_free(Text *text)
}
BLI_freelistN(&text->lines);
- BLI_freelistN(&text->markers);
if (text->name) MEM_freeN(text->name);
MEM_freeN(text->undo_buf);
@@ -202,7 +190,6 @@ Text *BKE_text_add(const char *name)
ta->flags |= TXT_TABSTOSPACES;
ta->lines.first = ta->lines.last = NULL;
- ta->markers.first = ta->markers.last = NULL;
tmp = (TextLine *) MEM_mallocN(sizeof(TextLine), "textline");
tmp->line = (char *) MEM_mallocN(1, "textline_string");
@@ -398,7 +385,6 @@ Text *BKE_text_load(const char *file, const char *relpath)
ta->id.us = 1;
ta->lines.first = ta->lines.last = NULL;
- ta->markers.first = ta->markers.last = NULL;
ta->curl = ta->sell = NULL;
if ((U.flag & USER_TXT_TABSTOSPACES_DISABLE) == 0)
@@ -495,7 +481,6 @@ Text *BKE_text_copy(Text *ta)
tan->flags = ta->flags | TXT_ISDIRTY;
tan->lines.first = tan->lines.last = NULL;
- tan->markers.first = tan->markers.last = NULL;
tan->curl = tan->sell = NULL;
tan->nlines = ta->nlines;
@@ -1150,9 +1135,7 @@ int txt_has_sel(Text *text)
static void txt_delete_sel(Text *text)
{
TextLine *tmpl;
- TextMarker *mrk;
char *buf;
- int move, lineno;
if (!text) return;
if (!text->curl) return;
@@ -1169,28 +1152,6 @@ static void txt_delete_sel(Text *text)
}
buf = MEM_mallocN(text->curc + (text->sell->len - text->selc) + 1, "textline_string");
-
- if (text->curl != text->sell) {
- txt_clear_marker_region(text, text->curl, text->curc, text->curl->len, 0, 0);
- move = txt_get_span(text->curl, text->sell);
- }
- else {
- mrk = txt_find_marker_region(text, text->curl, text->curc, text->selc, 0, 0);
- if (mrk && (mrk->start > text->curc || mrk->end < text->selc))
- txt_clear_marker_region(text, text->curl, text->curc, text->selc, 0, 0);
- move = 0;
- }
-
- mrk = txt_find_marker_region(text, text->sell, text->selc - 1, text->sell->len, 0, 0);
- if (mrk) {
- lineno = mrk->lineno;
- do {
- mrk->lineno -= move;
- if (mrk->start > text->curc) mrk->start -= text->selc - text->curc;
- mrk->end -= text->selc - text->curc;
- mrk = mrk->next;
- } while (mrk && mrk->lineno == lineno);
- }
strncpy(buf, text->curl->line, text->curc);
strcpy(buf + text->curc, text->sell->line + text->selc);
@@ -1419,19 +1380,9 @@ char *txt_sel_to_buf(Text *text)
return buf;
}
-static void txt_shift_markers(Text *text, int lineno, int count)
-{
- TextMarker *marker;
-
- for (marker = text->markers.first; marker; marker = marker->next)
- if (marker->lineno >= lineno) {
- marker->lineno += count;
- }
-}
-
void txt_insert_buf(Text *text, const char *in_buffer)
{
- int l = 0, u, len, lineno = -1, count = 0;
+ int l = 0, u, len;
size_t i = 0, j;
TextLine *add;
char *buffer;
@@ -1458,9 +1409,6 @@ void txt_insert_buf(Text *text, const char *in_buffer)
else { undoing = u; MEM_freeN(buffer); return; }
i++;
- /* Read as many full lines as we can */
- lineno = txt_get_span(text->lines.first, text->curl);
-
while (i < len) {
l = 0;
@@ -1472,14 +1420,8 @@ void txt_insert_buf(Text *text, const char *in_buffer)
add = txt_new_linen(buffer + (i - l), l);
BLI_insertlinkbefore(&text->lines, text->curl, add);
i++;
- count++;
}
else {
- if (count) {
- txt_shift_markers(text, lineno, count);
- count = 0;
- }
-
for (j = i - l; j < i && j < len; )
txt_add_raw_char(text, BLI_str_utf8_as_unicode_step(buffer, &j));
break;
@@ -1488,10 +1430,6 @@ void txt_insert_buf(Text *text, const char *in_buffer)
MEM_freeN(buffer);
- if (count) {
- txt_shift_markers(text, lineno, count);
- }
-
undoing = u;
}
@@ -2324,31 +2262,13 @@ void txt_do_redo(Text *text)
void txt_split_curline(Text *text)
{
TextLine *ins;
- TextMarker *mrk;
char *left, *right;
- int lineno = -1;
if (!text) return;
if (!text->curl) return;
txt_delete_sel(text);
- /* Move markers */
-
- lineno = txt_get_span(text->lines.first, text->curl);
- mrk = text->markers.first;
- while (mrk) {
- if (mrk->lineno == lineno && mrk->start > text->curc) {
- mrk->lineno++;
- mrk->start -= text->curc;
- mrk->end -= text->curc;
- }
- else if (mrk->lineno > lineno) {
- mrk->lineno++;
- }
- mrk = mrk->next;
- }
-
/* Make the two half strings */
left = MEM_mallocN(text->curc + 1, "textline_string");
@@ -2385,25 +2305,9 @@ void txt_split_curline(Text *text)
static void txt_delete_line(Text *text, TextLine *line)
{
- TextMarker *mrk = NULL, *nxt;
-
if (!text) return;
if (!text->curl) return;
- /* warning, this can be _slow_ when deleting many lines! */
- if ((mrk = text->markers.first)) {
- int lineno = txt_get_span(text->lines.first, line);
- mrk = text->markers.first;
- while (mrk) {
- nxt = mrk->next;
- if (mrk->lineno == lineno)
- BLI_freelinkN(&text->markers, mrk);
- else if (mrk->lineno > lineno)
- mrk->lineno--;
- mrk = nxt;
- }
- }
-
BLI_remlink(&text->lines, line);
if (line->line) MEM_freeN(line->line);
@@ -2418,27 +2322,11 @@ static void txt_delete_line(Text *text, TextLine *line)
static void txt_combine_lines(Text *text, TextLine *linea, TextLine *lineb)
{
char *tmp;
- TextMarker *mrk = NULL;
if (!text) return;
if (!linea || !lineb) return;
- mrk = txt_find_marker_region(text, lineb, 0, lineb->len, 0, 0);
- if (mrk) {
- int lineno;
- lineno = mrk->lineno;
- do {
- mrk->lineno--;
- mrk->start += linea->len;
- mrk->end += linea->len;
- mrk = mrk->next;
- } while (mrk && mrk->lineno == lineno);
- }
-#if 0 /* UNUSED */
- if (lineno == -1)
- lineno = txt_get_span(text->lines.first, lineb);
-#endif
tmp = MEM_mallocN(linea->len + lineb->len + 1, "textline_string");
@@ -2492,27 +2380,7 @@ void txt_delete_char(Text *text)
}
else { /* Just deleting a char */
size_t c_len = 0;
- TextMarker *mrk;
c = BLI_str_utf8_as_unicode_and_size(text->curl->line + text->curc, &c_len);
-
- mrk = txt_find_marker_region(text, text->curl, text->curc - c_len, text->curl->len, 0, 0);
- if (mrk) {
- int lineno = mrk->lineno;
- if (mrk->end == text->curc) {
- if ((mrk->flags & TMARK_TEMP) && !(mrk->flags & TMARK_EDITALL)) {
- txt_clear_markers(text, mrk->group, TMARK_TEMP);
- }
- else {
- BLI_freelinkN(&text->markers, mrk);
- }
- return;
- }
- do {
- if (mrk->start > text->curc) mrk->start -= c_len;
- mrk->end -= c_len;
- mrk = mrk->next;
- } while (mrk && mrk->lineno == lineno);
- }
memmove(text->curl->line + text->curc, text->curl->line + text->curc + c_len, text->curl->len - text->curc - c_len + 1);
@@ -2556,28 +2424,8 @@ void txt_backspace_char(Text *text)
}
else { /* Just backspacing a char */
size_t c_len = 0;
- TextMarker *mrk;
char *prev = BLI_str_prev_char_utf8(text->curl->line + text->curc);
c = BLI_str_utf8_as_unicode_and_size(prev, &c_len);
-
- mrk = txt_find_marker_region(text, text->curl, text->curc - c_len, text->curl->len, 0, 0);
- if (mrk) {
- int lineno = mrk->lineno;
- if (mrk->start == text->curc) {
- if ((mrk->flags & TMARK_TEMP) && !(mrk->flags & TMARK_EDITALL)) {
- txt_clear_markers(text, mrk->group, TMARK_TEMP);
- }
- else {
- BLI_freelinkN(&text->markers, mrk);
- }
- return;
- }
- do {
- if (mrk->start > text->curc - c_len) mrk->start -= c_len;
- mrk->end -= c_len;
- mrk = mrk->next;
- } while (mrk && mrk->lineno == lineno);
- }
/* source and destination overlap, don't use memcpy() */
memmove(text->curl->line + text->curc - c_len,
@@ -2619,9 +2467,7 @@ static void txt_convert_tab_to_spaces(Text *text)
static int txt_add_char_intern(Text *text, unsigned int add, int replace_tabs)
{
- int lineno;
char *tmp, ch[BLI_UTF8_MAX];
- TextMarker *mrk;
size_t add_len;
if (!text) return 0;
@@ -2643,15 +2489,6 @@ static int txt_add_char_intern(Text *text, unsigned int add, int replace_tabs)
if (!undoing) txt_undo_add_charop(text, UNDO_INSERT_1, add);
add_len = BLI_str_utf8_from_unicode(add, ch);
- mrk = txt_find_marker_region(text, text->curl, text->curc - 1, text->curl->len, 0, 0);
- if (mrk) {
- lineno = mrk->lineno;
- do {
- if (mrk->start > text->curc) mrk->start += add_len;
- mrk->end += add_len;
- mrk = mrk->next;
- } while (mrk && mrk->lineno == lineno);
- }
tmp = MEM_mallocN(text->curl->len + add_len + 1, "textline_string");
@@ -2698,10 +2535,7 @@ int txt_replace_char(Text *text, unsigned int add)
/* If text is selected or we're at the end of the line just use txt_add_char */
if (text->curc == text->curl->len || txt_has_sel(text) || add == '\n') {
- int i = txt_add_char(text, add);
- TextMarker *mrk = txt_find_marker(text, text->curl, text->curc, 0, 0);
- if (mrk) BLI_freelinkN(&text->markers, mrk);
- return i;
+ return txt_add_char(text, add);
}
del = BLI_str_utf8_as_unicode_and_size(text->curl->line + text->curc, &del_size);
@@ -3039,157 +2873,6 @@ int setcurr_tab_spaces(Text *text, int space)
return i;
}
-/*********************************/
-/* Text marker utility functions */
-/*********************************/
-
-/* Creates and adds a marker to the list maintaining sorted order */
-void txt_add_marker(Text *text, TextLine *line, int start, int end, const unsigned char color[4], int group, int flags)
-{
- TextMarker *tmp, *marker;
-
- marker = MEM_mallocN(sizeof(TextMarker), "text_marker");
-
- marker->lineno = txt_get_span(text->lines.first, line);
- marker->start = MIN2(start, end);
- marker->end = MAX2(start, end);
- marker->group = group;
- marker->flags = flags;
-
- marker->color[0] = color[0];
- marker->color[1] = color[1];
- marker->color[2] = color[2];
- marker->color[3] = color[3];
-
- for (tmp = text->markers.last; tmp; tmp = tmp->prev)
- if (tmp->lineno < marker->lineno || (tmp->lineno == marker->lineno && tmp->start < marker->start))
- break;
-
- if (tmp) BLI_insertlinkafter(&text->markers, tmp, marker);
- else BLI_addhead(&text->markers, marker);
-}
-
-/* Returns the first matching marker on the specified line between two points.
- * If the group or flags fields are non-zero the returned flag must be in the
- * specified group and have at least the specified flags set. */
-TextMarker *txt_find_marker_region(Text *text, TextLine *line, int start, int end, int group, int flags)
-{
- TextMarker *marker, *next;
- int lineno = txt_get_span(text->lines.first, line);
-
- for (marker = text->markers.first; marker; marker = next) {
- next = marker->next;
-
- if (group && marker->group != group) continue;
- else if ((marker->flags & flags) != flags) continue;
- else if (marker->lineno < lineno) continue;
- else if (marker->lineno > lineno) break;
-
- if ((marker->start == marker->end && start <= marker->start && marker->start <= end) ||
- (marker->start < end && marker->end > start))
- {
- return marker;
- }
- }
- return NULL;
-}
-
-/* Clears all markers on the specified line between two points. If the group or
- * flags fields are non-zero the returned flag must be in the specified group
- * and have at least the specified flags set. */
-short txt_clear_marker_region(Text *text, TextLine *line, int start, int end, int group, int flags)
-{
- TextMarker *marker, *next;
- int lineno = txt_get_span(text->lines.first, line);
- short cleared = 0;
-
- for (marker = text->markers.first; marker; marker = next) {
- next = marker->next;
-
- if (group && marker->group != group) continue;
- else if ((marker->flags & flags) != flags) continue;
- else if (marker->lineno < lineno) continue;
- else if (marker->lineno > lineno) break;
-
- if ((marker->start == marker->end && start <= marker->start && marker->start <= end) ||
- (marker->start < end && marker->end > start))
- {
- BLI_freelinkN(&text->markers, marker);
- cleared = 1;
- }
- }
- return cleared;
-}
-
-/* Clears all markers in the specified group (if given) with at least the
- * specified flags set. Useful for clearing temporary markers (group = 0,
- * flags = TMARK_TEMP) */
-short txt_clear_markers(Text *text, int group, int flags)
-{
- TextMarker *marker, *next;
- short cleared = 0;
-
- for (marker = text->markers.first; marker; marker = next) {
- next = marker->next;
-
- if ((!group || marker->group == group) &&
- (marker->flags & flags) == flags)
- {
- BLI_freelinkN(&text->markers, marker);
- cleared = 1;
- }
- }
- return cleared;
-}
-
-/* Finds the marker at the specified line and cursor position with at least the
- * specified flags set in the given group (if non-zero). */
-TextMarker *txt_find_marker(Text *text, TextLine *line, int curs, int group, int flags)
-{
- TextMarker *marker;
- int lineno = txt_get_span(text->lines.first, line);
-
- for (marker = text->markers.first; marker; marker = marker->next) {
- if (group && marker->group != group) continue;
- else if ((marker->flags & flags) != flags) continue;
- else if (marker->lineno < lineno) continue;
- else if (marker->lineno > lineno) break;
-
- if (marker->start <= curs && curs <= marker->end)
- return marker;
- }
- return NULL;
-}
-
-/* Finds the previous marker in the same group. If no other is found, the same
- * marker will be returned */
-TextMarker *txt_prev_marker(Text *text, TextMarker *marker)
-{
- TextMarker *tmp = marker;
- while (tmp) {
- if (tmp->prev) tmp = tmp->prev;
- else tmp = text->markers.last;
- if (tmp->group == marker->group)
- return tmp;
- }
- return NULL; /* Only if (marker == NULL) */
-}
-
-/* Finds the next marker in the same group. If no other is found, the same
- * marker will be returned */
-TextMarker *txt_next_marker(Text *text, TextMarker *marker)
-{
- TextMarker *tmp = marker;
- while (tmp) {
- if (tmp->next) tmp = tmp->next;
- else tmp = text->markers.first;
- if (tmp->group == marker->group)
- return tmp;
- }
- return NULL; /* Only if (marker == NULL) */
-}
-
-
/*******************************/
/* Character utility functions */
/*******************************/
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c
index da9c919c109..0f861a7ed37 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -111,6 +111,11 @@ static void delete_picture(AVFrame *f)
}
}
+static int use_float_audio_buffer(int codec_id)
+{
+ return codec_id == CODEC_ID_AAC || codec_id == CODEC_ID_AC3 || codec_id == CODEC_ID_VORBIS;
+}
+
#ifdef WITH_AUDASPACE
static int write_audio_frame(void)
{
@@ -599,12 +604,14 @@ static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
/* Prepare an audio stream for the output file */
-static AVStream *alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContext *of)
+static AVStream *alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContext *of, char *error, int error_size)
{
AVStream *st;
AVCodecContext *c;
AVCodec *codec;
+ error[0] = '\0';
+
st = av_new_stream(of, 1);
if (!st) return NULL;
@@ -616,6 +623,10 @@ static AVStream *alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex
c->bit_rate = ffmpeg_audio_bitrate * 1000;
c->sample_fmt = AV_SAMPLE_FMT_S16;
c->channels = rd->ffcodecdata.audio_channels;
+ if (use_float_audio_buffer(codec_id)) {
+ c->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
+ c->sample_fmt = AV_SAMPLE_FMT_FLT;
+ }
codec = avcodec_find_encoder(c->codec_id);
if (!codec) {
//XXX error("Couldn't find a valid audio codec");
@@ -626,6 +637,7 @@ static AVStream *alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex
if (avcodec_open(c, codec) < 0) {
//XXX error("Couldn't initialize audio codec");
+ BLI_strncpy(error, IMB_ffmpeg_last_error(), error_size);
return NULL;
}
@@ -646,7 +658,12 @@ static AVStream *alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex
audio_output_buffer = (uint8_t *) av_malloc(audio_outbuf_size);
- audio_input_buffer = (uint8_t *) av_malloc(audio_input_samples * c->channels * sizeof(int16_t));
+ if (use_float_audio_buffer(codec_id)) {
+ audio_input_buffer = (uint8_t *) av_malloc(audio_input_samples * c->channels * sizeof(float));
+ }
+ else {
+ audio_input_buffer = (uint8_t *) av_malloc(audio_input_samples * c->channels * sizeof(int16_t));
+ }
audio_time = 0.0f;
@@ -801,9 +818,12 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
}
if (ffmpeg_audio_codec != CODEC_ID_NONE) {
- audio_stream = alloc_audio_stream(rd, fmt->audio_codec, of);
+ audio_stream = alloc_audio_stream(rd, fmt->audio_codec, of, error, sizeof(error));
if (!audio_stream) {
- BKE_report(reports, RPT_ERROR, "Error initializing audio stream");
+ if (error[0])
+ BKE_report(reports, RPT_ERROR, error);
+ else
+ BKE_report(reports, RPT_ERROR, "Error initializing audio stream");
av_dict_free(&opts);
return 0;
}
@@ -943,7 +963,12 @@ int BKE_ffmpeg_start(struct Scene *scene, RenderData *rd, int rectx, int recty,
AVCodecContext *c = audio_stream->codec;
AUD_DeviceSpecs specs;
specs.channels = c->channels;
- specs.format = AUD_FORMAT_S16;
+ if (use_float_audio_buffer(c->codec_id)) {
+ specs.format = AUD_FORMAT_FLOAT32;
+ }
+ else {
+ specs.format = AUD_FORMAT_S16;
+ }
specs.rate = rd->ffcodecdata.audio_mixrate;
audio_mixdown_device = sound_mixdown(scene, specs, rd->sfra, rd->ffcodecdata.audio_volume);
#ifdef FFMPEG_CODEC_TIME_BASE