add support for passing frame size to analyzer; analyzer also print qlp coeffs
authorJosh Coalson <jcoalson@users.sourceforce.net>
Thu, 1 Feb 2007 04:58:11 +0000 (04:58 +0000)
committerJosh Coalson <jcoalson@users.sourceforce.net>
Thu, 1 Feb 2007 04:58:11 +0000 (04:58 +0000)
src/flac/analyze.c
src/flac/analyze.h
src/flac/decode.c

index 207543e..0ebb725 100644 (file)
@@ -58,7 +58,7 @@ void flac__analyze_init(analysis_options aopts)
        }
 }
 
-void flac__analyze_frame(const FLAC__Frame *frame, unsigned frame_number, analysis_options aopts, FILE *fout)
+void flac__analyze_frame(const FLAC__Frame *frame, unsigned frame_number, unsigned frame_bytes, analysis_options aopts, FILE *fout)
 {
        const unsigned channels = frame->header.channels;
        char outfilename[1024];
@@ -66,7 +66,7 @@ void flac__analyze_frame(const FLAC__Frame *frame, unsigned frame_number, analys
        unsigned i, channel;
 
        /* do the human-readable part first */
-       fprintf(fout, "frame=%u\tblocksize=%u\tsample_rate=%u\tchannels=%u\tchannel_assignment=%s\n", frame_number, frame->header.blocksize, frame->header.sample_rate, channels, FLAC__ChannelAssignmentString[frame->header.channel_assignment]);
+       fprintf(fout, "frame=%u\tbits=%u\tblocksize=%u\tsample_rate=%u\tchannels=%u\tchannel_assignment=%s\n", frame_number, frame_bytes*8, frame->header.blocksize, frame->header.sample_rate, channels, FLAC__ChannelAssignmentString[frame->header.channel_assignment]);
        for(channel = 0; channel < channels; channel++) {
                const FLAC__Subframe *subframe = frame->subframes+channel;
                fprintf(fout, "\tsubframe=%u\twasted_bits=%u\ttype=%s", channel, subframe->wasted_bits, FLAC__SubframeTypeString[subframe->type]);
@@ -96,6 +96,8 @@ void flac__analyze_frame(const FLAC__Frame *frame, unsigned frame_number, analys
                                FLAC__ASSERT(subframe->data.lpc.entropy_coding_method.type == FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE);
                                fprintf(fout, "\torder=%u\tpartition_order=%u\tqlp_coeff_precision=%u\tquantization_level=%d\n", subframe->data.lpc.order, subframe->data.lpc.entropy_coding_method.data.partitioned_rice.order, subframe->data.lpc.qlp_coeff_precision, subframe->data.lpc.quantization_level);
                                for(i = 0; i < subframe->data.lpc.order; i++)
+                                       fprintf(fout, "\t\tqlp_coeff[%u]=%d\n", i, subframe->data.lpc.qlp_coeff[i]);
+                               for(i = 0; i < subframe->data.lpc.order; i++)
                                        fprintf(fout, "\t\twarmup[%u]=%d\n", i, subframe->data.lpc.warmup[i]);
                                if(aopts.do_residual_text) {
                                        const unsigned partitions = (1u << subframe->data.lpc.entropy_coding_method.data.partitioned_rice.order);
index fec8e83..819962f 100644 (file)
@@ -25,7 +25,7 @@ typedef struct {
 } analysis_options;
 
 void flac__analyze_init(analysis_options aopts);
-void flac__analyze_frame(const FLAC__Frame *frame, unsigned frame_number, analysis_options aopts, FILE *fout);
+void flac__analyze_frame(const FLAC__Frame *frame, unsigned frame_number, unsigned frame_bytes, analysis_options aopts, FILE *fout);
 void flac__analyze_finish(analysis_options aopts);
 
 #endif
index 36766d7..0507146 100644 (file)
@@ -87,6 +87,9 @@ typedef struct {
        unsigned sample_rate;
        FLAC__uint32 channel_mask;
 
+       /* these are used only in analyze mode */
+       FLAC__uint64 decode_position;
+
        FLAC__StreamDecoder *decoder;
 
        FILE *fout;
@@ -280,6 +283,8 @@ FLAC__bool DecoderSession_construct(DecoderSession *d, FLAC__bool is_ogg, FLAC__
        d->sample_rate = 0;
        d->channel_mask = 0;
 
+       d->decode_position = 0;
+
        d->decoder = 0;
 
        d->fout = 0; /* initialized with an open file later if necessary */
@@ -858,7 +863,10 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder
                        print_stats(decoder_session);
 
                if(decoder_session->analysis_mode) {
-                       flac__analyze_frame(frame, decoder_session->frame_counter-1, decoder_session->aopts, fout);
+                       FLAC__uint64 dpos;
+                       FLAC__stream_decoder_get_decode_position(decoder_session->decoder, &dpos);
+                       flac__analyze_frame(frame, decoder_session->frame_counter-1, (unsigned)(dpos-decoder_session->decode_position), decoder_session->aopts, fout);
+                       decoder_session->decode_position = dpos;
                }
                else if(!decoder_session->test_only) {
                        if(shift && !decoder_session->replaygain.apply) {