Go to the documentation of this file.
22 for (
register int i = start - 1; i < end; i++)
if (findex[i] != -1) count++;
33 if (init)
for (
int i = 0; i < sfile->
frames; i++) sfile->
frame_index[i] = i + start_offset;
38 static boolean extend_frame_index(
int fileno,
frames_t start,
frames_t end) {
50 for (
int i = start; i < end; i++) sfile->
frame_index[i] = -1;
59 char *fname, *fname_new;
62 if (fileno == 0)
return TRUE;
75 for (i = 0; i < sfile->
frames; i++) {
100 }
while (retval == LIVES_RESPONSE_RETRY);
105 if (retval == LIVES_RESPONSE_CANCEL)
return FALSE;
117 char *fname, *fname_back;
118 boolean backuptried =
FALSE;
160 if (retval == LIVES_RESPONSE_CANCEL) {
166 LiVESResponseType response;
167 char *what = (
_(
"creating the frame index for the clip"));
169 response = LIVES_RESPONSE_OK;
171 if (!
cfile->frame_index) {
174 }
while (response == LIVES_RESPONSE_RETRY);
176 if (response == LIVES_RESPONSE_CANCEL) {
180 for (i = 0; i < sfile->
frames; i++) {
200 LiVESList *list = NULL;
204 if (
THREADVAR(read_failed) == fd + 1)
break;
205 list = lives_list_prepend(list, LIVES_INT_TO_POINTER(vframe));
212 list = lives_list_reverse(list);
222 for (xlist = list; xlist; xlist = xlist->next) {
226 if (list) lives_list_free(list);
227 }}}}
while (retval == LIVES_RESPONSE_RETRY);
249 LIVES_ERROR(
"deleting frame_index with virtual frames in it !");
267 for (i = 0; i < sfile->
frames; i++) {
281 for (
int j = 1; j < nimty; j++) {
284 if (lives_file_test(fname, LIVES_FILE_TEST_EXISTS)) {
302 boolean has_missing_frames =
FALSE, bad_imgfmts =
FALSE;
303 boolean mismatch =
FALSE;
304 boolean isfirst =
TRUE;
305 boolean backup_more_correct =
FALSE;
324 for (i = sfile->
frames - 1; i >= 0; i--) {
327 ximgtype = empirical_img_type;
330 if (!fname || !lives_file_test(fname, LIVES_FILE_TEST_EXISTS)) {
332 for (j = 1; j < nimty; j++) {
334 if (ximgtype == empirical_img_type)
continue;
336 if (lives_file_test(fname, LIVES_FILE_TEST_EXISTS)) {
338 empirical_img_type = ximgtype;
341 if (ximgtype == oemp) empirical_img_type = oemp;
351 has_missing_frames =
TRUE;
353 g_printerr(
"clip %s is missing image frame %d\n", sfile->
handle, i + 1);
371 if (maxframe > cdata->
nframes || has_missing_frames) {
373 if (maxframe > cdata->
nframes) {
374 g_printerr(
"frame count mismatch for clip %d, %s, maxframe is %d, decoder claims only %ld\nRescaning...",
375 fileno, sfile->
handle, maxframe, cdata-> nframes);
379 has_missing_frames =
TRUE;
380 sfile->
frames = scan_frames(sfile, cdata->
nframes, last_real_frame);
382 g_printerr(
"rescan counted %d frames\n.", sfile->
frames);
394 backup_more_correct =
TRUE;
398 for (i = 0; i < xframes; i++) {
405 backup_more_correct =
FALSE;
408 if (backup_more_correct && i < sfile->old_frames) {
412 backup_more_correct =
FALSE;
417 g_printerr(
"bad frame index %d, points to %d.....", i, fr);
419 if (fr < sfile->frames) has_missing_frames =
TRUE;
421 if (lives_file_test(fname, LIVES_FILE_TEST_EXISTS)) {
424 g_printerr(
"relinked to image frame %d\n", i + 1);
427 if (backup_more_correct && i < sfile->old_frames && sfile->
frame_index_back[i] == -1)
428 backup_more_correct =
FALSE;
429 if (lgoodframe != -1) {
432 g_printerr(
"relinked to clip frame %d\n", lgoodframe + i - goodidx);
437 g_printerr(
"reset to clip frame %d\n", i);
444 if (cdata && fr != -1) {
450 if (has_missing_frames && backup_more_correct) {
455 sfile->
frames = scan_frames(sfile, sfile->
frames, last_real_frame);
460 int hsize = sfile->
hsize, chsize = hsize;
461 int vsize = sfile->
vsize, cvsize = vsize;
463 if (last_real_frame > 0) {
465 for (i = last_real_frame; i > 0; i--) {
471 }
else last_img_frame = last_real_frame;
472 if (last_img_frame > -1) {
473 sfile->
img_type = empirical_img_type;
488 if (chsize == hsize && hsize != sfile->
hsize) sfile->
hsize = hsize;
489 if (cvsize == vsize && vsize != sfile->
vsize) sfile->
vsize = vsize;
491 if (last_real_frame > 0) {
492 if (hsize == sfile->
hsize && vsize == sfile->
vsize) {
498 for (i = 1; i < last_real_frame; i++) {
501 if (lives_file_test(fname, LIVES_FILE_TEST_EXISTS)) {
506 has_missing_frames =
TRUE;
514 if (sfile->
hsize != hsize || sfile->
vsize != vsize) {
517 g_printerr(
"incorrect frame size %d X %d, corrected to %d X %d\n", hsize, vsize, sfile->
hsize, sfile->
vsize);
519 if (resp == LIVES_RESPONSE_ACCEPT) {
520 sfile->
hsize = hsize;
521 sfile->
vsize = vsize;
522 }
else if (resp == LIVES_RESPONSE_YES) {
523 int missing = 0, nbadsized = 0;
528 &nbadsized, &missing)) {
529 g_printerr(
"resize detected %d bad sized, %d missing \n", nbadsized, missing);
530 if (missing) has_missing_frames =
TRUE;
532 else mismatch =
TRUE;
537 }
else mismatch =
TRUE;
542 if (resp == LIVES_RESPONSE_OK) {
543 int missing = 0, nbadsized = 0;
547 &nbadsized, &missing)) {
548 g_printerr(
"change fmts detected %d bad sized, %d missing \n", nbadsized, missing);
549 if (missing) has_missing_frames =
TRUE;
551 else mismatch =
TRUE;
556 }
else mismatch =
TRUE;
560 if (has_missing_frames) mismatch =
TRUE;
563 for (i = 0; i < sfile->
frames; i++) {
566 if (lives_file_test(fname, LIVES_FILE_TEST_EXISTS)) {
575 g_printerr(
"fps mismtach, claimed %f, cdata said %f\n", sfile->
fps, cdata->
fps);
579 if (sfile->
img_type != empirical_img_type) {
581 g_printerr(
"corrected image type from %d to %d\n", sfile->
img_type, empirical_img_type);
583 sfile->
img_type = empirical_img_type;
586 if (mismatch)
goto mismatch;
601 if (has_missing_frames) {
603 if (binf->frames == cdata->
nframes && binf->frames < sfile->
frames) sfile->
frames = binf->frames;
604 else if (binf->frames == sfile->
frames && binf->frames < sfile->
frames) {
608 }
else if (binf->frames <= sfile->
frames) sfile->
frames = binf->frames;
610 if (binf->fps == cdata->
fps) {
615 sfile->
img_type = empirical_img_type;
622 if (sfile->
frames > maxframe) extend_frame_index(fileno, maxframe, sfile->
frames);
636 for (
frames_t i = start; i <= end; i++) {
658 for (i = start; i <= end; i++) {
663 if (start > 1 || end < sfile->frames)
return TRUE;
683 #define DS_SPACE_CHECK_FRAMES 100
685 static boolean save_decoded(
int fileno,
frames_t i, LiVESPixbuf * pixbuf,
boolean silent,
int progress) {
689 LiVESError *
error = NULL;
693 retval = LIVES_RESPONSE_NONE;
695 if (
error && !silent) {
697 lives_error_free(
error);
702 }
while (retval == LIVES_RESPONSE_RETRY);
708 retval = LIVES_RESPONSE_CANCEL;
712 if (retval == LIVES_RESPONSE_CANCEL)
return FALSE;
717 #define STRG_CHECK 1000
732 LiVESPixbuf *pixbuf = NULL;
734 int progress = 1, count = 0;
739 if (sframe < 1) sframe = 1;
741 for (i = sframe; i <= eframe; i++) {
742 if (i > sfile->
frames)
break;
757 if (!pixbuf)
return -i;
758 if (!save_decoded(sfileno, i, pixbuf, pbr != NULL, progress)) {
783 if (pbr) *pbr = pixbuf;
789 if (pbr) *pbr = pixbuf;
798 static void restore_gamma_cb(
int gamma_type) {
804 int i, found = -1, progress = 0;
805 boolean is_stored =
FALSE;
810 if (found > -1 && is_stored)
break;
828 ocb->
gamma_type = ncb->gamma_type = gamma_type;
829 for (i = 0; i <
clipboard->frames; i++) {
834 0, 0, 0, LIVES_INTERP_BEST,
FALSE);
836 if (!save_decoded(0, i, pixbuf,
FALSE, progress)) {
860 restore_gamma_cb(
cfile->gamma_type);
865 cfile->progress_start = 1;
879 if (ret <= 0)
return ret;
894 LiVESResponseType response;
902 what = (
_(
"creating the new frame index for the clip"));
909 response = LIVES_RESPONSE_OK;
914 }
while (response == LIVES_RESPONSE_RETRY);
916 if (response == LIVES_RESPONSE_CANCEL) {
924 for (i = where; i < where + frames; i++) {
925 if (frame_index && frame_index[j] != -1) sfile->
frame_index[i] = frame_index[j];
927 if (++j >= sfile->
frames) j = 0;
947 LiVESResponseType response;
949 char *what = (
_(
"creating the new frame index for the clip"));
957 if (nframes - frames == 0) {
963 response = LIVES_RESPONSE_OK;
968 }
while (response == LIVES_RESPONSE_RETRY);
970 if (response == LIVES_RESPONSE_CANCEL) {
979 sfile->
frames = nframes - frames;
1042 for (
frames_t i = oldsframe; i <= oldframes; i++) {
1044 if ((i <= sfile->frames && sfile->
frame_index[i - 1] != -1) || i > sfile->
frames) {
1058 for (
int i = 0; i < nframes; i++) findexc[i] = findex[i + offset];
1074 if (frame < 1 || frame > sfile->
frames)
return FALSE;
1086 LiVESPixbuf *blankp = NULL;
1087 LiVESError *
error = NULL;
1095 for (i = after + 1; i <= sfile->
frames; i++) {
1098 lives_snprintf(oname,
PATH_MAX,
"%s", tmp);
1100 if (lives_file_test(oname, LIVES_FILE_TEST_EXISTS)) {
1102 lives_snprintf(nname,
PATH_MAX,
"%s", tmp);
1111 for (i = after; i < after + nframes; i++) {
1113 lives_snprintf(oname,
PATH_MAX,
"%s", tmp);
1118 char *msg =
lives_strdup_printf(
_(
"Padding: Unable to write blank frame with size %d x %d to %s"),
1122 lives_error_free(
error);
1127 nframes = i - after;
1132 sfile->
frames += nframes;
1143 cfile->fx_frame_pump++;
boolean lives_freep(void **ptr)
boolean create_frame_index(int fileno, boolean init, frames_t start_offset, frames_t nframes)
frames_t first_virtual_frame(int fileno, frames_t start, frames_t end)
LIVES_GLOBAL_INLINE boolean lives_proc_thread_cancelled(lives_proc_thread_t tinfo)
lives_img_type_t resolve_img_type(lives_clip_t *sfile)
lives_interlace_t interlace
interlace type (if known - none, topfirst, bottomfirst or : see plugins.h)
boolean get_frames_sizes(int fileno, int frame_to_test, int *hsize, int *vsize)
#define LIVES_FILE_EXT_BACK
char workdir[PATH_MAX]
kept in locale encoding
volatile boolean is_exiting
set during shutdown (inverse of only_close then)
#define IS_VALID_CLIP(clip)
int lives_cp(const char *from, const char *to)
boolean pull_frame_idle(livespointer data)
int current_palette
plugin should init this to palettes[0] if URI changes
frames_t frames
number of video frames
lives_clip_type_t clip_type
frames_t virtual_to_images(int sfileno, frames_t sframe, frames_t eframe, boolean update_progress, LiVESPixbuf **pbr)
boolean check_clip_integrity(int fileno, const lives_clip_data_t *cdata, frames_t maxframe)
LiVESResponseType do_read_failed_error_s_with_retry(const char *fname, const char *errtext)
weed_plantptr_t lives_proc_thread_t
lives proc_threads API
void restore_frame_index_back(int sfileno)
boolean btgamma
allows clips to be stored with bt709 gamma - CAUTION not backwards compatible, untested
boolean needs_update
loaded values were incorrect, update header
void delete_frames_from_virtual(int sfileno, frames_t start, frames_t end)
@ CANCEL_KILL
normal - kill background processes working on current clip
@ CANCEL_USER
user pressed stop
boolean check_storage_space(int clipno, boolean is_processing)
boolean check_if_non_virtual(int fileno, frames_t start, frames_t end)
LIVES_GLOBAL_INLINE void lives_proc_thread_set_cancellable(lives_proc_thread_t tinfo)
only threads with no return value can possibly be cancellable. For threads with a value,...
void del_frame_index(lives_clip_t *sfile)
int lives_open_buffered_rdonly(const char *pathname)
boolean do_header_write_error(int clip)
void end_threaded_dialog(void)
void threaded_dialog_spin(double fraction)
lives_img_type_t img_type
@ CLIP_TYPE_DISK
imported video, broken into frames
frames_t realize_all_frames(int clipno, const char *msg, boolean enough)
volatile lives_cancel_t cancelled
ssize_t lives_write_le_buffered(int fd, livesconstpointer buf, ssize_t count, boolean allow_fail)
void threaded_dialog_pop(void)
#define MAX_CBSTORES
this is not really used yet, but the idea is that in future the clipboard may be reproduced in variou...
lives_proc_thread_t pumper
int ocp
open_compression_percent : get/set in prefs
void close_current_file(int file_to_switch_to)
close current file, and try to switch to file_to_switch_to
off_t reget_afilesize_inner(int fileno)
int frame_width
frame is the surrounding part, including any black border (>=width)
@ CLIP_TYPE_FILE
unimported video, not or partially broken in frames
int lives_mv(const char *from, const char *to)
frames_t * frame_index
index of frames for CLIP_TYPE_FILE >0 means corresponding frame within original clip -1 means corresp...
int resize_all(int fileno, int width, int height, lives_img_type_t imgtype, boolean do_back, int *nbad, int *nmiss)
utility funcs for GUI
LiVESResponseType do_memory_error_dialog(char *op, size_t bytes)
#define CURRENT_CLIP_HAS_VIDEO
lives_clip_t * clip_forensic(int clipno)
boolean save_frame_index(int fileno)
frames_t load_frame_index(int fileno)
lives_clip_t * files[MAX_FILES+1]
+1 for the clipboard
boolean save_clip_value(int which, lives_clip_details_t, void *val)
int lives_close_buffered(int fd)
_palette * palette
interface colour settings
LIVES_GLOBAL_INLINE ticks_t q_gint64(ticks_t in, double fps)
void update_progress(boolean visible)
off_t sget_file_size(const char *name)
error("LSD_RANDFUNC(ptr, size) must be defined")
frames_t * frame_index_back
for undo
frames_t count_virtual_frames(frames_t *findex, frames_t start, frames_t end)
count virtual frames between start and end (inclusive)
void do_threaded_dialog(const char *trans_text, boolean has_cancel)
#define lives_strdup_printf(fmt,...)
boolean deinterlace
auto deinterlace
int lives_create_buffered(const char *pathname, int mode)
int hsize
frame width (horizontal) in pixels (NOT macropixels !)
LiVESPixbuf * lives_pixbuf_new_blank(int width, int height, int palette)
void close_clip_decoder(int clipno)
boolean is_virtual_frame(int sfileno, frames_t frame)
frames_t old_frames
for deordering, etc.
LiVESResponseType do_write_failed_error_s_with_retry(const char *fname, const char *errtext)
ssize_t lives_read_le_buffered(int fd, void *buf, ssize_t count, boolean allow_less)
char * make_image_file_name(lives_clip_t *clip, frames_t frame, const char *img_ext)
lives_image_type can be a string, lives_img_type_t is an enumeration
void clean_images_from_virtual(lives_clip_t *sfile, frames_t oldsframe, frames_t oldframes)
void insert_images_in_virtual(int sfileno, frames_t where, frames_t frames, frames_t *frame_index, frames_t start)
LIVES_GLOBAL_INLINE LiVESResponseType do_imgfmts_error(lives_img_type_t imgtype)
const char * get_image_ext_for_type(lives_img_type_t imgtype)
LIVES_GLOBAL_INLINE LiVESResponseType do_resize_dlg(int cwidth, int cheight, int fwidth, int fheight)
double pb_fps
current playback rate, may vary from fps, can be 0. or negative
#define DS_SPACE_CHECK_FRAMES
void insert_blank_frames(int sfileno, frames_t nframes, frames_t after, int palette)
void reverse_frame_index(int sfileno)
void init_clipboard(void)
lives_clip_t * cbstores[8]
int vsize
frame height (vertical) in pixels
@ CANCEL_SOFT
just cancel in GUI (for keep, etc)
corresponds to one clip in the GUI
void threaded_dialog_push(void)
lives_cancel_type_t cancel_type
#define FRAME_INDEX_FNAME
LiVESPixbuf * pull_lives_pixbuf_at_size(int clip, int frame, const char *image_ext, weed_timecode_t tc, int width, int height, LiVESInterpType interp, boolean fordisp)
LIVES_GLOBAL_INLINE boolean findex_bk_dialog(const char *fname_back)
#define DEF_FILE_PERMS
non-executable, is modified by the umask
LIVES_GLOBAL_INLINE int weed_palette_get_pixels_per_macropixel(int pal)
int lives_rm(const char *file)
frames_t * frame_index_copy(frames_t *findex, frames_t nframes, frames_t offset)
boolean lives_pixbuf_save(LiVESPixbuf *pixbuf, char *fname, lives_img_type_t imgtype, int quality, int width, int height, LiVESError **gerrorptr)
Save a pixbuf to a file using the specified imgtype and the specified quality/compression value.
#define MAINW_MSG_SIZE
mainw->msg bytesize