6 #include "colormodels.h"
10 #include "filelist.inc"
11 #include "overlayframe.inc"
12 #include "strategies.inc"
15 #include <sys/types.h>
17 // inherited by every file interpreter
21 FileBase(Asset
*asset
, File
*file
);
26 friend class FileList
;
27 friend class FrameWriter
;
32 int get_mode(char *mode
, int rd
, int wr
);
33 int reset_parameters();
37 virtual void get_parameters(BC_WindowBase
*parent_window
,
39 BC_WindowBase
**format_window
,
42 int lock_compressor
) {};
46 virtual int get_index(char *index_path
) { return 1; };
47 virtual int check_header() { return 0; }; // Test file to see if it is of this type.
48 virtual int reset_parameters_derived() {};
49 virtual int read_header() {}; // WAV files for getting header
50 virtual int open_file(int rd
, int wr
) {};
51 virtual int close_file();
52 virtual int close_file_derived() {};
54 virtual int seek_end() { return 0; };
55 virtual int seek_start() { return 0; };
56 virtual int64_t get_video_position() { return 0; };
57 virtual int64_t get_audio_position() { return 0; };
58 virtual int set_video_position(int64_t x
) { return 0; };
59 virtual int set_audio_position(int64_t x
) { return 0; };
61 // Subclass should call this to add the base class allocation.
62 // Only used in read mode.
63 virtual int64_t get_memory_usage() { return 0; };
65 virtual int write_samples(double **buffer
,
66 int64_t len
) { return 0; };
67 virtual int write_frames(VFrame
***frames
, int len
) { return 0; };
68 virtual int read_compressed_frame(VFrame
*buffer
) { return 0; };
69 virtual int write_compressed_frame(VFrame
*buffers
) { return 0; };
70 virtual int64_t compressed_frame_size() { return 0; };
71 // Doubles are used to allow resampling
72 virtual int read_samples(double *buffer
, int64_t len
) { return 0; };
75 virtual int prefer_samples_float() {return 0;};
76 virtual int read_samples_float(float *buffer
, int64_t len
) { return 0; };
78 virtual int read_frame(VFrame
*frame
) { return 1; };
80 // Return either the argument or another colormodel which read_frame should
82 virtual int colormodel_supported(int colormodel
) { return BC_RGB888
; };
83 // This file can copy compressed frames directly from the asset
84 virtual int can_copy_from(Edit
*edit
, int64_t position
) { return 0; };
85 virtual int get_render_strategy(ArrayList
<int>* render_strategies
) { return VRENDER_VPIXEL
; };
88 // Return 1 if the render_strategy is present on the list.
89 static int search_render_strategies(ArrayList
<int>* render_strategies
, int render_strategy
);
91 // convert samples into file format
92 int64_t samples_to_raw(char *out_buffer
,
93 float **in_buffer
, // was **buffer
100 // overwrites the buffer from PCM data depending on feather.
101 int raw_to_samples(float *out_buffer
, char *in_buffer
,
102 int64_t samples
, int bits
, int channels
, int channel
, int feather
,
103 float lfeather_len
, float lfeather_gain
, float lfeather_slope
);
105 // Overwrite the buffer from float data using feather.
106 int overlay_float_buffer(float *out_buffer
, float *in_buffer
,
108 float lfeather_len
, float lfeather_gain
, float lfeather_slope
);
110 // convert a frame to and from file format
112 int64_t frame_to_raw(unsigned char *out_buffer
,
120 // allocate a buffer for translating int to float
121 int get_audio_buffer(char **buffer
, int64_t len
, int64_t bits
, int64_t channels
); // audio
123 // Allocate a buffer for feathering floats
124 int get_float_buffer(float **buffer
, int64_t len
);
126 // allocate a buffer for translating video to VFrame
127 int get_video_buffer(unsigned char **buffer
, int depth
); // video
128 int get_row_pointers(unsigned char *buffer
, unsigned char ***pointers
, int depth
);
129 static int match4(char *in
, char *out
); // match 4 bytes for a quicktime type
131 int64_t ima4_samples_to_bytes(int64_t samples
, int channels
);
132 int64_t ima4_bytes_to_samples(int64_t bytes
, int channels
);
134 char *audio_buffer_in
, *audio_buffer_out
; // for raw audio reads and writes
135 float *float_buffer
; // for floating point feathering
136 unsigned char *video_buffer_in
, *video_buffer_out
;
137 unsigned char **row_pointers_in
, **row_pointers_out
;
138 int64_t prev_buffer_position
; // for audio determines if reading raw data is necessary
139 int64_t prev_frame_position
; // for video determines if reading raw video data is necessary
140 int64_t prev_bytes
; // determines if new raw buffer is needed and used for getting memory usage
147 int internal_byte_order
;
154 // ================================= Audio compression
156 float ulawtofloat(char ulaw
);
157 char floattoulaw(float value
);
158 int generate_ulaw_tables();
159 int delete_ulaw_tables();
160 float *ulawtofloat_table
, *ulawtofloat_ptr
;
161 unsigned char *floattoulaw_table
, *floattoulaw_ptr
;
166 int ima4_decode_block(int16_t *output
, unsigned char *input
);
167 int ima4_decode_sample(int *predictor
, int nibble
, int *index
, int *step
);
168 int ima4_encode_block(unsigned char *output
, int16_t *input
, int step
, int channel
);
169 int ima4_encode_sample(int *last_sample
, int *last_index
, int *nibble
, int next_sample
);
171 static int ima4_step
[89];
172 static int ima4_index
[16];
173 int *last_ima4_samples
;
174 int *last_ima4_indexes
;
176 int ima4_block_samples
;
177 OverlayFrame
*overlayer
;