22 #include <codec2/codec2.h>
60 c2->codec = codec2_create(
mode);
64 goto libcodec2_init_common_error;
68 avctx->
block_align = (codec2_bits_per_frame(
c2->codec) + 7) / 8;
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);
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 },
Libavcodec external API header.
static av_cold int init(AVCodecContext *avctx)
#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)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
mode
Use these values in ebur128_init (or'ed).
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
#define AV_CH_LAYOUT_MONO
#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 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.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_S16
signed 16 bits
#define LIBAVUTIL_VERSION_INT
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static const AVOption options[]
static av_cold int libcodec2_init_encoder(AVCodecContext *avctx)
AVCodec ff_libcodec2_encoder
static int libcodec2_decode(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *pkt)
AVCodec ff_libcodec2_decoder
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 const AVClass libcodec2_dec_class
static av_cold int libcodec2_init_decoder(AVCodecContext *avctx)
static av_cold int libcodec2_close(AVCodecContext *avctx)
static const AVClass libcodec2_enc_class
#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
Describe the class of an AVClass context structure.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
main external API structure.
enum AVSampleFormat sample_fmt
audio sample format
int sample_rate
samples per second
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
int channels
number of audio channels
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs.
uint64_t channel_layout
Audio channel layout.
int frame_size
Number of samples per channel in an audio frame.
const char * name
Name of the codec implementation.
This structure describes decoded (raw) audio or video data.
int nb_samples
number of audio samples (per channel) described by this frame
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
This structure stores compressed data.