22#include <codec2/codec2.h>
46 .class_name =
"libcodec2 encoder",
58 c2->codec = codec2_create(
mode);
62 goto libcodec2_init_common_error;
66 avctx->
block_align = (codec2_bits_per_frame(
c2->codec) + 7) / 8;
71 codec2_destroy(
c2->codec);
73 goto libcodec2_init_common_error;
76 codec2_set_natural_or_gray(
c2->codec, 1);
80libcodec2_init_common_error:
82 "Mode %i (%s) not supported with the linked version of libcodec2\n",
122 codec2_destroy(
c2->codec);
131 const uint8_t *input;
145 output = (int16_t *)
frame->data[0];
147 for (
i = 0;
i < nframes;
i++) {
148 codec2_decode(
c2->codec, output, input);
153 *got_frame_ptr = nframes > 0;
161 int16_t *samples = (int16_t *)
frame->data[0];
168 codec2_encode(
c2->codec, avpkt->
data, samples);
175 .p.name =
"libcodec2",
188 .p.name =
"libcodec2",
const FFCodec ff_libcodec2_encoder
const FFCodec ff_libcodec2_decoder
static av_cold void close(AVCodecParserContext *s)
Libavcodec external API header.
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
#define CODEC2_AVOPTIONS(desc, classname, min_val, default_val, option_flags)
static uint8_t codec2_mode_from_extradata(uint8_t *ptr)
#define CODEC2_EXTRADATA_SIZE
static void codec2_make_extradata(uint8_t *ptr, int mode)
#define CODEC_CH_LAYOUTS(...)
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
#define FF_CODEC_DECODE_CB(func)
#define CODEC_SAMPLERATES(...)
#define FF_CODEC_ENCODE_CB(func)
#define CODEC_LONG_NAME(str)
#define CODEC_SAMPLEFMTS(...)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int(* init)(AVBSFContext *ctx)
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
#define AV_OPT_FLAG_AUDIO_PARAM
#define AV_OPT_FLAG_ENCODING_PARAM
A generic parameter which can be set by the user for muxing or encoding.
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
#define AV_CHANNEL_LAYOUT_MONO
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
@ AV_SAMPLE_FMT_S16
signed 16 bits
#define LIBAVUTIL_VERSION_INT
static av_cold int libcodec2_init_encoder(AVCodecContext *avctx)
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)
static int libcodec2_decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *pkt)
static av_cold int libcodec2_init_decoder(AVCodecContext *avctx)
static av_cold int libcodec2_close(AVCodecContext *avctx)
static const AVClass libcodec2_enc_class
Memory handling functions.
An AVChannelLayout holds information about the channel layout of audio data.
Describe the class of an AVClass context structure.
main external API structure.
AVChannelLayout ch_layout
Audio channel layout.
enum AVSampleFormat sample_fmt
audio sample format
int sample_rate
samples per second
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs.
int frame_size
Number of samples per channel in an audio frame.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.