fix a bug where missing STREAMINFO fields (min/max framesize, total samples, MD5 sum) and seek point offsets were not getting rewritten back to Ogg FLAC file (SF#1338969 https://sourceforge.net/tracker/index.php?func=detail&aid=1338969&group_id=13478&atid=113478)

This commit is contained in:
Josh Coalson 2006-11-15 08:53:32 +00:00
parent 33bba6d34d
commit c986d135f1
4 changed files with 21 additions and 8 deletions

View File

@ -105,6 +105,7 @@
<li>MD5 comparison failures on decoding are now an error instead of a warning and will also return a non-zero exit code (<a href="https://sourceforge.net/tracker/index.php?func=detail&amp;aid=1493725&amp;group_id=13478&amp;atid=113478">SF #1493725</a>).</li>
<li>The default padding size is now 8K, or 64K if the input audio stream is more than 20 minutes long.</li>
<li>Fixed a bug in cuesheet parsing where it would return an error if the last line of the cuesheet did not end with a newline.</li>
<li>Fixed a bug where missing STREAMINFO fields (min/max framesize, total samples, MD5 sum) and seek point offsets were not getting rewritten back to Ogg FLAC file (<a href="https://sourceforge.net/tracker/index.php?func=detail&amp;aid=1338969&amp;group_id=13478&amp;atid=113478">SF #1338969</a>).</li>
<li>Fixed a bug that caused a crash when <span class="argument">-a</span> and <span class="argument">-t</span> were used together (<a href="https://sourceforge.net/tracker/index.php?func=detail&amp;aid=1229481&amp;group_id=13478&amp;atid=113478">SF #1229481</a>).</li>
<li>Fixed a bug with --sector-align where appended samples were not always totally silent (<a href="https://sourceforge.net/tracker/index.php?func=detail&amp;aid=1237707&amp;group_id=13478&amp;atid=113478">SF #1237707</a>).</li>
<li>Fixed bugs with --sector-align and raw input files.</li>

View File

@ -1443,7 +1443,7 @@
The following are major known bugs in the current (1.1.3) release:
<ul>
<li>
(none)
When encoding to Ogg FLAC, if there are too many seek points (&gt;240), the seek table will not have the offsets written back properly after encoding.
</li>
</ul>
The following are major known bugs in the 1.1.0 release:

View File

@ -150,7 +150,7 @@ FLAC__bool simple_ogg_page__get_at(FLAC__StreamEncoder *encoder, FLAC__uint64 po
}
}
page->body_len = 255 * i + page->header[i];
page->body_len = 255 * i + page->header[i + OGG_HEADER_FIXED_PORTION_LEN];
}
/* allocate space for the page body */
@ -199,6 +199,10 @@ FLAC__bool simple_ogg_page__set_at(FLAC__StreamEncoder *encoder, FLAC__uint64 po
encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR;
return false;
}
if(write_callback((FLAC__StreamEncoder*)encoder, page->body, page->body_len, 0, 0, client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK) {
encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR;
return false;
}
return true;
}

View File

@ -66,6 +66,7 @@
#include "private/memory.h"
#ifdef FLAC__HAS_OGG
#include "private/ogg_helper.h"
#include "private/ogg_mapping.h"
#endif
#include "private/stream_encoder_framing.h"
#include "private/window.h"
@ -2895,6 +2896,15 @@ void update_metadata_(const FLAC__StreamEncoder *encoder)
/* Gets called when the encoding process has finished so that we can update the STREAMINFO and SEEKTABLE blocks. */
void update_ogg_metadata_(FLAC__StreamEncoder *encoder)
{
/* the # of bytes in the 1st packet that precede the STREAMINFO */
static const unsigned FIRST_OGG_PACKET_STREAMINFO_PREFIX_LENGTH =
FLAC__OGG_MAPPING_PACKET_TYPE_LENGTH +
FLAC__OGG_MAPPING_MAGIC_LENGTH +
FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH +
FLAC__OGG_MAPPING_VERSION_MINOR_LENGTH +
FLAC__OGG_MAPPING_NUM_HEADERS_LENGTH +
FLAC__STREAM_SYNC_LENGTH
;
FLAC__byte b[max(6, FLAC__STREAM_METADATA_SEEKPOINT_LENGTH)];
const FLAC__StreamMetadata *metadata = &encoder->private_->streaminfo;
const FLAC__uint64 samples = metadata->data.stream_info.total_samples;
@ -2923,6 +2933,7 @@ void update_ogg_metadata_(FLAC__StreamEncoder *encoder)
*/
{
const unsigned md5_offset =
FIRST_OGG_PACKET_STREAMINFO_PREFIX_LENGTH +
FLAC__STREAM_METADATA_HEADER_LENGTH +
(
FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN +
@ -2948,6 +2959,7 @@ void update_ogg_metadata_(FLAC__StreamEncoder *encoder)
*/
{
const unsigned total_samples_byte_offset =
FIRST_OGG_PACKET_STREAMINFO_PREFIX_LENGTH +
FLAC__STREAM_METADATA_HEADER_LENGTH +
(
FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN +
@ -2979,6 +2991,7 @@ void update_ogg_metadata_(FLAC__StreamEncoder *encoder)
*/
{
const unsigned min_framesize_offset =
FIRST_OGG_PACKET_STREAMINFO_PREFIX_LENGTH +
FLAC__STREAM_METADATA_HEADER_LENGTH +
(
FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN +
@ -3021,7 +3034,7 @@ void update_ogg_metadata_(FLAC__StreamEncoder *encoder)
return; /* state already set */
}
if(FLAC__STREAM_METADATA_HEADER_LENGTH + (18*encoder->private_->seek_table->num_points) > (unsigned)page.body_len) {
if((FLAC__STREAM_METADATA_HEADER_LENGTH + 18*encoder->private_->seek_table->num_points) != (unsigned)page.body_len) {
encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR;
simple_ogg_page__clear(&page);
return;
@ -3051,11 +3064,6 @@ void update_ogg_metadata_(FLAC__StreamEncoder *encoder)
x = encoder->private_->seek_table->points[i].frame_samples;
b[17] = (FLAC__byte)x; x >>= 8;
b[16] = (FLAC__byte)x; x >>= 8;
if(encoder->private_->write_callback(encoder, b, 18, 0, 0, encoder->private_->client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK) {
encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR;
simple_ogg_page__clear(&page);
return;
}
memcpy(p, b, 18);
}