~ubuntu-branches/ubuntu/saucy/gst-libav1.0/saucy-proposed

« back to all changes in this revision

Viewing changes to gst-libs/ext/libav/libavcodec/wmavoice.c

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2013-07-30 09:00:15 UTC
  • mfrom: (1.1.16) (7.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20130730090015-sc1ou2yssu7q5w4e
Tags: 1.1.3-1
* New upstream development snapshot:
  + debian/control:
    - Build depend on GStreamer and gst-plugins-base >= 1.1.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#define UNCHECKED_BITSTREAM_READER 1
29
29
 
30
30
#include <math.h>
 
31
 
 
32
#include "libavutil/channel_layout.h"
 
33
#include "libavutil/mem.h"
 
34
#include "dsputil.h"
31
35
#include "avcodec.h"
 
36
#include "internal.h"
32
37
#include "get_bits.h"
33
38
#include "put_bits.h"
34
39
#include "wmavoice_data.h"
35
 
#include "celp_math.h"
36
40
#include "celp_filters.h"
37
41
#include "acelp_vectors.h"
38
42
#include "acelp_filters.h"
39
43
#include "lsp.h"
40
 
#include "libavutil/lzo.h"
41
44
#include "dct.h"
42
45
#include "rdft.h"
43
46
#include "sinewin.h"
318
321
          0x0ffc, 0x0ffd, 0x0ffe,        //   1111111111+00/01/10
319
322
          0x3ffc, 0x3ffd, 0x3ffe, 0x3fff // 111111111111+xx
320
323
    };
321
 
    int cntr[8], n, res;
 
324
    int cntr[8] = { 0 }, n, res;
322
325
 
323
326
    memset(vbm_tree, 0xff, sizeof(vbm_tree[0]) * 25);
324
 
    memset(cntr,     0,    sizeof(cntr));
325
327
    for (n = 0; n < 17; n++) {
326
328
        res = get_bits(gb, 3);
327
329
        if (cntr[res] > 3) // should be >= 3 + (res == 7))
439
441
                                  2 * (s->block_conv_table[1] - 2 * s->min_pitch_val);
440
442
    s->block_pitch_nbits        = av_ceil_log2(s->block_pitch_range);
441
443
 
 
444
    ctx->channels               = 1;
 
445
    ctx->channel_layout         = AV_CH_LAYOUT_MONO;
442
446
    ctx->sample_fmt             = AV_SAMPLE_FMT_FLT;
443
447
 
444
448
    avcodec_get_frame_defaults(&s->frame);
519
523
 
520
524
    /* find best fitting point in history */
521
525
    do {
522
 
        dot = ff_dot_productf(in, ptr, size);
 
526
        dot = ff_scalarproduct_float_c(in, ptr, size);
523
527
        if (dot > optimal_gain) {
524
528
            optimal_gain  = dot;
525
529
            best_hist_ptr = ptr;
528
532
 
529
533
    if (optimal_gain <= 0)
530
534
        return -1;
531
 
    dot = ff_dot_productf(best_hist_ptr, best_hist_ptr, size);
 
535
    dot = ff_scalarproduct_float_c(best_hist_ptr, best_hist_ptr, size);
532
536
    if (dot <= 0) // would be 1.0
533
537
        return -1;
534
538
 
558
562
{
559
563
    float rh0, rh1;
560
564
 
561
 
    rh0 = 1.0     + ff_dot_productf(lpcs,  lpcs,    n_lpcs);
562
 
    rh1 = lpcs[0] + ff_dot_productf(lpcs, &lpcs[1], n_lpcs - 1);
 
565
    rh0 = 1.0     + ff_scalarproduct_float_c(lpcs,  lpcs,    n_lpcs);
 
566
    rh1 = lpcs[0] + ff_scalarproduct_float_c(lpcs, &lpcs[1], n_lpcs - 1);
563
567
 
564
568
    return rh1 / rh0;
565
569
}
652
656
                             -1.8 * tilt_factor(coeffs, remainder - 1),
653
657
                             coeffs, remainder);
654
658
    }
655
 
    sq = (1.0 / 64.0) * sqrtf(1 / ff_dot_productf(coeffs, coeffs, remainder));
 
659
    sq = (1.0 / 64.0) * sqrtf(1 / ff_scalarproduct_float_c(coeffs, coeffs, remainder));
656
660
    for (n = 0; n < remainder; n++)
657
661
        coeffs[n] *= sq;
658
662
}
1316
1320
    /* Calculate gain for adaptive & fixed codebook signal.
1317
1321
     * see ff_amr_set_fixed_gain(). */
1318
1322
    idx = get_bits(gb, 7);
1319
 
    fcb_gain = expf(ff_dot_productf(s->gain_pred_err, gain_coeff, 6) -
 
1323
    fcb_gain = expf(ff_scalarproduct_float_c(s->gain_pred_err, gain_coeff, 6) -
1320
1324
                    5.2409161640 + wmavoice_gain_codebook_fcb[idx]);
1321
1325
    acb_gain = wmavoice_gain_codebook_acb[idx];
1322
1326
    pred_err = av_clipf(wmavoice_gain_codebook_fcb[idx],
1726
1730
 * (if less than 480), usually used to prevent blanks at track boundaries.
1727
1731
 *
1728
1732
 * @param ctx WMA Voice decoder context
1729
 
 * @param samples pointer to output buffer for voice samples
1730
 
 * @param data_size pointer containing the size of #samples on input, and the
1731
 
 *                  amount of #samples filled on output
1732
1733
 * @return 0 on success, <0 on error or 1 if there was not enough data to
1733
1734
 *         fully parse the superframe
1734
1735
 */
1765
1766
     * are really WMAPro-in-WMAVoice-superframes. I've never seen those in
1766
1767
     * the wild yet. */
1767
1768
    if (!get_bits1(gb)) {
1768
 
        av_log_missing_feature(ctx, "WMAPro-in-WMAVoice support", 1);
1769
 
        return -1;
 
1769
        av_log_missing_feature(ctx, "WMAPro-in-WMAVoice", 1);
 
1770
        return AVERROR_PATCHWELCOME;
1770
1771
    }
1771
1772
 
1772
1773
    /* (optional) nr. of samples in superframe; always <= 480 and >= 0 */
1801
1802
 
1802
1803
    /* get output buffer */
1803
1804
    s->frame.nb_samples = 480;
1804
 
    if ((res = ctx->get_buffer(ctx, &s->frame)) < 0) {
 
1805
    if ((res = ff_get_buffer(ctx, &s->frame)) < 0) {
1805
1806
        av_log(ctx, AV_LOG_ERROR, "get_buffer() failed\n");
1806
1807
        return res;
1807
1808
    }
2050
2051
AVCodec ff_wmavoice_decoder = {
2051
2052
    .name           = "wmavoice",
2052
2053
    .type           = AVMEDIA_TYPE_AUDIO,
2053
 
    .id             = CODEC_ID_WMAVOICE,
 
2054
    .id             = AV_CODEC_ID_WMAVOICE,
2054
2055
    .priv_data_size = sizeof(WMAVoiceContext),
2055
2056
    .init           = wmavoice_decode_init,
2056
2057
    .close          = wmavoice_decode_end,
2057
2058
    .decode         = wmavoice_decode_packet,
2058
2059
    .capabilities   = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1,
2059
 
    .flush     = wmavoice_flush,
2060
 
    .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio Voice"),
 
2060
    .flush          = wmavoice_flush,
 
2061
    .long_name      = NULL_IF_CONFIG_SMALL("Windows Media Audio Voice"),
2061
2062
};