From f219c658e80f36d39982796670c926b17f825ab3 Mon Sep 17 00:00:00 2001
From: Erik de Castro Lopo <erikd@mega-nerd.com>
Date: Mon, 20 Feb 2012 20:53:39 +1100
Subject: [PATCH] src/ : Don't fake psf->bytewidth values.

---
 src/au.c      |    2 --
 src/flac.c    |    7 -------
 src/g72x.c    |    8 +++-----
 src/wav_w64.c |    4 ----
 4 files changed, 3 insertions(+), 18 deletions(-)

--- a/src/au.c
+++ b/src/au.c
@@ -211,8 +211,6 @@ au_write_header (SF_PRIVATE *psf, int ca
 		psf->datalength = psf->filelength - psf->dataoffset ;
 		if (psf->dataend)
 			psf->datalength -= psf->filelength - psf->dataend ;
-
-		psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ;
 		} ;
 
 	encoding = au_format_to_encoding (SF_CODEC (psf->sf.format)) ;
--- a/src/flac.c
+++ b/src/flac.c
@@ -668,15 +668,11 @@ flac_open	(SF_PRIVATE *psf)
 
 	psf->datalength = psf->filelength ;
 	psf->dataoffset = 0 ;
-	psf->blockwidth = 0 ;
-	psf->bytewidth = 1 ;
 
 	psf->container_close = flac_close ;
 	psf->seek = flac_seek ;
 	psf->command = flac_command ;
 
-	psf->blockwidth = psf->bytewidth * psf->sf.channels ;
-
 	switch (subformat)
 	{	case SF_FORMAT_PCM_S8 :	/* 8-bit FLAC.  */
 		case SF_FORMAT_PCM_16 :	/* 16-bit FLAC. */
@@ -836,9 +832,6 @@ flac_init (SF_PRIVATE *psf)
 		psf->write_double	= flac_write_d2flac ;
 		} ;
 
-	psf->bytewidth = 1 ;
-	psf->blockwidth = psf->sf.channels ;
-
 	if (psf->filelength > psf->dataoffset)
 		psf->datalength = (psf->dataend) ? psf->dataend - psf->dataoffset : psf->filelength - psf->dataoffset ;
 	else
--- a/src/g72x.c
+++ b/src/g72x.c
@@ -112,8 +112,6 @@ g72x_init (SF_PRIVATE * psf)
 		default : return SFE_UNIMPLEMENTED ;
 		} ;
 
-	psf->blockwidth = psf->bytewidth = 1 ;
-
 	psf->filelength = psf_get_filelen (psf) ;
 	if (psf->filelength < psf->dataoffset)
 		psf->filelength = psf->dataoffset ;
@@ -501,7 +499,7 @@ g72x_write_i (SF_PRIVATE *psf, const int
 	pg72x = (G72x_PRIVATE*) psf->codec_data ;
 
 	sptr = psf->u.sbuf ;
-	bufferlen = ((SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth) / sizeof (short) ;
+	bufferlen = SF_BUFFER_LEN / sizeof (short) ;
 	while (len > 0)
 	{	writecount = (len >= bufferlen) ? bufferlen : len ;
 		for (k = 0 ; k < writecount ; k++)
@@ -531,7 +529,7 @@ g72x_write_f (SF_PRIVATE *psf, const flo
 	normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x8000) : 1.0 ;
 
 	sptr = psf->u.sbuf ;
-	bufferlen = ((SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth) / sizeof (short) ;
+	bufferlen = SF_BUFFER_LEN / sizeof (short) ;
 	while (len > 0)
 	{	writecount = (len >= bufferlen) ? bufferlen : len ;
 		for (k = 0 ; k < writecount ; k++)
@@ -562,7 +560,7 @@ g72x_write_d (SF_PRIVATE *psf, const dou
 	normfact = (psf->norm_double == SF_TRUE) ? (1.0 * 0x8000) : 1.0 ;
 
 	sptr = psf->u.sbuf ;
-	bufferlen = ((SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth) / sizeof (short) ;
+	bufferlen = SF_BUFFER_LEN / sizeof (short) ;
 	while (len > 0)
 	{	writecount = (len >= bufferlen) ? bufferlen : len ;
 		for (k = 0 ; k < writecount ; k++)
--- a/src/wav_w64.c
+++ b/src/wav_w64.c
@@ -195,7 +195,6 @@ wav_w64_read_fmt_chunk (SF_PRIVATE *psf,
 				else
 					psf_log_printf (psf, "  Bytes/sec     : %d\n", wav_fmt->ima.bytespersec) ;
 
-				psf->bytewidth = 2 ;
 				psf_log_printf (psf, "  Extra Bytes   : %d\n", wav_fmt->ima.extrabytes) ;
 				psf_log_printf (psf, "  Samples/Block : %d\n", wav_fmt->ima.samplesperblock) ;
 				break ;
@@ -218,8 +217,6 @@ wav_w64_read_fmt_chunk (SF_PRIVATE *psf,
 				else
 					psf_log_printf (psf, "  Bytes/sec     : %d (should be %d)\n", wav_fmt->min.bytespersec, bytespersec) ;
 
-
-				psf->bytewidth = 2 ;
 				psf_log_printf (psf, "  Extra Bytes   : %d\n", wav_fmt->msadpcm.extrabytes) ;
 				psf_log_printf (psf, "  Samples/Block : %d\n", wav_fmt->msadpcm.samplesperblock) ;
 				if (wav_fmt->msadpcm.numcoeffs > ARRAY_LEN (wav_fmt->msadpcm.coeffs))
@@ -254,7 +251,6 @@ wav_w64_read_fmt_chunk (SF_PRIVATE *psf,
 				else
 					psf_log_printf (psf, "  Bytes/sec     : %d\n", wav_fmt->gsm610.bytespersec) ;
 
-				psf->bytewidth = 2 ;
 				psf_log_printf (psf, "  Extra Bytes   : %d\n", wav_fmt->gsm610.extrabytes) ;
 				psf_log_printf (psf, "  Samples/Block : %d\n", wav_fmt->gsm610.samplesperblock) ;
 				break ;
