xref: /aosp_15_r20/external/flac/src/flac/encode.h (revision 600f14f40d737144c998e2ec7a483122d3776fbc)
1 /* flac - Command-line FLAC encoder/decoder
2  * Copyright (C) 2000-2009  Josh Coalson
3  * Copyright (C) 2011-2023  Xiph.Org Foundation
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef flac__encode_h
21 #define flac__encode_h
22 
23 #ifdef HAVE_CONFIG_H
24 #  include <config.h>
25 #endif
26 
27 #include "FLAC/metadata.h"
28 #include "foreign_metadata.h"
29 #include "utils.h"
30 #include "share/compat.h"
31 
32 extern const int FLAC_ENCODE__DEFAULT_PADDING;
33 
34 typedef enum {
35 	CST_BLOCKSIZE,
36 	CST_COMPRESSION_LEVEL,
37 	CST_DO_MID_SIDE,
38 	CST_LOOSE_MID_SIDE,
39 	CST_APODIZATION,
40 	CST_MAX_LPC_ORDER,
41 	CST_QLP_COEFF_PRECISION,
42 	CST_DO_QLP_COEFF_PREC_SEARCH,
43 	CST_DO_ESCAPE_CODING,
44 	CST_DO_EXHAUSTIVE_MODEL_SEARCH,
45 	CST_MIN_RESIDUAL_PARTITION_ORDER,
46 	CST_MAX_RESIDUAL_PARTITION_ORDER,
47 	CST_RICE_PARAMETER_SEARCH_DIST
48 } compression_setting_type_t;
49 
50 typedef struct {
51 	compression_setting_type_t type;
52 	union {
53 		FLAC__bool t_bool;
54 		unsigned t_unsigned;
55 		const char *t_string;
56 	} value;
57 } compression_setting_t;
58 
59 typedef struct {
60 	utils__SkipUntilSpecification skip_specification;
61 	utils__SkipUntilSpecification until_specification;
62 	FLAC__bool verify;
63 #if FLAC__HAS_OGG
64 	FLAC__bool use_ogg;
65 	long serial_number;
66 #endif
67 	FLAC__bool lax;
68 	int padding;
69 	size_t num_compression_settings;
70 	compression_setting_t compression_settings[64];
71 	char *requested_seek_points;
72 	int num_requested_seek_points;
73 	const char *cuesheet_filename;
74 	FLAC__bool treat_warnings_as_errors;
75 	FLAC__bool continue_through_decode_errors; /* currently only obeyed when encoding from FLAC or Ogg FLAC */
76 	FLAC__bool cued_seekpoints;
77 	FLAC__bool channel_map_none; /* --channel-map=none specified, eventually will expand to take actual channel map */
78 
79 	FLAC__bool is_first_file;
80 	FLAC__bool is_last_file;
81 	FLAC__bool replay_gain;
82 	FLAC__bool ignore_chunk_sizes;
83 	FLAC__bool error_on_compression_fail;
84 	FLAC__bool limit_min_bitrate;
85 	FLAC__bool relaxed_foreign_metadata_handling;
86 
87 	FLAC__StreamMetadata *vorbis_comment;
88 	FLAC__StreamMetadata *vorbis_comment_with_channel_mask_tag;
89 	FLAC__StreamMetadata *pictures[64];
90 	unsigned num_pictures;
91 
92 	FileFormat format;
93 	union {
94 		struct {
95 			FLAC__bool is_big_endian;
96 			FLAC__bool is_unsigned_samples;
97 			unsigned channels;
98 			unsigned bps;
99 			unsigned sample_rate;
100 		} raw;
101 		struct {
102 			foreign_metadata_t *foreign_metadata; /* NULL unless --keep-foreign-metadata requested */
103 		} iff;
104 	} format_options;
105 
106 	struct {
107 		FLAC__bool disable_constant_subframes;
108 		FLAC__bool disable_fixed_subframes;
109 		FLAC__bool disable_verbatim_subframes;
110 		FLAC__bool do_md5;
111 	} debug;
112 } encode_options_t;
113 
114 int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, uint32_t lookahead_length, encode_options_t options);
115 
116 #endif
117