Fix a couple of Windows 2Gig file size issues.
[platform/upstream/flac.git] / src / flac / decode.c
index ce152a2..2f2c311 100644 (file)
@@ -11,9 +11,9 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #if HAVE_CONFIG_H
@@ -87,7 +87,7 @@ typedef struct {
        FILE *fout;
 
        foreign_metadata_t *foreign_metadata; /* NULL unless --keep-foreign-metadata requested */
-       off_t fm_offset1, fm_offset2, fm_offset3;
+       FLAC__off_t fm_offset1, fm_offset2, fm_offset3;
 } DecoderSession;
 
 
@@ -333,32 +333,32 @@ FLAC__bool DecoderSession_process(DecoderSession *d)
                return false;
 
        /* set channel mapping */
-       if(!d->channel_map_none) {
-               /* currently FLAC order matches SMPTE/WAVEFORMATEXTENSIBLE order, so no reordering is necessary; see encode.c */
-               /* only the channel mask must be set if it was not already picked up from the WAVEFORMATEXTENSIBLE_CHANNEL_MASK tag */
+       /* currently FLAC order matches SMPTE/WAVEFORMATEXTENSIBLE order, so no reordering is necessary; see encode.c */
+       /* only the channel mask must be set if it was not already picked up from the WAVEFORMATEXTENSIBLE_CHANNEL_MASK tag */
+       if(!d->channel_map_none && d->channel_mask == 0) {
                if(d->channels == 1) {
-                       if(d->channel_mask == 0)
-                               d->channel_mask = 0x0001;
+                       d->channel_mask = 0x0001;
                }
                else if(d->channels == 2) {
-                       if(d->channel_mask == 0)
-                               d->channel_mask = 0x0003;
+                       d->channel_mask = 0x0003;
                }
                else if(d->channels == 3) {
-                       if(d->channel_mask == 0)
-                               d->channel_mask = 0x0007;
+                       d->channel_mask = 0x0007;
                }
                else if(d->channels == 4) {
-                       if(d->channel_mask == 0)
-                               d->channel_mask = 0x0033;
+                       d->channel_mask = 0x0033;
                }
                else if(d->channels == 5) {
-                       if(d->channel_mask == 0)
-                               d->channel_mask = 0x0607;
+                       d->channel_mask = 0x0607;
                }
                else if(d->channels == 6) {
-                       if(d->channel_mask == 0)
-                               d->channel_mask = 0x060f;
+                       d->channel_mask = 0x060f;
+               }
+               else if(d->channels == 7) {
+                       d->channel_mask = 0x070f;
+               }
+               else if(d->channels == 8) {
+                       d->channel_mask = 0x063f;
                }
        }
 
@@ -1414,6 +1414,7 @@ void print_error_with_state(const DecoderSession *d, const char *message)
 
 void print_stats(const DecoderSession *decoder_session)
 {
+       static int count = 0;
        if(flac__utils_verbosity_ >= 2) {
 #if defined _MSC_VER || defined __MINGW32__
                /* with MSVC you have to spoon feed it the casting */
@@ -1422,7 +1423,13 @@ void print_stats(const DecoderSession *decoder_session)
                const double progress = (double)decoder_session->samples_processed / (double)decoder_session->total_samples * 100.0;
 #endif
                if(decoder_session->total_samples > 0) {
-                       fprintf(stderr, "\r%s: %s%u%% complete",
+                       while (count > 0 && count--)
+                               fprintf(stderr, "\b");
+
+                       if ((unsigned)floor(progress + 0.5) == 100)
+                               return;
+
+                       count = fprintf(stderr, "%s: %s%u%% complete",
                                decoder_session->inbasefilename,
                                decoder_session->test_only? "testing, " : decoder_session->analysis_mode? "analyzing, " : "",
                                (unsigned)floor(progress + 0.5)