FFmpeg
Data Structures | Macros | Typedefs | Functions | Variables
vorbisdec.c File Reference
#include <inttypes.h>
#include <math.h>
#include "libavutil/avassert.h"
#include "libavutil/float_dsp.h"
#include "libavutil/tx.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "decode.h"
#include "get_bits.h"
#include "vorbis.h"
#include "vorbisdsp.h"
#include "vorbis_data.h"
#include "xiph.h"

Go to the source code of this file.

Data Structures

struct  vorbis_codebook
 
struct  vorbis_floor
 
union  vorbis_floor::vorbis_floor_u
 
struct  vorbis_floor::vorbis_floor_u::vorbis_floor0_s
 
struct  vorbis_floor::vorbis_floor_u::vorbis_floor1_s
 
struct  vorbis_residue
 
struct  vorbis_mapping
 
struct  vorbis_mode
 
struct  vorbis_context_s
 

Macros

#define BITSTREAM_READER_LE
 
#define V_NB_BITS   8
 
#define V_NB_BITS2   11
 
#define V_MAX_VLCS   (1 << 16)
 
#define V_MAX_PARTITIONS   (1 << 20)
 
#define BARK(x)   (13.1f * atan(0.00074f * (x)) + 2.24f * atan(1.85e-8f * (x) * (x)) + 1e-4f * (x))
 
#define VALIDATE_INDEX(idx, limit)
 
#define GET_VALIDATED_INDEX(idx, bits, limit)
 

Typedefs

typedef union vorbis_floor_u vorbis_floor_data
 
typedef struct vorbis_floor0_s vorbis_floor0
 
typedef struct vorbis_floor1_s vorbis_floor1
 
typedef int(* vorbis_floor_decode_func) (struct vorbis_context_s *, vorbis_floor_data *, float *)
 

Functions

static float vorbisfloat2float (unsigned val)
 
static void vorbis_free (vorbis_context *vc)
 
static int vorbis_parse_setup_hdr_codebooks (vorbis_context *vc)
 
static int vorbis_parse_setup_hdr_tdtransforms (vorbis_context *vc)
 
static int vorbis_floor0_decode (vorbis_context *vc, vorbis_floor_data *vfu, float *vec)
 
static int create_map (vorbis_context *vc, unsigned floor_number)
 
static int vorbis_floor1_decode (vorbis_context *vc, vorbis_floor_data *vfu, float *vec)
 
static int vorbis_parse_setup_hdr_floors (vorbis_context *vc)
 
static int vorbis_parse_setup_hdr_residues (vorbis_context *vc)
 
static int vorbis_parse_setup_hdr_mappings (vorbis_context *vc)
 
static int vorbis_parse_setup_hdr_modes (vorbis_context *vc)
 
static int vorbis_parse_setup_hdr (vorbis_context *vc)
 
static int vorbis_parse_id_hdr (vorbis_context *vc)
 
static av_cold int vorbis_decode_init (AVCodecContext *avctx)
 
static av_always_inline int setup_classifs (vorbis_context *vc, vorbis_residue *vr, uint8_t *do_not_decode, unsigned ch_used, int partition_count, int ptns_to_read)
 
static av_always_inline int vorbis_residue_decode_internal (vorbis_context *vc, vorbis_residue *vr, unsigned ch, uint8_t *do_not_decode, float *vec, unsigned vlen, unsigned ch_left, int vr_type)
 
static int vorbis_residue_decode (vorbis_context *vc, vorbis_residue *vr, unsigned ch, uint8_t *do_not_decode, float *vec, unsigned vlen, unsigned ch_left)
 
static int vorbis_parse_audio_packet (vorbis_context *vc, float **floor_ptr)
 
