Ignore:
Timestamp:
02/17/07 18:49:10 (18 years ago)
Author:
r2d
Message:
  • updated according to the spec
  • now reads / write beginning / end silences, but decoder does not care.
  • please test !
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libmpc/branches/r2d/mpcgain/mpcgain.c

    r219 r220  
    4141#include "../libmpcdec/huffman.h"
    4242#include "../libmpcdec/mpc_bits_reader.h"
    43 
    44 // crc32.c
    45 unsigned long crc32(unsigned char *buf, int len);
    4643
    4744static void usage(const char *exename)
     
    124121                mpc_block b;
    125122                mpc_uint64_t size;
    126                 mpc_uint32_t crc_pos, crc;
    127123                FILE * file;
    128124
     
    140136                size = mpc_bits_get_block(&r, &b);
    141137
    142                 while( memcmp(b.key, "SI", 2) != 0 ) {
    143                         header_pos[j] += b.size;
     138                while( memcmp(b.key, "RG", 2) != 0 ) {
     139                        header_pos[j] += b.size + size;
    144140                        fseek(file, header_pos[j], SEEK_SET);
    145141                        fread(buffer, 1, 16, file);
     
    150146
    151147                header_pos[j] += size;
    152 
    153                 fread(buffer + 16, 1, 48, file);
    154 
    155                 crc_pos = r.buff - buffer + (8 > r.count); // save position of CRC
    156                 r.buff += 4; // skip CRC
    157                 mpc_bits_get_size(&r, &size);
    158                 size += 4 + crc_pos;
    159148
    160149                buffer[size] = 1; // replaygain version
     
    168157                buffer[size + 8] = album_peak & 0xFF;
    169158
    170                 crc = crc32(buffer + crc_pos + 4, (int)b.size - 4);
    171                 buffer[crc_pos] = crc >> 24;
    172                 buffer[crc_pos + 1] = (crc >> 16) & 0xFF;
    173                 buffer[crc_pos + 2] = (crc >> 8) & 0xFF;
    174                 buffer[crc_pos + 3] = crc & 0xFF;
    175 
    176159                fseek(file, header_pos[j], SEEK_SET);
    177                 fwrite(buffer + crc_pos, 1, b.size, file);
     160                fwrite(buffer + size, 1, b.size, file);
    178161                fclose(file);
    179162        }
Note: See TracChangeset for help on using the changeset viewer.