~medibuntu-maintainers/mplayer/medibuntu.precise

« back to all changes in this revision

Viewing changes to ffmpeg/libavcodec/amrwbdec.c

  • Committer: Gauvain Pocentek
  • Date: 2012-03-06 11:59:12 UTC
  • mfrom: (66.1.15 precise)
  • Revision ID: gauvain@pocentek.net-20120306115912-h9d6kt9j0l532oo5
* Merge from Ubuntu:
  - put back faac support
  - recommends apport-hooks-medibuntu
  - change Maintainer, Uploaders & Vcs-* fields.
* New upstream snapshot
* upload to unstable
* Build against external libmpeg2
* drop 51_FTBFS_arm.patch again
* no longer build depend on libcdparanoia-dev on the Hurd
* Fix FTBFS on the hurd.
  Thanks to Samuel Thibault <sthibault@debian.org> (Closes: #654974)
* Fix FTBFS on arm
* New upstream snapshot, Closes: #650339, #643621, #481807
* Imported Upstream version 1.0~rc4+svn34492
* Bump standards version
* Bump dependency on libav >= 4:0.8~, Closes: #653887
* Fix build-indep
* Build mplayer-gui again, Closes: #568514
* Drop debian/all-lang-config-mak.sh, no longer needed
* include .dfsg1 in version number
* remove get-orig-source target
* no longer prune compiler flags from the environment
* No longer advertise nor build 3fdx, mga and dxr3 backends,
  Closes: #496106, #442181, #533546
* beautify mplayer version identification string
* Brown paperbag upload.
* Next try to fix build failure on sparce after recent binutils change.
* Brown paperbag upload.
* Really fix build failure on sparc after recent binutils change.
* Properly set Replaces/Conflicts on mplayer2{,-dbg} to avoid
  file overwrite errors.
* Adjust versioning of mplayer listed in the mplayer-dbg's Depends field.
* Fix build failure on sparc after recent binutils change.
* Urgency medium bumped because of RC-level bugfix
  and speeding up x264 transition.
* Update to my @debian.org email.
* Upload to unstable
* Enable joystick support on Linux only, Closes: #638408
* Rebuild fixes toolchain issue on arm, Closes: #637077
* New upstream snapshot
* following the discussion started by Diego Biurrun <diego@biurrun.de>
  in debian-devel, I have prepared a new packaging of 'mplayer'
  (with code that comes from CVS)
* the upstream tar.bz cannot be distributed by Debian, since it contains
   CSS code; so I am repackaging it 
* I have tried my best to address all known issues:
  - the package contains the detailed Copyright made by Diego Biurrun 
  - the package does not contain CSS code, or  AFAIK other code on which 
     there is active patent enforcement
  - there is a script  debian/cvs-changelog.sh  that shows all changes
     done to files included in this source.
    This should comply with GPLv2 sec 2.a  (in spirit if not in letter)
    For this reason, the source code contains CVS directories.
* needs   make (>= 3.80) for 'html-chunked-$(1)' in DOCS/xml/Makefile

* some corrections, as suggested Diego Biurrun
  - binary codecs should go into /usr/lib/codecs (upstream default)
  - better template 'mplayer/install_codecs'
  - an empty 'font=' in mplayer.conf breaks mplayer: postinst corrected
* correction in 'mplayer/cfgnote'
* better mplayer.postinst and mplayer.config

* New upstream release
* better debian/copyright file
* do not ship a skin
* New upstream release
* changed DEB_BUILD_OPTIONS to DEB_BUILD_CONFIGURE ,
  DEB_BUILD_OPTIONS is used as in debian policy
* use gcc-3.4
* changed xlibs-dev to a long list of dependencies, for Debian/etch
* try to adhere to  http://www.mplayerhq.hu/DOCS/tech/binary-packaging.txt
  (see README.Debian for details)
* removed dependency on xlibmesa-dev, disabled opengl
* New upstream release
* Simon McVittie <hacks@pseudorandom.co.uk> wonderful work:
- Work around Debian bug #267442 (glibc's sys/uio.h and gcc's altivec.h have
  conflicting uses for __vector) by re-ordering #includes
