MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / decode_coeffs

Function decode_coeffs

libavcodec/wmaprodec.c:919–1018  ·  view source on GitHub ↗

*@brief Extract the coefficients from the bitstream. *@param s codec context *@param c current channel number *@return 0 on success, < 0 in case of bitstream errors */

Source from the content-addressed store, hash-verified

917 *@return 0 on success, < 0 in case of bitstream errors
918 */
919static int decode_coeffs(WMAProDecodeCtx *s, int c)
920{
921 /* Integers 0..15 as single-precision floats. The table saves a
922 costly int to float conversion, and storing the values as
923 integers allows fast sign-flipping. */
924 static const uint32_t fval_tab[16] = {
925 0x00000000, 0x3f800000, 0x40000000, 0x40400000,
926 0x40800000, 0x40a00000, 0x40c00000, 0x40e00000,
927 0x41000000, 0x41100000, 0x41200000, 0x41300000,
928 0x41400000, 0x41500000, 0x41600000, 0x41700000,
929 };
930 int vlctable;
931 const VLCElem *vlc;
932 WMAProChannelCtx* ci = &s->channel[c];
933 int rl_mode = 0;
934 int cur_coeff = 0;
935 int num_zeros = 0;
936 const uint16_t* run;
937 const float* level;
938
939 ff_dlog(s->avctx, "decode coefficients for channel %i\n", c);
940
941 vlctable = get_bits1(&s->gb);
942 vlc = coef_vlc[vlctable];
943
944 if (vlctable) {
945 run = coef1_run;
946 level = coef1_level;
947 } else {
948 run = coef0_run;
949 level = coef0_level;
950 }
951
952 /** decode vector coefficients (consumes up to 167 bits per iteration for
953 4 vector coded large values) */
954 while ((s->transmit_num_vec_coeffs || !rl_mode) &&
955 (cur_coeff + 3 < ci->num_vec_coeffs)) {
956 uint32_t vals[4];
957 int i;
958 unsigned int idx;
959
960 idx = get_vlc2(&s->gb, vec4_vlc, VLCBITS, VEC4MAXDEPTH);
961
962 if ((int)idx < 0) {
963 for (i = 0; i < 4; i += 2) {
964 idx = get_vlc2(&s->gb, vec2_vlc, VLCBITS, VEC2MAXDEPTH);
965 if ((int)idx < 0) {
966 uint32_t v0, v1;
967 v0 = get_vlc2(&s->gb, vec1_vlc, VLCBITS, VEC1MAXDEPTH);
968 if (v0 == HUFF_VEC1_SIZE - 1)
969 v0 += ff_wma_get_large_val(&s->gb);
970 v1 = get_vlc2(&s->gb, vec1_vlc, VLCBITS, VEC1MAXDEPTH);
971 if (v1 == HUFF_VEC1_SIZE - 1)
972 v1 += ff_wma_get_large_val(&s->gb);
973 vals[i ] = av_float2int(v0);
974 vals[i+1] = av_float2int(v1);
975 } else {
976 vals[i] = fval_tab[idx >> 4 ];

Callers 1

decode_subframeFunction · 0.70

Calls 5

get_bits1Function · 0.85
get_vlc2Function · 0.85
ff_wma_get_large_valFunction · 0.85
av_float2intFunction · 0.85
ff_wma_run_level_decodeFunction · 0.85

Tested by

no test coverage detected