r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / resourcepixmap.C
blob5840f07d1a0077d2c198e5310f9fc08539865b4d
1 #include "aedit.h"
2 #include "assets.h"
3 #include "assets.inc"
4 #include "cache.h"
5 #include "clip.h"
6 #include "colormodels.h"
7 #include "datatype.h"
8 #include "edit.h"
9 #include "edits.h"
10 #include "edl.h"
11 #include "edlsession.h"
12 #include "file.h"
13 #include "filesystem.h"
14 #include "indexfile.h"
15 #include "localsession.h"
16 #include "mwindow.h"
17 #include "resourcepixmap.h"
18 #include "theme.h"
19 #include "track.h"
20 #include "trackcanvas.h"
21 #include "vedit.h"
22 #include "vframe.h"
25 #include <libintl.h>
26 #define _(String) gettext(String)
27 #define gettext_noop(String) String
28 #define N_(String) gettext_noop (String)
31 ResourcePixmap::ResourcePixmap(MWindow *mwindow, 
32         TrackCanvas *canvas, 
33         Edit *edit, 
34         int w, 
35         int h)
36  : BC_Pixmap(canvas, w, h)
38         reset();
40         this->mwindow = mwindow;
41         this->canvas = canvas;
42         startsource = edit->startsource;
43         data_type = edit->track->data_type;
44         source_framerate = edit->asset->frame_rate;
45         project_framerate = edit->edl->session->frame_rate;
46         source_samplerate = edit->asset->sample_rate;
47         project_samplerate = edit->edl->session->sample_rate;
48         edit_id = edit->id;
51 ResourcePixmap::~ResourcePixmap()
56 void ResourcePixmap::reset()
58         edit_x = 0;
59         pixmap_x = 0;
60         pixmap_w = 0;
61         pixmap_h = 0;
62         zoom_sample = 0;
63         zoom_track = 0;
64         zoom_y = 0;
65         visible = 1;
67         
68 void ResourcePixmap::resize(int w, int h)
70         int new_w = (w > get_w()) ? w : get_w();
71         int new_h = (h > get_h()) ? h : get_h();
73         BC_Pixmap::resize(new_w, new_h);
76 void ResourcePixmap::draw_data(Edit *edit,
77         int64_t edit_x,
78         int64_t edit_w, 
79         int64_t pixmap_x, 
80         int64_t pixmap_w,
81         int64_t pixmap_h,
82         int force,
83         int indexes_only)
85 // Get new areas to fill in relative to pixmap
86 // Area to redraw relative to pixmap
87         int refresh_x = 0, refresh_w = 0;
88         int64_t index_zoom = 0;
90 //printf("ResourcePixmap::draw_data 1\n");
91         if(indexes_only)
92         {
93                 IndexFile indexfile(mwindow);
94                 if(!indexfile.open_index(edit->asset))
95                 {
96                         index_zoom = edit->asset->index_zoom;
97                         indexfile.close_index();
98                 }
99         }
101 //printf("ResourcePixmap::draw_data 10\n");
102         int y = 0;
103         if(mwindow->edl->session->show_titles) y += mwindow->theme->title_bg_data->get_h();
104         Track *track = edit->edits->track;
106 //printf("ResourcePixmap::draw_data 20\n");
109 // Redraw everything
110         if(edit->startsource != this->startsource ||
111                 (data_type == TRACK_AUDIO && 
112                         edit->asset->sample_rate != source_samplerate) ||
113                 (data_type == TRACK_VIDEO && 
114                         !EQUIV(edit->asset->frame_rate, source_framerate)) ||
115                 mwindow->edl->session->sample_rate != project_samplerate ||
116                 mwindow->edl->session->frame_rate != project_framerate ||
117                 mwindow->edl->local_session->zoom_sample != zoom_sample || 
118                 mwindow->edl->local_session->zoom_track != zoom_track ||
119                 this->pixmap_h != pixmap_h ||
120                 (data_type == TRACK_AUDIO && 
121                         mwindow->edl->local_session->zoom_y != zoom_y) ||
122                 force ||
123                 (indexes_only && mwindow->edl->local_session->zoom_sample >= index_zoom))
124         {
125                 refresh_x = 0;
126                 refresh_w = pixmap_w;
127         }
128         else
129         {
130 // Start translated right
131                 if(pixmap_w == this->pixmap_w && edit_x < this->edit_x && edit_w != pixmap_w)
132                 {
133                         refresh_w = this->edit_x - edit_x;
134                         refresh_x = this->pixmap_w - refresh_w;
136 // Moved completely off the pixmap
137                         if(refresh_w > this->pixmap_w)
138                         {
139                                 refresh_w = this->pixmap_w;
140                                 refresh_x = 0;
141                         }
142                         else
143                         {
144                                 copy_area(refresh_w, 
145                                         y, 
146                                         refresh_x, 
147                                         mwindow->edl->local_session->zoom_track, 
148                                         0, 
149                                         y);
150                         }
151                 }
152                 else
153 // Start translated left
154                 if(pixmap_w == this->pixmap_w && edit_x > this->edit_x && edit_w != pixmap_w)
155                 {
156                         refresh_x = 0;
157                         refresh_w = edit_x - this->edit_x;
159 // Moved completely off the pixmap
160                         if(refresh_w > this->pixmap_w)
161                         {
162                                 refresh_w = this->pixmap_w;
163                         }
164                         else
165                         {
166                                 copy_area(0, 
167                                         y, 
168                                         this->pixmap_w - refresh_w, 
169                                         mwindow->edl->local_session->zoom_track, 
170                                         refresh_w, 
171                                         y);
172                         }
173                 }
174                 else
175 // Start translated right and pixmap came off of right side
176                 if(pixmap_w < this->pixmap_w && edit_x < this->edit_x && 
177                         this->edit_x + edit_w > this->pixmap_x + this->pixmap_w)
178                 {
179                         refresh_w = (this->edit_x + edit_w) - (this->pixmap_x + this->pixmap_w);
180                         refresh_x = pixmap_w - refresh_w;
181                         
182                         if(refresh_w >= pixmap_w)
183                         {
184                                 refresh_x = 0;
185                                 refresh_w = pixmap_w;
186                         }
187                         else
188                         {
189                                 copy_area(this->edit_x - edit_x, 
190                                         y, 
191                                         pixmap_w - refresh_w, 
192                                         mwindow->edl->local_session->zoom_track, 
193                                         0, 
194                                         y);
195                         }
196                 }
197                 else
198 // Start translated right and reduced in size on the right.
199                 if(pixmap_w < this->pixmap_w && edit_x < this->edit_x)
200                 {
201                         refresh_x = 0;
202                         refresh_w = 0;
204                         copy_area(this->pixmap_w - pixmap_w, 
205                                 y, 
206                                 pixmap_w, 
207                                 mwindow->edl->local_session->zoom_track, 
208                                 0, 
209                                 y);
210                 }
211                 else
212 // Start translated left and pixmap came off left side
213                 if(edit_x >= 0 && this->edit_x < 0)
214                 {
215                         refresh_x = 0;
216                         refresh_w = -this->edit_x;
218                         if(refresh_w > pixmap_w)
219                         {
220                                 refresh_w = pixmap_w;
221                         }
222                         else
223                         {
224                                 copy_area(0, 
225                                                 y, 
226                                                 this->pixmap_w, 
227                                                 mwindow->edl->local_session->zoom_track, 
228                                                 refresh_w, 
229                                                 y);
230                         }
231                 }
232                 else
233 // Start translated left and reduced in size on the right
234                 if(pixmap_w < this->pixmap_w && edit_x > this->edit_x)
235                 {
236                         refresh_x = 0;
237                         refresh_w = 0;
238                 }
239                 else
240 // Start translated right and left went into left side.
241                 if(pixmap_w > this->pixmap_w && edit_x < 0 && this->edit_x > 0)
242                 {
243                         refresh_w = pixmap_w - (edit_x + this->pixmap_w);
244                         refresh_x = pixmap_w - refresh_w;
246 // Moved completely off new pixmap
247                         if(refresh_w > pixmap_w)
248                         {
249                                 refresh_w = pixmap_w;
250                                 refresh_x = 0;
251                         }
252                         else
253                         {
254                                 copy_area(-edit_x, 
255                                         y,
256                                         refresh_x,
257                                         mwindow->edl->local_session->zoom_track,
258                                         0,
259                                         y);
260                         }
261                 }
262                 else
263 // Start translated right and increased in size on the right
264                 if(pixmap_w > this->pixmap_w && edit_x <= this->edit_x)
265                 {
266                         refresh_w = pixmap_w - this->pixmap_w;
267                         refresh_x = pixmap_w - refresh_w;
268                 }
269                 else
270 // Start translated left and increased in size on the right
271                 if(pixmap_w > this->pixmap_w && edit_x > this->edit_x)
272                 {
273                         refresh_x = 0;
274                         refresh_w = edit_x - this->edit_x;
276 // Moved completely off new pixmap
277                         if(refresh_w > this->pixmap_w)
278                         {
279                                 refresh_w = pixmap_w;
280                                 refresh_x = 0;
281                         }
282 // Shift and insert
283                         else
284                         {
285                                 copy_area(0, 
286                                         y,
287                                         this->pixmap_w,
288                                         mwindow->edl->local_session->zoom_track,
289                                         refresh_w,
290                                         y);
291                         }
292                 }
293         }
295 //printf("ResourcePixmap::draw_data 50\n");
296 // Update pixmap settings
297         this->edit_id = edit->id;
298         this->startsource = edit->startsource;
299         this->source_framerate = edit->asset->frame_rate;
300         this->source_samplerate = edit->asset->sample_rate;
301         this->project_framerate = edit->edl->session->frame_rate;
302         this->project_samplerate = edit->edl->session->sample_rate;
303         this->edit_x = edit_x;
304         this->pixmap_x = pixmap_x;
305         this->pixmap_w = pixmap_w;
306         this->pixmap_h = pixmap_h;
307         this->zoom_sample = mwindow->edl->local_session->zoom_sample;
308         this->zoom_track = mwindow->edl->local_session->zoom_track;
309         this->zoom_y = mwindow->edl->local_session->zoom_y;
310 //printf("ResourcePixmap::draw_data 2 refresh_x1=%d refresh_w1=%d refresh_x2=%d refresh_w2=%d\n", 
311 //      refresh_x1, refresh_w1, refresh_x2, refresh_w2);
314 //printf("ResourcePixmap::draw_data 60\n");
316 // Draw in new background
317         if(refresh_w > 0)
318                 mwindow->theme->draw_resource_bg(canvas,
319                         this, 
320                         edit_x,
321                         edit_w,
322                         pixmap_x,
323                         refresh_x, 
324                         y,
325                         refresh_x + refresh_w,
326                         mwindow->edl->local_session->zoom_track + y);
327 //printf("ResourcePixmap::draw_data 70\n");
330 // Draw media
331         if(track->draw)
332         {
333                 switch(track->data_type)
334                 {
335                         case TRACK_AUDIO:
336 //printf("ResourcePixmap::draw_data 4\n");
337                                 draw_audio_resource(edit, refresh_x, refresh_w);
338 //printf("ResourcePixmap::draw_data 5\n");
339                                 break;
341                         case TRACK_VIDEO:
342 //printf("ResourcePixmap::draw_data 6\n");
343                                 draw_video_resource(edit, 
344                                         edit_x, 
345                                         edit_w, 
346                                         pixmap_x,
347                                         pixmap_w,
348                                         refresh_x, 
349                                         refresh_w);
350 //printf("ResourcePixmap::draw_data 7\n");
351                                 break;
352                 }
353         }
355 // Draw title
356         if(mwindow->edl->session->show_titles)
357                 draw_title(edit, edit_x, edit_w, pixmap_x, pixmap_w);
359 //printf("ResourcePixmap::draw_data 3 refresh_x=%d refresh_w=%d\n", 
360 //refresh_x, 
361 //refresh_w);
362 //printf("ResourcePixmap::draw_data 10\n");
365 void ResourcePixmap::draw_title(Edit *edit,
366         int64_t edit_x, 
367         int64_t edit_w, 
368         int64_t pixmap_x, 
369         int64_t pixmap_w)
371 // coords relative to pixmap
372         int64_t total_x = edit_x - pixmap_x, total_w = edit_w;
373         int64_t x = total_x, w = total_w;
374         int left_margin = 10;
376         if(x < 0) 
377         {
378                 w -= -x;
379                 x = 0;
380         }
381         if(w > pixmap_w) w -= w - pixmap_w;
383         canvas->draw_3segmenth(x, 
384                 0, 
385                 w, 
386                 total_x,
387                 total_w,
388                 mwindow->theme->title_bg_data,
389                 this);
391         if(total_x > -BC_INFINITY)
392         {
393                 char title[BCTEXTLEN], channel[BCTEXTLEN];
394                 FileSystem fs;
395                 fs.extract_name(title, edit->asset->path);
397                 sprintf(channel, " #%d", edit->channel + 1);
398                 strcat(title, channel);
400                 canvas->set_color(mwindow->theme->title_color);
401                 canvas->set_font(mwindow->theme->title_font);
402 //printf("ResourcePixmap::draw_title 1 %d\n", total_x + 10);
403                 
404 // Justify the text on the left boundary of the edit if it is visible.
405 // Otherwise justify it on the left side of the screen.
406                 int text_x = total_x + left_margin;
407                 text_x = MAX(left_margin, text_x);
408                 canvas->draw_text(text_x, 
409                         canvas->get_text_ascent(MEDIUMFONT_3D) + 2, 
410                         title,
411                         strlen(title),
412                         this);
413         }
417 // Need to draw one more x
418 void ResourcePixmap::draw_audio_resource(Edit *edit, int x, int w)
420         if(w <= 0) return;
421         double asset_over_session = (double)edit->asset->sample_rate / 
422                 mwindow->edl->session->sample_rate;
424 // Develop strategy for drawing
425         switch(edit->asset->index_status)
426         {
427                 case INDEX_NOTTESTED:
428                         return;
429                         break;
430 // Disabled.  Always draw from index.
431                 case INDEX_TOOSMALL:
432                         draw_audio_source(edit, x, w);
433                         break;
434                 case INDEX_BUILDING:
435                 case INDEX_READY:
436                 {
437                         IndexFile indexfile(mwindow);
438                         if(!indexfile.open_index(edit->asset))
439                         {
440                                 if(edit->asset->index_zoom > 
441                                         mwindow->edl->local_session->zoom_sample * 
442                                         asset_over_session)
443                                         draw_audio_source(edit, x, w);
444                                 else
445                                         indexfile.draw_index(this, edit, x, w);
446                                 indexfile.close_index();
447                         }
448                         break;
449                 }
450         }
470 void ResourcePixmap::draw_audio_source(Edit *edit, int x, int w)
472         File *source = mwindow->audio_cache->check_out(edit->asset);
474         if(!source)
475         {
476                 printf(_("ResourcePixmap::draw_audio_source: failed to check out %s for drawing.\n"), edit->asset->path);
477                 return;
478         }
480         w++;
481         int64_t source_start = (pixmap_x - edit_x + x) * mwindow->edl->local_session->zoom_sample + edit->startsource;
482         int64_t source_len = w * mwindow->edl->local_session->zoom_sample;
483         int center_pixel = mwindow->edl->local_session->zoom_track / 2;
484         if(mwindow->edl->session->show_titles) center_pixel += mwindow->theme->title_bg_data->get_h();
485         double asset_over_session = (double)edit->asset->sample_rate / 
486                 mwindow->edl->session->sample_rate;
488 // Single sample zoom
489         if(mwindow->edl->local_session->zoom_sample == 1)
490         {
491                 double oldsample, newsample;
492                 int64_t total_source_samples = (int64_t)((double)(source_len + 1) * 
493                         asset_over_session);
494                 double *buffer = new double[total_source_samples];
496                 source->set_audio_position((int)((double)source_start *
497                                 asset_over_session), 
498                         edit->asset->sample_rate);
499                 source->set_channel(edit->channel);
500                 canvas->set_color(mwindow->theme->audio_color);
502                 if(!source->read_samples(buffer, 
503                         total_source_samples, 
504                         edit->asset->sample_rate))
505                 {
506                         oldsample = newsample = *buffer;
507                         for(int x1 = x, x2 = x + w, i = 0; 
508                                 x1 < x2; 
509                                 x1++, i++)
510                         {
511                                 oldsample = newsample;
512                                 newsample = buffer[(int64_t)(i * asset_over_session)];
513                                 canvas->draw_line(x1 - 1, 
514                                         (int)(center_pixel - oldsample * mwindow->edl->local_session->zoom_y / 2),
515                                         x1,
516                                         (int)(center_pixel - newsample * mwindow->edl->local_session->zoom_y / 2),
517                                         this);
518                         }
519                 }
521                 delete [] buffer;
522         }
523         else
524 // Multiple sample zoom
525         {
526                 int64_t fragmentsize;
527                 int64_t buffersize = fragmentsize = 65536;
528                 double *buffer = new double[buffersize + 1];
529                 double highsample, lowsample;
530                 float sample_of_pixel = 0;
531                 int64_t total_source_samples = (int64_t)(source_len * asset_over_session);
532                 double asset_samples_per_pixel = 
533                         mwindow->edl->local_session->zoom_sample *
534                         asset_over_session;
535                 int first_pixel = 1;
536                 int prev_y1 = -1;
537                 int prev_y2 = -1;
538                 int y1;
539                 int y2;
541                 source->set_audio_position((int64_t)(source_start * asset_over_session), 
542                         edit->asset->sample_rate);
543                 source->set_channel(edit->channel);
544                 canvas->set_color(mwindow->theme->audio_color);
546                 for(int64_t source_sample = 0; 
547                         source_sample < total_source_samples; 
548                         source_sample += buffersize)
549                 {
550                         fragmentsize = buffersize;
551                         if(total_source_samples - source_sample < buffersize)
552                                 fragmentsize = total_source_samples - source_sample;
554                         if(source_sample == 0)
555                         {
556                                 highsample = buffer[0];
557                                 lowsample = buffer[0];
558                         }
560                         if(!source->read_samples(buffer, 
561                                 fragmentsize, 
562                                 edit->asset->sample_rate))
563                         {
566 // Draw samples for this buffer
567                                 for(int64_t bufferposition = 0; 
568                                         bufferposition < fragmentsize; 
569                                         bufferposition++)
570                                 {
571 // Replicate
572                                         if(asset_samples_per_pixel < 1)
573                                         {
574                                                 int x1 = x;
575                                                 int x2 = (int)(x + 1 / asset_samples_per_pixel);
577                                                 highsample = lowsample = buffer[bufferposition];
578                                                 y1 = (int)(center_pixel - 
579                                                                 highsample * 
580                                                                 mwindow->edl->local_session->zoom_y / 
581                                                                 2);
582                                                 y2 = (int)(center_pixel - 
583                                                                 lowsample * 
584                                                                 mwindow->edl->local_session->zoom_y / 
585                                                                 2);
586                                                 canvas->draw_line(
587                                                         x1, 
588                                                         y1,
589                                                         x2,
590                                                         y2,
591                                                         this);
592                                         }
593                                         else
594                                         if(asset_samples_per_pixel >= 1 &&
595                                                 sample_of_pixel >= asset_samples_per_pixel)
596                                         {
597 // Draw column and reset
598                                                 y1 = (int)(center_pixel - 
599                                                         highsample * 
600                                                         mwindow->edl->local_session->zoom_y / 
601                                                         2);
602                                                 y2 = (int)(center_pixel - 
603                                                         lowsample * 
604                                                         mwindow->edl->local_session->zoom_y / 
605                                                         2);
607                                                 int current_y1;
608                                                 int current_y2;
609                                                 if(first_pixel)
610                                                 {
611                                                         canvas->draw_line(x, 
612                                                                 y1,
613                                                                 x,
614                                                                 y2,
615                                                                 this);
616                                                         first_pixel = 0;
617                                                 }
618                                                 else
619                                                         canvas->draw_line(x, 
620                                                                 MIN(y1, prev_y2),
621                                                                 x,
622                                                                 MAX(y2, prev_y1),
623                                                                 this);
624                                                 sample_of_pixel -= asset_samples_per_pixel;
625                                                 x++;
626                                                 lowsample = highsample = buffer[bufferposition];
627                                                 prev_y1 = y1;
628                                                 prev_y2 = y2;
629                                         }
631                                         if(sample_of_pixel >= 1)
632                                         {
633 // update lowsample and highsample
634                                                 if(buffer[bufferposition] < lowsample) 
635                                                         lowsample = buffer[bufferposition];
636                                                 else 
637                                                 if(buffer[bufferposition] > highsample) 
638                                                         highsample = buffer[bufferposition];
639                                         }
642                                         sample_of_pixel++;
643                                 }
649                         }
650                 }
651                 delete [] buffer;
652         }
654         mwindow->audio_cache->check_in(edit->asset);
676 void ResourcePixmap::draw_video_resource(Edit *edit, 
677         int64_t edit_x, 
678         int64_t edit_w, 
679         int64_t pixmap_x,
680         int64_t pixmap_w,
681         int refresh_x, 
682         int refresh_w)
684 //printf("ResourcePixmap::draw_video_resource 1\n");
685 // pixels spanned by a picon
686         int64_t picon_w = Units::round(edit->picon_w());
687         int64_t picon_h = edit->picon_h();
689 //printf("ResourcePixmap::draw_video_resource 1\n");
690 // Don't draw video if picon is bigger than edit
691         if(picon_w > edit_w) return;
693 //printf("ResourcePixmap::draw_video_resource 1\n");
694 // pixels spanned by a frame
695         double frame_w = edit->frame_w();
697 //printf("ResourcePixmap::draw_video_resource 1\n");
698 // Frames spanned by a picon
699         double frames_per_picon = edit->frames_per_picon();
701 //printf("ResourcePixmap::draw_video_resource 1\n");
702 // Current pixel relative to pixmap
703         int x = 0;
704         int y = 0;
705         if(mwindow->edl->session->show_titles) 
706                 y += mwindow->theme->title_bg_data->get_h();
707 // Frame in project touched by current pixel
708         int64_t project_frame;
710 //printf("ResourcePixmap::draw_video_resource 1\n");
711 // Get first frame touched by x and fix x to start of frame
712         if(frames_per_picon > 1)
713         {
714                 int picon = Units::to_int64((double)(refresh_x + pixmap_x - edit_x) / picon_w);
715                 x = picon_w * picon + edit_x - pixmap_x;
716                 project_frame = Units::to_int64((double)picon * frames_per_picon);
717         }
718         else
719         {
720                 project_frame = Units::to_int64((double)(refresh_x + pixmap_x - edit_x) / 
721                         frame_w);
722                 x = Units::round((double)project_frame * frame_w + edit_x - pixmap_x);
723         }
725 //printf("ResourcePixmap::draw_video_resource 1 %s\n", edit->asset->path);
726         File *source = mwindow->video_cache->check_out(edit->asset);
727 //printf("ResourcePixmap::draw_video_resource 2\n");
728         if(!source) return;
731 //printf("ResourcePixmap::draw_video_resource 2 project_frame=%d frame_w=%f refresh_x=%d refresh_w=%d x=%d\n",
732 //project_frame, frame_w, refresh_x, refresh_w, x);
733         while(x < refresh_x + refresh_w)
734         {
735                 int cache_hit; // so we know whether to relase a lock at the end or was it already
736                 VFrame *final_picon_frame;
737                 int64_t source_frame = project_frame + edit->startsource;
738                 source->set_layer(edit->channel);
739                 source->set_video_position(source_frame, 
740                         mwindow->edl->session->frame_rate);
741 //printf("ResourcePixmap::draw_video_resource 3 %p\n", source);
742 //              VFrame *src = source->read_frame(BC_RGB888);
743 //printf("ResourcePixmap::draw_video_resource 4 %p\n", src);
744                 source->frames_cache->enable_cache();           // we do enabling and disabling of cache 
745                                                                 // on our own, so File doesn't use it's own caching
746                 if ((final_picon_frame = source->frames_cache->get_frame(source->current_frame,
747                                                                         source->current_layer,
748                                                                         picon_w,
749                                                                         picon_h,
750                                                                         BC_RGB888)))
751                 {
752                         cache_hit = 1;
753                         
754                 } else
755                 {
756                         source->frames_cache->unlock_cache(); // implicitly locked
757                         cache_hit = 0;  
758                         long now_current_frame = source->current_frame;
759                         source->frames_cache->disable_cache();
760                         VFrame *src = source->read_frame(BC_RGB888);
761                                         if (src) 
762                         {
763                                 final_picon_frame = new VFrame (0, 
764                                                         picon_w,
765                                                         picon_h,
766                                                         BC_RGB888);
767                                 cmodel_transfer(final_picon_frame->get_rows(), 
768                                         src->get_rows(),
769                                         final_picon_frame->get_y(),
770                                         final_picon_frame->get_u(),
771                                         final_picon_frame->get_v(),
772                                         src->get_y(),
773                                         src->get_u(),
774                                         src->get_v(),
775                                         0, 
776                                         0, 
777                                         src->get_w(), 
778                                         src->get_h(),
779                                         0, 
780                                         0, 
781                                         picon_w, 
782                                         picon_h,
783                                         src->get_color_model(), 
784                                         BC_RGB888,
785                                         0,
786                                         src->get_w(),
787                                         picon_w);
788         
789                                 source->frames_cache->enable_cache();
790                                 source->frames_cache->add_frame(now_current_frame,
791                                                                 source->current_layer,
792                                                                 final_picon_frame,
793                                                                 1); // do not do a copy of frame. keep this one
794                                 source->frames_cache->disable_cache();
795         
796                         } else 
797                         {
798                                 final_picon_frame = 0;
799                         }
800                 }
801                 
804 //              if(src)
805 //                      draw_vframe(src, 
806                 if(final_picon_frame)
807                         draw_vframe(final_picon_frame, 
808                                 x, 
809                                 y, 
810                                 picon_w, 
811                                 picon_h, 
812                                 0, 
813                                 0);
815                 if (cache_hit)
816                         source->frames_cache->unlock_cache(); // implicitly locked
818                 
819                 
820                 
821                 if(frames_per_picon > 1)
822                 {
823                         x += Units::round(picon_w);
824                         project_frame = Units::to_int64(frames_per_picon * (int64_t)((double)(x + pixmap_x - edit_x) / picon_w));
825                 }
826                 else
827                 {
828                         x += Units::round(frame_w);
829                         project_frame = (int64_t)((double)(x + pixmap_x - edit_x) / frame_w);
830                 }
831         }
833         if(source)
834         {
835                 mwindow->video_cache->check_in(edit->asset);
836         }
837 //printf("ResourcePixmap::draw_video_resource 5\n");
841 void ResourcePixmap::dump()
843         printf("ResourcePixmap %p\n", this);
844         printf(" edit %x edit_x %d pixmap_x %d pixmap_w %d visible %d\n", edit_id, edit_x, pixmap_x, pixmap_w, visible);