Ignore:
Timestamp:
03/16/07 16:54:54 (18 years ago)
Author:
r2d
Message:
  • added sv8 options to mpcenc
  • some change in mpcdec to correctly display that there is no information
Location:
libmpc/branches/r2d/libmpcenc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libmpc/branches/r2d/libmpcenc/encode_sv7.c

    r221 r226  
    5050// initialize SV8
    5151void
    52 Init_SV8 ( mpc_encoder_t * e )
     52mpc_encoder_init ( mpc_encoder_t * e,
     53                                   mpc_uint64_t SamplesInWAVE,
     54                                   unsigned int FramesBlockPwr,
     55                                   unsigned int SeekDistance )
    5356{
    5457        Init_Skalenfaktoren ();
     
    5659
    5760        memset(e, 0, sizeof(*e));
    58         e->seek_pwr = 1;
     61
     62        if (SeekDistance > 15)
     63                SeekDistance = 1;
     64        if (FramesBlockPwr > 14)
     65                FramesBlockPwr = 6;
     66
     67        e->seek_pwr = SeekDistance;
     68        e->frames_per_block_pwr = FramesBlockPwr;
     69
     70        if (SamplesInWAVE == 0)
     71                e->seek_table = malloc((1 << 16) * sizeof(mpc_uint32_t));
     72        else
     73                e->seek_table = malloc((size_t)(2 + SamplesInWAVE / (MPC_FRAME_LENGTH << (e->seek_pwr + e->frames_per_block_pwr))) * sizeof(mpc_uint32_t));
     74
     75        e->buffer = malloc(MAX_FRAME_SIZE * (1 << e->frames_per_block_pwr) * sizeof(mpc_uint8_t));
     76}
     77
     78void
     79mpc_encoder_exit ( mpc_encoder_t * e )
     80{
     81        free(e->seek_table);
     82        free(e->buffer);
    5983}
    6084
     
    105129        writeBits ( e, ChannelCount - 1  ,  4 );    // Channels
    106130        writeBits ( e, MS_on        ,  1 );    // MS-Coding Flag
    107         writeBits ( e, FRAMES_PER_BLOCK_PWR >> 1,  3 );    // frames per block (log4 unit)
     131        writeBits ( e, e->frames_per_block_pwr >> 1,  3 );    // frames per block (log4 unit)
    108132}
    109133
     
    350374
    351375        e->framesInBlock++;
    352         if (e->framesInBlock == FRAMES_PER_BLOCK) {
     376        if (e->framesInBlock == (1 << e->frames_per_block_pwr)) {
    353377                if ((e->block_cnt & ((1 << e->seek_pwr) - 1)) == 0) {
    354378                        e->seek_table[e->seek_pos] = ftell(e->outputFile);
  • libmpc/branches/r2d/libmpcenc/libmpcenc.h

    r221 r226  
    2727#endif
    2828
    29 // bitstream.c
    30 #define FRAMES_PER_BLOCK_PWR 6 // MUST be even
    31 #define FRAMES_PER_BLOCK (1 << FRAMES_PER_BLOCK_PWR)
    32 #define BUFFER_FULL         (4352 * FRAMES_PER_BLOCK)         // 34490 bit/frame  1320.3 kbps
    33 
    34 // FIXME : make this size dependent of the input file
    35 #define SEEK_SIZE (1 << 16) // number of seek entries
     29#define MPC_FRAME_LENGTH (36 * 32)
     30#define MAX_FRAME_SIZE 4352
    3631
    3732typedef struct {
     
    4540        mpc_uint64_t outputBits; // Counter for the number of written bits in the bitstream
    4641        mpc_uint32_t bitsBuff; // bits buffer
    47         mpc_uint8_t buffer [BUFFER_FULL]; // Buffer for bitstream-file
    48         mpc_uint_t framesInBlock;
     42        mpc_uint8_t * buffer; // Buffer for bitstream-file
     43        mpc_uint_t framesInBlock; // Number of frames in current block
     44        mpc_uint_t frames_per_block_pwr; // Number of frame in a block = 1 << frames_per_block_pwr
    4945
    5046        // seeking
    51         mpc_uint32_t seek_table[SEEK_SIZE];
     47        mpc_uint32_t * seek_table;
    5248        mpc_uint32_t seek_pos; /// current position in the seek table
    5349        mpc_uint32_t seek_ref; /// reference position for the seek information
     
    7470 } mpc_encoder_t;
    7571
    76  void         Init_SV8             ( mpc_encoder_t* );
     72 void mpc_encoder_init ( mpc_encoder_t * e,
     73                                                 mpc_uint64_t SamplesInWAVE,
     74                                                 unsigned int FramesBlockPwr,
     75                                                 unsigned int SeekDistance );
     76 void mpc_encoder_exit ( mpc_encoder_t * e );
    7777 void writeStreamInfo ( mpc_encoder_t*e,
    7878                                                const unsigned int  MaxBand,
Note: See TracChangeset for help on using the changeset viewer.