celt.h   celt.h 
/* (C) 2007 Jean-Marc Valin, CSIRO /* (C) 2007 Jean-Marc Valin, CSIRO
*/ */
/**
@file celt.h
@brief Contains all the functions for encoding and decoding audio streams
*/
/* /*
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
are met: are met:
- Redistributions of source code must retain the above copyright - Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright - Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the notice, this list of conditions and the following disclaimer in the
skipping to change at line 41 skipping to change at line 46
#ifndef CELT_H #ifndef CELT_H
#define CELT_H #define CELT_H
#include "celt_types.h" #include "celt_types.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* Error codes */
/** No error */
#define CELT_OK 0 #define CELT_OK 0
/** An (or more) invalid argument (e.g. out of range) */
#define CELT_BAD_ARG -1 #define CELT_BAD_ARG -1
/** The mode struct passed is invalid */
#define CELT_INVALID_MODE -2 #define CELT_INVALID_MODE -2
/** An internal error was detected */
#define CELT_INTERNAL_ERROR -3 #define CELT_INTERNAL_ERROR -3
/** The data passed (e.g. compressed data to decoder) is corrupted */
#define CELT_CORRUPTED_DATA -4 #define CELT_CORRUPTED_DATA -4
/* Requests */
/** GET the frame size used in the current mode */
#define CELT_GET_FRAME_SIZE 1000 #define CELT_GET_FRAME_SIZE 1000
/** GET the lookahead used in the current mode */
#define CELT_GET_LOOKAHEAD 1001 #define CELT_GET_LOOKAHEAD 1001
/** GET the number of channels used in the current mode */
#define CELT_GET_NB_CHANNELS 1002 #define CELT_GET_NB_CHANNELS 1002
/** Contains the state of an encoder. One encoder state is needed for each
stream. It is initialised once at the beginning of the stream. Do *not*
re-initialise the state for every frame.
@brief Encoder state
*/
typedef struct CELTEncoder CELTEncoder; typedef struct CELTEncoder CELTEncoder;
/** State of the decoder. One decoder state is needed for each stream. It i
s
initialised once at the beginning of the stream. Do *not* re-initialise
the state for every frame */
typedef struct CELTDecoder CELTDecoder; typedef struct CELTDecoder CELTDecoder;
/** The mode contains all the information necessary to create an encoder. B
oth
the encoder and decoder need to be initialised with exactly the same mo
de,
otherwise the quality will be very bad */
typedef struct CELTMode CELTMode; typedef struct CELTMode CELTMode;
extern const CELTMode *celt_mono; /* To be removed soon */
extern const CELTMode *celt_stereo; #define celt_mono celt_mode_create(44100, 1, 256, 128, NULL)
#define celt_stereo celt_mode_create(44100, 2, 256, 128, NULL)
/** \defgroup codec Encoding and decoding */
/* @{ */
/* Mode calls */
/** Creates a new mode struct. This will be passed to an encoder or decoder
.
The mode MUST NOT BE DESTROYED until the encoders and decoders that use
it
are destroyed as well.
@param Fs Sampling rate (32000 to 64000 Hz)
@param channels Number of channels
@param frame_size Number of samples (per channel) to encode in each packet
(64 - 256)
@param lookahead Extra latency (in samples per channel) in addition to the
frame size (between 32 and frame_size). The larger that value, the better
the quality (at the expense of latency)
@param error Returned error code (if NULL, no error will be returned)
@return A newly created mode
*/
CELTMode *celt_mode_create(int Fs, int channels, int frame_size, int lookah
ead, int *error);
/** Destroys a mode struct. Only call this after all encoders and decoders
using this mode are destroyed as well.
@param mode Mode to be destroyed
*/
void celt_mode_destroy(CELTMode *mode);
/** Query information from a mode */
int celt_mode_info(const CELTMode *mode, int request, celt_int32_t *value);
/* Encoder stuff */ /* Encoder stuff */
CELTEncoder *celt_encoder_new(const CELTMode *mode); /** Creates a new encoder state. Each stream needs its own encoder state (c
an't
be shared across simultaneous streams).
@param mode Contains all the information about the characteristics of the
stream
(must be the same characteristics as used for the decoder)
@return Newly created encoder state.
*/
CELTEncoder *celt_encoder_create(const CELTMode *mode);
/** Destroys a an encoder state.
@param st Encoder state to be destroyed
*/
void celt_encoder_destroy(CELTEncoder *st); void celt_encoder_destroy(CELTEncoder *st);
/** Encodes a frame of audio.
@param st Encoder state
@param pcm PCM audio in signed 16-bit format (native endian). There must b
e
exactly frame_size samples per channel. The input data is
overwritten by a copy of what the remote decoder would decode.
@param compressed The compressed data is written here
@param nbCompressedBytes Number of bytes to use for compressing the frame
(can change from one frame to another)
@return Number of bytes written to "compressed". Should be the same as
"nbCompressedBytes" unless the stream is VBR. If negative, an erro
r
has occured (see error codes). It is IMPORTANT that the length ret
urned
be somehow transmitted to the decoder. Otherwise, no decoding is p
ossible.
*/
int celt_encode(CELTEncoder *st, celt_int16_t *pcm, unsigned char *compress ed, int nbCompressedBytes); int celt_encode(CELTEncoder *st, celt_int16_t *pcm, unsigned char *compress ed, int nbCompressedBytes);
/* Decoder stuff */ /* Decoder stuff */
CELTDecoder *celt_decoder_new(const CELTMode *mode); /** Creates a new decoder state. Each stream needs its own decoder state (c
an't
be shared across simultaneous streams).
@param mode Contains all the information about the characteristics of the
stream (must be the same characteristics as used for the encod
er)
@return Newly created decoder state.
*/
CELTDecoder *celt_decoder_create(const CELTMode *mode);
/** Destroys a a decoder state.
@param st Decoder state to be destroyed
*/
void celt_decoder_destroy(CELTDecoder *st); void celt_decoder_destroy(CELTDecoder *st);
int celt_decode(CELTDecoder *st, char *data, int len, celt_int16_t *pcm); /** Decodes a frame of audio.
@param st Decoder state
/* Mode calls */ @param data Compressed data produced by an encoder
@param len Number of bytes to read from "data". This MUST be exactly the n
umber
of bytes returned by the encoder. Using a larger value WILL NOT
WORK.
@param pcm One frame (frame_size samples per channel) of decoded PCM will
be
returned here.
@return Error code.
*/
int celt_decode(CELTDecoder *st, unsigned char *data, int len, celt_int16_t
*pcm);
int celt_mode_info(const CELTMode *mode, int request, celt_int32_t *value); /* @} */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /*CELT_H */ #endif /*CELT_H */
 End of changes. 20 change blocks. 
