mirror of https://github.com/xiph/flac
Let libFLAC not write a seektable in Ogg, even when asked for
The seektable libFLAC currently writes does not conform to https://datatracker.ietf.org/doc/draft-ietf-cellar-flac/07/ and it probably isn't used anywhere, so the code writing it is removed
This commit is contained in:
parent
8d2830b6a9
commit
2b87e4cd25
|
@ -766,6 +766,18 @@ static FLAC__StreamEncoderInitStatus init_stream_internal_(
|
|||
encoder->protected_->min_residual_partition_order = encoder->protected_->max_residual_partition_order;
|
||||
|
||||
#if FLAC__HAS_OGG
|
||||
/* drop any seektable for ogg */
|
||||
if(is_ogg && 0 != encoder->protected_->metadata && encoder->protected_->num_metadata_blocks > 0) {
|
||||
uint32_t i1;
|
||||
for(i1 = 0; i1 < encoder->protected_->num_metadata_blocks; i1++) {
|
||||
if(0 != encoder->protected_->metadata[i1] && encoder->protected_->metadata[i1]->type == FLAC__METADATA_TYPE_SEEKTABLE) {
|
||||
encoder->protected_->num_metadata_blocks--;
|
||||
for( ; i1 < encoder->protected_->num_metadata_blocks; i1++)
|
||||
encoder->protected_->metadata[i1] = encoder->protected_->metadata[i1+1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* reorder metadata if necessary to ensure that any VORBIS_COMMENT is the first, according to the mapping spec */
|
||||
if(is_ogg && 0 != encoder->protected_->metadata && encoder->protected_->num_metadata_blocks > 1) {
|
||||
uint32_t i1;
|
||||
|
@ -3147,63 +3159,6 @@ void update_ogg_metadata_(FLAC__StreamEncoder *encoder)
|
|||
return; /* state already set */
|
||||
}
|
||||
simple_ogg_page__clear(&page);
|
||||
|
||||
/*
|
||||
* Write seektable
|
||||
*/
|
||||
if(0 != encoder->private_->seek_table && encoder->private_->seek_table->num_points > 0 && encoder->protected_->seektable_offset > 0) {
|
||||
uint32_t i;
|
||||
FLAC__byte *p;
|
||||
|
||||
FLAC__format_seektable_sort(encoder->private_->seek_table);
|
||||
|
||||
FLAC__ASSERT(FLAC__format_seektable_is_legal(encoder->private_->seek_table));
|
||||
|
||||
simple_ogg_page__init(&page);
|
||||
if(!simple_ogg_page__get_at(encoder, encoder->protected_->seektable_offset, &page, encoder->private_->seek_callback, encoder->private_->read_callback, encoder->private_->client_data)) {
|
||||
simple_ogg_page__clear(&page);
|
||||
return; /* state already set */
|
||||
}
|
||||
|
||||
if((FLAC__STREAM_METADATA_HEADER_LENGTH + 18*encoder->private_->seek_table->num_points) != (uint32_t)page.body_len) {
|
||||
encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR;
|
||||
simple_ogg_page__clear(&page);
|
||||
return;
|
||||
}
|
||||
|
||||
for(i = 0, p = page.body + FLAC__STREAM_METADATA_HEADER_LENGTH; i < encoder->private_->seek_table->num_points; i++, p += 18) {
|
||||
FLAC__uint64 xx;
|
||||
uint32_t x;
|
||||
xx = encoder->private_->seek_table->points[i].sample_number;
|
||||
b[7] = (FLAC__byte)xx; xx >>= 8;
|
||||
b[6] = (FLAC__byte)xx; xx >>= 8;
|
||||
b[5] = (FLAC__byte)xx; xx >>= 8;
|
||||
b[4] = (FLAC__byte)xx; xx >>= 8;
|
||||
b[3] = (FLAC__byte)xx; xx >>= 8;
|
||||
b[2] = (FLAC__byte)xx; xx >>= 8;
|
||||
b[1] = (FLAC__byte)xx; xx >>= 8;
|
||||
b[0] = (FLAC__byte)xx; xx >>= 8;
|
||||
xx = encoder->private_->seek_table->points[i].stream_offset;
|
||||
b[15] = (FLAC__byte)xx; xx >>= 8;
|
||||
b[14] = (FLAC__byte)xx; xx >>= 8;
|
||||
b[13] = (FLAC__byte)xx; xx >>= 8;
|
||||
b[12] = (FLAC__byte)xx; xx >>= 8;
|
||||
b[11] = (FLAC__byte)xx; xx >>= 8;
|
||||
b[10] = (FLAC__byte)xx; xx >>= 8;
|
||||
b[9] = (FLAC__byte)xx; xx >>= 8;
|
||||
b[8] = (FLAC__byte)xx; xx >>= 8;
|
||||
x = encoder->private_->seek_table->points[i].frame_samples;
|
||||
b[17] = (FLAC__byte)x; x >>= 8;
|
||||
b[16] = (FLAC__byte)x; x >>= 8;
|
||||
memcpy(p, b, 18);
|
||||
}
|
||||
|
||||
if(!simple_ogg_page__set_at(encoder, encoder->protected_->seektable_offset, &page, encoder->private_->seek_callback, encoder->private_->write_callback, encoder->private_->client_data)) {
|
||||
simple_ogg_page__clear(&page);
|
||||
return; /* state already set */
|
||||
}
|
||||
simple_ogg_page__clear(&page);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -745,11 +745,10 @@ static bool test_stream_decoder(Layer layer, bool is_ogg)
|
|||
printf("OK\n");
|
||||
|
||||
num_expected_ = 0;
|
||||
if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping */
|
||||
if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping. Also removes the seektable */
|
||||
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
||||
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
||||
expected_metadata_sequence_[num_expected_++] = &padding_;
|
||||
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
||||
expected_metadata_sequence_[num_expected_++] = &application1_;
|
||||
expected_metadata_sequence_[num_expected_++] = &application2_;
|
||||
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
||||
|
@ -808,6 +807,7 @@ static bool test_stream_decoder(Layer layer, bool is_ogg)
|
|||
num_expected_ = 0;
|
||||
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
||||
expected_metadata_sequence_[num_expected_++] = &padding_;
|
||||
if(!is_ogg) /* encoder removes seektable for ogg */
|
||||
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
||||
expected_metadata_sequence_[num_expected_++] = &application1_;
|
||||
expected_metadata_sequence_[num_expected_++] = &application2_;
|
||||
|
@ -837,11 +837,10 @@ static bool test_stream_decoder(Layer layer, bool is_ogg)
|
|||
printf("OK\n");
|
||||
|
||||
num_expected_ = 0;
|
||||
if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping */
|
||||
if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping. Also removes the seektable */
|
||||
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
||||
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
||||
expected_metadata_sequence_[num_expected_++] = &padding_;
|
||||
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
||||
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
||||
expected_metadata_sequence_[num_expected_++] = &picture_;
|
||||
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
||||
|
@ -878,11 +877,10 @@ static bool test_stream_decoder(Layer layer, bool is_ogg)
|
|||
printf("OK\n");
|
||||
|
||||
num_expected_ = 0;
|
||||
if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping */
|
||||
if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping. Also removes the seektable */
|
||||
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
||||
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
||||
expected_metadata_sequence_[num_expected_++] = &padding_;
|
||||
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
||||
expected_metadata_sequence_[num_expected_++] = &application2_;
|
||||
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
||||
expected_metadata_sequence_[num_expected_++] = &picture_;
|
||||
|
@ -928,11 +926,10 @@ static bool test_stream_decoder(Layer layer, bool is_ogg)
|
|||
printf("OK\n");
|
||||
|
||||
num_expected_ = 0;
|
||||
if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping */
|
||||
if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping. Also removes seektable */
|
||||
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
||||
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
||||
expected_metadata_sequence_[num_expected_++] = &padding_;
|
||||
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
||||
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
||||
expected_metadata_sequence_[num_expected_++] = &picture_;
|
||||
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
||||
|
@ -1081,11 +1078,10 @@ static bool test_stream_decoder(Layer layer, bool is_ogg)
|
|||
printf("OK\n");
|
||||
|
||||
num_expected_ = 0;
|
||||
if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping */
|
||||
if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping. Also removes the seektable */
|
||||
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
||||
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
||||
expected_metadata_sequence_[num_expected_++] = &padding_;
|
||||
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
||||
expected_metadata_sequence_[num_expected_++] = &application1_;
|
||||
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
||||
expected_metadata_sequence_[num_expected_++] = &picture_;
|
||||
|
|
|
@ -670,11 +670,10 @@ static FLAC__bool test_stream_decoder(Layer layer, FLAC__bool is_ogg)
|
|||
printf("OK\n");
|
||||
|
||||
num_expected_ = 0;
|
||||
if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping */
|
||||
if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping. Also removes the seektable */
|
||||
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
||||
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
||||
expected_metadata_sequence_[num_expected_++] = &padding_;
|
||||
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
||||
expected_metadata_sequence_[num_expected_++] = &application1_;
|
||||
expected_metadata_sequence_[num_expected_++] = &application2_;
|
||||
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
||||
|
@ -727,6 +726,7 @@ static FLAC__bool test_stream_decoder(Layer layer, FLAC__bool is_ogg)
|
|||
num_expected_ = 0;
|
||||
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
||||
expected_metadata_sequence_[num_expected_++] = &padding_;
|
||||
if(!is_ogg) /* encoder removes seektable for ogg */
|
||||
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
||||
expected_metadata_sequence_[num_expected_++] = &application1_;
|
||||
expected_metadata_sequence_[num_expected_++] = &application2_;
|
||||
|
@ -752,11 +752,10 @@ static FLAC__bool test_stream_decoder(Layer layer, FLAC__bool is_ogg)
|
|||
printf("OK\n");
|
||||
|
||||
num_expected_ = 0;
|
||||
if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping */
|
||||
if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping. Also removes the seektable */
|
||||
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
||||
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
||||
expected_metadata_sequence_[num_expected_++] = &padding_;
|
||||
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
||||
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
||||
expected_metadata_sequence_[num_expected_++] = &picture_;
|
||||
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
||||
|
@ -789,11 +788,10 @@ static FLAC__bool test_stream_decoder(Layer layer, FLAC__bool is_ogg)
|
|||
printf("OK\n");
|
||||
|
||||
num_expected_ = 0;
|
||||
if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping */
|
||||
if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping. Also removes the seektable */
|
||||
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
||||
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
||||
expected_metadata_sequence_[num_expected_++] = &padding_;
|
||||
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
||||
expected_metadata_sequence_[num_expected_++] = &application2_;
|
||||
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
||||
expected_metadata_sequence_[num_expected_++] = &picture_;
|
||||
|
@ -833,11 +831,10 @@ static FLAC__bool test_stream_decoder(Layer layer, FLAC__bool is_ogg)
|
|||
printf("OK\n");
|
||||
|
||||
num_expected_ = 0;
|
||||
if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping */
|
||||
if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping. Also removes the seektable */
|
||||
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
||||
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
||||
expected_metadata_sequence_[num_expected_++] = &padding_;
|
||||
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
||||
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
||||
expected_metadata_sequence_[num_expected_++] = &picture_;
|
||||
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
||||
|
@ -962,11 +959,10 @@ static FLAC__bool test_stream_decoder(Layer layer, FLAC__bool is_ogg)
|
|||
printf("OK\n");
|
||||
|
||||
num_expected_ = 0;
|
||||
if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping */
|
||||
if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping. Also removes the seektable */
|
||||
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
||||
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
||||
expected_metadata_sequence_[num_expected_++] = &padding_;
|
||||
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
||||
expected_metadata_sequence_[num_expected_++] = &application1_;
|
||||
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
||||
expected_metadata_sequence_[num_expected_++] = &picture_;
|
||||
|
|
Loading…
Reference in New Issue