convert C prototypes for functions with no args from () to (void)
[platform/upstream/flac.git] / src / test_libFLAC / encoders.c
1 /* test_libFLAC - Unit tester for libFLAC
2  * Copyright (C) 2002,2003,2004,2005,2006  Josh Coalson
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  */
18
19 #if HAVE_CONFIG_H
20 #  include <config.h>
21 #endif
22
23 #include <errno.h>
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #include "encoders.h"
28 #include "FLAC/assert.h"
29 #include "FLAC/stream_encoder.h"
30 #include "share/grabbag.h"
31 #include "test_libs_common/file_utils_flac.h"
32 #include "test_libs_common/metadata_utils.h"
33
34 typedef enum {
35         LAYER_STREAM = 0, /* FLAC__stream_encoder_init_[ogg_]stream() without seeking */
36         LAYER_SEEKABLE_STREAM, /* FLAC__stream_encoder_init_[ogg_]stream() with seeking */
37         LAYER_FILE, /* FLAC__stream_encoder_init_[ogg_]FILE() */
38         LAYER_FILENAME /* FLAC__stream_encoder_init_[ogg_]file() */
39 } Layer;
40
41 static const char * const LayerString[] = {
42         "Stream",
43         "Seekable Stream",
44         "FILE*",
45         "Filename"
46 };
47
48 static FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, application2_, vorbiscomment_, cuesheet_, picture_, unknown_;
49 static FLAC__StreamMetadata *metadata_sequence_[] = { &vorbiscomment_, &padding_, &seektable_, &application1_, &application2_, &cuesheet_, &picture_, &unknown_ };
50 static const unsigned num_metadata_ = sizeof(metadata_sequence_) / sizeof(metadata_sequence_[0]);
51
52 static const char *flacfilename(FLAC__bool is_ogg)
53 {
54         return is_ogg? "metadata.ogg" : "metadata.flac";
55 }
56
57 static FLAC__bool die_(const char *msg)
58 {
59         printf("ERROR: %s\n", msg);
60         return false;
61 }
62
63 static FLAC__bool die_s_(const char *msg, const FLAC__StreamEncoder *encoder)
64 {
65         FLAC__StreamEncoderState state = FLAC__stream_encoder_get_state(encoder);
66
67         if(msg)
68                 printf("FAILED, %s", msg);
69         else
70                 printf("FAILED");
71
72         printf(", state = %u (%s)\n", (unsigned)state, FLAC__StreamEncoderStateString[state]);
73         if(state == FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR) {
74                 FLAC__StreamDecoderState dstate = FLAC__stream_encoder_get_verify_decoder_state(encoder);
75                 printf("      verify decoder state = %u (%s)\n", (unsigned)dstate, FLAC__StreamDecoderStateString[dstate]);
76         }
77
78         return false;
79 }
80
81 static void init_metadata_blocks_(void)
82 {
83         mutils__init_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &picture_, &unknown_);
84 }
85
86 static void free_metadata_blocks_(void)
87 {
88         mutils__free_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &picture_, &unknown_);
89 }
90
91 static FLAC__StreamEncoderReadStatus stream_encoder_read_callback_(const FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
92 {
93         FILE *f = (FILE*)client_data;
94         (void)encoder;
95         if(*bytes > 0) {
96                 *bytes = fread(buffer, sizeof(FLAC__byte), *bytes, f);
97                 if(ferror(f))
98                         return FLAC__STREAM_ENCODER_READ_STATUS_ABORT;
99                 else if(*bytes == 0)
100                         return FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM;
101                 else
102                         return FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE;
103         }
104         else
105                 return FLAC__STREAM_ENCODER_READ_STATUS_ABORT;
106 }
107
108 static FLAC__StreamEncoderWriteStatus stream_encoder_write_callback_(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, void *client_data)
109 {
110         FILE *f = (FILE*)client_data;
111         (void)encoder, (void)samples, (void)current_frame;
112         if(fwrite(buffer, 1, bytes, f) != bytes)
113                 return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
114         else
115                 return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
116 }
117
118 static FLAC__StreamEncoderSeekStatus stream_encoder_seek_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data)
119 {
120         FILE *f = (FILE*)client_data;
121         (void)encoder;
122         if(fseek(f, (long)absolute_byte_offset, SEEK_SET) < 0)
123                 return FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR;
124         else
125                 return FLAC__STREAM_ENCODER_SEEK_STATUS_OK;
126 }
127
128 static FLAC__StreamEncoderTellStatus stream_encoder_tell_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data)
129 {
130         FILE *f = (FILE*)client_data;
131         long pos;
132         (void)encoder;
133         if((pos = ftell(f)) < 0)
134                 return FLAC__STREAM_ENCODER_TELL_STATUS_ERROR;
135         else {
136                 *absolute_byte_offset = (FLAC__uint64)pos;
137                 return FLAC__STREAM_ENCODER_TELL_STATUS_OK;
138         }
139 }
140
141 static void stream_encoder_metadata_callback_(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetadata *metadata, void *client_data)
142 {
143         (void)encoder, (void)metadata, (void)client_data;
144 }
145
146 static void stream_encoder_progress_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data)
147 {
148         (void)encoder, (void)bytes_written, (void)samples_written, (void)frames_written, (void)total_frames_estimate, (void)client_data;
149 }
150
151 static FLAC__bool test_stream_encoder(Layer layer, FLAC__bool is_ogg)
152 {
153         FLAC__StreamEncoder *encoder;
154         FLAC__StreamEncoderInitStatus init_status;
155         FLAC__StreamEncoderState state;
156         FLAC__StreamDecoderState dstate;
157         FILE *file = 0;
158         FLAC__int32 samples[1024];
159         FLAC__int32 *samples_array[1];
160         unsigned i;
161
162         samples_array[0] = samples;
163
164         printf("\n+++ libFLAC unit test: FLAC__StreamEncoder (layer: %s, format: %s)\n\n", LayerString[layer], is_ogg? "Ogg FLAC":"FLAC");
165
166         printf("testing FLAC__stream_encoder_new()... ");
167         encoder = FLAC__stream_encoder_new();
168         if(0 == encoder) {
169                 printf("FAILED, returned NULL\n");
170                 return false;
171         }
172         printf("OK\n");
173
174         if(is_ogg) {
175                 printf("testing FLAC__stream_encoder_set_ogg_serial_number()... ");
176                 if(!FLAC__stream_encoder_set_ogg_serial_number(encoder, file_utils__ogg_serial_number))
177                         return die_s_("returned false", encoder);
178                 printf("OK\n");
179         }
180
181         printf("testing FLAC__stream_encoder_set_verify()... ");
182         if(!FLAC__stream_encoder_set_verify(encoder, true))
183                 return die_s_("returned false", encoder);
184         printf("OK\n");
185
186         printf("testing FLAC__stream_encoder_set_streamable_subset()... ");
187         if(!FLAC__stream_encoder_set_streamable_subset(encoder, true))
188                 return die_s_("returned false", encoder);
189         printf("OK\n");
190
191         printf("testing FLAC__stream_encoder_set_channels()... ");
192         if(!FLAC__stream_encoder_set_channels(encoder, streaminfo_.data.stream_info.channels))
193                 return die_s_("returned false", encoder);
194         printf("OK\n");
195
196         printf("testing FLAC__stream_encoder_set_bits_per_sample()... ");
197         if(!FLAC__stream_encoder_set_bits_per_sample(encoder, streaminfo_.data.stream_info.bits_per_sample))
198                 return die_s_("returned false", encoder);
199         printf("OK\n");
200
201         printf("testing FLAC__stream_encoder_set_sample_rate()... ");
202         if(!FLAC__stream_encoder_set_sample_rate(encoder, streaminfo_.data.stream_info.sample_rate))
203                 return die_s_("returned false", encoder);
204         printf("OK\n");
205
206         printf("testing FLAC__stream_encoder_set_compression_level()... ");
207         if(!FLAC__stream_encoder_set_compression_level(encoder, (unsigned)(-1)))
208                 return die_s_("returned false", encoder);
209         printf("OK\n");
210
211         printf("testing FLAC__stream_encoder_set_blocksize()... ");
212         if(!FLAC__stream_encoder_set_blocksize(encoder, streaminfo_.data.stream_info.min_blocksize))
213                 return die_s_("returned false", encoder);
214         printf("OK\n");
215
216         printf("testing FLAC__stream_encoder_set_do_mid_side_stereo()... ");
217         if(!FLAC__stream_encoder_set_do_mid_side_stereo(encoder, false))
218                 return die_s_("returned false", encoder);
219         printf("OK\n");
220
221         printf("testing FLAC__stream_encoder_set_loose_mid_side_stereo()... ");
222         if(!FLAC__stream_encoder_set_loose_mid_side_stereo(encoder, false))
223                 return die_s_("returned false", encoder);
224         printf("OK\n");
225
226         printf("testing FLAC__stream_encoder_set_max_lpc_order()... ");
227         if(!FLAC__stream_encoder_set_max_lpc_order(encoder, 0))
228                 return die_s_("returned false", encoder);
229         printf("OK\n");
230
231         printf("testing FLAC__stream_encoder_set_qlp_coeff_precision()... ");
232         if(!FLAC__stream_encoder_set_qlp_coeff_precision(encoder, 0))
233                 return die_s_("returned false", encoder);
234         printf("OK\n");
235
236         printf("testing FLAC__stream_encoder_set_do_qlp_coeff_prec_search()... ");
237         if(!FLAC__stream_encoder_set_do_qlp_coeff_prec_search(encoder, false))
238                 return die_s_("returned false", encoder);
239         printf("OK\n");
240
241         printf("testing FLAC__stream_encoder_set_do_escape_coding()... ");
242         if(!FLAC__stream_encoder_set_do_escape_coding(encoder, false))
243                 return die_s_("returned false", encoder);
244         printf("OK\n");
245
246         printf("testing FLAC__stream_encoder_set_do_exhaustive_model_search()... ");
247         if(!FLAC__stream_encoder_set_do_exhaustive_model_search(encoder, false))
248                 return die_s_("returned false", encoder);
249         printf("OK\n");
250
251         printf("testing FLAC__stream_encoder_set_min_residual_partition_order()... ");
252         if(!FLAC__stream_encoder_set_min_residual_partition_order(encoder, 0))
253                 return die_s_("returned false", encoder);
254         printf("OK\n");
255
256         printf("testing FLAC__stream_encoder_set_max_residual_partition_order()... ");
257         if(!FLAC__stream_encoder_set_max_residual_partition_order(encoder, 0))
258                 return die_s_("returned false", encoder);
259         printf("OK\n");
260
261         printf("testing FLAC__stream_encoder_set_rice_parameter_search_dist()... ");
262         if(!FLAC__stream_encoder_set_rice_parameter_search_dist(encoder, 0))
263                 return die_s_("returned false", encoder);
264         printf("OK\n");
265
266         printf("testing FLAC__stream_encoder_set_total_samples_estimate()... ");
267         if(!FLAC__stream_encoder_set_total_samples_estimate(encoder, streaminfo_.data.stream_info.total_samples))
268                 return die_s_("returned false", encoder);
269         printf("OK\n");
270
271         printf("testing FLAC__stream_encoder_set_metadata()... ");
272         if(!FLAC__stream_encoder_set_metadata(encoder, metadata_sequence_, num_metadata_))
273                 return die_s_("returned false", encoder);
274         printf("OK\n");
275
276         if(layer < LAYER_FILENAME) {
277                 printf("opening file for FLAC output... ");
278                 file = fopen(flacfilename(is_ogg), "w+b");
279                 if(0 == file) {
280                         printf("ERROR (%s)\n", strerror(errno));
281                         return false;
282                 }
283                 printf("OK\n");
284         }
285
286         switch(layer) {
287                 case LAYER_STREAM:
288                         printf("testing FLAC__stream_encoder_init_%sstream()... ", is_ogg? "ogg_":"");
289                         init_status = is_ogg?
290                                 FLAC__stream_encoder_init_ogg_stream(encoder, /*read_callback=*/0, stream_encoder_write_callback_, /*seek_callback=*/0, /*tell_callback=*/0, stream_encoder_metadata_callback_, /*client_data=*/file) :
291                                 FLAC__stream_encoder_init_stream(encoder, stream_encoder_write_callback_, /*seek_callback=*/0, /*tell_callback=*/0, stream_encoder_metadata_callback_, /*client_data=*/file);
292                         break;
293                 case LAYER_SEEKABLE_STREAM:
294                         printf("testing FLAC__stream_encoder_init_%sstream()... ", is_ogg? "ogg_":"");
295                         init_status = is_ogg?
296                                 FLAC__stream_encoder_init_ogg_stream(encoder, stream_encoder_read_callback_, stream_encoder_write_callback_, stream_encoder_seek_callback_, stream_encoder_tell_callback_, /*metadata_callback=*/0, /*client_data=*/file) :
297                                 FLAC__stream_encoder_init_stream(encoder, stream_encoder_write_callback_, stream_encoder_seek_callback_, stream_encoder_tell_callback_, /*metadata_callback=*/0, /*client_data=*/file);
298                         break;
299                 case LAYER_FILE:
300                         printf("testing FLAC__stream_encoder_init_%sFILE()... ", is_ogg? "ogg_":"");
301                         init_status = is_ogg?
302                                 FLAC__stream_encoder_init_ogg_FILE(encoder, file, stream_encoder_progress_callback_, /*client_data=*/0) :
303                                 FLAC__stream_encoder_init_FILE(encoder, file, stream_encoder_progress_callback_, /*client_data=*/0);
304                         break;
305                 case LAYER_FILENAME:
306                         printf("testing FLAC__stream_encoder_init_%sfile()... ", is_ogg? "ogg_":"");
307                         init_status = is_ogg?
308                                 FLAC__stream_encoder_init_ogg_file(encoder, flacfilename(is_ogg), stream_encoder_progress_callback_, /*client_data=*/0) :
309                                 FLAC__stream_encoder_init_file(encoder, flacfilename(is_ogg), stream_encoder_progress_callback_, /*client_data=*/0);
310                         break;
311                 default:
312                         die_("internal error 001");
313                         return false;
314         }
315         if(init_status != FLAC__STREAM_ENCODER_INIT_STATUS_OK)
316                 return die_s_(0, encoder);
317         printf("OK\n");
318
319         printf("testing FLAC__stream_encoder_get_state()... ");
320         state = FLAC__stream_encoder_get_state(encoder);
321         printf("returned state = %u (%s)... OK\n", (unsigned)state, FLAC__StreamEncoderStateString[state]);
322
323         printf("testing FLAC__stream_encoder_get_verify_decoder_state()... ");
324         dstate = FLAC__stream_encoder_get_verify_decoder_state(encoder);
325         printf("returned state = %u (%s)... OK\n", (unsigned)dstate, FLAC__StreamDecoderStateString[dstate]);
326
327         {
328                 FLAC__uint64 absolute_sample;
329                 unsigned frame_number;
330                 unsigned channel;
331                 unsigned sample;
332                 FLAC__int32 expected;
333                 FLAC__int32 got;
334
335                 printf("testing FLAC__stream_encoder_get_verify_decoder_error_stats()... ");
336                 FLAC__stream_encoder_get_verify_decoder_error_stats(encoder, &absolute_sample, &frame_number, &channel, &sample, &expected, &got);
337                 printf("OK\n");
338         }
339
340         printf("testing FLAC__stream_encoder_get_verify()... ");
341         if(FLAC__stream_encoder_get_verify(encoder) != true) {
342                 printf("FAILED, expected true, got false\n");
343                 return false;
344         }
345         printf("OK\n");
346
347         printf("testing FLAC__stream_encoder_get_streamable_subset()... ");
348         if(FLAC__stream_encoder_get_streamable_subset(encoder) != true) {
349                 printf("FAILED, expected true, got false\n");
350                 return false;
351         }
352         printf("OK\n");
353
354         printf("testing FLAC__stream_encoder_get_do_mid_side_stereo()... ");
355         if(FLAC__stream_encoder_get_do_mid_side_stereo(encoder) != false) {
356                 printf("FAILED, expected false, got true\n");
357                 return false;
358         }
359         printf("OK\n");
360
361         printf("testing FLAC__stream_encoder_get_loose_mid_side_stereo()... ");
362         if(FLAC__stream_encoder_get_loose_mid_side_stereo(encoder) != false) {
363                 printf("FAILED, expected false, got true\n");
364                 return false;
365         }
366         printf("OK\n");
367
368         printf("testing FLAC__stream_encoder_get_channels()... ");
369         if(FLAC__stream_encoder_get_channels(encoder) != streaminfo_.data.stream_info.channels) {
370                 printf("FAILED, expected %u, got %u\n", streaminfo_.data.stream_info.channels, FLAC__stream_encoder_get_channels(encoder));
371                 return false;
372         }
373         printf("OK\n");
374
375         printf("testing FLAC__stream_encoder_get_bits_per_sample()... ");
376         if(FLAC__stream_encoder_get_bits_per_sample(encoder) != streaminfo_.data.stream_info.bits_per_sample) {
377                 printf("FAILED, expected %u, got %u\n", streaminfo_.data.stream_info.bits_per_sample, FLAC__stream_encoder_get_bits_per_sample(encoder));
378                 return false;
379         }
380         printf("OK\n");
381
382         printf("testing FLAC__stream_encoder_get_sample_rate()... ");
383         if(FLAC__stream_encoder_get_sample_rate(encoder) != streaminfo_.data.stream_info.sample_rate) {
384                 printf("FAILED, expected %u, got %u\n", streaminfo_.data.stream_info.sample_rate, FLAC__stream_encoder_get_sample_rate(encoder));
385                 return false;
386         }
387         printf("OK\n");
388
389         printf("testing FLAC__stream_encoder_get_blocksize()... ");
390         if(FLAC__stream_encoder_get_blocksize(encoder) != streaminfo_.data.stream_info.min_blocksize) {
391                 printf("FAILED, expected %u, got %u\n", streaminfo_.data.stream_info.min_blocksize, FLAC__stream_encoder_get_blocksize(encoder));
392                 return false;
393         }
394         printf("OK\n");
395
396         printf("testing FLAC__stream_encoder_get_max_lpc_order()... ");
397         if(FLAC__stream_encoder_get_max_lpc_order(encoder) != 0) {
398                 printf("FAILED, expected %u, got %u\n", 0, FLAC__stream_encoder_get_max_lpc_order(encoder));
399                 return false;
400         }
401         printf("OK\n");
402
403         printf("testing FLAC__stream_encoder_get_qlp_coeff_precision()... ");
404         (void)FLAC__stream_encoder_get_qlp_coeff_precision(encoder);
405         /* we asked the encoder to auto select this so we accept anything */
406         printf("OK\n");
407
408         printf("testing FLAC__stream_encoder_get_do_qlp_coeff_prec_search()... ");
409         if(FLAC__stream_encoder_get_do_qlp_coeff_prec_search(encoder) != false) {
410                 printf("FAILED, expected false, got true\n");
411                 return false;
412         }
413         printf("OK\n");
414
415         printf("testing FLAC__stream_encoder_get_do_escape_coding()... ");
416         if(FLAC__stream_encoder_get_do_escape_coding(encoder) != false) {
417                 printf("FAILED, expected false, got true\n");
418                 return false;
419         }
420         printf("OK\n");
421
422         printf("testing FLAC__stream_encoder_get_do_exhaustive_model_search()... ");
423         if(FLAC__stream_encoder_get_do_exhaustive_model_search(encoder) != false) {
424                 printf("FAILED, expected false, got true\n");
425                 return false;
426         }
427         printf("OK\n");
428
429         printf("testing FLAC__stream_encoder_get_min_residual_partition_order()... ");
430         if(FLAC__stream_encoder_get_min_residual_partition_order(encoder) != 0) {
431                 printf("FAILED, expected %u, got %u\n", 0, FLAC__stream_encoder_get_min_residual_partition_order(encoder));
432                 return false;
433         }
434         printf("OK\n");
435
436         printf("testing FLAC__stream_encoder_get_max_residual_partition_order()... ");
437         if(FLAC__stream_encoder_get_max_residual_partition_order(encoder) != 0) {
438                 printf("FAILED, expected %u, got %u\n", 0, FLAC__stream_encoder_get_max_residual_partition_order(encoder));
439                 return false;
440         }
441         printf("OK\n");
442
443         printf("testing FLAC__stream_encoder_get_rice_parameter_search_dist()... ");
444         if(FLAC__stream_encoder_get_rice_parameter_search_dist(encoder) != 0) {
445                 printf("FAILED, expected %u, got %u\n", 0, FLAC__stream_encoder_get_rice_parameter_search_dist(encoder));
446                 return false;
447         }
448         printf("OK\n");
449
450         printf("testing FLAC__stream_encoder_get_total_samples_estimate()... ");
451         if(FLAC__stream_encoder_get_total_samples_estimate(encoder) != streaminfo_.data.stream_info.total_samples) {
452 #ifdef _MSC_VER
453                 printf("FAILED, expected %I64u, got %I64u\n", streaminfo_.data.stream_info.total_samples, FLAC__stream_encoder_get_total_samples_estimate(encoder));
454 #else
455                 printf("FAILED, expected %llu, got %llu\n", (unsigned long long)streaminfo_.data.stream_info.total_samples, (unsigned long long)FLAC__stream_encoder_get_total_samples_estimate(encoder));
456 #endif
457                 return false;
458         }
459         printf("OK\n");
460
461         /* init the dummy sample buffer */
462         for(i = 0; i < sizeof(samples) / sizeof(FLAC__int32); i++)
463                 samples[i] = i & 7;
464
465         printf("testing FLAC__stream_encoder_process()... ");
466         if(!FLAC__stream_encoder_process(encoder, (const FLAC__int32 * const *)samples_array, sizeof(samples) / sizeof(FLAC__int32)))
467                 return die_s_("returned false", encoder);
468         printf("OK\n");
469
470         printf("testing FLAC__stream_encoder_process_interleaved()... ");
471         if(!FLAC__stream_encoder_process_interleaved(encoder, samples, sizeof(samples) / sizeof(FLAC__int32)))
472                 return die_s_("returned false", encoder);
473         printf("OK\n");
474
475         printf("testing FLAC__stream_encoder_finish()... ");
476         if(!FLAC__stream_encoder_finish(encoder))
477                 return die_s_("returned false", encoder);
478         printf("OK\n");
479
480         if(layer < LAYER_FILE)
481                 fclose(file);
482
483         printf("testing FLAC__stream_encoder_delete()... ");
484         FLAC__stream_encoder_delete(encoder);
485         printf("OK\n");
486
487         printf("\nPASSED!\n");
488
489         return true;
490 }
491
492 FLAC__bool test_encoders(void)
493 {
494         FLAC__bool is_ogg = false;
495
496         while(1) {
497                 init_metadata_blocks_();
498
499                 if(!test_stream_encoder(LAYER_STREAM, is_ogg))
500                         return false;
501
502                 if(!test_stream_encoder(LAYER_SEEKABLE_STREAM, is_ogg))
503                         return false;
504
505                 if(!test_stream_encoder(LAYER_FILE, is_ogg))
506                         return false;
507
508                 if(!test_stream_encoder(LAYER_FILENAME, is_ogg))
509                         return false;
510
511                 (void) grabbag__file_remove_file(flacfilename(is_ogg));
512
513                 free_metadata_blocks_();
514
515                 if(!FLAC_API_SUPPORTS_OGG_FLAC || is_ogg)
516                         break;
517                 is_ogg = true;
518         }
519
520         return true;
521 }