5 #include "colormodels.h"
9 #include "filelist.inc"
10 #include "overlayframe.inc"
11 #include "strategies.inc"
14 #include <sys/types.h>
16 // inherited by every file interpreter
20 FileBase(Asset
*asset
, File
*file
);
25 friend class FileList
;
26 friend class FrameWriter
;
31 int get_mode(char *mode
, int rd
, int wr
);
32 int reset_parameters();
33 virtual int check_header() { return 0; }; // Test file to see if it is of this type.
34 virtual int reset_parameters_derived() {};
35 virtual int read_header() {}; // WAV files for getting header
36 virtual int open_file(int rd
, int wr
) {};
37 virtual int close_file();
38 virtual int close_file_derived() {};
40 virtual int seek_end() { return 0; };
41 virtual int seek_start() { return 0; };
42 virtual int64_t get_video_position() { return 0; };
43 virtual int64_t get_audio_position() { return 0; };
44 virtual int set_video_position(int64_t x
) { return 0; };
45 virtual int set_audio_position(int64_t x
) { return 0; };
46 virtual int64_t get_memory_usage() { return 0; };
47 virtual int write_samples(double **buffer
,
48 int64_t len
) { return 0; };
49 virtual int write_frames(VFrame
***frames
, int len
) { return 0; };
50 virtual int read_compressed_frame(VFrame
*buffer
) { return 0; };
51 virtual int write_compressed_frame(VFrame
*buffers
) { return 0; };
52 virtual int64_t compressed_frame_size() { return 0; };
53 // Doubles are used to allow resampling
54 virtual int read_samples(double *buffer
, int64_t len
) { return 0; };
56 virtual int read_frame(VFrame
*frame
) { return 1; };
58 // Return either the argument or another colormodel which read_frame should
60 virtual int colormodel_supported(int colormodel
) { return BC_RGB888
; };
61 // This file can copy compressed frames directly from the asset
62 virtual int can_copy_from(Edit
*edit
, int64_t position
) { return 0; };
63 virtual int get_render_strategy(ArrayList
<int>* render_strategies
) { return VRENDER_VPIXEL
; };
66 // Return 1 if the render_strategy is present on the list.
67 static int search_render_strategies(ArrayList
<int>* render_strategies
, int render_strategy
);
69 // convert samples into file format
70 int64_t samples_to_raw(char *out_buffer
,
71 float **in_buffer
, // was **buffer
78 // overwrites the buffer from PCM data depending on feather.
79 int raw_to_samples(float *out_buffer
, char *in_buffer
,
80 int64_t samples
, int bits
, int channels
, int channel
, int feather
,
81 float lfeather_len
, float lfeather_gain
, float lfeather_slope
);
83 // Overwrite the buffer from float data using feather.
84 int overlay_float_buffer(float *out_buffer
, float *in_buffer
,
86 float lfeather_len
, float lfeather_gain
, float lfeather_slope
);
88 // convert a frame to and from file format
90 int64_t frame_to_raw(unsigned char *out_buffer
,
98 // allocate a buffer for translating int to float
99 int get_audio_buffer(char **buffer
, int64_t len
, int64_t bits
, int64_t channels
); // audio
101 // Allocate a buffer for feathering floats
102 int get_float_buffer(float **buffer
, int64_t len
);
104 // allocate a buffer for translating video to VFrame
105 int get_video_buffer(unsigned char **buffer
, int depth
); // video
106 int get_row_pointers(unsigned char *buffer
, unsigned char ***pointers
, int depth
);
107 static int match4(char *in
, char *out
); // match 4 bytes for a quicktime type
109 int64_t ima4_samples_to_bytes(int64_t samples
, int channels
);
110 int64_t ima4_bytes_to_samples(int64_t bytes
, int channels
);
112 char *audio_buffer_in
, *audio_buffer_out
; // for raw audio reads and writes
113 float *float_buffer
; // for floating point feathering
114 unsigned char *video_buffer_in
, *video_buffer_out
;
115 unsigned char **row_pointers_in
, **row_pointers_out
;
116 int64_t prev_buffer_position
; // for audio determines if reading raw data is necessary
117 int64_t prev_frame_position
; // for video determines if reading raw video data is necessary
118 int64_t prev_bytes
; // determines if new raw buffer is needed and used for getting memory usage
125 int internal_byte_order
;
132 // ================================= Audio compression
134 float ulawtofloat(char ulaw
);
135 char floattoulaw(float value
);
136 int generate_ulaw_tables();
137 int delete_ulaw_tables();
138 float *ulawtofloat_table
, *ulawtofloat_ptr
;
139 unsigned char *floattoulaw_table
, *floattoulaw_ptr
;
144 int ima4_decode_block(int16_t *output
, unsigned char *input
);
145 int ima4_decode_sample(int *predictor
, int nibble
, int *index
, int *step
);
146 int ima4_encode_block(unsigned char *output
, int16_t *input
, int step
, int channel
);
147 int ima4_encode_sample(int *last_sample
, int *last_index
, int *nibble
, int next_sample
);
149 static int ima4_step
[89];
150 static int ima4_index
[16];
151 int *last_ima4_samples
;
152 int *last_ima4_indexes
;
154 int ima4_block_samples
;
155 OverlayFrame
*overlayer
;