mpg123-1.33.2

This commit is contained in:
Ozkan Sezer
2025-08-11 08:15:30 +03:00
parent 03c8b9e94d
commit b4abae51e1
6 changed files with 53 additions and 37 deletions

View File

@@ -23,7 +23,7 @@
*/
#define MPG123_API_VERSION 49
/** library patch level at client build time */
#define MPG123_PATCHLEVEL 3
#define MPG123_PATCHLEVEL 4
#ifndef MPG123_EXPORT
/** Defines needed for MS Visual Studio(tm) DLL builds.
@@ -338,7 +338,11 @@ enum mpg123_param_flags
* the stream is assumed as non-seekable unless overridden.
*/
,MPG123_FORCE_SEEKABLE = 0x40000 /**< 19th bit: Force the stream to be seekable. */
,MPG123_STORE_RAW_ID3 = 0x80000 /**< store raw ID3 data (even if skipping) */
,MPG123_STORE_RAW_ID3 = 0x80000 /**< Store raw ID3 data (even if skipping).
* Before mpg123 1.33.2 (libmpg123 API 49, patchlevel 4), this has to be combined with
* MPG123_SKIP_ID3 to avoid getting corrupted data due to the ID3 parser inserting
* encoding bytes for its own convenience.
*/
,MPG123_FORCE_ENDIAN = 0x100000 /**< Enforce endianess of output samples.
* This is not reflected in the format codes. If this flag is set along with
* MPG123_BIG_ENDIAN, MPG123_ENC_SIGNED16 means s16be, without

View File

@@ -330,9 +330,9 @@ void INT123_id3_link(mpg123_handle *fr)
Since we can overwrite strings with ID3 update frames, don't free
memory, just grow strings.
*/
static void store_id3_text(mpg123_string *sb, unsigned char *source, size_t source_size, const int noquiet, const int notranslate)
static void store_id3_text(mpg123_string *sb, unsigned char encoding, unsigned char *source
, size_t source_size, const int noquiet, const int notranslate)
{
unsigned char encoding;
if(sb) // Always overwrite, even with nothing.
sb->fill = 0;
if(!source_size)
@@ -345,25 +345,25 @@ static void store_id3_text(mpg123_string *sb, unsigned char *source, size_t sour
if(notranslate)
{
/* Future: Add a path for ID3 errors. */
if(!mpg123_grow_string(sb, source_size))
if(!mpg123_grow_string(sb, source_size+1))
{
if(noquiet) error("Cannot resize target string, out of memory?");
return;
}
memcpy(sb->p, source, source_size);
sb->fill = source_size;
debug1("stored undecoded ID3 text of size %zu", source_size);
sb->p[0] = (char)encoding;
memcpy(sb->p+1, source, source_size);
sb->fill = source_size+1;
debug1("stored undecoded ID3 text of size %zu", source_size+1);
return;
}
encoding = source[0];
if(encoding > mpg123_id3_enc_max)
{
if(noquiet)
error1("Unknown text encoding %u, I take no chances, sorry!", encoding);
return;
}
INT123_id3_to_utf8(sb, encoding, source+1, source_size-1, noquiet);
INT123_id3_to_utf8(sb, encoding, source, source_size, noquiet);
if(sb->fill) debug1("UTF-8 string (the first one): %s", sb->p);
else if(noquiet) error("unable to convert string to UTF-8 (out of memory, junk input?)!");
@@ -449,6 +449,11 @@ static void process_text(mpg123_handle *fr, unsigned char *realdata, size_t real
{
/* Text encoding $xx */
/* The text (encoded) ... */
if(realsize < 1)
{
if(NOQUIET) error("Not even an encoding byte?");
return;
}
mpg123_text *t = add_text(fr, id);
if(VERBOSE4) fprintf(stderr, "Note: Storing text from %s encoding\n", enc_name(realdata[0]));
if(t == NULL)
@@ -460,7 +465,8 @@ static void process_text(mpg123_handle *fr, unsigned char *realdata, size_t real
? (char[5]) { t->id[0], t->id[1], t->id[2], t->id[3], 0 }
: "(nil)" );
memcpy(t->id, id, 4);
store_id3_text(&t->text, realdata, realsize, NOQUIET, fr->p.flags & MPG123_PLAIN_ID3TEXT);
store_id3_text( &t->text, realdata[0], realdata+1, realsize-1
, NOQUIET, fr->p.flags & MPG123_PLAIN_ID3TEXT );
if(VERBOSE4) // Do not print unsanitized text to terminals!
fprintf(stderr, "Note: ID3v2 %c%c%c%c text frame stored\n", id[0], id[1], id[2], id[3]);
}
@@ -577,8 +583,6 @@ static void process_comment(mpg123_handle *fr, enum frame_types tt, unsigned cha
return;
}
memcpy(lang, realdata+1, 3);
/* Now I can abuse a byte from lang for the encoding. */
descr[-1] = encoding;
/* Be careful with finding the end of description, I have to honor encoding here. */
text = next_text(descr, encoding, realsize-(descr-realdata));
if(text == NULL)
@@ -591,14 +595,14 @@ static void process_comment(mpg123_handle *fr, enum frame_types tt, unsigned cha
mpg123_string description;
mpg123_init_string(&description);
// Store the text, with desired encoding, but for comments always a local copy in UTF-8.
store_id3_text( &description, descr-1, text-descr+1
store_id3_text( &description, encoding, descr, text-descr
, NOQUIET, fr->p.flags & MPG123_PLAIN_ID3TEXT );
if(tt == comment)
store_id3_text( &localcom.description, descr-1, text-descr+1
store_id3_text( &localcom.description, encoding, descr, text-descr
, NOQUIET, 0 );
if(VERBOSE4)
fprintf( stderr, "Note: Storing comment from %s encoding\n"
, enc_name(realdata[0]) );
, enc_name(encoding) );
xcom = tt == uslt
? add_uslt(fr, lang, &description)
: add_comment(fr, lang, &description);
@@ -616,8 +620,8 @@ static void process_comment(mpg123_handle *fr, enum frame_types tt, unsigned cha
mpg123_move_string(&description, &xcom->description);
}
text[-1] = encoding; /* Byte abusal for encoding... */
store_id3_text(&xcom->text, text-1, realsize+1-(text-realdata), NOQUIET, fr->p.flags & MPG123_PLAIN_ID3TEXT);
store_id3_text( &xcom->text, encoding, text, realsize-(text-realdata)
, NOQUIET, fr->p.flags & MPG123_PLAIN_ID3TEXT );
/* Remember: I will probably decode the above (again) for rva comment checking. So no messing around, please. */
if(VERBOSE4) /* Do _not_ print the verbatim text: The encoding might be funny! */
@@ -641,7 +645,8 @@ static void process_comment(mpg123_handle *fr, enum frame_types tt, unsigned cha
if((rva_mode > -1) && (fr->rva.level[rva_mode] <= rva_level))
{
/* Only translate the contents in here where we really need them. */
store_id3_text(&localcom.text, text-1, realsize+1-(text-realdata), NOQUIET, 0);
store_id3_text( &localcom.text, encoding, text, realsize-(text-realdata)
, NOQUIET, 0 );
if(localcom.text.fill > 0)
{
fr->rva.gain[rva_mode] = (float) atof(localcom.text.p);
@@ -689,7 +694,7 @@ static void process_extra(mpg123_handle *fr, unsigned char* realdata, size_t rea
mpg123_init_string(&description);
/* The outside storage gets reencoded to UTF-8 only if not requested otherwise.
Remember that we really need the -1 here to hand in the encoding byte!*/
store_id3_text( &description, descr-1, text-descr+1
store_id3_text( &description, encoding, descr, text-descr
, NOQUIET, fr->p.flags & MPG123_PLAIN_ID3TEXT );
xex = add_extra(fr, &description);
if(xex)
@@ -706,10 +711,10 @@ static void process_extra(mpg123_handle *fr, unsigned char* realdata, size_t rea
init_mpg123_text(&localex); /* For our local copy. */
/* Our local copy is always stored in UTF-8! */
store_id3_text(&localex.description, descr-1, text-descr+1, NOQUIET, 0);
store_id3_text(&localex.description, encoding, descr, text-descr, NOQUIET, 0);
/* At first, only store the outside copy of the payload. We may not need the local copy. */
text[-1] = encoding;
store_id3_text(&xex->text, text-1, realsize-(text-realdata)+1, NOQUIET, fr->p.flags & MPG123_PLAIN_ID3TEXT);
store_id3_text( &xex->text, encoding, text, realsize-(text-realdata)
, NOQUIET, fr->p.flags & MPG123_PLAIN_ID3TEXT );
/* Now check if we would like to interpret this extra info for RVA. */
if(localex.description.fill > 0)
@@ -737,7 +742,8 @@ static void process_extra(mpg123_handle *fr, unsigned char* realdata, size_t rea
if((rva_mode > -1) && (fr->rva.level[rva_mode] <= rva_level))
{
/* Now we need the translated copy of the data. */
store_id3_text(&localex.text, text-1, realsize-(text-realdata)+1, NOQUIET, 0);
store_id3_text( &localex.text, encoding, text, realsize-(text-realdata)
, NOQUIET, 0 );
if(localex.text.fill > 0)
{
if(is_peak)

View File

@@ -16,7 +16,7 @@
// only single spaces as separator to ease parsing by build scripts
#define MPG123_MAJOR 1
#define MPG123_MINOR 33
#define MPG123_PATCH 1
#define MPG123_PATCH 2
// Don't get too wild with that to avoid confusing m4. No brackets.
// Also, it should fit well into a sane file name for the tarball.
#define MPG123_SUFFIX ""