vkQuake2 doxygen  1.0 dev
dr_mp3.h File Reference
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <assert.h>
#include <stdio.h>

Go to the source code of this file.

Classes

struct  drmp3dec_frame_info
 
struct  drmp3dec
 
struct  drmp3_src_cache
 
struct  drmp3_src_config
 
struct  drmp3_src
 
struct  drmp3_seek_point
 
struct  drmp3_config
 
struct  drmp3
 

Macros

#define DRMP3_TRUE   1
 
#define DRMP3_FALSE   0
 
#define DRMP3_MAX_PCM_FRAMES_PER_MP3_FRAME   1152
 
#define DRMP3_MAX_SAMPLES_PER_FRAME   (DRMP3_MAX_PCM_FRAMES_PER_MP3_FRAME*2)
 
#define DRMP3_INLINE
 
#define DR_MP3_DEFAULT_CHANNELS   2
 
#define DR_MP3_DEFAULT_SAMPLE_RATE   44100
 
#define DRMP3_SRC_CACHE_SIZE_IN_FRAMES   512
 

Typedefs

typedef int8_t drmp3_int8
 
typedef uint8_t drmp3_uint8
 
typedef int16_t drmp3_int16
 
typedef uint16_t drmp3_uint16
 
typedef int32_t drmp3_int32
 
typedef uint32_t drmp3_uint32
 
typedef int64_t drmp3_int64
 
typedef uint64_t drmp3_uint64
 
typedef drmp3_uint8 drmp3_bool8
 
typedef drmp3_uint32 drmp3_bool32
 
typedef struct drmp3_src drmp3_src
 
typedef drmp3_uint64(* drmp3_src_read_proc) (drmp3_src *pSRC, drmp3_uint64 frameCount, void *pFramesOut, void *pUserData)
 
typedef size_t(* drmp3_read_proc) (void *pUserData, void *pBufferOut, size_t bytesToRead)
 
typedef drmp3_bool32(* drmp3_seek_proc) (void *pUserData, int offset, drmp3_seek_origin origin)
 

Enumerations

enum  drmp3_src_algorithm { drmp3_src_algorithm_none, drmp3_src_algorithm_linear }
 
enum  drmp3_seek_origin { drmp3_seek_origin_start, drmp3_seek_origin_current }
 

Functions

void drmp3dec_init (drmp3dec *dec)
 
int drmp3dec_decode_frame (drmp3dec *dec, const unsigned char *mp3, int mp3_bytes, void *pcm, drmp3dec_frame_info *info)
 
void drmp3dec_f32_to_s16 (const float *in, drmp3_int16 *out, int num_samples)
 
drmp3_bool32 drmp3_init (drmp3 *pMP3, drmp3_read_proc onRead, drmp3_seek_proc onSeek, void *pUserData, const drmp3_config *pConfig)
 
drmp3_bool32 drmp3_init_memory (drmp3 *pMP3, const void *pData, size_t dataSize, const drmp3_config *pConfig)
 
drmp3_bool32 drmp3_init_file (drmp3 *pMP3, const char *filePath, const drmp3_config *pConfig)
 
void drmp3_uninit (drmp3 *pMP3)
 
drmp3_uint64 drmp3_read_pcm_frames_f32 (drmp3 *pMP3, drmp3_uint64 framesToRead, float *pBufferOut)
 
drmp3_uint64 drmp3_read_pcm_frames_s16 (drmp3 *pMP3, drmp3_uint64 framesToRead, drmp3_int16 *pBufferOut)
 
drmp3_bool32 drmp3_seek_to_pcm_frame (drmp3 *pMP3, drmp3_uint64 frameIndex)
 
drmp3_uint64 drmp3_get_pcm_frame_count (drmp3 *pMP3)
 
drmp3_uint64 drmp3_get_mp3_frame_count (drmp3 *pMP3)
 
drmp3_bool32 drmp3_get_mp3_and_pcm_frame_count (drmp3 *pMP3, drmp3_uint64 *pMP3FrameCount, drmp3_uint64 *pPCMFrameCount)
 
drmp3_bool32 drmp3_calculate_seek_points (drmp3 *pMP3, drmp3_uint32 *pSeekPointCount, drmp3_seek_point *pSeekPoints)
 
drmp3_bool32 drmp3_bind_seek_table (drmp3 *pMP3, drmp3_uint32 seekPointCount, drmp3_seek_point *pSeekPoints)
 
float * drmp3_open_and_read_f32 (drmp3_read_proc onRead, drmp3_seek_proc onSeek, void *pUserData, drmp3_config *pConfig, drmp3_uint64 *pTotalFrameCount)
 
drmp3_int16drmp3_open_and_read_s16 (drmp3_read_proc onRead, drmp3_seek_proc onSeek, void *pUserData, drmp3_config *pConfig, drmp3_uint64 *pTotalFrameCount)
 
