merge libOggFLAC into libFLAC and libOggFLAC++ into FLAC++; documentation still needs work

This commit is contained in:
Josh Coalson
2006-10-15 04:24:05 +00:00
parent 03dbb26a27
commit 8da98c897b
120 changed files with 2581 additions and 12227 deletions

View File

@@ -15,21 +15,13 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
if FLaC__HAS_OGG
OGGFLAC_SOURCES = \
file_utils_oggflac.c
OGGFLAC_LIBS = \
../libOggFLAC/libOggFLAC.la
endif
INCLUDES = -I$(top_srcdir)/include
noinst_LTLIBRARIES = libtest_libs_common.la
libtest_libs_common_la_SOURCES = \
file_utils_flac.c \
metadata_utils.c \
$(OGGFLAC_SOURCES)
metadata_utils.c
EXTRA_DIST = \
Makefile.lite \

View File

@@ -28,7 +28,6 @@ INCLUDES = -I$(topdir)/include
SRCS_C = \
file_utils_flac.c \
file_utils_oggflac.c \
metadata_utils.c
include $(topdir)/build/lib.mk

View File

@@ -32,6 +32,8 @@
#endif
#define min(a,b) ((a)<(b)?(a):(b))
const long file_utils__ogg_serial_number = 12345;
#ifdef FLAC__VALGRIND_TESTING
static size_t local__fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
{
@@ -65,10 +67,11 @@ static void encoder_metadata_callback_(const FLAC__StreamEncoder *encoder, const
(void)encoder, (void)metadata, (void)client_data;
}
FLAC__bool file_utils__generate_flacfile(const char *output_filename, off_t *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata)
FLAC__bool file_utils__generate_flacfile(FLAC__bool is_ogg, const char *output_filename, off_t *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata)
{
FLAC__int32 samples[1024];
FLAC__StreamEncoder *encoder;
FLAC__StreamEncoderInitStatus init_status;
encoder_client_struct encoder_client_data;
unsigned i, n;
@@ -86,6 +89,7 @@ FLAC__bool file_utils__generate_flacfile(const char *output_filename, off_t *out
return false;
}
FLAC__stream_encoder_set_serial_number(encoder, file_utils__ogg_serial_number);
FLAC__stream_encoder_set_verify(encoder, true);
FLAC__stream_encoder_set_streamable_subset(encoder, true);
FLAC__stream_encoder_set_do_mid_side_stereo(encoder, false);
@@ -105,7 +109,12 @@ FLAC__bool file_utils__generate_flacfile(const char *output_filename, off_t *out
FLAC__stream_encoder_set_total_samples_estimate(encoder, streaminfo->data.stream_info.total_samples);
FLAC__stream_encoder_set_metadata(encoder, metadata, num_metadata);
if(FLAC__stream_encoder_init_stream(encoder, encoder_write_callback_, /*seek_callback=*/0, /*tell_callback=*/0, encoder_metadata_callback_, &encoder_client_data) != FLAC__STREAM_ENCODER_INIT_STATUS_OK) {
if(is_ogg)
init_status = FLAC__stream_encoder_init_ogg_stream(encoder, /*read_callback=*/0, encoder_write_callback_, /*seek_callback=*/0, /*tell_callback=*/0, encoder_metadata_callback_, &encoder_client_data);
else
init_status = FLAC__stream_encoder_init_stream(encoder, encoder_write_callback_, /*seek_callback=*/0, /*tell_callback=*/0, encoder_metadata_callback_, &encoder_client_data);
if(init_status != FLAC__STREAM_ENCODER_INIT_STATUS_OK) {
fclose(encoder_client_data.file);
return false;
}

View File

@@ -1,147 +0,0 @@
/* test_libOggFLAC - Unit tester for libOggFLAC
* Copyright (C) 2002,2003,2004,2005,2006 Josh Coalson
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include "FLAC/assert.h"
#include "OggFLAC/stream_encoder.h"
#include "test_libs_common/file_utils_oggflac.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h> /* for stat() */
#ifdef min
#undef min
#endif
#define min(a,b) ((a)<(b)?(a):(b))
const long file_utils__serial_number = 12345;
#ifdef FLAC__VALGRIND_TESTING
static size_t local__fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
{
size_t ret = fwrite(ptr, size, nmemb, stream);
if(!ferror(stream))
fflush(stream);
return ret;
}
#else
#define local__fwrite fwrite
#endif
typedef struct {
FILE *file;
} encoder_client_struct;
static FLAC__StreamEncoderWriteStatus encoder_write_callback_(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data)
{
encoder_client_struct *ecd = (encoder_client_struct*)client_data;
(void)encoder, (void)samples, (void)current_frame;
if(local__fwrite(buffer, 1, bytes, ecd->file) != bytes)
return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
else
return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
}
static void encoder_metadata_callback_(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetadata *metadata, void *client_data)
{
(void)encoder, (void)metadata, (void)client_data;
}
FLAC__bool file_utils__generate_oggflacfile(const char *output_filename, off_t *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata)
{
FLAC__int32 samples[1024];
OggFLAC__StreamEncoder *encoder;
encoder_client_struct encoder_client_data;
unsigned i, n;
FLAC__ASSERT(0 != output_filename);
FLAC__ASSERT(0 != streaminfo);
FLAC__ASSERT(streaminfo->type == FLAC__METADATA_TYPE_STREAMINFO);
FLAC__ASSERT((streaminfo->is_last && num_metadata == 0) || (!streaminfo->is_last && num_metadata > 0));
if(0 == (encoder_client_data.file = fopen(output_filename, "wb")))
return false;
encoder = OggFLAC__stream_encoder_new();
if(0 == encoder) {
fclose(encoder_client_data.file);
return false;
}
OggFLAC__stream_encoder_set_serial_number(encoder, file_utils__serial_number);
OggFLAC__stream_encoder_set_verify(encoder, true);
OggFLAC__stream_encoder_set_streamable_subset(encoder, true);
OggFLAC__stream_encoder_set_do_mid_side_stereo(encoder, false);
OggFLAC__stream_encoder_set_loose_mid_side_stereo(encoder, false);
OggFLAC__stream_encoder_set_channels(encoder, streaminfo->data.stream_info.channels);
OggFLAC__stream_encoder_set_bits_per_sample(encoder, streaminfo->data.stream_info.bits_per_sample);
OggFLAC__stream_encoder_set_sample_rate(encoder, streaminfo->data.stream_info.sample_rate);
OggFLAC__stream_encoder_set_blocksize(encoder, streaminfo->data.stream_info.min_blocksize);
OggFLAC__stream_encoder_set_max_lpc_order(encoder, 0);
OggFLAC__stream_encoder_set_qlp_coeff_precision(encoder, 0);
OggFLAC__stream_encoder_set_do_qlp_coeff_prec_search(encoder, false);
OggFLAC__stream_encoder_set_do_escape_coding(encoder, false);
OggFLAC__stream_encoder_set_do_exhaustive_model_search(encoder, false);
OggFLAC__stream_encoder_set_min_residual_partition_order(encoder, 0);
OggFLAC__stream_encoder_set_max_residual_partition_order(encoder, 0);
OggFLAC__stream_encoder_set_rice_parameter_search_dist(encoder, 0);
OggFLAC__stream_encoder_set_total_samples_estimate(encoder, streaminfo->data.stream_info.total_samples);
OggFLAC__stream_encoder_set_metadata(encoder, metadata, num_metadata);
if(OggFLAC__stream_encoder_init_stream(encoder, /*read_callback=*/0, encoder_write_callback_, /*seek_callback=*/0, /*tell_callback=*/0, encoder_metadata_callback_, &encoder_client_data) != FLAC__STREAM_ENCODER_INIT_STATUS_OK) {
fclose(encoder_client_data.file);
return false;
}
/* init the dummy sample buffer */
for(i = 0; i < sizeof(samples) / sizeof(FLAC__int32); i++)
samples[i] = i & 7;
while(length > 0) {
n = min(length, sizeof(samples) / sizeof(FLAC__int32));
if(!OggFLAC__stream_encoder_process_interleaved(encoder, samples, n)) {
fclose(encoder_client_data.file);
return false;
}
length -= n;
}
OggFLAC__stream_encoder_finish(encoder);
fclose(encoder_client_data.file);
OggFLAC__stream_encoder_delete(encoder);
if(0 != output_filesize) {
struct stat filestats;
if(stat(output_filename, &filestats) != 0)
return false;
else
*output_filesize = filestats.st_size;
}
return true;
}

View File

@@ -89,10 +89,6 @@ SOURCE=.\file_utils_flac.c
# End Source File
# Begin Source File
SOURCE=.\file_utils_oggflac.c
# End Source File
# Begin Source File
SOURCE=.\metadata_utils.c
# End Source File
# End Group
@@ -105,10 +101,6 @@ SOURCE=..\..\include\test_libs_common\file_utils_flac.h
# End Source File
# Begin Source File
SOURCE=..\..\include\test_libs_common\file_utils_oggflac.h
# End Source File
# Begin Source File
SOURCE=..\..\include\test_libs_common\metadata_utils.h
# End Source File
# End Group