- Fix potential symlink attack in ./configure
- Disable support for binary codecs on platforms for which those codecs
  aren't available; also disable the corresponding Debconf note when it's
  inappropriate
- Changed Build-Depends: so it works in pbuilder
- Explicitly build-depend on libjpeg62-dev, libfontconfig1-dev,
  libungif4-dev 
- Tweak debian/rules to avoid certain errors being ignored
- Use --language=all
* provide a target  'debian/rules get-orig-source' 
  that recreates the orig.tar.gz ; then use the above orig.tar.gz
* rewrote some parts of debian/rules
* don't clean and recompile docs if upstream ships them
* mplayer-doc was shipping too much stuff
* translated man pages where not installed properly
* compile with libdv4-dev
* correct README.Debian
* Forgot build-dep on libtheora
* Must not depend on libxvidcore
* New upstream release
* new release.
* rc1 to become 0.90
* new pre-release
* new pre-release
* gtk bug fixed.
* new release.
* version bumped
* 0.60 pre2 release
* 0.60 pre-release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
#include "amrwbdata.h"
42
42
 
43
43
typedef struct {
 
44
    AVFrame                              avframe; ///< AVFrame for decoded samples
44
45
    AMRWBFrame                             frame; ///< AMRWB parameters decoded from bitstream
45
46
    enum Mode                        fr_cur_mode; ///< mode index of current frame
46
47
    uint8_t                           fr_quality; ///< frame quality index (FQI)
102
103
    for (i = 0; i < 4; i++)
103
104
        ctx->prediction_error[i] = MIN_ENERGY;
104
105
 
 
106
    avcodec_get_frame_defaults(&ctx->avframe);
 
107
    avctx->coded_frame = &ctx->avframe;
 
108
 
105
109
    return 0;
106
110
}
107
111
 
108
112
/**
109
113
 * Decode the frame header in the "MIME/storage" format. This format
110
 
 * is simpler and does not carry the auxiliary information of the frame
 
114
 * is simpler and does not carry the auxiliary frame information.
111
115
 *
112
116
 * @param[in] ctx                  The Context
113
117
 * @param[in] buf                  Pointer to the input buffer
129
133
}
130
134
 
131
135
/**
132
 
 * Decodes quantized ISF vectors using 36-bit indexes (6K60 mode only)
 
136
 * Decode quantized ISF vectors using 36-bit indexes (6K60 mode only).
133
137
 *
134
138
 * @param[in]  ind                 Array of 5 indexes
135
139
 * @param[out] isf_q               Buffer for isf_q[LP_ORDER]
156
160
}
157
161
 
158
162
/**
159
 
 * Decodes quantized ISF vectors using 46-bit indexes (except 6K60 mode)
 
163
 * Decode quantized ISF vectors using 46-bit indexes (except 6K60 mode).
160
164
 *
161
165
 * @param[in]  ind                 Array of 7 indexes
162
166
 * @param[out] isf_q               Buffer for isf_q[LP_ORDER]
189
193
}
190
194
 
191
195
/**
192
 
 * Apply mean and past ISF values using the prediction factor
193
 
 * Updates past ISF vector
 
196
 * Apply mean and past ISF values using the prediction factor.
 
197
 * Updates past ISF vector.
194
198
 *
195
199
 * @param[in,out] isf_q            Current quantized ISF
196
200
 * @param[in,out] isf_past         Past quantized ISF
211
215
 
212
216
/**
213
217
 * Interpolate the fourth ISP vector from current and past frames
214
 
 * to obtain a ISP vector for each subframe
 
218
 * to obtain an ISP vector for each subframe.
215
219
 *
216
220
 * @param[in,out] isp_q            ISPs for each subframe
217
221
 * @param[in]     isp4_past        Past ISP for subframe 4
228
232
}
229
233
 
230
234
/**
231
 
 * Decode an adaptive codebook index into pitch lag (except 6k60, 8k85 modes)
232
 
 * Calculate integer lag and fractional lag always using 1/4 resolution
233
 
 * In 1st and 3rd subframes the index is relative to last subframe integer lag
 
235
 * Decode an adaptive codebook index into pitch lag (except 6k60, 8k85 modes).
 
236
 * Calculate integer lag and fractional lag always using 1/4 resolution.
 
237
 * In 1st and 3rd subframes the index is relative to last subframe integer lag.
234
238
 *
235
239
 * @param[out]    lag_int          Decoded integer pitch lag
236
240
 * @param[out]    lag_frac         Decoded fractional pitch lag
267
271
}
268
272
 
269
273
/**
270
 
 * Decode a adaptive codebook index into pitch lag for 8k85 and 6k60 modes
271
 
 * Description is analogous to decode_pitch_lag_high, but in 6k60 relative
272
 
 * index is used for all subframes except the first
 
274
 * Decode an adaptive codebook index into pitch lag for 8k85 and 6k60 modes.
 
275
 * The description is analogous to decode_pitch_lag_high, but in 6k60 the
 
276
 * relative index is used for all subframes except the first.
273
277
 */
