LMMS
Loading...
Searching...
No Matches
minimp3_ex.h File Reference
#include "minimp3.h"
#include <limits.h>
#include <stdio.h>

Go to the source code of this file.

Classes

struct  mp3dec_file_info_t
struct  mp3dec_map_info_t
struct  mp3dec_frame_t
struct  mp3dec_index_t
struct  mp3dec_io_t
struct  mp3dec_ex_t

Macros

#define MP3D_SEEK_TO_BYTE   0 /* mp3dec_ex_seek seeks to byte in stream */
#define MP3D_SEEK_TO_SAMPLE   1 /* mp3dec_ex_seek precisely seeks to sample using index (created during duration calculation scan or when mp3dec_ex_seek called) */
#define MP3D_DO_NOT_SCAN   2 /* do not scan whole stream for duration if vbrtag not found, mp3dec_ex_t::samples will be filled only if mp3dec_ex_t::vbr_tag_found == 1 */
#define MINIMP3_PREDECODE_FRAMES   2 /* frames to pre-decode and skip after seek (to fill internal structures) */
#define MINIMP3_IO_SIZE   (128*1024) /* io buffer size for streaming functions, must be greater than MINIMP3_BUF_SIZE */
#define MINIMP3_BUF_SIZE   (16*1024) /* buffer which can hold minimum 10 consecutive mp3 frames (~16KB) worst case */
#define MINIMP3_ENABLE_RING   0 /* WIP enable hardware magic ring buffer if available, to make less input buffer memmove(s) in callback IO mode */
#define MP3D_E_PARAM   -1
#define MP3D_E_MEMORY   -2
#define MP3D_E_IOERROR   -3
#define MP3D_E_USER   -4 /* can be used to stop processing from callbacks without indicating specific error */
#define MP3D_E_DECODE   -5 /* decode error which can't be safely skipped, such as sample rate, layer and channels change */
#define MINIMP3_ID3_DETECT_SIZE   10
#define FRAMES_FLAG   1
#define BYTES_FLAG   2
#define TOC_FLAG   4
#define VBR_SCALE_FLAG   8

Typedefs

typedef size_t(* MP3D_READ_CB) (void *buf, size_t size, void *user_data)
typedef int(* MP3D_SEEK_CB) (uint64_t position, void *user_data)
typedef int(* MP3D_ITERATE_CB) (void *user_data, const uint8_t *frame, int frame_size, int free_format_bytes, size_t buf_size, uint64_t offset, mp3dec_frame_info_t *info)
typedef int(* MP3D_PROGRESS_CB) (void *user_data, size_t file_size, uint64_t offset, mp3dec_frame_info_t *info)

Functions

int mp3dec_detect_buf (const uint8_t *buf, size_t buf_size)
int mp3dec_detect_cb (mp3dec_io_t *io, uint8_t *buf, size_t buf_size)
int mp3dec_load_buf (mp3dec_t *dec, const uint8_t *buf, size_t buf_size, mp3dec_file_info_t *info, MP3D_PROGRESS_CB progress_cb, void *user_data)
int mp3dec_load_cb (mp3dec_t *dec, mp3dec_io_t *io, uint8_t *buf, size_t buf_size, mp3dec_file_info_t *info, MP3D_PROGRESS_CB progress_cb, void *user_data)
int mp3dec_iterate_buf (const uint8_t *buf, size_t buf_size, MP3D_ITERATE_CB callback, void *user_data)
int mp3dec_iterate_cb (mp3dec_io_t *io, uint8_t *buf, size_t buf_size, MP3D_ITERATE_CB callback, void *user_data)
int mp3dec_ex_open_buf (mp3dec_ex_t *dec, const uint8_t *buf, size_t buf_size, int flags)
int mp3dec_ex_open_cb (mp3dec_ex_t *dec, mp3dec_io_t *io, int flags)
void mp3dec_ex_close (mp3dec_ex_t *dec)
int mp3dec_ex_seek (mp3dec_ex_t *dec, uint64_t position)
size_t mp3dec_ex_read (mp3dec_ex_t *dec, mp3d_sample_t *buf, size_t samples)
int mp3dec_detect (const char *file_name)
int mp3dec_load (mp3dec_t *dec, const char *file_name, mp3dec_file_info_t *info, MP3D_PROGRESS_CB progress_cb, void *user_data)
int mp3dec_iterate (const char *file_name, MP3D_ITERATE_CB callback, void *user_data)
int mp3dec_ex_open (mp3dec_ex_t *dec, const char *file_name, int flags)
static void mp3dec_skip_id3v1 (const uint8_t *buf, size_t *pbuf_size)
static size_t mp3dec_skip_id3v2 (const uint8_t *buf, size_t buf_size)
static void mp3dec_skip_id3 (const uint8_t **pbuf, size_t *pbuf_size)
static int mp3dec_check_vbrtag (const uint8_t *frame, int frame_size, uint32_t *frames, int *delay, int *padding)
static int mp3dec_load_index (void *user_data, const uint8_t *frame, int frame_size, int free_format_bytes, size_t buf_size, uint64_t offset, mp3dec_frame_info_t *info)
static size_t mp3dec_idx_binary_search (mp3dec_index_t *idx, uint64_t position)
static void mp3dec_close_file (mp3dec_map_info_t *map_info)
static int mp3dec_open_file (const char *file_name, mp3dec_map_info_t *map_info)
static int mp3dec_detect_mapinfo (mp3dec_map_info_t *map_info)
static int mp3dec_load_mapinfo (mp3dec_t *dec, mp3dec_map_info_t *map_info, mp3dec_file_info_t *info, MP3D_PROGRESS_CB progress_cb, void *user_data)
static int mp3dec_iterate_mapinfo (mp3dec_map_info_t *map_info, MP3D_ITERATE_CB callback, void *user_data)
static int mp3dec_ex_open_mapinfo (mp3dec_ex_t *dec, int flags)

