mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-12-03 16:21:48 +00:00
Rename mp3 -> mpeg (file sources and function names)
This commit is contained in:
parent
dae19b9502
commit
163f725631
@ -302,7 +302,7 @@ add_library (sndfile
|
|||||||
src/ogg_vcomment.h
|
src/ogg_vcomment.h
|
||||||
src/ogg_vcomment.c
|
src/ogg_vcomment.c
|
||||||
src/nms_adpcm.c
|
src/nms_adpcm.c
|
||||||
src/mp3.c
|
src/mpeg.c
|
||||||
src/mpeg_decode.c
|
src/mpeg_decode.c
|
||||||
src/mpeg_l3_encode.c
|
src/mpeg_l3_encode.c
|
||||||
src/GSM610/config.h
|
src/GSM610/config.h
|
||||||
@ -1208,8 +1208,8 @@ if (BUILD_TESTING)
|
|||||||
$<$<BOOL:${LIBM_REQUIRED}>:m>
|
$<$<BOOL:${LIBM_REQUIRED}>:m>
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable (mp3_test tests/mp3_test.c)
|
add_executable (mpeg_test tests/mpeg_test.c)
|
||||||
target_link_libraries (mp3_test
|
target_link_libraries (mpeg_test
|
||||||
PRIVATE
|
PRIVATE
|
||||||
sndfile
|
sndfile
|
||||||
test_utils
|
test_utils
|
||||||
@ -1447,8 +1447,8 @@ if (BUILD_TESTING)
|
|||||||
add_test (lossy_comp_test_ogg_opus lossy_comp_test ogg_opus)
|
add_test (lossy_comp_test_ogg_opus lossy_comp_test ogg_opus)
|
||||||
add_test (string_test_opus string_test opus)
|
add_test (string_test_opus string_test opus)
|
||||||
|
|
||||||
### mp3-tests ###
|
### mpeg-tests ###
|
||||||
add_test (mp3_test mp3_test)
|
add_test (mpeg_test mpeg_test)
|
||||||
add_test (compression_size_test_mpeg compression_size_test mpeg)
|
add_test (compression_size_test_mpeg compression_size_test mpeg)
|
||||||
|
|
||||||
### io-tests
|
### io-tests
|
||||||
|
@ -69,7 +69,7 @@ src_libsndfile_la_SOURCES = src/sndfile.c src/aiff.c src/au.c src/avr.c src/caf.
|
|||||||
src/macos.c src/mat4.c src/mat5.c src/nist.c src/paf.c src/pvf.c src/raw.c src/rx2.c src/sd2.c \
|
src/macos.c src/mat4.c src/mat5.c src/nist.c src/paf.c src/pvf.c src/raw.c src/rx2.c src/sd2.c \
|
||||||
src/sds.c src/svx.c src/txw.c src/voc.c src/wve.c src/w64.c src/wavlike.c src/wav.c src/xi.c src/mpc2k.c src/rf64.c \
|
src/sds.c src/svx.c src/txw.c src/voc.c src/wve.c src/w64.c src/wavlike.c src/wav.c src/xi.c src/mpc2k.c src/rf64.c \
|
||||||
src/ogg.c src/ogg.h src/ogg_vorbis.c src/ogg_speex.c src/ogg_pcm.c src/ogg_opus.c src/ogg_vcomment.c src/ogg_vcomment.h \
|
src/ogg.c src/ogg.h src/ogg_vorbis.c src/ogg_speex.c src/ogg_pcm.c src/ogg_opus.c src/ogg_vcomment.c src/ogg_vcomment.h \
|
||||||
src/common.h src/sfconfig.h src/sfendian.h src/wavlike.h src/sf_unistd.h src/chanmap.h src/mp3.c
|
src/common.h src/sfconfig.h src/sfendian.h src/wavlike.h src/sf_unistd.h src/chanmap.h src/mpeg.c
|
||||||
nodist_src_libsndfile_la_SOURCES = $(nodist_include_HEADERS)
|
nodist_src_libsndfile_la_SOURCES = $(nodist_include_HEADERS)
|
||||||
src_libsndfile_la_LIBADD = src/GSM610/libgsm.la src/G72x/libg72x.la src/ALAC/libalac.la \
|
src_libsndfile_la_LIBADD = src/GSM610/libgsm.la src/G72x/libg72x.la src/ALAC/libalac.la \
|
||||||
src/libcommon.la $(EXTERNAL_XIPH_LIBS) -lm $(MPEG_LIBS)
|
src/libcommon.la $(EXTERNAL_XIPH_LIBS) -lm $(MPEG_LIBS)
|
||||||
@ -222,7 +222,7 @@ check_PROGRAMS += tests/sfversion tests/floating_point_test tests/write_read_tes
|
|||||||
tests/checksum_test tests/external_libs_test tests/rdwr_test tests/format_check_test $(CPP_TEST) \
|
tests/checksum_test tests/external_libs_test tests/rdwr_test tests/format_check_test $(CPP_TEST) \
|
||||||
tests/channel_test tests/long_read_write_test tests/stdin_test tests/stdout_test \
|
tests/channel_test tests/long_read_write_test tests/stdin_test tests/stdout_test \
|
||||||
tests/dither_test tests/fix_this tests/largefile_test tests/benchmark tests/ogg_opus_test \
|
tests/dither_test tests/fix_this tests/largefile_test tests/benchmark tests/ogg_opus_test \
|
||||||
tests/mp3_test
|
tests/mpeg_test
|
||||||
|
|
||||||
BUILT_SOURCES += \
|
BUILT_SOURCES += \
|
||||||
tests/write_read_test.c \
|
tests/write_read_test.c \
|
||||||
@ -378,8 +378,8 @@ tests_cpp_test_LDADD = src/libsndfile.la
|
|||||||
tests_checksum_test_SOURCES = tests/checksum_test.c tests/utils.c tests/utils.h
|
tests_checksum_test_SOURCES = tests/checksum_test.c tests/utils.c tests/utils.h
|
||||||
tests_checksum_test_LDADD = src/libsndfile.la
|
tests_checksum_test_LDADD = src/libsndfile.la
|
||||||
|
|
||||||
tests_mp3_test_SOURCES = tests/mp3_test.c tests/utils.c tests/utils.h
|
tests_mpeg_test_SOURCES = tests/mpeg_test.c tests/utils.c tests/utils.h
|
||||||
tests_mp3_test_LDADD = src/libsndfile.la
|
tests_mpeg_test_LDADD = src/libsndfile.la
|
||||||
|
|
||||||
# Lite remove start
|
# Lite remove start
|
||||||
tests_dwvw_test_SOURCES = tests/dwvw_test.c tests/utils.c tests/utils.h
|
tests_dwvw_test_SOURCES = tests/dwvw_test.c tests/utils.c tests/utils.h
|
||||||
|
@ -896,7 +896,7 @@ int ogg_pcm_open (SF_PRIVATE *psf) ;
|
|||||||
int ogg_opus_open (SF_PRIVATE *psf) ;
|
int ogg_opus_open (SF_PRIVATE *psf) ;
|
||||||
int ogg_open (SF_PRIVATE *psf) ;
|
int ogg_open (SF_PRIVATE *psf) ;
|
||||||
|
|
||||||
int mp3_open (SF_PRIVATE *psf) ;
|
int mpeg_open (SF_PRIVATE *psf) ;
|
||||||
|
|
||||||
/* In progress. Do not currently work. */
|
/* In progress. Do not currently work. */
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright (C) 2019 Erik de Castro Lopo <erikd@mega-nerd.com>
|
** Copyright (C) 2019 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||||
** Copyright (C) 2019 Arthur Taylor <art@ified.ca>
|
** Copyright (C) 2021 Arthur Taylor <art@ified.ca>
|
||||||
**
|
**
|
||||||
** This program is free software ; you can redistribute it and/or modify
|
** This program is free software ; you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU Lesser General Public License as published by
|
** it under the terms of the GNU Lesser General Public License as published by
|
||||||
@ -17,47 +17,6 @@
|
|||||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
** What is an MP3 file anyways?
|
|
||||||
**
|
|
||||||
** Believe it or not, MP3 files don't exist.
|
|
||||||
**
|
|
||||||
** The MPEG-1 standard defined a few audio codecs. The standard only defined a
|
|
||||||
** streaming format of semi-independent frames of audio meant for broadcasting,
|
|
||||||
** with no details or hints about stored on-disk formats. Each frame defines
|
|
||||||
** it's own bitrate, channel count, sample rate. However, they aren't
|
|
||||||
** completely independent.
|
|
||||||
**
|
|
||||||
** With its amazing-for-the-time compression ratio, the layer III audio codec
|
|
||||||
** became quite popular with file sharers and the internet. A stream of layer
|
|
||||||
** III audio would simply be written as a file, usually with the extension
|
|
||||||
** .mp3. Over time enthusiast and proprietary encoders sprung up adding
|
|
||||||
** different metadata headers and trailers, file seeking tables, and fiddling
|
|
||||||
** with the codecs parameters. These changes are only really based on consensus.
|
|
||||||
**
|
|
||||||
** MPEG-1 I/II/III audio can be embedded in a few container formats (including
|
|
||||||
** WAV), stored raw, or with additional metadata extension headers and trailers.
|
|
||||||
**
|
|
||||||
** This file is concerned only with the most common case of MPEG Layer III
|
|
||||||
** audio without a container but with the additional metadata standards.
|
|
||||||
**
|
|
||||||
** For the purposes of libsndfile, the major format of SF_FORMAT_MPEG means the
|
|
||||||
** following assumptions. A file of major format type SF_FORMAT_MPEG:
|
|
||||||
** - Contains only layer III audio frames (SF_FORMAT_MPEG_LAYER_III)
|
|
||||||
** - All MPEG frames contained in the file have the same channel count
|
|
||||||
** - All MPEG frames contained in the file have the same samplerate
|
|
||||||
** - Has at least one of:
|
|
||||||
** - an ID3v1 trailer
|
|
||||||
** - an ID3v2 header or trailer
|
|
||||||
** - A Lame/Xing/Info header
|
|
||||||
**
|
|
||||||
** Testing has revealed that, more than any other format, MP3 suffers from
|
|
||||||
** corrupt files in the wild that most other software 'just works' with. This is
|
|
||||||
** usually because the MP3 decoders are very lenient. They are aided by the
|
|
||||||
** presence of a regular sync frame, but this makes it hard to classify them
|
|
||||||
** in a library that consumes other better-specified file formats.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "sfconfig.h"
|
#include "sfconfig.h"
|
||||||
|
|
||||||
#include "sndfile.h"
|
#include "sndfile.h"
|
||||||
@ -67,15 +26,15 @@
|
|||||||
|
|
||||||
#include "mpeg.h"
|
#include "mpeg.h"
|
||||||
|
|
||||||
static int mp3_write_header (SF_PRIVATE *psf, int calc_length) ;
|
static int mpeg_write_header (SF_PRIVATE *psf, int calc_length) ;
|
||||||
static int mp3_command (SF_PRIVATE *psf, int command, void *data, int datasize) ;
|
static int mpeg_command (SF_PRIVATE *psf, int command, void *data, int datasize) ;
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Private functions
|
* Private functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mp3_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
|
mpeg_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
|
||||||
{
|
{
|
||||||
if (psf->have_written)
|
if (psf->have_written)
|
||||||
return 0 ;
|
return 0 ;
|
||||||
@ -84,7 +43,7 @@ mp3_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
|
|||||||
} ;
|
} ;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mp3_command (SF_PRIVATE *psf, int command, void *data, int datasize)
|
mpeg_command (SF_PRIVATE *psf, int command, void *data, int datasize)
|
||||||
{ int bitrate_mode ;
|
{ int bitrate_mode ;
|
||||||
|
|
||||||
switch (command)
|
switch (command)
|
||||||
@ -129,7 +88,7 @@ mp3_command (SF_PRIVATE *psf, int command, void *data, int datasize)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
mp3_open (SF_PRIVATE *psf)
|
mpeg_open (SF_PRIVATE *psf)
|
||||||
{ int error ;
|
{ int error ;
|
||||||
|
|
||||||
if (psf->file.mode == SFM_RDWR)
|
if (psf->file.mode == SFM_RDWR)
|
||||||
@ -147,7 +106,7 @@ mp3_open (SF_PRIVATE *psf)
|
|||||||
|
|
||||||
/* ID3 support */
|
/* ID3 support */
|
||||||
psf->strings.flags = SF_STR_ALLOW_START ;
|
psf->strings.flags = SF_STR_ALLOW_START ;
|
||||||
psf->write_header = mp3_write_header ;
|
psf->write_header = mpeg_write_header ;
|
||||||
psf->datalength = 0 ;
|
psf->datalength = 0 ;
|
||||||
psf->dataoffset = 0 ;
|
psf->dataoffset = 0 ;
|
||||||
} ;
|
} ;
|
||||||
@ -157,7 +116,7 @@ mp3_open (SF_PRIVATE *psf)
|
|||||||
return error ;
|
return error ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
psf->command = mp3_command ;
|
psf->command = mpeg_command ;
|
||||||
|
|
||||||
return 0 ;
|
return 0 ;
|
||||||
} /* mpeg_open */
|
} /* mpeg_open */
|
||||||
@ -165,7 +124,7 @@ mp3_open (SF_PRIVATE *psf)
|
|||||||
#else /* HAVE_MPEG */
|
#else /* HAVE_MPEG */
|
||||||
|
|
||||||
int
|
int
|
||||||
mp3_open (SF_PRIVATE *psf)
|
mpeg_open (SF_PRIVATE *psf)
|
||||||
{
|
{
|
||||||
psf_log_printf (psf, "This version of libsndfile was compiled without MP3 support.\n") ;
|
psf_log_printf (psf, "This version of libsndfile was compiled without MP3 support.\n") ;
|
||||||
return SFE_UNIMPLEMENTED ;
|
return SFE_UNIMPLEMENTED ;
|
@ -2884,7 +2884,7 @@ retry:
|
|||||||
|
|
||||||
/* Guess MP3, try and open it as such. Allows libmpg123 to parse the ID3v2 headers */
|
/* Guess MP3, try and open it as such. Allows libmpg123 to parse the ID3v2 headers */
|
||||||
if (psf->file.mode == SFM_READ)
|
if (psf->file.mode == SFM_READ)
|
||||||
{ if (mp3_open (psf) == 0)
|
{ if (mpeg_open (psf) == 0)
|
||||||
return SF_FORMAT_MPEG | ((~SF_FORMAT_TYPEMASK) & psf->sf.format) ;
|
return SF_FORMAT_MPEG | ((~SF_FORMAT_TYPEMASK) & psf->sf.format) ;
|
||||||
else if (psf->codec_close)
|
else if (psf->codec_close)
|
||||||
psf->codec_close (psf) ;
|
psf->codec_close (psf) ;
|
||||||
@ -3270,7 +3270,7 @@ psf_open_file (SF_PRIVATE *psf, SF_INFO *sfinfo)
|
|||||||
break ;
|
break ;
|
||||||
|
|
||||||
case SF_FORMAT_MPEG :
|
case SF_FORMAT_MPEG :
|
||||||
error = mp3_open (psf) ;
|
error = mpeg_open (psf) ;
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
/* Lite remove end */
|
/* Lite remove end */
|
||||||
|
@ -48,7 +48,7 @@ static BUFFER data_out ;
|
|||||||
static BUFFER data_in ;
|
static BUFFER data_in ;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mp3_short_test (void)
|
mpeg_short_test (void)
|
||||||
{ const char * filename = "mpeg_short.mp3" ;
|
{ const char * filename = "mpeg_short.mp3" ;
|
||||||
|
|
||||||
SNDFILE * file ;
|
SNDFILE * file ;
|
||||||
@ -106,7 +106,7 @@ mp3_short_test (void)
|
|||||||
} /* mpeg_short_test */
|
} /* mpeg_short_test */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mp3_int_test (void)
|
mpeg_int_test (void)
|
||||||
{ const char * filename = "mpeg_int.mp3" ;
|
{ const char * filename = "mpeg_int.mp3" ;
|
||||||
|
|
||||||
SNDFILE * file ;
|
SNDFILE * file ;
|
||||||
@ -161,7 +161,7 @@ mp3_int_test (void)
|
|||||||
} /* mpeg_int_test */
|
} /* mpeg_int_test */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mp3_float_test (void)
|
mpeg_float_test (void)
|
||||||
{ const char * filename = "mpeg_float.mp3" ;
|
{ const char * filename = "mpeg_float.mp3" ;
|
||||||
|
|
||||||
SNDFILE * file ;
|
SNDFILE * file ;
|
||||||
@ -210,7 +210,7 @@ mp3_float_test (void)
|
|||||||
} /* mpeg_float_test */
|
} /* mpeg_float_test */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mp3_double_test (void)
|
mpeg_double_test (void)
|
||||||
{ const char * filename = "mpeg_double.mp3" ;
|
{ const char * filename = "mpeg_double.mp3" ;
|
||||||
|
|
||||||
SNDFILE * file ;
|
SNDFILE * file ;
|
||||||
@ -260,7 +260,7 @@ mp3_double_test (void)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mp3_stereo_seek_test (const char * filename, int format)
|
mpeg_stereo_seek_test (const char * filename, int format)
|
||||||
{ static float data [SAMPLE_RATE] ;
|
{ static float data [SAMPLE_RATE] ;
|
||||||
static float stereo_out [SAMPLE_RATE * 2] ;
|
static float stereo_out [SAMPLE_RATE * 2] ;
|
||||||
|
|
||||||
@ -334,12 +334,12 @@ int
|
|||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
if (HAVE_MPEG)
|
if (HAVE_MPEG)
|
||||||
{ mp3_short_test () ;
|
{ mpeg_short_test () ;
|
||||||
mp3_int_test () ;
|
mpeg_int_test () ;
|
||||||
mp3_float_test () ;
|
mpeg_float_test () ;
|
||||||
mp3_double_test () ;
|
mpeg_double_test () ;
|
||||||
|
|
||||||
mp3_stereo_seek_test ("mpeg_seek.mp3", SF_FORMAT_MPEG | SF_FORMAT_MPEG_LAYER_III) ;
|
mpeg_stereo_seek_test ("mpeg_seek.mp3", SF_FORMAT_MPEG | SF_FORMAT_MPEG_LAYER_III) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
puts (" No MPEG tests because mpg123/lame support was not compiled in.") ;
|
puts (" No MPEG tests because mpg123/lame support was not compiled in.") ;
|
@ -353,7 +353,7 @@ echo " $sfversion passed tests on OPUS files."
|
|||||||
echo "----------------------------------------------------------------------"
|
echo "----------------------------------------------------------------------"
|
||||||
|
|
||||||
# mpeg-tests
|
# mpeg-tests
|
||||||
./tests/mp3_test@EXEEXT@
|
./tests/mpeg_test@EXEEXT@
|
||||||
./tests/compression_size_test@EXEEXT@ mpeg
|
./tests/compression_size_test@EXEEXT@ mpeg
|
||||||
./tests/string_test@EXEEXT@ mpeg
|
./tests/string_test@EXEEXT@ mpeg
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user