1 // resample.h
2 // LiVES
3 // (c) G. Finch 2004 - 2016 <salsaman@gmail.com>
4 // released under the GNU GPL 3 or later
5 // see file ../COPYING or www.gnu.org for licensing details
6 
7 
8 // functions/structs for reordering, resampling video and audio
9 
10 #ifndef HAS_LIVES_RESAMPLE_H
11 #define HAS_LIVES_RESAMPLE_H
12 
13 #define RESIZE_ALL_NEEDS_CONVERT 0
14 #define LETTERBOX_NEEDS_COMPOSITE 1
15 #define LETTERBOX_NEEDS_CONVERT 1
16 
17 /// resample audio window
18 typedef struct __resaudw {
19   LiVESWidget *dialog;
20   LiVESWidget *entry_arate;
21   LiVESWidget *entry_achans;
22   LiVESWidget *entry_asamps;
23   LiVESWidget *rb_signed;
24   LiVESWidget *rb_unsigned;
25   LiVESWidget *rb_bigend;
26   LiVESWidget *rb_littleend;
27   LiVESWidget *unlim_radiobutton;
28   LiVESWidget *hour_spinbutton;
29   LiVESWidget *minute_spinbutton;
30   LiVESWidget *second_spinbutton;
31   LiVESWidget *fps_spinbutton;
32   LiVESWidget *aud_checkbutton;
33   LiVESWidget *aud_hbox;
34   LiVESWidget *vbox;
35 } _resaudw;
36 
37 
38 _resaudw *resaudw;
39 
40 ticks_t q_gint64(ticks_t in, double fps);
41 ticks_t q_gint64_floor(ticks_t in, double fps);
42 ticks_t q_dbl(double in, double fps);
43 
44 void reorder_leave_back_set(boolean val);
45 
46 size_t quant_asamps(double seek, int arate);
47 double quant_aseek(double seek, int arate);
48 off_t quant_abytes(double seek, int arate, int achans, int asampsize);
49 
50 #define SKJUMP_THRESH_RATIO 1.025 /// if fabs(recorded_vel / predicted_vel) < 1.0 +- SKJUMP_THRESH_RATIO then smooth the velocity
51 #define SKJUMP_THRESH_SECS 0.25 /// if fabs(rec_seek - predicted_seek) < SKJUMP_THRESH_SECS then smooth the seek time
52 
53 weed_plant_t *quantise_events(weed_plant_t *in_list, double new_fps,
54                               boolean allow_gap) WARN_UNUSED;  ///< quantise frame events for a single clip
55 
56 ///////////////////////////////////////////////////////
57 int count_resampled_frames(int in_frames, double orig_fps, double resampled_fps);
58 
59 /////////////////////////////////////////
60 
61 // GUI functions
62 
63 /// resample audio window
64 ///
65 /// type 1 : show current and new,
66 /// type 2 : show new
67 _resaudw *create_resaudw(short type, render_details *, LiVESWidget *top_vbox);
68 
69 void on_change_speed_activate(LiVESMenuItem *, livespointer);
70 void on_change_speed_ok_clicked(LiVESButton *, livespointer);
71 
72 boolean auto_resample_resize(int width, int height, double fps, int fps_num,
73                              int fps_denom, int arate, int asigned, boolean swap_endian);
74 int reorder_frames(int rwidth, int rheight);
75 int deorder_frames(int old_framecount, boolean leave_bak); ///< leave_bak is a special mode for the clipboard
76 
77 boolean resample_clipboard(double new_fps); ///< call this to resample clipboard video
78 
79 #endif
80