ralf.c
Go to the documentation of this file.
1 /*
2  * RealAudio Lossless decoder
3  *
4  * Copyright (c) 2012 Konstantin Shishkov
5  *
6  * This file is part of Libav.
7  *
8  * Libav is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * Libav is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with Libav; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 /**
24  * @file
25  * This is a decoder for Real Audio Lossless format.
26  * Dedicated to the mastermind behind it, Ralph Wiggum.
27  */
28 
30 #include "avcodec.h"
31 #include "get_bits.h"
32 #include "golomb.h"
33 #include "internal.h"
34 #include "unary.h"
35 #include "ralfdata.h"
36 
37 #define FILTER_NONE 0
38 #define FILTER_RAW 642
39 
40 typedef struct VLCSet {
44  VLC filter_coeffs[10][11];
47 } VLCSet;
48 
49 #define RALF_MAX_PKT_SIZE 8192
50 
51 typedef struct RALFContext {
52  int version;
54  VLCSet sets[3];
55  int32_t channel_data[2][4096];
56 
57  int filter_params; ///< combined filter parameters for the current channel data
58  int filter_length; ///< length of the filter for the current channel data
59  int filter_bits; ///< filter precision for the current channel data
61 
62  int bias[2]; ///< a constant value added to channel data after filtering
63 
64  int num_blocks; ///< number of blocks inside the frame
66  int block_size[1 << 12]; ///< size of the blocks
67  int block_pts[1 << 12]; ///< block start time (in milliseconds)
68 
69  uint8_t pkt[16384];
70  int has_pkt;
71 } RALFContext;
72 
73 #define MAX_ELEMS 644 // no RALF table uses more than that
74 
75 static int init_ralf_vlc(VLC *vlc, const uint8_t *data, int elems)
76 {
77  uint8_t lens[MAX_ELEMS];
78  uint16_t codes[MAX_ELEMS];
79  int counts[17], prefixes[18];
80  int i, cur_len;
81  int max_bits = 0;
82  int nb = 0;
83 
84  for (i = 0; i <= 16; i++)
85  counts[i] = 0;
86  for (i = 0; i < elems; i++) {
87  cur_len = (nb ? *data & 0xF : *data >> 4) + 1;
88  counts[cur_len]++;
89  max_bits = FFMAX(max_bits, cur_len);
90  lens[i] = cur_len;
91  data += nb;
92  nb ^= 1;
93  }
94  prefixes[1] = 0;
95  for (i = 1; i <= 16; i++)
96  prefixes[i + 1] = (prefixes[i] + counts[i]) << 1;
97 
98  for (i = 0; i < elems; i++)
99  codes[i] = prefixes[lens[i]]++;
100 
101  return ff_init_vlc_sparse(vlc, FFMIN(max_bits, 9), elems,
102  lens, 1, 1, codes, 2, 2, NULL, 0, 0, 0);
103 }
104 
106 {
107  RALFContext *ctx = avctx->priv_data;
108  int i, j, k;
109 
110  for (i = 0; i < 3; i++) {
111  ff_free_vlc(&ctx->sets[i].filter_params);
112  ff_free_vlc(&ctx->sets[i].bias);
113  ff_free_vlc(&ctx->sets[i].coding_mode);
114  for (j = 0; j < 10; j++)
115  for (k = 0; k < 11; k++)
116  ff_free_vlc(&ctx->sets[i].filter_coeffs[j][k]);
117  for (j = 0; j < 15; j++)
118  ff_free_vlc(&ctx->sets[i].short_codes[j]);
119  for (j = 0; j < 125; j++)
120  ff_free_vlc(&ctx->sets[i].long_codes[j]);
121  }
122 
123  return 0;
124 }
125 
127 {
128  RALFContext *ctx = avctx->priv_data;
129  int i, j, k;
130  int ret;
131 
132  if (avctx->extradata_size < 24 || memcmp(avctx->extradata, "LSD:", 4)) {
133  av_log(avctx, AV_LOG_ERROR, "Extradata is not groovy, dude\n");
134  return AVERROR_INVALIDDATA;
135  }
136 
137  ctx->version = AV_RB16(avctx->extradata + 4);
138  if (ctx->version != 0x103) {
139  avpriv_request_sample(avctx, "Unknown version %X", ctx->version);
140  return AVERROR_PATCHWELCOME;
141  }
142 
143  avctx->channels = AV_RB16(avctx->extradata + 8);
144  avctx->sample_rate = AV_RB32(avctx->extradata + 12);
145  if (avctx->channels < 1 || avctx->channels > 2
146  || avctx->sample_rate < 8000 || avctx->sample_rate > 96000) {
147  av_log(avctx, AV_LOG_ERROR, "Invalid coding parameters %d Hz %d ch\n",
148  avctx->sample_rate, avctx->channels);
149  return AVERROR_INVALIDDATA;
150  }
152  avctx->channel_layout = (avctx->channels == 2) ? AV_CH_LAYOUT_STEREO
154 
155  ctx->max_frame_size = AV_RB32(avctx->extradata + 16);
156  if (ctx->max_frame_size > (1 << 20) || !ctx->max_frame_size) {
157  av_log(avctx, AV_LOG_ERROR, "invalid frame size %d\n",
158  ctx->max_frame_size);
159  }
160  ctx->max_frame_size = FFMAX(ctx->max_frame_size, avctx->sample_rate);
161 
162  for (i = 0; i < 3; i++) {
165  if (ret < 0) {
166  decode_close(avctx);
167  return ret;
168  }
169  ret = init_ralf_vlc(&ctx->sets[i].bias, bias_def[i], BIAS_ELEMENTS);
170  if (ret < 0) {
171  decode_close(avctx);
172  return ret;
173  }
174  ret = init_ralf_vlc(&ctx->sets[i].coding_mode, coding_mode_def[i],
176  if (ret < 0) {
177  decode_close(avctx);
178  return ret;
179  }
180  for (j = 0; j < 10; j++) {
181  for (k = 0; k < 11; k++) {
182  ret = init_ralf_vlc(&ctx->sets[i].filter_coeffs[j][k],
183  filter_coeffs_def[i][j][k],
185  if (ret < 0) {
186  decode_close(avctx);
187  return ret;
188  }
189  }
190  }
191  for (j = 0; j < 15; j++) {
192  ret = init_ralf_vlc(&ctx->sets[i].short_codes[j],
194  if (ret < 0) {
195  decode_close(avctx);
196  return ret;
197  }
198  }
199  for (j = 0; j < 125; j++) {
200  ret = init_ralf_vlc(&ctx->sets[i].long_codes[j],
202  if (ret < 0) {
203  decode_close(avctx);
204  return ret;
205  }
206  }
207  }
208 
209  return 0;
210 }
211 
212 static inline int extend_code(GetBitContext *gb, int val, int range, int bits)
213 {
214  if (val == 0) {
215  val = -range - get_ue_golomb(gb);
216  } else if (val == range * 2) {
217  val = range + get_ue_golomb(gb);
218  } else {
219  val -= range;
220  }
221  if (bits)
222  val = (val << bits) | get_bits(gb, bits);
223  return val;
224 }
225 
226 static int decode_channel(RALFContext *ctx, GetBitContext *gb, int ch,
227  int length, int mode, int bits)
228 {
229  int i, t;
230  int code_params;
231  VLCSet *set = ctx->sets + mode;
232  VLC *code_vlc; int range, range2, add_bits;
233  int *dst = ctx->channel_data[ch];
234 
235  ctx->filter_params = get_vlc2(gb, set->filter_params.table, 9, 2);
236  ctx->filter_bits = (ctx->filter_params - 2) >> 6;
237  ctx->filter_length = ctx->filter_params - (ctx->filter_bits << 6) - 1;
238 
239  if (ctx->filter_params == FILTER_RAW) {
240  for (i = 0; i < length; i++)
241  dst[i] = get_bits(gb, bits);
242  ctx->bias[ch] = 0;
243  return 0;
244  }
245 
246  ctx->bias[ch] = get_vlc2(gb, set->bias.table, 9, 2);
247  ctx->bias[ch] = extend_code(gb, ctx->bias[ch], 127, 4);
248 
249  if (ctx->filter_params == FILTER_NONE) {
250  memset(dst, 0, sizeof(*dst) * length);
251  return 0;
252  }
253 
254  if (ctx->filter_params > 1) {
255  int cmode = 0, coeff = 0;
256  VLC *vlc = set->filter_coeffs[ctx->filter_bits] + 5;
257 
258  add_bits = ctx->filter_bits;
259 
260  for (i = 0; i < ctx->filter_length; i++) {
261  t = get_vlc2(gb, vlc[cmode].table, vlc[cmode].bits, 2);
262  t = extend_code(gb, t, 21, add_bits);
263  if (!cmode)
264  coeff -= 12 << add_bits;
265  coeff = t - coeff;
266  ctx->filter[i] = coeff;
267 
268  cmode = coeff >> add_bits;
269  if (cmode < 0) {
270  cmode = -1 - av_log2(-cmode);
271  if (cmode < -5)
272  cmode = -5;
273  } else if (cmode > 0) {
274  cmode = 1 + av_log2(cmode);
275  if (cmode > 5)
276  cmode = 5;
277  }
278  }
279  }
280 
281  code_params = get_vlc2(gb, set->coding_mode.table, set->coding_mode.bits, 2);
282  if (code_params >= 15) {
283  add_bits = av_clip((code_params / 5 - 3) / 2, 0, 10);
284  if (add_bits > 9 && (code_params % 5) != 2)
285  add_bits--;
286  range = 10;
287  range2 = 21;
288  code_vlc = set->long_codes + code_params - 15;
289  } else {
290  add_bits = 0;
291  range = 6;
292  range2 = 13;
293  code_vlc = set->short_codes + code_params;
294  }
295 
296  for (i = 0; i < length; i += 2) {
297  int code1, code2;
298 
299  t = get_vlc2(gb, code_vlc->table, code_vlc->bits, 2);
300  code1 = t / range2;
301  code2 = t % range2;
302  dst[i] = extend_code(gb, code1, range, 0) << add_bits;
303  dst[i + 1] = extend_code(gb, code2, range, 0) << add_bits;
304  if (add_bits) {
305  dst[i] |= get_bits(gb, add_bits);
306  dst[i + 1] |= get_bits(gb, add_bits);
307  }
308  }
309 
310  return 0;
311 }
312 
313 static void apply_lpc(RALFContext *ctx, int ch, int length, int bits)
314 {
315  int i, j, acc;
316  int *audio = ctx->channel_data[ch];
317  int bias = 1 << (ctx->filter_bits - 1);
318  int max_clip = (1 << bits) - 1, min_clip = -max_clip - 1;
319 
320  for (i = 1; i < length; i++) {
321  int flen = FFMIN(ctx->filter_length, i);
322 
323  acc = 0;
324  for (j = 0; j < flen; j++)
325  acc += ctx->filter[j] * audio[i - j - 1];
326  if (acc < 0) {
327  acc = (acc + bias - 1) >> ctx->filter_bits;
328  acc = FFMAX(acc, min_clip);
329  } else {
330  acc = (acc + bias) >> ctx->filter_bits;
331  acc = FFMIN(acc, max_clip);
332  }
333  audio[i] += acc;
334  }
335 }
336 
338  int16_t *dst0, int16_t *dst1)
339 {
340  RALFContext *ctx = avctx->priv_data;
341  int len, ch, ret;
342  int dmode, mode[2], bits[2];
343  int *ch0, *ch1;
344  int i, t, t2;
345 
346  len = 12 - get_unary(gb, 0, 6);
347 
348  if (len <= 7) len ^= 1; // codes for length = 6 and 7 are swapped
349  len = 1 << len;
350 
351  if (ctx->sample_offset + len > ctx->max_frame_size) {
352  av_log(avctx, AV_LOG_ERROR,
353  "Decoder's stomach is crying, it ate too many samples\n");
354  return AVERROR_INVALIDDATA;
355  }
356 
357  if (avctx->channels > 1)
358  dmode = get_bits(gb, 2) + 1;
359  else
360  dmode = 0;
361 
362  mode[0] = (dmode == 4) ? 1 : 0;
363  mode[1] = (dmode >= 2) ? 2 : 0;
364  bits[0] = 16;
365  bits[1] = (mode[1] == 2) ? 17 : 16;
366 
367  for (ch = 0; ch < avctx->channels; ch++) {
368  if ((ret = decode_channel(ctx, gb, ch, len, mode[ch], bits[ch])) < 0)
369  return ret;
370  if (ctx->filter_params > 1 && ctx->filter_params != FILTER_RAW) {
371  ctx->filter_bits += 3;
372  apply_lpc(ctx, ch, len, bits[ch]);
373  }
374  if (get_bits_left(gb) < 0)
375  return AVERROR_INVALIDDATA;
376  }
377  ch0 = ctx->channel_data[0];
378  ch1 = ctx->channel_data[1];
379  switch (dmode) {
380  case 0:
381  for (i = 0; i < len; i++)
382  dst0[i] = ch0[i] + ctx->bias[0];
383  break;
384  case 1:
385  for (i = 0; i < len; i++) {
386  dst0[i] = ch0[i] + ctx->bias[0];
387  dst1[i] = ch1[i] + ctx->bias[1];
388  }
389  break;
390  case 2:
391  for (i = 0; i < len; i++) {
392  ch0[i] += ctx->bias[0];
393  dst0[i] = ch0[i];
394  dst1[i] = ch0[i] - (ch1[i] + ctx->bias[1]);
395  }
396  break;
397  case 3:
398  for (i = 0; i < len; i++) {
399  t = ch0[i] + ctx->bias[0];
400  t2 = ch1[i] + ctx->bias[1];
401  dst0[i] = t + t2;
402  dst1[i] = t;
403  }
404  break;
405  case 4:
406  for (i = 0; i < len; i++) {
407  t = ch1[i] + ctx->bias[1];
408  t2 = ((ch0[i] + ctx->bias[0]) << 1) | (t & 1);
409  dst0[i] = (t2 + t) / 2;
410  dst1[i] = (t2 - t) / 2;
411  }
412  break;
413  }
414 
415  ctx->sample_offset += len;
416 
417  return 0;
418 }
419 
420 static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
421  AVPacket *avpkt)
422 {
423  RALFContext *ctx = avctx->priv_data;
424  AVFrame *frame = data;
425  int16_t *samples0;
426  int16_t *samples1;
427  int ret;
428  GetBitContext gb;
429  int table_size, table_bytes, i;
430  const uint8_t *src, *block_pointer;
431  int src_size;
432  int bytes_left;
433 
434  if (ctx->has_pkt) {
435  ctx->has_pkt = 0;
436  table_bytes = (AV_RB16(avpkt->data) + 7) >> 3;
437  if (table_bytes + 3 > avpkt->size || avpkt->size > RALF_MAX_PKT_SIZE) {
438  av_log(avctx, AV_LOG_ERROR, "Wrong packet's breath smells of wrong data!\n");
439  return AVERROR_INVALIDDATA;
440  }
441  if (memcmp(ctx->pkt, avpkt->data, 2 + table_bytes)) {
442  av_log(avctx, AV_LOG_ERROR, "Wrong packet tails are wrong!\n");
443  return AVERROR_INVALIDDATA;
444  }
445 
446  src = ctx->pkt;
447  src_size = RALF_MAX_PKT_SIZE + avpkt->size;
448  memcpy(ctx->pkt + RALF_MAX_PKT_SIZE, avpkt->data + 2 + table_bytes,
449  avpkt->size - 2 - table_bytes);
450  } else {
451  if (avpkt->size == RALF_MAX_PKT_SIZE) {
452  memcpy(ctx->pkt, avpkt->data, avpkt->size);
453  ctx->has_pkt = 1;
454  *got_frame_ptr = 0;
455 
456  return avpkt->size;
457  }
458  src = avpkt->data;
459  src_size = avpkt->size;
460  }
461 
462  frame->nb_samples = ctx->max_frame_size;
463  if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
464  return ret;
465  samples0 = (int16_t *)frame->data[0];
466  samples1 = (int16_t *)frame->data[1];
467 
468  if (src_size < 5) {
469  av_log(avctx, AV_LOG_ERROR, "too short packets are too short!\n");
470  return AVERROR_INVALIDDATA;
471  }
472  table_size = AV_RB16(src);
473  table_bytes = (table_size + 7) >> 3;
474  if (src_size < table_bytes + 3) {
475  av_log(avctx, AV_LOG_ERROR, "short packets are short!\n");
476  return AVERROR_INVALIDDATA;
477  }
478  init_get_bits(&gb, src + 2, table_size);
479  ctx->num_blocks = 0;
480  while (get_bits_left(&gb) > 0) {
481  ctx->block_size[ctx->num_blocks] = get_bits(&gb, 15);
482  if (get_bits1(&gb)) {
483  ctx->block_pts[ctx->num_blocks] = get_bits(&gb, 9);
484  } else {
485  ctx->block_pts[ctx->num_blocks] = 0;
486  }
487  ctx->num_blocks++;
488  }
489 
490  block_pointer = src + table_bytes + 2;
491  bytes_left = src_size - table_bytes - 2;
492  ctx->sample_offset = 0;
493  for (i = 0; i < ctx->num_blocks; i++) {
494  if (bytes_left < ctx->block_size[i]) {
495  av_log(avctx, AV_LOG_ERROR, "I'm pedaling backwards\n");
496  break;
497  }
498  init_get_bits(&gb, block_pointer, ctx->block_size[i] * 8);
499  if (decode_block(avctx, &gb, samples0 + ctx->sample_offset,
500  samples1 + ctx->sample_offset) < 0) {
501  av_log(avctx, AV_LOG_ERROR, "Sir, I got carsick in your office. Not decoding the rest of packet.\n");
502  break;
503  }
504  block_pointer += ctx->block_size[i];
505  bytes_left -= ctx->block_size[i];
506  }
507 
508  frame->nb_samples = ctx->sample_offset;
509  *got_frame_ptr = ctx->sample_offset > 0;
510 
511  return avpkt->size;
512 }
513 
514 static void decode_flush(AVCodecContext *avctx)
515 {
516  RALFContext *ctx = avctx->priv_data;
517 
518  ctx->has_pkt = 0;
519 }
520 
521 
523  .name = "ralf",
524  .type = AVMEDIA_TYPE_AUDIO,
525  .id = AV_CODEC_ID_RALF,
526  .priv_data_size = sizeof(RALFContext),
527  .init = decode_init,
528  .close = decode_close,
529  .decode = decode_frame,
530  .flush = decode_flush,
531  .capabilities = CODEC_CAP_DR1,
532  .long_name = NULL_IF_CONFIG_SMALL("RealAudio Lossless"),
533  .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
535 };
int max_frame_size
Definition: ralf.c:53
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
This structure describes decoded (raw) audio or video data.
Definition: frame.h:76
static void set(uint8_t *a[], int ch, int index, int ch_count, enum AVSampleFormat f, double v)
int num_blocks
number of blocks inside the frame
Definition: ralf.c:64
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:240
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
int acc
Definition: yuv2rgb.c:519
VLC filter_params
Definition: ralf.c:41
location of range
#define AV_CH_LAYOUT_STEREO
static const uint8_t bias_def[3][128]
Definition: ralfdata.h:123
static int init_ralf_vlc(VLC *vlc, const uint8_t *data, int elems)
Definition: ralf.c:75
initialize output if(nPeaks >3)%at least 3 peaks in spectrum for trying to find f0 nf0peaks
#define MAX_ELEMS
Definition: ralf.c:73
#define FILTER_NONE
Definition: ralf.c:37
static const uint8_t filter_coeffs_def[3][10][11][24]
Definition: ralfdata.h:188
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, const void *symbols, int symbols_wrap, int symbols_size, int flags)
Definition: bitstream.c:262
uint8_t bits
Definition: crc.c:216
enum AVSampleFormat sample_fmt
audio sample format
uint8_t
#define av_cold
Definition: attributes.h:78
mode
Definition: f_perms.c:27
#define AV_RB32
static AVPacket pkt
Definition: demuxing.c:56
int sample_offset
Definition: ralf.c:65
static int decode_block(AVCodecContext *avctx, GetBitContext *gb, int16_t *dst0, int16_t *dst1)
Definition: ralf.c:337
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
the mask is usually to keep the same permissions Filters should remove permissions on reference they give to output whenever necessary It can be automatically done by setting the rej_perms field on the output pad Here are a few guidelines corresponding to common then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
uint8_t * data
bitstream reader API header.
struct RALFContext RALFContext
int version
Definition: ralf.c:52
frame
Definition: stft.m:14
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:557
static int get_ue_golomb(GetBitContext *gb)
read unsigned exp golomb code.
Definition: golomb.h:53
struct VLCSet VLCSet
#define AV_RB16
int filter_bits
filter precision for the current channel data
Definition: ralf.c:59
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
Definition: ralf.c:420
int has_pkt
Definition: ralf.c:70
static void decode_flush(AVCodecContext *avctx)
Definition: ralf.c:514
static const struct endianess table[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_cold int decode_close(AVCodecContext *avctx)
Definition: ralf.c:105
Spectrum Plot time data
static int decode_channel(RALFContext *ctx, GetBitContext *gb, int ch, int length, int mode, int bits)
Definition: ralf.c:226
static const uint8_t long_codes_def[3][125][224]
Definition: ralfdata.h:2036
#define RALF_MAX_PKT_SIZE
Definition: ralf.c:49
VLC coding_mode
Definition: ralf.c:43
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:246
const char * name
Name of the codec implementation.
#define FFMAX(a, b)
Definition: common.h:56
external API header
Definition: get_bits.h:63
uint64_t channel_layout
Audio channel layout.
int32_t channel_data[2][4096]
Definition: ralf.c:55
VLCSet sets[3]
Definition: ralf.c:54
audio channel layout utility functions
#define FILTER_COEFFS_ELEMENTS
Definition: ralfdata.h:31
#define FFMIN(a, b)
Definition: common.h:58
#define FILTER_RAW
Definition: ralf.c:38
ret
Definition: avfilter.c:821
t
Definition: genspecsines3.m:6
#define SHORT_CODES_ELEMENTS
Definition: ralfdata.h:32
int32_t
static const uint8_t coding_mode_def[3][72]
Definition: ralfdata.h:163
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
Definition: get_bits.h:524
static void flush(AVCodecContext *avctx)
int bits
Definition: get_bits.h:64
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:62
for k
int32_t filter[64]
Definition: ralf.c:60
NULL
Definition: eval.c:55
int filter_params
combined filter parameters for the current channel data
Definition: ralf.c:57
uint8_t pkt[16384]
Definition: ralf.c:69
AVS_Value src
Definition: avisynth_c.h:523
int sample_rate
samples per second
AVCodec ff_ralf_decoder
Definition: ralf.c:522
#define FILTERPARAM_ELEMENTS
Definition: ralfdata.h:28
main external API structure.
static void close(AVCodecParserContext *s)
Definition: h264_parser.c:375
static VLC code_vlc
Definition: wnv1.c:47
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:148
VLC long_codes[125]
Definition: ralf.c:46
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:273
synthesis window for stochastic i
Definition: ralf.c:40
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
Definition: get_bits.h:379
static const double coeff[2][5]
Definition: vf_ow.c:64
VLC short_codes[15]
Definition: ralf.c:45
VLC filter_coeffs[10][11]
Definition: ralf.c:44
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:87
int block_size[1<< 12]
size of the blocks
Definition: ralf.c:66
int block_pts[1<< 12]
block start time (in milliseconds)
Definition: ralf.c:67
#define CODING_MODE_ELEMENTS
Definition: ralfdata.h:30
common internal api header.
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length.
Definition: unary.h:33
AVSampleFormat
Audio Sample Formats.
Definition: samplefmt.h:49
static const uint8_t short_codes_def[3][15][88]
Definition: ralfdata.h:1577
VLC bias
Definition: ralf.c:42
int filter_length
length of the filter for the current channel data
Definition: ralf.c:58
static av_cold int decode_init(AVCodecContext *avctx)
Definition: ralf.c:126
static int extend_code(GetBitContext *gb, int val, int range, int bits)
Definition: ralf.c:212
int len
int channels
number of audio channels
#define av_log2
Definition: intmath.h:89
else dst[i][x+y *dst_stride[i]]
Definition: vf_mcdeint.c:160
VLC_TYPE(* table)[2]
code, bits
Definition: get_bits.h:65
static const uint8_t filter_param_def[3][324]
Definition: ralfdata.h:35
int bias[2]
a constant value added to channel data after filtering
Definition: ralf.c:62
signed 16 bits, planar
Definition: samplefmt.h:58
#define BIAS_ELEMENTS
Definition: ralfdata.h:29
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: crystalhd.c:868
#define LONG_CODES_ELEMENTS
Definition: ralfdata.h:33
const char int length
Definition: avisynth_c.h:668
#define AV_CH_LAYOUT_MONO
static void apply_lpc(RALFContext *ctx, int ch, int length, int bits)
Definition: ralf.c:313
exp golomb vlc stuff
This structure stores compressed data.
void ff_free_vlc(VLC *vlc)
Definition: bitstream.c:344
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:127
for(j=16;j >0;--j)
#define t2
Definition: regdef.h:30