Hi all,

Attached are three patches.

The first patch changes links to git.xiph.org to gitlab.xiph.org. The
second patch enables the flac analyse function to be able to handle frames
which are over 4Gbit in size. The third one fixes the compression ratio
display of very small files.

Kind regards,

Martijn van Beurden
From 2d875b71e56b35cd1ca0ff1fc4b163ccf77ae4bd Mon Sep 17 00:00:00 2001
From: Martijn van Beurden <mva...@gmail.com>
Date: Sat, 4 Jul 2020 14:19:40 +0200
Subject: [PATCH 1/3] Update links to Xiph git in documentation

---
 doc/html/changelog.html                  | 2 +-
 doc/html/developers.html                 | 2 +-
 doc/html/documentation_example_code.html | 2 +-
 doc/html/license.html                    | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/doc/html/changelog.html b/doc/html/changelog.html
index fc0dc4d7..3094ffa0 100644
--- a/doc/html/changelog.html
+++ b/doc/html/changelog.html
@@ -330,7 +330,7 @@
 			<li>
 				General:
 				<ul>
-					<li>Move development to Xiph.org <a href="http://git.xiph.org/?p=flac.git;a=summary";>git repository</a>.</li>
+					<li>Move development to Xiph.org git repository.</li>
 					<li>The <span class="argument"><a href="documentation_tools_flac.html#flac_options_sector_align">--sector-align</a></span> option of <span class="commandname">flac</span> has been deprecated and may not exist in future versions.  <a href="http://www.etree.org/shnutils/shntool/";>shntool</a> provides similar functionality.</li>
 					<li>Support for the RF64 and Wave64 formats in <span class="commandname">flac</span> (see below).</li>
 					<li>Better handling of cuesheets with non-CD-DA sample rates.</li>
diff --git a/doc/html/developers.html b/doc/html/developers.html
index 06d31c0f..b96ea7f3 100644
--- a/doc/html/developers.html
+++ b/doc/html/developers.html
@@ -54,7 +54,7 @@
 			<li><a href="format.html">FLAC Format Specification</a> - The formal specification.</li>
 			<li><a href="ogg_mapping.html">Ogg FLAC Mapping</a> - How FLAC should be embedded in an Ogg container.</li>
 			<li><a href="id.html">ID Registration</a> - Register an ID if you need to write custom metadata.</li>
-			<li><a href="https://git.xiph.org/?p=flac.git;a%3Dsummary";>Git access</a> - for checking out the source code.</li>
+			<li><a href="https://gitlab.xiph.org/xiph/flac";>Git access</a> - for checking out the source code.</li>
 			<li><a href="http://sourceforge.net/p/flac/bugs/";>Bug Tracker</a> - to submit bug reports and patches</li>
 		</ul>
 	</div>
diff --git a/doc/html/documentation_example_code.html b/doc/html/documentation_example_code.html
index dea608a2..bf078be4 100644
--- a/doc/html/documentation_example_code.html
+++ b/doc/html/documentation_example_code.html
@@ -42,7 +42,7 @@
 	</div>
 	<div class="box_header"></div>
 	<div class="box_body">
-		The FLAC source code has several small example programs that demonstrate how to use the libraries.  The source is available on the <a href="http://xiph.org/flac/download.html";>download page</a>, or can be <a href="https://git.xiph.org/?p=flac.git";>checked out from git</a>.  The examples complement the <a href="api/index.html">API documentation</a>.<br />
+		The FLAC source code has several small example programs that demonstrate how to use the libraries.  The source is available on the <a href="http://xiph.org/flac/download.html";>download page</a>, or can be <a href="https://gitlab.xiph.org/xiph/flac";>checked out from git</a>.  The examples complement the <a href="api/index.html">API documentation</a>.<br />
 		<br />
 		Currently the examples show how to encode WAV files to FLAC and vice-versa using both libFLAC and libFLAC++.  Over time we'll be adding more examples.
 	</div>
diff --git a/doc/html/license.html b/doc/html/license.html
index 22733880..b5d2accd 100644
--- a/doc/html/license.html
+++ b/doc/html/license.html
@@ -48,7 +48,7 @@
 		<br />
 		The FLAC project also makes available software that implements the formats, which is distributed according to <a href="http://opensource.org/docs/definition.php";>Open Source</a> licenses as follows:<br />
 		<br />
