]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
wma: Store ASF header info in afhi->techinfo.
authorAndre Noll <maan@systemlinux.org>
Wed, 8 Jan 2014 18:38:06 +0000 (18:38 +0000)
committerAndre Noll <maan@systemlinux.org>
Tue, 22 Apr 2014 00:26:43 +0000 (02:26 +0200)
This changes the wma audio format handler and decoder to store
the ASF header bits we care about (exp_vlc, bit reservoir, and
variable block length) in struct asf_header_info instead of struct
private_wmadec_data.

This way the wma audio format handler can print this information in
its ->techinfo string for the audio file.

wma.h
wma_afh.c
wma_common.c
wmadec_filter.c

diff --git a/wma.h b/wma.h
index f0ba7f631703b35878606facde8f2980de621bce..15b9c5d492560f2c6532935460cc7ca4f38ca571 100644 (file)
--- a/wma.h
+++ b/wma.h
@@ -20,8 +20,14 @@ struct asf_header_info {
        uint32_t bit_rate;
        /** Further decoding information (ignored). */
        uint32_t flags1;
        uint32_t bit_rate;
        /** Further decoding information (ignored). */
        uint32_t flags1;
-       /** Whether to use exp_vlc, bit reservoir, variable block len. */
+       /** Encodes exp_vlc, bit reservoir, vbl, number of block sizes. */
        uint16_t flags2;
        uint16_t flags2;
+       /** Whether exponents are coded with VLC codes. */
+       bool use_exp_vlc;
+       /** If false, a frame is equal to a superframe. */
+       bool use_bit_reservoir;
+       /** Whether blocks are of variable or of constant size. */
+       bool use_variable_block_len;
 };
 
 /* wma_common.c */
 };
 
 /* wma_common.c */
index c429020c4e3455aa56929d5a36e60df315de7e28..65795fd8b8e4ac66cc1e3cf1cba8e18d68800636 100644 (file)
--- a/wma_afh.c
+++ b/wma_afh.c
@@ -257,6 +257,15 @@ static int wma_get_file_info(char *map, size_t numbytes, __a_unused int fd,
        afhi->frequency = ahi.sample_rate;
        afhi->channels = ahi.channels;
        afhi->header_len = ahi.header_len;
        afhi->frequency = ahi.sample_rate;
        afhi->channels = ahi.channels;
        afhi->header_len = ahi.header_len;
+
+       afhi->techinfo = make_message("%s%s%s%s%s",
+               ahi.use_exp_vlc? "exp vlc" : "",
+               (ahi.use_bit_reservoir && ahi.use_exp_vlc)? ", " : "",
+               ahi.use_bit_reservoir? "bit reservoir" : "",
+               (ahi.use_variable_block_len &&
+                       (ahi.use_exp_vlc || ahi.use_bit_reservoir)? ", " : ""),
+               ahi.use_variable_block_len? "vbl" : ""
+       );
        wma_make_chunk_table(map + ahi.header_len, numbytes - ahi.header_len,
                ahi.block_align, afhi);
        read_asf_tags(map, ahi.header_len, &afhi->tags);
        wma_make_chunk_table(map + ahi.header_len, numbytes - ahi.header_len,
                ahi.block_align, afhi);
        read_asf_tags(map, ahi.header_len, &afhi->tags);
index 97cdba0ae5a34953257de5657fc79f62f355500f..e53cdf5e400aca8f7552052a5586a4e4d5a04bfe 100644 (file)
@@ -115,6 +115,9 @@ int read_asf_header(const char *buf, int loaded, struct asf_header_info *ahi)
        ahi->flags2 = read_u16(start + 60);
        PARA_INFO_LOG("read_asf_header: flags1: %d, flag2: %d\n",
                ahi->flags1, ahi->flags2);
        ahi->flags2 = read_u16(start + 60);
        PARA_INFO_LOG("read_asf_header: flags1: %d, flag2: %d\n",
                ahi->flags1, ahi->flags2);
+       ahi->use_exp_vlc = ahi->flags2 & 0x0001;
+       ahi->use_bit_reservoir = ahi->flags2 & 0x0002;
+       ahi->use_variable_block_len = ahi->flags2 & 0x0004;
        return 1;
 }
 
        return 1;
 }
 