274
278
static void decode_pitch_lag_low(int *lag_int, int *lag_frac, int pitch_index,
275
279
                                 uint8_t *base_lag_int, int subframe, enum Mode mode)
294
298
 
295
299
/**
296
300
 * Find the pitch vector by interpolating the past excitation at the
297
 
 * pitch delay, which is obtained in this function
 
301
 * pitch delay, which is obtained in this function.
298
302
 *
299
303
 * @param[in,out] ctx              The context
300
304
 * @param[in]     amr_subframe     Current subframe data
347
351
/**
348
352
 * The next six functions decode_[i]p_track decode exactly i pulses
349
353
 * positions and amplitudes (-1 or 1) in a subframe track using
350
 
 * an encoded pulse indexing (TS 26.190 section 5.8.2)
 
354
 * an encoded pulse indexing (TS 26.190 section 5.8.2).
351
355
 *
352
356
 * The results are given in out[], in which a negative number means
353
 
 * amplitude -1 and vice versa (i.e., ampl(x) = x / abs(x) )
 
357
 * amplitude -1 and vice versa (i.e., ampl(x) = x / abs(x) ).
354
358
 *
355
359
 * @param[out] out                 Output buffer (writes i elements)
356
360
 * @param[in]  code                Pulse index (no. of bits varies, see below)
466
470
 
467
471
/**
468
472
 * Decode the algebraic codebook index to pulse positions and signs,
469
 
 * then construct the algebraic codebook vector
 
473
 * then construct the algebraic codebook vector.
470
474
 *
471
475
 * @param[out] fixed_vector        Buffer for the fixed codebook excitation
472
476
 * @param[in]  pulse_hi            MSBs part of the pulse index array (higher modes only)
537
541
}
538
542
 
539
543
/**
540
 
 * Decode pitch gain and fixed gain correction factor
 
544
 * Decode pitch gain and fixed gain correction factor.
541
545
 *
542
546
 * @param[in]  vq_gain             Vector-quantized index for gains
543
547
 * @param[in]  mode                Mode of the current frame
555
559
}
556
560
 
557
561
/**
558
 
 * Apply pitch sharpening filters to the fixed codebook vector
 
562
 * Apply pitch sharpening filters to the fixed codebook vector.
559
563
 *
560
564
 * @param[in]     ctx              The context
561
565
 * @param[in,out] fixed_vector     Fixed codebook excitation
576
580
}
577
581
 
578
582
/**
579
 
 * Calculate the voicing factor (-1.0 = unvoiced to 1.0 = voiced)
 
583
 * Calculate the voicing factor (-1.0 = unvoiced to 1.0 = voiced).
580
584
 *
581
585
 * @param[in] p_vector, f_vector   Pitch and fixed excitation vectors
582
586
 * @param[in] p_gain, f_gain       Pitch and fixed gains
595
599
}
596
600
 
597
601
/**
598
 
 * Reduce fixed vector sparseness by smoothing with one of three IR filters
599
 
 * Also known as "adaptive phase dispersion"
 
602
 * Reduce fixed vector sparseness by smoothing with one of three IR filters,
 
603
 * also known as "adaptive phase dispersion".
600
604
 *
601
605
 * @param[in]     ctx              The context
602
606
 * @param[in,out] fixed_vector     Unfiltered fixed vector
666
670
 
667
671
/**
668
672
 * Calculate a stability factor {teta} based on distance between
669
 
 * current and past isf. A value of 1 shows maximum signal stability
 
673
 * current and past isf. A value of 1 shows maximum signal stability.
670
674
 */
