void load_framedraw_image(LiVESPixbuf *pixbuf) { // this is for the single frame framedraw widget // it should be called whenever mainw->framedraw_bitmap changes weed_timecode_t tc; if (mainw->framedraw_frame>cfile->frames) mainw->framedraw_frame=cfile->frames; if (pixbuf==NULL) { const char *img_ext=get_image_ext_for_type(cfile->img_type); // can happen if we preview for rendered generators if ((mainw->multitrack==NULL||mainw->current_file!=mainw->multitrack->render_file)&&mainw->framedraw_frame==0) return; tc=((mainw->framedraw_frame-1.))/cfile->fps*U_SECL; pixbuf=pull_lives_pixbuf_at_size(mainw->current_file,mainw->framedraw_frame,img_ext,tc, (double)cfile->hsize,(double)cfile->vsize, LIVES_INTERP_BEST); } if (pixbuf!=NULL) { if (mainw->fd_layer_orig!=NULL) { weed_layer_free(mainw->fd_layer_orig); } mainw->fd_layer_orig=weed_layer_new(0,0,NULL,WEED_PALETTE_END); if (!pixbuf_to_layer(mainw->fd_layer_orig,pixbuf)) lives_object_unref(pixbuf); } if (mainw->fd_layer!=NULL) weed_layer_free(mainw->fd_layer); mainw->fd_layer=NULL; }
void load_framedraw_image(LiVESPixbuf *pixbuf) { // this is for the single frame framedraw widget // it should be called whenever mainw->framedraw_bitmap changes weed_timecode_t tc; boolean needs_unlock=FALSE; if (mainw->framedraw_frame>cfile->frames) mainw->framedraw_frame=cfile->frames; if (pixbuf==NULL) { const char *img_ext=get_image_ext_for_type(cfile->img_type); // can happen if we preview for rendered generators if ((mainw->multitrack==NULL||mainw->current_file!=mainw->multitrack->render_file)&&mainw->framedraw_frame==0) return; tc=((mainw->framedraw_frame-1.))/cfile->fps*U_SECL; pixbuf=pull_lives_pixbuf_at_size(mainw->current_file,mainw->framedraw_frame,img_ext,tc, (double)cfile->hsize,(double)cfile->vsize, LIVES_INTERP_BEST); } if (pixbuf!=NULL) { if (mainw->fd_layer_orig!=NULL) { weed_layer_free(mainw->fd_layer_orig); } mainw->fd_layer_orig=weed_layer_new(0,0,NULL,WEED_PALETTE_END); if (pixbuf_to_layer(mainw->fd_layer_orig,pixbuf)) { mainw->do_not_free=(livespointer)lives_pixbuf_get_pixels_readonly(pixbuf); // might be threaded here so we need a mutex to stop other thread resetting free_fn pthread_mutex_lock(&mainw->free_fn_mutex); needs_unlock=TRUE; mainw->free_fn=_lives_free_with_check; } lives_object_unref(pixbuf); mainw->do_not_free=NULL; mainw->free_fn=_lives_free_normal; if (needs_unlock) pthread_mutex_unlock(&mainw->free_fn_mutex); } if (mainw->fd_layer!=NULL) weed_layer_free(mainw->fd_layer); mainw->fd_layer=NULL; }
boolean virtual_to_images(int sfileno, int sframe, int eframe, boolean update_progress, LiVESPixbuf **pbr) { // pull frames from a clip to images // from sframe to eframe inclusive (first frame is 1) // if update_progress, set mainw->msg with number of frames pulled // should be threadsafe apart from progress update // if pbr is non-null, it will be set to point to the pulled pixbuf ( // return FALSE on write error register int i; lives_clip_t *sfile=mainw->files[sfileno]; LiVESPixbuf *pixbuf=NULL; LiVESError *error=NULL; char *oname; int retval; int progress=1; if (sframe<1) sframe=1; for (i=sframe; i<=eframe; i++) { if (i>sfile->frames) break; if (sfile->frame_index[i-1]>=0) { oname=NULL; if (update_progress) { threaded_dialog_spin(); lives_widget_context_update(); } if (pbr!=NULL&&pixbuf!=NULL) lives_object_unref(pixbuf); pixbuf=pull_lives_pixbuf_at_size(sfileno,i,get_image_ext_for_type(sfile->img_type), q_gint64((i-1.)/sfile->fps,sfile->fps),sfile->hsize,sfile->vsize,LIVES_INTERP_BEST); oname=lives_strdup_printf("%s/%s/%08d.%s",prefs->tmpdir,sfile->handle,i,get_image_ext_for_type(sfile->img_type)); do { retval=0; lives_pixbuf_save(pixbuf, oname, sfile->img_type, 100-prefs->ocp, TRUE, &error); if (error!=NULL&&pbr==NULL) { retval=do_write_failed_error_s_with_retry(oname,error->message,NULL); lives_error_free(error); error=NULL; } } while (retval==LIVES_RESPONSE_RETRY); if (oname!=NULL) lives_free(oname); if (pbr==NULL) { if (pixbuf!=NULL) lives_object_unref(pixbuf); pixbuf=NULL; } if (retval==LIVES_RESPONSE_CANCEL) return FALSE; // another thread may have called check_if_non_virtual - TODO : use a mutex if (sfile->frame_index==NULL) break; sfile->frame_index[i-1]=-1; if (update_progress) { // sig_progress... lives_snprintf(mainw->msg,256,"%d",progress++); threaded_dialog_spin(); lives_widget_context_update(); } if (mainw->cancelled!=CANCEL_NONE) { if (!check_if_non_virtual(sfileno,1,sfile->frames)) save_frame_index(sfileno); if (pbr!=NULL) *pbr=pixbuf; return TRUE; } } } if (pbr!=NULL) *pbr=pixbuf; if (!check_if_non_virtual(sfileno,1,sfile->frames)) if (!save_frame_index(sfileno)) return FALSE; return TRUE; }