Changed semantic of recently added start_frame
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 6 Jun 2012 18:58:30 +0000 (18:58 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 6 Jun 2012 18:58:30 +0000 (18:58 +0000)
Now it's indicates at which scene frame number movie clip starts playing back.
This this setting is still belongs to clip datavlock and used by all users of
clip such as movie compositor nodes, constraints and so.

After long discussion and thoughts about this it was decided that this would
match image's current behavior (which initially seen a bit crappy), but that's
actually allows:

- Keep semantics of start frame in image and clip datablocks in sync
- Allows to support features like support of loading image sequences
  with crappy numbers in suffix which doesn't fit long int.
- Allows to eliminate extra boolean checkbox to control such kind of offset.

Hopefully from pipeline POV it wouldn't hurt because idea of having this things
implemented in original way was  working only if sequence before processing
started naming form 001.

14 files changed:
release/scripts/startup/bl_ui/space_clip.py
source/blender/blenkernel/BKE_blender.h
source/blender/blenkernel/BKE_movieclip.h
source/blender/blenkernel/intern/constraint.c
source/blender/blenkernel/intern/movieclip.c
source/blender/blenkernel/intern/tracking.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/include/ED_clip.h
source/blender/editors/space_clip/clip_draw.c
source/blender/editors/space_clip/clip_editor.c
source/blender/editors/space_clip/tracking_ops.c
source/blender/editors/transform/transform_conversions.c
source/blender/makesdna/DNA_movieclip_types.h
source/blender/makesrna/intern/rna_movieclip.c

index 9f283b70f7721b9e6394d084ac794e084aecab70..0174762fcc81afbb9f0ea27d39136820b9d307fa 100644 (file)
@@ -960,9 +960,7 @@ class CLIP_PT_footage(CLIP_PT_clip_view_panel, Panel):
 
         col = layout.column()
         col.template_movieclip(sc, "clip", compact=True)
-        col.prop(clip, "use_custom_start_frame")
-        if clip.use_custom_start_frame:
-            col.prop(clip, "start_frame")
+        col.prop(clip, "start_frame")
 
 
 class CLIP_PT_tools_clip(CLIP_PT_clip_view_panel, Panel):
index 6fccf819d052fab2b1acb5f9ead1736133ff94cf..db8fcd4a0d38da1ca7d231e85f32b1a1a5fc3cf6 100644 (file)
@@ -42,7 +42,7 @@ extern "C" {
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         263
-#define BLENDER_SUBVERSION      9
+#define BLENDER_SUBVERSION      10
 
 #define BLENDER_MINVERSION      250
 #define BLENDER_MINSUBVERSION   0
index 15b3cb91b90a16467f0735bfa8e6e92339e7ac14..221ae99a0ec57490925bff111281b3087d983ed2 100644 (file)
@@ -63,6 +63,9 @@ void BKE_movieclip_get_cache_segments(struct MovieClip *clip, struct MovieClipUs
 void BKE_movieclip_build_proxy_frame(struct MovieClip *clip, int clip_flag, struct MovieDistortion *distortion,
                                      int cfra, int *build_sizes, int build_count, int undistorted);
 
+int BKE_movieclip_remap_scene_to_clip_frame(struct MovieClip *clip, int framenr);
+int BKE_movieclip_remap_clip_to_scene_frame(struct MovieClip *clip, int framenr);
+
 /* cacheing flags */
 #define MOVIECLIP_CACHE_SKIP        (1 << 0)
 
index c6a0ecc057a7f1ba585ec618e9d5fef3982efa7e..afd50de8159c4e976bb71889260c8b5fa1c0dbc4 100644 (file)
@@ -3897,6 +3897,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
        MovieTrackingTrack *track;
        MovieTrackingObject *tracking_object;
        Object *camob = data->camera ? data->camera : scene->camera;
+       int framenr;
 
        if (data->flag & FOLLOWTRACK_ACTIVECLIP)
                clip = scene->clip;
@@ -3919,6 +3920,8 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
        if (!track)
                return;
 
+       framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, scene->r.cfra);
+
        if (data->flag & FOLLOWTRACK_USE_3D_POSITION) {
                if (track->flag & TRACK_HAS_BUNDLE) {
                        float obmat[4][4], mat[4][4];
@@ -3930,7 +3933,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
 
                                copy_m4_m4(mat, camob->obmat);
 
-                               BKE_tracking_get_interpolated_camera(tracking, tracking_object, scene->r.cfra, imat);
+                               BKE_tracking_get_interpolated_camera(tracking, tracking_object, framenr, imat);
                                invert_m4(imat);
 
                                mul_serie_m4(cob->matrix, obmat, mat, imat, NULL, NULL, NULL, NULL, NULL);
@@ -3969,7 +3972,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
                        CameraParams params;
                        float pos[2], rmat[4][4];
 
-                       marker = BKE_tracking_get_marker(track, scene->r.cfra);
+                       marker = BKE_tracking_get_marker(track, framenr);
 
                        add_v2_v2v2(pos, marker->pos, track->offset);
 
@@ -4092,8 +4095,9 @@ static void camerasolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
                float mat[4][4], obmat[4][4];
                MovieTracking *tracking = &clip->tracking;
                MovieTrackingObject *object = BKE_tracking_get_camera_object(tracking);
+               int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, scene->r.cfra);
 
-               BKE_tracking_get_interpolated_camera(tracking, object, scene->r.cfra, mat);
+               BKE_tracking_get_interpolated_camera(tracking, object, framenr, mat);
 
                copy_m4_m4(obmat, cob->matrix);
 
@@ -4156,10 +4160,11 @@ static void objectsolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
 
                if (object) {
                        float mat[4][4], obmat[4][4], imat[4][4], cammat[4][4], camimat[4][4], parmat[4][4];
+                       int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, scene->r.cfra);
 
                        BKE_object_where_is_calc_mat4(scene, camob, cammat);
 
-                       BKE_tracking_get_interpolated_camera(tracking, object, scene->r.cfra, mat);
+                       BKE_tracking_get_interpolated_camera(tracking, object, framenr, mat);
 
                        invert_m4_m4(camimat, cammat);
                        mult_m4_m4m4(parmat, cammat, data->invmat);
index a90fc28cd1eafeb113f53fb28e6c9a8fddba11cf..de12926f3ebade1393cc2ac8adb980cc50c67a47 100644 (file)
@@ -153,18 +153,13 @@ static void get_sequence_fname(MovieClip *clip, int framenr, char *name)
        BLI_strncpy(name, clip->name, sizeof(clip->name));
        BLI_stringdec(name, head, tail, &numlen);
 
-       if (clip->flag & MCLIP_CUSTOM_START_FRAME) {
-               offset = clip->start_frame;
-       }
-       else {
-               /* movieclips always points to first image from sequence,
-                * autoguess offset for now. could be something smarter in the future
-                */
-               offset = sequence_guess_offset(clip->name, strlen(head), numlen);
-       }
+       /* movieclips always points to first image from sequence,
+        * autoguess offset for now. could be something smarter in the future
+        */
+       offset = sequence_guess_offset(clip->name, strlen(head), numlen);
 
        if (numlen)
-               BLI_stringenc(name, head, tail, numlen, offset + framenr - 1);
+               BLI_stringenc(name, head, tail, numlen, offset + framenr - clip->start_frame);
        else
                BLI_strncpy(name, clip->name, sizeof(clip->name));
 
@@ -176,6 +171,7 @@ static void get_proxy_fname(MovieClip *clip, int proxy_render_size, int undistor
 {
        int size = rendersize_to_number(proxy_render_size);
        char dir[FILE_MAX], clipdir[FILE_MAX], clipfile[FILE_MAX];
+       int proxynr = framenr - clip->start_frame + 1;
 
        BLI_split_dirfile(clip->name, clipdir, clipfile, FILE_MAX, FILE_MAX);
 
@@ -187,9 +183,9 @@ static void get_proxy_fname(MovieClip *clip, int proxy_render_size, int undistor
        }
 
        if (undistorted)
-               BLI_snprintf(name, FILE_MAX, "%s/%s/proxy_%d_undistorted/%08d", dir, clipfile, size, framenr);
+               BLI_snprintf(name, FILE_MAX, "%s/%s/proxy_%d_undistorted/%08d", dir, clipfile, size, proxynr);
        else
-               BLI_snprintf(name, FILE_MAX, "%s/%s/proxy_%d/%08d", dir, clipfile, size, framenr);
+               BLI_snprintf(name, FILE_MAX, "%s/%s/proxy_%d/%08d", dir, clipfile, size, proxynr);
 
        BLI_path_abs(name, G.main->name);
        BLI_path_frame(name, 1, 0);
@@ -254,11 +250,7 @@ static ImBuf *movieclip_load_movie_file(MovieClip *clip, MovieClipUser *user, in
                int fra;
 
                dur = IMB_anim_get_duration(clip->anim, tc);
-               fra = framenr - 1;
-
-               if (clip->flag & MCLIP_CUSTOM_START_FRAME) {
-                       fra += clip->start_frame - 1;
-               }
+               fra = framenr - clip->start_frame;
 
                if (fra < 0)
                        fra = 0;
@@ -1038,7 +1030,8 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip
 
                if (act_track) {
                        MovieTrackingTrack *track = act_track;
-                       MovieTrackingMarker *marker = BKE_tracking_get_marker(track, user->framenr);
+                       int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, user->framenr);
+                       MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenr);
 
                        if (marker->flag & MARKER_DISABLED) {
                                scopes->track_disabled = TRUE;
@@ -1230,3 +1223,13 @@ void BKE_movieclip_unlink(Main *bmain, MovieClip *clip)
 
        clip->id.us = 0;
 }
+
+int BKE_movieclip_remap_scene_to_clip_frame(MovieClip *clip, int framenr)
+{
+       return framenr - clip->start_frame + 1;
+}
+
+int BKE_movieclip_remap_clip_to_scene_frame(MovieClip *clip, int framenr)
+{
+       return framenr + clip->start_frame - 1;
+}
index b0745ebf1c8df9ddc24d96bf158f6ad34555ee0a..4abb461bc81c6d1dccede75612b97050d633f642 100644 (file)
@@ -972,7 +972,8 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u
        track = tracksbase->first;
        while (track) {
                if (TRACK_SELECTED(track) && (track->flag & (TRACK_LOCKED | TRACK_HIDDEN)) == 0) {
-                       MovieTrackingMarker *marker = BKE_tracking_get_marker(track, user->framenr);
+                       int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, user->framenr);
+                       MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenr);
 
                        if ((marker->flag & MARKER_DISABLED) == 0)
                                num_tracks++;
@@ -993,7 +994,8 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u
                track = tracksbase->first;
                while (track) {
                        if (TRACK_SELECTED(track) && (track->flag & (TRACK_HIDDEN | TRACK_LOCKED)) == 0) {
-                               MovieTrackingMarker *marker = BKE_tracking_get_marker(track, user->framenr);
+                               int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, user->framenr);
+                               MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenr);
 
                                if ((marker->flag & MARKER_DISABLED) == 0) {
                                        TrackContext track_context;
@@ -1311,7 +1313,7 @@ static ImBuf *get_frame_ibuf(MovieTrackingContext *context, int framenr)
        ImBuf *ibuf;
        MovieClipUser user = context->user;
 
-       user.framenr = framenr;
+       user.framenr = BKE_movieclip_remap_clip_to_scene_frame(context->clip, framenr);
 
        ibuf = BKE_movieclip_get_ibuf_flag(context->clip, &user, context->clip_flag, MOVIECLIP_CACHE_SKIP);
 
@@ -1399,7 +1401,7 @@ void BKE_tracking_sync_user(MovieClipUser *user, MovieTrackingContext *context)
 int BKE_tracking_next(MovieTrackingContext *context)
 {
        ImBuf *ibuf_new;
-       int curfra = context->user.framenr;
+       int curfra =  BKE_movieclip_remap_scene_to_clip_frame(context->clip, context->user.framenr);
        int a, ok = FALSE, map_size;
 
        map_size = tracks_map_size(context->tracks_map);
@@ -1529,7 +1531,7 @@ int BKE_tracking_next(MovieTrackingContext *context)
                                marker_new.framenr = nextfra;
                                marker_new.flag |= MARKER_DISABLED;
 
-                               #pragma omp critical
+                               //#pragma omp critical
                                {
                                        BKE_tracking_insert_marker(track, &marker_new);
                                }
index f1150d8f00af95eae19d2d6ad1cb7c984cf3b177..8fccae918701901a074217866bd092d715bd29d9 100644 (file)
@@ -7636,42 +7636,53 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                        ntreetype->foreach_nodetree(main, NULL, do_version_ntree_image_user_264);
        }
 
-       /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
-       /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
-       {
-               Scene *scene;
-               // composite redesign
-               for (scene=main->scene.first; scene; scene=scene->id.next) {
-                       if (scene->nodetree) {
-                               if (scene->nodetree->chunksize == 0) {
-                                       scene->nodetree->chunksize = 256;
+       if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 10)) {
+               {
+                       Scene *scene;
+                       // composite redesign
+                       for (scene=main->scene.first; scene; scene=scene->id.next) {
+                               if (scene->nodetree) {
+                                       if (scene->nodetree->chunksize == 0) {
+                                               scene->nodetree->chunksize = 256;
+                                       }
                                }
                        }
                }
-       }
 
-       {
-               bScreen *sc;
+               {
+                       bScreen *sc;
 
-               for (sc = main->screen.first; sc; sc = sc->id.next) {
-                       ScrArea *sa;
+                       for (sc = main->screen.first; sc; sc = sc->id.next) {
+                               ScrArea *sa;
 
-                       for (sa = sc->areabase.first; sa; sa = sa->next) {
-                               SpaceLink *sl;
+                               for (sa = sc->areabase.first; sa; sa = sa->next) {
+                                       SpaceLink *sl;
 
-                               for (sl = sa->spacedata.first; sl; sl = sl->next) {
-                                       if (sl->spacetype == SPACE_CLIP) {
-                                               SpaceClip *sclip = (SpaceClip *)sl;
+                                       for (sl = sa->spacedata.first; sl; sl = sl->next) {
+                                               if (sl->spacetype == SPACE_CLIP) {
+                                                       SpaceClip *sclip = (SpaceClip *)sl;
 
-                                               if (sclip->around == 0) {
-                                                       sclip->around = V3D_CENTROID;
+                                                       if (sclip->around == 0) {
+                                                               sclip->around = V3D_CENTROID;
+                                                       }
                                                }
                                        }
                                }
                        }
                }
+
+               {
+                       MovieClip *clip;
+
+                       for (clip = main->movieclip.first; clip; clip = clip->id.next) {
+                               clip->start_frame = 1;
+                       }
+               }
        }
 
+       /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
+       /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
+
        /* don't forget to set version number in blender.c! */
 }
 
index f7fb1709ce767ad438084051ead40a8da848f83c..6b1028525a7ec1638889b0d0df6db5b5e2dd2e5b 100644 (file)
@@ -60,6 +60,8 @@ void ED_space_clip_zoom(struct SpaceClip *sc, ARegion *ar, float *zoomx, float *
 void ED_space_clip_aspect(struct SpaceClip *sc, float *aspx, float *aspy);
 void ED_space_clip_aspect_dimension_aware(struct SpaceClip *sc, float *aspx, float *aspy);
 
+int ED_space_clip_clip_framenr(struct SpaceClip *sc);
+
 void ED_space_clip_mask_size(struct SpaceClip *sc, int *width, int *height);
 void ED_space_clip_mask_aspect(struct SpaceClip *sc, float *aspx, float *aspy);
 
index d55d32deaa4b007f93d6a1cd9fe098bd50137e5e..62ea0b00ff8da1db491626e24eabdaecfd2202fc 100644 (file)
@@ -155,7 +155,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc
                                else
                                        glColor4ub(255, 255, 0, 96);
 
-                               glRecti((i - sfra) * framelen, 0, (i - sfra + 1)*framelen, 4);
+                               glRecti((i - sfra + clip->start_frame - 1) * framelen, 0, (i - sfra + clip->start_frame) * framelen, 4);
                        }
                }
        }
@@ -183,7 +183,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc
                        }
 
                        if (!ok)
-                               glRecti((i - sfra) * framelen, 0, (i - sfra + 1) * framelen, 8);
+                               glRecti((i - sfra + clip->start_frame - 1) * framelen, 0, (i - sfra + clip->start_frame) * framelen, 8);
                }
        }
 
@@ -338,17 +338,17 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
        int count = sc->path_length;
        int i, a, b, curindex = -1;
        float path[102][2];
-       int tiny = sc->flag & SC_SHOW_TINY_MARKER, framenr;
+       int tiny = sc->flag & SC_SHOW_TINY_MARKER, framenr, start_frame;
        MovieTrackingMarker *marker;
 
        if (count == 0)
                return;
 
-       marker = BKE_tracking_get_marker(track, sc->user.framenr);
-       if (marker->framenr != sc->user.framenr || marker->flag & MARKER_DISABLED)
-               return;
+       start_frame = framenr = ED_space_clip_clip_framenr(sc);
 
-       framenr = marker->framenr;
+       marker = BKE_tracking_get_marker(track, framenr);
+       if (marker->framenr != framenr || marker->flag & MARKER_DISABLED)
+               return;
 
        a = count;
        i = framenr - 1;
@@ -362,7 +362,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
                        add_v2_v2v2(path[--a], marker->pos, track->offset);
                        ED_clip_point_undistorted_pos(sc, path[a], path[a]);
 
-                       if (marker->framenr == sc->user.framenr)
+                       if (marker->framenr == start_frame)
                                curindex = a;
                }
                else {
@@ -381,7 +381,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
                        break;
 
                if (marker->framenr == i) {
-                       if (marker->framenr == sc->user.framenr)
+                       if (marker->framenr == start_frame)
                                curindex = b;
 
                        add_v2_v2v2(path[b++], marker->pos, track->offset);
@@ -924,7 +924,7 @@ static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
 
        if (marker->flag & MARKER_DISABLED)
                strcpy(state, "disabled");
-       else if (marker->framenr != sc->user.framenr)
+       else if (marker->framenr != ED_space_clip_clip_framenr(sc))
                strcpy(state, "estimated");
        else if (marker->flag & MARKER_TRACKED)
                strcpy(state, "tracked");
@@ -972,7 +972,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
        ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
        MovieTrackingTrack *track, *act_track;
        MovieTrackingMarker *marker;
-       int framenr = sc->user.framenr;
+       int framenr = ED_space_clip_clip_framenr(sc);
        int undistort = sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT;
        float *marker_pos = NULL, *fp, *active_pos = NULL, cur_pos[2];
 
index 3349a61cd869e80dd868e60ba87495f3d1f48b3c..ab100b46f70b3aae8bc8a5e3d58902683db85fb2 100644 (file)
@@ -362,6 +362,14 @@ void ED_clip_update_frame(const Main *mainp, int cfra)
        }
 }
 
+/* return current frame number in clip space */
+int ED_space_clip_clip_framenr(SpaceClip *sc)
+{
+       MovieClip *clip = ED_space_clip(sc);
+
+       return BKE_movieclip_remap_scene_to_clip_frame(clip, sc->user.framenr);
+}
+
 static int selected_boundbox(SpaceClip *sc, float min[2], float max[2])
 {
        MovieClip *clip = ED_space_clip(sc);
@@ -547,7 +555,6 @@ typedef struct SpaceClipDrawContext {
 
        /* fields to check if cache is still valid */
        int framenr, start_frame;
-       short custom_start_frame;
 } SpaceClipDrawContext;
 
 int ED_space_clip_texture_buffer_supported(SpaceClip *sc)
@@ -585,14 +592,7 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf)
         * so not changed image buffer pointer means unchanged image content */
        need_rebind |= context->texture_ibuf != ibuf;
        need_rebind |= context->framenr != sc->user.framenr;
-
-       if (clip->flag & MCLIP_CUSTOM_START_FRAME) {
-               need_rebind |= context->custom_start_frame != TRUE;
-               need_rebind |= context->start_frame != clip->start_frame;
-       }
-       else {
-               need_rebind |= context->custom_start_frame != FALSE;
-       }
+       need_rebind |= context->start_frame != clip->start_frame;
 
        if (need_rebind) {
                int width = ibuf->x, height = ibuf->y;
@@ -648,7 +648,6 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf)
                context->image_height = ibuf->y;
                context->framenr = sc->user.framenr;
                context->start_frame = clip->start_frame;
-               context->custom_start_frame = (clip->flag & MCLIP_CUSTOM_START_FRAME) ? TRUE : FALSE;
        }
        else {
                /* displaying exactly the same image which was loaded t oa texture,
index f6dbae596b8d3def7559233b82d01d1f5d40ea14..7073fdb35428f0dd02c35f6b156d743d4ea61384 100644 (file)
@@ -88,10 +88,11 @@ static void add_marker(SpaceClip *sc, float x, float y)
        ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
        MovieTrackingTrack *track;
        int width, height;
+       int framenr = ED_space_clip_clip_framenr(sc);
 
        ED_space_clip_size(sc, &width, &height);
 
-       track = BKE_tracking_add_track(tracking, tracksbase, x, y, sc->user.framenr, width, height);
+       track = BKE_tracking_add_track(tracking, tracksbase, x, y, framenr, width, height);
 
        BKE_tracking_select_track(tracksbase, track, TRACK_AREA_ALL, 0);
 
@@ -202,7 +203,7 @@ static int delete_marker_exec(bContext *C, wmOperator *UNUSED(op))
        MovieClip *clip = ED_space_clip(sc);
        ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
        MovieTrackingTrack *track = tracksbase->first, *next;
-       int framenr = sc->user.framenr;
+       int framenr = ED_space_clip_clip_framenr(sc);
        int has_selection = 0;
 
        while (track) {
@@ -269,8 +270,9 @@ static SlideMarkerData *create_slide_marker_data(SpaceClip *sc, MovieTrackingTra
                        MovieTrackingMarker *marker, wmEvent *event, int area, int action, int width, int height)
 {
        SlideMarkerData *data = MEM_callocN(sizeof(SlideMarkerData), "slide marker data");
+       int framenr = ED_space_clip_clip_framenr(sc);
 
-       marker = BKE_tracking_ensure_marker(track, sc->user.framenr);
+       marker = BKE_tracking_ensure_marker(track, framenr);
 
        data->area = area;
        data->action = action;
@@ -406,6 +408,7 @@ static void *slide_marker_customdata(bContext *C, wmEvent *event)
        float co[2];
        void *customdata = NULL;
        ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
+       int framenr = ED_space_clip_clip_framenr(sc);
 
        ED_space_clip_size(sc, &width, &height);
 
@@ -417,7 +420,7 @@ static void *slide_marker_customdata(bContext *C, wmEvent *event)
        track = tracksbase->first;
        while (track) {
                if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
-                       MovieTrackingMarker *marker = BKE_tracking_get_marker(track, sc->user.framenr);
+                       MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenr);
 
                        if ((marker->flag & MARKER_DISABLED) == 0) {
                                if (!customdata)
@@ -671,7 +674,8 @@ static int mouse_on_rect(float co[2], float pos[2], float min[2], float max[2],
 
 static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *track)
 {
-       MovieTrackingMarker *marker = BKE_tracking_get_marker(track, sc->user.framenr);
+       int framenr = ED_space_clip_clip_framenr(sc);
+       MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenr);
        float epsx, epsy;
        int width, height;
 
@@ -727,10 +731,11 @@ static MovieTrackingTrack *find_nearest_track(SpaceClip *sc, ListBase *tracksbas
 {
        MovieTrackingTrack *track = NULL, *cur;
        float mindist = 0.0f;
+       int framenr = ED_space_clip_clip_framenr(sc);
 
        cur = tracksbase->first;
        while (cur) {
-               MovieTrackingMarker *marker = BKE_tracking_get_marker(cur, sc->user.framenr);
+               MovieTrackingMarker *marker = BKE_tracking_get_marker(cur, framenr);
 
                if (((cur->flag & TRACK_HIDDEN) == 0) && MARKER_VISIBLE(sc, cur, marker)) {
                        float dist, d1, d2 = FLT_MAX, d3 = FLT_MAX;
@@ -879,6 +884,7 @@ static int border_select_exec(bContext *C, wmOperator *op)
        rcti rect;
        rctf rectf;
        int change = FALSE, mode, extend;
+       int framenr = ED_space_clip_clip_framenr(sc);
 
        /* get rectangle from operator */
        rect.xmin = RNA_int_get(op->ptr, "xmin");
@@ -896,7 +902,7 @@ static int border_select_exec(bContext *C, wmOperator *op)
        track = tracksbase->first;
        while (track) {
                if ((track->flag & TRACK_HIDDEN) == 0) {
-                       MovieTrackingMarker *marker = BKE_tracking_get_marker(track, sc->user.framenr);
+                       MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenr);
 
                        if (MARKER_VISIBLE(sc, track, marker)) {
                                if (BLI_in_rctf(&rectf, marker->pos[0], marker->pos[1])) {
@@ -955,6 +961,7 @@ static int do_lasso_select_marker(bContext *C, int mcords[][2], short moves, sho
        ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
        rcti rect;
        int change = FALSE;
+       int framenr = ED_space_clip_clip_framenr(sc);
 
        /* get rectangle from operator */
        BLI_lasso_boundbox(&rect, mcords, moves);
@@ -963,7 +970,7 @@ static int do_lasso_select_marker(bContext *C, int mcords[][2], short moves, sho
        track = tracksbase->first;
        while (track) {
                if ((track->flag & TRACK_HIDDEN) == 0) {
-                       MovieTrackingMarker *marker = BKE_tracking_get_marker(track, sc->user.framenr);
+                       MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenr);
 
                        if (MARKER_VISIBLE(sc, track, marker)) {
                                float screen_co[2];
@@ -1057,6 +1064,7 @@ static int circle_select_exec(bContext *C, wmOperator *op)
        ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
        int x, y, radius, width, height, mode, change = FALSE;
        float zoomx, zoomy, offset[2], ellipse[2];
+       int framenr = ED_space_clip_clip_framenr(sc);
 
        /* get operator properties */
        x = RNA_int_get(op->ptr, "x");
@@ -1078,7 +1086,7 @@ static int circle_select_exec(bContext *C, wmOperator *op)
        track = tracksbase->first;
        while (track) {
                if ((track->flag & TRACK_HIDDEN) == 0) {
-                       MovieTrackingMarker *marker = BKE_tracking_get_marker(track, sc->user.framenr);
+                       MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenr);
 
                        if (MARKER_VISIBLE(sc, track, marker) && marker_inside_ellipse(marker, offset, ellipse)) {
                                BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, mode != GESTURE_MODAL_SELECT);
@@ -1135,7 +1143,7 @@ static int select_all_exec(bContext *C, wmOperator *op)
        MovieTrackingMarker *marker;
        ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
        int action = RNA_enum_get(op->ptr, "action");
-       int framenr = sc->user.framenr;
+       int framenr = ED_space_clip_clip_framenr(sc);
        int has_selection = FALSE;
 
        if (action == SEL_TOGGLE) {
@@ -1225,21 +1233,22 @@ static int select_groped_exec(bContext *C, wmOperator *op)
        MovieTracking *tracking = &clip->tracking;
        ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
        int group = RNA_enum_get(op->ptr, "group");
+       int framenr = ED_space_clip_clip_framenr(sc);
 
        track = tracksbase->first;
        while (track) {
                int ok = FALSE;
 
-               marker = BKE_tracking_get_marker(track, sc->user.framenr);
+               marker = BKE_tracking_get_marker(track, framenr);
 
                if (group == 0) { /* Keyframed */
-                       ok = marker->framenr == sc->user.framenr && (marker->flag & MARKER_TRACKED) == 0;
+                       ok = marker->framenr == framenr && (marker->flag & MARKER_TRACKED) == 0;
                }
                else if (group == 1) { /* Estimated */
-                       ok = marker->framenr != sc->user.framenr;
+                       ok = marker->framenr != framenr;
                }
                else if (group == 2) { /* tracked */
-                       ok = marker->framenr == sc->user.framenr && (marker->flag & MARKER_TRACKED);
+                       ok = marker->framenr == framenr && (marker->flag & MARKER_TRACKED);
                }
                else if (group == 3) { /* locked */
                        ok = track->flag & TRACK_LOCKED;
@@ -1332,7 +1341,7 @@ static int track_count_markers(SpaceClip *sc, MovieClip *clip)
        int tot = 0;
        ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
        MovieTrackingTrack *track;
-       int framenr = sc->user.framenr;
+       int framenr = ED_space_clip_clip_framenr(sc);
 
        track = tracksbase->first;
        while (track) {
@@ -1376,7 +1385,7 @@ static void track_init_markers(SpaceClip *sc, MovieClip *clip, int *frames_limit
 {
        ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
        MovieTrackingTrack *track;
-       int framenr = sc->user.framenr;
+       int framenr = ED_space_clip_clip_framenr(sc);
        int frames_limit = 0;
 
        clear_invisible_track_selection(sc, clip);
@@ -1426,7 +1435,7 @@ static int track_markers_initjob(bContext *C, TrackMarkersJob *tmj, int backward
 
        track_init_markers(sc, clip, &frames_limit);
 
-       tmj->sfra = sc->user.framenr;
+       tmj->sfra = ED_space_clip_clip_framenr(sc);
        tmj->clip = clip;
        tmj->backwards = backwards;
 
@@ -1443,6 +1452,8 @@ static int track_markers_initjob(bContext *C, TrackMarkersJob *tmj, int backward
                        tmj->efra = MIN2(tmj->efra, tmj->sfra + frames_limit);
        }
 
+       tmj->efra = BKE_movieclip_remap_scene_to_clip_frame(clip, tmj->efra);
+
        if (settings->speed != TRACKING_SPEED_FASTEST) {
                tmj->delay = 1.0f / scene->r.frs_sec * 1000.0f;
 
@@ -1527,7 +1538,7 @@ static void track_markers_freejob(void *tmv)
        TrackMarkersJob *tmj = (TrackMarkersJob *)tmv;
 
        tmj->clip->tracking_context = NULL;
-       tmj->scene->r.cfra = tmj->lastfra;
+       tmj->scene->r.cfra = BKE_movieclip_remap_clip_to_scene_frame(tmj->clip, tmj->lastfra);
        ED_update_for_newframe(tmj->main, tmj->scene, 0);
 
        BKE_tracking_sync(tmj->context);
@@ -1544,7 +1555,7 @@ static int track_markers_exec(bContext *C, wmOperator *op)
        MovieClip *clip = ED_space_clip(sc);
        Scene *scene = CTX_data_scene(C);
        struct MovieTrackingContext *context;
-       int framenr = sc->user.framenr;
+       int framenr = ED_space_clip_clip_framenr(sc);
        int sfra = framenr, efra;
        int backwards = RNA_boolean_get(op->ptr, "backwards");
        int sequence = RNA_boolean_get(op->ptr, "sequence");
@@ -1568,6 +1579,8 @@ static int track_markers_exec(bContext *C, wmOperator *op)
                        efra = MIN2(efra, sfra + frames_limit);
        }
 
+       efra = BKE_movieclip_remap_scene_to_clip_frame(clip, efra);
+
        if (!track_markers_check_direction(backwards, framenr, efra))
                return OPERATOR_CANCELLED;
 
@@ -1589,7 +1602,7 @@ static int track_markers_exec(bContext *C, wmOperator *op)
        BKE_tracking_context_free(context);
 
        /* update scene current frame to the lastes tracked frame */
-       scene->r.cfra = framenr;
+       scene->r.cfra = BKE_movieclip_remap_clip_to_scene_frame(clip, framenr);
 
        WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip);
        WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
@@ -1967,16 +1980,17 @@ static int clear_track_path_exec(bContext *C, wmOperator *op)
        ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
        int action = RNA_enum_get(op->ptr, "action");
        int clear_active = RNA_boolean_get(op->ptr, "clear_active");
+       int framenr = ED_space_clip_clip_framenr(sc);
 
        if (clear_active) {
                track = BKE_tracking_active_track(&clip->tracking);
-               BKE_tracking_clear_path(track, sc->user.framenr, action);
+               BKE_tracking_clear_path(track, framenr, action);
        }
        else {
                track = tracksbase->first;
                while (track) {
                        if (TRACK_VIEW_SELECTED(sc, track))
-                               BKE_tracking_clear_path(track, sc->user.framenr, action);
+                               BKE_tracking_clear_path(track, framenr, action);
 
                        track = track->next;
                }
@@ -2023,10 +2037,11 @@ static int disable_markers_exec(bContext *C, wmOperator *op)
        ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
        MovieTrackingTrack *track = tracksbase->first;
        int action = RNA_enum_get(op->ptr, "action");
+       int framenr = ED_space_clip_clip_framenr(sc);
 
        while (track) {
                if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
-                       MovieTrackingMarker *marker = BKE_tracking_ensure_marker(track, sc->user.framenr);
+                       MovieTrackingMarker *marker = BKE_tracking_ensure_marker(track, framenr);
 
                        if (action == 0)
                                marker->flag |= MARKER_DISABLED;
@@ -2945,6 +2960,7 @@ static int detect_features_exec(bContext *C, wmOperator *op)
        int min_trackability = RNA_int_get(op->ptr, "min_trackability");
        int min_distance = RNA_int_get(op->ptr, "min_distance");
        int place_outside_layer = 0;
+       int framenr = ED_space_clip_clip_framenr(sc);
        bGPDlayer *layer = NULL;
 
        if (placement != 0) {
@@ -2961,7 +2977,7 @@ static int detect_features_exec(bContext *C, wmOperator *op)
                track = track->next;
        }
 
-       BKE_tracking_detect_fast(tracking, tracksbase, ibuf, sc->user.framenr, margin,
+       BKE_tracking_detect_fast(tracking, tracksbase, ibuf, framenr, margin,
                                min_trackability, min_distance, layer, place_outside_layer);
 
        IMB_freeImBuf(ibuf);
@@ -3019,7 +3035,8 @@ static int frame_jump_exec(bContext *C, wmOperator *op)
                delta = pos == 1 ? 1 : -1;
 
                while (sc->user.framenr + delta >= SFRA && sc->user.framenr + delta <= EFRA) {
-                       MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, sc->user.framenr + delta);
+                       int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, sc->user.framenr + delta);
+                       MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, framenr);
 
                        if (!marker || marker->flag & MARKER_DISABLED)
                                break;
@@ -3029,7 +3046,7 @@ static int frame_jump_exec(bContext *C, wmOperator *op)
        }
        else {  /* to to failed frame */
                if (clip->tracking.reconstruction.flag & TRACKING_RECONSTRUCTED) {
-                       int a = sc->user.framenr;
+                       int a = ED_space_clip_clip_framenr(sc);
                        MovieTracking *tracking = &clip->tracking;
                        MovieTrackingObject *object = BKE_tracking_active_object(tracking);
 
@@ -3043,7 +3060,7 @@ static int frame_jump_exec(bContext *C, wmOperator *op)
                                cam = BKE_tracking_get_reconstructed_camera(tracking, object, a);
 
                                if (!cam) {
-                                       sc->user.framenr = a;
+                                       sc->user.framenr = BKE_movieclip_remap_clip_to_scene_frame(clip, a);
 
                                        break;
                                }
index 19d97b64f5479da7838cdcf60b3ab0e13a4e6f75..0391afdc18826879e66baa8e1d3b0564eb2c8251 100644 (file)
@@ -5474,7 +5474,8 @@ static void markerToTransDataInit(TransData *td, TransData2D *td2d, TransDataTra
 static void trackToTransData(SpaceClip *sc, TransData *td, TransData2D *td2d,
                              TransDataTracking *tdt, MovieTrackingTrack *track)
 {
-       MovieTrackingMarker *marker = BKE_tracking_ensure_marker(track, sc->user.framenr);
+       int framenr = ED_space_clip_clip_framenr(sc);
+       MovieTrackingMarker *marker = BKE_tracking_ensure_marker(track, framenr);
 
        tdt->flag = marker->flag;
        marker->flag &= ~(MARKER_DISABLED|MARKER_TRACKED);
@@ -5517,7 +5518,7 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
        MovieTrackingTrack *track;
        MovieTrackingMarker *marker;
        TransDataTracking *tdt;
-       int framenr = sc->user.framenr;
+       int framenr = ED_space_clip_clip_framenr(sc);
 
        /* count */
        t->total = 0;
@@ -5747,7 +5748,7 @@ static void cancelTransTracking(TransInfo *t)
        ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
        MovieTrackingTrack *track;
        MovieTrackingMarker *marker;
-       int a, framenr = sc->user.framenr;
+       int a, framenr = ED_space_clip_clip_framenr(sc);
 
        if (tdt->mode == transDataTracking_ModeTracks) {
                track = tracksbase->first;
index 81d532fd24720b15862025b3aba143fbfa451f31..fd7046854ff1b143ba9f054e6f3be389090e60a8 100644 (file)
@@ -123,7 +123,7 @@ typedef struct MovieClipScopes {
 /* MovieClip->flag */
 #define MCLIP_USE_PROXY                                        (1<<0)
 #define MCLIP_USE_PROXY_CUSTOM_DIR             (1<<1)
-#define MCLIP_CUSTOM_START_FRAME               (1<<2)
+/*#define MCLIP_CUSTOM_START_FRAME             (1<<2)*/ /* UNUSED */
 
 #define MCLIP_TIMECODE_FLAGS                   (MCLIP_USE_PROXY|MCLIP_USE_PROXY_CUSTOM_DIR)
 
index 70cb0de643eabaad52f4ad3c485db1168c1b9c61..592e2c9f348545aac586e1e4f36aaf3d8b908011 100644 (file)
@@ -285,17 +285,10 @@ static void rna_def_movieclip(BlenderRNA *brna)
        RNA_def_property_struct_type(prop, "GreasePencil");
        RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this movie clip");
 
-       /* use custom offset */
-       prop = RNA_def_property(srna, "use_custom_start_frame", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "flag", MCLIP_CUSTOM_START_FRAME);
-       RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
-       RNA_def_property_ui_text(prop, "Custom Start Frame", "Use custom first frame offset instead of automatic frame number");
-       RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClip_reload_update");
-
        /* frame offset */
        prop = RNA_def_property(srna, "start_frame", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "start_frame");
-       RNA_def_property_ui_text(prop, "Start Frame", "Number of frame from sequence or movie displaying at scene frame #1");
+       RNA_def_property_ui_text(prop, "Start Frame", "Global scene frame number at which this movie starts playing");
        RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClip_reload_update");
 }