static int vorbis_decode_frame (AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
 
static av_cold int vorbis_decode_close (AVCodecContext *avctx)
 
static av_cold void vorbis_decode_flush (AVCodecContext *avctx)
 

Variables

static const char idx_err_str [] = "Index value %d out of range (0 - %d) for %s at %s:%i\n"
 
const FFCodec ff_vorbis_decoder
 

Detailed Description

Vorbis I decoder

Author
Denes Balatoni ( dbalatoni programozo hu )

This file is part of FFmpeg.

FFmpeg is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

FFmpeg is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with FFmpeg; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Vorbis I decoder

Author
Denes Balatoni ( dbalatoni programozo hu )

Definition in file vorbisdec.c.

Macro Definition Documentation

◆ BITSTREAM_READER_LE

#define BITSTREAM_READER_LE

Definition at line 36 of file vorbisdec.c.

◆ V_NB_BITS

#define V_NB_BITS   8

Definition at line 46 of file vorbisdec.c.

◆ V_NB_BITS2

#define V_NB_BITS2   11

Definition at line 47 of file vorbisdec.c.

◆ V_MAX_VLCS

#define V_MAX_VLCS   (1 << 16)

Definition at line 48 of file vorbisdec.c.

◆ V_MAX_PARTITIONS

#define V_MAX_PARTITIONS   (1 << 20)

Definition at line 49 of file vorbisdec.c.

◆ BARK

#define BARK (   x)    (13.1f * atan(0.00074f * (x)) + 2.24f * atan(1.85e-8f * (x) * (x)) + 1e-4f * (x))

Definition at line 164 of file vorbisdec.c.

◆ VALIDATE_INDEX

#define VALIDATE_INDEX (   idx,
  limit 
)
Value:
if (idx >= limit) {\
av_log(vc->avctx, AV_LOG_ERROR,\
(int)(idx), (int)(limit - 1), #idx, __FILE__, __LINE__);\
}

Definition at line 168 of file vorbisdec.c.

◆ GET_VALIDATED_INDEX

#define GET_VALIDATED_INDEX (   idx,
  bits,
  limit 
)
Value:
{\
idx = get_bits(gb, bits);\
VALIDATE_INDEX(idx, limit)\
}

Definition at line 175 of file vorbisdec.c.

Typedef Documentation

◆ vorbis_floor_data

typedef union vorbis_floor_u vorbis_floor_data

Definition at line 60 of file vorbisdec.c.

◆ vorbis_floor0

typedef struct vorbis_floor0_s vorbis_floor0

Definition at line 61 of file vorbisdec.c.

◆ vorbis_floor1

typedef struct vorbis_floor1_s vorbis_floor1

Definition at line 62 of file vorbisdec.c.

◆ vorbis_floor_decode_func

typedef int(* vorbis_floor_decode_func) (struct vorbis_context_s *, vorbis_floor_data *, float *)

Definition at line 66 of file vorbisdec.c.

Function Documentation

◆ vorbisfloat2float()

static float vorbisfloat2float ( unsigned  val)
static

Definition at line 181 of file vorbisdec.c.

Referenced by vorbis_parse_setup_hdr_codebooks().

◆ vorbis_free()

static void vorbis_free ( vorbis_context *  vc)
static

Definition at line 193 of file vorbisdec.c.

Referenced by vorbis_decode_close(), vorbis_decode_frame(), and vorbis_decode_init().

◆ vorbis_parse_setup_hdr_codebooks()

static int vorbis_parse_setup_hdr_codebooks ( vorbis_context *  vc)
static

Definition at line 243 of file vorbisdec.c.

Referenced by vorbis_parse_setup_hdr().

◆ vorbis_parse_setup_hdr_tdtransforms()

static int vorbis_parse_setup_hdr_tdtransforms ( vorbis_context *  vc)
static

Definition at line 478 of file vorbisdec.c.

Referenced by vorbis_parse_setup_hdr().

◆ vorbis_floor0_decode()

static int vorbis_floor0_decode ( vorbis_context *  vc,
vorbis_floor_data vfu,
float vec 
)
static

Definition at line 1112 of file vorbisdec.c.

Referenced by vorbis_parse_setup_hdr_floors().

◆ create_map()

static int create_map ( vorbis_context *  vc,
unsigned  floor_number 
)
static

Definition at line 855 of file vorbisdec.c.

Referenced by vorbis_parse_setup_hdr_floors().

◆ vorbis_floor1_decode()

static int vorbis_floor1_decode ( vorbis_context *  vc,
vorbis_floor_data vfu,
float vec 
)
static

Definition at line 1226 of file vorbisdec.c.

Referenced by vorbis_parse_setup_hdr_floors().

◆ vorbis_parse_setup_hdr_floors()

static int vorbis_parse_setup_hdr_floors ( vorbis_context *  vc)
static

Definition at line 504 of file vorbisdec.c.

Referenced by vorbis_parse_setup_hdr().

◆ vorbis_parse_setup_hdr_residues()

static int vorbis_parse_setup_hdr_residues ( vorbis_context *  vc)
static

Definition at line 694 of file vorbisdec.c.

Referenced by vorbis_parse_setup_hdr().

◆ vorbis_parse_setup_hdr_mappings()

static int vorbis_parse_setup_hdr_mappings ( vorbis_context *  vc)
static

Definition at line 775 of file vorbisdec.c.

Referenced by vorbis_parse_setup_hdr().

◆ vorbis_parse_setup_hdr_modes()

