Commit f1eff45c authored by Josh Coalson's avatar Josh Coalson
Browse files

new seekable stream encoder and file encoder layers, not fully implemented yet

parent 570db867
......@@ -21,10 +21,12 @@ includedir = ${prefix}/include/FLAC
include_HEADERS = \
all.h \
assert.h \
file_encoder.h \
file_decoder.h \
format.h \
metadata.h \
ordinals.h \
seekable_stream_decoder.h \
seekable_stream_encoder.h \
stream_decoder.h \
stream_encoder.h
......@@ -22,10 +22,12 @@
#include "assert.h"
#include "file_decoder.h"
#include "file_encoder.h"
#include "format.h"
#include "metadata.h"
#include "ordinals.h"
#include "seekable_stream_decoder.h"
#include "seekable_stream_encoder.h"
#include "stream_decoder.h"
#include "stream_encoder.h"
......@@ -94,6 +96,28 @@
* From there you can go on to look at the documentation of
* individual functions. You can see different views of the individual
* functions through the links in top bar across this page.
*
* \section embedded_developers Embedded Developers
*
* libFLAC has grown larger over time as more functionality has been
* included, but much of it may be unnecessary for a particular embedded
* implementation. Unused parts may be pruned by some simple editing of
* src/libFLAC/Makefile.am. In general, the decoders, encoders, and
* metadata interface are all independent from each other.
*
* It is easiest to just describe the dependencies:
*
* - All modules depend on the \link flac_format Format \endlink module.
* - The decoders and encoders are independent of each other.
* - The metadata interface requires the file decoder.
* - The decoder and encoder layers depend on the layers below them, but
* not above them; e.g. the seekable stream decoder depends on the stream
* decoder but not the file decoder
*
* For example, if your application only requires the stream decoder, no
* encoders, and no metadata interface, you can remove the seekable stream
* decoder, file decoder, all encoders, and the metadata interface, which
* will greatly reduce the size of the library.
*/
/** \defgroup flac FLAC C API
......
This diff is collapsed.
This diff is collapsed.
......@@ -41,11 +41,18 @@ extern "C" {
* \ingroup flac
*
* \brief
* This module describes the single encoder layer provided by libFLAC.
* This module describes the two encoder layers provided by libFLAC.
*
* Currently there is only one level of encoder implementation which is at
* the stream level. There is currently no file encoder because seeking
* within a file while encoding seemed like too obscure a feature.
* For encoding FLAC streams, libFLAC provides two layers of access. The
* lowest layer is stream-level encoding, and the highest is file-level
* encoding. The interfaces are described in the \link flac_stream_encoder
* stream encoder \endlink and \link flac_file_encoder file encoder \endlink
* modules respectively. Typically you will choose the highest layer that
* your output source will support.
*
* The stream encoder relies on callbacks for writing the data and
* metadata. The file encoder provides these callbacks internally and you
* need only supply the filename.
*/
/** \defgroup flac_stream_encoder FLAC/stream_encoder.h: stream encoder interface
......@@ -574,6 +581,13 @@ FLAC__bool FLAC__stream_encoder_set_metadata(FLAC__StreamEncoder *encoder, FLAC_
* audio frames and the data is not guaranteed to be aligned on frame or
* metadata block boundaries.
*
* The only duty of the callback is to write out the \a bytes worth of data
* in \a buffer to the current position in the output stream. The arguments
* \a samples and \a current_frame are purely informational. If \a samples
* is greater than \c 0, then \a current_frame will hold the current frame
* number that is being written; otherwise, the write callback is being called
* to write metadata.
*
* \note
* The callback is mandatory and must be set before initialization.
*
......@@ -848,7 +862,6 @@ FLAC__bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, const FLAC
* sample-aligned, i.e. the first value should be channel0_sample0
* and the last value channelN_sampleM.
*
*
* \param encoder An initialized encoder instance in the OK state.
* \param buffer An array of channel-interleaved data (see above).
* \param samples The number of samples in one channel, the same as for
......
......@@ -51,6 +51,7 @@ libFLAC_la_SOURCES = \
cpu.c \
crc.c \
file_decoder.c \
file_encoder.c \
fixed.c \
format.c \
lpc.c \
......@@ -59,6 +60,7 @@ libFLAC_la_SOURCES = \
metadata_iterators.c \
metadata_object.c \
seekable_stream_decoder.c \
seekable_stream_encoder.c \
stream_decoder.c \
stream_encoder.c \
stream_encoder_framing.c
......@@ -50,6 +50,7 @@ OBJS = $(ASM_OBJS) \
cpu.o \
crc.o \
file_decoder.o \
file_encoder.o \
fixed.o \
format.o \
lpc.o \
......@@ -58,6 +59,7 @@ OBJS = $(ASM_OBJS) \
metadata_iterators.o \
metadata_object.o \
seekable_stream_decoder.o \
seekable_stream_encoder.o \
stream_decoder.o \
stream_encoder.o \
stream_encoder_framing.o
......
......@@ -34,6 +34,7 @@ C_FILES= \
cpu.c \
crc.c \
file_decoder.c \
file_encoder.c \
fixed.c \
format.c \
lpc.c \
......@@ -42,6 +43,7 @@ C_FILES= \
metadata_iterators.c \
metadata_object.c \
seekable_stream_decoder.c \
seekable_stream_encoder.c \
stream_decoder.c \
stream_encoder.c \
stream_encoder_framing.c
......
This diff is collapsed.
......@@ -19,6 +19,8 @@
noinst_HEADERS = \
all.h \
file_decoder.h \
file_encoder.h \
seekable_stream_decoder.h \
seekable_stream_encoder.h \
stream_decoder.h \
stream_encoder.h
......@@ -21,7 +21,9 @@
#define FLAC__PROTECTED__ALL_H
#include "file_decoder.h"
#include "file_encoder.h"
#include "seekable_stream_decoder.h"
#include "seekable_stream_encoder.h"
#include "stream_decoder.h"
#include "stream_encoder.h"
......
/* libFLAC - Free Lossless Audio Codec library
* Copyright (C) 2001,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 FLAC__PROTECTED__FILE_ENCODER_H
#define FLAC__PROTECTED__FILE_ENCODER_H
#include "FLAC/file_encoder.h"
typedef struct FLAC__FileEncoderProtected {
FLAC__FileEncoderState state;
} FLAC__FileEncoderProtected;
#endif
/* libFLAC - Free Lossless Audio Codec 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 FLAC__PROTECTED__SEEKABLE_STREAM_ENCODER_H
#define FLAC__PROTECTED__SEEKABLE_STREAM_ENCODER_H
#include "FLAC/seekable_stream_encoder.h"
typedef struct FLAC__SeekableStreamEncoderProtected {
FLAC__SeekableStreamEncoderState state;
} FLAC__SeekableStreamEncoderProtected;
#endif
This diff is collapsed.
This diff is collapsed.
......@@ -27,8 +27,8 @@
#endif
#define max(x,y) ((x)>(y)?(x):(y))
static FLAC__bool subframe_add_entropy_coding_method_(FLAC__BitBuffer *bb, const FLAC__EntropyCodingMethod *method);
static FLAC__bool subframe_add_residual_partitioned_rice_(FLAC__BitBuffer *bb, const FLAC__int32 residual[], const unsigned residual_samples, const unsigned predictor_order, const unsigned rice_parameters[], const unsigned raw_bits[], const unsigned partition_order);
static FLAC__bool add_entropy_coding_method_(FLAC__BitBuffer *bb, const FLAC__EntropyCodingMethod *method);
static FLAC__bool add_residual_partitioned_rice_(FLAC__BitBuffer *bb, const FLAC__int32 residual[], const unsigned residual_samples, const unsigned predictor_order, const unsigned rice_parameters[], const unsigned raw_bits[], const unsigned partition_order);
FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetadata *metadata, FLAC__BitBuffer *bb)
{
......@@ -279,11 +279,11 @@ FLAC__bool FLAC__subframe_add_fixed(const FLAC__Subframe_Fixed *subframe, unsign
if(!FLAC__bitbuffer_write_raw_int32(bb, subframe->warmup[i], subframe_bps))
return false;
if(!subframe_add_entropy_coding_method_(bb, &subframe->entropy_coding_method))
if(!add_entropy_coding_method_(bb, &subframe->entropy_coding_method))
return false;
switch(subframe->entropy_coding_method.type) {
case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE:
if(!subframe_add_residual_partitioned_rice_(bb, subframe->residual, residual_samples, subframe->order, subframe->entropy_coding_method.data.partitioned_rice.parameters, subframe->entropy_coding_method.data.partitioned_rice.raw_bits, subframe->entropy_coding_method.data.partitioned_rice.order))
if(!add_residual_partitioned_rice_(bb, subframe->residual, residual_samples, subframe->order, subframe->entropy_coding_method.data.partitioned_rice.parameters, subframe->entropy_coding_method.data.partitioned_rice.raw_bits, subframe->entropy_coding_method.data.partitioned_rice.order))
return false;
break;
default:
......@@ -315,11 +315,11 @@ FLAC__bool FLAC__subframe_add_lpc(const FLAC__Subframe_LPC *subframe, unsigned r
if(!FLAC__bitbuffer_write_raw_int32(bb, subframe->qlp_coeff[i], subframe->qlp_coeff_precision))
return false;
if(!subframe_add_entropy_coding_method_(bb, &subframe->entropy_coding_method))
if(!add_entropy_coding_method_(bb, &subframe->entropy_coding_method))
return false;
switch(subframe->entropy_coding_method.type) {
case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE:
if(!subframe_add_residual_partitioned_rice_(bb, subframe->residual, residual_samples, subframe->order, subframe->entropy_coding_method.data.partitioned_rice.parameters, subframe->entropy_coding_method.data.partitioned_rice.raw_bits, subframe->entropy_coding_method.data.partitioned_rice.order))
if(!add_residual_partitioned_rice_(bb, subframe->residual, residual_samples, subframe->order, subframe->entropy_coding_method.data.partitioned_rice.parameters, subframe->entropy_coding_method.data.partitioned_rice.raw_bits, subframe->entropy_coding_method.data.partitioned_rice.order))
return false;
break;
default:
......@@ -347,7 +347,7 @@ FLAC__bool FLAC__subframe_add_verbatim(const FLAC__Subframe_Verbatim *subframe,
return true;
}
FLAC__bool subframe_add_entropy_coding_method_(FLAC__BitBuffer *bb, const FLAC__EntropyCodingMethod *method)
FLAC__bool add_entropy_coding_method_(FLAC__BitBuffer *bb, const FLAC__EntropyCodingMethod *method)
{
if(!FLAC__bitbuffer_write_raw_uint32(bb, method->type, FLAC__ENTROPY_CODING_METHOD_TYPE_LEN))
return false;
......@@ -362,7 +362,7 @@ FLAC__bool subframe_add_entropy_coding_method_(FLAC__BitBuffer *bb, const FLAC__
return true;
}
FLAC__bool subframe_add_residual_partitioned_rice_(FLAC__BitBuffer *bb, const FLAC__int32 residual[], const unsigned residual_samples, const unsigned predictor_order, const unsigned rice_parameters[], const unsigned raw_bits[], const unsigned partition_order)
FLAC__bool add_residual_partitioned_rice_(FLAC__BitBuffer *bb, const FLAC__int32 residual[], const unsigned residual_samples, const unsigned predictor_order, const unsigned rice_parameters[], const unsigned raw_bits[], const unsigned partition_order)
{
if(partition_order == 0) {
unsigned i;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment