Ignore:
Timestamp:
10/02/06 23:20:16 (18 years ago)
Author:
r2d
Message:
  • mppenc compiles and runs, but output is not playing
File:
1 edited

Legend:

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

    r65 r66  
    2222#include "libmpcenc.h"
    2323
     24void  WriteBits         ( mpc_encoder_t*, const mpc_uint32_t input, const unsigned int bits );
     25
    2426// huffsv7.c
    2527extern Huffman_t         HuffHdr  [10];         // contains tables for SV7-header
     
    6062// writes SV7-header
    6163void
    62 WriteHeader_SV7 ( const unsigned int  MaxBand,
     64WriteHeader_SV7 ( mpc_encoder_t*e,
     65                                  const unsigned int  MaxBand,
    6366                  const unsigned int  Profile,
    6467                  const unsigned int  MS_on,
     
    6871                  const unsigned int  SampleFreq )
    6972{
    70     WriteBits ( StreamVersion,  8 );    // StreamVersion
    71     WriteBits ( 0x2B504D     , 24 );    // Magic Number "MP+"
    72 
    73     WriteBits ( TotalFrames  , 32 );    // # of frames
    74 
    75     WriteBits ( 0            ,  1 );    // former IS-Flag (not supported anymore)
    76     WriteBits ( MS_on        ,  1 );    // MS-Coding Flag
    77     WriteBits ( MaxBand      ,  6 );    // Bandwidth
     73    WriteBits ( e, StreamVersion,  8 );    // StreamVersion
     74        WriteBits ( e, 0x2B504D     , 24 );    // Magic Number "MP+"
     75
     76        WriteBits ( e, TotalFrames  , 32 );    // # of frames
     77
     78        WriteBits ( e, 0            ,  1 );    // former IS-Flag (not supported anymore)
     79        WriteBits ( e, MS_on        ,  1 );    // MS-Coding Flag
     80        WriteBits ( e, MaxBand      ,  6 );    // Bandwidth
    7881
    7982#if 0
    8083    if ( MPPENC_VERSION [3] & 1 )
    81         WriteBits ( 1        ,  4 );    // 1: Experimental profile
     84        WriteBits ( e, 1        ,  4 );    // 1: Experimental profile
    8285    else
    8386#endif
    8487
    85         WriteBits ( Profile  ,  4 );    // 5...15: below Telephone...above BrainDead
    86     WriteBits ( 0            ,  2 );    // for future use
     88        WriteBits ( e, Profile  ,  4 );    // 5...15: below Telephone...above BrainDead
     89        WriteBits ( e, 0            ,  2 );    // for future use
    8790    switch ( SampleFreq ) {
    88         case 44100: WriteBits ( 0, 2 ); break;
    89         case 48000: WriteBits ( 1, 2 ); break;
    90         case 37800: WriteBits ( 2, 2 ); break;
    91         case 32000: WriteBits ( 3, 2 ); break;
     91                case 44100: WriteBits ( e, 0, 2 ); break;
     92                case 48000: WriteBits ( e, 1, 2 ); break;
     93                case 37800: WriteBits ( e, 2, 2 ); break;
     94                case 32000: WriteBits ( e, 3, 2 ); break;
    9295        default   : stderr_printf ( "Internal error\n");
    9396                    exit (1);
    9497    }
    95     WriteBits ( 0            , 16 );    // maximum input sample value, currently filled by replaygain
    96 
    97     WriteBits ( 0            , 32 );    // title based gain controls, currently filled by replaygain
    98 
    99     WriteBits ( 0            , 32 );    // album based gain controls, currently filled by replaygain
    100 
    101     WriteBits ( 1            ,  1 );    // true gapless: used?
    102     WriteBits ( SamplesRest  , 11 );    // true gapless: valid samples in last frame
    103     WriteBits ( 1            , 1 );     // we now support fast seeking
    104     WriteBits ( 0            , 19 );
    105 
    106     WriteBits ( (MPPENC_VERSION[0]&15)*100 + (MPPENC_VERSION[2]&15)*10 + (MPPENC_VERSION[3]&15),
     98        WriteBits ( e, 0            , 16 );    // maximum input sample value, currently filled by replaygain
     99
     100        WriteBits ( e, 0            , 32 );    // title based gain controls, currently filled by replaygain
     101
     102        WriteBits ( e, 0            , 32 );    // album based gain controls, currently filled by replaygain
     103
     104        WriteBits ( e, 1            ,  1 );    // true gapless: used?
     105        WriteBits ( e, SamplesRest  , 11 );    // true gapless: valid samples in last frame
     106        WriteBits ( e, 1            , 1 );     // we now support fast seeking
     107        WriteBits ( e, 0            , 19 );
     108
     109        WriteBits ( e, (MPPENC_VERSION[0]&15)*100 + (MPPENC_VERSION[2]&15)*10 + (MPPENC_VERSION[3]&15),
    107110                                8 );    // for future use
    108111}
     
    119122        d = new - old + 7;                                   \
    120123        if ( d <= 14u  && rll < 32) {                        \
    121             WriteBits ( Table[d].Code, Table[d].Length );    \
     124            WriteBits ( e, Table[d].Code, Table[d].Length );    \
    122125        }                                                    \
    123126        else {                                               \
    124127            if ( new < 0 ) new = 0, e->Overflows++;          \
    125             WriteBits ( Table[15].Code, Table[15].Length );  \
    126             WriteBits ( (unsigned int)new, 6 );              \
     128            WriteBits ( e, Table[15].Code, Table[15].Length );  \
     129            WriteBits ( e, (unsigned int)new, 6 );              \
    127130            rll = 0;                                         \
    128131        }
     
    131134        d = new - old + 7;                                   \
    132135        if ( d <= 14u ) {                                    \
    133             WriteBits ( Table[d].Code, Table[d].Length );    \
     136            WriteBits ( e, Table[d].Code, Table[d].Length );    \
    134137        }                                                    \
    135138        else {                                               \
    136139            if ( new < 0 ) new = 0, e->Overflows++;          \
    137             WriteBits ( Table[15].Code, Table[15].Length );  \
    138             WriteBits ( (unsigned int)new, 6 );              \
     140            WriteBits ( e, Table[15].Code, Table[15].Length );  \
     141            WriteBits ( e, (unsigned int)new, 6 );              \
    139142            rll = 0;                                         \
    140143        }
     
    187190
    188191    /************************************ Resolution *********************************/
    189     WriteBits ( (unsigned int)Res_L[0], 4 );                            // subband 0
    190     WriteBits ( (unsigned int)Res_R[0], 4 );
     192    WriteBits ( e, (unsigned int)Res_L[0], 4 );                            // subband 0
     193        WriteBits ( e, (unsigned int)Res_R[0], 4 );
    191194    if ( e->MS_Channelmode > 0  &&  !(Res_L[0]==0  &&  Res_R[0]==0) )
    192          WriteBits ( MS_Flag[0] , 1 );
     195                WriteBits ( e, MS_Flag[0] , 1 );
    193196
    194197    Table = HuffHdr;                                                    // subband 1...MaxBand
     
    198201        d = Res_L[n] - Res_L[n-1] + 5;
    199202        if ( d <= 8u ) {
    200             WriteBits ( Table[d].Code, Table[d].Length );
     203                        WriteBits ( e, Table[d].Code, Table[d].Length );
    201204        }
    202205        else {
    203             WriteBits ( Table[9].Code, Table[9].Length );
    204             WriteBits ( Res_L[n]     , 4               );
     206                        WriteBits ( e, Table[9].Code, Table[9].Length );
     207                        WriteBits ( e, Res_L[n]     , 4               );
    205208        }
    206209
     
    208211        d = Res_R[n] - Res_R[n-1] + 5;
    209212        if ( d <= 8u ) {
    210             WriteBits ( Table[d].Code, Table[d].Length );
     213                        WriteBits ( e, Table[d].Code, Table[d].Length );
    211214        }
    212215        else {
    213             WriteBits ( Table[9].Code, Table[9].Length );
    214             WriteBits ( Res_R[n]     , 4               );
     216                        WriteBits ( e, Table[9].Code, Table[9].Length );
     217                        WriteBits ( e, Res_R[n]     , 4               );
    215218        }
    216219        if ( e->MS_Channelmode > 0  &&  !(Res_L[n]==0 && Res_R[n]==0) )
    217             WriteBits ( MS_Flag[n], 1 );
     220                        WriteBits ( e, MS_Flag[n], 1 );
    218221    }
    219222
     
    223226        if ( Res_L[n] ) {
    224227            SCFI_L[n] = 2 * (SCF_Index_L[n][0] == SCF_Index_L[n][1]) + (SCF_Index_L[n][1] == SCF_Index_L[n][2]);
    225             WriteBits ( Table[SCFI_L[n]].Code, Table[SCFI_L[n]].Length );
     228                        WriteBits ( e, Table[SCFI_L[n]].Code, Table[SCFI_L[n]].Length );
    226229        }
    227230        if ( Res_R[n] ) {
    228231            SCFI_R[n] = 2 * (SCF_Index_R[n][0] == SCF_Index_R[n][1]) + (SCF_Index_R[n][1] == SCF_Index_R[n][2]);
    229             WriteBits ( Table[SCFI_R[n]].Code, Table[SCFI_R[n]].Length );
     232                        WriteBits ( e, Table[SCFI_R[n]].Code, Table[SCFI_R[n]].Length );
    230233        }
    231234    }
     
    309312            }
    310313            book = sum >= 0;
    311             WriteBits ( book, 1 );
     314                        WriteBits ( e, book, 1 );
    312315            Table = HuffQ [book][1];
    313316            for ( k = 0; k < 36; k += 3 ) {
    314317                idx = q[k+0] + 3*q[k+1] + 9*q[k+2];
    315                 WriteBits ( Table[idx].Code, Table[idx].Length );
     318                                WriteBits ( e, Table[idx].Code, Table[idx].Length );
    316319            }
    317320            break;
     
    325328            }
    326329            book = sum >= 0;
    327             WriteBits ( book, 1 );
     330                        WriteBits ( e, book, 1 );
    328331            Table = HuffQ [book][2];
    329332            for ( k = 0; k < 36; k += 2 ) {
    330333                idx = q[k+0] + 5*q[k+1];
    331                 WriteBits ( Table[idx].Code, Table[idx].Length );
     334                                WriteBits ( e, Table[idx].Code, Table[idx].Length );
    332335            }
    333336            break;
     
    344347            }
    345348            book = sum >= 0;
    346             WriteBits ( book, 1 );
     349                        WriteBits ( e, book, 1 );
    347350            Table = HuffQ [book][Res_L[n]];
    348351            for ( k = 0; k < 36; k++ ) {
    349352                idx = q[k];
    350                 WriteBits ( Table[idx].Code, Table[idx].Length );
     353                                WriteBits ( e, Table[idx].Code, Table[idx].Length );
    351354            }
    352355            break;
    353356        default:
    354357            for ( k = 0; k < 36; k++ )
    355                 WriteBits ( q[k], Res_L[n]-1 );
     358                                WriteBits ( e, q[k], Res_L[n]-1 );
    356359            break;
    357360        }
     
    373376            }
    374377            book = sum >= 0;
    375             WriteBits ( book, 1 );
     378                        WriteBits ( e, book, 1 );
    376379            Table = HuffQ [book][1];
    377380            for ( k = 0; k < 36; k += 3 ) {
    378381                idx = q[k+0] + 3*q[k+1] + 9*q[k+2];
    379                 WriteBits ( Table[idx].Code, Table[idx].Length );
     382                                WriteBits ( e, Table[idx].Code, Table[idx].Length );
    380383            }
    381384            break;
     
    389392            }
    390393            book = sum >= 0;
    391             WriteBits ( book, 1 );
     394                        WriteBits ( e, book, 1 );
    392395            Table = HuffQ [book][2];
    393396            for ( k = 0; k < 36; k += 2 ) {
    394397                idx = q[k+0] + 5*q[k+1];
    395                 WriteBits ( Table[idx].Code, Table[idx].Length );
     398                                WriteBits ( e, Table[idx].Code, Table[idx].Length );
    396399            }
    397400            break;
     
    408411            }
    409412            book = sum >= 0;
    410             WriteBits ( book, 1 );
     413                        WriteBits ( e, book, 1 );
    411414            Table = HuffQ [book][Res_R[n]];
    412415            for ( k = 0; k < 36; k++ ) {
    413416                idx = q[k];
    414                 WriteBits ( Table[idx].Code, Table[idx].Length );
     417                                WriteBits ( e, Table[idx].Code, Table[idx].Length );
    415418            }
    416419            break;
    417420        default:
    418421            for ( k = 0; k < 36; k++ )
    419                 WriteBits ( q[k], Res_R[n] - 1 );
     422                                WriteBits ( e, q[k], Res_R[n] - 1 );
    420423            break;
    421424        }
Note: See TracChangeset for help on using the changeset viewer.