-		The reference implementation libraries are licensed under the New <!-- <a href="http://www.xiph.org/licenses/bsd/";> --><a href="https://git.xiph.org/?p=flac.git;a=blob_plain;f=COPYING.Xiph";>BSD License</a>.  In simple terms, these libraries may be used by any application, Open or proprietary, linked or incorporated in whole, so long as acknowledgement is made to Xiph.org Foundation when using the source code in whole or in derived works.  The Xiph License is free enough that the libraries have been used in commercial products to implement FLAC, including in the firmware of hardware devices where other Open Source licenses can be problematic.  In the source code these libraries are called <span class="commandname">libFLAC</span> and <span class="commandname">libFLAC++</span>.<br />
+		The reference implementation libraries are licensed under the New <a href="https://gitlab.xiph.org/xiph/flac/-/blob/master/COPYING.Xiph";>BSD License</a>.  In simple terms, these libraries may be used by any application, Open or proprietary, linked or incorporated in whole, so long as acknowledgement is made to Xiph.org Foundation when using the source code in whole or in derived works.  The Xiph License is free enough that the libraries have been used in commercial products to implement FLAC, including in the firmware of hardware devices where other Open Source licenses can be problematic.  In the source code these libraries are called <span class="commandname">libFLAC</span> and <span class="commandname">libFLAC++</span>.<br />
 		<br />
 		The rest of the software that the FLAC project provides is licensed under the <a href="http://www.gnu.org/licenses/licenses.html#GPL";>GNU General Public License</a> (GPL).  This software includes various utilities for converting files to and from FLAC format, plugins for audio players, et cetera.  In general, the GPL allows redistribution as long as derived works are also made available in source code form according to compatible terms.<br />
 		<br />
-- 
2.20.1

From eb0ecad5d5fbee87a02bce8eb0ca7ee90948e130 Mon Sep 17 00:00:00 2001
From: Martijn van Beurden <mva...@gmail.com>
Date: Sun, 5 Jul 2020 19:29:35 +0200
Subject: [PATCH 2/3] Change analyse function to support >4Gbit frames

Theoretically, when a rice parameter of 0, 24-bit samples, fixed
predictor with order 0, no rice escaping and a blocksize of 65536
is chosen, a subframe could be up to 2^24*65536 = 1 terabyte in
size. While this obviously should never happen, the analyse
function should be able to debug such a case.
---
 src/flac/analyze.c | 4 ++--
 src/flac/analyze.h | 2 +-
 src/flac/decode.c  | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/flac/analyze.c b/src/flac/analyze.c
index 683b6446..4c68094c 100644
--- a/src/flac/analyze.c
+++ b/src/flac/analyze.c
@@ -62,7 +62,7 @@ void flac__analyze_init(analysis_options aopts)
 	}
 }
 
