allow non-strict mode for reading replaygain tags, to fallback to track tags if album tags are not available and vice versa
This commit is contained in:
parent
53b626a771
commit
95e39a8fa5
@ -101,6 +101,7 @@
|
||||
<li>
|
||||
plugins:
|
||||
<ul>
|
||||
<li>When ReplayGain is on, if tags for the preferred kind of gain (album/track) are not in a stream, the other kind will be used.</li>
|
||||
<li>Fixed UTF-8 decoder to disallow non-shortest-form and surrogate sequences (see <a href="http://www.unicode.org/versions/corrigendum1.html">here</a>).</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
@ -457,7 +457,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<span class="argument">a|t</span><br />
|
||||
Specify '<span class="argument">a</span>' to use the album gain, or '<span class="argument">t</span>' to use the track gain
|
||||
Specify '<span class="argument">a</span>' to use the album gain, or '<span class="argument">t</span>' to use the track gain. If tags for the preferred kind (album/track) do not exist but tags for the other (track/album) do, those will be used instead.
|
||||
</li>
|
||||
<li>
|
||||
<span class="argument">l|L</span><br />
|
||||
|
@ -59,7 +59,7 @@ const char *grabbag__replaygain_store_to_file(const char *filename, float album_
|
||||
const char *grabbag__replaygain_store_to_file_album(const char *filename, float album_gain, float album_peak, FLAC__bool preserve_modtime);
|
||||
const char *grabbag__replaygain_store_to_file_title(const char *filename, float title_gain, float title_peak, FLAC__bool preserve_modtime);
|
||||
|
||||
FLAC__bool grabbag__replaygain_load_from_vorbiscomment(const FLAC__StreamMetadata *block, FLAC__bool album_mode, double *gain, double *peak);
|
||||
FLAC__bool grabbag__replaygain_load_from_vorbiscomment(const FLAC__StreamMetadata *block, FLAC__bool album_mode, FLAC__bool strict, double *gain, double *peak);
|
||||
double grabbag__replaygain_compute_scale_factor(double peak, double gain, double preamp, FLAC__bool prevent_clipping);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1106,8 +1106,8 @@ void metadata_callback(const void *decoder, const FLAC__StreamMetadata *metadata
|
||||
else if(metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) {
|
||||
if (decoder_session->replaygain.spec.apply) {
|
||||
double gain, peak;
|
||||
if (!(decoder_session->replaygain.apply = grabbag__replaygain_load_from_vorbiscomment(metadata, decoder_session->replaygain.spec.use_album_gain, &gain, &peak))) {
|
||||
flac__utils_printf(stderr, 1, "%s: WARNING: can't get %s ReplayGain tag\n", decoder_session->inbasefilename, decoder_session->replaygain.spec.use_album_gain? "album":"track");
|
||||
if (!(decoder_session->replaygain.apply = grabbag__replaygain_load_from_vorbiscomment(metadata, decoder_session->replaygain.spec.use_album_gain, /*strict=*/false, &gain, &peak))) {
|
||||
flac__utils_printf(stderr, 1, "%s: WARNING: can't get %s (or even %s) ReplayGain tags\n", decoder_session->inbasefilename, decoder_session->replaygain.spec.use_album_gain? "album":"track", decoder_session->replaygain.spec.use_album_gain? "track":"album");
|
||||
}
|
||||
else {
|
||||
const char *ls[] = { "no", "peak", "hard" };
|
||||
|
@ -77,7 +77,7 @@ static void metadata_callback(const FLAC__FileDecoder *decoder, const FLAC__Stre
|
||||
else if (metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT)
|
||||
{
|
||||
double gain, peak;
|
||||
if (grabbag__replaygain_load_from_vorbiscomment(metadata, cfg.replaygain.album_mode, &gain, &peak))
|
||||
if (grabbag__replaygain_load_from_vorbiscomment(metadata, cfg.replaygain.album_mode, /*strict=*/false, &gain, &peak))
|
||||
{
|
||||
file_info->has_replaygain = true;
|
||||
file_info->replay_scale = grabbag__replaygain_compute_scale_factor(peak, gain, (double)cfg.replaygain.preamp, !cfg.replaygain.hard_limit);
|
||||
|
@ -798,7 +798,7 @@ void metadata_callback_(const void *decoder, const FLAC__StreamMetadata *metadat
|
||||
}
|
||||
else if(metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) {
|
||||
double gain, peak;
|
||||
if(grabbag__replaygain_load_from_vorbiscomment(metadata, flac_cfg.output.replaygain.album_mode, &gain, &peak)) {
|
||||
if(grabbag__replaygain_load_from_vorbiscomment(metadata, flac_cfg.output.replaygain.album_mode, /*strict=*/false, &gain, &peak)) {
|
||||
file_info->has_replaygain = true;
|
||||
file_info->replay_scale = grabbag__replaygain_compute_scale_factor(peak, gain, (double)flac_cfg.output.replaygain.preamp, /*prevent_clipping=*/!flac_cfg.output.replaygain.hard_limit);
|
||||
}
|
||||
|
@ -581,7 +581,7 @@ static FLAC__bool parse_double_(const FLAC__StreamMetadata_VorbisComment_Entry *
|
||||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool grabbag__replaygain_load_from_vorbiscomment(const FLAC__StreamMetadata *block, FLAC__bool album_mode, double *gain, double *peak)
|
||||
FLAC__bool grabbag__replaygain_load_from_vorbiscomment(const FLAC__StreamMetadata *block, FLAC__bool album_mode, FLAC__bool strict, double *gain, double *peak)
|
||||
{
|
||||
int gain_offset, peak_offset;
|
||||
|
||||
@ -589,14 +589,14 @@ FLAC__bool grabbag__replaygain_load_from_vorbiscomment(const FLAC__StreamMetadat
|
||||
FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT);
|
||||
|
||||
if(0 > (gain_offset = FLAC__metadata_object_vorbiscomment_find_entry_from(block, /*offset=*/0, (const char *)(album_mode? GRABBAG__REPLAYGAIN_TAG_ALBUM_GAIN : GRABBAG__REPLAYGAIN_TAG_TITLE_GAIN))))
|
||||
return false;
|
||||
return !strict && grabbag__replaygain_load_from_vorbiscomment(block, !album_mode, /*strict=*/true, gain, peak);
|
||||
if(0 > (peak_offset = FLAC__metadata_object_vorbiscomment_find_entry_from(block, /*offset=*/0, (const char *)(album_mode? GRABBAG__REPLAYGAIN_TAG_ALBUM_PEAK : GRABBAG__REPLAYGAIN_TAG_TITLE_PEAK))))
|
||||
return false;
|
||||
return !strict && grabbag__replaygain_load_from_vorbiscomment(block, !album_mode, /*strict=*/true, gain, peak);
|
||||
|
||||
if(!parse_double_(block->data.vorbis_comment.comments + gain_offset, gain))
|
||||
return false;
|
||||
return !strict && grabbag__replaygain_load_from_vorbiscomment(block, !album_mode, /*strict=*/true, gain, peak);
|
||||
if(!parse_double_(block->data.vorbis_comment.comments + peak_offset, peak))
|
||||
return false;
|
||||
return !strict && grabbag__replaygain_load_from_vorbiscomment(block, !album_mode, /*strict=*/true, gain, peak);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user