float * drmp3_open_memory_and_read_f32 (const void *pData, size_t dataSize, drmp3_config *pConfig, drmp3_uint64 *pTotalFrameCount)
 
drmp3_int16drmp3_open_memory_and_read_s16 (const void *pData, size_t dataSize, drmp3_config *pConfig, drmp3_uint64 *pTotalFrameCount)
 
float * drmp3_open_file_and_read_f32 (const char *filePath, drmp3_config *pConfig, drmp3_uint64 *pTotalFrameCount)
 
drmp3_int16drmp3_open_file_and_read_s16 (const char *filePath, drmp3_config *pConfig, drmp3_uint64 *pTotalFrameCount)
 
void drmp3_free (void *p)
 

Macro Definition Documentation

◆ DR_MP3_DEFAULT_CHANNELS

#define DR_MP3_DEFAULT_CHANNELS   2

Definition at line 139 of file dr_mp3.h.

◆ DR_MP3_DEFAULT_SAMPLE_RATE

#define DR_MP3_DEFAULT_SAMPLE_RATE   44100

Definition at line 142 of file dr_mp3.h.

◆ DRMP3_FALSE

#define DRMP3_FALSE   0

Definition at line 92 of file dr_mp3.h.

◆ DRMP3_INLINE

#define DRMP3_INLINE

Definition at line 103 of file dr_mp3.h.

◆ DRMP3_MAX_PCM_FRAMES_PER_MP3_FRAME

#define DRMP3_MAX_PCM_FRAMES_PER_MP3_FRAME   1152

Definition at line 94 of file dr_mp3.h.

◆ DRMP3_MAX_SAMPLES_PER_FRAME

#define DRMP3_MAX_SAMPLES_PER_FRAME   (DRMP3_MAX_PCM_FRAMES_PER_MP3_FRAME*2)

Definition at line 95 of file dr_mp3.h.

◆ DRMP3_SRC_CACHE_SIZE_IN_FRAMES

#define DRMP3_SRC_CACHE_SIZE_IN_FRAMES   512

Definition at line 154 of file dr_mp3.h.

◆ DRMP3_TRUE

#define DRMP3_TRUE   1

Definition at line 91 of file dr_mp3.h.

Typedef Documentation

◆ drmp3_bool32

Definition at line 90 of file dr_mp3.h.

◆ drmp3_bool8

Definition at line 89 of file dr_mp3.h.

◆ drmp3_int16

typedef int16_t drmp3_int16

Definition at line 82 of file dr_mp3.h.

◆ drmp3_int32

typedef int32_t drmp3_int32

Definition at line 84 of file dr_mp3.h.

◆ drmp3_int64

typedef int64_t drmp3_int64

Definition at line 86 of file dr_mp3.h.

◆ drmp3_int8

typedef int8_t drmp3_int8

Definition at line 80 of file dr_mp3.h.

◆ drmp3_read_proc

typedef size_t(* drmp3_read_proc) (void *pUserData, void *pBufferOut, size_t bytesToRead)

Definition at line 216 of file dr_mp3.h.

◆ drmp3_seek_proc

typedef drmp3_bool32(* drmp3_seek_proc) (void *pUserData, int offset, drmp3_seek_origin origin)

Definition at line 230 of file dr_mp3.h.

◆ drmp3_src

typedef struct drmp3_src drmp3_src

Definition at line 145 of file dr_mp3.h.

◆ drmp3_src_read_proc

typedef drmp3_uint64(* drmp3_src_read_proc) (drmp3_src *pSRC, drmp3_uint64 frameCount, void *pFramesOut, void *pUserData)

Definition at line 146 of file dr_mp3.h.

◆ drmp3_uint16

typedef uint16_t drmp3_uint16

Definition at line 83 of file dr_mp3.h.

◆ drmp3_uint32

typedef uint32_t drmp3_uint32

Definition at line 85 of file dr_mp3.h.

◆ drmp3_uint64

typedef uint64_t drmp3_uint64

Definition at line 87 of file dr_mp3.h.

◆ drmp3_uint8

typedef uint8_t drmp3_uint8

Definition at line 81 of file dr_mp3.h.

Enumeration Type Documentation

◆ drmp3_seek_origin

Enumerator
drmp3_seek_origin_start 
drmp3_seek_origin_current 

Definition at line 190 of file dr_mp3.h.

◆ drmp3_src_algorithm

Enumerator
drmp3_src_algorithm_none 
drmp3_src_algorithm_linear 

Definition at line 148 of file dr_mp3.h.

Function Documentation

◆ drmp3_bind_seek_table()

drmp3_bool32 drmp3_bind_seek_table ( drmp3 pMP3,
drmp3_uint32  seekPointCount,
drmp3_seek_point pSeekPoints 
)