index 0071337f38427cc98f341404a6819ee683352ecc..fdca2814d76a44db720752e2c99d10d9df7bbe5c 100644 (file)
@@ -62,17 +62,11 @@ struct private_wmadec_data {
        /** Information contained in the audio file header. */
        struct asf_header_info ahi;
        struct getbit_context gb;
        /** Information contained in the audio file header. */
        struct asf_header_info ahi;
        struct getbit_context gb;
-       /** Whether to use the bit reservoir. */
-       int use_bit_reservoir;
-       /** Whether to use variable block length. */
-       int use_variable_block_len;
-       /** Whether to use exponent coding. */
-       int use_exp_vlc;
        /** Whether perceptual noise is added. */
        int use_noise_coding;
        /** Depends on number of the bits per second and the frame length. */
        int byte_offset_bits;
        /** Whether perceptual noise is added. */
        int use_noise_coding;
        /** Depends on number of the bits per second and the frame length. */
        int byte_offset_bits;
-       /** Only used if use_exp_vlc is true. */
+       /** Only used if ahi->use_exp_vlc is true. */
        struct vlc exp_vlc;
        uint16_t exponent_bands[BLOCK_NB_SIZES][25];
        /** The index of the first coef in high band. */
        struct vlc exp_vlc;
        uint16_t exponent_bands[BLOCK_NB_SIZES][25];
        /** The index of the first coef in high band. */
@@ -96,7 +90,7 @@ struct private_wmadec_data {
        int frame_len;
        /** log2 of frame_len. */
        int frame_len_bits;
        int frame_len;
        /** log2 of frame_len. */
        int frame_len_bits;
-       /** Number of block sizes. */
+       /** Number of block sizes, one if !ahi->use_variable_block_len. */
        int nb_block_sizes;
        /* block info */
        int reset_block_lengths;
        int nb_block_sizes;
        /* block info */
        int reset_block_lengths;
@@ -180,7 +174,7 @@ static void wmadec_cleanup(struct private_wmadec_data *pwd)
 
        for (i = 0; i < pwd->nb_block_sizes; i++)
                imdct_end(pwd->mdct_ctx[i]);
 
        for (i = 0; i < pwd->nb_block_sizes; i++)
                imdct_end(pwd->mdct_ctx[i]);
-       if (pwd->use_exp_vlc)
+       if (pwd->ahi.use_exp_vlc)
                free_vlc(&pwd->exp_vlc);
        if (pwd->use_noise_coding)
                free_vlc(&pwd->hgain_vlc);
                free_vlc(&pwd->exp_vlc);
        if (pwd->use_noise_coding)
                free_vlc(&pwd->hgain_vlc);
@@ -314,7 +308,7 @@ static int wma_init(struct private_wmadec_data *pwd)
        else
                pwd->frame_len_bits = 11;
        pwd->frame_len = 1 << pwd->frame_len_bits;
        else
                pwd->frame_len_bits = 11;
        pwd->frame_len = 1 << pwd->frame_len_bits;
-       if (pwd->use_variable_block_len) {
+       if (pwd->ahi.use_variable_block_len) {
                int nb_max, nb;
                nb = ((flags2 >> 3) & 3) + 1;
                if ((ahi->bit_rate / ahi->channels) >= 32000)
                int nb_max, nb;
                nb = ((flags2 >> 3) & 3) + 1;
                if ((ahi->bit_rate / ahi->channels) >= 32000)
@@ -395,7 +389,7 @@ static int wma_init(struct private_wmadec_data *pwd)
                pwd->frame_len, bps, bps1,
                high_freq, pwd->byte_offset_bits);
        PARA_INFO_LOG("use_noise_coding=%d use_exp_vlc=%d nb_block_sizes=%d\n",
                pwd->frame_len, bps, bps1,
                high_freq, pwd->byte_offset_bits);
        PARA_INFO_LOG("use_noise_coding=%d use_exp_vlc=%d nb_block_sizes=%d\n",
-               pwd->use_noise_coding, pwd->use_exp_vlc, pwd->nb_block_sizes);
+               pwd->use_noise_coding, pwd->ahi.use_exp_vlc, pwd->nb_block_sizes);
 
        compute_scale_factor_band_sizes(pwd, high_freq);
        /* init MDCT windows : simple sinus window */
 
        compute_scale_factor_band_sizes(pwd, high_freq);
        /* init MDCT windows : simple sinus window */
@@ -410,7 +404,7 @@ static int wma_init(struct private_wmadec_data *pwd)
 
        if (pwd->use_noise_coding) {
                /* init the noise generator */
 
        if (pwd->use_noise_coding) {
                /* init the noise generator */
-               if (pwd->use_exp_vlc)
+               if (pwd->ahi.use_exp_vlc)
                        pwd->noise_mult = 0.02;
                else
                        pwd->noise_mult = 0.04;
                        pwd->noise_mult = 0.02;
                else
                        pwd->noise_mult = 0.04;
@@ -484,10 +478,6 @@ static int wma_decode_init(char *initial_buf, int len, struct private_wmadec_dat
                return ret;
        }
 
                return ret;
        }
 
-       pwd->use_exp_vlc = pwd->ahi.flags2 & 0x0001;
-       pwd->use_bit_reservoir = pwd->ahi.flags2 & 0x0002;
-       pwd->use_variable_block_len = pwd->ahi.flags2 & 0x0004;
-
        ret = wma_init(pwd);
        if (ret < 0)
                return ret;
        ret = wma_init(pwd);
        if (ret < 0)
                return ret;
@@ -504,7 +494,7 @@ static int wma_decode_init(char *initial_buf, int len, struct private_wmadec_dat
                        wma_hgain_huffcodes, 2);
        }
 
                        wma_hgain_huffcodes, 2);
        }
 
