Commit cb913029 authored by Josh Coalson's avatar Josh Coalson

initial import

parent 71e623bc
# libOggFLAC++ - Free Lossless Audio Codec + Ogg library
# Copyright (C) 2002 Josh Coalson
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library 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
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
includedir = ${prefix}/include/OggFLAC++
include_HEADERS = \
all.h \
decoder.h \
encoder.h
/* libOggFLAC++ - Free Lossless Audio Codec + Ogg library
* Copyright (C) 2002 Josh Coalson
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef OggFLACPP__ALL_H
#define OggFLACPP__ALL_H
#include "encoder.h"
#include "decoder.h"
/** \defgroup oggflacpp OggFLAC C++ API
*
* The OggFLAC C++ API is the interface to libOggFLAC++, a set of classes
* that encapsulate the encoders and decoders interfaces in libOggFLAC.
*
*/
#endif
/* libOggFLAC++ - Free Lossless Audio Codec + Ogg library
* Copyright (C) 2002 Josh Coalson
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef OggFLACPP__DECODER_H
#define OggFLACPP__DECODER_H
#include "OggFLAC/stream_decoder.h"
// we only need this for the state abstraction really...
#include "FLAC++/decoder.h"
// ===============================================================
//
// Full documentation for the decoder interfaces can be found
// in the C layer in include/OggFLAC/ *_decoder.h
//
// ===============================================================
/** \file include/OggFLAC++/decoder.h
*
* \brief
* This file contains the classes which implement the various
* decoders.
*
* See the detailed documentation in the
* \link oggflacpp_decoder decoder \endlink module.
*/
/** \defgroup oggflacpp_decoder OggFLAC++/decoder.h: decoder classes
* \ingroup oggflacpp
*
* \brief
* Brief XXX.
*
* Detailed decoder XXX.
*/
namespace OggFLAC {
namespace Decoder {
// ============================================================
//
// The only real difference here is that instead of passing
// in C function pointers for callbacks, you inherit from
// stream and provide implementations for the callbacks in
// the derived class; because of this there is no need for a
// 'client_data' property.
//
// ============================================================
// ============================================================
//
// Equivalent: OggFLAC__StreamDecoder
//
// ============================================================
/** \defgroup oggflacpp_stream_decoder OggFLAC++/decoder.h: stream decoder class
* \ingroup oggflacpp_decoder
*
* \brief
* Brief XXX.
*
* Detailed stream decoder XXX.
* \{
*/
/** stream decoder XXX.
*/
class Stream {
public:
class State {
public:
inline State(::OggFLAC__StreamDecoderState state): state_(state) { }
inline operator ::OggFLAC__StreamDecoderState() const { return state_; }
inline const char *as_cstring() const { return ::OggFLAC__StreamDecoderStateString[state_]; }
protected:
::OggFLAC__StreamDecoderState state_;
};
Stream();
virtual ~Stream();
bool is_valid() const;
inline operator bool() const { return is_valid(); }
bool set_metadata_respond(::FLAC__MetadataType type);
bool set_metadata_respond_application(const FLAC__byte id[4]);
bool set_metadata_respond_all();
bool set_metadata_ignore(::FLAC__MetadataType type);
bool set_metadata_ignore_application(const FLAC__byte id[4]);
bool set_metadata_ignore_all();
State get_state() const;
FLAC::Decoder::Stream::State get_FLAC_stream_decoder_state() const;
unsigned get_channels() const;
::FLAC__ChannelAssignment get_channel_assignment() const;
unsigned get_bits_per_sample() const;
unsigned get_sample_rate() const;
unsigned get_blocksize() const;
// Initialize the instance; as with the C interface,
// init() should be called after construction and 'set'
// calls but before any of the 'process' calls.
State init();
void finish();
bool flush();
bool reset();
bool process_single();
bool process_until_end_of_metadata();
bool process_until_end_of_stream();
protected:
virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes) = 0;
virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
::OggFLAC__StreamDecoder *decoder_;
private:
static ::FLAC__StreamDecoderReadStatus read_callback_(const ::OggFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::OggFLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
static void metadata_callback_(const ::OggFLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
static void error_callback_(const ::OggFLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
// Private and undefined so you can't use them:
Stream(const Stream &);
void operator=(const Stream &);
};
/* \} */
};
};
#endif
/* libOggFLAC++ - Free Lossless Audio Codec + Ogg library
* Copyright (C) 2002 Josh Coalson
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef OggFLACPP__ENCODER_H
#define OggFLACPP__ENCODER_H
#include "OggFLAC/stream_encoder.h"
#include "decoder.h"
// we only need these for the state abstractions really...
#include "FLAC++/decoder.h"
#include "FLAC++/encoder.h"
// ===============================================================
//
// Full documentation for the encoder interfaces can be found
// in the C layer in include/OggFLAC/ *_encoder.h
//
// ===============================================================
/** \file include/OggFLAC++/encoder.h
*
* \brief
* This module contains the classes which implement the various
* encoders.
*
* See the detailed documentation in the
* \link oggflacpp_encoder encoder \endlink module.
*/
/** \defgroup oggflacpp_encoder OggFLAC++/encoder.h: encoder classes
* \ingroup oggflacpp
*
* \brief
* Brief XXX.
*
* Detailed encoder XXX.
*/
namespace OggFLAC {
namespace Encoder {
// ============================================================
//
// Equivalent: OggFLAC__StreamEncoder
//
// ----------------------------------------------------------
//
// The only real difference here is that instead of passing
// in C function pointers for callbacks, you inherit from
// stream and provide implementations for the callbacks in
// the derived class; because of this there is no need for a
// 'client_data' property.
//
// ============================================================
/** \defgroup oggflacpp_stream_encoder OggFLAC++/encoder.h: stream encoder class
* \ingroup oggflacpp_encoder
*
* \brief
* Brief XXX.
*
* Detailed stream encoder XXX.
* \{
*/
/** stream encoder XXX.
*/
class Stream {
public:
class State {
public:
inline State(::OggFLAC__StreamEncoderState state): state_(state) { }
inline operator ::OggFLAC__StreamEncoderState() const { return state_; }
inline const char *as_cstring() const { return ::OggFLAC__StreamEncoderStateString[state_]; }
protected:
::OggFLAC__StreamEncoderState state_;
};
Stream();
virtual ~Stream();
bool is_valid() const;
inline operator bool() const { return is_valid(); }
bool set_verify(bool value);
bool set_streamable_subset(bool value);
bool set_do_mid_side_stereo(bool value);
bool set_loose_mid_side_stereo(bool value);
bool set_channels(unsigned value);
bool set_bits_per_sample(unsigned value);
bool set_sample_rate(unsigned value);
bool set_blocksize(unsigned value);
bool set_max_lpc_order(unsigned value);
bool set_qlp_coeff_precision(unsigned value);
bool set_do_qlp_coeff_prec_search(bool value);
bool set_do_escape_coding(bool value);
bool set_do_exhaustive_model_search(bool value);
bool set_min_residual_partition_order(unsigned value);
bool set_max_residual_partition_order(unsigned value);
bool set_rice_parameter_search_dist(unsigned value);
bool set_total_samples_estimate(FLAC__uint64 value);
bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
State get_state() const;
FLAC::Encoder::Stream::State get_FLAC_stream_encoder_state() const;
FLAC::Decoder::Stream::State get_verify_decoder_state() const;
bool get_verify() const;
bool get_streamable_subset() const;
bool get_do_mid_side_stereo() const;
bool get_loose_mid_side_stereo() const;
unsigned get_channels() const;
unsigned get_bits_per_sample() const;
unsigned get_sample_rate() const;
unsigned get_blocksize() const;
unsigned get_max_lpc_order() const;
unsigned get_qlp_coeff_precision() const;
bool get_do_qlp_coeff_prec_search() const;
bool get_do_escape_coding() const;
bool get_do_exhaustive_model_search() const;
unsigned get_min_residual_partition_order() const;
unsigned get_max_residual_partition_order() const;
unsigned get_rice_parameter_search_dist() const;
FLAC__uint64 get_total_samples_estimate() const;
// Initialize the instance; as with the C interface,
// init() should be called after construction and 'set'
// calls but before any of the 'process' calls.
State init();
void finish();
bool process(const FLAC__int32 * const buffer[], unsigned samples);
bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
protected:
virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame) = 0;
::OggFLAC__StreamEncoder *encoder_;
private:
static ::FLAC__StreamEncoderWriteStatus write_callback_(const ::OggFLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
// Private and undefined so you can't use them:
Stream(const Stream &);
void operator=(const Stream &);
};
/* \} */
};
};
#endif
# libOggFLAC++ - Free Lossless Audio Codec + Ogg library
# Copyright (C) 2002 Josh Coalson
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library 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
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
lib_LTLIBRARIES = libOggFLAC++.la
CXXFLAGS = @CXXFLAGS@
m4datadir = $(datadir)/aclocal
m4data_DATA = libOggFLAC++.m4
EXTRA_DIST = \
Makefile.lite \
Makefile.vc \
libOggFLAC++.m4
# see 'http://www.gnu.org/software/libtool/manual.html#Versioning' for numbering convention
libOggFLAC___la_LDFLAGS = -version-info 0:0:0
libOggFLAC___la_SOURCES = \
stream_decoder.cc \
stream_encoder.cc
# libOggFLAC++ - Free Lossless Audio Codec + Ogg library
# Copyright (C) 2002 Josh Coalson
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library 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
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
# GNU makefile
#
LIB_NAME = libOggFLAC++
INCLUDES = -I../../include
OBJS = \
stream_decoder.o \
stream_encoder.o
include ../../build/lib.mk
# DO NOT DELETE THIS LINE -- make depend depends on it.
# libOggFLAC++ - Free Lossless Audio Codec + Ogg library
# Copyright (C) 2002 Josh Coalson
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library 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
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
!include <win32.mak>
SUFFIXES = .cc
!IFDEF DEBUG
.cc.obj:
$(cc) /D "_LIB" /GX /GR $(cdebug) $(cflags) /I "..\..\include" -DSTRICT -YX /Od /D "_DEBUG" $<
!else
.cc.obj:
$(cc) /D "_LIB" /O2 /GR $(crelease) $(cflags) /I "..\..\include" -DSTRICT -YX -DNODEBUG $<
!endif
CC_FILES= \
stream_decoder.cc \
stream_encoder.cc
OBJS= $(CC_FILES:.cc=.obj)
all: libOggFLAC++.lib
libOggFLAC++.lib: $(OBJS)
link.exe -lib /nodefaultlib -out:../../obj/lib/$*.lib $(OBJS)
# can't figure out how to get it to take .cc so we just hack it for now:
stream_decoder.obj: stream_decoder.cc
$(cc) /D "_LIB" /O2 /GR $(crelease) $(cflags) /I "..\..\include" -DSTRICT -YX -DNODEBUG /TP stream_decoder.cc
stream_encoder.obj: stream_encoder.cc
$(cc) /D "_LIB" /O2 /GR $(crelease) $(cflags) /I "..\..\include" -DSTRICT -YX -DNODEBUG /TP stream_encoder.cc
clean:
-del *.obj *.pch
-del ..\..\obj\lib\libOggFLAC++.lib ..\..\obj\lib\libOggFLAC++.pdb
# Configure paths for libOggFLAC++
# "Inspired" by ogg.m4
# Caller must first run AM_PATH_LIBOGGFLAC
dnl AM_PATH_LIBOGGFLACPP([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
dnl Test for libOggFLAC++, and define LIBOGGFLACPP_CFLAGS and LIBOGGFLACPP_LIBS
dnl
AC_DEFUN(AM_PATH_LIBOGGFLACPP,
[dnl
dnl Get the cflags and libraries
dnl
AC_ARG_WITH(libOggFLACPP,[ --with-libOggFLACPP=PFX Prefix where libOggFLAC++ is installed (optional)], libOggFLACPP_prefix="$withval", libOggFLACPP_prefix="")
AC_ARG_WITH(libOggFLACPP-libraries,[ --with-libOggFLACPP-libraries=DIR Directory where libOggFLAC++ library is installed (optional)], libOggFLACPP_libraries="$withval", libOggFLACPP_libraries="")
AC_ARG_WITH(libOggFLACPP-includes,[ --with-libOggFLACPP-includes=DIR Directory where libOggFLAC++ header files are installed (optional)], libOggFLACPP_includes="$withval", libOggFLACPP_includes="")
AC_ARG_ENABLE(libOggFLACPPtest, [ --disable-libOggFLACPPtest Do not try to compile and run a test libOggFLAC++ program],, enable_libOggFLACPPtest=yes)
if test "x$libOggFLACPP_libraries" != "x" ; then
LIBOGGFLACPP_LIBS="-L$libOggFLACPP_libraries"
elif test "x$libOggFLACPP_prefix" != "x" ; then
LIBOGGFLACPP_LIBS="-L$libOggFLACPP_prefix/lib"
elif test "x$prefix" != "xNONE" ; then
LIBOGGFLACPP_LIBS="-L$prefix/lib"
fi
LIBOGGFLACPP_LIBS="$LIBOGGFLACPP_LIBS -lOggFLAC++ $LIBOGGFLAC_LIBS"
if test "x$libOggFLACPP_includes" != "x" ; then
LIBOGGFLACPP_CFLAGS="-I$libOggFLACPP_includes"
elif test "x$libOggFLACPP_prefix" != "x" ; then
LIBOGGFLACPP_CFLAGS="-I$libOggFLACPP_prefix/include"
elif test "$prefix" != "xNONE"; then
LIBOGGFLACPP_CFLAGS="-I$prefix/include"
fi
LIBOGGFLACPP_CFLAGS="$LIBOGGFLACPP_CFLAGS $LIBOGGFLAC_CFLAGS"
AC_MSG_CHECKING(for libOggFLAC++)
no_libOggFLACPP=""
if test "x$enable_libOggFLACPPtest" = "xyes" ; then
ac_save_CFLAGS="$CFLAGS"
ac_save_CXXFLAGS="$CXXFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $LIBOGGFLACPP_CFLAGS"
CXXFLAGS="$CXXFLAGS $LIBOGGFLACPP_CFLAGS"
LIBS="$LIBS $LIBOGGFLACPP_LIBS"
dnl
dnl Now check if the installed libOggFLAC++ is sufficiently new.
dnl
rm -f conf.libOggFLAC++test
AC_TRY_RUN([
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <OggFLAC++/decoder.h>
int main ()
{
system("touch conf.libOggFLAC++test");
return 0;
}
],, no_libOggFLACPP=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
if test "x$no_libOggFLACPP" = "x" ; then
AC_MSG_RESULT(yes)
ifelse([$1], , :, [$1])
else
AC_MSG_RESULT(no)
if test -f conf.libOggFLAC++test ; then
:
else
echo "*** Could not run libOggFLAC++ test program, checking why..."
CFLAGS="$CFLAGS $LIBOGGFLACPP_CFLAGS"
LIBS="$LIBS $LIBOGGFLACPP_LIBS"
AC_TRY_LINK([
#include <stdio.h>
#include <OggFLAC++/decoder.h>
], [ return 0; ],
[ echo "*** The test program compiled, but did not run. This usually means"
echo "*** that the run-time linker is not finding libOggFLAC++ or finding the wrong"
echo "*** version of libOggFLAC++. If it is not finding libOggFLAC++, you'll need to set your"
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
echo "*** to the installed location Also, make sure you have run ldconfig if that"
echo "*** is required on your system"
echo "***"
echo "*** If you have an old version installed, it is best to remove it, although"
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
[ echo "*** The test program failed to compile or link. See the file config.log for the"
echo "*** exact error that occured. This usually means libOggFLAC++ was incorrectly installed"
echo "*** or that you have moved libOggFLAC++ since it was installed. In the latter case, you"
echo "*** may want to edit the libOggFLAC++-config script: $LIBFLACPP_CONFIG" ])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
LIBOGGFLACPP_CFLAGS=""
LIBOGGFLACPP_LIBS=""
ifelse([$2], , :, [$2])
fi
AC_SUBST(LIBOGGFLACPP_CFLAGS)
AC_SUBST(LIBOGGFLACPP_LIBS)
rm -f conf.libOggFLAC++test
])
/* libOggFLAC++ - Free Lossless Audio Codec + Ogg library
* Copyright (C) 2002 Josh Coalson
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "OggFLAC++/decoder.h"
#include "FLAC/assert.h"
namespace OggFLAC {
namespace Decoder {
Stream::Stream():
decoder_(::OggFLAC__stream_decoder_new())
{ }
Stream::~Stream()
{
if(0 != decoder_) {
::OggFLAC__stream_decoder_finish(decoder_);
::OggFLAC__stream_decoder_delete(decoder_);
}
}
bool Stream::is_valid() const
{
return 0 != decoder_;
}
bool Stream::set_metadata_respond(::FLAC__MetadataType type)
{
FLAC__ASSERT(is_valid());