◆ drmp3_calculate_seek_points()

drmp3_bool32 drmp3_calculate_seek_points ( drmp3 pMP3,
drmp3_uint32 pSeekPointCount,
drmp3_seek_point pSeekPoints 
)

◆ drmp3_free()

void drmp3_free ( void p)

◆ drmp3_get_mp3_and_pcm_frame_count()

drmp3_bool32 drmp3_get_mp3_and_pcm_frame_count ( drmp3 pMP3,
drmp3_uint64 pMP3FrameCount,
drmp3_uint64 pPCMFrameCount 
)

◆ drmp3_get_mp3_frame_count()

drmp3_uint64 drmp3_get_mp3_frame_count ( drmp3 pMP3)

◆ drmp3_get_pcm_frame_count()

drmp3_uint64 drmp3_get_pcm_frame_count ( drmp3 pMP3)

◆ drmp3_init()

drmp3_bool32 drmp3_init ( drmp3 pMP3,
drmp3_read_proc  onRead,
drmp3_seek_proc  onSeek,
void pUserData,
const drmp3_config pConfig 
)

◆ drmp3_init_file()

drmp3_bool32 drmp3_init_file ( drmp3 pMP3,
const char *  filePath,
const drmp3_config pConfig 
)

◆ drmp3_init_memory()

drmp3_bool32 drmp3_init_memory ( drmp3 pMP3,
const void pData,
size_t  dataSize,
const drmp3_config pConfig 
)

◆ drmp3_open_and_read_f32()

float* drmp3_open_and_read_f32 ( drmp3_read_proc  onRead,
drmp3_seek_proc  onSeek,
void pUserData,
drmp3_config pConfig,
drmp3_uint64 pTotalFrameCount 
)

◆ drmp3_open_and_read_s16()

drmp3_int16* drmp3_open_and_read_s16 ( drmp3_read_proc  onRead,
drmp3_seek_proc  onSeek,
void pUserData,
drmp3_config pConfig,
drmp3_uint64 pTotalFrameCount 
)

◆ drmp3_open_file_and_read_f32()

float* drmp3_open_file_and_read_f32 ( const char *  filePath,
drmp3_config pConfig,
drmp3_uint64 pTotalFrameCount 
)

◆ drmp3_open_file_and_read_s16()

drmp3_int16* drmp3_open_file_and_read_s16 ( const char *  filePath,
drmp3_config pConfig,
drmp3_uint64 pTotalFrameCount 
)

◆ drmp3_open_memory_and_read_f32()

float* drmp3_open_memory_and_read_f32 ( const void pData,
size_t  dataSize,
drmp3_config pConfig,
drmp3_uint64 pTotalFrameCount 
)

◆ drmp3_open_memory_and_read_s16()

drmp3_int16* drmp3_open_memory_and_read_s16 ( const void pData,
size_t  dataSize,
drmp3_config pConfig,
drmp3_uint64 pTotalFrameCount 
)

◆ drmp3_read_pcm_frames_f32()

drmp3_uint64 drmp3_read_pcm_frames_f32 ( drmp3 pMP3,
drmp3_uint64  framesToRead,
float *  pBufferOut 
)

◆ drmp3_read_pcm_frames_s16()

drmp3_uint64 drmp3_read_pcm_frames_s16 ( drmp3 pMP3,
drmp3_uint64  framesToRead,
drmp3_int16 pBufferOut 
)

◆ drmp3_seek_to_pcm_frame()

drmp3_bool32 drmp3_seek_to_pcm_frame ( drmp3 pMP3,
drmp3_uint64  frameIndex 
)

◆ drmp3_uninit()

void drmp3_uninit ( drmp3 pMP3)

◆ drmp3dec_decode_frame()

int drmp3dec_decode_frame ( drmp3dec dec,
const unsigned char *  mp3,
int  mp3_bytes,
void pcm,
drmp3dec_frame_info info 
)

◆ drmp3dec_f32_to_s16()

void drmp3dec_f32_to_s16 ( const float *  in,
drmp3_int16 out,
int  num_samples 
)

◆ drmp3dec_init()

void drmp3dec_init ( drmp3dec dec)
drmp3_src_algorithm
drmp3_src_algorithm
Definition: dr_mp3.h:148
drmp3_seek_origin_current
@ drmp3_seek_origin_current
Definition: dr_mp3.h:193
drmp3_seek_origin_start
@ drmp3_seek_origin_start
Definition: dr_mp3.h:192
drmp3_src_algorithm_none
@ drmp3_src_algorithm_none
Definition: dr_mp3.h:150
drmp3_seek_origin
drmp3_seek_origin
Definition: dr_mp3.h:190
drmp3_src_algorithm_linear
@ drmp3_src_algorithm_linear
Definition: dr_mp3.h:151