flake-enc-svnlog Mailing List for Flake
Status: Beta
Brought to you by:
jbr79
You can subscribe to this list here.
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(7) |
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(4) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2009 |
Jan
(11) |
Feb
|
Mar
|
Apr
|
May
(5) |
Jun
(10) |
Jul
|
Aug
(6) |
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <jb...@us...> - 2009-08-30 21:18:54
|
Revision: 264
http://flake-enc.svn.sourceforge.net/flake-enc/?rev=264&view=rev
Author: jbr79
Date: 2009-08-30 21:18:45 +0000 (Sun, 30 Aug 2009)
Log Message:
-----------
update copyright year in commandline output
Modified Paths:
--------------
flake/flake.c
Modified: flake/flake.c
===================================================================
--- flake/flake.c 2009-08-30 20:59:41 UTC (rev 263)
+++ flake/flake.c 2009-08-30 21:18:45 UTC (rev 264)
@@ -742,7 +742,7 @@
if(!opts.quiet) {
fprintf(stderr, "\nFlake: FLAC audio encoder\n"
"Version %s\n"
- "(c) 2006-2007 Justin Ruggles\n\n",
+ "(c) 2006-2009 Justin Ruggles\n\n",
flake_get_version());
}
if(err == 2) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-08-30 20:59:49
|
Revision: 263
http://flake-enc.svn.sourceforge.net/flake-enc/?rev=263&view=rev
Author: jbr79
Date: 2009-08-30 20:59:41 +0000 (Sun, 30 Aug 2009)
Log Message:
-----------
Fix bug in 2/4/8LEVEL order search where index is off-by-1.
Thanks to Gregory Chudov for pointing out the bug.
Modified Paths:
--------------
libflake/optimize.c
Modified: libflake/optimize.c
===================================================================
--- libflake/optimize.c 2009-08-30 20:39:56 UTC (rev 262)
+++ libflake/optimize.c 2009-08-30 20:59:41 UTC (rev 263)
@@ -209,7 +209,7 @@
opt_order = max_order-1;
bits[opt_index] = UINT32_MAX;
for(i=opt_index; i>=0; i--) {
- order = min_order + (((max_order-min_order+1) * (i+1)) / levels)-1;
+ order = min_order + (((max_order-min_order+1) * (i+1)) / levels)-2;
if(order < 0) order = 0;
encode_residual_lpc(res, smp, n, order+1, coefs[order], shift[order]);
bits[i] = calc_rice_params_lpc(&sub->rc, min_porder, max_porder,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-08-30 20:40:04
|
Revision: 262
http://flake-enc.svn.sourceforge.net/flake-enc/?rev=262&view=rev
Author: jbr79
Date: 2009-08-30 20:39:56 +0000 (Sun, 30 Aug 2009)
Log Message:
-----------
factor out a common function from calc_rice_params_fixed() and
calc_rice_params_lpc()
Modified Paths:
--------------
libflake/rice.c
Modified: libflake/rice.c
===================================================================
--- libflake/rice.c 2009-08-30 20:30:41 UTC (rev 261)
+++ libflake/rice.c 2009-08-30 20:39:56 UTC (rev 262)
@@ -24,6 +24,7 @@
#include "common.h"
+#include "encode.h"
#include "rice.h"
int
@@ -153,28 +154,34 @@
return porder;
}
-uint32_t
-calc_rice_params_fixed(RiceContext *rc, int pmin, int pmax, int32_t *data,
- int n, int pred_order, int bps)
+static uint32_t calc_rice_params_common(RiceContext *rc, int pmin, int pmax,
+ int32_t *data, int n, int pred_order,
+ int bps, int precision,
+ FlakePrediction pred_type)
{
uint32_t bits;
pmin = limit_max_partition_order(pmin, n, pred_order);
pmax = limit_max_partition_order(pmax, n, pred_order);
bits = pred_order*bps + 2;
+ if (pred_type == FLAKE_PREDICTION_LEVINSON)
+ bits += 4 + 5 + pred_order*precision;
bits += calc_rice_params(rc, pmin, pmax, data, n, pred_order);
bits += rc->method + 4;
return bits;
}
uint32_t
+calc_rice_params_fixed(RiceContext *rc, int pmin, int pmax, int32_t *data,
+ int n, int pred_order, int bps)
+{
+ return calc_rice_params_common(rc, pmin, pmax, data, n, pred_order, bps, 0,
+ FLAKE_PREDICTION_FIXED);
+}
+
+uint32_t
calc_rice_params_lpc(RiceContext *rc, int pmin, int pmax, int32_t *data, int n,
int pred_order, int bps, int precision)
{
- uint32_t bits;
- pmin = limit_max_partition_order(pmin, n, pred_order);
- pmax = limit_max_partition_order(pmax, n, pred_order);
- bits = pred_order*bps + 4 + 5 + pred_order*precision + 2;
- bits += calc_rice_params(rc, pmin, pmax, data, n, pred_order);
- bits += rc->method + 4;
- return bits;
+ return calc_rice_params_common(rc, pmin, pmax, data, n, pred_order, bps,
+ precision, FLAKE_PREDICTION_LEVINSON);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-08-30 20:30:50
|
Revision: 261
http://flake-enc.svn.sourceforge.net/flake-enc/?rev=261&view=rev
Author: jbr79
Date: 2009-08-30 20:30:41 +0000 (Sun, 30 Aug 2009)
Log Message:
-----------
Calculate bits from entropy coding method after it has been set.
Thanks to Gregory Chudov for finding the bug.
Modified Paths:
--------------
libflake/rice.c
Modified: libflake/rice.c
===================================================================
--- libflake/rice.c 2009-08-30 20:26:37 UTC (rev 260)
+++ libflake/rice.c 2009-08-30 20:30:41 UTC (rev 261)
@@ -158,11 +158,11 @@
int n, int pred_order, int bps)
{
uint32_t bits;
- int param_bits = rc->method + 4;
pmin = limit_max_partition_order(pmin, n, pred_order);
pmax = limit_max_partition_order(pmax, n, pred_order);
- bits = pred_order*bps + 2 + param_bits;
+ bits = pred_order*bps + 2;
bits += calc_rice_params(rc, pmin, pmax, data, n, pred_order);
+ bits += rc->method + 4;
return bits;
}
@@ -171,10 +171,10 @@
int pred_order, int bps, int precision)
{
uint32_t bits;
- int param_bits = rc->method + 4;
pmin = limit_max_partition_order(pmin, n, pred_order);
pmax = limit_max_partition_order(pmax, n, pred_order);
- bits = pred_order*bps + 4 + 5 + pred_order*precision + 2 + param_bits;
+ bits = pred_order*bps + 4 + 5 + pred_order*precision + 2;
bits += calc_rice_params(rc, pmin, pmax, data, n, pred_order);
+ bits += rc->method + 4;
return bits;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-08-30 20:26:45
|
Revision: 260
http://flake-enc.svn.sourceforge.net/flake-enc/?rev=260&view=rev
Author: jbr79
Date: 2009-08-30 20:26:37 +0000 (Sun, 30 Aug 2009)
Log Message:
-----------
Move setting of entropy coding method to calc_optimal_rice_params().
Thanks to Gregory Chudov for finding the bug.
Modified Paths:
--------------
libflake/rice.c
Modified: libflake/rice.c
===================================================================
--- libflake/rice.c 2009-08-22 17:42:33 UTC (rev 259)
+++ libflake/rice.c 2009-08-30 20:26:37 UTC (rev 260)
@@ -51,6 +51,8 @@
int k, cnt, part;
uint32_t all_bits;
+ rc->method = ENCODING_METHOD_RICE;
+
part = (1 << porder);
all_bits = 0;
@@ -114,8 +116,6 @@
assert(pmax >= 0 && pmax <= MAX_PARTITION_ORDER);
assert(pmin <= pmax);
- rc->method = ENCODING_METHOD_RICE;
-
udata = malloc(n * sizeof(uint32_t));
for(i=0; i<n; i++) {
udata[i] = (2*data[i]) ^ (data[i]>>31);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-08-22 17:42:39
|
Revision: 259
http://flake-enc.svn.sourceforge.net/flake-enc/?rev=259&view=rev
Author: jbr79
Date: 2009-08-22 17:42:33 +0000 (Sat, 22 Aug 2009)
Log Message:
-----------
Pass max_order instead of max_order+1 to compute_lpc_coefs(). This avoids a
buffer overrun in the autoc[] array. Thanks to Gregory Chudov for pointing this
out.
Modified Paths:
--------------
libflake/lpc.c
Modified: libflake/lpc.c
===================================================================
--- libflake/lpc.c 2009-06-11 03:01:38 UTC (rev 258)
+++ libflake/lpc.c 2009-08-22 17:42:33 UTC (rev 259)
@@ -231,7 +231,7 @@
int i;
int opt_order;
- compute_autocorr(samples, blocksize, max_order+1, autoc);
+ compute_autocorr(samples, blocksize, max_order, autoc);
opt_order = max_order;
if(omethod == FLAKE_ORDER_METHOD_EST) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-06-11 03:01:45
|
Revision: 258
http://flake-enc.svn.sourceforge.net/flake-enc/?rev=258&view=rev
Author: jbr79
Date: 2009-06-11 03:01:38 +0000 (Thu, 11 Jun 2009)
Log Message:
-----------
cosmetics: indentation and remove unneeded braces
Modified Paths:
--------------
flake/flake.c
Modified: flake/flake.c
===================================================================
--- flake/flake.c 2009-06-11 03:01:02 UTC (rev 257)
+++ flake/flake.c 2009-06-11 03:01:38 UTC (rev 258)
@@ -442,9 +442,8 @@
for (i = (nr * channels) - 1; i >= 0; i--)
wav[i] = wav16[i] >> 8;
} else {
- for (i = (nr * channels) - 1; i >= 0; i--) {
- wav[i] = wav16[i];
- }
+ for (i = (nr * channels) - 1; i >= 0; i--)
+ wav[i] = wav16[i];
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-06-11 03:01:09
|
Revision: 257
http://flake-enc.svn.sourceforge.net/flake-enc/?rev=257&view=rev
Author: jbr79
Date: 2009-06-11 03:01:02 +0000 (Thu, 11 Jun 2009)
Log Message:
-----------
fix reading of 8-bit audio when using libsndfile
Modified Paths:
--------------
flake/flake.c
Modified: flake/flake.c
===================================================================
--- flake/flake.c 2009-06-11 01:19:51 UTC (rev 256)
+++ flake/flake.c 2009-06-11 03:01:02 UTC (rev 257)
@@ -437,9 +437,16 @@
} else {
int16_t *wav16 = (int16_t *)wav;
nr = sf_readf_short(sfctx, wav16, samples);
+ if (nr) {
+ if (bps == 8) {
+ for (i = (nr * channels) - 1; i >= 0; i--)
+ wav[i] = wav16[i] >> 8;
+ } else {
for (i = (nr * channels) - 1; i >= 0; i--) {
wav[i] = wav16[i];
}
+ }
+ }
}
return nr;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-06-11 01:20:52
|
Revision: 256
http://flake-enc.svn.sourceforge.net/flake-enc/?rev=256&view=rev
Author: jbr79
Date: 2009-06-11 01:19:51 +0000 (Thu, 11 Jun 2009)
Log Message:
-----------
document and rename the function which limits the maximum rice partition
order based on blocksize and lpc order.
Modified Paths:
--------------
libflake/rice.c
Modified: libflake/rice.c
===================================================================
--- libflake/rice.c 2009-06-08 00:17:05 UTC (rev 255)
+++ libflake/rice.c 2009-06-11 01:19:51 UTC (rev 256)
@@ -137,8 +137,15 @@
return bits[opt_porder];
}
+/**
+ * Constrain maximum partition order.
+ * The actual allowable maximum partition order for a particular subframe
+ * depends on the blocksize and the LPC order. Firstly, the blocksize must be
+ * an exact multiple of the number of partitions. Secondly, the partition size
+ * cannot be smaller than the LPC order.
+ */
static int
-get_max_p_order(int max_porder, int n, int order)
+limit_max_partition_order(int max_porder, int n, int order)
{
int porder = MIN(max_porder, log2i(n^(n-1)));
if(order > 0)
@@ -152,8 +159,8 @@
{
uint32_t bits;
int param_bits = rc->method + 4;
- pmin = get_max_p_order(pmin, n, pred_order);
- pmax = get_max_p_order(pmax, n, pred_order);
+ pmin = limit_max_partition_order(pmin, n, pred_order);
+ pmax = limit_max_partition_order(pmax, n, pred_order);
bits = pred_order*bps + 2 + param_bits;
bits += calc_rice_params(rc, pmin, pmax, data, n, pred_order);
return bits;
@@ -165,8 +172,8 @@
{
uint32_t bits;
int param_bits = rc->method + 4;
- pmin = get_max_p_order(pmin, n, pred_order);
- pmax = get_max_p_order(pmax, n, pred_order);
+ pmin = limit_max_partition_order(pmin, n, pred_order);
+ pmax = limit_max_partition_order(pmax, n, pred_order);
bits = pred_order*bps + 4 + 5 + pred_order*precision + 2 + param_bits;
bits += calc_rice_params(rc, pmin, pmax, data, n, pred_order);
return bits;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-06-08 02:28:32
|
Revision: 255
http://flake-enc.svn.sourceforge.net/flake-enc/?rev=255&view=rev
Author: jbr79
Date: 2009-06-08 00:17:05 +0000 (Mon, 08 Jun 2009)
Log Message:
-----------
Do not use a loop to initialize lpc_tmp in compute_lpc_coefs()
Modified Paths:
--------------
libflake/lpc.c
Modified: libflake/lpc.c
===================================================================
--- libflake/lpc.c 2009-06-08 00:11:37 UTC (rev 254)
+++ libflake/lpc.c 2009-06-08 00:17:05 UTC (rev 255)
@@ -80,9 +80,8 @@
{
int i, j, i2;
double r, err, tmp;
- double lpc_tmp[MAX_LPC_ORDER];
+ double lpc_tmp[MAX_LPC_ORDER] = {0,};
- for(i=0; i<max_order; i++) lpc_tmp[i] = 0;
err = 1.0;
if(autoc) {
err = autoc[0];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-06-08 00:11:44
|
Revision: 254
http://flake-enc.svn.sourceforge.net/flake-enc/?rev=254&view=rev
Author: jbr79
Date: 2009-06-08 00:11:37 +0000 (Mon, 08 Jun 2009)
Log Message:
-----------
suppress a gcc warning by using pointer subtraction instead of pointer
addition.
Modified Paths:
--------------
libflake/bitio.h
Modified: libflake/bitio.h
===================================================================
--- libflake/bitio.h 2009-06-08 00:06:27 UTC (rev 253)
+++ libflake/bitio.h 2009-06-08 00:11:37 UTC (rev 254)
@@ -87,7 +87,7 @@
assert(bits == 32 || val < (1U << bits));
if(bits == 0 || bw->eof) return;
- if((bw->buf_ptr+3) >= bw->buf_end) {
+ if(bw->buf_ptr >= bw->buf_end-3) {
bw->eof = 1;
return;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-06-08 00:06:40
|
Revision: 253
http://flake-enc.svn.sourceforge.net/flake-enc/?rev=253&view=rev
Author: jbr79
Date: 2009-06-08 00:06:27 +0000 (Mon, 08 Jun 2009)
Log Message:
-----------
Make the vbs flag and frame/sample count depend on the allow_vbs
parameter instead of variable_block_size.
Modified Paths:
--------------
libflake/encode.c
Modified: libflake/encode.c
===================================================================
--- libflake/encode.c 2009-06-07 23:02:49 UTC (rev 252)
+++ libflake/encode.c 2009-06-08 00:06:27 UTC (rev 253)
@@ -234,12 +234,14 @@
params->order_method = FLAKE_ORDER_METHOD_LOG;
params->max_prediction_order = 12;
params->max_partition_order = 8;
+ params->allow_vbs = 1;
params->variable_block_size = 1;
break;
case 10:
params->order_method = FLAKE_ORDER_METHOD_SEARCH;
params->max_prediction_order = 12;
params->max_partition_order = 8;
+ params->allow_vbs = 1;
params->variable_block_size = 1;
break;
case 11:
@@ -247,6 +249,7 @@
params->order_method = FLAKE_ORDER_METHOD_LOG;
params->max_prediction_order = 32;
params->max_partition_order = 8;
+ params->allow_vbs = 1;
params->variable_block_size = 1;
break;
case 12:
@@ -254,6 +257,7 @@
params->order_method = FLAKE_ORDER_METHOD_SEARCH;
params->max_prediction_order = 32;
params->max_partition_order = 8;
+ params->allow_vbs = 1;
params->variable_block_size = 1;
break;
}
@@ -356,12 +360,12 @@
if(params->variable_block_size < 0 || params->variable_block_size > 1) {
return -1;
}
+ if(params->variable_block_size > 0 && !params->allow_vbs) {
+ return -1;
+ }
- // don't allow block size of 16 in variable block size mode. this is a bug
- // in the spec which has been fixed in FLAC 1.2.0, but is not backwards
- // compatible. this constraint will be removed when Flake is updated to
- // the new spec version.
- if(bs == 16 && (params->variable_block_size > 0 || params->allow_vbs)) {
+ // don't allow block size of less than 128 in variable block size mode
+ if(bs < VBS_MIN_BLOCK_SIZE && params->allow_vbs) {
return -1;
}
@@ -722,7 +726,7 @@
bitwriter_writebits(ctx->bw, 15, 0x7FFC);
// new bitstream syntax for variable blocksize in FLAC 1.2.0
- bitwriter_writebits(ctx->bw, 1, ctx->params.variable_block_size > 0);
+ bitwriter_writebits(ctx->bw, 1, ctx->params.allow_vbs);
bitwriter_writebits(ctx->bw, 4, frame->bs_code[0]);
bitwriter_writebits(ctx->bw, 4, ctx->sr_code[0]);
@@ -963,7 +967,7 @@
ctx->max_frame_size = MAX(ctx->max_frame_size, bitwriter_count(ctx->bw));
if(frame_buffer != NULL) {
- if(ctx->params.variable_block_size || ctx->params.allow_vbs) {
+ if(ctx->params.allow_vbs) {
ctx->frame_count += ctx->frame.blocksize;
} else {
ctx->frame_count++;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-06-07 23:03:01
|
Revision: 252
http://flake-enc.svn.sourceforge.net/flake-enc/?rev=252&view=rev
Author: jbr79
Date: 2009-06-07 23:02:49 +0000 (Sun, 07 Jun 2009)
Log Message:
-----------
Add a doc subdirectory. Add a document detailing FLAC format constraints.
Added Paths:
-----------
doc/
doc/flac_constraints.txt
Added: doc/flac_constraints.txt
===================================================================
--- doc/flac_constraints.txt (rev 0)
+++ doc/flac_constraints.txt 2009-06-07 23:02:49 UTC (rev 252)
@@ -0,0 +1,162 @@
+
+FLAC Constraints
+
+
+================================================================================
+(c) 2009 Justin Ruggles
+This work is licensed under a Creative Commons Attribution-Share Alike 3.0
+Unported License. http://creativecommons.org/licenses/by-sa/3.0/
+================================================================================
+
+
+This document details the constraints on the source audio format parameters and
+encoding options in the FLAC format. There are 3 limiting factors, the FLAC
+bitstream format, the compression level, and Subset compatibility. Encoder and
+decoder limitations add additional constraints in practical use, but those are
+only noted in this document for informational purposes.
+
+
+Compression Level Compatibility Constraints
+===========================================
+
+Compression levels are not defined in the official FLAC format description, but
+the libFLAC compression levels are often used to describe compatibility in
+hardware implementations.
+
+ Level Blocksize Mid/Side LPC Type Max LPC Order Max Rice Order
+--------------------------------------------------------------------------------
+ 0 1152 No Fixed 4 3
+ 1/2 1152 Yes Fixed 4 3
+ 3 4096 No Adaptive 6 4
+ 4 4096 Yes Adaptive 8 4
+ 5 4096 Yes Adaptive 8 5
+ 6/7 4096 Yes Adaptive 8 6
+ 8 4096 Yes Adaptive 12 6
+ *9/10 4096(v) Yes Adaptive 12 8
+*11/12 8192(v) Yes Adaptive 32 8
+
+* = Flake only
+v = maximum blocksize in variable blocksize mode
+
+
+Subset Compatibility Constraints
+================================
+
+Quote from the FLAC Format Description:
+ FLAC specifies a subset of itself as the Subset format. The purpose of this
+ is to ensure that any streams encoded according to the Subset are truly
+ "streamable", meaning that a decoder that cannot seek within the stream can
+ still pick up in the middle of the stream and start decoding. It also makes
+ hardware decoder implementations more practical by limiting the encoding
+ parameters such that decoder buffer sizes and other resource requirements
+ can be easily determined. flac generates Subset streams by default unless
+ the "--lax" command-line option is used. The Subset makes the following
+ limitations on what may be used in the stream:
+ * The blocksize bits in the frame header must be 0001-1110. The
+ blocksize must be <=16384; if the sample rate is <= 48000Hz, the
+ blocksize must be <=4608.
+ * The sample rate bits in the frame header must be 0001-1110.
+ * The bits-per-sample bits in the frame header must be 001-111.
+ * If the sample rate is <= 48000Hz, the filter order in LPC subframes
+ must be less than or equal to 12, i.e. the subframe type bits in the
+ subframe header may not be 101100-111111.
+ * The Rice partition order in a Rice-coded residual section must be less
+ than or equal to 8.
+
+In practical terms, this means that compression levels 0 to 10 are Subset
+compatible for sample rates <= 48kHz, and compression levels 0 to 12 are Subset
+compatible for higher sample rates. There is also the additional constraint
+that the "get from STREAMINFO" values cannot be used for sample rate and sample
+size in the frame headers. This limits the possible sample sizes, but not the
+possible sample rates.
+
+The use of 32-bit sample sizes is not currently allowed in Subset compatible
+streams since the only way to specify it is in the STREAMINFO. The logical use
+of the reserved value of 7 for sample size would be for 32-bit, and 7 is
+included in the allowed values for Subset, but for now the value is still
+reserved.
+
+
+Detailed Summary of Constraints
+===============================
+
+Sample Size:
+ * The FLAC format supports from 4-bit to 32-bit sample sizes.
+ * libFLAC does not support encoding or decoding anything above 24-bit.
+ * Flake supports encoding up to 32-bit.
+ * FFmpeg supports decoding up to 32-bit, but 32-bit is only supported if
+ mid/side is disabled due to bitstream reader limitations.
+ * Only sample sizes of 8, 12, 16, 20, and 24 are Subset compatible.
+
+Channels:
+ * The number of channels can be from 1 to 8.
+ * Channel assignment is defined for 1 to 6 channels, but is undefined for
+ 7 or 8 channels. However, the flac reference encoder also has an option
+ for keeping the WAV header, which contains a channel mask to define
+ channel assignment.
+ * Channel order is defined for 1 to 6 channels as SMPTE/WAV order, but is
+ undefined for 7 or 8 channels.
+ * Mid/side coding can be used for stereo audio. It is not used for
+ compression levels 0 and 3.
+ * There is no limitation with regard to Subset compatibility on the number
+ of channels or the use of mid/side coding.
+
+Sample Rate:
+ * The sample rate can be from 1Hz to 655350Hz.
+ * The only Subset limitation is that the sample rate must be specified in
+ each frame, not just in the STREAMINFO.
+ * The sample rate determines Subset compatibility constraints for blocksize
+ and LPC order.
+
+Blocksize:
+ * The minimum blocksize is 16 samples, except for the last block which can
+ be as small as 1 sample.
+ * The maximum blocksize is 65535 samples.
+ * Subset compatible streams are limited to a blocksize of 4608 when the
+ sample rate is <= 48kHz or 16384 when the sample rate is > 48kHz.
+ * The FLAC format description specifies how to indicate variable blocksize,
+ and there are no constraints listed on its use.
+ * The libFLAC reference encoder does not use variable blocksize encoding,
+ but it is supported in the libFLAC decoder.
+ * Flake takes a cautious approach and only uses variable blocksize encoding
+ for compression levels which are specific to Flake.
+
+Subframe Type:
+ * There are 4 subframe types: Constant, Verbatim, Fixed LPC, and Adaptive
+ LPC.
+ * All subframe types are Subset compatible.
+ * No prediction or Rice coding is used in Constant and Verbatim subframes.
+ * All compression levels can use the Constant, Verbatim, and Fixed LPC
+ subframe types.
+ * Only compression levels > 2 use the Adaptive LPC subframe type.
+
+LPC Order:
+ * The prediction order in Fixed LPC mode can be 0 to 4.
+ * Order 0 in Fixed LPC mode does no prediction, but does allow for Rice
+ coding.
+ * Order 0 is not allowed in Adaptive LPC mode.
+ * The maximum order in Adaptive LPC mode is 32.
+ * If the sample rate is <= 48kHz, the LPC order must be <= 12 in order for
+ the stream to be Subset compatible.
+ * The maximum LPC order constraint varies between compression levels.
+
+Quantized LPC Coefficient Precision:
+ * The LPC coefficient precision can be from 1 to 15 bits.
+ * There is no additional constraint on LPC coefficient precision with
+ regard to Subset compatibility or compression level.
+ * By default, the libFLAC encoder adaptively chooses the precision based on
+ sample size and blocksize.
+
+Residual Encoding Method:
+ * There is no constraint on the selection of the residual encoding method.
+ * Both Flake and the libFLAC encoder adaptively choose RICE or RICE2 based
+ on which one compresses better for each subframe.
+
+Rice Partition Order:
+ * The minimum Rice order is 0, which corresponds to a single Rice parameter
+ being used for the entire subframe.
+ * The maximum Rice order is 15, which uses 32768 Rice parameters for the
+ subframe.
+ * The Rice order must be <= 8 in order for the stream to be Subset
+ compatible.
+ * The maximum Rice order constraint varies between compression levels.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-06-07 17:47:37
|
Revision: 251
http://flake-enc.svn.sourceforge.net/flake-enc/?rev=251&view=rev
Author: jbr79
Date: 2009-06-07 17:47:25 +0000 (Sun, 07 Jun 2009)
Log Message:
-----------
remove unused variable
Modified Paths:
--------------
libflake/encode.h
Modified: libflake/encode.h
===================================================================
--- libflake/encode.h 2009-06-06 03:53:14 UTC (rev 250)
+++ libflake/encode.h 2009-06-07 17:47:25 UTC (rev 251)
@@ -67,7 +67,6 @@
int verbatim_size;
int bs_code[2];
int ch_mode;
- int ch_order[2];
uint8_t crc8;
FlacSubframe subframes[FLAC_MAX_CH];
} FlacFrame;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-06-06 03:53:15
|
Revision: 250
http://flake-enc.svn.sourceforge.net/flake-enc/?rev=250&view=rev
Author: jbr79
Date: 2009-06-06 03:53:14 +0000 (Sat, 06 Jun 2009)
Log Message:
-----------
revert to using libpcm_io if libsndfile is not found
Modified Paths:
--------------
CMakeLists.txt
Modified: CMakeLists.txt
===================================================================
--- CMakeLists.txt 2009-06-06 03:41:42 UTC (rev 249)
+++ CMakeLists.txt 2009-06-06 03:53:14 UTC (rev 250)
@@ -139,6 +139,10 @@
# check for libsndfile
IF(USE_LIBSNDFILE)
CHECK_LIBSNDFILE_DEFINE(HAVE_LIBSNDFILE)
+IF(NOT HAVE_LIBSNDFILE)
+MESSAGE(STATUS "libsndfile not found. using libpcm_io instead.")
+SET(USE_LIBSNDFILE FALSE)
+ENDIF(NOT HAVE_LIBSNDFILE)
ENDIF(USE_LIBSNDFILE)
# output SVN version to config.h
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-06-06 03:41:44
|
Revision: 249
http://flake-enc.svn.sourceforge.net/flake-enc/?rev=249&view=rev
Author: jbr79
Date: 2009-06-06 03:41:42 +0000 (Sat, 06 Jun 2009)
Log Message:
-----------
add support for using libsndfile instead of libpcm_io. since it has not
been extensively tested, it is not enabled by default. to use it,
configure with the CMake option -DUSE_LIBSNDFILE=yes
Modified Paths:
--------------
CMakeLists.txt
Changelog
flake/flake.c
Added Paths:
-----------
CMakeModules/Libsndfile.cmake
Modified: CMakeLists.txt
===================================================================
--- CMakeLists.txt 2009-05-20 02:35:40 UTC (rev 248)
+++ CMakeLists.txt 2009-06-06 03:41:42 UTC (rev 249)
@@ -4,6 +4,9 @@
# CMake files written by Prakash Punnoor
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
+IF(COMMAND cmake_policy)
+ cmake_policy(SET CMP0003 NEW)
+ENDIF(COMMAND cmake_policy)
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules")
Project(Flake C)
@@ -26,8 +29,10 @@
INCLUDE(${CMAKE_MODULE_PATH}/FlagsTests.cmake)
INCLUDE(${CMAKE_MODULE_PATH}/CompilerVisibility.cmake)
INCLUDE(${CMAKE_MODULE_PATH}/DetectCompiler.cmake)
+INCLUDE(${CMAKE_MODULE_PATH}/Libsndfile.cmake)
OPTION(SHARED "build shared Flake library" OFF)
+OPTION(USE_LIBSNDFILE "use libsndfile library for audio input" OFF)
INCLUDE_DIRECTORIES(${Flake_BINARY_DIR}/)
INCLUDE_DIRECTORIES(${Flake_SOURCE_DIR}/)
@@ -131,6 +136,11 @@
CHECK_INCLUDE_FILE_DEFINE(byteswap.h HAVE_BYTESWAP_H)
CHECK_FUNCTION_DEFINE("#include <string.h>" "strnlen" "(\"help\", 6)" HAVE_STRNLEN)
+# check for libsndfile
+IF(USE_LIBSNDFILE)
+CHECK_LIBSNDFILE_DEFINE(HAVE_LIBSNDFILE)
+ENDIF(USE_LIBSNDFILE)
+
# output SVN version to config.h
EXECUTE_PROCESS(COMMAND svn info --xml WORKING_DIRECTORY ${Flake_SOURCE_DIR}
OUTPUT_VARIABLE SVN_INFO ERROR_QUIET)
@@ -160,7 +170,9 @@
TARGET_LINK_LIBRARIES(flake_static ${LIBM} ${ADD_LIBS})
# building a separate static lib for the pcm audio decoder
+IF(NOT USE_LIBSNDFILE)
ADD_LIBRARY(pcm_io STATIC ${LIBPCM_IO_SRCS})
+ENDIF(NOT USE_LIBSNDFILE)
ADD_EXECUTABLE(flake_exe ${FLAKE_SRCS})
SET_TARGET_PROPERTIES(flake_exe PROPERTIES OUTPUT_NAME flake)
@@ -169,12 +181,22 @@
# When linking to static lib, dllimport mustn't be used
SET_TARGET_PROPERTIES(flake_exe PROPERTIES COMPILE_FLAGS -DFLAKE_BUILD_LIBRARY)
ENDIF(WIN32)
+IF(USE_LIBSNDFILE)
+TARGET_LINK_LIBRARIES(flake_exe flake_static)
+ELSE(USE_LIBSNDFILE)
TARGET_LINK_LIBRARIES(flake_exe pcm_io flake_static)
+ENDIF(USE_LIBSNDFILE)
+IF(NOT USE_LIBSNDFILE)
ADD_EXECUTABLE(wavinfo util/wavinfo.c)
TARGET_LINK_LIBRARIES(wavinfo pcm_io)
+ENDIF(NOT USE_LIBSNDFILE)
-INSTALL(TARGETS ${INSTALL_TARGETS} flake_exe wavinfo
+SET(INSTALL_TARGETS ${INSTALL_TARGETS} flake_exe)
+IF(NOT USE_LIBSNDFILE)
+SET(INSTALL_TARGETS ${INSTALL_TARGETS} wavinfo)
+ENDIF(NOT USE_LIBSNDFILE)
+INSTALL(TARGETS ${INSTALL_TARGETS}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
Added: CMakeModules/Libsndfile.cmake
===================================================================
--- CMakeModules/Libsndfile.cmake (rev 0)
+++ CMakeModules/Libsndfile.cmake 2009-06-06 03:41:42 UTC (rev 249)
@@ -0,0 +1,19 @@
+MACRO(CHECK_LIBSNDFILE_DEFINE VAR)
+SET(CMAKE_REQUIRED_LIBRARIES "-lsndfile")
+CHECK_C_SOURCE_COMPILES(
+"
+#include <sndfile.h>
+int main(){
+ char buffer[128];
+ sf_command(NULL, SFC_GET_LIB_VERSION, buffer, sizeof(buffer));
+#ifndef SNDFILE_1
+#error \"Version 1.0.X required.\"
+#endif
+}
+" ${VAR})
+IF(${VAR})
+ ADD_DEFINE("${VAR} 1")
+ SET(ADD_LIBS "${ADD_LIBS}-lsndfile")
+ENDIF(${VAR})
+SET(CMAKE_REQUIRED_LIBRARIES "")
+ENDMACRO(CHECK_LIBSNDFILE_DEFINE)
Modified: Changelog
===================================================================
--- Changelog 2009-05-20 02:35:40 UTC (rev 248)
+++ Changelog 2009-06-06 03:41:42 UTC (rev 249)
@@ -12,6 +12,8 @@
- API changed so that flake_encode_frame() takes 32-bit ints instead of 16-bit
- Added support for lossless encoding of all valid FLAC bit depths (4 to 32)
- Added support for RICE2 entropy coding
+- Added a compile-time option (USE_LIBSNDFILE) for using libsndfile instead of
+ libpcm_io for reading the input files
version 0.11 : 5 August 2007
- Significant speed improvements
Modified: flake/flake.c
===================================================================
--- flake/flake.c 2009-05-20 02:35:40 UTC (rev 248)
+++ flake/flake.c 2009-06-06 03:41:42 UTC (rev 249)
@@ -17,6 +17,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+/* required for fileno() */
+#define _XOPEN_SOURCE
+
#include "common.h"
#include <limits.h>
@@ -27,8 +30,14 @@
#include <io.h>
#endif
+/* libsndfile */
+#if HAVE_LIBSNDFILE
+#include <sndfile.h>
+#else
+#include "pcm_io.h"
+#endif
+
#include "bswap.h"
-#include "pcm_io.h"
#include "flake.h"
#ifndef PATH_MAX
@@ -38,14 +47,14 @@
static void
print_usage(FILE *out)
{
- fprintf(out, "usage: flake [options] <input.wav> [-o output.flac]\n"
+ fprintf(out, "usage: flake [options] <input> [-o output.flac]\n"
"type 'flake -h' for more details.\n\n");
}
static void
print_help(FILE *out)
{
- fprintf(out, "usage: flake [options] <input.wav> [-o output.flac]\n"
+ fprintf(out, "usage: flake [options] <input> [-o output.flac]\n"
"options:\n"
" [-h] Print out list of commandline options\n"
" [-q] Quiet mode: no console output\n"
@@ -353,11 +362,134 @@
fprintf(stderr, "header padding: %d\n", s->params.padding_size);
}
+#if HAVE_LIBSNDFILE
+typedef SNDFILE PcmContext;
+typedef SF_INFO PcmInfo;
+
static int
+pcm_init_sndfile(PcmContext **ctx, PcmInfo *info, FILE *ifp, FlakeContext *s)
+{
+ *ctx = sf_open_fd(fileno(ifp), SFM_READ, info, 0);
+ if (!*ctx)
+ return -1;
+
+ // set parameters from input audio
+ s->channels = info->channels;
+ s->sample_rate = info->samplerate;
+ switch (info->format & SF_FORMAT_SUBMASK) {
+ case SF_FORMAT_PCM_S8:
+ case SF_FORMAT_PCM_U8: s->bits_per_sample = 8; break;
+ case SF_FORMAT_PCM_16: s->bits_per_sample = 16; break;
+ case SF_FORMAT_PCM_24: s->bits_per_sample = 24; break;
+ case SF_FORMAT_PCM_32: s->bits_per_sample = 32; break;
+ default:
+ fprintf(stderr, "sample format not supported.\n");
+ sf_close(*ctx);
+ return -1;
+ }
+ s->samples = MIN(info->frames, UINT32_MAX);
+ return 0;
+}
+
+#else
+typedef PcmFile PcmContext;
+typedef void PcmInfo;
+
+static int
+pcm_init_pcmio(PcmContext *ctx, FILE *ifp, FlakeContext *s)
+{
+ if(pcmfile_init(ctx, ifp, PCM_SAMPLE_FMT_S32, PCM_FORMAT_UNKNOWN))
+ return 1;
+
+ // set parameters from input audio
+ s->channels = ctx->channels;
+ s->sample_rate = ctx->sample_rate;
+ s->bits_per_sample = ctx->bit_width;
+ s->samples = MIN(ctx->samples, UINT32_MAX);
+ return 0;
+}
+
+#endif /* !HAVE_LIBSNDFILE */
+
+static int
+pcm_init(PcmContext **ctx, PcmInfo *info, FILE *ifp, FlakeContext *s)
+{
+#if HAVE_LIBSNDFILE
+ return pcm_init_sndfile(ctx, info, ifp, s);
+#else
+ return pcm_init_pcmio(*ctx, ifp, s);
+#endif
+}
+
+#if HAVE_LIBSNDFILE
+static int
+sndfile_read_samples(SNDFILE *sfctx, int32_t *wav, int bps, int channels,
+ int samples)
+{
+ int i, nr=0;
+ if (bps > 16) {
+ nr = sf_readf_int(sfctx, wav, samples);
+ if (nr && bps == 24) {
+ for (i = 0; i < nr * channels; i++) {
+ wav[i] >>= 8;
+ }
+ }
+ } else {
+ int16_t *wav16 = (int16_t *)wav;
+ nr = sf_readf_short(sfctx, wav16, samples);
+ for (i = (nr * channels) - 1; i >= 0; i--) {
+ wav[i] = wav16[i];
+ }
+ }
+ return nr;
+}
+
+static void
+sndfile_print(SF_INFO *info, FILE *st)
+{
+ SF_FORMAT_INFO format_info;
+ const char *chan, *fmt, *order;
+ int bps=0;
+
+ if(st == NULL || info == NULL) return;
+
+ chan = "?-channel";
+ fmt = "unknown";
+ order = "?-endian";
+
+ switch (info->channels) {
+ case 1: chan = "mono"; break;
+ case 2: chan = "stereo"; break;
+ case 3: chan = "3-channel"; break;
+ case 4: chan = "4-channel"; break;
+ case 5: chan = "5-channel"; break;
+ case 6: chan = "6-channel"; break;
+ case 7: chan = "7-channel"; break;
+ case 8: chan = "8-channel"; break;
+ default: chan = "multi-channel"; break;
+ }
+
+ format_info.format = info->format & SF_FORMAT_TYPEMASK;
+ sf_command(NULL, SFC_GET_FORMAT_INFO, &format_info, sizeof(format_info));
+ fmt = format_info.name;
+
+ switch (info->format & SF_FORMAT_SUBMASK) {
+ case SF_FORMAT_PCM_S8:
+ case SF_FORMAT_PCM_U8: bps = 8; break;
+ case SF_FORMAT_PCM_16: bps = 16; break;
+ case SF_FORMAT_PCM_24: bps = 24; break;
+ case SF_FORMAT_PCM_32: bps = 32; break;
+ }
+
+ fprintf(st, "%s %d-bit %d Hz %s\n", fmt, bps, info->samplerate, chan);
+}
+
+#endif
+
+static int
encode_file(CommandOptions *opts, FilePair *files, int first_file)
{
FlakeContext s;
- PcmFile wf;
int header_size, subset;
uint8_t *frame;
int32_t *wav;
@@ -365,19 +497,23 @@
int fs;
uint32_t nr, samplecount, bytecount;
float kb, sec, kbps, wav_bytes;
+ int block_align;
+ PcmContext *ctx=NULL;
+#if HAVE_LIBSNDFILE
+ SF_INFO info1;
+ SF_INFO *info = &info1;
+#else
+ PcmFile ctx1;
+ void *info = NULL;
+ ctx = &ctx1;
+#endif
- if(pcmfile_init(&wf, files->ifp, PCM_SAMPLE_FMT_S32, PCM_FORMAT_UNKNOWN)) {
- fprintf(stderr, "invalid input file: %s\n", files->infile);
+ if (pcm_init(&ctx, info, files->ifp, &s)) {
+ fprintf(stderr, "\ninvalid input file: %s\n", files->infile);
return 1;
}
+ block_align = s.bits_per_sample * s.channels / 8;
- // set parameters from input audio
- s.channels = wf.channels;
- s.sample_rate = wf.sample_rate;
- s.bits_per_sample = wf.bit_width;
- // TODO: FLAC supports values up to 36-bits for number of samples, but libflake only uses a 32-bit value
- s.samples = MIN(wf.samples, UINT32_MAX);
-
// set parameters from commandline
s.params.compression = opts->compr;
if(flake_set_defaults(&s.params)) {
@@ -442,18 +578,22 @@
fprintf(stderr, "\n");
fprintf(stderr, "input file: \"%s\"\n", files->infile);
fprintf(stderr, "output file: \"%s\"\n", files->outfile);
- pcmfile_print(&wf, stderr);
- if(wf.samples > 0) {
+#if HAVE_LIBSNDFILE
+ sndfile_print(info, stderr);
+#else
+ pcmfile_print(ctx, stderr);
+#endif
+ if(s.samples > 0) {
int64_t tms;
int th, tm, ts;
- tms = (int64_t)(wf.samples * 1000.0 / wf.sample_rate);
+ tms = (int64_t)(s.samples * 1000.0 / s.sample_rate);
ts = tms / 1000;
tms = tms % 1000;
tm = ts / 60;
ts = ts % 60;
th = tm / 60;
tm = tm % 60;
- fprintf(stderr, "samples: %"PRIu64" (", wf.samples);
+ fprintf(stderr, "samples: %"PRIu32" (", s.samples);
if(th) fprintf(stderr, "%dh", th);
fprintf(stderr, "%dm", tm);
fprintf(stderr, "%d.%03ds)\n", ts, (int)tms);
@@ -464,13 +604,25 @@
}
frame = flake_get_buffer(&s);
- wav = malloc(s.params.block_size * wf.channels * sizeof(int32_t));
+ wav = malloc(s.params.block_size * s.channels * sizeof(int32_t));
samplecount = percent = 0;
wav_bytes = 0;
bytecount = header_size;
- nr = pcmfile_read_samples(&wf, wav, s.params.block_size);
+#if HAVE_LIBSNDFILE
+ nr = sndfile_read_samples(ctx, wav, s.bits_per_sample, s.channels,
+ s.params.block_size);
+#else
+ nr = pcmfile_read_samples(ctx, wav, s.params.block_size);
+#endif
while(nr > 0) {
+ /*unsigned int z,ch;
+ for (z = 0; z < nr; z++) {
+ fprintf(stderr, "\n");
+ for (ch = 0; ch < s.channels; ch++) {
+ fprintf(stderr, "%-5d", wav[z*s.channels+ch]);
+ }
+ }*/
fs = flake_encode_frame(&s, wav, nr);
if(fs < 0) {
fprintf(stderr, "\nError encoding frame\n");
@@ -488,7 +640,7 @@
if(s.samples > 0) {
percent = ((samplecount * 100.5) / s.samples);
}
- wav_bytes = samplecount*wf.block_align;
+ wav_bytes = samplecount * block_align;
if(!opts->quiet) {
fprintf(stderr, "\rprogress: %3d%% | ratio: %1.3f | "
"bitrate: %4.1f kbps ",
@@ -496,7 +648,12 @@
}
}
}
- nr = pcmfile_read_samples(&wf, wav, s.params.block_size);
+#if HAVE_LIBSNDFILE
+ nr = sndfile_read_samples(ctx, wav, s.bits_per_sample, s.channels,
+ s.params.block_size);
+#else
+ nr = pcmfile_read_samples(ctx, wav, s.params.block_size);
+#endif
}
if(!opts->quiet) {
fprintf(stderr, "| bytes: %d \n\n", bytecount);
@@ -514,7 +671,11 @@
}
}
- pcmfile_close(&wf);
+#if HAVE_LIBSNDFILE
+ sf_close(ctx);
+#else
+ pcmfile_close(ctx);
+#endif
flake_encode_close(&s);
free(wav);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-05-20 02:35:47
|
Revision: 248
http://flake-enc.svn.sourceforge.net/flake-enc/?rev=248&view=rev
Author: jbr79
Date: 2009-05-20 02:35:40 +0000 (Wed, 20 May 2009)
Log Message:
-----------
faster counting of wasted bits
Modified Paths:
--------------
libflake/encode.c
Modified: libflake/encode.c
===================================================================
--- libflake/encode.c 2009-05-20 01:09:12 UTC (rev 247)
+++ libflake/encode.c 2009-05-20 02:35:40 UTC (rev 248)
@@ -564,17 +564,17 @@
wasted = ctx->bps-1;
samples = frame->subframes[ch].samples;
for (i = 0; i < frame->blocksize; i++) {
- int32_t s = samples[i];
- uint32_t mask = 0x1;
- for (b = 0; b <= wasted; b++) {
- if (s & mask)
+ uint32_t s = samples[i];
+ if (s) {
+ s = (s ^ (s - 1)) >> 1;
+ for (b = 0; s; b++) {
+ s >>= 1;
+ }
+ if (b < wasted)
+ wasted = b;
+ if (!wasted)
break;
- mask <<= 1;
}
- if (b < wasted)
- wasted = b;
- if (!wasted)
- break;
}
if (wasted == ctx->bps-1) {
wasted = 0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-05-20 01:09:21
|
Revision: 247
http://flake-enc.svn.sourceforge.net/flake-enc/?rev=247&view=rev
Author: jbr79
Date: 2009-05-20 01:09:12 +0000 (Wed, 20 May 2009)
Log Message:
-----------
remove unneeded line
Modified Paths:
--------------
libflake/encode.c
Modified: libflake/encode.c
===================================================================
--- libflake/encode.c 2009-05-20 00:44:29 UTC (rev 246)
+++ libflake/encode.c 2009-05-20 01:09:12 UTC (rev 247)
@@ -496,7 +496,6 @@
}
// get block size codes
- i = 15;
for(i=0; i<15; i++) {
if(block_size == flac_blocksizes[i]) {
frame->blocksize = flac_blocksizes[i];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-05-20 00:44:37
|
Revision: 246
http://flake-enc.svn.sourceforge.net/flake-enc/?rev=246&view=rev
Author: jbr79
Date: 2009-05-20 00:44:29 +0000 (Wed, 20 May 2009)
Log Message:
-----------
add support for shifting out wasted low-order bits
Modified Paths:
--------------
libflake/encode.c
libflake/encode.h
Modified: libflake/encode.c
===================================================================
--- libflake/encode.c 2009-05-19 23:43:18 UTC (rev 245)
+++ libflake/encode.c 2009-05-20 00:44:29 UTC (rev 246)
@@ -526,6 +526,7 @@
// initialize output bps for each channel
for(ch=0; ch<ctx->channels; ch++) {
frame->subframes[ch].obits = ctx->bps;
+ frame->subframes[ch].wasted_bits = 0;
}
return 0;
@@ -549,6 +550,46 @@
}
/**
+ * Shift out any zero bits and set the wasted_bits parameter.
+ */
+static void
+remove_wasted_bits(FlacEncodeContext *ctx)
+{
+ int i, ch, b;
+ int wasted;
+ FlacFrame *frame;
+ int32_t *samples;
+
+ frame = &ctx->frame;
+ for (ch = 0; ch < ctx->channels; ch++) {
+ wasted = ctx->bps-1;
+ samples = frame->subframes[ch].samples;
+ for (i = 0; i < frame->blocksize; i++) {
+ int32_t s = samples[i];
+ uint32_t mask = 0x1;
+ for (b = 0; b <= wasted; b++) {
+ if (s & mask)
+ break;
+ mask <<= 1;
+ }
+ if (b < wasted)
+ wasted = b;
+ if (!wasted)
+ break;
+ }
+ if (wasted == ctx->bps-1) {
+ wasted = 0;
+ } else if (wasted) {
+ for (i = 0; i < frame->blocksize; i++) {
+ samples[i] >>= wasted;
+ }
+ frame->subframes[ch].obits -= wasted;
+ }
+ frame->subframes[ch].wasted_bits = wasted;
+ }
+}
+
+/**
* Estimate the best stereo decorrelation mode
*/
static int
@@ -838,7 +879,13 @@
// subframe header
bitwriter_writebits(ctx->bw, 1, 0);
bitwriter_writebits(ctx->bw, 6, frame->subframes[ch].type_code);
- bitwriter_writebits(ctx->bw, 1, 0);
+ if (frame->subframes[ch].wasted_bits) {
+ bitwriter_writebits(ctx->bw, 1, 1);
+ bitwriter_writebits(ctx->bw, frame->subframes[ch].wasted_bits-1, 0);
+ bitwriter_writebits(ctx->bw, 1, 1);
+ } else {
+ bitwriter_writebits(ctx->bw, 1, 0);
+ }
// subframe
switch(frame->subframes[ch].type) {
@@ -883,6 +930,8 @@
channel_decorrelation(ctx);
+ remove_wasted_bits(ctx);
+
for(ch=0; ch<ctx->channels; ch++) {
if(encode_residual(ctx, ch) < 0) {
return -1;
Modified: libflake/encode.h
===================================================================
--- libflake/encode.h 2009-05-19 23:43:18 UTC (rev 245)
+++ libflake/encode.h 2009-05-20 00:44:29 UTC (rev 246)
@@ -52,6 +52,7 @@
typedef struct FlacSubframe {
int type;
int type_code;
+ int wasted_bits;
int order;
int obits;
int32_t coefs[MAX_LPC_ORDER];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-05-19 23:43:26
|
Revision: 245
http://flake-enc.svn.sourceforge.net/flake-enc/?rev=245&view=rev
Author: jbr79
Date: 2009-05-19 23:43:18 +0000 (Tue, 19 May 2009)
Log Message:
-----------
Use new bitstream syntax for variable blocksize. This was introduced in FLAC
1.2.0, so older decoders will not support it.
Modified Paths:
--------------
libflake/encode.c
Modified: libflake/encode.c
===================================================================
--- libflake/encode.c 2009-05-19 23:28:38 UTC (rev 244)
+++ libflake/encode.c 2009-05-19 23:43:18 UTC (rev 245)
@@ -681,10 +681,8 @@
bitwriter_writebits(ctx->bw, 15, 0x7FFC);
- // new bitstream syntax in FLAC 1.2.0 - don't activate until the
- // reference encoder actually uses it (supports variable blocksize)
- bitwriter_writebits(ctx->bw, 1, 0);
- //bitwriter_writebits(ctx->bw, 1, ctx->params.variable_block_size > 0);
+ // new bitstream syntax for variable blocksize in FLAC 1.2.0
+ bitwriter_writebits(ctx->bw, 1, ctx->params.variable_block_size > 0);
bitwriter_writebits(ctx->bw, 4, frame->bs_code[0]);
bitwriter_writebits(ctx->bw, 4, ctx->sr_code[0]);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-05-19 23:28:52
|
Revision: 244
http://flake-enc.svn.sourceforge.net/flake-enc/?rev=244&view=rev
Author: jbr79
Date: 2009-05-19 23:28:38 +0000 (Tue, 19 May 2009)
Log Message:
-----------
reverse parameters in fwrite(). fixes printing of false error messages.
Modified Paths:
--------------
flake/flake.c
Modified: flake/flake.c
===================================================================
--- flake/flake.c 2009-01-01 17:33:07 UTC (rev 243)
+++ flake/flake.c 2009-05-19 23:28:38 UTC (rev 244)
@@ -420,7 +420,7 @@
fprintf(stderr, "Error initializing encoder.\n");
return 1;
}
- if (fwrite(s.header, 1, header_size, files->ofp) != 1) {
+ if (fwrite(s.header, header_size, 1, files->ofp) != 1) {
fprintf(stderr, "\nError writing header to output\n");
}
@@ -475,7 +475,7 @@
if(fs < 0) {
fprintf(stderr, "\nError encoding frame\n");
} else if(fs > 0) {
- if(fwrite(frame, 1, fs, files->ofp) != 1) {
+ if(fwrite(frame, fs, 1, files->ofp) != 1) {
fprintf(stderr, "\nError writing frame to output\n");
}
samplecount = MAX(samplecount, samplecount+nr);
@@ -508,7 +508,7 @@
if(!flake_get_streaminfo(&s, &strminfo)) {
uint8_t strminfo_data[34];
flake_write_streaminfo(&strminfo, strminfo_data);
- if (fwrite(strminfo_data, 1, 34, files->ofp) != 1) {
+ if (fwrite(strminfo_data, 34, 1, files->ofp) != 1) {
fprintf(stderr, "\nError writing header to output\n");
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-01-01 17:33:11
|
Revision: 243
http://flake-enc.svn.sourceforge.net/flake-enc/?rev=243&view=rev
Author: jbr79
Date: 2009-01-01 17:33:07 +0000 (Thu, 01 Jan 2009)
Log Message:
-----------
silence some gcc warnings
Modified Paths:
--------------
flake/flake.c
util/wavinfo.c
Modified: flake/flake.c
===================================================================
--- flake/flake.c 2009-01-01 17:07:55 UTC (rev 242)
+++ flake/flake.c 2009-01-01 17:33:07 UTC (rev 243)
@@ -420,7 +420,9 @@
fprintf(stderr, "Error initializing encoder.\n");
return 1;
}
- fwrite(s.header, 1, header_size, files->ofp);
+ if (fwrite(s.header, 1, header_size, files->ofp) != 1) {
+ fprintf(stderr, "\nError writing header to output\n");
+ }
// print encoding parameters
if(first_file && !opts->quiet) {
@@ -451,7 +453,7 @@
ts = ts % 60;
th = tm / 60;
tm = tm % 60;
- fprintf(stderr, "samples: %llu (", wf.samples);
+ fprintf(stderr, "samples: %"PRIu64" (", wf.samples);
if(th) fprintf(stderr, "%dh", th);
fprintf(stderr, "%dm", tm);
fprintf(stderr, "%d.%03ds)\n", ts, (int)tms);
@@ -473,7 +475,9 @@
if(fs < 0) {
fprintf(stderr, "\nError encoding frame\n");
} else if(fs > 0) {
- fwrite(frame, 1, fs, files->ofp);
+ if(fwrite(frame, 1, fs, files->ofp) != 1) {
+ fprintf(stderr, "\nError writing frame to output\n");
+ }
samplecount = MAX(samplecount, samplecount+nr);
if(!opts->quiet) {
bytecount += fs;
@@ -504,7 +508,9 @@
if(!flake_get_streaminfo(&s, &strminfo)) {
uint8_t strminfo_data[34];
flake_write_streaminfo(&strminfo, strminfo_data);
- fwrite(strminfo_data, 1, 34, files->ofp);
+ if (fwrite(strminfo_data, 1, 34, files->ofp) != 1) {
+ fprintf(stderr, "\nError writing header to output\n");
+ }
}
}
Modified: util/wavinfo.c
===================================================================
--- util/wavinfo.c 2009-01-01 17:07:55 UTC (rev 242)
+++ util/wavinfo.c 2009-01-01 17:33:07 UTC (rev 243)
@@ -284,7 +284,7 @@
printf("File:\n");
printf(" Name: %s\n", wi->fname);
if(wf->seekable) {
- printf(" File Size: %lld\n", wf->file_size);
+ printf(" File Size: %"PRIu64"\n", wf->file_size);
} else {
printf(" File Size: unknown\n");
}
@@ -300,8 +300,8 @@
printf(" Block Align: %d bytes\n", wf->block_align);
printf(" Bit Width: %d\n", wf->bit_width);
printf("Data:\n");
- printf(" Start: %lld\n", wf->data_start);
- printf(" Data Size: %lld\n", wf->data_size);
+ printf(" Start: %"PRIu64"\n", wf->data_start);
+ printf(" Data Size: %"PRIu64"\n", wf->data_size);
leftover = wf->file_size - wf->data_size - wf->data_start;
if(leftover < 0) {
if(!wf->seekable) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-01-01 17:07:58
|
Revision: 242
http://flake-enc.svn.sourceforge.net/flake-enc/?rev=242&view=rev
Author: jbr79
Date: 2009-01-01 17:07:55 +0000 (Thu, 01 Jan 2009)
Log Message:
-----------
cosmetics: add some comments
Modified Paths:
--------------
libflake/md5.c
Modified: libflake/md5.c
===================================================================
--- libflake/md5.c 2009-01-01 17:07:48 UTC (rev 241)
+++ libflake/md5.c 2009-01-01 17:07:55 UTC (rev 242)
@@ -295,6 +295,7 @@
bytes_per_sample = (bps + 7) >> 3;
data_bytes = ch * nsamples * bytes_per_sample;
+ /* allocate data buffer, if needed */
if (ctx->data_buffer_size < data_bytes) {
ctx->data_buffer_size = 0;
ctx->data_buffer = realloc(ctx->data_buffer, data_bytes);
@@ -303,6 +304,7 @@
ctx->data_buffer_size = data_bytes;
}
+ /* convert sample values to little-endian raw audio data */
k = 0;
for (i = 0; i < nsamples * ch; i++) {
int32_t x = le2me_32(signal[i]);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-01-01 17:07:54
|
Revision: 240
http://flake-enc.svn.sourceforge.net/flake-enc/?rev=240&view=rev
Author: jbr79
Date: 2009-01-01 17:07:41 +0000 (Thu, 01 Jan 2009)
Log Message:
-----------
use all 64 bits for START/STOP_TIMER
Modified Paths:
--------------
common.h
Modified: common.h
===================================================================
--- common.h 2009-01-01 16:35:00 UTC (rev 239)
+++ common.h 2009-01-01 17:07:41 UTC (rev 240)
@@ -83,10 +83,14 @@
#if 0 /* TIMER USED FOR TESTING */
static inline long long read_time(void)
{
- long long l;
- __asm__ __volatile__("rdtsc\n\t"
- : "=A" (l));
- return l;
+ union {
+ long x1[2];
+ long long x;
+ } l;
+ __asm__ __volatile__("rdtsc"
+ : "=a" (l.x1[0]),
+ "=d" (l.x1[1]));
+ return l.x;
}
#define START_TIMER \
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-01-01 17:07:52
|
Revision: 241
http://flake-enc.svn.sourceforge.net/flake-enc/?rev=241&view=rev
Author: jbr79
Date: 2009-01-01 17:07:48 +0000 (Thu, 01 Jan 2009)
Log Message:
-----------
faster conversion of sample data in MD5 calculation
Modified Paths:
--------------
libflake/md5.c
Modified: libflake/md5.c
===================================================================
--- libflake/md5.c 2009-01-01 17:07:41 UTC (rev 240)
+++ libflake/md5.c 2009-01-01 17:07:48 UTC (rev 241)
@@ -282,7 +282,7 @@
md5_accumulate(MD5Context *ctx, const int32_t *signal, int ch, int bps,
int nsamples)
{
- int i, j, k;
+ int i, k;
int bytes_per_sample, data_bytes;
assert(ch > 0 && ch <= 8);
@@ -306,9 +306,12 @@
k = 0;
for (i = 0; i < nsamples * ch; i++) {
int32_t x = le2me_32(signal[i]);
- uint8_t *xb = (uint8_t *)&x;
- for (j = 0; j < bytes_per_sample; j++)
- ctx->data_buffer[k++] = xb[j];
+ switch (bytes_per_sample) {
+ case 4: ctx->data_buffer[k++] = x & 0xFF; x >>= 8;
+ case 3: ctx->data_buffer[k++] = x & 0xFF; x >>= 8;
+ case 2: ctx->data_buffer[k++] = x & 0xFF; x >>= 8;
+ case 1: ctx->data_buffer[k++] = x & 0xFF;
+ }
}
md5_update(ctx, ctx->data_buffer, data_bytes);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|