Macro Definition Documentation

◆ BYTES_FLAG

#define BYTES_FLAG   2

◆ FRAMES_FLAG

#define FRAMES_FLAG   1

◆ MINIMP3_BUF_SIZE

#define MINIMP3_BUF_SIZE   (16*1024) /* buffer which can hold minimum 10 consecutive mp3 frames (~16KB) worst case */

◆ MINIMP3_ENABLE_RING

#define MINIMP3_ENABLE_RING   0 /* WIP enable hardware magic ring buffer if available, to make less input buffer memmove(s) in callback IO mode */

◆ MINIMP3_ID3_DETECT_SIZE

#define MINIMP3_ID3_DETECT_SIZE   10

◆ MINIMP3_IO_SIZE

#define MINIMP3_IO_SIZE   (128*1024) /* io buffer size for streaming functions, must be greater than MINIMP3_BUF_SIZE */

◆ MINIMP3_PREDECODE_FRAMES

#define MINIMP3_PREDECODE_FRAMES   2 /* frames to pre-decode and skip after seek (to fill internal structures) */

◆ MP3D_DO_NOT_SCAN

#define MP3D_DO_NOT_SCAN   2 /* do not scan whole stream for duration if vbrtag not found, mp3dec_ex_t::samples will be filled only if mp3dec_ex_t::vbr_tag_found == 1 */

◆ MP3D_E_DECODE

#define MP3D_E_DECODE   -5 /* decode error which can't be safely skipped, such as sample rate, layer and channels change */

◆ MP3D_E_IOERROR

#define MP3D_E_IOERROR   -3

◆ MP3D_E_MEMORY

#define MP3D_E_MEMORY   -2

◆ MP3D_E_PARAM

#define MP3D_E_PARAM   -1

◆ MP3D_E_USER

#define MP3D_E_USER   -4 /* can be used to stop processing from callbacks without indicating specific error */

◆ MP3D_SEEK_TO_BYTE

#define MP3D_SEEK_TO_BYTE   0 /* mp3dec_ex_seek seeks to byte in stream */

◆ MP3D_SEEK_TO_SAMPLE

#define MP3D_SEEK_TO_SAMPLE   1 /* mp3dec_ex_seek precisely seeks to sample using index (created during duration calculation scan or when mp3dec_ex_seek called) */

◆ TOC_FLAG

#define TOC_FLAG   4

◆ VBR_SCALE_FLAG

#define VBR_SCALE_FLAG   8

Typedef Documentation

◆ MP3D_ITERATE_CB

typedef int(* MP3D_ITERATE_CB) (void *user_data, const uint8_t *frame, int frame_size, int free_format_bytes, size_t buf_size, uint64_t offset, mp3dec_frame_info_t *info)

◆ MP3D_PROGRESS_CB

typedef int(* MP3D_PROGRESS_CB) (void *user_data, size_t file_size, uint64_t offset, mp3dec_frame_info_t *info)

◆ MP3D_READ_CB

typedef size_t(* MP3D_READ_CB) (void *buf, size_t size, void *user_data)

◆ MP3D_SEEK_CB

typedef int(* MP3D_SEEK_CB) (uint64_t position, void *user_data)

Function Documentation

◆ mp3dec_check_vbrtag()

