From dd47d27f5ec28aa972eb0eb29bf2aa54da65fa9b Mon Sep 17 00:00:00 2001 From: thor Date: Sun, 17 May 2009 00:36:30 +0000 Subject: [PATCH] add --preframes, update documentation git-svn-id: svn://scm.orgis.org/mpg123/trunk@2051 35dc7657-300d-0410-a2e5-dc2837fedb53 --- man1/mpg123.1 | 8 ++++++++ src/mpg123.c | 8 +++++++- src/mpg123app.h | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/man1/mpg123.1 b/man1/mpg123.1 index d797ef0b..47315d61 100644 --- a/man1/mpg123.1 +++ b/man1/mpg123.1 @@ -125,6 +125,14 @@ Do not accept ICY meta data. \fB\-i, \-\^-\index Index / scan through the track before playback. This fills the index table for seeking (if enabled in libmpg123) and may make the operating system cache the file contents for smoother operating on playback. +.TP +\fB\-\-index\-size \fIsize\fR +Set the number of entries in the seek frame index table. +.TP +\fB\-\-preframes \fInum\fR +Set the number of frames to be read as lead-in before a seeked-to position. +This serves to fill the layer 3 bit reservoir, which is needed to faithfully reproduce a certain sample at a certain position. +Note that for layer 3, a minimum of 1 is enforced (because of frame overlap), and for layer 1 and 2, this is limited to 2 (no bit reservoir in that case, but engine spin-up anyway). .SH OUTPUT and PROCESSING OPTIONS .TP diff --git a/src/mpg123.c b/src/mpg123.c index a9e021b0..a4ae4c58 100644 --- a/src/mpg123.c +++ b/src/mpg123.c @@ -112,6 +112,7 @@ struct parameter param = { ,INDEX_SIZE ,NULL /* force_encoding */ ,1. /* preload */ + ,-1 /* preframes */ }; mpg123_handle *mh = NULL; @@ -441,6 +442,7 @@ topt opts[] = { {0, "no-seekbuffer", GLO_INT, unset_frameflag, &frameflag, MPG123_SEEKBUFFER}, {'e', "encoding", GLO_ARG|GLO_CHAR, 0, ¶m.force_encoding, 0}, {0, "preload", GLO_ARG|GLO_DOUBLE, 0, ¶m.preload, 0}, + {0, "preframes", GLO_ARG|GLO_LONG, 0, ¶m.preframes, 0}, {0, 0, 0, 0, 0, 0} }; @@ -724,6 +726,7 @@ int main(int argc, char *argv[]) param.flags = (int) parr; param.flags |= MPG123_SEEKBUFFER; /* Default on, for HTTP streams. */ mpg123_getpar(mp, MPG123_RESYNC_LIMIT, ¶m.resync_limit, NULL); + mpg123_getpar(mp, MPG123_PREFRAMES, ¶m.preframes, NULL); #ifdef OS2 _wildcard(&argc,&argv); @@ -822,6 +825,8 @@ int main(int argc, char *argv[]) #endif && ++libpar && MPG123_OK == (result = mpg123_par(mp, MPG123_OUTSCALE, param.outscale, 0)) + && ++libpar + && MPG123_OK == (result = mpg123_par(mp, MPG123_PREFRAMES, param.preframes, 0)) )) { error2("Cannot set library parameter %i: %s", libpar, mpg123_plain_strerror(result)); @@ -1145,7 +1150,8 @@ static void long_usage(int err) fprintf(o," -Z --random full random play\n"); fprintf(o," --no-icy-meta Do not accept ICY meta data\n"); fprintf(o," -i --index index / scan through the track before playback\n"); - fprintf(o," --index-size change size of frame index\n"); + fprintf(o," --index-size change size of frame index\n"); + fprintf(o," --preframes number of frames to decode in advance after seeking (to keep layer 3 bit reservoir happy)\n"); fprintf(o," --resync-limit Set number of bytes to search for valid MPEG data; <0 means search whole stream.\n"); fprintf(o,"\noutput/processing options\n\n"); fprintf(o," -o --output select audio output module\n"); diff --git a/src/mpg123app.h b/src/mpg123app.h index 4396056a..e0a95fae 100644 --- a/src/mpg123app.h +++ b/src/mpg123app.h @@ -98,6 +98,7 @@ struct parameter long index_size; /* size of frame index */ char *force_encoding; double preload; /* buffer preload size (fraction of full buffer) */ + long preframes; }; extern char *equalfile;