-       if (pwd->use_exp_vlc) {
+       if (pwd->ahi.use_exp_vlc) {
                PARA_INFO_LOG("using exp_vlc\n");
                init_vlc(&pwd->exp_vlc, EXPVLCBITS, sizeof(wma_scale_huffbits),
                        wma_scale_huffbits, wma_scale_huffcodes, 4);
                PARA_INFO_LOG("using exp_vlc\n");
                init_vlc(&pwd->exp_vlc, EXPVLCBITS, sizeof(wma_scale_huffbits),
                        wma_scale_huffbits, wma_scale_huffcodes, 4);
@@ -850,7 +840,7 @@ static int wma_decode_block(struct private_wmadec_data *pwd)
        int nb_coefs[MAX_CHANNELS];
 
        /* compute current block length */
        int nb_coefs[MAX_CHANNELS];
 
        /* compute current block length */
-       if (pwd->use_variable_block_len) {
+       if (pwd->ahi.use_variable_block_len) {
                n = wma_log2(pwd->nb_block_sizes - 1) + 1;
 
                if (pwd->reset_block_lengths) {
                n = wma_log2(pwd->nb_block_sizes - 1) + 1;
 
                if (pwd->reset_block_lengths) {
@@ -927,7 +917,7 @@ static int wma_decode_block(struct private_wmadec_data *pwd)
        if ((pwd->block_len_bits == pwd->frame_len_bits) || get_bit(&pwd->gb)) {
                for (ch = 0; ch < pwd->ahi.channels; ch++) {
                        if (pwd->channel_coded[ch]) {
        if ((pwd->block_len_bits == pwd->frame_len_bits) || get_bit(&pwd->gb)) {
                for (ch = 0; ch < pwd->ahi.channels; ch++) {
                        if (pwd->channel_coded[ch]) {
-                               if (pwd->use_exp_vlc) {
+                               if (pwd->ahi.use_exp_vlc) {
                                        ret = decode_exp_vlc(pwd, ch);
                                        if (ret < 0)
                                                return ret;
                                        ret = decode_exp_vlc(pwd, ch);
                                        if (ret < 0)
                                                return ret;
@@ -1096,7 +1086,7 @@ static int wma_decode_superframe(struct private_wmadec_data *pwd, void *data,
        buf_size = pwd->ahi.block_align;
        samples = data;
        init_get_bits(&pwd->gb, buf, buf_size);
        buf_size = pwd->ahi.block_align;
        samples = data;
        init_get_bits(&pwd->gb, buf, buf_size);
-       if (pwd->use_bit_reservoir) {
+       if (pwd->ahi.use_bit_reservoir) {
                int i, nb_frames, bit_offset, pos, len;
                uint8_t *q;
 
                int i, nb_frames, bit_offset, pos, len;
                uint8_t *q;