forked from bartvdbraak/blender
Code cleanup and small fixes:
- Assume all areas are using valid MovieClipUser when using functions from movieclip.c - Set active scene clip to movie-related nodes in compositor rather than checking if there's only one clip in datablocks - Fixed users count issue when solving camera motion
This commit is contained in:
parent
e28d0c6a8f
commit
23dfb8a156
@ -191,15 +191,13 @@ static ImBuf *movieclip_load_sequence_file(MovieClip *clip, MovieClipUser *user,
|
||||
{
|
||||
struct ImBuf *ibuf;
|
||||
char name[FILE_MAX];
|
||||
int loadflag /*, size */ /* UNUSED */, undistort;
|
||||
int loadflag, use_proxy= 0;
|
||||
|
||||
/* size= rendersize_to_number(user->render_size); */
|
||||
|
||||
undistort= user->render_flag&MCLIP_PROXY_RENDER_UNDISTORT;
|
||||
|
||||
if((flag&MCLIP_USE_PROXY) && user->render_size != MCLIP_PROXY_RENDER_SIZE_FULL)
|
||||
use_proxy= (flag&MCLIP_USE_PROXY) && user->render_size != MCLIP_PROXY_RENDER_SIZE_FULL;
|
||||
if(use_proxy) {
|
||||
int undistort= user->render_flag&MCLIP_PROXY_RENDER_UNDISTORT;
|
||||
get_proxy_fname(clip, user->render_size, undistort, framenr, name);
|
||||
else
|
||||
} else
|
||||
get_sequence_fname(clip, framenr, name);
|
||||
|
||||
loadflag= IB_rect|IB_multilayer;
|
||||
@ -318,7 +316,7 @@ static ImBuf *get_imbuf_cache(MovieClip *clip, MovieClipUser *user, int flag)
|
||||
if(clip->cache) {
|
||||
MovieClipImBufCacheKey key;
|
||||
|
||||
key.framenr= user?user->framenr:clip->lastframe;
|
||||
key.framenr= user->framenr;
|
||||
|
||||
if(flag&MCLIP_USE_PROXY) {
|
||||
key.proxy= rendersize_to_proxy(user, flag);
|
||||
@ -346,7 +344,7 @@ static void put_imbuf_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, i
|
||||
moviecache_hashcmp, moviecache_keydata);
|
||||
}
|
||||
|
||||
key.framenr= user?user->framenr:clip->lastframe;
|
||||
key.framenr= user->framenr;
|
||||
|
||||
if(flag&MCLIP_USE_PROXY) {
|
||||
key.proxy= rendersize_to_proxy(user, flag);
|
||||
@ -478,9 +476,6 @@ static void real_ibuf_size(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, in
|
||||
|
||||
static int need_undistorted_cache(MovieClipUser *user, int flag)
|
||||
{
|
||||
if (!user)
|
||||
return 0;
|
||||
|
||||
/* only full undistorted render can be used as on-fly undistorting image */
|
||||
if(flag&MCLIP_USE_PROXY) {
|
||||
if(user->render_size != MCLIP_PROXY_RENDER_SIZE_FULL || (user->render_flag&MCLIP_PROXY_RENDER_UNDISTORT)==0)
|
||||
@ -495,7 +490,7 @@ static ImBuf *get_undistorted_cache(MovieClip *clip, MovieClipUser *user)
|
||||
{
|
||||
MovieClipCache *cache= clip->cache;
|
||||
MovieTrackingCamera *camera= &clip->tracking.camera;
|
||||
int framenr= user?user->framenr:clip->lastframe;
|
||||
int framenr= user->framenr;
|
||||
|
||||
/* no cache or no cached undistorted image */
|
||||
if(!clip->cache || !clip->cache->undistibuf)
|
||||
@ -547,7 +542,7 @@ static ImBuf *put_undistorted_cache(MovieClip *clip, MovieClipUser *user, ImBuf
|
||||
|
||||
copy_v2_v2(cache->principal, camera->principal);
|
||||
copy_v3_v3(&cache->k1, &camera->k1);
|
||||
cache->undist_framenr= user?user->framenr:clip->lastframe;
|
||||
cache->undist_framenr= user->framenr;
|
||||
|
||||
if(cache->undistibuf)
|
||||
IMB_freeImBuf(cache->undistibuf);
|
||||
@ -568,7 +563,7 @@ static ImBuf *put_undistorted_cache(MovieClip *clip, MovieClipUser *user, ImBuf
|
||||
ImBuf *BKE_movieclip_get_ibuf(MovieClip *clip, MovieClipUser *user)
|
||||
{
|
||||
ImBuf *ibuf= NULL;
|
||||
int framenr= user?user->framenr:clip->lastframe;
|
||||
int framenr= user->framenr;
|
||||
int cache_undistorted= 0;
|
||||
|
||||
/* cache isn't threadsafe itself and also loading of movies
|
||||
@ -586,11 +581,11 @@ ImBuf *BKE_movieclip_get_ibuf(MovieClip *clip, MovieClipUser *user)
|
||||
ibuf= get_imbuf_cache(clip, user, clip->flag);
|
||||
|
||||
if(!ibuf) {
|
||||
int use_sequence= 1;
|
||||
int use_sequence= 0;
|
||||
|
||||
/* undistorted proxies for movies should be read as image sequence */
|
||||
use_sequence&= user->render_flag&MCLIP_PROXY_RENDER_UNDISTORT;
|
||||
use_sequence&= user->render_size!=MCLIP_PROXY_RENDER_SIZE_FULL;
|
||||
use_sequence= (user->render_flag&MCLIP_PROXY_RENDER_UNDISTORT) &&
|
||||
(user->render_size!=MCLIP_PROXY_RENDER_SIZE_FULL);
|
||||
|
||||
if(clip->source==MCLIP_SRC_SEQUENCE || use_sequence)
|
||||
ibuf= movieclip_load_sequence_file(clip, user, framenr, clip->flag);
|
||||
@ -622,7 +617,7 @@ ImBuf *BKE_movieclip_get_ibuf(MovieClip *clip, MovieClipUser *user)
|
||||
ImBuf *BKE_movieclip_get_ibuf_flag(MovieClip *clip, MovieClipUser *user, int flag)
|
||||
{
|
||||
ImBuf *ibuf= NULL;
|
||||
int framenr= user?user->framenr:clip->lastframe;
|
||||
int framenr= user->framenr;
|
||||
int cache_undistorted= 0;
|
||||
|
||||
/* cache isn't threadsafe itself and also loading of movies
|
||||
@ -668,7 +663,7 @@ ImBuf *BKE_movieclip_get_ibuf_flag(MovieClip *clip, MovieClipUser *user, int fla
|
||||
ImBuf *BKE_movieclip_get_stable_ibuf(MovieClip *clip, MovieClipUser *user, float loc[2], float *scale, float *angle)
|
||||
{
|
||||
ImBuf *ibuf, *stableibuf= NULL;
|
||||
int framenr= user?user->framenr:clip->lastframe;
|
||||
int framenr= user->framenr;
|
||||
|
||||
ibuf= BKE_movieclip_get_ibuf(clip, user);
|
||||
|
||||
@ -749,7 +744,7 @@ int BKE_movieclip_has_frame(MovieClip *clip, MovieClipUser *user)
|
||||
|
||||
void BKE_movieclip_get_size(MovieClip *clip, MovieClipUser *user, int *width, int *height)
|
||||
{
|
||||
if(!user || user->framenr==clip->lastframe) {
|
||||
if(user->framenr==clip->lastframe) {
|
||||
*width= clip->lastsize[0];
|
||||
*height= clip->lastsize[1];
|
||||
} else {
|
||||
|
@ -1537,7 +1537,7 @@ static int solve_camera_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
/* could fail if footage uses images with different sizes */
|
||||
BKE_movieclip_get_size(clip, NULL, &width, &height);
|
||||
BKE_movieclip_get_size(clip, &sc->user, &width, &height);
|
||||
|
||||
error= BKE_tracking_solve_reconstruction(tracking, width, height);
|
||||
|
||||
@ -1546,6 +1546,9 @@ static int solve_camera_exec(bContext *C, wmOperator *op)
|
||||
else
|
||||
BKE_reportf(op->reports, RPT_INFO, "Average reprojection error %.3f", error);
|
||||
|
||||
if(scene->clip)
|
||||
id_us_min(&clip->id);
|
||||
|
||||
scene->clip= clip;
|
||||
id_us_plus(&clip->id);
|
||||
|
||||
|
@ -2211,9 +2211,7 @@ bNode *node_add_node(SpaceNode *snode, Main *bmain, Scene *scene, bNodeTemplate
|
||||
node->id = &scene->id;
|
||||
}
|
||||
else if(ELEM3(node->type, CMP_NODE_MOVIECLIP, CMP_NODE_MOVIEDISTORTION, CMP_NODE_STABILIZE2D)) {
|
||||
if(G.main->movieclip.first == G.main->movieclip.last) {
|
||||
node->id= G.main->movieclip.first;
|
||||
}
|
||||
node->id = (ID *)scene->clip;
|
||||
}
|
||||
|
||||
ntreeCompositForceHidden(snode->edittree, scene);
|
||||
|
@ -66,24 +66,6 @@ static void rna_MovieClip_size_get(PointerRNA *ptr, int *values)
|
||||
values[1]= clip->lastsize[1];
|
||||
}
|
||||
|
||||
static void rna_MovieClip_resolution_get(PointerRNA *ptr, float *values)
|
||||
{
|
||||
MovieClip *clip= (MovieClip*)ptr->id.data;
|
||||
ImBuf *ibuf;
|
||||
|
||||
ibuf= BKE_movieclip_get_ibuf(clip, NULL);
|
||||
if (ibuf) {
|
||||
values[0]= ibuf->ppm[0];
|
||||
values[1]= ibuf->ppm[1];
|
||||
|
||||
IMB_freeImBuf(ibuf);
|
||||
}
|
||||
else {
|
||||
values[0]= 0;
|
||||
values[1]= 0;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void rna_def_movieclip_proxy(BlenderRNA *brna)
|
||||
@ -235,10 +217,6 @@ static void rna_def_movieclip(BlenderRNA *brna)
|
||||
RNA_def_property_int_funcs(prop, "rna_MovieClip_size_get" , NULL, NULL);
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
|
||||
prop= RNA_def_float_vector(srna, "resolution" , 2 , NULL , 0, 0, "Resolution" , "X/Y pixels per meter" , 0 , 0);
|
||||
RNA_def_property_float_funcs(prop, "rna_MovieClip_resolution_get", NULL, NULL);
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
|
||||
prop= RNA_def_property(srna, "display_aspect", PROP_FLOAT, PROP_XYZ);
|
||||
RNA_def_property_float_sdna(prop, NULL, "aspx");
|
||||
RNA_def_property_array(prop, 2);
|
||||
|
@ -45,7 +45,7 @@ static bNodeSocketTemplate cmp_node_moviedistortion_out[]= {
|
||||
{ -1, 0, "" }
|
||||
};
|
||||
|
||||
static void exec(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
|
||||
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
|
||||
{
|
||||
if(in[0]->data) {
|
||||
if(node->id) {
|
||||
@ -57,14 +57,18 @@ static void exec(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **
|
||||
ibuf= IMB_allocImBuf(cbuf->x, cbuf->y, 32, 0);
|
||||
|
||||
if(ibuf) {
|
||||
RenderData *rd= data;
|
||||
ImBuf *obuf;
|
||||
MovieTracking *tracking= &clip->tracking;
|
||||
int width, height;
|
||||
float overscan= 0.0f;
|
||||
MovieClipUser user= {0};
|
||||
|
||||
BKE_movieclip_user_set_frame(&user, rd->cfra);
|
||||
|
||||
ibuf->rect_float= cbuf->rect;
|
||||
|
||||
BKE_movieclip_get_size(clip, NULL, &width, &height);
|
||||
BKE_movieclip_get_size(clip, &user, &width, &height);
|
||||
|
||||
if(!node->storage)
|
||||
node->storage= BKE_tracking_distortion_create();
|
||||
|
Loading…
Reference in New Issue
Block a user