-void flac__analyze_frame(const FLAC__Frame *frame, uint32_t frame_number, FLAC__uint64 frame_offset, uint32_t frame_bytes, analysis_options aopts, FILE *fout)
+void flac__analyze_frame(const FLAC__Frame *frame, uint32_t frame_number, FLAC__uint64 frame_offset, FLAC__uint64 frame_bytes, analysis_options aopts, FILE *fout)
 {
 	const uint32_t channels = frame->header.channels;
 	char outfilename[1024];
@@ -70,7 +70,7 @@ void flac__analyze_frame(const FLAC__Frame *frame, uint32_t frame_number, FLAC__
 	uint32_t i, channel, partitions;
 
 	/* do the human-readable part first */
-	fprintf(fout, "frame=%u\toffset=%" PRIu64 "\tbits=%u\tblocksize=%u\tsample_rate=%u\tchannels=%u\tchannel_assignment=%s\n", frame_number, frame_offset, frame_bytes*8, frame->header.blocksize, frame->header.sample_rate, channels, FLAC__ChannelAssignmentString[frame->header.channel_assignment]);
+	fprintf(fout, "frame=%u\toffset=%" PRIu64 "\tbits=%" PRIu64 "\tblocksize=%u\tsample_rate=%u\tchannels=%u\tchannel_assignment=%s\n", frame_number, frame_offset, frame_bytes*8, frame->header.blocksize, frame->header.sample_rate, channels, FLAC__ChannelAssignmentString[frame->header.channel_assignment]);
 	for(channel = 0; channel < channels; channel++) {
 		const FLAC__Subframe *subframe = frame->subframes+channel;
 		const FLAC__bool is_rice2 = subframe->data.fixed.entropy_coding_method.type == FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2;
diff --git a/src/flac/analyze.h b/src/flac/analyze.h
index 44798c71..fed0ee23 100644
--- a/src/flac/analyze.h
+++ b/src/flac/analyze.h
@@ -26,7 +26,7 @@ typedef struct {
 } analysis_options;
 
 void flac__analyze_init(analysis_options aopts);
-void flac__analyze_frame(const FLAC__Frame *frame, uint32_t frame_number, FLAC__uint64 frame_offset, uint32_t frame_bytes, analysis_options aopts, FILE *fout);
+void flac__analyze_frame(const FLAC__Frame *frame, uint32_t frame_number, FLAC__uint64 frame_offset, FLAC__uint64 frame_bytes, analysis_options aopts, FILE *fout);
 void flac__analyze_finish(analysis_options aopts);
 
 #endif
diff --git a/src/flac/decode.c b/src/flac/decode.c
index c26d3f60..7166d964 100644
--- a/src/flac/decode.c
+++ b/src/flac/decode.c
@@ -1007,7 +1007,7 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder
 		decoder_session->is_unsigned_samples
 	));
 	uint32_t wide_samples = frame->header.blocksize, wide_sample, sample, channel;
-	uint32_t frame_bytes = 0;
+	FLAC__uint64 frame_bytes = 0;
 
 	static union
 	{	/* The arrays defined within this union are all the same size. */
@@ -1117,7 +1117,7 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder
 	if(decoder_session->analysis_mode) {
 		FLAC__uint64 dpos;
 		FLAC__stream_decoder_get_decode_position(decoder_session->decoder, &dpos);
-		frame_bytes = (uint32_t)(dpos-decoder_session->decode_position);
+		frame_bytes = (dpos-decoder_session->decode_position);
 		decoder_session->decode_position = dpos;
 	}
 
-- 
2.20.1

From 4feff769ca3310e51760c5f69f05c3686f6d6aba Mon Sep 17 00:00:00 2001
From: Martijn van Beurden <mva...@gmail.com>
Date: Sun, 5 Jul 2020 19:42:39 +0200
Subject: [PATCH 3/3] Fix compression ratio display for very small files

Because the compression ratio was calculated before processing
the input of the last frame, it did not include the size of this
last frame. This patch moves the calculation of the compression
ratio after the new input has been processed. Now the compression
ratio on very small files is correctly displayed.
---
 src/flac/encode.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/flac/encode.c b/src/flac/encode.c
index a7fbfdf5..30543645 100644
--- a/src/flac/encode.c
+++ b/src/flac/encode.c
@@ -2463,14 +2463,14 @@ void encoder_progress_callback(const FLAC__StreamEncoder *encoder, FLAC__uint64
 
 	const FLAC__uint64 uesize = e->unencoded_size;
 
-	e->progress = e->total_samples_to_encode ? (double)samples_written / (double)e->total_samples_to_encode : 0;
-	e->compression_ratio = (e->progress && uesize) ? (double)e->bytes_written / ((double)uesize * min(1.0, e->progress)) : 0;
-
 	(void)encoder, (void)total_frames_estimate;
 
 	e->bytes_written = bytes_written;
 	e->samples_written = samples_written;
 
+	e->progress = e->total_samples_to_encode ? (double)samples_written / (double)e->total_samples_to_encode : 0;
+	e->compression_ratio = (e->progress && uesize) ? (double)e->bytes_written / ((double)uesize * min(1.0, e->progress)) : 0;
+
 	if(e->total_samples_to_encode > 0 && frames_written - e->old_frames_written > e->stats_frames_interval) {
 		print_stats(e);
 		e->old_frames_written = frames_written;
-- 
2.20.1

_______________________________________________
flac-dev mailing list
flac-dev@xiph.org
http://lists.xiph.org/mailman/listinfo/flac-dev

Reply via email to