mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-27 03:50:29 +00:00
Add codec specific handlers for byterate.
This commit is contained in:
parent
1db0bad655
commit
19d01b5fde
@ -11,6 +11,9 @@
|
||||
* src/sndfile.h.in src/sndfile.c src/common.h src/create_symbols_file.py
|
||||
Add API function sf_current_byterate().
|
||||
|
||||
* src/dwvw.c src/flac.c src/ogg_vorbis.c src/sds.c
|
||||
Add codec specific handlers for current byterate.
|
||||
|
||||
2012-02-24 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* src/common.[ch]
|
||||
|
12
src/dwvw.c
12
src/dwvw.c
@ -61,7 +61,8 @@ static sf_count_t dwvw_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t le
|
||||
static sf_count_t dwvw_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ;
|
||||
|
||||
static sf_count_t dwvw_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ;
|
||||
static int dwvw_close (SF_PRIVATE *psf) ;
|
||||
static int dwvw_close (SF_PRIVATE *psf) ;
|
||||
static int dwvw_byterate (SF_PRIVATE *psf) ;
|
||||
|
||||
static int dwvw_decode_data (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, int *ptr, int len) ;
|
||||
static int dwvw_decode_load_bits (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, int bit_count) ;
|
||||
@ -112,6 +113,7 @@ dwvw_init (SF_PRIVATE *psf, int bitwidth)
|
||||
|
||||
psf->codec_close = dwvw_close ;
|
||||
psf->seek = dwvw_seek ;
|
||||
psf->byterate = dwvw_byterate ;
|
||||
|
||||
if (psf->file.mode == SFM_READ)
|
||||
{ psf->sf.frames = psf_decode_frame_count (psf) ;
|
||||
@ -169,6 +171,14 @@ dwvw_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset)
|
||||
return PSF_SEEK_ERROR ;
|
||||
} /* dwvw_seek */
|
||||
|
||||
static int
|
||||
dwvw_byterate (SF_PRIVATE *psf)
|
||||
{
|
||||
if (psf->file.mode == SFM_READ)
|
||||
return (psf->datalength * psf->sf.samplerate) / psf->sf.frames ;
|
||||
|
||||
return -1 ;
|
||||
} /* dwvw_byterate */
|
||||
|
||||
/*==============================================================================
|
||||
*/
|
||||
|
13
src/flac.c
13
src/flac.c
@ -75,6 +75,7 @@ typedef struct
|
||||
} FLAC_TAG ;
|
||||
|
||||
static sf_count_t flac_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ;
|
||||
static int flac_byterate (SF_PRIVATE *psf) ;
|
||||
static int flac_close (SF_PRIVATE *psf) ;
|
||||
|
||||
static int flac_enc_init (SF_PRIVATE *psf) ;
|
||||
@ -659,6 +660,8 @@ flac_open (SF_PRIVATE *psf)
|
||||
|
||||
psf->container_close = flac_close ;
|
||||
psf->seek = flac_seek ;
|
||||
psf->byterate = flac_byterate ;
|
||||
|
||||
psf->command = flac_command ;
|
||||
|
||||
switch (subformat)
|
||||
@ -1304,6 +1307,16 @@ flac_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset)
|
||||
return ((sf_count_t) -1) ;
|
||||
} /* flac_seek */
|
||||
|
||||
static int
|
||||
flac_byterate (SF_PRIVATE *psf)
|
||||
{
|
||||
if (psf->file.mode == SFM_READ)
|
||||
return (psf->datalength * psf->sf.samplerate) / psf->sf.frames ;
|
||||
|
||||
return -1 ;
|
||||
} /* flac_byterate */
|
||||
|
||||
|
||||
#else /* HAVE_EXTERNAL_LIBS */
|
||||
|
||||
int
|
||||
|
@ -82,6 +82,7 @@ static int vorbis_read_header (SF_PRIVATE *psf, int log_data) ;
|
||||
static int vorbis_write_header (SF_PRIVATE *psf, int calc_length) ;
|
||||
static int vorbis_close (SF_PRIVATE *psf) ;
|
||||
static int vorbis_command (SF_PRIVATE *psf, int command, void *data, int datasize) ;
|
||||
static int vorbis_byterate (SF_PRIVATE *psf) ;
|
||||
static sf_count_t vorbis_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ;
|
||||
static sf_count_t vorbis_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
|
||||
static sf_count_t vorbis_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
|
||||
@ -530,6 +531,7 @@ ogg_vorbis_open (SF_PRIVATE *psf)
|
||||
|
||||
psf->seek = vorbis_seek ;
|
||||
psf->command = vorbis_command ;
|
||||
psf->byterate = vorbis_byterate ;
|
||||
|
||||
/* FIXME, FIXME, FIXME : Hack these here for now and correct later. */
|
||||
psf->sf.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ;
|
||||
@ -873,6 +875,16 @@ vorbis_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset)
|
||||
return 0 ;
|
||||
} /* vorbis_seek */
|
||||
|
||||
|
||||
static int
|
||||
vorbis_byterate (SF_PRIVATE *psf)
|
||||
{
|
||||
if (psf->file.mode == SFM_READ)
|
||||
return (psf->datalength * psf->sf.samplerate) / psf->sf.frames ;
|
||||
|
||||
return -1 ;
|
||||
} /* vorbis_byterate */
|
||||
|
||||
/*==============================================================================
|
||||
** Most of the following code was snipped from Mike Smith's ogginfo utility
|
||||
** which is part of vorbis-tools.
|
||||
|
13
src/sds.c
13
src/sds.c
@ -83,6 +83,7 @@ static sf_count_t sds_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len
|
||||
static sf_count_t sds_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ;
|
||||
|
||||
static sf_count_t sds_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ;
|
||||
static int sds_byterate (SF_PRIVATE * psf) ;
|
||||
|
||||
static int sds_2byte_read (SF_PRIVATE *psf, SDS_PRIVATE *psds) ;
|
||||
static int sds_3byte_read (SF_PRIVATE *psf, SDS_PRIVATE *psds) ;
|
||||
@ -132,8 +133,9 @@ sds_open (SF_PRIVATE *psf)
|
||||
if ((error = sds_init (psf, psds)) != 0)
|
||||
return error ;
|
||||
|
||||
psf->seek = sds_seek ;
|
||||
psf->container_close = sds_close ;
|
||||
psf->seek = sds_seek ;
|
||||
psf->byterate = sds_byterate ;
|
||||
|
||||
psf->blockwidth = 0 ;
|
||||
|
||||
@ -752,6 +754,15 @@ sds_seek (SF_PRIVATE *psf, int mode, sf_count_t seek_from_start)
|
||||
return seek_from_start ;
|
||||
} /* sds_seek */
|
||||
|
||||
static int
|
||||
sds_byterate (SF_PRIVATE * psf)
|
||||
{
|
||||
if (psf->file.mode == SFM_READ)
|
||||
return (psf->datalength * psf->sf.samplerate) / psf->sf.frames ;
|
||||
|
||||
return -1 ;
|
||||
} /* sds_byterate */
|
||||
|
||||
/*==============================================================================
|
||||
*/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user