Mercurial > SDL_sound_CoreAudio
view decoders/mpglib/mpg123_sdlsound.h @ 474:c66080364dff
Most decoders now report total sample play time, now. Technically, this
breaks binary compatibility with the 1.0 branch, since it extends the
Sound_Sample struct, but most (all?) programs are just passing pointers
allocated by SDL_sound around, and might be okay.
Source-level compatibility is not broken...yet! :)
--ryan.
-------- Original Message --------
Subject: SDL_sound patch: Finding total length of time of sound file.
Date: Sun, 26 Jan 2003 09:31:17 -0800 (PST)
Hi Ryan,
I am working with Eric Wing and helping him modify
SDL_sound. AS part of our efforts in improving and
enhancing SDL_sound, we like to submit this patch. We
modified the codecs to find the total time of a sound
file. Below is the explanation of the patch. The
patch is appended as an attachment to this email.
* MOTIVATION:
We needed the ability to get the total play time of a
sample (And we noticed that we're not the only ones).
Since SDL_sound blocks direct access to the specific
decoders, there is no way for a user to know this
information short of decoding the whole thing.
Because of this, we believe this will be a useful
addition, even though the accuracy may not be perfect
(subject to each decoder) or the information may not
always be available.
* CONTRIBUTORS:
Wesley Leong (modified the majority of the codecs and
verified the results)
Eric Wing (showed everyone how to do modify codec,
modified mikmod)
Wang Lam (modified a handful of codecs, researched
into specs and int overflow)
Ahilan Anantha (modified a few codecs and helped with
integer math)
* GENERAL ISSUES:
We chose the value to be milliseconds as an Sint32.
Milliseconds because that's what Sound_Seek takes as a
parameter and -1 to allow for instances/codecs where
the value could not be determined. We are
not sure if this is the final convention you want, so
we are willing to work with you on this.
We also expect the total_time field to be set on open
and never again modified by SDL_sound. Users may
access it directly much like the sample buffer and
buffer_size. We thought about recomputing the time
on DecodeAll, but since users may seek or decode small
chunks first, not all the data may be there. So this
is better done by the user. This may be good
information to document.
Currently, all the main codecs are implemented except
for QuickTime.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Sat, 08 May 2004 08:19:50 +0000 |
parents | c42ac9ee2ce4 |
children |
line wrap: on
line source
#include <stdio.h> #include <string.h> #if !defined(WIN32) && !defined(macintosh) && !defined(_WIN32_WCE) #include <unistd.h> #endif #include <math.h> #if defined(_WIN32) # undef WIN32 # define WIN32 #endif #if defined(WIN32) || defined(macintosh) || defined(_WIN32_WCE) # define M_PI 3.14159265358979323846 # define M_SQRT2 1.41421356237309504880 # define REAL_IS_FLOAT # define NEW_DCT9 # define random rand # define srandom srand #endif #ifdef REAL_IS_FLOAT # define real float #elif defined(REAL_IS_LONG_DOUBLE) # define real long double #else # define real double #endif #ifdef __GNUC__ #define INLINE inline #elif ((defined _MSC_VER) || (defined __inline__)) #define INLINE __inline__ #else #define INLINE #endif /* AUDIOBUFSIZE = n*64 with n=1,2,3 ... */ #define AUDIOBUFSIZE 16384 #ifndef FALSE #define FALSE 0 #endif #ifndef FALSE #define TRUE 1 #endif #define SBLIMIT 32 #define SSLIMIT 18 #define SCALE_BLOCK 12 #define MPG_MD_STEREO 0 #define MPG_MD_JOINT_STEREO 1 #define MPG_MD_DUAL_CHANNEL 2 #define MPG_MD_MONO 3 #define MAXFRAMESIZE 1792 /* Pre Shift fo 16 to 8 bit converter table */ #define AUSHIFT (3) struct frame { int stereo; int jsbound; int single; int lsf; int mpeg25; int header_change; int lay; int error_protection; int bitrate_index; int sampling_frequency; int padding; int extension; int mode; int mode_ext; int copyright; int original; int emphasis; int framesize; /* computed framesize */ /* layer2 stuff */ int II_sblimit; void *alloc; int bitrate; }; struct parameter { int quiet; /* shut up! */ int tryresync; /* resync stream after error */ int verbose; /* verbose level */ int checkrange; }; struct mpstr; /* forward declaration. */ extern unsigned int get1bit(void); extern unsigned int getbits(int); extern unsigned int getbits_fast(int); extern int set_pointer(long,struct mpstr *); extern unsigned char *wordpointer; extern int bitindex; extern void make_decode_tables(long scaleval); extern int do_layer3(struct frame *fr,unsigned char *,int *,struct mpstr *); extern int do_layer2(struct frame *fr,unsigned char *,int *,struct mpstr *); extern int do_layer1(struct frame *fr,unsigned char *,int *,struct mpstr *); extern int decode_header(struct frame *fr,unsigned long newhead); struct gr_info_s { int scfsi; unsigned part2_3_length; unsigned big_values; unsigned scalefac_compress; unsigned block_type; unsigned mixed_block_flag; unsigned table_select[3]; unsigned subblock_gain[3]; unsigned maxband[3]; unsigned maxbandl; unsigned maxb; unsigned region1start; unsigned region2start; unsigned preflag; unsigned scalefac_scale; unsigned count1table_select; real *full_gain[3]; real *pow2gain; }; struct III_sideinfo { unsigned main_data_begin; unsigned private_bits; struct { struct gr_info_s gr[2]; } ch[2]; }; extern int synth_1to1 (real *,int,unsigned char *,int *,struct mpstr *); extern int synth_1to1_8bit (real *,int,unsigned char *,int *); extern int synth_1to1_mono (real *,unsigned char *,int *,struct mpstr *); extern int synth_1to1_mono2stereo (real *,unsigned char *,int *); extern int synth_1to1_8bit_mono (real *,unsigned char *,int *); extern int synth_1to1_8bit_mono2stereo (real *,unsigned char *,int *); extern int synth_2to1 (real *,int,unsigned char *,int *); extern int synth_2to1_8bit (real *,int,unsigned char *,int *); extern int synth_2to1_mono (real *,unsigned char *,int *); extern int synth_2to1_mono2stereo (real *,unsigned char *,int *); extern int synth_2to1_8bit_mono (real *,unsigned char *,int *); extern int synth_2to1_8bit_mono2stereo (real *,unsigned char *,int *); extern int synth_4to1 (real *,int,unsigned char *,int *); extern int synth_4to1_8bit (real *,int,unsigned char *,int *); extern int synth_4to1_mono (real *,unsigned char *,int *); extern int synth_4to1_mono2stereo (real *,unsigned char *,int *); extern int synth_4to1_8bit_mono (real *,unsigned char *,int *); extern int synth_4to1_8bit_mono2stereo (real *,unsigned char *,int *); extern int synth_ntom (real *,int,unsigned char *,int *); extern int synth_ntom_8bit (real *,int,unsigned char *,int *); extern int synth_ntom_mono (real *,unsigned char *,int *); extern int synth_ntom_mono2stereo (real *,unsigned char *,int *); extern int synth_ntom_8bit_mono (real *,unsigned char *,int *); extern int synth_ntom_8bit_mono2stereo (real *,unsigned char *,int *); extern void rewindNbits(int bits); extern int hsstell(void); extern int get_songlen(struct frame *fr,int no); extern void init_layer3(int); extern void init_layer2(void); extern void make_decode_tables(long scale); extern void make_conv16to8_table(int); extern void dct64(real *,real *,real *); extern void synth_ntom_set_step(long,long); extern unsigned char *conv16to8; extern long mpglib_freqs[9]; extern real muls[27][64]; extern real decwin[512+32]; extern real *pnts[5]; extern struct parameter param;