int mp3dec_check_vbrtag ( const uint8_t * frame,
int frame_size,
uint32_t * frames,
int * delay,
int * padding )
static

◆ mp3dec_close_file()

void mp3dec_close_file ( mp3dec_map_info_t * map_info)
static

◆ mp3dec_detect()

int mp3dec_detect ( const char * file_name)

◆ mp3dec_detect_buf()

int mp3dec_detect_buf ( const uint8_t * buf,
size_t buf_size )

◆ mp3dec_detect_cb()

int mp3dec_detect_cb ( mp3dec_io_t * io,
uint8_t * buf,
size_t buf_size )

◆ mp3dec_detect_mapinfo()

int mp3dec_detect_mapinfo ( mp3dec_map_info_t * map_info)
static

◆ mp3dec_ex_close()

void mp3dec_ex_close ( mp3dec_ex_t * dec)

◆ mp3dec_ex_open()

int mp3dec_ex_open ( mp3dec_ex_t * dec,
const char * file_name,
int flags )

◆ mp3dec_ex_open_buf()

int mp3dec_ex_open_buf ( mp3dec_ex_t * dec,
const uint8_t * buf,
size_t buf_size,
int flags )

◆ mp3dec_ex_open_cb()

int mp3dec_ex_open_cb ( mp3dec_ex_t * dec,
mp3dec_io_t * io,
int flags )

◆ mp3dec_ex_open_mapinfo()

int mp3dec_ex_open_mapinfo ( mp3dec_ex_t * dec,
int flags )
static

◆ mp3dec_ex_read()

size_t mp3dec_ex_read ( mp3dec_ex_t * dec,
mp3d_sample_t * buf,
size_t samples )

◆ mp3dec_ex_seek()

int mp3dec_ex_seek ( mp3dec_ex_t * dec,
uint64_t position )

◆ mp3dec_idx_binary_search()

size_t mp3dec_idx_binary_search ( mp3dec_index_t * idx,
uint64_t position )
static

◆ mp3dec_iterate()

int mp3dec_iterate ( const char * file_name,
MP3D_ITERATE_CB callback,
void * user_data )

◆ mp3dec_iterate_buf()

int mp3dec_iterate_buf ( const uint8_t * buf,
size_t buf_size,
MP3D_ITERATE_CB callback,
void * user_data )

◆ mp3dec_iterate_cb()

int mp3dec_iterate_cb ( mp3dec_io_t * io,
uint8_t * buf,
size_t buf_size,
MP3D_ITERATE_CB callback,
void * user_data )

◆ mp3dec_iterate_mapinfo()

int mp3dec_iterate_mapinfo ( mp3dec_map_info_t * map_info,
MP3D_ITERATE_CB callback,
void * user_data )
static

◆ mp3dec_load()

int mp3dec_load ( mp3dec_t * dec,
const char * file_name,
mp3dec_file_info_t * info,
MP3D_PROGRESS_CB progress_cb,
void * user_data )

◆ mp3dec_load_buf()

int mp3dec_load_buf ( mp3dec_t * dec,
const uint8_t * buf,
size_t buf_size,
mp3dec_file_info_t * info,
MP3D_PROGRESS_CB progress_cb,
void * user_data )

◆ mp3dec_load_cb()

int mp3dec_load_cb ( mp3dec_t * dec,
mp3dec_io_t * io,
uint8_t * buf,
size_t buf_size,
mp3dec_file_info_t * info,
MP3D_PROGRESS_CB progress_cb,
void * user_data )

◆ mp3dec_load_index()

int mp3dec_load_index ( void * user_data,
const uint8_t * frame,
int frame_size,
int free_format_bytes,
size_t buf_size,
uint64_t offset,
mp3dec_frame_info_t * info )
static

◆ mp3dec_load_mapinfo()

int mp3dec_load_mapinfo ( mp3dec_t * dec,
mp3dec_map_info_t * map_info,
mp3dec_file_info_t * info,
MP3D_PROGRESS_CB progress_cb,
void * user_data )
static

◆ mp3dec_open_file()

int mp3dec_open_file ( const char * file_name,
mp3dec_map_info_t * map_info )
static

◆ mp3dec_skip_id3()

void mp3dec_skip_id3 ( const uint8_t ** pbuf,
size_t * pbuf_size )
static

◆ mp3dec_skip_id3v1()

void mp3dec_skip_id3v1 ( const uint8_t * buf,
size_t * pbuf_size )
static

◆ mp3dec_skip_id3v2()

size_t mp3dec_skip_id3v2 ( const uint8_t * buf,
size_t buf_size )
static