671
675
static float stability_factor(const float *isf, const float *isf_past)
672
676
{
683
687
 
684
688
/**
685
689
 * Apply a non-linear fixed gain smoothing in order to reduce
686
 
 * fluctuation in the energy of excitation
 
690
 * fluctuation in the energy of excitation.
687
691
 *
688
692
 * @param[in]     fixed_gain       Unsmoothed fixed gain
689
693
 * @param[in,out] prev_tr_gain     Previous threshold gain (updated)
714
718
}
715
719
 
716
720
/**
717
 
 * Filter the fixed_vector to emphasize the higher frequencies
 
721
 * Filter the fixed_vector to emphasize the higher frequencies.
718
722
 *
719
723
 * @param[in,out] fixed_vector     Fixed codebook vector
720
724
 * @param[in]     voice_fac        Frame voicing factor
738
742
}
739
743
 
740
744
/**
741
 
 * Conduct 16th order linear predictive coding synthesis from excitation
 
745
 * Conduct 16th order linear predictive coding synthesis from excitation.
742
746
 *
743
747
 * @param[in]     ctx              Pointer to the AMRWBContext
744
748
 * @param[in]     lpc              Pointer to the LPC coefficients
798
802
 
799
803
/**
800
804
 * Upsample a signal by 5/4 ratio (from 12.8kHz to 16kHz) using
801
 
 * a FIR interpolation filter. Uses past data from before *in address
 
805
 * a FIR interpolation filter. Uses past data from before *in address.
802
806
 *
803
807
 * @param[out] out                 Buffer for interpolated signal
804
808
 * @param[in]  in                  Current signal data (length 0.8*o_size)
828
832
 
829
833
/**
830
834
 * Calculate the high-band gain based on encoded index (23k85 mode) or
831
 
 * on the low-band speech signal and the Voice Activity Detection flag
 
835
 * on the low-band speech signal and the Voice Activity Detection flag.
832
836
 *
833
837
 * @param[in] ctx                  The context
834
838
 * @param[in] synth                LB speech synthesis at 12.8k
853
857
 
854
858
/**
855
859
 * Generate the high-band excitation with the same energy from the lower
856
 
 * one and scaled by the given gain
 
860
 * one and scaled by the given gain.
857
861
 *
858
862
 * @param[in]  ctx                 The context
859
863
 * @param[out] hb_exc              Buffer for the excitation
876
880
}
877
881
 
878
882
/**
879
 
 * Calculate the auto-correlation for the ISF difference vector
 
883
 * Calculate the auto-correlation for the ISF difference vector.
880
884
 */
881
885
static float auto_correlation(float *diff_isf, float mean, int lag)
882
886
{
892
896
 
893
897
/**
894
898
 * Extrapolate a ISF vector to the 16kHz range (20th order LP)
895
 
 * used at mode 6k60 LP filter for the high frequency band
 
899
 * used at mode 6k60 LP filter for the high frequency band.
896
900
 *
897
901
 * @param[out] out                 Buffer for extrapolated isf
898
902
 * @param[in]  isf                 Input isf vector
977
981
 
978
982
/**
979
983
 * Conduct 20th order linear predictive coding synthesis for the high
980
 
 * frequency band excitation at 16kHz
 
984
 * frequency band excitation at 16kHz.
981
985
 *
982
986
 * @param[in]     ctx              The context
983
987
 * @param[in]     subframe         Current subframe index (0 to 3)
1015
1019
}
1016
1020
 
1017
1021
/**
1018
 
 * Apply to high-band samples a 15th order filter
1019
 
 * The filter characteristic depends on the given coefficients
 
1022
 * Apply a 15th order filter to high-band samples.
 
1023
 * The filter characteristic depends on the given coefficients.
1020
1024
 *
1021
1025
 * @param[out]    out              Buffer for filtered output
1022
1026
 * @param[in]     fir_coef         Filter coefficients
1044
1048
}
1045
1049
 
1046
1050
/**
1047
 
 * Update context state before the next subframe
 
1051
 * Update context state before the next subframe.
1048
1052
 */
1049
1053
static void update_sub_state(AMRWBContext *ctx)
1050
1054
{
1062
1066
            LP_ORDER_16k * sizeof(float));
1063
1067
}
1064
1068
 
1065
 
static int amrwb_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
1066
 
                              AVPacket *avpkt)
 