8 lines changed or deleted 121 lines changed or added


 celt_header.h   celt_header.h 
skipping to change at line 42 skipping to change at line 42
#ifndef CELT_HEADER_H #ifndef CELT_HEADER_H
#define CELT_HEADER_H #define CELT_HEADER_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include "celt.h" #include "celt.h"
#include "celt_types.h" #include "celt_types.h"
/** Header data to be used for Ogg files (or possibly other encapsulation)
@brief Header data
*/
typedef struct { typedef struct {
char codec_id[8]; char codec_id[8]; /**< MUST be "CELT " (four spaces) */
char codec_version[20]; char codec_version[20]; /**< Version used (as string) */
celt_int32_t version_id; celt_int32_t version_id; /**< Version id (negative for until stre
celt_int32_t header_size; am is frozen) */
celt_int32_t mode; celt_int32_t header_size; /**< Size of this header */
celt_int32_t sample_rate; celt_int32_t sample_rate; /**< Sampling rate of the original audio
celt_int32_t nb_channels; */
celt_int32_t bytes_per_packet; celt_int32_t nb_channels; /**< Number of channels */
celt_int32_t extra_headers; celt_int32_t frame_size; /**< Samples per frame (per channel) */
celt_int32_t overlap; /**< Overlapping samples (per channel) *
/
celt_int32_t bytes_per_packet; /**< Number of bytes per compressed pack
et (0 if unknown) */
celt_int32_t extra_headers; /**< Number of additional headers that f
ollow this header */
} CELTHeader; } CELTHeader;
void celt_header_init(CELTHeader *header, celt_int32_t rate, celt_int32_t n /** Creates a basic header struct */
b_channels, const CELTMode *m); void celt_header_init(CELTHeader *header, const CELTMode *m);
int celt_header_to_packet(const CELTHeader *header, unsigned char *packet, celt_uint32_t size); int celt_header_to_packet(const CELTHeader *header, unsigned char *packet, celt_uint32_t size);
int celt_header_from_packet(const unsigned char *packet, celt_uint32_t size , CELTHeader *header); int celt_header_from_packet(const unsigned char *packet, celt_uint32_t size , CELTHeader *header);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* CELT_HEADER_H */ #endif /* CELT_HEADER_H */
 End of changes. 3 change blocks. 
11 lines changed or deleted 20 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/