static int vorbis_parse_setup_hdr_modes ( vorbis_context *  vc)
static

Definition at line 890 of file vorbisdec.c.

Referenced by vorbis_parse_setup_hdr().

◆ vorbis_parse_setup_hdr()

static int vorbis_parse_setup_hdr ( vorbis_context *  vc)
static

Definition at line 919 of file vorbisdec.c.

Referenced by vorbis_decode_frame(), and vorbis_decode_init().

◆ vorbis_parse_id_hdr()

static int vorbis_parse_id_hdr ( vorbis_context *  vc)
static

Definition at line 965 of file vorbisdec.c.

Referenced by vorbis_decode_frame(), and vorbis_decode_init().

◆ vorbis_decode_init()

static av_cold int vorbis_decode_init ( AVCodecContext avctx)
static

Definition at line 1045 of file vorbisdec.c.

◆ setup_classifs()

static av_always_inline int setup_classifs ( vorbis_context *  vc,
vorbis_residue vr,
uint8_t *  do_not_decode,
unsigned  ch_used,
int  partition_count,
int  ptns_to_read 
)
static

Definition at line 1353 of file vorbisdec.c.

Referenced by vorbis_residue_decode_internal().

◆ vorbis_residue_decode_internal()

static av_always_inline int vorbis_residue_decode_internal ( vorbis_context *  vc,
vorbis_residue vr,
unsigned  ch,
uint8_t *  do_not_decode,
float vec,
unsigned  vlen,
unsigned  ch_left,
int  vr_type 
)
static

Definition at line 1402 of file vorbisdec.c.

Referenced by vorbis_residue_decode().

◆ vorbis_residue_decode()

static int vorbis_residue_decode ( vorbis_context *  vc,
vorbis_residue vr,
unsigned  ch,
uint8_t *  do_not_decode,
float vec,
unsigned  vlen,
unsigned  ch_left 
)
inlinestatic

Definition at line 1577 of file vorbisdec.c.

Referenced by vorbis_parse_audio_packet().

◆ vorbis_parse_audio_packet()

static int vorbis_parse_audio_packet ( vorbis_context *  vc,
float **  floor_ptr 
)
static

Definition at line 1597 of file vorbisdec.c.

Referenced by vorbis_decode_frame().

◆ vorbis_decode_frame()

static int vorbis_decode_frame ( AVCodecContext avctx,
AVFrame frame,
int got_frame_ptr,
AVPacket avpkt 
)
static

Definition at line 1762 of file vorbisdec.c.

◆ vorbis_decode_close()

static av_cold int vorbis_decode_close ( AVCodecContext avctx)
static

Definition at line 1862 of file vorbisdec.c.

◆ vorbis_decode_flush()

static av_cold void vorbis_decode_flush ( AVCodecContext avctx)
static

Definition at line 1871 of file vorbisdec.c.

Variable Documentation

◆ idx_err_str

const char idx_err_str[] = "Index value %d out of range (0 - %d) for %s at %s:%i\n"
static

Definition at line 167 of file vorbisdec.c.

◆ ff_vorbis_decoder

const FFCodec ff_vorbis_decoder
Initial value:
= {
.p.name = "vorbis",
CODEC_LONG_NAME("Vorbis"),
.p.type = AVMEDIA_TYPE_AUDIO,
.priv_data_size = sizeof(vorbis_context),
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
.p.ch_layouts = ff_vorbis_ch_layouts,
.p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
}

Definition at line 1882 of file vorbisdec.c.

AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:66
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:42
vorbis_decode_close
static av_cold int vorbis_decode_close(AVCodecContext *avctx)
Definition: vorbisdec.c:1862
idx_err_str
static const char idx_err_str[]
Definition: vorbisdec.c:167
get_bits
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:325
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:306
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:365
bits
uint8_t bits
Definition: vp3data.h:128
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
vorbis_decode_init
static av_cold int vorbis_decode_init(AVCodecContext *avctx)
Definition: vorbisdec.c:1045
AV_CODEC_CAP_CHANNEL_CONF
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
Definition: codec.h:103
vorbis_decode_frame
static int vorbis_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
Definition: vorbisdec.c:1762
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
limit
static double limit(double x)
Definition: vf_pseudocolor.c:130
ff_vorbis_ch_layouts
const AVChannelLayout ff_vorbis_ch_layouts[9]
Definition: vorbis_data.c:51
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
AV_CODEC_ID_VORBIS
@ AV_CODEC_ID_VORBIS
Definition: codec_id.h:443
vorbis_decode_flush
static av_cold void vorbis_decode_flush(AVCodecContext *avctx)
Definition: vorbisdec.c:1871