LiVES
3.2.0
|
#include "main.h"
#include "resample.h"
#include "callbacks.h"
#include "effects.h"
#include "audio.h"
#include "events.h"
#include "cvirtual.h"
Go to the source code of this file.
Macros | |
#define | READJ_MAX 2. |
#define | READJ_MIN 0.1 |
#define | SMTH_FRAME_LIM 8 |
#define | SMTH_TC_LIM (0.5 * TICKS_PER_SECOND_DBL) |
Functions | |
void | reorder_leave_back_set (boolean val) |
LIVES_GLOBAL_INLINE ticks_t | q_gint64 (ticks_t in, double fps) |
LIVES_GLOBAL_INLINE ticks_t | q_gint64_floor (ticks_t in, double fps) |
LIVES_GLOBAL_INLINE ticks_t | q_dbl (double in, double fps) |
LIVES_GLOBAL_INLINE size_t | quant_asamps (double seek, int arate) |
convert seek time to an integer number of samples More... | |
LIVES_GLOBAL_INLINE double | quant_aseek (double seek, int arate) |
convert seek time (secs) to an (almost) integer number of samples More... | |
LIVES_GLOBAL_INLINE off_t | quant_abytes (double seek, int arate, int achans, int asampsize) |
LIVES_GLOBAL_INLINE int | count_resampled_frames (int in_frames, double orig_fps, double resampled_fps) |
boolean | auto_resample_resize (int width, int height, double fps, int fps_num, int fps_denom, int arate, int asigned, boolean swap_endian) |
void | pre_analyse (weed_plant_t *elist) |
weed_plant_t * | quantise_events (weed_plant_t *in_list, double qfps, boolean allow_gap) |
quantise from event_list_t *in_list to *out_list at the new rate of qfps More... | |
void | on_resample_audio_activate (LiVESMenuItem *menuitem, livespointer user_data) |
void | on_resaudio_ok_clicked (LiVESButton *button, LiVESEntry *entry) |
void | on_resaudw_asamps_changed (LiVESWidget *irrelevant, livespointer rubbish) |
void | on_resample_video_activate (LiVESMenuItem *menuitem, livespointer user_data) |
void | on_resample_vid_ok (LiVESButton *button, LiVESEntry *entry) |
_resaudw * | create_resaudw (short type, render_details *rdet, LiVESWidget *top_vbox) |
resample audio window More... | |
void | on_change_speed_activate (LiVESMenuItem *menuitem, livespointer user_data) |
void | on_change_speed_ok_clicked (LiVESButton *button, livespointer user_data) |
int | reorder_frames (int rwidth, int rheight) |
int | deorder_frames (int old_frames, boolean leave_bak) |
leave_bak is a special mode for the clipboard More... | |
boolean | resample_clipboard (double new_fps) |
call this to resample clipboard video More... | |
#define READJ_MAX 2. |
Definition at line 301 of file resample.c.
#define READJ_MIN 0.1 |
Definition at line 302 of file resample.c.
#define SMTH_FRAME_LIM 8 |
Definition at line 304 of file resample.c.
#define SMTH_TC_LIM (0.5 * TICKS_PER_SECOND_DBL) |
Definition at line 305 of file resample.c.
boolean auto_resample_resize | ( | int | width, |
int | height, | ||
double | fps, | ||
int | fps_num, | ||
int | fps_denom, | ||
int | arate, | ||
int | asigned, | ||
boolean | swap_endian | ||
) |
Definition at line 80 of file resample.c.
LIVES_GLOBAL_INLINE int count_resampled_frames | ( | int | in_frames, |
double | orig_fps, | ||
double | resampled_fps | ||
) |
Definition at line 72 of file resample.c.
Referenced by add_lmap_error(), resample_clipboard(), and setmergealign().
_resaudw* create_resaudw | ( | short | type, |
render_details * | , | ||
LiVESWidget * | top_vbox | ||
) |
resample audio window
type 1 : show current and new, type 2 : show new
Definition at line 1521 of file resample.c.
Referenced by on_capture_activate(), on_recaudclip_activate(), and on_resample_audio_activate().
int deorder_frames | ( | int | old_frames, |
boolean | leave_bak | ||
) |
leave_bak is a special mode for the clipboard
Definition at line 2208 of file resample.c.
void on_change_speed_activate | ( | LiVESMenuItem * | menuitem, |
livespointer | user_data | ||
) |
Definition at line 2017 of file resample.c.
void on_change_speed_ok_clicked | ( | LiVESButton * | button, |
livespointer | user_data | ||
) |
Definition at line 2025 of file resample.c.
Referenced by create_new_pb_speed(), and on_redo_activate().
void on_resample_audio_activate | ( | LiVESMenuItem * | menuitem, |
livespointer | user_data | ||
) |
Definition at line 1148 of file resample.c.
void on_resample_vid_ok | ( | LiVESButton * | button, |
LiVESEntry * | entry | ||
) |
Definition at line 1379 of file resample.c.
Referenced by create_new_pb_speed(), insert_frames(), on_redo_activate(), and resample_clipboard().
void on_resample_video_activate | ( | LiVESMenuItem * | menuitem, |
livespointer | user_data | ||
) |
Definition at line 1372 of file resample.c.
void on_resaudio_ok_clicked | ( | LiVESButton * | button, |
LiVESEntry * | entry | ||
) |
Definition at line 1159 of file resample.c.
Referenced by create_resaudw(), and on_redo_activate().
void on_resaudw_asamps_changed | ( | LiVESWidget * | irrelevant, |
livespointer | rubbish | ||
) |
Definition at line 1353 of file resample.c.
Referenced by create_resaudw().
void pre_analyse | ( | weed_plant_t * | elist | ) |
for older lists we didnt set the seek point at audio off, so ignore those
offs is what we will add to remianing events when we hit the end
Definition at line 307 of file resample.c.
LIVES_GLOBAL_INLINE ticks_t q_dbl | ( | double | in, |
double | fps | ||
) |
Definition at line 41 of file resample.c.
Referenced by add_blank_frames_up_to(), get_time_from_x(), mt_spin_end_value_changed(), and mt_spin_start_value_changed().
LIVES_GLOBAL_INLINE ticks_t q_gint64 | ( | ticks_t | in, |
double | fps | ||
) |
Definition at line 25 of file resample.c.
Referenced by add_blank_frames_up_to(), add_markers(), avel_spin_changed(), get_region_overlap(), insert_audio(), insert_frames(), mt_add_region_effect(), multitrack_audio_insert(), multitrack_insert(), multitrack_view_sel_events(), on_del_node_clicked(), on_effects_paused(), on_next_fm_clicked(), on_next_node_clicked(), on_node_spin_value_changed(), on_prev_fm_clicked(), on_prev_node_clicked(), on_set_pvals_clicked(), on_split_activate(), on_split_curr_activate(), render_events(), and virtual_to_images().
LIVES_GLOBAL_INLINE ticks_t q_gint64_floor | ( | ticks_t | in, |
double | fps | ||
) |
Definition at line 35 of file resample.c.
Referenced by calc_new_playback_position().
LIVES_GLOBAL_INLINE off_t quant_abytes | ( | double | seek, |
int | arate, | ||
int | achans, | ||
int | asampsize | ||
) |
Definition at line 66 of file resample.c.
LIVES_GLOBAL_INLINE size_t quant_asamps | ( | double | seek, |
int | arate | ||
) |
convert seek time to an integer number of samples
Definition at line 52 of file resample.c.
Referenced by quant_abytes(), and quant_aseek().
LIVES_GLOBAL_INLINE double quant_aseek | ( | double | seek, |
int | arate | ||
) |
convert seek time (secs) to an (almost) integer number of samples
Definition at line 58 of file resample.c.
weed_plant_t* quantise_events | ( | weed_plant_t * | in_list, |
double | qfps, | ||
boolean | allow_gap | ||
) |
quantise from event_list_t *in_list to *out_list at the new rate of qfps
quantise frame events for a single clip
This is called from 3 functions:
if old_list has no frames then we just return an empty list otherwise returned list will always have at least one event (a frame at timecode 0).
if there is a timecode gap at the start of the old_list (i.e frame 1 has a non-zero timecode) then this well be eliminated in the out iist; i.e. frame 1 in out_list always has a timecode of 0.
if the old event_list has a fixed fps, then we try to keep the duration as near as possible, so:
nframes_new = MAX(nframes_old / old_fps * new_fps , 1) the value is rounded DOWN in the case that qfps < old_fps and rounded to the nearest integer in the case that qfps > old_fps
e.g 210 frames @ 20.0 fps -> 157 frames @ 15.0 fps -> 410 frames @ 39.0 fps
i.e when the duration of the final frame is added, the total will always be >= duration of the old list
if old_list has no fixed fps, then new_frames = (timecode of last frame - timecode of first frame) * qfps rounded UP.
/ algorithm: / - get tc of 1st frame event in in_list / tc of out_list starts at zero. If allow_gap is FALSE we add an offset_tc / so out_list 0 coincides with tc of 1st frame in in_list. / loop: / - advance in_list until either we hit a frame event, or tc of NEXT event > out_tc / – if tc of next frame is <= out_tc, we continue / – update the state to current event / / - apply in_list state at out_tc, interpolating between last (current) in frame and next in frame / - advance out_tc by 1. / out_fps / - goto loop
/ inserting from scrap_file, we cannot interpolate frame numbers. So we just insert nearest frame
copy metadata; we will change PREV, NEXT and FPS
in pre-analysis, we will look at the audio frames, and instead of correcting the audio veloicity, we will attempt to slightly modify (scale) the frame timings such that the audio hits the precise seek point
in this mode we walk the event_list until we pass the output time, keeping track of state - frame and clip numbers, audio positions, param values, then insert everything at the output slot
values which we maintain: current init_events (cancelled by a deinit) current filter map (cancelled by a new filter_map) current deinits (cancelled by cancelling an init_event) current param changes (cancelled by another pchange for same fx / param or a deinit) audio seeks
events are added in the standard ordering, i.e filter_inits, param changes, filter map, frame, filter_deinits
update the state until we pass out_tc
now we have a choice: we can either insert this frame at out_tc with the current fx state, or with the state at out_tc the difference is: either we force insertion of this frame now, with the current filter state, or we wait until we pass the slot and insert with the filter inits at that time
force insertion by setting stop_tc to -1, thus all events will have a timecode
laud_tc is last frame in_tc, frame_event is last frame
if init_event is in list, discard it + this event
param changes just get inserted at whatever timcode, as long as their init_event isnt in the "to be added" list
replace current filter map
probably a marker; ignore
insert the state
INSERT A FRAME AT OUT_TC
interpolate frames if possible
now we insert the frame
insert the audio state
if there is still audio to be added, update the seek posn to out_tc laud_tc is last frame in_tc
the timecode of each audio frame is adjusted to the quantised time, and we update the seek position accordingly however, when playing back, any velocity change will come slightly later than when recorded; thus the player seek pos will be slightly off. To remedy this we can very slightly adjust the velocity at the prior frame, so that the seek is correct when arriving at the current audio frame
< audio was off, older lists didnt store the offset
find the prior audio frame for the track
what we will do here is insert an extra audio event at the previous out_frame. the seek will be calculated from old_val, and we will adjust the velocity so we hit the seek value at this frame adjust velocity by seek_delta / frame_duration
merge natracks with xatracks
frame insertion done
increase out_tc
end of the in_list
end of out_list
for completeness we should add closers for all active audio tracks, however this will be done in event_list_rectify() when necessary (or ideally, the player would add the closers and record the offsets)
Definition at line 456 of file resample.c.
Referenced by on_resample_vid_ok(), and render_to_clip().
int reorder_frames | ( | int | rwidth, |
int | rheight | ||
) |
Definition at line 2106 of file resample.c.
void reorder_leave_back_set | ( | boolean | val | ) |
Definition at line 21 of file resample.c.
Referenced by create_new_pb_speed().
boolean resample_clipboard | ( | double | new_fps | ) |
call this to resample clipboard video
Definition at line 2250 of file resample.c.