#include <speex/speex.h>
#include <speex/speex_header.h>
#include <speex/speex_stereo.h>
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "internal.h"
Go to the source code of this file.
Data Structures | |
| struct | LibSpeexEncContext |
Defines | |
| #define | OFFSET(x) offsetof(LibSpeexEncContext, x) |
| #define | AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM |
Functions | |
| static av_cold void | print_enc_params (AVCodecContext *avctx, LibSpeexEncContext *s) |
| static av_cold int | encode_init (AVCodecContext *avctx) |
| static int | encode_frame (AVCodecContext *avctx, uint8_t *frame, int buf_size, void *data) |
| static av_cold int | encode_close (AVCodecContext *avctx) |
Variables | |
| static const AVOption | options [] |
| class { | |
| class_name = "libspeex" | |
| item_name = av_default_item_name | |
| option = options | |
| version = LIBAVUTIL_VERSION_INT | |
| }; | |
| static const AVCodecDefault | defaults [] |
| AVCodec | ff_libspeex_encoder |
Usage Guide This explains the values that need to be set prior to initialization in order to control various encoding parameters.
Channels Speex only supports mono or stereo, so avctx->channels must be set to 1 or 2.
Sample Rate / Encoding Mode Speex has 3 modes, each of which uses a specific sample rate. narrowband : 8 kHz wideband : 16 kHz ultra-wideband : 32 kHz avctx->sample_rate must be set to one of these 3 values. This will be used to set the encoding mode.
Rate Control VBR mode is turned on by setting CODEC_FLAG_QSCALE in avctx->flags. avctx->global_quality is used to set the encoding quality. For CBR mode, avctx->bit_rate can be used to set the constant bitrate. Alternatively, the 'cbr_quality' option can be set from 0 to 10 to set a constant bitrate based on quality. For ABR mode, set avctx->bit_rate and set the 'abr' option to 1. Approx. Bitrate Range: narrowband : 2400 - 25600 bps wideband : 4000 - 43200 bps ultra-wideband : 4400 - 45200 bps
Complexity Encoding complexity is controlled by setting avctx->compression_level. The valid range is 0 to 10. A higher setting gives generally better quality at the expense of encoding speed. This does not affect the bit rate.
Frames-per-Packet The encoder defaults to using 1 frame-per-packet. However, it is sometimes desirable to use multiple frames-per-packet to reduce the amount of container overhead. This can be done by setting the 'frames_per_packet' option to a value 1 to 8.
Definition in file libspeexenc.c.
| #define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM |
Definition at line 292 of file libspeexenc.c.
| #define OFFSET | ( | x | ) | offsetof(LibSpeexEncContext, x) |
Definition at line 291 of file libspeexenc.c.
| static av_cold int encode_close | ( | AVCodecContext * | avctx | ) | [static] |
Definition at line 278 of file libspeexenc.c.
| static int encode_frame | ( | AVCodecContext * | avctx, | |
| uint8_t * | frame, | |||
| int | buf_size, | |||
| void * | data | |||
| ) | [static] |
Definition at line 234 of file libspeexenc.c.
| static av_cold int encode_init | ( | AVCodecContext * | avctx | ) | [static] |
Definition at line 122 of file libspeexenc.c.
| static av_cold void print_enc_params | ( | AVCodecContext * | avctx, | |
| LibSpeexEncContext * | s | |||
| ) | [static] |
const { ... } [static] |
| class_name = "libspeex" |
const AVCodecDefault defaults[] [static] |
Initial value:
{
{ "b", "0" },
{ "compression_level", "3" },
{ NULL },
}
Definition at line 307 of file libspeexenc.c.
Initial value:
{
.name = "libspeex",
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_SPEEX,
.priv_data_size = sizeof(LibSpeexEncContext),
.init = encode_init,
.encode = encode_frame,
.close = encode_close,
.capabilities = CODEC_CAP_DELAY,
.sample_fmts = (const enum SampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE },
.long_name = NULL_IF_CONFIG_SMALL("libspeex Speex"),
.priv_class = &class,
.defaults = defaults,
}
Definition at line 313 of file libspeexenc.c.
| item_name = av_default_item_name |
Definition at line 302 of file libspeexenc.c.
Initial value:
{
{ "abr", "Use average bit rate", OFFSET(abr), AV_OPT_TYPE_INT, { 0 }, 0, 1, AE },
{ "cbr_quality", "Set quality value (0 to 10) for CBR", OFFSET(cbr_quality), AV_OPT_TYPE_INT, { 8 }, 0, 10, AE },
{ "frames_per_packet", "Number of frames to encode in each packet", OFFSET(frames_per_packet), AV_OPT_TYPE_INT, { 1 }, 1, 8, AE },
{ NULL },
}
Definition at line 293 of file libspeexenc.c.
Definition at line 304 of file libspeexenc.c.
Referenced by adpcm_compress_trellis(), aiff_read_header(), celt_header(), decode_frame(), decode_frame_header(), decode_init(), dvbsub_parse_clut_segment(), dvbsub_parse_page_segment(), dvbsub_parse_region_segment(), ff_mov_read_stsd_entries(), init(), libcelt_dec_init(), mov_read_chan(), mov_read_chpl(), mov_read_elst(), mov_read_mdhd(), mov_read_mvhd(), mov_read_tkhd(), mov_write_audio_tag(), mov_write_edts_tag(), mov_write_mdhd_tag(), mov_write_mvhd_tag(), mov_write_tkhd_tag(), mxf_write_identification(), read_header(), read_tfra(), rm_read_audio_stream_info(), smjpeg_read_header(), spdif_header_mpeg(), swf_write_header(), txd_decode_frame(), vble_decode_frame(), voc_probe(), voc_write_header(), wsvqa_read_header(), and xwd_decode_frame().
1.5.8