diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-04-04 17:37:07 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-04-04 17:37:07 +0400 |
commit | 83fff218cca47147183c1177de9db1381cfa48e6 (patch) | |
tree | 2576a9f8c61393a346c53eb85077ede1ba2b1d33 /source/blender/blenkernel/intern | |
parent | 69035e183ba91877489e8aae2d0425b13813ac18 (diff) | |
parent | 19dd08a4828ac1883138b2a65f0b8df1498e0d15 (diff) |
svn merge ^/trunk/blender -r55700:55776
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/anim.c | 48 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/colortools.c | 25 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/group.c | 51 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mball.c | 9 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/movieclip.c | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 28 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 12 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/writeffmpeg.c | 125 |
13 files changed, 179 insertions, 139 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index f53743ea06e..bf29fd571c4 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -270,6 +270,7 @@ void DM_init_funcs(DerivedMesh *dm) dm->getEdgeDataArray = DM_get_edge_data_layer; dm->getTessFaceDataArray = DM_get_tessface_data_layer; dm->getPolyDataArray = DM_get_poly_data_layer; + dm->getLoopDataArray = DM_get_loop_data_layer; bvhcache_init(&dm->bvhCache); } diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index ad791852253..8c49ce22dea 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -766,10 +766,10 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int persiste if (flag & DUPLILIST_DO_UPDATE) { /* note: update is optional because we don't always need object * transformations to be correct. Also fixes bug [#29616]. */ - group_handle_recalc_and_update(scene, ob, group); + BKE_group_handle_recalc_and_update(scene, ob, group); } - if (group_is_animated(ob, group)) + if (BKE_group_is_animated(group, ob)) flag |= DUPLILIST_ANIMATED; for (go = group->gobject.first, id = 0; go; go = go->next, id++) { @@ -953,6 +953,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl float vec[3], no[3], pmat[4][4]; int totvert, a, oblay; unsigned int lay; + CustomDataMask dm_mask; copy_m4_m4(pmat, par->obmat); @@ -961,16 +962,18 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl em = BMEdit_FromObject(par); - if (em) { - dm = editbmesh_get_derived_cage(scene, par, em, CD_MASK_BAREMESH); - } + /* get derived mesh */ + dm_mask = CD_MASK_BAREMESH; + if (flag & DUPLILIST_FOR_RENDER) + dm_mask |= CD_MASK_ORCO; + + if (em) + dm = editbmesh_get_derived_cage(scene, par, em, dm_mask); else - dm = mesh_get_derived_final(scene, par, CD_MASK_BAREMESH); + dm = mesh_get_derived_final(scene, par, dm_mask); - if (flag & DUPLILIST_FOR_RENDER) { - vdd.orco = (float(*)[3])BKE_mesh_orco_verts_get(par); - BKE_mesh_orco_verts_transform(me, vdd.orco, me->totvert, 0); - } + if (flag & DUPLILIST_FOR_RENDER) + vdd.orco = dm->getVertDataArray(dm, CD_ORCO); else vdd.orco = NULL; @@ -1057,8 +1060,6 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl else go = go->next; /* group loop */ } - if (vdd.orco) - MEM_freeN(vdd.orco); dm->release(dm); } @@ -1069,7 +1070,6 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa Base *base = NULL; DupliObject *dob; DerivedMesh *dm; - Mesh *me = par->data; MLoopUV *mloopuv; MPoly *mpoly, *mp; MLoop *mloop; @@ -1081,6 +1081,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa GroupObject *go = NULL; BMEditMesh *em; float ob__obmat[4][4]; /* needed for groups where the object matrix needs to be modified */ + CustomDataMask dm_mask; /* simple preventing of too deep nested groups */ if (level > MAX_DUPLI_RECUR) return; @@ -1088,11 +1089,16 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa copy_m4_m4(pmat, par->obmat); em = BMEdit_FromObject(par); + /* get derived mesh */ + dm_mask = CD_MASK_BAREMESH; + if (flag & DUPLILIST_FOR_RENDER) + dm_mask |= CD_MASK_ORCO | CD_MASK_MLOOPUV; + if (em) { - dm = editbmesh_get_derived_cage(scene, par, em, CD_MASK_BAREMESH); + dm = editbmesh_get_derived_cage(scene, par, em, dm_mask); } else { - dm = mesh_get_derived_final(scene, par, CD_MASK_BAREMESH); + dm = mesh_get_derived_final(scene, par, dm_mask); } totface = dm->getNumPolys(dm); @@ -1101,9 +1107,8 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa mvert = dm->getVertArray(dm); if (flag & DUPLILIST_FOR_RENDER) { - orco = (float(*)[3])BKE_mesh_orco_verts_get(par); - BKE_mesh_orco_verts_transform(me, orco, me->totvert, 0); - mloopuv = me->mloopuv; + orco = dm->getVertDataArray(dm, CD_ORCO); + mloopuv = dm->getLoopDataArray(dm, CD_MLOOPUV); } else { orco = NULL; @@ -1215,7 +1220,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa if (mloopuv) { int j; for (j = 0; j < mpoly->totloop; j++) { - madd_v2_v2fl(dob->orco, mloopuv[loopstart[j].v].uv, w); + madd_v2_v2fl(dob->uv, mloopuv[mp->loopstart + j].uv, w); } } } @@ -1238,9 +1243,6 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa else go = go->next; /* group loop */ } - if (orco) - MEM_freeN(orco); - dm->release(dm); } @@ -1331,7 +1333,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p /* gather list of objects or single object */ if (part->ren_as == PART_DRAW_GR) { if (flag & DUPLILIST_DO_UPDATE) { - group_handle_recalc_and_update(scene, par, part->dup_group); + BKE_group_handle_recalc_and_update(scene, par, part->dup_group); } if (part->draw & PART_DRAW_COUNT_GR) { diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 5176f93f4f3..04cc3cc6a09 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -1008,6 +1008,7 @@ void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const ColorM IMB_colormanagement_processor_free(cm_processor); } +/* if view_settings, it also applies this to byte buffers */ void scopes_update(Scopes *scopes, ImBuf *ibuf, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings) { @@ -1021,7 +1022,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, const ColorManagedViewSettings * float rgba[4], ycc[3], luma; int ycc_mode = -1; const short is_float = (ibuf->rect_float != NULL); - + void *cache_handle = NULL; struct ColormanageProcessor *cm_processor = NULL; if (ibuf->rect == NULL && ibuf->rect_float == NULL) return; @@ -1090,9 +1091,10 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, const ColorManagedViewSettings * if (is_float) rf = ibuf->rect_float; - else - rc = (unsigned char *)ibuf->rect; - + else { + rc = (unsigned char *)IMB_display_buffer_acquire(ibuf, view_settings, display_settings, &cache_handle); + } + if (ibuf->rect_float) cm_processor = IMB_colormanagement_display_processor_new(view_settings, display_settings); @@ -1173,11 +1175,12 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, const ColorManagedViewSettings * if (bin_b[x] > nb) nb = bin_b[x]; if (bin_a[x] > na) na = bin_a[x]; } - divl = 1.0 / (double)nl; - diva = 1.0 / (double)na; - divr = 1.0 / (double)nr; - divg = 1.0 / (double)ng; - divb = 1.0 / (double)nb; + divl = nl ? 1.0 / (double)nl : 1.0; + diva = na ? 1.0 / (double)na : 1.0; + divr = nr ? 1.0 / (double)nr : 1.0; + divg = ng ? 1.0 / (double)ng : 1.0; + divb = nb ? 1.0 / (double)nb : 1.0; + for (x = 0; x < 256; x++) { scopes->hist.data_luma[x] = bin_lum[x] * divl; scopes->hist.data_r[x] = bin_r[x] * divr; @@ -1193,7 +1196,9 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, const ColorManagedViewSettings * if (cm_processor) IMB_colormanagement_processor_free(cm_processor); - + if (cache_handle) + IMB_display_buffer_release(cache_handle); + scopes->ok = 1; } diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 4d9f0fc769c..12fa16e3273 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1204,8 +1204,8 @@ static void followpath_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstra vec_to_quat(quat, dir, (short)data->trackflag, (short)data->upflag); normalize_v3(dir); - q[0] = (float)cos(0.5 * vec[3]); - x1 = (float)sin(0.5 * vec[3]); + q[0] = cosf(0.5 * vec[3]); + x1 = sinf(0.5 * vec[3]); q[1] = -x1 * dir[0]; q[2] = -x1 * dir[1]; q[3] = -x1 * dir[2]; diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index 98d1d301f65..d0a9a6efe6b 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -95,7 +95,9 @@ void BKE_group_unlink(Group *group) /* ensure objects are not in this group */ for (; base; base = base->next) { - if (rem_from_group(group, base->object, sce, base) && find_group(base->object, NULL) == NULL) { + if (BKE_group_object_unlink(group, base->object, sce, base) && + BKE_group_object_find(NULL, base->object) == NULL) + { base->object->flag &= ~OB_FROMGROUP; base->flag &= ~OB_FROMGROUP; } @@ -132,7 +134,7 @@ void BKE_group_unlink(Group *group) group->id.us = 0; } -Group *add_group(Main *bmain, const char *name) +Group *BKE_group_add(Main *bmain, const char *name) { Group *group; @@ -152,7 +154,7 @@ Group *BKE_group_copy(Group *group) } /* external */ -static int add_to_group_internal(Group *group, Object *ob) +static int group_object_add_internal(Group *group, Object *ob) { GroupObject *go; @@ -173,9 +175,9 @@ static int add_to_group_internal(Group *group, Object *ob) return TRUE; } -int add_to_group(Group *group, Object *object, Scene *scene, Base *base) +bool BKE_group_object_add(Group *group, Object *object, Scene *scene, Base *base) { - if (add_to_group_internal(group, object)) { + if (group_object_add_internal(group, object)) { if ((object->flag & OB_FROMGROUP) == 0) { if (scene && base == NULL) @@ -186,15 +188,15 @@ int add_to_group(Group *group, Object *object, Scene *scene, Base *base) if (base) base->flag |= OB_FROMGROUP; } - return 1; + return true; } else { - return 0; + return false; } } /* also used for (ob == NULL) */ -static int rem_from_group_internal(Group *group, Object *ob) +static int group_object_unlink_internal(Group *group, Object *ob) { GroupObject *go, *gon; int removed = 0; @@ -214,11 +216,11 @@ static int rem_from_group_internal(Group *group, Object *ob) return removed; } -int rem_from_group(Group *group, Object *object, Scene *scene, Base *base) +bool BKE_group_object_unlink(Group *group, Object *object, Scene *scene, Base *base) { - if (rem_from_group_internal(group, object)) { + if (group_object_unlink_internal(group, object)) { /* object can be NULL */ - if (object && find_group(object, NULL) == NULL) { + if (object && BKE_group_object_find(NULL, object) == NULL) { if (scene && base == NULL) base = BKE_scene_base_find(scene, object); @@ -227,23 +229,24 @@ int rem_from_group(Group *group, Object *object, Scene *scene, Base *base) if (base) base->flag &= ~OB_FROMGROUP; } - return 1; + return true; } else { - return 0; + return false; } } -int object_in_group(Object *ob, Group *group) +bool BKE_group_object_exists(Group *group, Object *ob) { if (group == NULL || ob == NULL) { - return FALSE; + return false; + } + else { + return (BLI_findptr(&group->gobject, ob, offsetof(GroupObject, ob)) != NULL); } - - return (BLI_findptr(&group->gobject, ob, offsetof(GroupObject, ob)) != NULL); } -Group *find_group(Object *ob, Group *group) +Group *BKE_group_object_find(Group *group, Object *ob) { if (group) group = group->id.next; @@ -251,14 +254,14 @@ Group *find_group(Object *ob, Group *group) group = G.main->group.first; while (group) { - if (object_in_group(ob, group)) + if (BKE_group_object_exists(group, ob)) return group; group = group->id.next; } return NULL; } -void group_tag_recalc(Group *group) +void BKE_group_tag_recalc(Group *group) { GroupObject *go; @@ -270,7 +273,7 @@ void group_tag_recalc(Group *group) } } -int group_is_animated(Object *UNUSED(parent), Group *group) +bool BKE_group_is_animated(Group *group, Object *UNUSED(parent)) { GroupObject *go; @@ -281,9 +284,9 @@ int group_is_animated(Object *UNUSED(parent), Group *group) for (go = group->gobject.first; go; go = go->next) if (go->ob && go->ob->proxy) - return 1; + return true; - return 0; + return false; } #if 0 // add back when timeoffset & animsys work again @@ -332,7 +335,7 @@ static void group_replaces_nla(Object *parent, Object *target, char mode) * you can draw everything, leaves tags in objects to signal it needs further updating */ /* note: does not work for derivedmesh and render... it recreates all again in convertblender.c */ -void group_handle_recalc_and_update(Scene *scene, Object *UNUSED(parent), Group *group) +void BKE_group_handle_recalc_and_update(Scene *scene, Object *UNUSED(parent), Group *group) { GroupObject *go; diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 56480434b70..3a59f578446 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1065,6 +1065,7 @@ ID *BKE_libblock_find_name(const short type, const char *name) /* type: "OB return BLI_findstring(lb, name, offsetof(ID, name) + 2); } +#if 0 /* UNUSED */ static void get_flags_for_id(ID *id, char *buf) { int isfake = id->flag & LIB_FAKEUSER; @@ -1145,7 +1146,6 @@ static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, shor } } - /* used by headerbuttons.c buttons.c editobject.c editseq.c */ /* if (nr == NULL) no MAX_IDPUP, this for non-header browsing */ void IDnames_to_pupstring(const char **str, const char *title, const char *extraops, ListBase *lb, ID *link, short *nr) @@ -1170,7 +1170,6 @@ void IDnames_to_pupstring(const char **str, const char *title, const char *extra } /* skips viewer images */ -#if 0 /* unused */ void IMAnames_to_pupstring(const char **str, const char *title, const char *extraops, ListBase *lb, ID *link, short *nr) { DynStr *pupds = BLI_dynstr_new(); diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 72284130869..b93d924ddf9 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -1426,7 +1426,8 @@ static void converge(const float p1[3], const float p2[3], float v1, float v2, while (1) { if (i++ == RES) return; p[0] = 0.5f * (pos[0] + neg[0]); - if ((function(p[0], p[1], p[2])) > 0.0f) pos[0] = p[0]; else neg[0] = p[0]; + if ((function(p[0], p[1], p[2])) > 0.0f) pos[0] = p[0]; + else neg[0] = p[0]; } } @@ -1436,7 +1437,8 @@ static void converge(const float p1[3], const float p2[3], float v1, float v2, while (1) { if (i++ == RES) return; p[1] = 0.5f * (pos[1] + neg[1]); - if ((function(p[0], p[1], p[2])) > 0.0f) pos[1] = p[1]; else neg[1] = p[1]; + if ((function(p[0], p[1], p[2])) > 0.0f) pos[1] = p[1]; + else neg[1] = p[1]; } } @@ -1446,7 +1448,8 @@ static void converge(const float p1[3], const float p2[3], float v1, float v2, while (1) { if (i++ == RES) return; p[2] = 0.5f * (pos[2] + neg[2]); - if ((function(p[0], p[1], p[2])) > 0.0f) pos[2] = p[2]; else neg[2] = p[2]; + if ((function(p[0], p[1], p[2])) > 0.0f) pos[2] = p[2]; + else neg[2] = p[2]; } } diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index d0eb1494451..c8f3399665c 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -1162,13 +1162,17 @@ static void free_buffers(MovieClip *clip) BKE_free_animdata((ID *) clip); } +void BKE_movieclip_clear_cache(MovieClip *clip) +{ + free_buffers(clip); +} + void BKE_movieclip_reload(MovieClip *clip) { /* clear cache */ free_buffers(clip); clip->tracking.stabilization.ok = FALSE; - clip->prefetch_ok = FALSE; /* update clip source */ detect_clip_source(clip); diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 5cf8758aa1b..83e2ff6593b 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -190,7 +190,10 @@ static void node_socket_set_typeinfo(bNodeTree *ntree, bNodeSocket *sock, bNodeS { if (typeinfo) { sock->typeinfo = typeinfo; - + + /* deprecated integer type */ + sock->type = typeinfo->type; + if (sock->default_value == NULL) { /* initialize the default_value pointer used by standard socket types */ node_socket_init_default_value(sock); @@ -435,28 +438,6 @@ GHashIterator *nodeSocketTypeGetIterator(void) return BLI_ghashIterator_new(nodesockettypes_hash); } -void nodeMakeDynamicType(bNode *UNUSED(node)) -{ - #if 0 /* XXX deprecated */ - /* find SH_DYNAMIC_NODE ntype */ - bNodeType *ntype = ntreeType_Shader->node_types.first; - while (ntype) { - if (ntype->type == NODE_DYNAMIC) - break; - ntype = ntype->next; - } - - /* make own type struct to fill */ - if (ntype) { - /*node->typeinfo= MEM_dupallocN(ntype);*/ - bNodeType *newtype = MEM_callocN(sizeof(bNodeType), "dynamic bNodeType"); - *newtype = *ntype; - BLI_strncpy(newtype->name, ntype->name, sizeof(newtype->name)); - node->typeinfo = newtype; - } - #endif -} - struct bNodeSocket *nodeFindSocket(bNode *node, int in_out, const char *identifier) { bNodeSocket *sock = (in_out == SOCK_IN ? node->inputs.first : node->outputs.first); @@ -3438,6 +3419,7 @@ static void registerShaderNodes(void) register_node_type_sh_holdout(); //register_node_type_sh_volume_transparent(); //register_node_type_sh_volume_isotropic(); + register_node_type_sh_subsurface_scattering(); register_node_type_sh_mix_shader(); register_node_type_sh_add_shader(); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 6f0f6a357bb..3750eadb6db 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -771,7 +771,7 @@ void BKE_object_unlink(Object *ob) /* groups */ group = bmain->group.first; while (group) { - rem_from_group(group, ob, NULL, NULL); + BKE_group_object_unlink(group, ob, NULL, NULL); group = group->id.next; } @@ -1848,8 +1848,8 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[4][4]) /* the tilt */ normalize_v3(dir); - q[0] = (float)cos(0.5 * vec[3]); - si = (float)sin(0.5 * vec[3]); + q[0] = cosf(0.5 * vec[3]); + si = sinf(0.5 * vec[3]); q[1] = -si * dir[0]; q[2] = -si * dir[1]; q[3] = -si * dir[2]; @@ -3403,7 +3403,7 @@ struct LinkNode *BKE_object_groups(Object *ob) { LinkNode *group_linknode = NULL; Group *group = NULL; - while ((group = find_group(ob, group))) { + while ((group = BKE_group_object_find(group, ob))) { BLI_linklist_prepend(&group_linknode, group); } @@ -3420,7 +3420,7 @@ void BKE_object_groups_clear(Scene *scene, Base *base, Object *object) base = BKE_scene_base_find(scene, object); } - while ((group = find_group(base->object, group))) { - rem_from_group(group, object, scene, base); + while ((group = BKE_group_object_find(group, base->object))) { + BKE_group_object_unlink(group, object, scene, base); } } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index d9dabf24ba0..4e78ab52499 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -314,7 +314,7 @@ void psys_check_group_weights(ParticleSettings *part) /* first remove all weights that don't have an object in the group */ dw = part->dupliweights.first; while (dw) { - if (!object_in_group(dw->ob, part->dup_group)) { + if (!BKE_group_object_exists(part->dup_group, dw->ob)) { tdw = dw->next; BLI_freelinkN(&part->dupliweights, dw); dw = tdw; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 83ee6759b4f..c2d25ce54db 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -1093,7 +1093,7 @@ static void scene_depsgraph_hack(Scene *scene, Scene *scene_parent) if (go->ob) go->ob->recalc |= recalc; } - group_handle_recalc_and_update(scene_parent, ob, ob->dup_group); + BKE_group_handle_recalc_and_update(scene_parent, ob, ob->dup_group); } } } @@ -1136,7 +1136,7 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen BKE_object_handle_update_ex(scene_parent, ob, scene->rigidbody_world); if (ob->dup_group && (ob->transflag & OB_DUPLIGROUP)) - group_handle_recalc_and_update(scene_parent, ob, ob->dup_group); + BKE_group_handle_recalc_and_update(scene_parent, ob, ob->dup_group); /* always update layer, so that animating layers works (joshua july 2010) */ /* XXX commented out, this has depsgraph issues anyway - and this breaks setting scenes diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index a88a9e4954b..3249de49fe6 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -88,10 +88,11 @@ static uint8_t *video_buffer = 0; static int video_buffersize = 0; static uint8_t *audio_input_buffer = 0; +static uint8_t *audio_deinterleave_buffer = 0; static int audio_input_samples = 0; -static uint8_t *audio_output_buffer = 0; -static int audio_outbuf_size = 0; static double audio_time = 0.0f; +static bool audio_deinterleave = false; +static int audio_sample_size = 0; #ifdef WITH_AUDASPACE static AUD_Device *audio_mixdown_device = 0; @@ -122,37 +123,69 @@ static int write_audio_frame(void) { AVCodecContext *c = NULL; AVPacket pkt; + AVFrame *frame; + int got_output = 0; c = audio_stream->codec; av_init_packet(&pkt); pkt.size = 0; + pkt.data = NULL; + + frame = avcodec_alloc_frame(); + frame->nb_samples = audio_input_samples; + frame->format = c->sample_fmt; +#ifdef FFMPEG_HAVE_FRAME_CHANNEL_LAYOUT + frame->channel_layout = c->channel_layout; +#endif AUD_readDevice(audio_mixdown_device, audio_input_buffer, audio_input_samples); audio_time += (double) audio_input_samples / (double) c->sample_rate; - pkt.size = avcodec_encode_audio(c, audio_output_buffer, audio_outbuf_size, (short *) audio_input_buffer); + if (audio_deinterleave) { + int channel, i; + uint8_t *temp; + + for (channel = 0; channel < c->channels; channel++) { + for (i = 0; i < frame->nb_samples; i++) { + memcpy(audio_deinterleave_buffer + (i + channel * frame->nb_samples) * audio_sample_size, + audio_input_buffer + (c->channels * i + channel) * audio_sample_size, audio_sample_size); + } + } + + temp = audio_deinterleave_buffer; + audio_deinterleave_buffer = audio_input_buffer; + audio_input_buffer = temp; + } + + avcodec_fill_audio_frame(frame, c->channels, c->sample_fmt, audio_input_buffer, + audio_input_samples * c->channels * audio_sample_size, 0); - if (pkt.size < 0) { + if (avcodec_encode_audio2(c, &pkt, frame, &got_output) < 0) { // XXX error("Error writing audio packet"); return -1; } - pkt.data = audio_output_buffer; + if (got_output) { + if (c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE) { + pkt.pts = av_rescale_q(c->coded_frame->pts, c->time_base, audio_stream->time_base); + PRINT("Audio Frame PTS: %d\n", (int) pkt.pts); + } - if (c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE) { - pkt.pts = av_rescale_q(c->coded_frame->pts, c->time_base, audio_stream->time_base); - PRINT("Audio Frame PTS: %d\n", (int) pkt.pts); - } + pkt.stream_index = audio_stream->index; - pkt.stream_index = audio_stream->index; + pkt.flags |= AV_PKT_FLAG_KEY; - pkt.flags |= AV_PKT_FLAG_KEY; + if (av_interleaved_write_frame(outfile, &pkt) != 0) { + fprintf(stderr, "Error writing audio packet!\n"); + return -1; + } - if (av_interleaved_write_frame(outfile, &pkt) != 0) { - fprintf(stderr, "Error writing audio packet!\n"); - return -1; + av_free_packet(&pkt); } + + avcodec_free_frame(&frame); + return 0; } #endif // #ifdef WITH_AUDASPACE @@ -608,8 +641,6 @@ static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex return st; } -/* Prepare an audio stream for the output file */ - static AVStream *alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContext *of, char *error, int error_size) { AVStream *st; @@ -659,11 +690,6 @@ static AVStream *alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex } } - if (c->sample_fmt == AV_SAMPLE_FMT_FLTP) { - BLI_strncpy(error, "Requested audio codec requires planar float sample format, which is not supported yet", error_size); - return NULL; - } - if (codec->supported_samplerates) { const int *p = codec->supported_samplerates; int best = 0; @@ -692,24 +718,23 @@ static AVStream *alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex st->codec->time_base.num = 1; st->codec->time_base.den = st->codec->sample_rate; - audio_outbuf_size = FF_MIN_BUFFER_SIZE; - - if ((c->codec_id >= CODEC_ID_PCM_S16LE) && (c->codec_id <= CODEC_ID_PCM_DVD)) - audio_input_samples = audio_outbuf_size * 8 / c->bits_per_coded_sample / c->channels; + if (c->frame_size == 0) + // used to be if((c->codec_id >= CODEC_ID_PCM_S16LE) && (c->codec_id <= CODEC_ID_PCM_DVD)) + // not sure if that is needed anymore, so let's try out if there are any + // complaints regarding some ffmpeg versions users might have + audio_input_samples = FF_MIN_BUFFER_SIZE * 8 / c->bits_per_coded_sample / c->channels; else { audio_input_samples = c->frame_size; - if (c->frame_size * c->channels * sizeof(int16_t) * 4 > audio_outbuf_size) - audio_outbuf_size = c->frame_size * c->channels * sizeof(int16_t) * 4; } - audio_output_buffer = (uint8_t *) av_malloc(audio_outbuf_size); + audio_deinterleave = av_sample_fmt_is_planar(c->sample_fmt); - if (c->sample_fmt == AV_SAMPLE_FMT_FLT) { - 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_sample_size = av_get_bytes_per_sample(c->sample_fmt); + + audio_input_buffer = (uint8_t *) av_malloc(audio_input_samples * c->channels * audio_sample_size); + + if (audio_deinterleave) + audio_deinterleave_buffer = (uint8_t *) av_malloc(audio_input_samples * c->channels * audio_sample_size); audio_time = 0.0f; @@ -1010,12 +1035,27 @@ 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; - if (c->sample_fmt == AV_SAMPLE_FMT_FLT) { - specs.format = AUD_FORMAT_FLOAT32; - } - else { + + switch (av_get_packed_sample_fmt(c->sample_fmt)) { + case AV_SAMPLE_FMT_U8: + specs.format = AUD_FORMAT_U8; + break; + case AV_SAMPLE_FMT_S16: specs.format = AUD_FORMAT_S16; + break; + case AV_SAMPLE_FMT_S32: + specs.format = AUD_FORMAT_S32; + break; + case AV_SAMPLE_FMT_FLT: + specs.format = AUD_FORMAT_FLOAT32; + break; + case AV_SAMPLE_FMT_DBL: + specs.format = AUD_FORMAT_FLOAT64; + break; + default: + return -31415; } + specs.rate = rd->ffcodecdata.audio_mixrate; audio_mixdown_device = sound_mixdown(scene, specs, rd->sfra, rd->ffcodecdata.audio_volume); #ifdef FFMPEG_CODEC_TIME_BASE @@ -1138,15 +1178,16 @@ static void end_ffmpeg_impl(int is_autosplit) MEM_freeN(video_buffer); video_buffer = 0; } - if (audio_output_buffer) { - av_free(audio_output_buffer); - audio_output_buffer = 0; - } if (audio_input_buffer) { av_free(audio_input_buffer); audio_input_buffer = 0; } + if (audio_deinterleave_buffer) { + av_free(audio_deinterleave_buffer); + audio_deinterleave_buffer = 0; + } + if (img_convert_ctx) { sws_freeContext(img_convert_ctx); img_convert_ctx = 0; |