svn merge -r 13452:14721 https://svn.blender.org/svnroot/bf-blender/trunk/blender
[blender.git] / source / blender / src / buttons_scene.c
1 /**
2  * $Id$ 
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19  *
20  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21  * All rights reserved.
22  *
23  * The Original Code is: all of this file.
24  *
25  * Contributor(s): none yet.
26  *
27  * ***** END GPL LICENSE BLOCK *****
28  */
29
30 #include <time.h>
31 #include <math.h>
32 #include <stdlib.h>
33 #include <string.h>
34
35 #include "MEM_guardedalloc.h"
36 #include "DNA_node_types.h"
37 #include "DNA_screen_types.h"
38 #include "DNA_space_types.h"
39 #include "DNA_scene_types.h"
40 #include "DNA_sound_types.h"
41 #include "DNA_sequence_types.h"
42 #include "DNA_userdef_types.h"
43 #include "DNA_packedFile_types.h"
44
45 #include "BKE_global.h"
46 #include "BKE_main.h"
47 #include "BKE_node.h"
48 #include "BKE_library.h"
49 #include "BKE_scene.h"
50 #include "BKE_sound.h"
51 #include "BKE_packedFile.h"
52 #include "BKE_utildefines.h"
53
54 #include "BLI_blenlib.h"
55
56 #include "BSE_filesel.h"
57
58 #include "BIF_gl.h"
59 #include "BIF_graphics.h"
60 #include "BIF_glutil.h"
61 #include "BIF_interface.h"
62 #include "BIF_imasel.h"
63 #include "BIF_keyval.h"
64 #include "BIF_mainqueue.h"
65 #include "BIF_mywindow.h"
66 #include "BIF_meshtools.h"
67 #include "BIF_resources.h"
68 #include "BIF_renderwin.h"
69 #include "BIF_screen.h"
70 #include "BIF_space.h"
71 #include "BIF_toolbox.h"
72 #include "BIF_editseq.h"
73
74 #include "BIF_butspace.h"
75
76 #include "mydevice.h"
77 #include "blendef.h"
78
79 /* -----includes for this file specific----- */
80
81 #include "DNA_image_types.h"
82
83 #include "BKE_writeavi.h"
84 #include "BKE_writeffmpeg.h"
85 #include "BKE_image.h"
86 #include "BKE_plugin_types.h"
87
88 #include "BLI_threads.h"
89
90 #include "BIF_editsound.h"
91 #include "BIF_writeimage.h"
92 #include "BIF_writeavicodec.h"
93
94 #include "BSE_headerbuttons.h"
95 #include "BSE_sequence.h"
96 #include "BSE_seqeffects.h"
97 #include "BSE_seqscopes.h"
98 #include "BSE_seqaudio.h"
99
100 #include "RE_pipeline.h"
101
102 #include "butspace.h" // own module
103
104 #ifdef WITH_QUICKTIME
105 #include "quicktime_export.h"
106 #endif
107
108 #ifdef WITH_FFMPEG
109
110 #include <ffmpeg/avcodec.h> /* for PIX_FMT_* and CODEC_ID_* */
111 #include <ffmpeg/avformat.h>
112
113 static int ffmpeg_preset_sel = 0;
114
115 extern int is_container(int);
116
117 extern void makeffmpegstring(char* string);
118
119 #endif
120
121 /* here the calls for scene buttons
122    - render
123    - world
124    - anim settings, audio
125 */
126
127 /* prototypes */
128 void playback_anim(void);
129
130 /* ************************ SOUND *************************** */
131 static void load_new_sample(char *str)  /* called from fileselect */
132 {
133         char name[FILE_MAX];
134         bSound *sound;
135         bSample *sample, *newsample;
136
137         sound = G.buts->lockpoin;
138
139         if (sound) {
140                 // save values
141                 sample = sound->sample;
142                 strcpy(name, sound->sample->name);
143
144                 strcpy(sound->name, str);
145                 sound_set_sample(sound, NULL);
146                 sound_initialize_sample(sound);
147
148                 if (sound->sample->type == SAMPLE_INVALID) {
149                         error("Not a valid sample: %s", str);
150
151                         newsample = sound->sample;
152
153                         // restore values
154                         strcpy(sound->name, name);
155                         sound_set_sample(sound, sample);
156
157                         // remove invalid sample
158
159                         sound_free_sample(newsample);
160                         BLI_remlink(samples, newsample);
161                         MEM_freeN(newsample);
162                 }
163         }
164
165         BIF_undo_push("Load new audio file");
166         allqueue(REDRAWBUTSSCENE, 0);
167
168 }
169
170
171 void do_soundbuts(unsigned short event)
172 {
173         char name[FILE_MAX];
174         bSound *sound;
175         bSample *sample;
176         bSound* tempsound;
177         ID *id;
178         
179         sound = G.buts->lockpoin;
180         
181         switch(event) {
182         case B_SOUND_REDRAW:
183                 allqueue(REDRAWBUTSSCENE, 0);
184                 break;
185
186         case B_SOUND_LOAD_SAMPLE:
187                 if (sound) strcpy(name, sound->name);
188                 else strcpy(name, U.sounddir);
189                         
190                 activate_fileselect(FILE_SPECIAL, "SELECT WAV FILE", name, load_new_sample);
191                 break;
192
193         case B_SOUND_PLAY_SAMPLE:
194                 if (sound) {
195                         if (sound->sample->type != SAMPLE_INVALID) {
196                                 sound_play_sound(sound);
197                                 allqueue(REDRAWBUTSSCENE, 0);
198                         }
199                 }
200                 break;
201
202         case B_SOUND_MENU_SAMPLE:
203                 if (G.buts->menunr > 0) {
204                         sample = BLI_findlink(samples, G.buts->menunr - 1);
205                         if (sample && sound) {
206                                 BLI_strncpy(sound->name, sample->name, sizeof(sound->name));
207                                 sound_set_sample(sound, sample);
208                                 do_soundbuts(B_SOUND_REDRAW);
209                         }
210                 }
211                         
212                 break;
213         case B_SOUND_NAME_SAMPLE:
214                 load_new_sample(sound->name);
215                 break;
216         
217         case B_SOUND_UNPACK_SAMPLE:
218                 if(sound && sound->sample) {
219                         sample = sound->sample;
220                         
221                         if (sample->packedfile) {
222                                 if (G.fileflags & G_AUTOPACK) {
223                                         if (okee("Disable AutoPack ?")) {
224                                                 G.fileflags &= ~G_AUTOPACK;
225                                         }
226                                 }
227                                 
228                                 if ((G.fileflags & G_AUTOPACK) == 0) {
229                                         unpackSample(sample, PF_ASK);
230                                 }
231                         } else {
232                                 sound_set_packedfile(sample, newPackedFile(sample->name));
233                         }
234                         allqueue(REDRAWHEADERS, 0);
235                         do_soundbuts(B_SOUND_REDRAW);
236                 }
237                 break;
238
239         case B_SOUND_COPY_SOUND:
240                 if (sound) {
241                         tempsound = sound_make_copy(sound);
242                         sound = tempsound;
243                         id = &sound->id;
244                         G.buts->lockpoin = (bSound*)id;
245                         BIF_undo_push("Copy sound");
246                         do_soundbuts(B_SOUND_REDRAW);
247                 }
248                 break;
249
250         case B_SOUND_RECALC:
251                 waitcursor(1);
252                 sound = G.main->sound.first;
253                 while (sound) {
254                         free(sound->stream);
255                         sound->stream = 0;
256                         audio_makestream(sound);
257                         sound = (bSound *) sound->id.next;
258                 }
259                 waitcursor(0);
260                 allqueue(REDRAWSEQ, 0);
261                 break;
262
263         case B_SOUND_RATECHANGED:
264
265                 allqueue(REDRAWBUTSSCENE, 0);
266                 allqueue(REDRAWSEQ, 0);
267                 break;
268
269         case B_SOUND_MIXDOWN:
270                 audio_mixdown();
271                 break;
272
273         default: 
274                 if (G.f & G_DEBUG) {
275                         printf("do_soundbuts: unhandled event %d\n", event);
276                 }
277         }
278 }
279
280
281 static void sound_panel_listener(void)
282 {
283         uiBlock *block;
284         int xco= 100, yco=100, mixrate;
285         char mixrateinfo[256];
286         
287         block= uiNewBlock(&curarea->uiblocks, "sound_panel_listener", UI_EMBOSS, UI_HELV, curarea->win);
288         if(uiNewPanel(curarea, block, "Listener", "Sound", 320, 0, 318, 204)==0) return;
289
290         mixrate = sound_get_mixrate();
291         sprintf(mixrateinfo, "Game Mixrate: %d Hz", mixrate);
292         uiDefBut(block, LABEL, 0, mixrateinfo, xco,yco,295,20, 0, 0, 0, 0, 0, "");
293
294         yco -= 30;
295         uiDefBut(block, LABEL, 0, "Game listener settings:",xco,yco,195,20, 0, 0, 0, 0, 0, "");
296
297         yco -= 30;
298         uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Volume: ",
299                 xco,yco,195,24,&G.listener->gain, 0.0, 1.0, 1.0, 0, "Sets the maximum volume for the overall sound");
300         
301         yco -= 30;
302         uiDefBut(block, LABEL, 0, "Game Doppler effect settings:",xco,yco,195,20, 0, 0, 0, 0, 0, "");
303
304         yco -= 30;
305         uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Doppler: ",
306         xco,yco,195,24,&G.listener->dopplerfactor, 0.0, 10.0, 1.0, 0, "Use this for scaling the doppler effect");
307         
308         yco -=30;
309         uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Velocity: ",
310         xco,yco,195,24,&G.listener->dopplervelocity,0.0,10000.0, 1.0,0, "Sets the propagation speed of sound");
311
312         
313 }
314
315 static void sound_panel_sequencer(void)
316 {
317         uiBlock *block;
318         short xco, yco;
319         char mixrateinfo[256];
320         
321         block= uiNewBlock(&curarea->uiblocks, "sound_panel_sequencer", UI_EMBOSS, UI_HELV, curarea->win);
322         if(uiNewPanel(curarea, block, "Sequencer", "Sound", 640, 0, 318, 204)==0) return;
323
324         /* audio sequence engine settings ------------------------------------------------------------------ */
325
326         xco = 1010;
327         yco = 195;
328
329         uiDefBut(block, LABEL, 0, "Audio sequencer settings", xco,yco,295,20, 0, 0, 0, 0, 0, "");
330
331         yco -= 25;
332         sprintf(mixrateinfo, "Mixing/Sync (latency: %d ms)", (int)( (((float)U.mixbufsize)/(float)G.scene->audio.mixrate)*1000.0 ) );
333         uiDefBut(block, LABEL, 0, mixrateinfo, xco,yco,295,20, 0, 0, 0, 0, 0, "");
334
335         yco -= 25;              
336         uiDefButI(block, ROW, B_SOUND_RATECHANGED, "44.1 kHz",  xco,yco,75,20, &G.scene->audio.mixrate, 2.0, 44100.0, 0, 0, "Mix at 44.1 kHz");
337         uiDefButI(block, ROW, B_SOUND_RATECHANGED, "48.0 kHz",          xco+80,yco,75,20, &G.scene->audio.mixrate, 2.0, 48000.0, 0, 0, "Mix at 48 kHz");
338         uiDefBut(block, BUT, B_SOUND_RECALC, "Recalc",          xco+160,yco,75,20, 0, 0, 0, 0, 0, "Recalculate samples");
339
340         yco -= 25;
341         uiDefButBitS(block, TOG, AUDIO_SYNC, B_SOUND_CHANGED, "Sync",   xco,yco,115,20, &G.scene->audio.flag, 0, 0, 0, 0, "Use sample clock for syncing animation to audio");
342         uiDefButBitS(block, TOG, AUDIO_SCRUB, B_SOUND_CHANGED, "Scrub",         xco+120,yco,115,20, &G.scene->audio.flag, 0, 0, 0, 0, "Scrub when changing frames");
343
344         yco -= 25;
345         uiDefBut(block, LABEL, 0, "Main mix", xco,yco,295,20, 0, 0, 0, 0, 0, "");
346
347         yco -= 25;              
348         uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Main (dB): ",
349                 xco,yco,235,24,&G.scene->audio.main, -24.0, 6.0, 0, 0, "Set the audio master gain/attenuation in dB");
350
351         yco -= 25;
352         uiDefButBitS(block, TOG, AUDIO_MUTE, 0, "Mute", xco,yco,235,24, &G.scene->audio.flag, 0, 0, 0, 0, "Mute audio from sequencer");         
353         
354         yco -= 35;
355         uiDefBut(block, BUT, B_SOUND_MIXDOWN, "MIXDOWN",        xco,yco,235,24, 0, 0, 0, 0, 0, "Create WAV file from sequenced audio (output goes to render output dir)");
356         
357 }
358
359 static char *make_sample_menu(void)
360 {
361         int len= BLI_countlist(samples);        /* BKE_sound.h */
362         
363         if(len) {
364                 bSample *sample;
365                 char *str;
366                 int nr, a=0;
367                 
368                 str= MEM_callocN(32*len, "menu");
369                 
370                 for(nr=1, sample= samples->first; sample; sample= sample->id.next, nr++) {
371                         a+= sprintf(str+a, "|%s %%x%d", sample->id.name+2, nr);
372                 }
373                 return str;
374         }
375         return NULL;
376 }
377
378 static void sound_panel_sound(bSound *sound)
379 {
380         static int packdummy=0;
381         ID *id, *idfrom;
382         uiBlock *block;
383         bSample *sample;
384         char *strp, ch[256];
385
386         block= uiNewBlock(&curarea->uiblocks, "sound_panel_sound", UI_EMBOSS, UI_HELV, curarea->win);
387         if(uiNewPanel(curarea, block, "Sound", "Sound", 0, 0, 318, 204)==0) return;
388         
389         uiDefBut(block, LABEL, 0, "Blender Sound block",10,180,195,20, 0, 0, 0, 0, 0, "");
390         
391         // warning: abuse of texnr here! (ton didnt code!)
392         buttons_active_id(&id, &idfrom);
393         std_libbuttons(block, 10, 160, 0, NULL, B_SOUNDBROWSE2, ID_SO, 0, id, idfrom, &(G.buts->texnr), 1, 0, 0, 0, 0);
394
395         if (sound) {
396         
397                 uiDefBut(block, BUT, B_SOUND_COPY_SOUND, "Copy sound", 220,160,90,20, 0, 0, 0, 0, 0, "Make another copy (duplicate) of the current sound");
398
399                 uiSetButLock(sound->id.lib!=0, ERROR_LIBDATA_MESSAGE);
400                 sound_initialize_sample(sound);
401                 sample = sound->sample;
402
403                 /* info string */
404                 if (sound->sample && sound->sample->len) {
405                         char *tmp;
406                         if (sound->sample->channels == 1) tmp= "Mono";
407                         else if (sound->sample->channels == 2) tmp= "Stereo";
408                         else tmp= "Unknown";
409                         
410                         sprintf(ch, "Sample: %s, %d bit, %d Hz, %d samples", tmp, sound->sample->bits, sound->sample->rate, (sound->sample->len/(sound->sample->bits/8)/sound->sample->channels));
411                         uiDefBut(block, LABEL, 0, ch,                   35,140,225,20, 0, 0, 0, 0, 0, "");
412                 }
413                 else {
414                         uiDefBut(block, LABEL, 0, "Sample: No sample info available.",35,140,225,20, 0, 0, 0, 0, 0, "");
415                 }
416
417                 /* sample browse buttons */
418                 uiBlockBeginAlign(block);
419                 strp= make_sample_menu();
420                 if (strp) {
421                         uiDefButS(block, MENU, B_SOUND_MENU_SAMPLE, strp, 10,120,23,20, &(G.buts->menunr), 0, 0, 0, 0, "Select another loaded sample");
422                         MEM_freeN(strp);
423                 }
424                 uiDefBut(block, TEX, B_SOUND_NAME_SAMPLE, "",           35,120,250,20, sound->name, 0.0, 79.0, 0, 0, "The sample file used by this Sound");
425                 
426                 if (sound->sample->packedfile) packdummy = 1;
427                 else packdummy = 0;
428                 
429                 uiDefIconButBitI(block, TOG, 1, B_SOUND_UNPACK_SAMPLE, ICON_PACKAGE,
430                         285, 120,25,20, &packdummy, 0, 0, 0, 0,"Pack/Unpack this sample");
431                 
432                 uiBlockBeginAlign(block);
433                 uiDefBut(block, BUT, B_SOUND_LOAD_SAMPLE, "Load sample", 10, 95,150,24, 0, 0, 0, 0, 0, "Load a different sample file");
434
435                 uiDefBut(block, BUT, B_SOUND_PLAY_SAMPLE, "Play",       160, 95, 150, 24, 0, 0.0, 0, 0, 0, "Playback sample using settings below");
436                 
437                 uiBlockBeginAlign(block);
438                 uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Volume: ",
439                         10,70,150,20, &sound->volume, 0.0, 1.0, 0, 0, "Game engine only: Set the volume of this sound");
440
441                 uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Pitch: ",
442                         160,70,150,20, &sound->pitch, -12.0, 12.0, 0, 0, "Game engine only: Set the pitch of this sound");
443
444                 /* looping */
445                 uiBlockBeginAlign(block);
446                 uiDefButBitI(block, TOG, SOUND_FLAGS_LOOP, B_SOUND_REDRAW, "Loop",
447                         10, 50, 95, 20, &sound->flags, 0.0, 0.0, 0, 0, "Game engine only: Toggle between looping on/off");
448
449                 if (sound->flags & SOUND_FLAGS_LOOP) {
450                         uiDefButBitI(block, TOG, SOUND_FLAGS_BIDIRECTIONAL_LOOP, B_SOUND_REDRAW, "Ping Pong",
451                                 105, 50, 95, 20, &sound->flags, 0.0, 0.0, 0, 0, "Game engine only: Toggle between A->B and A->B->A looping");
452                         
453                 }
454         
455
456                 /* 3D settings ------------------------------------------------------------------ */
457                 uiBlockBeginAlign(block);
458
459                 if (sound->sample->channels == 1) {
460                         uiDefButBitI(block, TOG, SOUND_FLAGS_3D, B_SOUND_REDRAW, "3D Sound",
461                                 10, 10, 90, 20, &sound->flags, 0, 0, 0, 0, "Game engine only: Turns 3D sound on");
462                         
463                         if (sound->flags & SOUND_FLAGS_3D) {
464                                 uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Scale: ",
465                                         100,10,210,20, &sound->attenuation, 0.0, 5.0, 1.0, 0, "Game engine only: Sets the surround scaling factor for this sound");
466                                 
467                         }
468                 }
469         }
470 }
471
472 /* ************************* Sequencer *********************** */
473
474 #define SEQ_PANEL_EDITING 1
475 #define SEQ_PANEL_INPUT   2
476 #define SEQ_PANEL_FILTER  4
477 #define SEQ_PANEL_EFFECT  8
478 #define SEQ_PANEL_PROXY   16
479
480 static char* seq_panel_blend_modes()
481 {
482         static char string[2048];
483
484         Sequence *last_seq = get_last_seq();
485
486         sprintf(string, "Blend mode: %%t|%s %%x%d",
487                 "Replace", SEQ_BLEND_REPLACE);
488
489         /*
490           Blending can only work without effect strips. 
491           Otherwise, one would have
492           to decide, what the effect strips IPO should do:
493           - drive the effect _or_
494           - drive the blend mode ?
495
496           Also: effectdata is used by these implicit effects,
497           so that would collide also.
498         */
499
500         if (!(last_seq->type & SEQ_EFFECT)) {
501                 int i;
502
503                 for (i = SEQ_EFFECT; i <= SEQ_EFFECT_MAX; i++) {
504                         if (get_sequence_effect_num_inputs(i) == 2) {
505                                 sprintf(string + strlen(string), 
506                                         "|%s %%x%d", 
507                                         give_seqname_by_type(i), i);
508                         }
509                 }
510         }
511         return string;
512 }
513
514 static char* seq_panel_scenes()
515 {
516         static char rstr[8192];
517         char * str;
518
519         IDnames_to_pupstring(&str, NULL, NULL, 
520                              &G.main->scene, (ID *)G.scene, NULL);
521
522         strncpy(rstr, str, 8192);
523         MEM_freeN(str);
524
525         return rstr;
526 }
527
528 static void seq_update_scenenr(Sequence * seq)
529 {
530         Scene * sce;
531         int nr;
532         if (seq->type != SEQ_SCENE) {
533                 return;
534         }
535
536         seq->scenenr = 0;
537
538         sce = G.main->scene.first;
539         nr = 1;
540         while(sce) {
541                 if (sce == seq->scene) {
542                         seq->scenenr = nr;
543                         break;
544                 }
545                 nr++;
546                 sce = sce->id.next;
547         }
548 }
549
550
551 static void seq_panel_editing()
552 {
553         Sequence *last_seq = get_last_seq();
554         uiBlock *block;
555         static char strdata[1024];
556         char * str = strdata;
557         char * p;
558         int yco;
559
560         block = uiNewBlock(&curarea->uiblocks, "seq_panel_editing", 
561                            UI_EMBOSS, UI_HELV, curarea->win);
562
563         if(uiNewPanel(curarea, block, "Edit", "Sequencer", 
564                       10, 230, 318, 204) == 0) return;
565
566         uiDefBut(block, LABEL, 
567                  0, give_seqname(last_seq), 
568                  10,140,60,19, 0, 
569                  0, 0, 0, 0, "");
570
571         uiDefBut(block, TEX, 
572                  B_NOP, "Name: ", 
573                  70,140,180,19, last_seq->name+2, 
574                  0.0, 21.0, 100, 0, "");
575
576         uiDefButI(block, MENU, B_SEQ_BUT_RELOAD, seq_panel_blend_modes(), 
577                   10, 120, 120, 19, &last_seq->blend_mode, 
578                   0,0,0,0, "Strip Blend Mode");
579
580         uiDefButF(block, NUM, B_SEQ_BUT_RELOAD, "Blend:",
581                   130, 120, 120, 19, &last_seq->blend_opacity, 
582                   0.0, 100.0, 100.0, 0, 
583                   "Blend opacity");
584
585         uiDefButBitI(block, TOG, SEQ_MUTE,
586                      B_SEQ_BUT_RELOAD_ALL, "Mute",
587                      10,100,60,19, &last_seq->flag,
588                      0.0, 1.0, 0, 0,
589                      "Mute the current strip.");
590
591         uiDefButBitI(block, TOG, SEQ_LOCK,
592                      B_REDR, "Lock",
593                      70,100,60,19, &last_seq->flag,
594                      0.0, 1.0, 0, 0,
595                      "Lock strip, so that it can't be transformed.");
596         
597         uiDefButBitI(block, TOG, SEQ_IPO_FRAME_LOCKED,
598                      B_SEQ_BUT_RELOAD_ALL, "IPO Frame locked",
599                      130,100,120,19, &last_seq->flag,
600                      0.0, 1.0, 0, 0,
601                      "Lock the IPO coordinates to the "
602                      "global frame counter.");
603         
604         if (!(last_seq->flag & SEQ_LOCK)) {
605                 uiDefButI(block, NUM, 
606                           B_SEQ_BUT_TRANSFORM, "Start", 
607                           10, 80, 120, 20, &last_seq->start, 
608                           -MAXFRAMEF, MAXFRAMEF, 0.0, 0.0, "Start of strip");
609                 uiDefButI(block, NUM, 
610                           B_SEQ_BUT_TRANSFORM, "Chan", 
611                           130, 80, 120, 20, &last_seq->machine, 
612                           0.0, MAXSEQ, 0.0, 0.0, "Channel used (Y position)");
613                 
614                 if (check_single_seq(last_seq) || last_seq->len == 0) {
615                         uiDefButI(block, NUM, 
616                                 B_SEQ_BUT_TRANSFORM, "End-Still", 
617                                 130, 60, 120, 19, &last_seq->endstill, 
618                                 0.0, MAXFRAMEF, 0.0, 0.0, "End still");
619                 } else {
620                         uiDefButI(block, NUM, 
621                                   B_SEQ_BUT_TRANSFORM, "Start-Still", 
622                                   10, 60, 120, 20, &last_seq->startstill, 
623                                   0.0, MAXFRAMEF, 0.0, 0.0, "Start still");
624                         uiDefButI(block, NUM, 
625                                   B_SEQ_BUT_TRANSFORM, "End-Still", 
626                                   130, 60, 120, 19, &last_seq->endstill, 
627                                   0.0, MAXFRAMEF, 0.0, 0.0, "End still");
628                         uiDefButI(block, NUM, 
629                                   B_SEQ_BUT_TRANSFORM, "Start-Ofs", 
630                                   10, 40, 120, 20, &last_seq->startofs, 
631                                   0.0, last_seq->len - last_seq->endofs, 
632                                   0.0, 0.0, "Start offset");
633                         uiDefButI(block, NUM, 
634                                   B_SEQ_BUT_TRANSFORM, "End-Ofs", 
635                                   130, 40, 120, 19, &last_seq->endofs, 
636                                   0.0, last_seq->len - last_seq->startofs, 
637                                   0.0, 0.0, "End offset");
638                 }
639         }
640
641
642         if(last_seq->type & SEQ_EFFECT)
643                 sprintf(str, "Len: %d\nFrom %d - %d\n", last_seq->len, last_seq->startdisp, last_seq->enddisp-1);
644         else
645                 sprintf(str, "Len: %d(%d)\n", last_seq->enddisp-last_seq->startdisp, last_seq->len);
646
647         str += strlen(str);
648
649         if(last_seq->type==SEQ_IMAGE) {
650                 if (last_seq->len > 1) {
651                         /* CURRENT */
652                         StripElem * se= give_stripelem(last_seq, CFRA);
653                         StripElem * last;
654
655                         /* FIRST AND LAST */
656         
657                         if(last_seq->strip) {
658                                 se= last_seq->strip->stripdata;
659                                 last= se+last_seq->len-1;
660                                 if(last_seq->startofs) se+= last_seq->startofs;
661                                 if(last_seq->endofs) last-= last_seq->endofs;
662         
663                                 sprintf(str, "First: %s at %d\nLast: %s at %d\n", se->name, last_seq->startdisp, last->name, last_seq->enddisp-1);
664                         }
665                 } else { /* single image */
666                         if (last_seq->strip) {
667                                 sprintf(str, "Len: %d\n", last_seq->enddisp-last_seq->startdisp);
668                         }
669                 }
670
671                 str += strlen(str);
672
673                 /* orig size */
674                 if(last_seq->strip) {
675                         sprintf(str, "OrigSize: %d x %d\n", last_seq->strip->orx, last_seq->strip->ory);
676                 }
677         }
678         else if(last_seq->type==SEQ_MOVIE) {
679                 int sta= last_seq->startofs;
680                 int end= last_seq->len-1-last_seq->endofs;
681
682                 sprintf(str, "First: %d at %d\nLast: %d at %d\nCur: %d\n",
683                         sta, last_seq->startdisp, end, last_seq->enddisp-1,  
684                         (G.scene->r.cfra)-last_seq->startdisp);
685
686                 str += strlen(str);
687                 /* orig size */
688                 if(last_seq->strip) {
689                         sprintf(str, "OrigSize: %d x %d\n", 
690                                 last_seq->strip->orx, last_seq->strip->ory);
691                 }
692         }
693         else if(last_seq->type==SEQ_SCENE) {
694                 TStripElem * se= give_tstripelem(last_seq,  (G.scene->r.cfra));
695                 if(se && last_seq->scene) {
696                         sprintf(str, "First: %d\nLast: %d\nCur: %d\n", last_seq->sfra+se->nr, last_seq->sfra, last_seq->sfra+last_seq->len-1); 
697                 }
698                 str += strlen(str);
699                 /* orig size */
700                 if(last_seq->strip) {
701                         sprintf(str, "OrigSize: %d x %d\n", 
702                                 last_seq->strip->orx, last_seq->strip->ory);
703                 }
704         }
705         else if(last_seq->type==SEQ_RAM_SOUND
706                 || last_seq->type == SEQ_HD_SOUND) {
707
708                 int sta= last_seq->startofs;
709                 int end= last_seq->len-1-last_seq->endofs;
710
711                 sprintf(str, "First: %d at %d\nLast: %d at %d\nCur: %d\n",
712                         sta, last_seq->startdisp, end, last_seq->enddisp-1,  
713                         (G.scene->r.cfra)-last_seq->startdisp);
714         }
715         else if(last_seq->type == SEQ_SPEED) {
716                 SpeedControlVars * vars = 
717                         (SpeedControlVars*) last_seq->effectdata;
718
719                 if (vars) {
720                         sprintf(str, "Last mapped frame: %d at %d\n", 
721                                 vars->lastValidFrame, 
722                                 vars->lastValidFrame 
723                                 + last_seq->startdisp);
724                 }
725         }
726
727         str = strdata;
728         yco = 20;
729
730         while ((p = strchr(str, '\n'))) {
731                 *p = 0;
732                 uiDefBut(block, LABEL, 0, str, 10,yco,240,17, 0, 
733                          0, 0, 0, 0, "");
734                 str = p+1;
735                 yco -= 18;
736         }
737 }
738
739 static void seq_panel_input()
740 {
741         Sequence *last_seq = get_last_seq();
742         uiBlock *block;
743
744         block = uiNewBlock(&curarea->uiblocks, "seq_panel_input", 
745                            UI_EMBOSS, UI_HELV, curarea->win);
746
747         if(uiNewPanel(curarea, block, "Input", "Sequencer", 
748                       10, 230, 318, 204) == 0) return;
749
750         if (SEQ_HAS_PATH(last_seq)) {
751                 uiDefBut(block, TEX, 
752                          B_SEQ_BUT_RELOAD_FILE, "Dir: ", 
753                          10,140,240,19, last_seq->strip->dir, 
754                          0.0, 160.0, 100, 0, "");
755         }
756
757         if (last_seq->type == SEQ_IMAGE) {
758                 StripElem * se = give_stripelem(last_seq, CFRA);
759
760                 if (se) {
761                         uiDefBut(block, TEX, 
762                                  B_SEQ_BUT_RELOAD_FILE, "File: ", 
763                                  10, 120, 190,19, se->name, 
764                                  0.0, 80.0, 100, 0, "");
765                 }
766
767         } else if (last_seq->type == SEQ_MOVIE || 
768                    last_seq->type == SEQ_HD_SOUND ||
769                    last_seq->type == SEQ_RAM_SOUND) {
770                 uiDefBut(block, TEX, 
771                          B_SEQ_BUT_RELOAD_FILE, "File: ", 
772                          10,120,190,19, last_seq->strip->stripdata->name, 
773                          0.0, 80.0, 100, 0, "");
774         } else if (last_seq->type == SEQ_SCENE) {
775                 seq_update_scenenr(last_seq);
776                 uiDefButI(block, MENU, B_SEQ_BUT_RELOAD_FILE, 
777                           seq_panel_scenes(), 
778                           10, 120, 190, 19, &last_seq->scenenr, 
779                           0,0,0,0, "Linked Scene");
780         }
781
782         uiDefBut(block, BUT, B_SEQ_BUT_RELOAD_FILE, 
783                  "Reload",
784                  200,120,50,19, 0, 0, 0, 0, 0, 
785                  "Reload files/scenes from disk and update strip length.");
786
787         if (last_seq->type == SEQ_MOVIE 
788             || last_seq->type == SEQ_IMAGE 
789             || last_seq->type == SEQ_SCENE
790             || last_seq->type == SEQ_META) {
791                 uiDefButBitI(block, TOG, SEQ_USE_CROP,
792                              B_SEQ_BUT_RELOAD, "Use Crop",
793                              10,100,240,19, &last_seq->flag,
794                              0.0, 1.0, 0, 0,
795                              "Crop image before processing.");
796
797                 if (last_seq->flag & SEQ_USE_CROP) {
798                         if (!last_seq->strip->crop) {
799                                 last_seq->strip->crop = 
800                                         MEM_callocN(sizeof(struct StripCrop), 
801                                                     "StripCrop");
802                         }
803                         uiDefButI(block, NUM, 
804                                   B_SEQ_BUT_RELOAD, "Top", 
805                                   10, 80, 120, 20, 
806                                   &last_seq->strip->crop->top, 
807                                   0.0, 4096, 0.0, 0.0, "Top of source image");
808                         uiDefButI(block, NUM, 
809                                   B_SEQ_BUT_RELOAD, "Bottom", 
810                                   130, 80, 120, 20, 
811                                   &last_seq->strip->crop->bottom, 
812                                   0.0, 4096, 0.0, 0.0,
813                                   "Bottom of source image");
814                         
815                         uiDefButI(block, NUM, 
816                                   B_SEQ_BUT_RELOAD, "Left", 
817                                   10, 60, 120, 20,
818                                   &last_seq->strip->crop->left, 
819                                   0.0, 4096, 0.0, 0.0, "Left");
820                         uiDefButI(block, NUM, 
821                                   B_SEQ_BUT_RELOAD, "Right", 
822                                   130, 60, 120, 19, 
823                                   &last_seq->strip->crop->right, 
824                                   0.0, 4096, 0.0, 0.0, "Right");
825                 }
826                 
827                 uiDefButBitI(block, TOG, SEQ_USE_TRANSFORM,
828                              B_SEQ_BUT_RELOAD, "Use Translate",
829                              10,40,240,19, &last_seq->flag,
830                              0.0, 1.0, 0, 0,
831                              "Translate image before processing.");
832                 
833                 if (last_seq->flag & SEQ_USE_TRANSFORM) {
834                         if (!last_seq->strip->transform) {
835                                 last_seq->strip->transform = 
836                                         MEM_callocN(
837                                                 sizeof(struct StripTransform), 
838                                                 "StripTransform");
839                         }
840                         uiDefButI(block, NUM, 
841                                   B_SEQ_BUT_RELOAD, "X-Ofs", 
842                                   10, 20, 120, 20, 
843                                   &last_seq->strip->transform->xofs, 
844                                   -4096.0, 4096, 0.0, 0.0, "X Offset");
845                         uiDefButI(block, NUM, 
846                                   B_SEQ_BUT_RELOAD, "Y-Ofs", 
847                                   130, 20, 120, 20, 
848                                   &last_seq->strip->transform->yofs, 
849                                   -4096.0, 4096, 0.0, 0.0, "Y Offset");
850                 }
851         }
852
853         uiDefButI(block, NUM, 
854                   B_SEQ_BUT_RELOAD_FILE, "A-Start", 
855                   10, 0, 120, 20, &last_seq->anim_startofs, 
856                   0.0, last_seq->len + last_seq->anim_startofs, 0.0, 0.0, 
857                   "Animation start offset (trim start)");
858         uiDefButI(block, NUM, 
859                   B_SEQ_BUT_RELOAD_FILE, "A-End", 
860                   130, 0, 120, 20, &last_seq->anim_endofs, 
861                   0.0, last_seq->len + last_seq->anim_endofs, 0.0, 0.0, 
862                   "Animation end offset (trim end)");
863
864
865         if (last_seq->type == SEQ_MOVIE) {
866                 uiDefButI(block, NUM, B_SEQ_BUT_RELOAD, "MPEG-Preseek:",
867                           10, -20, 240,19, &last_seq->anim_preseek, 
868                           0.0, 50.0, 100,0,
869                           "On MPEG-seeking preseek this many frames");
870         }
871
872 }
873
874 static void seq_panel_filter_video()
875 {
876         Sequence *last_seq = get_last_seq();
877         uiBlock *block;
878         block = uiNewBlock(&curarea->uiblocks, "seq_panel_filter", 
879                            UI_EMBOSS, UI_HELV, curarea->win);
880
881         if(uiNewPanel(curarea, block, "Filter", "Sequencer", 
882                       10, 230, 318, 204) == 0) return;
883
884
885         uiBlockBeginAlign(block);
886
887
888         uiDefButBitI(block, TOG, SEQ_MAKE_PREMUL, 
889                      B_SEQ_BUT_RELOAD, "Premul", 
890                      10,110,80,19, &last_seq->flag, 
891                      0.0, 21.0, 100, 0, 
892                      "Converts RGB values to become premultiplied with Alpha");
893
894         uiDefButBitI(block, TOG, SEQ_MAKE_FLOAT, 
895                      B_SEQ_BUT_RELOAD, "Float", 
896                      90,110,80,19, &last_seq->flag, 
897                      0.0, 21.0, 100, 0, 
898                      "Convert input to float data");
899
900         uiDefButBitI(block, TOG, SEQ_FILTERY, 
901                      B_SEQ_BUT_RELOAD, "FilterY",       
902                      170,110,80,19, &last_seq->flag, 
903                      0.0, 21.0, 100, 0, 
904                      "For video movies to remove fields");
905
906         uiDefButBitI(block, TOG, SEQ_FLIPX, 
907                      B_SEQ_BUT_RELOAD, "FlipX", 
908                      10,90,80,19, &last_seq->flag, 
909                      0.0, 21.0, 100, 0, 
910                      "Flip on the X axis");
911         uiDefButBitI(block, TOG, SEQ_FLIPY, 
912                      B_SEQ_BUT_RELOAD, "FlipY", 
913                      90,90,80,19, &last_seq->flag, 
914                      0.0, 21.0, 100, 0, 
915                      "Flip on the Y axis");
916
917         uiDefButBitI(block, TOG, SEQ_REVERSE_FRAMES,
918                      B_SEQ_BUT_RELOAD, "Flip Time", 
919                      170,90,80,19, &last_seq->flag, 
920                      0.0, 21.0, 100, 0, 
921                      "Reverse frame order");
922                 
923         uiDefButF(block, NUM, B_SEQ_BUT_RELOAD, "Mul:",
924                   10,70,120,19, &last_seq->mul, 
925                   0.001, 20.0, 0.1, 0, 
926                   "Multiply colors");
927
928         uiDefButF(block, NUM, B_SEQ_BUT_RELOAD, "Strobe:",
929                   130,70,120,19, &last_seq->strobe, 
930                   1.0, 30.0, 100, 0, 
931                   "Only display every nth frame");
932
933         uiDefButBitI(block, TOG, SEQ_USE_COLOR_BALANCE,
934                      B_SEQ_BUT_RELOAD, "Use Color Balance", 
935                      10,50,240,19, &last_seq->flag, 
936                      0.0, 21.0, 100, 0, 
937                      "Activate Color Balance "
938                      "(3-Way color correction) on input");
939
940
941         if (last_seq->flag & SEQ_USE_COLOR_BALANCE) {
942                 if (!last_seq->strip->color_balance) {
943                         int c;
944                         StripColorBalance * cb 
945                                 = last_seq->strip->color_balance 
946                                 = MEM_callocN(
947                                         sizeof(struct StripColorBalance), 
948                                         "StripColorBalance");
949                         for (c = 0; c < 3; c++) {
950                                 cb->lift[c] = 1.0;
951                                 cb->gamma[c] = 1.0;
952                                 cb->gain[c] = 1.0;
953                         }
954                 }
955
956                 uiDefBut(block, LABEL, 0, "Lift",
957                          10,30,80,19, 0, 0, 0, 0, 0, "");
958                 uiDefBut(block, LABEL, 0, "Gamma",
959                          90,30,80,19, 0, 0, 0, 0, 0, "");
960                 uiDefBut(block, LABEL, 0, "Gain",
961                          170,30,80,19, 0, 0, 0, 0, 0, "");
962
963                 uiDefButF(block, COL, B_SEQ_BUT_RELOAD, "Lift",
964                           10,10,80,19, last_seq->strip->color_balance->lift, 
965                           0, 0, 0, 0, "Lift (shadows)");
966
967                 uiDefButF(block, COL, B_SEQ_BUT_RELOAD, "Gamma",
968                           90,10,80,19, last_seq->strip->color_balance->gamma, 
969                           0, 0, 0, 0, "Gamma (midtones)");
970
971                 uiDefButF(block, COL, B_SEQ_BUT_RELOAD, "Gain",
972                           170,10,80,19, last_seq->strip->color_balance->gain, 
973                           0, 0, 0, 0, "Gain (highlights)");
974
975                 uiDefButBitI(block, TOG, SEQ_COLOR_BALANCE_INVERSE_LIFT,
976                              B_SEQ_BUT_RELOAD, "Inv Lift", 
977                              10,-10,80,19, 
978                              &last_seq->strip->color_balance->flag, 
979                              0.0, 21.0, 100, 0, 
980                              "Inverse Lift");
981                 uiDefButBitI(block, TOG, SEQ_COLOR_BALANCE_INVERSE_GAMMA,
982                              B_SEQ_BUT_RELOAD, "Inv Gamma", 
983                              90,-10,80,19, 
984                              &last_seq->strip->color_balance->flag, 
985                              0.0, 21.0, 100, 0, 
986                              "Inverse Gamma");
987                 uiDefButBitI(block, TOG, SEQ_COLOR_BALANCE_INVERSE_GAIN,
988                              B_SEQ_BUT_RELOAD, "Inv Gain", 
989                              170,-10,80,19, 
990                              &last_seq->strip->color_balance->flag, 
991                              0.0, 21.0, 100, 0, 
992                              "Inverse Gain");
993         }
994
995
996         uiBlockEndAlign(block);
997
998 }
999
1000
1001 static void seq_panel_filter_audio()
1002 {
1003         Sequence *last_seq = get_last_seq();
1004         uiBlock *block;
1005         block = uiNewBlock(&curarea->uiblocks, "seq_panel_filter", 
1006                            UI_EMBOSS, UI_HELV, curarea->win);
1007
1008         if(uiNewPanel(curarea, block, "Filter", "Sequencer", 
1009                       10, 230, 318, 204) == 0) return;
1010
1011         uiBlockBeginAlign(block);
1012         uiDefButF(block, NUM, B_SEQ_BUT_RELOAD, "Gain (dB):", 10,50,150,19, &last_seq->level, -96.0, 6.0, 100, 0, "");
1013         uiDefButF(block, NUM, B_SEQ_BUT_RELOAD, "Pan:",         10,30,150,19, &last_seq->pan, -1.0, 1.0, 100, 0, "");
1014         uiBlockEndAlign(block);
1015 }
1016
1017 static void seq_panel_effect()
1018 {
1019         Sequence *last_seq = get_last_seq();
1020         uiBlock *block;
1021         block = uiNewBlock(&curarea->uiblocks, "seq_panel_effect", 
1022                            UI_EMBOSS, UI_HELV, curarea->win);
1023
1024         if(uiNewPanel(curarea, block, "Effect", "Sequencer", 
1025                       10, 230, 318, 204) == 0) return;
1026
1027         if(last_seq->type == SEQ_PLUGIN) {
1028                 PluginSeq *pis;
1029                 VarStruct *varstr;
1030                 int a, xco, yco;
1031
1032                 get_sequence_effect(last_seq);/* make sure, plugin is loaded */
1033
1034                 pis= last_seq->plugin;
1035                 if(pis->vars==0) return;
1036
1037                 varstr= pis->varstr;
1038                 if(varstr) {
1039                         for(a=0; a<pis->vars; a++, varstr++) {
1040                                 xco= 150*(a/6)+10;
1041                                 yco= 125 - 20*(a % 6)+1;
1042                                 uiDefBut(block, varstr->type, B_SEQ_BUT_PLUGIN, varstr->name, xco,yco,150,19, &(pis->data[a]), varstr->min, varstr->max, 100, 0, varstr->tip);
1043
1044                         }
1045                 }
1046                 return;
1047         } 
1048
1049         uiBlockBeginAlign(block);
1050
1051         if(last_seq->type==SEQ_WIPE){
1052                 WipeVars *wipe = (WipeVars *)last_seq->effectdata;
1053                 char formatstring[256];
1054                         
1055                 strncpy(formatstring, "Transition Type %t|Single Wipe%x0|Double Wipe %x1|Iris Wipe %x4|Clock Wipe %x5", 255);
1056                 uiDefButS(block, MENU,B_SEQ_BUT_EFFECT, formatstring,   10,65,220,22, &wipe->wipetype, 0, 0, 0, 0, "What type of wipe should be performed");
1057                 uiDefButF(block, NUM,B_SEQ_BUT_EFFECT,"Blur:",  10,40,220,22, &wipe->edgeWidth,0.0,1.0, 1, 2, "The percent width of the blur edge");
1058                 switch(wipe->wipetype){ /*Skip Types that do not require angle*/
1059                 case DO_IRIS_WIPE:
1060                 case DO_CLOCK_WIPE:
1061                         break;
1062                         
1063                 default:
1064                         uiDefButF(block, NUM,B_SEQ_BUT_EFFECT,"Angle:", 10,15,220,22, &wipe->angle,-90.0,90.0, 1, 2, "The Angle of the Edge");
1065                 }
1066                 uiDefButS(block, TOG,B_SEQ_BUT_EFFECT,"Wipe In",  10,-10,220,22, &wipe->forward,0,0, 0, 0, "Controls Primary Direction of Wipe");                               
1067         } else if(last_seq->type==SEQ_GLOW){
1068                 GlowVars *glow = (GlowVars *)last_seq->effectdata;
1069
1070                 uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "Threshold:",   10,70,150,19, &glow->fMini, 0.0, 1.0, 0, 0, "Trigger Intensity");
1071                 uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "Clamp:",                       10,50,150,19, &glow->fClamp, 0.0, 1.0, 0, 0, "Brightness limit of intensity");
1072                 uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "Boost factor:",        10,30,150,19, &glow->fBoost, 0.0, 10.0, 0, 0, "Brightness multiplier");
1073                 uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "Blur distance:",       10,10,150,19, &glow->dDist, 0.5, 20.0, 0, 0, "Radius of glow effect");
1074                 uiDefButI(block, NUM, B_NOP, "Quality:", 10,-5,150,19, &glow->dQuality, 1.0, 5.0, 0, 0, "Accuracy of the blur effect");
1075                 uiDefButI(block, TOG, B_NOP, "Only boost", 10,-25,150,19, &glow->bNoComp, 0.0, 0.0, 0, 0, "Show the glow buffer only");
1076         }
1077         else if(last_seq->type==SEQ_TRANSFORM){
1078                 TransformVars *transform = (TransformVars *)last_seq->effectdata;
1079
1080                 uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "xScale Start:",        10,70,150,19, &transform->ScalexIni, 0.0, 10.0, 0, 0, "X Scale Start");
1081                 uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "xScale End:",  160,70,150,19, &transform->ScalexFin, 0.0, 10.0, 0, 0, "X Scale End");
1082                 uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "yScale Start:",        10,50,150,19, &transform->ScaleyIni, 0.0, 10.0, 0, 0, "Y Scale Start");
1083                 uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "yScale End:",  160,50,150,19, &transform->ScaleyFin, 0.0, 10.0, 0, 0, "Y Scale End");
1084                 
1085                 uiDefButI(block, ROW, B_SEQ_BUT_EFFECT, "Percent", 10, 30, 150, 19, &transform->percent, 0.0, 1.0, 0.0, 0.0, "Percent Translate");
1086                 uiDefButI(block, ROW, B_SEQ_BUT_EFFECT, "Pixels", 160, 30, 150, 19, &transform->percent, 0.0, 0.0, 0.0, 0.0, "Pixels Translate");
1087                 if(transform->percent==1){
1088                         uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "x Start:",     10,10,150,19, &transform->xIni, -500.0, 500.0, 0, 0, "X Position Start");
1089                         uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "x End:",       160,10,150,19, &transform->xFin, -500.0, 500.0, 0, 0, "X Position End");
1090                         uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "y Start:",     10,-10,150,19, &transform->yIni, -500.0, 500.0, 0, 0, "Y Position Start");
1091                         uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "y End:",       160,-10,150,19, &transform->yFin, -500.0, 500.0, 0, 0, "Y Position End");
1092                 } else {
1093                         uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "x Start:",     10,10,150,19, &transform->xIni, -10000.0, 10000.0, 0, 0, "X Position Start");
1094                         uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "x End:",       160,10,150,19, &transform->xFin, -10000.0, 10000.0, 0, 0, "X Position End");
1095                         uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "y Start:",     10,-10,150,19, &transform->yIni, -10000.0, 10000.0, 0, 0, "Y Position Start");
1096                         uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "y End:",       160,-10,150,19, &transform->yFin, -10000.0, 10000.0, 0, 0, "Y Position End");
1097                         
1098                 }
1099                 
1100                 
1101                 
1102                 uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "rot Start:",10,-30,150,19, &transform->rotIni, 0.0, 360.0, 0, 0, "Rotation Start");
1103                 uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "rot End:",160,-30,150,19, &transform->rotFin, 0.0, 360.0, 0, 0, "Rotation End");
1104                 
1105                 uiDefButI(block, ROW, B_SEQ_BUT_EFFECT, "No Interpolat", 10, -50, 100, 19, &transform->interpolation, 0.0, 0.0, 0.0, 0.0, "No interpolation");
1106                 uiDefButI(block, ROW, B_SEQ_BUT_EFFECT, "Bilinear", 101, -50, 100, 19, &transform->interpolation, 0.0, 1.0, 0.0, 0.0, "Bilinear interpolation");
1107                 uiDefButI(block, ROW, B_SEQ_BUT_EFFECT, "Bicubic", 202, -50, 100, 19, &transform->interpolation, 0.0, 2.0, 0.0, 0.0, "Bicubic interpolation");
1108         } else if(last_seq->type==SEQ_COLOR) {
1109                 SolidColorVars *colvars = (SolidColorVars *)last_seq->effectdata;
1110                 uiDefButF(block, COL, B_SEQ_BUT_RELOAD, "",10,90,150,19, colvars->col, 0, 0, 0, 0, "");
1111         } else if(last_seq->type==SEQ_SPEED){
1112                 SpeedControlVars *sp = 
1113                         (SpeedControlVars *)last_seq->effectdata;
1114                 
1115                 uiDefButF(block, NUM, B_SEQ_BUT_RELOAD, "Global Speed:",        10,70,150,19, &sp->globalSpeed, 0.0, 100.0, 0, 0, "Global Speed");
1116                 
1117                 uiDefButBitI(block, TOG, SEQ_SPEED_INTEGRATE,
1118                              B_SEQ_BUT_RELOAD, 
1119                              "IPO is velocity",
1120                              10,50,150,19, &sp->flags, 
1121                              0.0, 1.0, 0, 0, 
1122                              "Interpret the IPO value as a "
1123                              "velocity instead of a frame number");
1124
1125                 uiDefButBitI(block, TOG, SEQ_SPEED_BLEND,
1126                              B_SEQ_BUT_RELOAD, 
1127                              "Enable frame blending",
1128                              10,30,150,19, &sp->flags, 
1129                              0.0, 1.0, 0, 0, 
1130                              "Blend two frames into the "
1131                              "target for a smoother result");
1132                 
1133                 uiDefButBitI(block, TOG, SEQ_SPEED_COMPRESS_IPO_Y,
1134                              B_SEQ_BUT_RELOAD, 
1135                              "IPO value runs from [0..1]",
1136                              10,10,150,19, &sp->flags, 
1137                              0.0, 1.0, 0, 0, 
1138                              "Scale IPO value to get the "
1139                              "target frame number.");
1140         }
1141
1142         uiBlockEndAlign(block);
1143 }
1144
1145 static void seq_panel_proxy()
1146 {
1147         Sequence *last_seq = get_last_seq();
1148         uiBlock *block;
1149         block = uiNewBlock(&curarea->uiblocks, "seq_panel_proxy", 
1150                            UI_EMBOSS, UI_HELV, curarea->win);
1151
1152         if(uiNewPanel(curarea, block, "Proxy", "Sequencer", 
1153                       10, 230, 318, 204) == 0) return;
1154
1155         uiBlockBeginAlign(block);
1156
1157         uiDefButBitI(block, TOG, SEQ_USE_PROXY, 
1158                      B_SEQ_BUT_RELOAD, "Use Proxy", 
1159                      10,140,120,19, &last_seq->flag, 
1160                      0.0, 21.0, 100, 0, 
1161                      "Use a preview proxy for this strip");
1162
1163         if (last_seq->flag & SEQ_USE_PROXY) {
1164                 if (!last_seq->strip->proxy) {
1165                         last_seq->strip->proxy = 
1166                                 MEM_callocN(sizeof(struct StripProxy),
1167                                             "StripProxy");
1168                 }
1169
1170                 uiDefButBitI(block, TOG, SEQ_USE_PROXY_CUSTOM_DIR, 
1171                              B_SEQ_BUT_RELOAD, "Custom Dir", 
1172                              130,140,120,19, &last_seq->flag, 
1173                              0.0, 21.0, 100, 0, 
1174                              "Use a custom directory to store data");
1175         }
1176
1177         if (last_seq->flag & SEQ_USE_PROXY_CUSTOM_DIR) {
1178                 uiDefIconBut(block, BUT, B_SEQ_SEL_PROXY_DIR, 
1179                              ICON_FILESEL, 10, 120, 20, 20, 0, 0, 0, 0, 0, 
1180                              "Select the directory/name for "
1181                              "the proxy storage");
1182
1183                 uiDefBut(block, TEX, 
1184                          B_SEQ_BUT_RELOAD, "Dir: ", 
1185                          30,120,220,20, last_seq->strip->proxy->dir, 
1186                          0.0, 160.0, 100, 0, "");
1187         }
1188
1189         if (last_seq->flag & SEQ_USE_PROXY) {
1190                 if (G.scene->r.size == 100) {
1191                         uiDefBut(block, LABEL, 0, 
1192                                  "Full render size selected, ",
1193                                  10,100,240,19, 0, 0, 0, 0, 0, "");
1194                         uiDefBut(block, LABEL, 0, 
1195                                  "so no proxy enabled!",
1196                                  10,80,240,19, 0, 0, 0, 0, 0, "");
1197                 } else if (last_seq->type != SEQ_MOVIE 
1198                            && last_seq->type != SEQ_IMAGE
1199                            && !(last_seq->flag & SEQ_USE_PROXY_CUSTOM_DIR)) {
1200                         uiDefBut(block, LABEL, 0, 
1201                                  "Cannot proxy this strip without ",
1202                                  10,100,240,19, 0, 0, 0, 0, 0, "");
1203                         uiDefBut(block, LABEL, 0, 
1204                                  "custom directory selection!",
1205                                  10,80,240,19, 0, 0, 0, 0, 0, "");
1206
1207                 } else {
1208                         uiDefBut(block, BUT, B_SEQ_BUT_REBUILD_PROXY, 
1209                                  "Rebuild proxy",
1210                                  10,100,240,19, 0, 0, 0, 0, 0, 
1211                                  "Rebuild proxy for the "
1212                                  "currently selected strip.");
1213                 }
1214         }
1215
1216         uiBlockEndAlign(block);
1217 }
1218
1219
1220 void sequencer_panels()
1221 {
1222         Sequence *last_seq = get_last_seq();
1223         int panels = 0;
1224         int type;
1225
1226         if(last_seq == NULL) {
1227                 return;
1228         }
1229         
1230         type = last_seq->type;
1231
1232         panels = SEQ_PANEL_EDITING;
1233
1234         if (type == SEQ_MOVIE || type == SEQ_IMAGE || type == SEQ_SCENE
1235             || type == SEQ_META) {
1236                 panels |= SEQ_PANEL_INPUT | SEQ_PANEL_FILTER | SEQ_PANEL_PROXY;
1237         }
1238
1239         if (type == SEQ_RAM_SOUND || type == SEQ_HD_SOUND) {
1240                 panels |= SEQ_PANEL_FILTER | SEQ_PANEL_INPUT;
1241         }
1242
1243         if (type == SEQ_PLUGIN || type >= SEQ_EFFECT) {
1244                 panels |= SEQ_PANEL_EFFECT | SEQ_PANEL_PROXY;
1245         }
1246
1247         if (panels & SEQ_PANEL_EDITING) {
1248                 seq_panel_editing();
1249         }
1250
1251         if (panels & SEQ_PANEL_INPUT) {
1252                 seq_panel_input();
1253         }
1254
1255         if (panels & SEQ_PANEL_FILTER) {
1256                 if (type == SEQ_RAM_SOUND || type == SEQ_HD_SOUND) {
1257                         seq_panel_filter_audio();
1258                 } else {
1259                         seq_panel_filter_video();
1260                 }
1261         }
1262
1263         if (panels & SEQ_PANEL_EFFECT) {
1264                 seq_panel_effect();
1265         }
1266
1267         if (panels & SEQ_PANEL_PROXY) {
1268                 seq_panel_proxy();
1269         }
1270 }
1271
1272 static void sel_proxy_dir(char *name)
1273 {
1274         Sequence *last_seq = get_last_seq();
1275         strcpy(last_seq->strip->proxy->dir, name);
1276
1277         allqueue(REDRAWBUTSSCENE, 0);
1278
1279         BIF_undo_push("Change proxy directory");
1280 }
1281
1282 void do_sequencer_panels(unsigned short event)
1283 {
1284         Sequence *last_seq = get_last_seq();
1285         ScrArea * sa;
1286
1287         switch(event) {
1288         case B_SEQ_BUT_PLUGIN:
1289         case B_SEQ_BUT_EFFECT:
1290                 update_changed_seq_and_deps(last_seq, 0, 1);
1291                 break;
1292         case B_SEQ_BUT_RELOAD_FILE:
1293                 reload_sequence_new_file(last_seq);
1294                 break;
1295         case B_SEQ_BUT_REBUILD_PROXY:
1296                 seq_proxy_rebuild(last_seq);
1297                 break;
1298         case B_SEQ_SEL_PROXY_DIR:
1299                 sa= closest_bigger_area();
1300                 areawinset(sa->win);
1301                 activate_fileselect(FILE_SPECIAL, "SELECT PROXY DIR", 
1302                                     last_seq->strip->proxy->dir, 
1303                                     sel_proxy_dir);
1304                 break;
1305         case B_SEQ_BUT_RELOAD:
1306         case B_SEQ_BUT_RELOAD_ALL:
1307                 update_seq_ipo_rect(last_seq);
1308                 update_seq_icu_rects(last_seq);
1309
1310                 free_imbuf_seq();       // frees all
1311
1312                 break;
1313         case B_SEQ_BUT_TRANSFORM:
1314                 calc_sequence(last_seq);
1315                 if (test_overlap_seq(last_seq))
1316                         shuffle_seq(last_seq);
1317                 break;
1318         }
1319
1320         if (event == B_SEQ_BUT_RELOAD_ALL) {
1321                 allqueue(REDRAWALL, 0);
1322         } else {
1323                 allqueue(REDRAWSEQ, 0);
1324         }
1325 }
1326
1327
1328 /* ************************* SCENE *********************** */
1329
1330
1331 static void output_pic(char *name)
1332 {
1333         strcpy(G.scene->r.pic, name);
1334         allqueue(REDRAWBUTSSCENE, 0);
1335         BIF_undo_push("Change output picture directory");
1336 }
1337
1338 static void backbuf_pic(char *name)
1339 {
1340         Image *ima;
1341         
1342         strcpy(G.scene->r.backbuf, name);
1343         allqueue(REDRAWBUTSSCENE, 0);
1344
1345         ima= BKE_add_image_file(name);
1346         if(ima)
1347                 BKE_image_signal(ima, NULL, IMA_SIGNAL_RELOAD);
1348
1349         BIF_undo_push("Change background picture");
1350 }
1351
1352 static void run_playanim(char *file) 
1353 {
1354         extern char bprogname[];        /* usiblender.c */
1355         char str[FILE_MAX*2]; /* FILE_MAX*2 is a bit arbitary, but this should roughly allow for the args + the max-file-length */
1356         int pos[2], size[2];
1357
1358         /* use current settings for defining position of window. it actually should test image size */
1359         calc_renderwin_rectangle((G.scene->r.xsch*G.scene->r.size)/100, 
1360                                                          (G.scene->r.ysch*G.scene->r.size)/100, G.winpos, pos, size);
1361 #ifdef WIN32
1362         sprintf(str, "%s -a -s %d -e %d -p %d %d -f %d %g \"%s\"", bprogname, G.scene->r.sfra, G.scene->r.efra, pos[0], pos[1], G.scene->r.frs_sec, G.scene->r.frs_sec_base, file);
1363 #else
1364         sprintf(str, "\"%s\" -a -s %d -e %d  -p %d %d -f %d %g \"%s\"", bprogname, G.scene->r.sfra, G.scene->r.efra, pos[0], pos[1], G.scene->r.frs_sec, G.scene->r.frs_sec_base, file);
1365 #endif
1366         system(str);
1367 }
1368
1369 void playback_anim(void)
1370 {       
1371         char file[FILE_MAX];
1372
1373         if(BKE_imtype_is_movie(G.scene->r.imtype)) {
1374                 switch (G.scene->r.imtype) {
1375 #ifdef WITH_QUICKTIME
1376                         case R_QUICKTIME:
1377                                 makeqtstring(file);
1378                                 break;
1379 #endif
1380 #ifdef WITH_FFMPEG
1381                 case R_FFMPEG:
1382                         makeffmpegstring(file);
1383                         break;
1384 #endif
1385                 default:
1386                         makeavistring(&G.scene->r, file);
1387                         break;
1388                 }
1389                 if(BLI_exist(file)) {
1390                         run_playanim(file);
1391                 }
1392                 else error("Can't find movie: %s", file);
1393         }
1394         else {
1395                 BKE_makepicstring(file, G.scene->r.pic, G.scene->r.sfra, G.scene->r.imtype);
1396                 if(BLI_exist(file)) {
1397                         run_playanim(file);
1398                 }
1399                 else error("Can't find image: %s", file);
1400         }
1401 }
1402
1403 #ifdef WITH_FFMPEG
1404 static void set_ffmpeg_preset(int preset);
1405 #endif
1406
1407 void do_render_panels(unsigned short event)
1408 {
1409         ScrArea *sa;
1410         ID *id;
1411
1412         switch(event) {
1413
1414         case B_DORENDER:
1415                 BIF_do_render(0);
1416                 break;
1417         case B_RTCHANGED:
1418                 allqueue(REDRAWALL, 0);
1419                 break;
1420         case B_SWITCHRENDER:
1421                 /* new panels added, so... */
1422                 G.buts->re_align= 1;
1423                 allqueue(REDRAWBUTSSCENE, 0);
1424                 break;
1425         case B_PLAYANIM:
1426                 playback_anim();
1427                 break;
1428                 
1429         case B_DOANIM:
1430                 BIF_do_render(1);
1431                 break;
1432         
1433         case B_FS_PIC:
1434                 sa= closest_bigger_area();
1435                 areawinset(sa->win);
1436                 if(G.qual == LR_CTRLKEY)
1437                         activate_imageselect(FILE_SPECIAL, "SELECT OUTPUT PICTURES", G.scene->r.pic, output_pic);
1438                 else
1439                         activate_fileselect(FILE_SPECIAL, "SELECT OUTPUT PICTURES", G.scene->r.pic, output_pic);
1440                 break;
1441
1442         case B_FS_BACKBUF:
1443                 sa= closest_bigger_area();
1444                 areawinset(sa->win);
1445                 if(G.qual == LR_CTRLKEY)
1446                         activate_imageselect(FILE_SPECIAL, "SELECT BACKBUF PICTURE", G.scene->r.backbuf, backbuf_pic);
1447                 else
1448                         activate_fileselect(FILE_SPECIAL, "SELECT BACKBUF PICTURE", G.scene->r.backbuf, backbuf_pic);
1449                 break;
1450         
1451         case B_PR_PAL:
1452                 G.scene->r.xsch= 720;
1453                 G.scene->r.ysch= 576;
1454                 G.scene->r.xasp= 54;
1455                 G.scene->r.yasp= 51;
1456                 G.scene->r.size= 100;
1457                 G.scene->r.frs_sec= 25;
1458                 G.scene->r.frs_sec_base= 1;
1459                 G.scene->r.mode &= ~R_PANORAMA;
1460                 G.scene->r.xparts=  G.scene->r.yparts= 4;
1461 #ifdef WITH_FFMPEG
1462                 G.scene->r.ffcodecdata.gop_size = 15;
1463 #endif          
1464                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
1465                 BIF_undo_push("Set PAL");
1466                 allqueue(REDRAWBUTSSCENE, 0);
1467                 allqueue(REDRAWVIEWCAM, 0);
1468                 break;
1469
1470         case B_FILETYPEMENU:
1471                 allqueue(REDRAWBUTSSCENE, 0);
1472 #ifdef WITH_FFMPEG
1473                 if (G.scene->r.imtype == R_FFMPEG) {
1474                         if (G.scene->r.ffcodecdata.type <= 0 ||
1475                             G.scene->r.ffcodecdata.codec <= 0 ||
1476                             G.scene->r.ffcodecdata.audio_codec <= 0 ||
1477                             G.scene->r.ffcodecdata.video_bitrate <= 1) {
1478                                 G.scene->r.ffcodecdata.codec 
1479                                         = CODEC_ID_MPEG2VIDEO;
1480                                 set_ffmpeg_preset(FFMPEG_PRESET_DVD);
1481                         }
1482
1483                         if (G.scene->r.ffcodecdata.audio_codec <= 0) {
1484                                 G.scene->r.ffcodecdata.audio_codec 
1485                                         = CODEC_ID_MP2;
1486                                 G.scene->r.ffcodecdata.audio_bitrate = 128;
1487                         }
1488                         break;
1489                 }
1490 #endif
1491 #if defined (_WIN32) || defined (__APPLE__)
1492                 // fall through to codec settings if this is the first
1493                 // time R_AVICODEC is selected for this scene.
1494                 if (((G.scene->r.imtype == R_AVICODEC) 
1495                          && (G.scene->r.avicodecdata == NULL)) ||
1496                         ((G.scene->r.imtype == R_QUICKTIME) 
1497                          && (G.scene->r.qtcodecdata == NULL))) {
1498                 } else {
1499                   break;
1500                 }
1501 #endif /*_WIN32 || __APPLE__ */
1502
1503         case B_SELECTCODEC:
1504 #if defined (_WIN32) || defined (__APPLE__)
1505                 if ((G.scene->r.imtype == R_QUICKTIME)) { /* || (G.scene->r.qtcodecdata)) */
1506 #ifdef WITH_QUICKTIME
1507                         get_qtcodec_settings();
1508 #endif /* WITH_QUICKTIME */
1509                 }
1510 #if defined (_WIN32) && !defined(FREE_WINDOWS)
1511                 else
1512                         get_avicodec_settings();
1513 #endif /* _WIN32 && !FREE_WINDOWS */
1514 #endif /* _WIN32 || __APPLE__ */
1515                 break;
1516
1517         case B_PR_HD:
1518                 G.scene->r.xsch= 1920;
1519                 G.scene->r.ysch= 1080;
1520                 G.scene->r.xasp= 1;
1521                 G.scene->r.yasp= 1;
1522                 G.scene->r.size= 100;
1523                 G.scene->r.mode &= ~R_PANORAMA;
1524                 G.scene->r.xparts=  G.scene->r.yparts= 4;
1525                 
1526                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
1527                 BIF_undo_push("Set FULL");
1528                 allqueue(REDRAWBUTSSCENE, 0);
1529                 allqueue(REDRAWVIEWCAM, 0);
1530                 break;
1531         case B_PR_FULL:
1532                 G.scene->r.xsch= 1280;
1533                 G.scene->r.ysch= 1024;
1534                 G.scene->r.xasp= 1;
1535                 G.scene->r.yasp= 1;
1536                 G.scene->r.size= 100;
1537                 G.scene->r.mode &= ~R_PANORAMA;
1538                 G.scene->r.xparts=  G.scene->r.yparts= 4;
1539
1540                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
1541                 BIF_undo_push("Set FULL");
1542                 allqueue(REDRAWBUTSSCENE, 0);
1543                 allqueue(REDRAWVIEWCAM, 0);
1544                 break;
1545         case B_PR_PRV:
1546                 G.scene->r.xsch= 640;
1547                 G.scene->r.ysch= 512;
1548                 G.scene->r.xasp= 1;
1549                 G.scene->r.yasp= 1;
1550                 G.scene->r.size= 50;
1551                 G.scene->r.mode &= ~R_PANORAMA;
1552                 G.scene->r.xparts=  G.scene->r.yparts= 2;
1553
1554                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
1555                 allqueue(REDRAWVIEWCAM, 0);
1556                 allqueue(REDRAWBUTSSCENE, 0);
1557                 break;
1558         case B_PR_PAL169:
1559                 G.scene->r.xsch= 720;
1560                 G.scene->r.ysch= 576;
1561                 G.scene->r.xasp= 64;
1562                 G.scene->r.yasp= 45;
1563                 G.scene->r.size= 100;
1564                 G.scene->r.frs_sec= 25;
1565                 G.scene->r.frs_sec_base= 1;
1566                 G.scene->r.mode &= ~R_PANORAMA;
1567                 G.scene->r.xparts=  G.scene->r.yparts= 4;
1568 #ifdef WITH_FFMPEG
1569                 G.scene->r.ffcodecdata.gop_size = 15;
1570 #endif          
1571
1572                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
1573                 BIF_undo_push("Set PAL 16/9");
1574                 allqueue(REDRAWVIEWCAM, 0);
1575                 allqueue(REDRAWBUTSSCENE, 0);
1576                 break;
1577         case B_PR_PC:
1578                 G.scene->r.xsch= 640;
1579                 G.scene->r.ysch= 480;
1580                 G.scene->r.xasp= 100;
1581                 G.scene->r.yasp= 100;
1582                 G.scene->r.size= 100;
1583                 G.scene->r.mode &= ~R_PANORAMA;
1584                 G.scene->r.xparts=  G.scene->r.yparts= 4;
1585
1586                 BLI_init_rctf(&G.scene->r.safety, 0.0, 1.0, 0.0, 1.0);
1587                 BIF_undo_push("Set PC");
1588                 allqueue(REDRAWVIEWCAM, 0);
1589                 allqueue(REDRAWBUTSSCENE, 0);
1590                 break;
1591         case B_PR_PRESET:
1592                 G.scene->r.xsch= 720;
1593                 G.scene->r.ysch= 576;
1594                 G.scene->r.xasp= 54;
1595                 G.scene->r.yasp= 51;
1596                 G.scene->r.size= 100;
1597                 G.scene->r.mode= R_OSA+R_SHADOW+R_FIELDS+R_SSS;
1598                 G.scene->r.imtype= R_TARGA;
1599                 G.scene->r.xparts=  G.scene->r.yparts= 4;
1600
1601                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
1602                 BIF_undo_push("Set Default");
1603                 allqueue(REDRAWVIEWCAM, 0);
1604                 allqueue(REDRAWBUTSSCENE, 0);
1605                 break;
1606         case B_PR_PANO:
1607                 G.scene->r.xsch= 576;
1608                 G.scene->r.ysch= 176;
1609                 G.scene->r.xasp= 115;
1610                 G.scene->r.yasp= 100;
1611                 G.scene->r.size= 100;
1612                 G.scene->r.mode |= R_PANORAMA;
1613                 G.scene->r.xparts=  16;
1614                 G.scene->r.yparts= 1;
1615
1616                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
1617                 BIF_undo_push("Set Panorama");
1618                 allqueue(REDRAWVIEWCAM, 0);
1619                 allqueue(REDRAWBUTSSCENE, 0);
1620                 break;
1621         case B_PR_NTSC:
1622                 G.scene->r.xsch= 720;
1623                 G.scene->r.ysch= 480;
1624                 G.scene->r.xasp= 10;
1625                 G.scene->r.yasp= 11;
1626                 G.scene->r.size= 100;
1627                 G.scene->r.frs_sec= 30;
1628                 G.scene->r.frs_sec_base = 1.001;
1629                 G.scene->r.mode &= ~R_PANORAMA;
1630                 G.scene->r.xparts=  G.scene->r.yparts= 2;
1631 #ifdef WITH_FFMPEG
1632                 G.scene->r.ffcodecdata.gop_size = 18;
1633 #endif          
1634                 
1635                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
1636                 BIF_undo_push("Set NTSC");
1637                 allqueue(REDRAWBUTSSCENE, 0);
1638                 allqueue(REDRAWVIEWCAM, 0);
1639                 break;
1640
1641         case B_SETBROWSE:
1642                 id= (ID*) G.scene->set;
1643                 
1644                 if (G.buts->menunr==-2) {
1645                          activate_databrowse(id, ID_SCE, 0, B_SETBROWSE, &G.buts->menunr, do_render_panels);
1646                 } 
1647                 else if (G.buts->menunr>0) {
1648                         Scene *newset= (Scene*) BLI_findlink(&G.main->scene, G.buts->menunr-1);
1649                         
1650                         if (newset==G.scene)
1651                                 error("Can't use the same scene as its own set");
1652                         else if (newset) {
1653                                 G.scene->set= newset;
1654                                 if (scene_check_setscene(G.scene)==0)
1655                                         error("This would create a cycle");
1656
1657                                 allqueue(REDRAWBUTSSCENE, 0);
1658                                 allqueue(REDRAWVIEW3D, 0);
1659                                 BIF_undo_push("Change Set Scene");
1660                         }
1661                 }  
1662                 break;
1663         case B_CLEARSET:
1664                 G.scene->set= NULL;
1665                 allqueue(REDRAWBUTSSCENE, 0);
1666                 allqueue(REDRAWVIEW3D, 0);
1667                 BIF_undo_push("Clear Set Scene");
1668                 
1669                 break;
1670         case B_SET_EDGE:
1671                 allqueue(REDRAWBUTSSCENE, 0);
1672                 break;
1673         case B_SET_ZBLUR:
1674                 G.scene->r.mode &= ~R_EDGE;
1675                 allqueue(REDRAWBUTSSCENE, 0);
1676                 break;
1677         case B_ADD_RENDERLAYER:
1678                 if(G.scene->r.actlay==32767) {
1679                         scene_add_render_layer(G.scene);
1680                         G.scene->r.actlay= BLI_countlist(&G.scene->r.layers) - 1;
1681                 }
1682                 allqueue(REDRAWBUTSSCENE, 0);
1683                 allqueue(REDRAWNODE, 0);
1684                 break;
1685         case B_SET_PASS:
1686                 if(G.scene->nodetree) {
1687                         ntreeCompositForceHidden(G.scene->nodetree);
1688                         allqueue(REDRAWNODE, 0);
1689                 }
1690                 allqueue(REDRAWBUTSSCENE, 0);
1691                 allqueue(REDRAWOOPS, 0);
1692         }
1693 }
1694
1695 /* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */
1696 static uiBlock *edge_render_menu(void *arg_unused)
1697 {
1698         uiBlock *block;
1699         
1700         block= uiNewBlock(&curarea->uiblocks, "edge render", UI_EMBOSS, UI_HELV, curarea->win);
1701                 
1702         /* use this for a fake extra empy space around the buttons */
1703         uiDefBut(block, LABEL, 0, "",  0, 0, 220, 115, NULL,  0, 0, 0, 0, "");
1704         
1705         uiDefButS(block, NUM, 0,"Eint:",        45,75,175,19,  &G.scene->r.edgeint, 0.0, 255.0, 0, 0,
1706                   "Sets edge intensity for Toon shading");
1707
1708         /* color settings for the toon shading */
1709         uiDefButF(block, COL, 0, "",            10, 10,30,60,  &(G.scene->r.edgeR), 0, 0, 0, B_EDGECOLSLI, "");
1710         
1711         uiBlockBeginAlign(block);
1712         uiDefButF(block, NUMSLI, 0, "R ",   45, 50, 175,19,   &G.scene->r.edgeR, 0.0, 1.0, B_EDGECOLSLI, 0,
1713                   "Color for edges in toon shading mode.");
1714         uiDefButF(block, NUMSLI, 0, "G ",       45, 30, 175,19,  &G.scene->r.edgeG, 0.0, 1.0, B_EDGECOLSLI, 0,
1715                   "Color for edges in toon shading mode.");
1716         uiDefButF(block, NUMSLI, 0, "B ",       45, 10, 175,19,  &G.scene->r.edgeB, 0.0, 1.0, B_EDGECOLSLI, 0,
1717                   "Color for edges in toon shading mode.");
1718
1719         
1720         uiBlockSetDirection(block, UI_TOP);
1721         
1722         return block;
1723 }
1724
1725
1726 /* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */
1727 static uiBlock *framing_render_menu(void *arg_unused)
1728 {
1729         uiBlock *block;
1730         short yco = 190, xco = 0;
1731         int randomcolorindex = 1234;
1732
1733         block= uiNewBlock(&curarea->uiblocks, "framing_options", UI_EMBOSS, UI_HELV, curarea->win);
1734
1735         /* use this for a fake extra empy space around the buttons */
1736         uiDefBut(block, LABEL, 0, "",                   -5, -10, 295, 224, NULL, 0, 0, 0, 0, "");
1737
1738         uiDefBut(block, LABEL, 0, "Framing:", xco, yco, 68,19, 0, 0, 0, 0, 0, "");
1739         uiBlockBeginAlign(block);
1740         uiDefButC(block, ROW, 0, "Stretch",     xco += 70, yco, 68, 19, &G.scene->framing.type, 1.0, SCE_GAMEFRAMING_SCALE , 0, 0, "Stretch or squeeze the viewport to fill the display window");
1741         uiDefButC(block, ROW, 0, "Expose",      xco += 70, yco, 68, 19, &G.scene->framing.type, 1.0, SCE_GAMEFRAMING_EXTEND, 0, 0, "Show the entire viewport in the display window, viewing more horizontally or vertically");
1742         uiDefButC(block, ROW, 0, "Letterbox",       xco += 70, yco, 68, 19, &G.scene->framing.type, 1.0, SCE_GAMEFRAMING_BARS  , 0, 0, "Show the entire viewport in the display window, using bar horizontally or vertically");
1743         uiBlockEndAlign(block);
1744
1745         yco -= 25;
1746         xco = 40;
1747
1748         uiDefButF(block, COL, 0, "",                0, yco - 58 + 18, 33, 58, &G.scene->framing.col[0], 0, 0, 0, randomcolorindex, "");
1749
1750         uiBlockBeginAlign(block);
1751         uiDefButF(block, NUMSLI, 0, "R ", xco,yco,243,18, &G.scene->framing.col[0], 0.0, 1.0, randomcolorindex, 0, "Set the red component of the bars");
1752         yco -= 20;
1753         uiDefButF(block, NUMSLI, 0, "G ", xco,yco,243,18, &G.scene->framing.col[1], 0.0, 1.0, randomcolorindex, 0, "Set the green component of the bars");
1754         yco -= 20;
1755         uiDefButF(block, NUMSLI, 0, "B ", xco,yco,243,18, &G.scene->framing.col[2], 0.0, 1.0, randomcolorindex, 0, "Set the blue component of the bars");
1756         uiBlockEndAlign(block);
1757         
1758         xco = 0;
1759         uiDefBut(block, LABEL, 0, "Fullscreen:",                xco, yco-=30, 100, 19, 0, 0.0, 0.0, 0, 0, "");
1760         uiDefButS(block, TOG, 0, "Fullscreen", xco+70, yco, 68, 19, &G.scene->r.fullscreen, 0.0, 0.0, 0, 0, "Starts player in a new fullscreen display");
1761         uiBlockBeginAlign(block);
1762         uiDefButS(block, NUM, 0, "X:",          xco+40, yco-=27, 100, 19, &G.scene->r.xplay, 10.0, 2000.0, 0, 0, "Displays current X screen/window resolution. Click to change.");
1763         uiDefButS(block, NUM, 0, "Y:",          xco+140, yco, 100, 19, &G.scene->r.yplay,    10.0, 2000.0, 0, 0, "Displays current Y screen/window resolution. Click to change.");
1764         uiDefButS(block, NUM, 0, "Freq:",       xco+40, yco-=21, 100, 19, &G.scene->r.freqplay, 10.0, 2000.0, 0, 0, "Displays clock frequency of fullscreen display. Click to change.");
1765         uiDefButS(block, NUM, 0, "Bits:",       xco+140, yco, 100, 19, &G.scene->r.depth, 8.0, 32.0, 800.0, 0, "Displays bit depth of full screen display. Click to change.");
1766         uiBlockEndAlign(block);
1767
1768         /* stereo settings */
1769         /* can't use any definition from the game engine here so hardcode it. Change it here when it changes there!
1770          * RAS_IRasterizer has definitions:
1771          * RAS_STEREO_NOSTEREO           1
1772          * RAS_STEREO_QUADBUFFERED 2
1773          * RAS_STEREO_ABOVEBELOW         3
1774          * RAS_STEREO_INTERLACED         4       future
1775          * RAS_STEREO_ANAGLYPH          5
1776          * RAS_STEREO_SIDEBYSIDE        6
1777          * RAS_STEREO_VINTERLACE        7
1778          */
1779         uiBlockBeginAlign(block);
1780         uiDefButS(block, ROW, 0, "No Stereo", xco, yco-=30, 88, 19, &(G.scene->r.stereomode), 7.0, 1.0, 0, 0, "Disables stereo");
1781         uiDefButS(block, ROW, 0, "Pageflip", xco+=90, yco, 88, 19, &(G.scene->r.stereomode), 7.0, 2.0, 0, 0, "Enables hardware pageflip stereo method");
1782         uiDefButS(block, ROW, 0, "Syncdouble", xco+=90, yco, 88, 19, &(G.scene->r.stereomode), 7.0, 3.0, 0, 0, "Enables syncdoubling stereo method");
1783         uiDefButS(block, ROW, 0, "Anaglyph", xco-=180, yco-=21, 88, 19, &(G.scene->r.stereomode), 7.0, 5.0, 0, 0, "Enables anaglyph (Red-Blue) stereo method");
1784         uiDefButS(block, ROW, 0, "Side by Side", xco+=90, yco, 88, 19, &(G.scene->r.stereomode), 7.0, 6.0, 0, 0, "Enables side by side left and right images");
1785         uiDefButS(block, ROW, 0, "V Interlace", xco+=90, yco, 88, 19, &(G.scene->r.stereomode), 7.0, 7.0, 0, 0, "Enables interlaced vertical strips for autostereo display");
1786         
1787         uiBlockEndAlign(block);
1788
1789         uiBlockSetDirection(block, UI_TOP);
1790
1791         return block;
1792 }
1793
1794 #ifdef WITH_FFMPEG
1795
1796 static char* ffmpeg_format_pup(void) 
1797 {
1798         static char string[2048];
1799         char formatstring[2048];
1800 #if 0
1801        int i = 0;
1802        int stroffs = 0;
1803        AVOutputFormat* next = first_oformat;
1804        formatstring = "FFMpeg format: %%t";
1805       sprintf(string, formatstring);
1806        formatstring = "|%s %%x%d";
1807        /* FIXME: This should only be generated once */
1808        while (next != NULL) {
1809                if (next->video_codec != CODEC_ID_NONE && !(next->flags & AVFMT_NOFILE)) {
1810                        sprintf(string+stroffs, formatstring, next->name, i++);
1811                        stroffs += strlen(string+stroffs);
1812                }
1813                next = next->next;
1814        }
1815        return string;
1816 #endif
1817        strcpy(formatstring, "FFMpeg format: %%t|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d");
1818        sprintf(string, formatstring,
1819                "MPEG-1", FFMPEG_MPEG1,
1820                "MPEG-2", FFMPEG_MPEG2,
1821                "MPEG-4", FFMPEG_MPEG4,
1822                "AVI",    FFMPEG_AVI,
1823                "Quicktime", FFMPEG_MOV,
1824                "DV", FFMPEG_DV,
1825                "H264", FFMPEG_H264,
1826                "XVid", FFMPEG_XVID,
1827                "FLV", FFMPEG_FLV);
1828        return string;
1829 }
1830
1831 static char* ffmpeg_preset_pup(void) 
1832 {
1833         static char string[2048];
1834         char formatstring[2048];
1835
1836        strcpy(formatstring, "FFMpeg preset: %%t|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d");
1837        sprintf(string, formatstring,
1838                "", FFMPEG_PRESET_NONE,
1839                "DVD", FFMPEG_PRESET_DVD,
1840                "SVCD", FFMPEG_PRESET_SVCD,
1841                "VCD", FFMPEG_PRESET_VCD,
1842                "DV", FFMPEG_PRESET_DV);
1843        return string;
1844 }
1845
1846
1847 static char* ffmpeg_codec_pup(void) {
1848        static char string[2048];
1849        char formatstring[2048];
1850        strcpy(formatstring, "FFMpeg format: %%t|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d");
1851        sprintf(string, formatstring,
1852                "MPEG1", CODEC_ID_MPEG1VIDEO,
1853                "MPEG2", CODEC_ID_MPEG2VIDEO,
1854                "MPEG4(divx)", CODEC_ID_MPEG4,
1855                "HuffYUV", CODEC_ID_HUFFYUV,
1856                "DV", CODEC_ID_DVVIDEO,
1857                "H264", CODEC_ID_H264,
1858                "XVid", CODEC_ID_XVID,
1859                "FlashVideo1", CODEC_ID_FLV1 );
1860        return string;
1861
1862 }
1863
1864 static char* ffmpeg_audio_codec_pup(void) {
1865        static char string[2048];
1866        char formatstring[2048];
1867        strcpy(formatstring, "FFMpeg format: %%t|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d");
1868        sprintf(string, formatstring,
1869                "MP2", CODEC_ID_MP2,
1870                "MP3", CODEC_ID_MP3,
1871                "AC3", CODEC_ID_AC3,
1872                "AAC", CODEC_ID_AAC,
1873                "PCM", CODEC_ID_PCM_S16LE);
1874        return string;
1875
1876 }
1877
1878 #endif
1879
1880 static char *imagetype_pup(void)
1881 {
1882         static char string[1024];
1883         char formatstring[1024];
1884         char appendstring[1024];
1885
1886         strcpy(formatstring, "Save image as: %%t|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d");
1887
1888 #ifdef __sgi
1889         strcat(formatstring, "|%s %%x%d");      // add space for Movie
1890 #endif
1891
1892         strcat(formatstring, "|%s %%x%d");      // add space for PNG
1893 /*  Commented out until implemented
1894 #ifdef WITH_DDS
1895         strcat(formatstring, "|%s %%x%d");      // add space for DDS
1896 #endif
1897 */
1898         strcat(formatstring, "|%s %%x%d");      // add space for BMP
1899         strcat(formatstring, "|%s %%x%d");      // add space for Radiance HDR
1900         strcat(formatstring, "|%s %%x%d");      // add space for Cineon
1901         strcat(formatstring, "|%s %%x%d");      // add space for DPX
1902         
1903 #ifdef _WIN32
1904         strcat(formatstring, "|%s %%x%d");      // add space for AVI Codec
1905 #endif
1906
1907 #ifdef WITH_FFMPEG
1908        strcat(formatstring, "|%s %%x%d"); // Add space for ffmpeg
1909 #endif
1910        strcat(formatstring, "|%s %%x%d"); // Add space for frameserver
1911
1912 #ifdef WITH_QUICKTIME
1913         if(G.have_quicktime)
1914                 strcat(formatstring, "|%s %%x%d");      // add space for Quicktime
1915 #endif
1916
1917         if(G.have_quicktime) {
1918                 sprintf(string, formatstring,
1919                         "Frameserver",   R_FRAMESERVER,
1920 #ifdef WITH_FFMPEG
1921                        "FFMpeg",         R_FFMPEG,
1922 #endif
1923                         "AVI Raw",        R_AVIRAW,
1924                         "AVI Jpeg",       R_AVIJPEG,
1925 #ifdef _WIN32
1926                         "AVI Codec",      R_AVICODEC,
1927 #endif
1928 #ifdef WITH_QUICKTIME
1929                         "QuickTime",      R_QUICKTIME,
1930 #endif
1931                         "Targa",          R_TARGA,
1932                         "Targa Raw",      R_RAWTGA,
1933                         "PNG",            R_PNG,
1934 /* commented out until implemented 
1935 #ifdef WITH_DDS
1936                         "DDS",            R_DDS,
1937 #endif
1938 */
1939                         "BMP",            R_BMP,
1940                         "Jpeg",           R_JPEG90,
1941                         "HamX",           R_HAMX,
1942                         "Iris",           R_IRIS,
1943                         "Radiance HDR",   R_RADHDR,
1944                         "Cineon",                 R_CINEON,
1945                         "DPX",                    R_DPX
1946 #ifdef __sgi
1947                         ,"Movie",          R_MOVIE
1948 #endif
1949                 );
1950         } else {
1951                 sprintf(string, formatstring,
1952                         "Frameserver",   R_FRAMESERVER,
1953 #ifdef WITH_FFMPEG
1954                        "FFMpeg",         R_FFMPEG,
1955 #endif
1956                         "AVI Raw",        R_AVIRAW,
1957                         "AVI Jpeg",       R_AVIJPEG,
1958 #ifdef _WIN32
1959                         "AVI Codec",      R_AVICODEC,
1960 #endif
1961                         "Targa",          R_TARGA,
1962                         "Targa Raw",      R_RAWTGA,
1963                         "PNG",            R_PNG,
1964 /*#ifdef WITH_DDS
1965                         "DDS",            R_DDS,
1966 #endif*/
1967                         "BMP",            R_BMP,
1968                         "Jpeg",           R_JPEG90,
1969                         "HamX",           R_HAMX,
1970                         "Iris",           R_IRIS,
1971                         "Radiance HDR",   R_RADHDR,
1972                         "Cineon",                 R_CINEON,
1973                         "DPX",                    R_DPX
1974 #ifdef __sgi
1975                         ,"Movie",          R_MOVIE
1976 #endif
1977                 );
1978         }
1979
1980 #ifdef WITH_OPENEXR
1981         strcpy(formatstring, "|%s %%x%d");
1982         sprintf(appendstring, formatstring, "OpenEXR", R_OPENEXR);
1983         strcat(string, appendstring);
1984         sprintf(appendstring, formatstring, "MultiLayer", R_MULTILAYER);
1985         strcat(string, appendstring);
1986 #endif
1987         
1988         if (G.have_libtiff) {
1989                 strcpy(formatstring, "|%s %%x%d");
1990                 sprintf(appendstring, formatstring, "TIFF", R_TIFF);
1991                 strcat(string, appendstring);
1992         }
1993
1994         return (string);
1995 }
1996
1997 #ifdef _WIN32
1998 static char *avicodec_str(void)
1999 {
2000         static char string[1024];
2001
2002         sprintf(string, "Codec: %s", G.scene->r.avicodecdata->avicodecname);
2003
2004         return string;
2005 }
2006 #endif
2007
2008 static void render_panel_output(void)
2009 {
2010         ID *id;
2011         int a,b;
2012         uiBlock *block;
2013         char *strp;
2014
2015         block= uiNewBlock(&curarea->uiblocks, "render_panel_output", UI_EMBOSS, UI_HELV, curarea->win);
2016         if(uiNewPanel(curarea, block, "Output", "Render", 0, 0, 318, 204)==0) return;
2017         
2018         uiBlockBeginAlign(block);
2019         uiDefIconBut(block, BUT, B_FS_PIC, ICON_FILESEL,        10, 190, 20, 20, 0, 0, 0, 0, 0, "Select the directory/name for saving animations");
2020         uiDefBut(block, TEX,0,"",                                                       31, 190, 279, 20,G.scene->r.pic, 0.0,79.0, 0, 0, "Directory/name to save animations, # characters defines the position and length of frame numbers");
2021         uiDefIconBut(block, BUT,B_FS_BACKBUF, ICON_FILESEL, 10, 168, 20, 20, 0, 0, 0, 0, 0, "Select the directory/name for a Backbuf image");
2022         uiDefBut(block, TEX,0,"",                                                       31, 168, 259, 20,G.scene->r.backbuf, 0.0,79.0, 0, 0, "Image to use as background for rendering");
2023         uiDefIconButBitS(block, ICONTOG, R_BACKBUF, B_NOP, ICON_CHECKBOX_HLT-1, 290, 168, 20, 20, &G.scene->r.bufflag, 0.0, 0.0, 0, 0, "Enable/Disable use of Backbuf image");
2024         uiBlockEndAlign(block);
2025         
2026         uiDefButBitI(block, TOG, R_EXTENSION, B_NOP, "Extensions", 10, 142, 100, 20, &G.scene->r.scemode, 0.0, 0.0, 0, 0, "Adds filetype extensions to the filename when rendering animations");
2027         
2028         uiBlockBeginAlign(block);
2029         uiDefButBitI(block, TOG, R_TOUCH, B_NOP, "Touch",       170, 142, 50, 20, &G.scene->r.mode, 0.0, 0.0, 0, 0, "Create an empty file before rendering each frame, remove if cancelled (and empty)");
2030         uiDefButBitI(block, TOG, R_NO_OVERWRITE, B_NOP, "No Overwrite", 220, 142, 90, 20, &G.scene->r.mode, 0.0, 0.0, 0, 0, "Skip rendering frames when the file exists (image output only)");
2031         uiBlockEndAlign(block);
2032         
2033         /* SET BUTTON */
2034         uiBlockBeginAlign(block);
2035         id= (ID *)G.scene->set;
2036         IDnames_to_pupstring(&strp, NULL, NULL, &(G.main->scene), id, &(G.buts->menunr));
2037         if(strp[0])
2038                 uiDefButS(block, MENU, B_SETBROWSE, strp,                       10, 114, 20, 20, &(G.buts->menunr), 0, 0, 0, 0, "Scene to link as a Set");
2039         MEM_freeN(strp);
2040
2041         if(G.scene->set) {
2042                 uiSetButLock(1, NULL);
2043                 uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, B_NOP, "",    31, 114, 100, 20, &(G.scene->set), "Name of the Set");
2044                 uiClearButLock();
2045                 uiDefIconBut(block, BUT, B_CLEARSET, ICON_X,            132, 114, 20, 20, 0, 0, 0, 0, 0, "Remove Set link");
2046         } else {
2047                 uiDefBut(block, LABEL, 0, "No Set Scene", 31, 114, 200, 20, 0, 0, 0, 0, 0, "");
2048         }
2049         uiBlockEndAlign(block);
2050
2051         uiBlockBeginAlign(block);
2052         uiDefIconButBitI(block, TOGN, R_FIXED_THREADS, B_REDR, ICON_AUTO,       10, 63, 20, 20, &G.scene->r.mode, 0.0, 0.0, 0, 0, "Automatically set the threads to the number of processors on the system");
2053         if ((G.scene->r.mode & R_FIXED_THREADS)==0) {
2054                 char thread_str[16];
2055                 sprintf(thread_str, " Threads: %d", BLI_system_thread_count());
2056                 uiDefBut(block, LABEL, 0, thread_str, 30, 63,80,20, 0, 0, 0, 0, 0, "");
2057         } else {
2058                 uiDefButS(block, NUM, B_NOP, "Threads:", 30, 63, 80, 20, &G.scene->r.threads, 1, BLENDER_MAX_THREADS, 0, 0, "Amount of threads for render (takes advantage of multi-core and multi-processor computers)");
2059         }
2060         uiBlockEndAlign(block);
2061         
2062         uiBlockSetCol(block, TH_AUTO);
2063                 
2064         uiBlockBeginAlign(block);
2065         for(b=2; b>=0; b--)
2066                 for(a=0; a<3; a++)
2067                         uiDefButBitS(block, TOG, 1<<(3*b+a), 800,"",    (short)(10+18*a),(short)(10+14*b),16,12, &G.winpos, 0, 0, 0, 0, "Render window placement on screen");
2068         uiBlockEndAlign(block);
2069
2070 #ifdef WITH_OPENEXR
2071         uiBlockBeginAlign(block);
2072         uiDefButBitI(block, TOG, R_EXR_TILE_FILE, B_REDR, "Save Buffers", 72, 31, 120, 19, &G.scene->r.scemode, 0.0, 0.0, 0, 0, "Save tiles for all RenderLayers and used SceneNodes to files in the temp directory (saves memory, allows Full Sampling)");
2073         if(G.scene->r.scemode & R_EXR_TILE_FILE)
2074                 uiDefButBitI(block, TOG, R_FULL_SAMPLE, B_REDR, "FullSample",    192, 31, 118, 19, &G.scene->r.scemode, 0.0, 0.0, 0, 0, "Saves for every OSA sample the entire RenderLayer results (Higher quality sampling but slower)");
2075         uiBlockEndAlign(block);
2076 #endif
2077         
2078         uiDefButS(block, MENU, B_REDR, "Render Display %t|Render Window %x1|Image Editor %x0|Full Screen %x2",  
2079                                         72, 10, 120, 19, &G.displaymode, 0.0, (float)R_DISPLAYWIN, 0, 0, "Sets render output display");
2080         
2081         /* Dither control */
2082         uiDefButF(block, NUM,B_DIFF, "Dither:",         10,89,100,19, &G.scene->r.dither_intensity, 0.0, 2.0, 0, 0, "The amount of dithering noise present in the output image (0.0 = no dithering)");
2083         
2084         /* Toon shading buttons */
2085         uiBlockBeginAlign(block);
2086         uiDefButBitI(block, TOG, R_EDGE, B_NOP,"Edge",   115, 89, 60, 20, &G.scene->r.mode, 0, 0, 0, 0, "Enable Toon Edge-enhance");
2087         uiDefBlockBut(block, edge_render_menu, NULL, "Edge Settings", 175, 89, 135, 20, "Display Edge settings");
2088         uiBlockEndAlign(block);
2089         
2090         uiBlockBeginAlign(block);
2091         uiDefButBitI(block, TOG, R_NO_TEX, B_NOP, "Disable Tex", 115, 63, 75, 20, &G.scene->r.scemode, 0.0, 0.0, 0, 0, "Disables Textures for render");
2092         uiDefButBitI(block, TOG, R_FREE_IMAGE, B_NOP, "Free Tex Images", 210, 63, 100, 20, &G.scene->r.scemode, 0.0, 0.0, 0, 0, "Frees all Images used by Textures after each render");
2093         uiBlockEndAlign(block);
2094 }
2095
2096 static void do_bake_func(void *unused_v, void *unused_p)
2097 {
2098         objects_bake_render_ui(0);
2099 }
2100
2101 static void render_panel_bake(void)
2102 {
2103         uiBlock *block;
2104         uiBut *but;
2105         
2106         block= uiNewBlock(&curarea->uiblocks, "render_panel_bake", UI_EMBOSS, UI_HELV, curarea->win);
2107         uiNewPanelTabbed("Anim", "Render");
2108         if(uiNewPanel(curarea, block, "Bake", "Render", 320, 0, 318, 204)==0) return;
2109         
2110         but= uiDefBut(block, BUT, B_NOP, "BAKE",        10, 150, 190,40, 0, 0, 0, 0, 0, "Start the bake render for selected Objects");
2111         uiButSetFunc(but, do_bake_func, NULL, NULL);
2112
2113         uiBlockBeginAlign(block);
2114         uiDefButBitS(block, TOG, R_BAKE_TO_ACTIVE, B_DIFF, "Selected to Active", 10,120,190,20,&G.scene->r.bake_flag, 0.0, 0, 0, 0, "Bake shading on the surface of selected objects to the active object");
2115         uiDefButF(block, NUM, B_DIFF, "Dist:", 10,100,95,20,&G.scene->r.bake_maxdist, 0.0, 1000.0, 1, 0, "Maximum distance from active object to other object (in blender units)");
2116         uiDefButF(block, NUM, B_DIFF, "Bias:", 105,100,95,20,&G.scene->r.bake_biasdist, 0.0, 1000.0, 1, 0, "Bias towards faces further away from the object (in blender units)");
2117         uiBlockEndAlign(block);
2118
2119         if(G.scene->r.bake_mode == RE_BAKE_NORMALS)
2120                 uiDefButS(block, MENU, B_DIFF, "Normal Space %t|Camera %x0|World %x1|Object %x2|Tangent %x3", 
2121                         10,70,190,20, &G.scene->r.bake_normal_space, 0, 0, 0, 0, "Choose normal space for baking");
2122         else if(G.scene->r.bake_mode == RE_BAKE_AO || G.scene->r.bake_mode == RE_BAKE_DISPLACEMENT) {
2123                 uiDefButBitS(block, TOG, R_BAKE_NORMALIZE, B_DIFF, "Normalized", 10,70,190,20, &G.scene->r.bake_flag, 0.0, 0, 0, 0,
2124                                 G.scene->r.bake_mode == RE_BAKE_AO ?
2125                                  "Bake ambient occlusion normalized, without taking into acount material settings":
2126                                  "Normalized displacement value to fit the 'Dist' range"
2127                 );
2128         }
2129 #if 0   
2130         uiBlockBeginAlign(block);
2131         uiDefButBitS(block, TOG, R_BAKE_OSA, B_DIFF, "OSA",             10,120,190,20, &G.scene->r.bake_flag, 0, 0, 0, 0, "Enables Oversampling (Anti-aliasing)");
2132         uiDefButS(block, ROW,B_DIFF,"5",                        10,100,50,20,&G.scene->r.bake_osa,2.0,5.0, 0, 0, "Sets oversample level to 5");
2133         uiDefButS(block, ROW,B_DIFF,"8",                        60,100,45,20,&G.scene->r.bake_osa,2.0,8.0, 0, 0, "Sets oversample level to 8");
2134         uiDefButS(block, ROW,B_DIFF,"11",                       105,100,45,20,&G.scene->r.bake_osa,2.0,11.0, 0, 0, "Sets oversample level to 11");
2135         uiDefButS(block, ROW,B_DIFF,"16",                       150,100,50,20,&G.scene->r.bake_osa,2.0,16.0, 0, 0, "Sets oversample level to 16");
2136 #endif  
2137         uiBlockBeginAlign(block);
2138         uiDefButS(block, ROW,B_REDR,"Full Render",              210,170,120,20,&G.scene->r.bake_mode, 1.0, RE_BAKE_ALL, 0, 0, "");
2139         uiDefButS(block, ROW,B_REDR,"Ambient Occlusion",210,150,120,20,&G.scene->r.bake_mode, 1.0, RE_BAKE_AO, 0, 0, "");
2140         uiDefButS(block, ROW,B_REDR,"Normals",          210,130,120,20,&G.scene->r.bake_mode, 1.0, RE_BAKE_NORMALS, 0, 0, "");
2141         uiDefButS(block, ROW,B_REDR,"Textures",         210,110,120,20,&G.scene->r.bake_mode, 1.0, RE_BAKE_TEXTURE, 0, 0, "");
2142         uiDefButS(block, ROW,B_REDR,"Displacement",             210,90,120,20,&G.scene->r.bake_mode, 1.0, RE_BAKE_DISPLACEMENT, 0, 0, "");
2143         uiBlockEndAlign(block);
2144         
2145         uiDefButBitS(block, TOG, R_BAKE_CLEAR, B_DIFF, "Clear",         210,60,120,20,&G.scene->r.bake_flag, 0.0, 0, 0, 0, "Clear Images before baking");
2146         
2147         uiDefButS(block, NUM, B_DIFF,"Margin:",                         210,30,120,20,&G.scene->r.bake_filter, 0.0, 32.0, 0, 0, "Amount of pixels to extend the baked result with, as post process filter");
2148 }
2149
2150 static void render_panel_simplify(void)
2151 {
2152         uiBlock *block;
2153         
2154         block= uiNewBlock(&curarea->uiblocks, "render_panel_simplify", UI_EMBOSS, UI_HELV, curarea->win);
2155         uiNewPanelTabbed("Render", "Render");
2156         if(uiNewPanel(curarea, block, "Simplifcation", "Render", 320, 0, 318, 204)==0) return;
2157
2158         uiDefButBitI(block, TOG, R_SIMPLIFY, B_DIFF,"Render Simplification",    10,150,190,20, &G.scene->r.mode, 0, 0, 0, 0, "Enable simplification of scene");
2159
2160         uiBlockBeginAlign(block);
2161         uiDefButI(block, NUM,B_DIFF, "Subsurf:",        10,120,190,20, &G.scene->r.simplify_subsurf, 0.0, 6.0, 0, 0, "Global maximum subsurf level percentage");
2162         uiDefButF(block, NUM,B_DIFF, "Child Particles:",        10,100,190,20, &G.scene->r.simplify_particles, 0.0, 1.0, 0, 0, "Global child particle percentage");
2163         uiBlockEndAlign(block);
2164
2165         uiBlockBeginAlign(block);
2166         uiDefButI(block, NUM,B_DIFF, "Shadow Samples:", 10,70,190,20, &G.scene->r.simplify_shadowsamples, 1.0, 16.0, 0, 0, "Global maximum shadow map samples");
2167         uiDefButF(block, NUM,B_DIFF, "AO and SSS:",     10,50,190,20, &G.scene->r.simplify_aosss, 0.0, 1.0, 0, 0, "Global approximate AO and SSS quality factor");
2168         uiBlockEndAlign(block);
2169 }
2170
2171 static void render_panel_render(void)
2172 {
2173         uiBlock *block;
2174         char str[256];
2175
2176         block= uiNewBlock(&curarea->uiblocks, "render_panel_render", UI_EMBOSS, UI_HELV, curarea->win);
2177         if(uiNewPanel(curarea, block, "Render", "Render", 320, 0, 318, 204)==0) return;
2178
2179         uiBlockBeginAlign(block);
2180         uiDefBut(block, BUT,B_DORENDER,"RENDER",        369, 164, 191,37, 0, 0, 0, 0, 0, "Render the current frame (F12)");
2181 #ifndef DISABLE_YAFRAY
2182         /* yafray: on request, render engine menu is back again, and moved to Render panel */
2183         uiDefButS(block, MENU, B_SWITCHRENDER, "Rendering Engine %t|Blender Internal %x0|YafRay %x1", 
2184                                                                                                 369, 142, 191, 20, &G.scene->r.renderer, 0, 0, 0, 0, "Choose rendering engine");        
2185 #else
2186         uiDefButS(block, MENU, B_SWITCHRENDER, "Rendering Engine %t|Blender Internal %x0", 
2187                                                                                                 369, 142, 191, 20, &G.scene->r.renderer, 0, 0, 0, 0, "Choose rendering engine");        
2188 #endif /* disable yafray */
2189
2190         uiBlockBeginAlign(block);
2191         if((G.scene->r.scemode & R_FULL_SAMPLE) && (G.scene->r.scemode & R_EXR_TILE_FILE))
2192                 uiDefButBitI(block, TOG, R_OSA, B_DIFF, "FSA",  369,109,122,20,&G.scene->r.mode, 0, 0, 0, 0, "Saves all samples, then composites, and then merges (for best Anti-aliasing)");
2193         else
2194                 uiDefButBitI(block, TOG, R_OSA, B_DIFF, "OSA",  369,109,122,20,&G.scene->r.mode, 0, 0, 0, 0, "Enables Oversampling (Anti-aliasing)");
2195         uiDefButS(block, ROW,B_DIFF,"5",                        369,88,29,20,&G.scene->r.osa,2.0,5.0, 0, 0, "Render 5 samples per pixel for smooth edges (Fast)");
2196         uiDefButS(block, ROW,B_DIFF,"8",                        400,88,29,20,&G.scene->r.osa,2.0,8.0, 0, 0, "Render 8 samples per pixel for smooth edges (Recommended)");
2197         uiDefButS(block, ROW,B_DIFF,"11",                       431,88,29,20,&G.scene->r.osa,2.0,11.0, 0, 0, "Render 11 samples per pixel for smooth edges (High Quality)");
2198         uiDefButS(block, ROW,B_DIFF,"16",                       462,88,29,20,&G.scene->r.osa,2.0,16.0, 0, 0, "Render 16 samples per pixel for smooth edges (Highest Quality)");
2199         uiBlockEndAlign(block);
2200
2201         uiBlockBeginAlign(block);
2202         uiDefButBitI(block, TOG, R_MBLUR, B_REDR, "MBLUR",      496,109,64,20,&G.scene->r.mode, 0, 0, 0, 0, "Enables Motion Blur calculation");
2203         uiDefButF(block, NUM,B_DIFF,"Bf:",                      496,88,64,20,&G.scene->r.blurfac, 0.01, 5.0, 10, 2, "Sets motion blur factor");
2204         uiBlockEndAlign(block);
2205
2206         uiBlockBeginAlign(block);
2207         uiDefButS(block, NUM,B_DIFF,"Xparts:",          369,46,95,29,&G.scene->r.xparts,1.0, 512.0, 0, 0, "Sets the number of horizontal parts to render image in (For panorama sets number of camera slices)");
2208         uiDefButS(block, NUM,B_DIFF,"Yparts:",          465,46,95,29,&G.scene->r.yparts,1.0, 64.0, 0, 0, "Sets the number of vertical parts to render image in");
2209         uiBlockEndAlign(block);
2210
2211         uiBlockBeginAlign(block);
2212         uiDefButS(block, ROW,800,"Sky",         369,13,35,20,&G.scene->r.alphamode,3.0,0.0, 0, 0, "Fill background with sky");
2213         uiDefButS(block, ROW,800,"Premul",      405,13,50,20,&G.scene->r.alphamode,3.0,1.0, 0, 0, "Multiply alpha in advance");
2214         uiDefButS(block, ROW,800,"Key",         456,13,35,20,&G.scene->r.alphamode,3.0,2.0, 0, 0, "Alpha and color values remain unchanged");
2215         uiBlockEndAlign(block);
2216
2217         uiDefButS(block, MENU, B_DIFF,"Octree resolution %t|64 %x64|128 %x128|256 %x256|512 %x512",     496,13,64,20,&G.scene->r.ocres,0.0,0.0, 0, 0, "Octree resolution for ray tracing and baking, Use higher values for complex scenes");
2218
2219         uiBlockBeginAlign(block);
2220         uiDefButBitI(block, TOG, R_SHADOW, B_REDR,"Shadow",     565,172,52,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable shadow calculation");
2221         uiDefButBitI(block, TOG, R_SSS, B_REDR,"SSS",   617,172,32,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable subsurface scattering map rendering");
2222         uiDefButBitI(block, TOG, R_PANORAMA, B_REDR,"Pano",     649,172,38,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable panorama rendering (output width is multiplied by Xparts)");
2223         uiDefButBitI(block, TOG, R_ENVMAP, B_REDR,"EnvMap",     565,142,52,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable environment map rendering");
2224         uiDefButBitI(block, TOG, R_RAYTRACE, B_REDR,"Ray",617,142,32,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable ray tracing");
2225         uiDefButBitI(block, TOG, R_RADIO, B_REDR,"Radio",       649,142,38,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable radiosity rendering");
2226         uiBlockEndAlign(block);
2227         
2228         uiBlockBeginAlign(block);
2229         uiDefButS(block, ROW,B_DIFF,"100%",                     565,109,122,20,&G.scene->r.size,1.0,100.0, 0, 0, "Set render size to defined size");
2230         uiDefButS(block, ROW,B_DIFF,"75%",                      565,88,40,20,&G.scene->r.size,1.0,75.0, 0, 0, "Set render size to 3/4 of defined size");
2231         uiDefButS(block, ROW,B_DIFF,"50%",                      606,88,40,20,&G.scene->r.size,1.0,50.0, 0, 0, "Set render size to 1/2 of defined size");
2232         uiDefButS(block, ROW,B_DIFF,"25%",                      647,88,40,20,&G.scene->r.size,1.0,25.0, 0, 0, "Set render size to 1/4 of defined size");
2233         uiBlockEndAlign(block);
2234
2235         uiBlockBeginAlign(block);
2236         uiDefButBitI(block, TOG, R_FIELDS, B_REDR,"Fields",  565,55,60,20,&G.scene->r.mode, 0, 0, 0, 0, "Enables field rendering");
2237         uiDefButBitI(block, TOG, R_ODDFIELD, B_REDR,"Odd",      627,55,39,20,&G.scene->r.mode, 0, 0, 0, 0, "Enables Odd field first rendering (Default: Even field)");
2238         uiDefButBitI(block, TOG, R_FIELDSTILL, B_REDR,"X",              668,55,19,20,&G.scene->r.mode, 0, 0, 0, 0, "Disables time difference in field calculations");
2239         
2240         sprintf(str, "Filter%%t|Box %%x%d|Tent %%x%d|Quad %%x%d|Cubic %%x%d|Gauss %%x%d|CatRom %%x%d|Mitch %%x%d", R_FILTER_BOX, R_FILTER_TENT, R_FILTER_QUAD, R_FILTER_CUBIC, R_FILTER_GAUSS, R_FILTER_CATROM, R_FILTER_MITCH);
2241         uiDefButS(block, MENU, B_DIFF,str,              565,34,60,20, &G.scene->r.filtertype, 0, 0, 0, 0, "Set sampling filter for antialiasing");
2242         uiDefButF(block, NUM,B_DIFF,"",                 627,34,60,20,&G.scene->r.gauss,0.5, 1.5, 10, 2, "Sets the filter size");
2243         
2244         uiDefButBitI(block, TOG, R_BORDER, REDRAWVIEWCAM, "Border",     565,13,122,20, &G.scene->r.mode, 0, 0, 0, 0, "Render a small cut-out of the image (Shift+B to set in the camera view)");
2245         uiBlockEndAlign(block);
2246
2247 }
2248
2249 static void render_panel_anim(void)
2250 {
2251         uiBlock *block;
2252
2253
2254         block= uiNewBlock(&curarea->uiblocks, "render_panel_anim", UI_EMBOSS, UI_HELV, curarea->win);
2255         if(uiNewPanel(curarea, block, "Anim", "Render", 640, 0, 318, 204)==0) return;
2256
2257
2258         uiDefBut(block, BUT,B_DOANIM,"ANIM",            692,142,192,47, 0, 0, 0, 0, 0, "Render the animation to disk from start to end frame, (Ctrl+F12)");
2259
2260         uiBlockSetCol(block, TH_BUT_SETTING1);
2261         uiBlockBeginAlign(block);
2262         uiDefButBitI(block, TOG, R_DOSEQ, B_NOP, "Do Sequence",692,114,192,20, &G.scene->r.scemode, 0, 0, 0, 0, "Enables sequence output rendering (Default: 3D rendering)");
2263         uiDefButBitI(block, TOG, R_DOCOMP, B_NOP, "Do Composite",692,90,192,20, &G.scene->r.scemode, 0, 0, 0, 0, "Uses compositing nodes for output rendering");
2264         uiBlockEndAlign(block);
2265
2266         uiBlockSetCol(block, TH_AUTO);
2267         uiDefBut(block, BUT,B_PLAYANIM, "PLAY",692,40,94,33, 0, 0, 0, 0, 0, "Play rendered images/avi animation (Ctrl+F11), (Play Hotkeys: A-Noskip, P-PingPong)");
2268         uiDefButS(block, NUM, B_RTCHANGED, "rt:",789,40,95,33, &G.rt, -1000.0, 1000.0, 0, 0, "General testing/debug button");
2269
2270         uiBlockBeginAlign(block);
2271         uiDefButI(block, NUM,REDRAWSEQ,"Sta:",692,10,94,24, &G.scene->r.sfra,1.0,MAXFRAMEF, 0, 0, "The start frame of the animation (inclusive)");
2272         uiDefButI(block, NUM,REDRAWSEQ,"End:",789,10,95,24, &G.scene->r.efra,SFRA,MAXFRAMEF, 0, 0, "The end  frame of the animation  (inclusive)");
2273         uiBlockEndAlign(block);
2274 }
2275
2276 #ifdef WITH_FFMPEG
2277 static void set_ffmpeg_preset(int preset)
2278 {
2279         int isntsc = (G.scene->r.frs_sec != 25);
2280         switch (preset) {
2281         case FFMPEG_PRESET_VCD:
2282                 G.scene->r.ffcodecdata.type = FFMPEG_MPEG1;
2283                 G.scene->r.ffcodecdata.video_bitrate = 1150;
2284                 G.scene->r.xsch = 352;
2285                 G.scene->r.ysch = isntsc ? 240 : 288;
2286                 G.scene->r.ffcodecdata.gop_size = isntsc ? 18 : 15;
2287                 G.scene->r.ffcodecdata.rc_max_rate = 1150;
2288                 G.scene->r.ffcodecdata.rc_min_rate = 1150;
2289                 G.scene->r.ffcodecdata.rc_buffer_size = 40*8;
2290                 G.scene->r.ffcodecdata.mux_packet_size = 2324;
2291                 G.scene->r.ffcodecdata.mux_rate = 2352 * 75 * 8;
2292                 break;
2293         case FFMPEG_PRESET_SVCD:
2294                 G.scene->r.ffcodecdata.type = FFMPEG_MPEG2;
2295                 G.scene->r.ffcodecdata.video_bitrate = 2040;
2296                 G.scene->r.xsch = 480;
2297                 G.scene->r.ysch = isntsc ? 480 : 576;
2298                 G.scene->r.ffcodecdata.gop_size = isntsc ? 18 : 15;
2299                 G.scene->r.ffcodecdata.rc_max_rate = 2516;
2300                 G.scene->r.ffcodecdata.rc_min_rate = 0;
2301                 G.scene->r.ffcodecdata.rc_buffer_size = 224*8;
2302                 G.scene->r.ffcodecdata.mux_packet_size = 2324;
2303                 G.scene->r.ffcodecdata.mux_rate = 0;
2304                 
2305                 break;
2306         case FFMPEG_PRESET_DVD:
2307                 G.scene->r.ffcodecdata.type = FFMPEG_MPEG2;
2308                 G.scene->r.ffcodecdata.video_bitrate = 6000;
2309                 G.scene->r.xsch = 720;
2310                 G.scene->r.ysch = isntsc ? 480 : 576;
2311                 G.scene->r.ffcodecdata.gop_size = isntsc ? 18 : 15;
2312                 G.scene->r.ffcodecdata.rc_max_rate = 9000;
2313                 G.scene->r.ffcodecdata.rc_min_rate = 0;
2314                 G.scene->r.ffcodecdata.rc_buffer_size = 224*8;
2315                 G.scene->r.ffcodecdata.mux_packet_size = 2048;
2316                 G.scene->r.ffcodecdata.mux_rate = 10080000;
2317                 
2318                 break;
2319         case FFMPEG_PRESET_DV:
2320                 G.scene->r.ffcodecdata.type = FFMPEG_DV;
2321                 G.scene->r.xsch = 720;
2322                 G.scene->r.ysch = isntsc ? 480 : 576;
2323                 break;
2324         }
2325 }
2326
2327 static void render_panel_ffmpeg_video(void)
2328 {
2329         uiBlock *block;
2330         int yofs;
2331         int xcol1;
2332         int xcol2;
2333         
2334         block = uiNewBlock(&curarea->uiblocks, "render_panel_ffmpeg_video", 
2335                                            UI_EMBOSS, UI_HELV, curarea->win);
2336         
2337         uiNewPanelTabbed("Format", "Render");
2338         if (uiNewPanel(curarea, block, "Video", "Render", 960, 0, 318, 204)== 0) 
2339                 return;
2340         
2341         if (ffmpeg_preset_sel != 0) {
2342                 set_ffmpeg_preset(ffmpeg_preset_sel);
2343                 ffmpeg_preset_sel = 0;
2344                 allqueue(REDRAWBUTSSCENE, 0);
2345         }
2346         
2347         xcol1 = 872;
2348         xcol2 = 1002;
2349         
2350         yofs = 54;
2351         uiDefBut(block, LABEL, B_DIFF, "Format", xcol1, yofs+88, 
2352                          110, 20, 0, 0, 0, 0, 0, "");
2353         uiDefBut(block, LABEL, B_DIFF, "Preset", xcol2, yofs+88, 
2354                          110, 20, 0, 0, 0, 0, 0, "");
2355         uiDefButI(block, MENU, B_DIFF, ffmpeg_format_pup(), 
2356                           xcol1, yofs+66, 110, 20, &G.scene->r.ffcodecdata.type, 
2357                           0,0,0,0, "output file format");
2358         uiDefButI(block, NUM, B_DIFF, "Bitrate", 
2359                           xcol1, yofs+44, 110, 20, 
2360                           &G.scene->r.ffcodecdata.video_bitrate, 
2361                           1, 14000, 0, 0, "Video bitrate(kb/s)");
2362         uiDefButI(block, NUM, B_DIFF, "Min Rate", 
2363                           xcol1, yofs+22, 110, 20, &G.scene->r.ffcodecdata.rc_min_rate, 
2364                           0, 14000, 0, 0, "Rate control: min rate(kb/s)");
2365         uiDefButI(block, NUM, B_DIFF, "Max Rate", 
2366                           xcol1, yofs, 110, 20, &G.scene->r.ffcodecdata.rc_max_rate, 
2367                           1, 14000, 0, 0, "Rate control: max rate(kb/s)");
2368         
2369         uiDefButI(block, NUM, B_DIFF, "Mux Rate", 
2370                           xcol1, yofs-22, 110, 20, 
2371                           &G.scene->r.ffcodecdata.mux_rate, 
2372                           0, 100000000, 0, 0, "Mux rate (bits/s(!))");
2373         
2374         
2375         uiDefButI(block, MENU, B_REDR, ffmpeg_preset_pup(), 
2376                           xcol2, yofs+66, 110, 20, &ffmpeg_preset_sel, 
2377                           0,0,0,0, "Output file format preset selection");
2378         uiDefButI(block, NUM, B_DIFF, "GOP Size", 
2379                           xcol2, yofs+44, 110, 20, &G.scene->r.ffcodecdata.gop_size, 
2380                           0, 100, 0, 0, "Distance between key frames");
2381         uiDefButI(block, NUM, B_DIFF, "Buffersize", 
2382                           xcol2, yofs+22, 110, 20,
2383                           &G.scene->r.ffcodecdata.rc_buffer_size, 
2384                           0, 2000, 0, 0, "Rate control: buffer size (kb)");
2385         uiDefButI(block, NUM, B_DIFF, "Mux PSize", 
2386                           xcol2, yofs, 110, 20, 
2387                           &G.scene->r.ffcodecdata.mux_packet_size, 
2388                           0, 16384, 0, 0, "Mux packet size (byte)");
2389         
2390         uiDefButBitI(block, TOG, FFMPEG_AUTOSPLIT_OUTPUT, B_NOP,
2391                                  "Autosplit Output", 
2392                                  xcol2, yofs-22, 110, 20, 
2393                                  &G.scene->r.ffcodecdata.flags, 
2394                                  0, 1, 0,0, "Autosplit output at 2GB boundary.");
2395         
2396         
2397         if (ELEM(G.scene->r.ffcodecdata.type, FFMPEG_AVI, FFMPEG_MOV)) {
2398                 uiDefBut(block, LABEL, 0, "Codec", 
2399                                 xcol1, yofs-44, 110, 20, 0, 0, 0, 0, 0, "");
2400                 uiDefButI(block, MENU,B_REDR, ffmpeg_codec_pup(), 
2401                                   xcol1, yofs-66, 110, 20, 
2402                                   &G.scene->r.ffcodecdata.codec, 
2403                                   0,0,0,0, "FFMpeg codec to use");
2404         }
2405 }
2406
2407 static void render_panel_ffmpeg_audio(void)
2408 {
2409         uiBlock *block;
2410         int yofs;
2411         int xcol;
2412         
2413         block = uiNewBlock(&curarea->uiblocks, "render_panel_ffmpeg_audio", UI_EMBOSS, UI_HELV, curarea->win);
2414         uiNewPanelTabbed("Format", "Render");
2415         if (uiNewPanel(curarea, block, "Audio", "Render", 960, 0, 318, 204) == 0) return;
2416         
2417         yofs = 54;
2418         xcol = 892;
2419         
2420         uiDefButBitI(block, TOG, FFMPEG_MULTIPLEX_AUDIO, B_NOP,
2421                                  "Multiplex audio", xcol, yofs, 225, 20, 
2422                                  &G.scene->r.ffcodecdata.flags, 
2423                                  0, 1, 0,0, "Interleave audio with the output video");
2424         uiDefBut(block, LABEL, 0, "Codec", 
2425                          xcol, yofs-22, 225, 20, 0, 0, 0, 0, 0, "");
2426         uiDefButI(block, MENU,B_NOP, ffmpeg_audio_codec_pup(), 
2427                           xcol, yofs-44, 225, 20, 
2428                           &G.scene->r.ffcodecdata.audio_codec, 
2429                           0,0,0,0, "FFMpeg codec to use");
2430         uiDefButI(block, NUM, B_DIFF, "Bitrate", 
2431                           xcol, yofs-66, 110, 20, 
2432                           &G.scene->r.ffcodecdata.audio_bitrate, 
2433                           32, 384, 0, 0, "Audio bitrate(kb/s)");
2434 }
2435 #endif
2436
2437 static void render_panel_stamp(void)
2438 {
2439         uiBlock *block;
2440         int yofs=0, xofs=550;
2441
2442         block= uiNewBlock (&curarea->uiblocks, "render_panel_stamp", UI_EMBOSS, UI_HELV, curarea->win);
2443         uiNewPanelTabbed ("Format", "Render");
2444         if(uiNewPanel (curarea, block, "Stamp", "Render", 960, 0, 318, 204)==0) return;
2445
2446         if (G.scene->r.scemode & R_STAMP_INFO) {
2447                 uiBlockBeginAlign(block);
2448                 uiDefButBitI(block, TOG, R_STAMP_NOTE, B_REDR, "Note", xofs, yofs, 120, 19, &G.scene->r.stamp, 0, 0, 0, 0, "Stamp user data");
2449                 uiDefBut(block, TEX, B_NOP, "", xofs+120, yofs, 180, 19, &G.scene->r.stamp_udata, 0.0, 128.0, 100, 0, "User Note");
2450                 uiBlockEndAlign(block);
2451                 yofs += 30; /* gap */
2452                 
2453                 
2454                 yofs += 80;
2455                 /* Order is important for alligning ... grr */
2456                 uiBlockBeginAlign(block);
2457                 uiDefButBitI(block, TOG, R_STAMP_FILENAME, B_REDR, "Filename", xofs, yofs, 120, 19, &G.scene->r.stamp, 0, 0, 0, 0, "Stamp blend filename");
2458                 yofs -= 20;
2459                 uiDefButBitI(block, TOG, R_STAMP_SCENE, B_REDR, "Scene", xofs, yofs, 60, 19, &G.scene->r.stamp, 0, 0, 0, 0, "Stamp scene name");
2460                 uiDefButBitI(block, TOG, R_STAMP_CAMERA, B_REDR, "Camera", xofs+60, yofs, 60, 19, &G.scene->r.stamp, 0, 0, 0, 0, "Stamp camera name");
2461                 yofs -= 20;
2462                 uiDefButBitI(block, TOG, R_STAMP_TIME, B_REDR, "Time", xofs, yofs, 60, 19, &G.scene->r.stamp, 0, 0, 0, 0, "Stamp time (HH:MM:SS)");
2463                 uiDefButBitI(block, TOG, R_STAMP_DATE, B_REDR, "Date", xofs+60, yofs, 60, 19, &G.scene->r.stamp, 0, 0, 0, 0, "Stamp date");
2464                 yofs -= 20;
2465                 uiDefButBitI(block, TOG, R_STAMP_FRAME, B_REDR, "Frame", xofs, yofs, 60, 19, &G.scene->r.stamp, 0, 0, 0, 0, "Stamp frame number");
2466                 uiDefButBitI(block, TOG, R_STAMP_MARKER, B_REDR, "Marker", xofs+60, yofs, 60, 19, &G.scene->r.stamp, 0, 0, 0, 0, "Stamp the last marker");
2467                 yofs -= 20;
2468                 uiDefButBitI(block, TOG, R_STAMP_SEQSTRIP, B_REDR, "Sequence Strip", xofs, yofs, 120, 19, &G.scene->r.stamp, 0, 0, 0, 0, "Stamp the forground sequence strip name");
2469                 uiBlockEndAlign(block);
2470                 yofs += 80;
2471                 
2472                 /* draw font selector */
2473                 if (G.scene->r.stamp & R_STAMP_DRAW) {
2474                         uiDefButS(block, MENU, B_REDR, "Stamp Font Size%t|Tiny Text%x1|Small Text%x2|Medium Text%x3|Large Text%x0|Extra Large Text%x4|",
2475                                         xofs+130, yofs, 170, 19, &G.scene->r.stamp_font_id, 0, 0, 0, 0, "Choose stamp text size");
2476                         
2477                         /* draw fg/bg next to the scene */
2478                         yofs -= 25;
2479                         uiDefBut(block, LABEL, B_NOP, "Text Color", xofs+130, yofs, 70, 19, 0, 0, 0, 0, 0, "");
2480                         uiDefBut(block, LABEL, B_NOP, "Background", xofs+215, yofs, 70, 19, 0, 0, 0, 0, 0, "");
2481                         yofs -= 20;
2482                         uiDefButF(block, COL, B_NOP, "", xofs+130, yofs, 80, 19, G.scene->r.fg_stamp, 0, 0, 0, 0, "Foreground text color");
2483                         uiDefButF(block, COL, B_NOP, "", xofs+220, yofs, 80, 19, G.scene->r.bg_stamp, 0, 0, 0, 0, "Background color");
2484                         yofs -= 30;
2485                         uiDefButF(block, NUMSLI, B_NOP, "A ", xofs+130, yofs, 170, 19, &G.scene->r.bg_stamp[3], 0, 1.0, 0, 0, "Alpha for text background");
2486                         yofs += 105;
2487                 } else {
2488                         yofs += 30;
2489                 }
2490                 
2491                 uiDefButBitI(block, TOG, R_STAMP_INFO, B_REDR, "Enable Stamp", xofs, yofs, 120, 20, &G.scene->r.scemode, 0, 0, 0, 0, "Disable stamp info in images metadata");
2492                 uiDefButBitI(block, TOG, R_STAMP_DRAW, B_REDR, "Draw Stamp", xofs+130, yofs, 170, 20, &G.scene->r.stamp, 0, 0, 0, 0, "Draw the stamp info into each frame");
2493                 yofs += 20;
2494         }
2495         else {
2496                 uiDefButBitI(block, TOG, R_STAMP_INFO, B_REDR, "Enable Stamp", xofs, 142, 120, 20, &G.scene->r.scemode, 0, 0, 0, 0, "Enable stamp info to image metadata");
2497                 yofs += 20;
2498                 uiDefBut(block, LABEL, 0, "", xofs, yofs, 300, 19, 0, 0, 0, 0, 0, "");
2499         }
2500 }
2501
2502 static void render_panel_format(void)
2503 {
2504         uiBlock *block;
2505         int yofs;
2506
2507
2508         block= uiNewBlock(&curarea->uiblocks, "render_panel_format", UI_EMBOSS, UI_HELV, curarea->win);
2509         if(uiNewPanel(curarea, block, "Format", "Render", 960, 0, 318, 204)==0) return;
2510         uiDefBlockBut(block, framing_render_menu, NULL, 
2511                                   "Game framing settings", 
2512                                   892, 169, 227, 20, "Display game framing settings");
2513         /* uiDefIconTextBlockBut(block, framing_render_menu, NULL, 
2514                                                    ICON_BLOCKBUT_CORNER, 
2515                                                    "Game framing settings", 
2516                                                    892, 169, 227, 20, 
2517                                                    "Display game framing settings"); */
2518
2519         uiBlockBeginAlign(block);
2520         uiDefButS(block, NUM,REDRAWVIEWCAM,"SizeX:",    892 ,136,112,27, &G.scene->r.xsch, 4.0, 10000.0, 0, 0, "The image width in pixels");
2521         uiDefButS(block, NUM,REDRAWVIEWCAM,"SizeY:",    1007,136,112,27, &G.scene->r.ysch, 4.0,10000.0, 0, 0, "The image height in scanlines");
2522         
2523         uiDefButF(block, NUM, REDRAWVIEWCAM, "AspX:",
2524                                 892 ,114,112,20,
2525                                 &G.scene->r.xasp,
2526                                 1, 200, 100, 2,
2527                                 "Horizontal Aspect Ratio");
2528         uiDefButF(block, NUM, REDRAWVIEWCAM, "AspY:",
2529                                 1007,114,112,20,
2530                                 &G.scene->r.yasp,
2531                                 1, 200, 100, 2,
2532                                 "Vertical Aspect Ratio");
2533         
2534         uiBlockEndAlign(block);
2535
2536         yofs = 54;
2537
2538 #ifdef __sgi
2539         yofs = 76;
2540         uiDefButS(block, NUM,B_DIFF,"MaxSize:",                 892,32,165,20, &G.scene->r.maximsize, 0.0, 500.0, 0, 0, "Maximum size per frame to save in an SGI movie");
2541         uiDefButBitI(block, TOG, R_COSMO, 0,"Cosmo",    1059,32,60,20, &G.scene->r.mode, 0, 0, 0, 0, "Attempt to save SGI movies using Cosmo hardware");
2542 #endif
2543
2544         uiDefButS(block, MENU,B_FILETYPEMENU,imagetype_pup(),   892,yofs,174,20, &G.scene->r.imtype, 0, 0, 0, 0, "Images are saved in this file format");
2545         uiDefButBitI(block, TOG, R_CROP, B_DIFF, "Crop",        1068,yofs,51,20, &G.scene->r.mode, 0, 0, 0, 0, "When Border render, the resulting image gets cropped");
2546
2547         yofs -= 22;
2548
2549         if(G.scene->r.quality==0) G.scene->r.quality= 90;
2550
2551         if (G.scene->r.imtype == R_AVICODEC || G.scene->r.imtype == R_QUICKTIME) {
2552                 if(G.scene->r.imtype == R_QUICKTIME) {
2553 #ifdef WITH_QUICKTIME
2554 #if defined (_WIN32) || defined (__APPLE__)
2555                         //glColor3f(0.65, 0.65, 0.7);
2556                         //glRecti(892,yofs+46,892+225,yofs+45+20);
2557                         if(G.scene->r.qtcodecdata == NULL)
2558                                 uiDefBut(block, LABEL, 0, "Codec: not set",  892,yofs+44,225,20, 0, 0, 0, 0, 0, "");
2559                         else
2560                                 uiDefBut(block, LABEL, 0, G.scene->r.qtcodecdata->qtcodecname,  892,yofs+44,225,20, 0, 0, 0, 0, 0, "");
2561                         uiDefBut(block, BUT,B_SELECTCODEC, "Set codec",  892,yofs,74,20, 0, 0, 0, 0, 0, "Set codec settings for Quicktime");
2562 #endif
2563 #endif /* WITH_QUICKTIME */
2564                 } else {
2565 #ifdef _WIN32
2566                         //glColor3f(0.65, 0.65, 0.7);
2567                         //glRecti(892,yofs+46,892+225,yofs+45+20);
2568                         if(G.scene->r.avicodecdata == NULL)
2569                                 uiDefBut(block, LABEL, 0, "Codec: not set.",  892,yofs+43,225,20, 0, 0, 0, 0, 0, "");
2570                         else
2571                                 uiDefBut(block, LABEL, 0, avicodec_str(),  892,yofs+43,225,20, 0, 0, 0, 0, 0, "");
2572 #endif
2573                         uiDefBut(block, BUT,B_SELECTCODEC, "Set codec",  892,yofs,74,20, 0, 0, 0, 0, 0, "Set codec settings for AVI");
2574                 }
2575 #ifdef WITH_OPENEXR
2576         } 
2577         else if (ELEM(G.scene->r.imtype, R_OPENEXR, R_MULTILAYER)) {
2578                 if (G.scene->r.quality > 5) G.scene->r.quality = 2;
2579                 
2580                 if(G.scene->r.imtype==R_OPENEXR) {
2581                         uiBlockBeginAlign(block);
2582                         uiDefButBitS(block, TOG, R_OPENEXR_HALF, B_NOP,"Half",  892,yofs+44,60,20, &G.scene->r.subimtype, 0, 0, 0, 0, "Use 16 bit floats instead of 32 bit floats per channel");
2583                         uiDefButBitS(block, TOG, R_OPENEXR_ZBUF, B_NOP,"Zbuf",  952,yofs+44,60,20, &G.scene->r.subimtype, 0, 0, 0, 0, "Save the z-depth per pixel (32 bit unsigned int zbuffer)");
2584                         uiBlockEndAlign(block);
2585                         uiDefButBitS(block, TOG, R_PREVIEW_JPG, B_NOP,"Preview",1027,yofs+44,90,20, &G.scene->r.subimtype, 0, 0, 0, 0, "When animation render, save JPG preview images in same directory");
2586                 }               
2587                 uiDefButS(block, MENU,B_NOP, "Codec %t|None %x0|Pxr24 (lossy) %x1|ZIP (lossless) %x2|PIZ (lossless) %x3|RLE (lossless) %x4",  
2588                                                                                                                         892,yofs,74,20, &G.scene->r.quality, 0, 0, 0, 0, "Set codec settings for OpenEXR");
2589                 
2590 #endif
2591         } else if (G.scene->r.imtype == R_DPX || G.scene->r.imtype == R_CINEON) {
2592                 uiDefButBitS(block, TOG, R_CINEON_LOG, B_REDR, "Log",           892,yofs,74,20, &G.scene->r.subimtype, 0, 0, 0, 0, "Convert to log color space");
2593
2594                 if(G.scene->r.subimtype & R_CINEON_LOG) {
2595                         uiBlockBeginAlign(block);
2596                         uiDefButS(block, NUM, B_NOP, "B",       892,yofs+44,80,20, &G.scene->r.cineonblack, 0, 1024, 0, 0, "Log conversion reference black");
2597                         uiDefButS(block, NUM, B_NOP, "W",       972,yofs+44,80,20, &G.scene->r.cineonwhite, 0, 1024, 0, 0, "Log conversion reference white");
2598                         uiDefButF(block, NUM, B_NOP, "G",       1052,yofs+44,70,20, &G.scene->r.cineongamma, 0.0f, 10.0f, 1, 2, "Log conversion gamma");
2599                         uiBlockEndAlign(block);
2600                 }
2601         } else if (G.scene->r.imtype == R_TIFF) {
2602                 uiDefButBitS(block, TOG, R_TIFF_16BIT, B_REDR, "16 Bit",           892,yofs,74,20, &G.scene->r.subimtype, 0, 0, 0, 0, "Save 16 bit per channel TIFF");
2603         } else {
2604                 if(G.scene->r.quality < 5) G.scene->r.quality = 90;     /* restore from openexr */
2605                 
2606                 uiDefButS(block, NUM,B_DIFF, "Q:",           892,yofs,74,20, &G.scene->r.quality, 10.0, 100.0, 0, 0, "Quality setting for JPEG images, AVI Jpeg and SGI movies");
2607         }
2608         uiDefButS(block, NUM,B_FRAMEMAP,"FPS:",   968,yofs,75,20, &G.scene->r.frs_sec, 1.0, 120.0, 100.0, 0, "Frames per second");
2609         uiDefButF(block, NUM,B_FRAMEMAP,"/",  1043,yofs,75,20, &G.scene->r.frs_sec_base, 1.0, 120.0, 0.1, 3, "Frames per second base");
2610
2611
2612         uiBlockBeginAlign(block);
2613         uiDefButS(block, ROW,B_DIFF,"BW",                       892, 10,74,19, &G.scene->r.planes, 5.0,(float)R_PLANESBW, 0, 0, "Images are saved with BW (grayscale) data");
2614         uiDefButS(block, ROW,B_DIFF,"RGB",                  968, 10,74,19, &G.scene->r.planes, 5.0,(float)R_PLANES24, 0, 0, "Images are saved with RGB (color) data");
2615         uiDefButS(block, ROW,B_DIFF,"RGBA",                1044, 10,75,19, &G.scene->r.planes, 5.0,(float)R_PLANES32, 0, 0, "Images are saved with RGB and Alpha data (if supported)");
2616
2617         uiBlockBeginAlign(block);
2618         uiDefBut(block, BUT,B_PR_PAL, "PAL",            1146,170,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 720x576, Aspect ratio - 54x51, 25 fps");
2619         uiDefBut(block, BUT,B_PR_NTSC, "NTSC",          1146,150,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 720x480, Aspect ratio - 10x11, 30 fps");
2620         uiDefBut(block, BUT,B_PR_PRESET, "Default",     1146,130,100,18, 0, 0, 0, 0, 0, "Same as PAL, with render settings (OSA, Shadows, Fields)");
2621         uiDefBut(block, BUT,B_PR_PRV, "Preview",        1146,110,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 640x512, Render size 50%");
2622         uiDefBut(block, BUT,B_PR_PC, "PC",                      1146,90,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 640x480, Aspect ratio - 100x100");
2623         uiDefBut(block, BUT,B_PR_PAL169, "PAL 16:9",1146,70,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 720x576, Aspect ratio - 64x45");
2624         uiDefBut(block, BUT,B_PR_PANO, "PANO",          1146,50,100,18, 0, 0, 0, 0, 0, "Standard panorama settings");
2625         uiDefBut(block, BUT,B_PR_FULL, "FULL",          1146,30,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 1280x1024, Aspect ratio - 1x1");
2626         uiDefBut(block, BUT,B_PR_HD, "HD",              1146,10,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 1920x1080, Aspect ratio - 1x1");
2627         uiBlockEndAlign(block);
2628 }
2629
2630 #ifndef DISABLE_YAFRAY /* disable yafray stuff */
2631 /* yafray: global illumination options panel */
2632 static void render_panel_yafrayGI()
2633 {
2634         uiBlock *block;
2635
2636         block= uiNewBlock(&curarea->uiblocks, "render_panel_yafrayGI", UI_EMBOSS, UI_HELV, curarea->win);
2637         uiNewPanelTabbed("Render", "Render");
2638         if(uiNewPanel(curarea, block, "YafRay GI", "Render", 320, 0, 318, 204)==0) return;
2639
2640         // label to force a boundbox for buttons not to be centered
2641         uiDefBut(block, LABEL, 0, " ", 305,180,10,10, 0, 0, 0, 0, 0, "");
2642
2643         uiDefBut(block, LABEL, 0, "Method", 5,175,70,20, 0, 1.0, 0, 0, 0, "");
2644         uiDefButS(block, MENU, B_REDR, "GiMethod %t|None %x0|SkyDome %x1|Full %x2", 70,175,89,20, &G.scene->r.GImethod, 0, 0, 0, 0, "Global Illumination Method");
2645
2646         uiDefBut(block, LABEL, 0, "Quality", 5,150,70,20, 0, 1.0, 0, 0, 0, "");
2647         uiDefButS(block, MENU, B_REDR, "GiQuality %t|None %x0|Low %x1|Medium %x2 |High %x3|Higher %x4|Best %x5|Use Blender AO settings %x6", 70,150,89,20, &G.scene->r.GIquality, 0, 0, 0, 0, "Global Illumination Quality");
2648
2649         if (G.scene->r.GImethod>0) {
2650                 uiDefButF(block, NUM, B_DIFF, "EmitPwr:", 5,35,154,20, &G.scene->r.GIpower, 0.01, 100.0, 10, 0, "arealight, material emit and background intensity scaling, 1 is normal");
2651                 if (G.scene->r.GImethod==2) uiDefButF(block, NUM, B_DIFF, "GI Pwr:", 5,10,154,20, &G.scene->r.GIindirpower, 0.01, 100.0, 10, 0, "GI indirect lighting intensity scaling, 1 is normal");
2652         }
2653
2654         if (G.scene->r.GImethod>0)
2655         {
2656                 if (G.scene->r.GIdepth==0) G.scene->r.GIdepth=2;
2657
2658                 if (G.scene->r.GImethod==2) {
2659                         uiDefButI(block, NUM, B_DIFF, "Depth:", 180,175,110,20, &G.scene->r.GIdepth, 1.0, 100.0, 10, 10, "Number of bounces of the indirect light");
2660                         uiDefButI(block, NUM, B_DIFF, "CDepth:", 180,150,110,20, &G.scene->r.GIcausdepth, 1.0, 100.0, 10, 10, "Number of bounces inside objects (for caustics)");
2661                         uiDefButBitS(block, TOG, 1,  B_REDR, "Photons",210,125,100,20, &G.scene->r.GIphotons, 0, 0, 0, 0, "Use global photons to help in GI");
2662                 }
2663
2664                 uiDefButBitS(block, TOG, 1, B_REDR, "Cache",6,125,95,20, &G.scene->r.GIcache, 0, 0, 0, 0, "Cache occlusion/irradiance samples (faster)");
2665                 if (G.scene->r.GIcache) 
2666                 {
2667                         uiDefButBitS(block,TOG, 1, B_REDR, "NoBump",108,125,95,20, &G.scene->r.YF_nobump, 0, 0, 0, 0, "Don't use bumpnormals for cache (faster, but no bumpmapping in total indirectly lit areas)");
2668                         uiDefBut(block, LABEL, 0, "Cache parameters:", 5,105,130,20, 0, 1.0, 0, 0, 0, "");
2669                         if (G.scene->r.GIshadowquality==0.0) G.scene->r.GIshadowquality=0.9;
2670                         uiDefButF(block, NUM, B_DIFF,"ShadQu:", 5,85,154,20,    &(G.scene->r.GIshadowquality), 0.01, 1.0 ,1,0, "Sets the shadow quality, keep it under 0.95 :-) ");
2671                         if (G.scene->r.GIpixelspersample==0) G.scene->r.GIpixelspersample=10;
2672                         uiDefButI(block, NUM, B_DIFF, "Prec:",  5,60,75,20, &G.scene->r.GIpixelspersample, 1, 50, 10, 10, "Maximum number of pixels without samples, the lower the better and slower");
2673                         if (G.scene->r.GIrefinement==0) G.scene->r.GIrefinement=1.0;
2674                         uiDefButF(block, NUM, B_DIFF, "Ref:", 84,60,75,20, &G.scene->r.GIrefinement, 0.001, 1.0, 1, 0, "Threshold to refine shadows EXPERIMENTAL. 1 = no refinement");
2675                 }
2676
2677                 if (G.scene->r.GImethod==2) {
2678                         if (G.scene->r.GIphotons)
2679                         {
2680                                 uiDefBut(block, LABEL, 0, "Photon parameters:", 170,105,130,20, 0, 1.0, 0, 0, 0, "");
2681                                 if(G.scene->r.GIphotoncount==0) G.scene->r.GIphotoncount=100000;
2682                                 uiDefButI(block, NUM, B_DIFF, "Count:", 170,85,140,20, &G.scene->r.GIphotoncount, 
2683                                                 0, 10000000, 10, 10, "Number of photons to shoot");
2684                                 if(G.scene->r.GIphotonradius==0.0) G.scene->r.GIphotonradius=1.0;
2685                                 uiDefButF(block, NUMSLI, B_DIFF,"Radius:", 170,60,140,20,       &(G.scene->r.GIphotonradius), 
2686                                                 0.00001, 100.0 ,0,0, "Radius to search for photons to mix (blur)");
2687                                 if(G.scene->r.GImixphotons==0) G.scene->r.GImixphotons=100;
2688                                 uiDefButI(block, NUM, B_DIFF, "MixCount:", 170,35,140,20, &G.scene->r.GImixphotons, 
2689                                                 0, 1000, 10, 10, "Number of photons to mix");
2690                                 uiDefButBitS(block, TOG, 1, B_REDR, "Tune Photons",170,10,140,20, &G.scene->r.GIdirect, 
2691                                                 0, 0, 0, 0, "Show the photonmap directly in the render for tuning");
2692                         }
2693                 }
2694
2695         }
2696 }
2697
2698 /* yafray: global  options panel */
2699 static void render_panel_yafrayGlobal()
2700 {
2701         uiBlock *block;
2702
2703         block= uiNewBlock(&curarea->uiblocks, "render_panel_yafrayGlobal", UI_EMBOSS, UI_HELV, curarea->win);
2704         uiNewPanelTabbed("Render", "Render");
2705         if(uiNewPanel(curarea, block, "YafRay", "Render", 320, 0, 318, 204)==0) return;
2706
2707         // label to force a boundbox for buttons not to be centered
2708         uiDefBut(block, LABEL, 0, " ", 305,180,10,10, 0, 0, 0, 0, 0, "");
2709
2710         uiDefButBitS(block, TOGN, 1, B_REDR, "xml", 5,180,75,20, &G.scene->r.YFexportxml,
2711                                         0, 0, 0, 0, "Export to an xml file and call yafray instead of plugin");
2712
2713         uiDefButF(block, NUMSLI, B_DIFF,"Bi ", 5,35,150,20,     &(G.scene->r.YF_raybias), 
2714                                 0.0, 10.0 ,0,0, "Shadow ray bias to avoid self shadowing");
2715         uiDefButI(block, NUM, B_DIFF, "Raydepth ", 5,60,150,20,
2716                                 &G.scene->r.YF_raydepth, 1.0, 80.0, 10, 10, "Maximum render ray depth from the camera");
2717         uiDefButF(block, NUMSLI, B_DIFF, "Gam ", 5,10,150,20, &G.scene->r.YF_gamma, 0.001, 5.0, 0, 0, "Gamma correction, 1 is off");
2718         uiDefButF(block, NUMSLI, B_DIFF, "Exp ", 160,10,150,20,&G.scene->r.YF_exposure, 0.0, 10.0, 0, 0, "Exposure adjustment, 0 is off");
2719         
2720         /*AA Settings*/
2721         uiDefButBitS(block, TOGN, 1, B_REDR, "Auto AA", 5,140,150,20, &G.scene->r.YF_AA, 
2722                                         0, 0, 0, 0, "Set AA using OSA and GI quality, disable for manual control");
2723         uiDefButBitS(block, TOGN, 1, B_DIFF, "Clamp RGB", 160,140,150,20, &G.scene->r.YF_clamprgb, 1.0, 8.0, 10, 10, "For AA on fast high contrast changes. Not advisable for Bokeh! Dulls lens shape detail.");
2724         if(G.scene->r.YF_AA){
2725                 uiDefButI(block, NUM, B_DIFF, "AA Passes ", 5,115,150,20, &G.scene->r.YF_AApasses, 0, 64, 10, 10, "Number of AA passes (0 is no AA)");
2726                 uiDefButI(block, NUM, B_DIFF, "AA Samples ", 160,115,150,20, &G.scene->r.YF_AAsamples, 0, 2048, 10, 10, "Number of samples per pass");
2727                 uiDefButF(block, NUMSLI, B_DIFF, "Psz ", 5,90,150,20, &G.scene->r.YF_AApixelsize, 1.0, 2.0, 0, 0, "AA pixel filter size");
2728                 uiDefButF(block, NUMSLI, B_DIFF, "Thr ", 160,90,150,20, &G.scene->r.YF_AAthreshold, 0.000001, 1.0, 0, 0, "AA threshold");
2729         }
2730 }
2731 #endif /* disable yafray stuff */
2732
2733 static void layer_copy_func(void *lay_v, void *lay_p)
2734 {
2735         unsigned int *lay= lay_p;
2736         int laybit= GET_INT_FROM_POINTER(lay_v);
2737
2738         if(G.qual & (LR_SHIFTKEY|LR_CTRLKEY)) {
2739                 if(*lay==0) *lay= 1<<laybit;
2740         }
2741         else
2742                 *lay= 1<<laybit;
2743         
2744         copy_view3d_lock(REDRAW);
2745         allqueue(REDRAWBUTSSCENE, 0);
2746 }
2747
2748 static void delete_scene_layer_func(void *srl_v, void *act_i)
2749 {
2750         if(BLI_countlist(&G.scene->r.layers)>1) {
2751                 long act= (long)act_i;
2752                 
2753                 BLI_remlink(&G.scene->r.layers, srl_v);
2754                 MEM_freeN(srl_v);
2755                 G.scene->r.actlay= 0;
2756                 
2757                 if(G.scene->nodetree) {
2758                         bNode *node;
2759                         for(node= G.scene->nodetree->nodes.first; node; node= node->next) {
2760                                 if(node->type==CMP_NODE_R_LAYERS && node->id==NULL) {
2761                                         if(node->custom1==act)
2762                                                 node->custom1= 0;
2763                                         else if(node->custom1>act)
2764                                                 node->custom1--;
2765                                 }
2766                         }
2767                 }
2768                 allqueue(REDRAWBUTSSCENE, 0);
2769                 allqueue(REDRAWNODE, 0);
2770         }
2771 }
2772
2773 static void rename_scene_layer_func(void *srl_v, void *unused_v)
2774 {
2775         if(G.scene->nodetree) {
2776                 SceneRenderLayer *srl= srl_v;
2777                 bNode *node;
2778                 for(node= G.scene->nodetree->nodes.first; node; node= node->next) {
2779                         if(node->type==CMP_NODE_R_LAYERS && node->id==NULL) {
2780                                 if(node->custom1==G.scene->r.actlay)
2781                                         BLI_strncpy(node->name, srl->name, NODE_MAXSTR);
2782                         }
2783                 }
2784         }
2785         allqueue(REDRAWBUTSSCENE, 0);
2786         allqueue(REDRAWOOPS, 0);
2787         allqueue(REDRAWNODE, 0);
2788 }
2789
2790 static char *scene_layer_menu(void)
2791 {
2792         SceneRenderLayer *srl;
2793         int len= 32 + 32*BLI_countlist(&G.scene->r.layers);
2794         short a, nr;
2795         char *str= MEM_callocN(len, "menu layers");
2796         
2797         strcpy(str, "ADD NEW %x32767");
2798         a= strlen(str);
2799         for(nr=0, srl= G.scene->r.layers.first; srl; srl= srl->next, nr++) {
2800                 if(srl->layflag & SCE_LAY_DISABLE)
2801                         a+= sprintf(str+a, "|%s %%i%d %%x%d", srl->name, ICON_BLANK1, nr);
2802                 else 
2803                         a+= sprintf(str+a, "|%s %%i%d %%x%d", srl->name, ICON_CHECKBOX_HLT, nr);
2804         }
2805         
2806         return str;
2807 }
2808
2809 static void draw_3d_layer_buttons(uiBlock *block, int type, unsigned int *poin, short xco, short yco, short dx, short dy, char *tip)
2810 {
2811         uiBut *bt;
2812         long a;
2813         
2814         uiBlockBeginAlign(block);
2815         for(a=0; a<5; a++) {
2816                 bt= uiDefButBitI(block, type, 1<<a, B_NOP, "",  (short)(xco+a*(dx/2)), yco+dy/2, (short)(dx/2), (short)(dy/2), (int *)poin, 0, 0, 0, 0, tip);
2817                 uiButSetFunc(bt, layer_copy_func, (void *)a, poin);
2818         }
2819         for(a=0; a<5; a++) {
2820                 bt=uiDefButBitI(block, type, 1<<(a+10), B_NOP, "",      (short)(xco+a*(dx/2)), yco, (short)(dx/2), (short)(dy/2), (int *)poin, 0, 0, 0, 0, tip);
2821                 uiButSetFunc(bt, layer_copy_func, (void *)(a+10), poin);
2822         }
2823         
2824         xco+= 7;
2825         uiBlockBeginAlign(block);
2826         for(a=5; a<10; a++) {
2827                 bt=uiDefButBitI(block, type, 1<<a, B_NOP, "",   (short)(xco+a*(dx/2)), yco+dy/2, (short)(dx/2), (short)(dy/2), (int *)poin, 0, 0, 0, 0, tip);
2828                 uiButSetFunc(bt, layer_copy_func, (void *)a, poin);
2829         }
2830         for(a=5; a<10; a++) {
2831                 bt=uiDefButBitI(block, type, 1<<(a+10), B_NOP, "",      (short)(xco+a*(dx/2)), yco, (short)(dx/2), (short)(dy/2), (int *)poin, 0, 0, 0, 0, tip);
2832                 uiButSetFunc(bt, layer_copy_func, (void *)(a+10), poin);
2833         }
2834         
2835         uiBlockEndAlign(block);
2836 }
2837
2838 static void render_panel_layers(void)
2839 {
2840         uiBlock *block;
2841         uiBut *bt;
2842         SceneRenderLayer *srl= BLI_findlink(&G.scene->r.layers, G.scene->r.actlay);
2843         char *strp;
2844         
2845         if(srl==NULL) {
2846                 G.scene->r.actlay= 0;
2847                 srl= G.scene->r.layers.first;
2848         }
2849         
2850         block= uiNewBlock(&curarea->uiblocks, "render_panel_layers", UI_EMBOSS, UI_HELV, curarea->win);
2851         uiNewPanelTabbed("Output", "Render");
2852         if(uiNewPanel(curarea, block, "Render Layers", "Render", 320, 0, 318, 204)==0) return;
2853         
2854         /* first, as reminder, the scene layers */
2855         uiDefBut(block, LABEL, 0, "Scene:",                             10,170,100,20, NULL, 0, 0, 0, 0, "");
2856         draw_3d_layer_buttons(block, TOG, &G.scene->lay,                130, 170, 35, 30, "Scene layers to render");
2857         
2858         /* layer disable, menu, name, delete button */
2859         uiBlockBeginAlign(block);
2860         uiDefIconButBitI(block, ICONTOGN, SCE_LAY_DISABLE, B_REDR, ICON_CHECKBOX_HLT-1, 10, 145, 20, 20, &srl->layflag, 0.0, 0.0, 0, 0, "Disable or enable this RenderLayer");
2861         strp= scene_layer_menu();
2862         uiDefButS(block, MENU, B_ADD_RENDERLAYER, strp, 30,145,23,20, &(G.scene->r.actlay), 0, 0, 0, 0, "Choose Active Render Layer");
2863         MEM_freeN(strp);
2864         
2865         /* name max 20, exr format limit... */
2866         bt= uiDefBut(block, TEX, REDRAWNODE, "",  53,145,172,20, srl->name, 0.0, 20.0, 0, 0, "");
2867         uiButSetFunc(bt, rename_scene_layer_func, srl, NULL);
2868         
2869         uiDefButBitI(block, TOG, R_SINGLE_LAYER, B_NOP, "Single",       230,145,60,20, &G.scene->r.scemode, 0, 0, 0, 0, "Only render this layer");      
2870         bt=uiDefIconBut(block, BUT, B_NOP, ICON_X,      285, 145, 25, 20, 0, 0, 0, 0, 0, "Deletes current Render Layer");
2871         uiButSetFunc(bt, delete_scene_layer_func, srl, (void *)(long)G.scene->r.actlay);
2872         uiBlockEndAlign(block);
2873
2874         /* RenderLayer visible-layers */
2875         uiDefBut(block, LABEL, 0, "Layer:",                     10,110,100,20, NULL, 0, 0, 0, 0, "");
2876         draw_3d_layer_buttons(block, BUT_TOGDUAL, &srl->lay,            130,110, 35, 30, "Scene-layers included in this render-layer (Hold CTRL for Z-mask)");
2877         
2878         uiBlockBeginAlign(block);
2879         uiDefButBitI(block, TOG, SCE_LAY_ZMASK, B_REDR,"Zmask", 10, 85, 40, 20, &srl->layflag, 0, 0, 0, 0, "Only render what's in front of the solid z values");        
2880         if(srl->layflag & SCE_LAY_ZMASK)
2881                 uiDefButBitI(block, TOG, SCE_LAY_NEG_ZMASK, B_NOP,"Neg",        10, 65, 40, 20, &srl->layflag, 0, 0, 0, 0, "For Zmask, only render what is behind solid z values instead of in front");
2882         else
2883                 uiDefButBitI(block, TOG, SCE_LAY_ALL_Z, B_NOP,"AllZ",   10, 65, 40, 20, &srl->layflag, 0, 0, 0, 0, "Fill in Z values for solid faces in invisible layers, for masking");        
2884         uiBlockBeginAlign(block);
2885         uiDefButBitI(block, TOG, SCE_LAY_SOLID, B_NOP,"Solid",  50,  85, 45, 20, &srl->layflag, 0, 0, 0, 0, "Render Solid faces in this Layer");        
2886         uiDefButBitI(block, TOG, SCE_LAY_HALO, B_NOP,"Halo",    95,  85, 40, 20, &srl->layflag, 0, 0, 0, 0, "Render Halos in this Layer (on top of Solid)");    
2887         uiDefButBitI(block, TOG, SCE_LAY_ZTRA, B_NOP,"Ztra",    135, 85, 40, 20, &srl->layflag, 0, 0, 0, 0, "Render Z-Transparent faces in this Layer (On top of Solid and Halos)");    
2888         uiDefButBitI(block, TOG, SCE_LAY_SKY, B_NOP,"Sky",              175, 85, 40, 20, &srl->layflag, 0, 0, 0, 0, "Render Sky or backbuffer in this Layer");  
2889         uiDefButBitI(block, TOG, SCE_LAY_EDGE, B_NOP,"Edge",    215, 85, 45, 20, &srl->layflag, 0, 0, 0, 0, "Render Edge-enhance in this Layer (only works for Solid faces)");  
2890         uiDefButBitI(block, TOG, SCE_LAY_STRAND, B_NOP,"Strand",260, 85, 50, 20, &srl->layflag, 0, 0, 0, 0, "Render Strands in this Layer");    
2891         
2892         uiDefIDPoinBut(block, test_grouppoin_but, ID_GR, B_SET_PASS, "Light:",  50, 65, 130, 20, &(srl->light_override), "Name of Group to use as Lamps instead");
2893         uiDefIDPoinBut(block, test_matpoin_but, ID_MA, B_SET_PASS, "Mat:",      180, 65, 130, 20, &(srl->mat_override), "Name of Material to use as Materials instead");
2894         uiBlockEndAlign(block);
2895
2896         uiBlockBeginAlign(block);
2897         uiDefButBitI(block, TOG, SCE_PASS_COMBINED, B_SET_PASS,"Combined",      10, 30, 80, 20, &srl->passflag, 0, 0, 0, 0, "Deliver full combined RGBA buffer");       
2898         uiDefButBitI(block, TOG, SCE_PASS_Z, B_SET_PASS,"Z",                    90, 30, 30, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Z values pass");   
2899         uiDefButBitI(block, TOG, SCE_PASS_VECTOR, B_SET_PASS,"Vec",             120, 30, 40, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Speed Vector pass");      
2900         uiDefButBitI(block, TOG, SCE_PASS_NORMAL, B_SET_PASS,"Nor",             160, 30, 40, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Normal pass");    
2901         uiDefButBitI(block, TOG, SCE_PASS_UV, B_SET_PASS,"UV",                  200, 30, 40, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Texture UV pass");        
2902         uiDefButBitI(block, TOG, SCE_PASS_MIST, B_SET_PASS,"Mist",              240, 30, 35, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Mist factor pass (0-1)"); 
2903         uiDefButBitI(block, TOG, SCE_PASS_INDEXOB, B_SET_PASS,"Index",  275, 30, 35, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Object Index pass");      
2904         
2905         uiDefButBitI(block, TOG, SCE_PASS_RGBA, B_SET_PASS,"Col",                               10, 10, 35, 20, &srl->passflag, 0, 0, 0, 0, "Deliver shade-less Color pass");   
2906         uiDefButBitI(block, TOG, SCE_PASS_DIFFUSE, B_SET_PASS,"Diff",                   45, 10, 35, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Diffuse pass");    
2907         uiDefButBitI(block, BUT_TOGDUAL, SCE_PASS_SPEC, B_SET_PASS,"Spec",              80, 10, 40, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Specular pass (Hold Ctrl to exclude from combined)");      
2908         uiDefButBitI(block, BUT_TOGDUAL, SCE_PASS_SHADOW, B_SET_PASS,"Shad",    120, 10, 40, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Shadow pass (Hold Ctrl to exclude from combined)");       
2909         uiDefButBitI(block, BUT_TOGDUAL, SCE_PASS_AO, B_SET_PASS,"AO",                  160, 10, 30, 20, &srl->passflag, 0, 0, 0, 0, "Deliver AO pass (Hold Ctrl to exclude from combined)");
2910         uiDefButBitI(block, BUT_TOGDUAL, SCE_PASS_REFLECT, B_SET_PASS,"Refl",   190, 10, 40, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Raytraced Reflection pass (Hold Ctrl to exclude from combined)"); 
2911         uiDefButBitI(block, BUT_TOGDUAL, SCE_PASS_REFRACT, B_SET_PASS,"Refr",   230, 10, 40, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Raytraced Refraction pass (Hold Ctrl to exclude from combined)"); 
2912         uiDefButBitI(block, BUT_TOGDUAL, SCE_PASS_RADIO, B_SET_PASS,"Rad",              270, 10, 40, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Radiosity pass (Hold Ctrl to exclude from combined)");    
2913 }       
2914
2915 void render_panels()
2916 {
2917
2918         render_panel_output();
2919         render_panel_layers();
2920         render_panel_render();
2921         if(G.rt == 1) render_panel_simplify();
2922         render_panel_anim();
2923         render_panel_bake();
2924
2925         render_panel_format();
2926         render_panel_stamp();
2927 #ifdef WITH_FFMPEG
2928        if (G.scene->r.imtype == R_FFMPEG) {
2929                    render_panel_ffmpeg_video();
2930                render_panel_ffmpeg_audio();
2931        }
2932 #endif
2933
2934 #ifndef DISABLE_YAFRAY
2935         /* yafray: GI & Global panel, only available when yafray enabled for rendering */
2936         if (G.scene->r.renderer==R_YAFRAY) {
2937                 if (G.scene->r.YF_gamma==0.0) G.scene->r.YF_gamma=1.0;
2938                 if (G.scene->r.YF_raybias==0.0) G.scene->r.YF_raybias=0.001;
2939                 if (G.scene->r.YF_raydepth==0) G.scene->r.YF_raydepth=5;
2940                 if (G.scene->r.YF_AApixelsize==0.0) G.scene->r.YF_AApixelsize=1.5;
2941                 if (G.scene->r.YF_AAthreshold==0.0) G.scene->r.YF_AAthreshold=0.05;
2942                 if (G.scene->r.GIpower==0.0) G.scene->r.GIpower=1.0;
2943                 if (G.scene->r.GIindirpower==0.0) G.scene->r.GIindirpower=1.0;
2944                 render_panel_yafrayGlobal();
2945                 render_panel_yafrayGI();
2946         }
2947 #endif
2948
2949 }
2950
2951 /* --------------------------------------------- */
2952
2953 void anim_panels()
2954 {
2955         uiBlock *block;
2956
2957         block= uiNewBlock(&curarea->uiblocks, "anim_panel", UI_EMBOSS, UI_HELV, curarea->win);
2958         if(uiNewPanel(curarea, block, "Anim", "Anim", 0, 0, 318, 204)==0) return;
2959
2960         uiBlockBeginAlign(block);
2961         uiDefButI(block, NUM,B_FRAMEMAP,"Map Old:",     10,160,150,20,&G.scene->r.framapto,1.0,900.0, 0, 0, "Specify old mapping value in frames");
2962         uiDefButI(block, NUM,B_FRAMEMAP,"Map New:",     160,160,150,20,&G.scene->r.images,1.0,900.0, 0, 0, "Specify how many frames the Map Old will last");
2963
2964         uiBlockBeginAlign(block);
2965         uiDefButS(block, NUM,B_FRAMEMAP,"FPS:",  10,130,75,20, &G.scene->r.frs_sec, 1.0, 120.0, 100.0, 0, "Frames per second");
2966         uiDefButF(block, NUM,B_FRAMEMAP,"/",  85,130,75,20, &G.scene->r.frs_sec_base, 1.0, 120.0, 0.1, 3, "Frames per second base");
2967
2968         uiDefButBitS(block, TOG, AUDIO_SYNC, B_SOUND_CHANGED, "Sync",160,130,150,20, &G.scene->audio.flag, 0, 0, 0, 0, "Use sample clock for syncing animation to audio");
2969         
2970         uiBlockBeginAlign(block);
2971         uiDefButI(block, NUM,REDRAWALL,"Sta:",  10,100,150,20,&G.scene->r.sfra,1.0,MAXFRAMEF, 0, 0, "Specify the start frame of the animation");
2972         uiDefButI(block, NUM,REDRAWALL,"End:",  160,100,150,20,&G.scene->r.efra,1.0,MAXFRAMEF, 0, 0, "Specify the end frame of the animation");
2973
2974         uiBlockBeginAlign(block);
2975         uiDefButS(block, NUM, REDRAWTIME, "Steps:",10, 70, 150, 20,&(G.scene->jumpframe), 1, 100, 1, 100, "Set spacing between frames changes with up and down arrow keys");
2976
2977
2978 }
2979
2980 /* --------------------------------------------- */
2981
2982 void sound_panels()
2983 {
2984         bSound *sound;
2985
2986         /* paranoia check */
2987         sound = G.buts->lockpoin;
2988         if(sound && GS(sound->id.name)!=ID_SO) {
2989                 sound= NULL;
2990                 G.buts->lockpoin= NULL;
2991         }
2992         
2993         sound_panel_sound(sound);
2994         sound_panel_listener();
2995         sound_panel_sequencer();
2996 }
2997
2998
2999