1069
static int amrwb_decode_frame(AVCodecContext *avctx, void *data,
 
1070
                              int *got_frame_ptr, AVPacket *avpkt)
1067
1071
{
1068
1072
    AMRWBContext *ctx  = avctx->priv_data;
1069
1073
    AMRWBFrame   *cf   = &ctx->frame;
1070
1074
    const uint8_t *buf = avpkt->data;
1071
1075
    int buf_size       = avpkt->size;
1072
1076
    int expected_fr_size, header_size;
1073
 
    float *buf_out = data;
 
1077
    float *buf_out;
1074
1078
    float spare_vector[AMRWB_SFR_SIZE];      // extra stack space to hold result from anti-sparseness processing
1075
1079
    float fixed_gain_factor;                 // fixed gain correction factor (gamma)
1076
1080
    float *synth_fixed_vector;               // pointer to the fixed vector that synthesis should use
1080
1084
    float hb_exc[AMRWB_SFR_SIZE_16k];        // excitation for the high frequency band
1081
1085
    float hb_samples[AMRWB_SFR_SIZE_16k];    // filtered high-band samples from synthesis
1082
1086
    float hb_gain;
1083
 
    int sub, i;
 
1087
    int sub, i, ret;
 
1088
 
 
1089
    /* get output buffer */
 
1090
    ctx->avframe.nb_samples = 4 * AMRWB_SFR_SIZE_16k;
 
1091
    if ((ret = avctx->get_buffer(avctx, &ctx->avframe)) < 0) {
 
1092
        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
 
1093
        return ret;
 
1094
    }
 
1095
    buf_out = (float *)ctx->avframe.data[0];
1084
1096
 
1085
1097
    header_size      = decode_mime_header(ctx, buf);
1086
1098
    expected_fr_size = ((cf_sizes_wb[ctx->fr_cur_mode] + 7) >> 3) + 1;
1088
1100
    if (buf_size < expected_fr_size) {
1089
1101
        av_log(avctx, AV_LOG_ERROR,
1090
1102
            "Frame too small (%d bytes). Truncated file?\n", buf_size);
1091
 
        *data_size = 0;
 
1103
        *got_frame_ptr = 0;
1092
1104
        return buf_size;
1093
1105
    }
1094
1106
 
1219
1231
    memcpy(ctx->isp_sub4_past, ctx->isp[3], LP_ORDER * sizeof(ctx->isp[3][0]));
1220
1232
    memcpy(ctx->isf_past_final, ctx->isf_cur, LP_ORDER * sizeof(float));
1221
1233
 
1222
 
    /* report how many samples we got */
1223
 
    *data_size = 4 * AMRWB_SFR_SIZE_16k * sizeof(float);
 
1234
    *got_frame_ptr   = 1;
 
1235
    *(AVFrame *)data = ctx->avframe;
1224
1236
 
1225
1237
    return expected_fr_size;
1226
1238
}
1232
1244
    .priv_data_size = sizeof(AMRWBContext),
1233
1245
    .init           = amrwb_decode_init,
1234
1246
    .decode         = amrwb_decode_frame,
 
1247
    .capabilities   = CODEC_CAP_DR1,
1235
1248
    .long_name      = NULL_IF_CONFIG_SMALL("Adaptive Multi-Rate WideBand"),
1236
1249
    .sample_fmts    = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE},
1237
1250
};