22 #include <codec2/codec2.h> 60 c2->
codec = codec2_create(mode);
64 goto libcodec2_init_common_error;
73 codec2_destroy(c2->
codec);
75 goto libcodec2_init_common_error;
78 codec2_set_natural_or_gray(c2->
codec, 1);
82 libcodec2_init_common_error:
84 "Mode %i (%s) not supported with the linked version of libcodec2\n",
132 codec2_destroy(c2->
codec);
154 output = (int16_t *)frame->
data[0];
156 for (i = 0; i < nframes; i++) {
157 codec2_decode(c2->
codec, output, input);
162 *got_frame_ptr = nframes > 0;
170 int16_t *samples = (int16_t *)frame->
data[0];
177 codec2_encode(c2->
codec, avpkt->
data, samples);
193 .supported_samplerates = (
const int[]){ 8000, 0 },
209 .supported_samplerates = (
const int[]){ 8000, 0 },
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
static av_cold int libcodec2_init_common(AVCodecContext *avctx, int mode)
static int libcodec2_encode(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
#define LIBAVUTIL_VERSION_INT
static av_cold int init(AVCodecContext *avctx)
#define AV_OPT_FLAG_AUDIO_PARAM
const char * av_default_item_name(void *ptr)
Return the context name.
static uint8_t avpriv_codec2_mode_from_extradata(uint8_t *ptr)
static const AVClass libcodec2_dec_class
static int libcodec2_decode(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *pkt)
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
AVCodec ff_libcodec2_decoder
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
enum AVSampleFormat sample_fmt
audio sample format
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static av_cold int libcodec2_init_decoder(AVCodecContext *avctx)
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVCodec ff_libcodec2_encoder
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
const char * name
Name of the codec implementation.
#define AVPRIV_CODEC2_AVOPTIONS(desc, classname, min_val, default_val, option_flags)
uint64_t channel_layout
Audio channel layout.
#define AVPRIV_CODEC2_EXTRADATA_SIZE
static const AVOption options[]
int frame_size
Number of samples per channel in an audio frame.
Libavcodec external API header.
AVSampleFormat
Audio sample formats.
int sample_rate
samples per second
main external API structure.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Describe the class of an AVClass context structure.
static av_cold int libcodec2_close(AVCodecContext *avctx)
static av_cold int libcodec2_init_encoder(AVCodecContext *avctx)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal api header.
static const AVClass libcodec2_enc_class
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
static void avpriv_codec2_make_extradata(uint8_t *ptr, int mode)
int channels
number of audio channels
#define AVPRIV_CODEC2_MODE_MAX
#define AV_CH_LAYOUT_MONO
This structure stores compressed data.
mode
Use these values in ebur128_init (or'ed).
int nb_samples
number of audio samples (per channel) described by this frame