FFmpeg  4.4.7
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 FFmpeg.
7  *
8  * FFmpeg 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  * FFmpeg 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 FFmpeg; 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 
29 #include "libavutil/attributes.h"
31 #include "avcodec.h"
32 #include "get_bits.h"
33 #include "golomb.h"
34 #include "internal.h"
35 #include "unary.h"
36 #include "ralfdata.h"
37 
38 #define FILTER_NONE 0
39 #define FILTER_RAW 642
40 
41 typedef struct VLCSet {
45  VLC filter_coeffs[10][11];
48 } VLCSet;
49 
50 #define RALF_MAX_PKT_SIZE 8192
51 
52 typedef struct RALFContext {
53  int version;
57 
58  int filter_params; ///< combined filter parameters for the current channel data
59  int filter_length; ///< length of the filter for the current channel data
60  int filter_bits; ///< filter precision for the current channel data
62 
63  unsigned bias[2]; ///< a constant value added to channel data after filtering
64 
65  int num_blocks; ///< number of blocks inside the frame
67  int block_size[1 << 12]; ///< size of the blocks
68  int block_pts[1 << 12]; ///< block start time (in milliseconds)
69 
70  uint8_t pkt[16384];
71  int has_pkt;
72 } RALFContext;
73 
74 #define MAX_ELEMS 644 // no RALF table uses more than that
75 
76 static av_cold int init_ralf_vlc(VLC *vlc, const uint8_t *data, int elems)
77 {
78  uint8_t lens[MAX_ELEMS];
79  uint16_t codes[MAX_ELEMS];
80  int counts[17], prefixes[18];
81  int i, cur_len;
82  int max_bits = 0;
83  int nb = 0;
84 
85  for (i = 0; i <= 16; i++)
86  counts[i] = 0;
87  for (i = 0; i < elems; i++) {
88  cur_len = (nb ? *data & 0xF : *data >> 4) + 1;
89  counts[cur_len]++;
90  max_bits = FFMAX(max_bits, cur_len);
91  lens[i] = cur_len;
92  data += nb;
93  nb ^= 1;
94  }
95  prefixes[1] = 0;
96  for (i = 1; i <= 16; i++)
97  prefixes[i + 1] = (prefixes[i] + counts[i]) << 1;
98 
99  for (i = 0; i < elems; i++)
100  codes[i] = prefixes[lens[i]]++;
101 
102  return ff_init_vlc_sparse(vlc, FFMIN(max_bits, 9), elems,
103  lens, 1, 1, codes, 2, 2, NULL, 0, 0, 0);
104 }
105 
107 {
108  RALFContext *ctx = avctx->priv_data;
109  int i, j, k;
110 
111  for (i = 0; i < 3; i++) {
112  ff_free_vlc(&ctx->sets[i].filter_params);
113  ff_free_vlc(&ctx->sets[i].bias);
114  ff_free_vlc(&ctx->sets[i].coding_mode);
115  for (j = 0; j < 10; j++)
116  for (k = 0; k < 11; k++)
117  ff_free_vlc(&ctx->sets[i].filter_coeffs[j][k]);
118  for (j = 0; j < 15; j++)
119  ff_free_vlc(&ctx->sets[i].short_codes[j]);
120  for (j = 0; j < 125; j++)
121  ff_free_vlc(&ctx->sets[i].long_codes[j]);
122  }
123 
124  return 0;
125 }
126 
128 {
129  RALFContext *ctx = avctx->priv_data;
130  int i, j, k;
131  int ret;
132 
133  if (avctx->extradata_size < 24 || memcmp(avctx->extradata, "LSD:", 4)) {
134  av_log(avctx, AV_LOG_ERROR, "Extradata is not groovy, dude\n");
135  return AVERROR_INVALIDDATA;
136  }
137 
138  ctx->version = AV_RB16(avctx->extradata + 4);
139  if (ctx->version != 0x103) {
140  avpriv_request_sample(avctx, "Unknown version %X", ctx->version);
141  return AVERROR_PATCHWELCOME;
142  }
143 
144  avctx->channels = AV_RB16(avctx->extradata + 8);
145  avctx->sample_rate = AV_RB32(avctx->extradata + 12);
146  if (avctx->channels < 1 || avctx->channels > 2
147  || avctx->sample_rate < 8000 || avctx->sample_rate > 96000) {
148  av_log(avctx, AV_LOG_ERROR, "Invalid coding parameters %d Hz %d ch\n",
149  avctx->sample_rate, avctx->channels);
150  return AVERROR_INVALIDDATA;
151  }
153  avctx->channel_layout = (avctx->channels == 2) ? AV_CH_LAYOUT_STEREO
155 
156  ctx->max_frame_size = AV_RB32(avctx->extradata + 16);
157  if (ctx->max_frame_size > (1 << 20) || !ctx->max_frame_size) {
158  av_log(avctx, AV_LOG_ERROR, "invalid frame size %d\n",
159  ctx->max_frame_size);
160  return AVERROR_INVALIDDATA;
161  }
162  ctx->max_frame_size = FFMAX(ctx->max_frame_size, avctx->sample_rate);
163 
164  for (i = 0; i < 3; i++) {
165  ret = init_ralf_vlc(&ctx->sets[i].filter_params, filter_param_def[i],
167  if (ret < 0) {
168  decode_close(avctx);
169  return ret;
170  }
171  ret = init_ralf_vlc(&ctx->sets[i].bias, bias_def[i], BIAS_ELEMENTS);
172  if (ret < 0) {
173  decode_close(avctx);
174  return ret;
175  }
176  ret = init_ralf_vlc(&ctx->sets[i].coding_mode, coding_mode_def[i],
178  if (ret < 0) {
179  decode_close(avctx);
180  return ret;
181  }
182  for (j = 0; j < 10; j++) {
183  for (k = 0; k < 11; k++) {
184  ret = init_ralf_vlc(&ctx->sets[i].filter_coeffs[j][k],
185  filter_coeffs_def[i][j][k],
187  if (ret < 0) {
188  decode_close(avctx);
189  return ret;
190  }
191  }
192  }
193  for (j = 0; j < 15; j++) {
194  ret = init_ralf_vlc(&ctx->sets[i].short_codes[j],
196  if (ret < 0) {
197  decode_close(avctx);
198  return ret;
199  }
200  }
201  for (j = 0; j < 125; j++) {
202  ret = init_ralf_vlc(&ctx->sets[i].long_codes[j],
204  if (ret < 0) {
205  decode_close(avctx);
206  return ret;
207  }
208  }
209  }
210 
211  return 0;
212 }
213 
214 static inline int extend_code(GetBitContext *gb, int val, int range, int bits)
215 {
216  if (val == 0) {
217  val = -range - get_ue_golomb(gb);
218  } else if (val == range * 2) {
219  val = range + get_ue_golomb(gb);
220  } else {
221  val -= range;
222  }
223  if (bits)
224  val = ((unsigned)val << bits) | get_bits(gb, bits);
225  return val;
226 }
227 
228 static int decode_channel(RALFContext *ctx, GetBitContext *gb, int ch,
229  int length, int mode, int bits)
230 {
231  int i, t;
232  int code_params;
233  VLCSet *set = ctx->sets + mode;
234  VLC *code_vlc; int range, range2, add_bits;
235  int *dst = ctx->channel_data[ch];
236 
237  ctx->filter_params = get_vlc2(gb, set->filter_params.table, 9, 2);
238  if (ctx->filter_params > 1) {
239  ctx->filter_bits = (ctx->filter_params - 2) >> 6;
240  ctx->filter_length = ctx->filter_params - (ctx->filter_bits << 6) - 1;
241  }
242 
243  if (ctx->filter_params == FILTER_RAW) {
244  for (i = 0; i < length; i++)
245  dst[i] = get_bits(gb, bits);
246  ctx->bias[ch] = 0;
247  return 0;
248  }
249 
250  ctx->bias[ch] = get_vlc2(gb, set->bias.table, 9, 2);
251  ctx->bias[ch] = extend_code(gb, ctx->bias[ch], 127, 4);
252 
253  if (ctx->filter_params == FILTER_NONE) {
254  memset(dst, 0, sizeof(*dst) * length);
255  return 0;
256  }
257 
258  if (ctx->filter_params > 1) {
259  int cmode = 0, coeff = 0;
260  VLC *vlc = set->filter_coeffs[ctx->filter_bits] + 5;
261 
262  add_bits = ctx->filter_bits;
263 
264  for (i = 0; i < ctx->filter_length; i++) {
265  t = get_vlc2(gb, vlc[cmode].table, vlc[cmode].bits, 2);
266  t = extend_code(gb, t, 21, add_bits);
267  if (!cmode)
268  coeff -= 12U << add_bits;
269  coeff = (unsigned)t - coeff;
270  ctx->filter[i] = coeff;
271 
272  cmode = coeff >> add_bits;
273  if (cmode < 0) {
274  cmode = -1 - av_log2(-cmode);
275  if (cmode < -5)
276  cmode = -5;
277  } else if (cmode > 0) {
278  cmode = 1 + av_log2(cmode);
279  if (cmode > 5)
280  cmode = 5;
281  }
282  }
283  }
284 
285  code_params = get_vlc2(gb, set->coding_mode.table, set->coding_mode.bits, 2);
286  if (code_params >= 15) {
287  add_bits = av_clip((code_params / 5 - 3) / 2, 0, 10);
288  if (add_bits > 9 && (code_params % 5) != 2)
289  add_bits--;
290  range = 10;
291  range2 = 21;
292  code_vlc = set->long_codes + (code_params - 15);
293  } else {
294  add_bits = 0;
295  range = 6;
296  range2 = 13;
297  code_vlc = set->short_codes + code_params;
298  }
299 
300  for (i = 0; i < length; i += 2) {
301  int code1, code2;
302 
303  t = get_vlc2(gb, code_vlc->table, code_vlc->bits, 2);
304  code1 = t / range2;
305  code2 = t % range2;
306  dst[i] = extend_code(gb, code1, range, 0) * (1U << add_bits);
307  dst[i + 1] = extend_code(gb, code2, range, 0) * (1U << add_bits);
308  if (add_bits) {
309  dst[i] |= get_bits(gb, add_bits);
310  dst[i + 1] |= get_bits(gb, add_bits);
311  }
312  }
313 
314  return 0;
315 }
316 
317 static void apply_lpc(RALFContext *ctx, int ch, int length, int bits)
318 {
319  int i, j, acc;
320  int *audio = ctx->channel_data[ch];
321  int bias = 1 << (ctx->filter_bits - 1);
322  int max_clip = (1 << bits) - 1, min_clip = -max_clip - 1;
323 
324  for (i = 1; i < length; i++) {
325  int flen = FFMIN(ctx->filter_length, i);
326 
327  acc = 0;
328  for (j = 0; j < flen; j++)
329  acc += (unsigned)ctx->filter[j] * audio[i - j - 1];
330  if (acc < 0) {
331  acc = (acc + bias - 1) >> ctx->filter_bits;
332  acc = FFMAX(acc, min_clip);
333  } else {
334  acc = ((unsigned)acc + bias) >> ctx->filter_bits;
335  acc = FFMIN(acc, max_clip);
336  }
337  audio[i] += acc;
338  }
339 }
340 
342  int16_t *dst0, int16_t *dst1)
343 {
344  RALFContext *ctx = avctx->priv_data;
345  int len, ch, ret;
346  int dmode, mode[2], bits[2];
347  int *ch0, *ch1;
348  int i;
349  unsigned int t, t2;
350 
351  len = 12 - get_unary(gb, 0, 6);
352 
353  if (len <= 7) len ^= 1; // codes for length = 6 and 7 are swapped
354  len = 1 << len;
355 
356  if (ctx->sample_offset + len > ctx->max_frame_size) {
357  av_log(avctx, AV_LOG_ERROR,
358  "Decoder's stomach is crying, it ate too many samples\n");
359  return AVERROR_INVALIDDATA;
360  }
361 
362  if (avctx->channels > 1)
363  dmode = get_bits(gb, 2) + 1;
364  else
365  dmode = 0;
366 
367  mode[0] = (dmode == 4) ? 1 : 0;
368  mode[1] = (dmode >= 2) ? 2 : 0;
369  bits[0] = 16;
370  bits[1] = (mode[1] == 2) ? 17 : 16;
371 
372  for (ch = 0; ch < avctx->channels; ch++) {
373  if ((ret = decode_channel(ctx, gb, ch, len, mode[ch], bits[ch])) < 0)
374  return ret;
375  if (ctx->filter_params > 1 && ctx->filter_params != FILTER_RAW) {
376  ctx->filter_bits += 3;
377  apply_lpc(ctx, ch, len, bits[ch]);
378  }
379  if (get_bits_left(gb) < 0)
380  return AVERROR_INVALIDDATA;
381  }
382  ch0 = ctx->channel_data[0];
383  ch1 = ctx->channel_data[1];
384  switch (dmode) {
385  case 0:
386  for (i = 0; i < len; i++)
387  dst0[i] = ch0[i] + ctx->bias[0];
388  break;
389  case 1:
390  for (i = 0; i < len; i++) {
391  dst0[i] = ch0[i] + ctx->bias[0];
392  dst1[i] = ch1[i] + ctx->bias[1];
393  }
394  break;
395  case 2:
396  for (i = 0; i < len; i++) {
397  ch0[i] += ctx->bias[0];
398  dst0[i] = ch0[i];
399  dst1[i] = ch0[i] - (ch1[i] + ctx->bias[1]);
400  }
401  break;
402  case 3:
403  for (i = 0; i < len; i++) {
404  t = ch0[i] + ctx->bias[0];
405  t2 = ch1[i] + ctx->bias[1];
406  dst0[i] = t + t2;
407  dst1[i] = t;
408  }
409  break;
410  case 4:
411  for (i = 0; i < len; i++) {
412  t = ch1[i] + ctx->bias[1];
413  t2 = ((ch0[i] + ctx->bias[0]) * 2) | (t & 1);
414  dst0[i] = (int)(t2 + t) / 2;
415  dst1[i] = (int)(t2 - t) / 2;
416  }
417  break;
418  }
419 
420  ctx->sample_offset += len;
421 
422  return 0;
423 }
424 
425 static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
426  AVPacket *avpkt)
427 {
428  RALFContext *ctx = avctx->priv_data;
429  AVFrame *frame = data;
430  int16_t *samples0;
431  int16_t *samples1;
432  int ret;
433  GetBitContext gb;
434  int table_size, table_bytes, i;
435  const uint8_t *src, *block_pointer;
436  int src_size;
437  int bytes_left;
438 
439  if (ctx->has_pkt) {
440  ctx->has_pkt = 0;
441  table_bytes = (AV_RB16(avpkt->data) + 7) >> 3;
442  if (table_bytes + 3 > avpkt->size || avpkt->size > RALF_MAX_PKT_SIZE) {
443  av_log(avctx, AV_LOG_ERROR, "Wrong packet's breath smells of wrong data!\n");
444  return AVERROR_INVALIDDATA;
445  }
446  if (memcmp(ctx->pkt, avpkt->data, 2 + table_bytes)) {
447  av_log(avctx, AV_LOG_ERROR, "Wrong packet tails are wrong!\n");
448  return AVERROR_INVALIDDATA;
449  }
450 
451  src = ctx->pkt;
452  src_size = RALF_MAX_PKT_SIZE + avpkt->size;
453  memcpy(ctx->pkt + RALF_MAX_PKT_SIZE, avpkt->data + 2 + table_bytes,
454  avpkt->size - 2 - table_bytes);
455  } else {
456  if (avpkt->size == RALF_MAX_PKT_SIZE) {
457  memcpy(ctx->pkt, avpkt->data, avpkt->size);
458  ctx->has_pkt = 1;
459  *got_frame_ptr = 0;
460 
461  return avpkt->size;
462  }
463  src = avpkt->data;
464  src_size = avpkt->size;
465  }
466 
467  frame->nb_samples = ctx->max_frame_size;
468  if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
469  return ret;
470  samples0 = (int16_t *)frame->data[0];
471  samples1 = (int16_t *)frame->data[1];
472 
473  if (src_size < 5) {
474  av_log(avctx, AV_LOG_ERROR, "too short packets are too short!\n");
475  return AVERROR_INVALIDDATA;
476  }
477  table_size = AV_RB16(src);
478  table_bytes = (table_size + 7) >> 3;
479  if (src_size < table_bytes + 3) {
480  av_log(avctx, AV_LOG_ERROR, "short packets are short!\n");
481  return AVERROR_INVALIDDATA;
482  }
483  init_get_bits(&gb, src + 2, table_size);
484  ctx->num_blocks = 0;
485  while (get_bits_left(&gb) > 0) {
486  if (ctx->num_blocks >= FF_ARRAY_ELEMS(ctx->block_size))
487  return AVERROR_INVALIDDATA;
488  ctx->block_size[ctx->num_blocks] = get_bits(&gb, 13 + avctx->channels);
489  if (get_bits1(&gb)) {
490  ctx->block_pts[ctx->num_blocks] = get_bits(&gb, 9);
491  } else {
492  ctx->block_pts[ctx->num_blocks] = 0;
493  }
494  ctx->num_blocks++;
495  }
496 
497  block_pointer = src + table_bytes + 2;
498  bytes_left = src_size - table_bytes - 2;
499  ctx->sample_offset = 0;
500  for (i = 0; i < ctx->num_blocks; i++) {
501  if (bytes_left < ctx->block_size[i]) {
502  av_log(avctx, AV_LOG_ERROR, "I'm pedaling backwards\n");
503  break;
504  }
505  init_get_bits(&gb, block_pointer, ctx->block_size[i] * 8);
506  if (decode_block(avctx, &gb, samples0 + ctx->sample_offset,
507  samples1 + ctx->sample_offset) < 0) {
508  av_log(avctx, AV_LOG_ERROR, "Sir, I got carsick in your office. Not decoding the rest of packet.\n");
509  break;
510  }
511  block_pointer += ctx->block_size[i];
512  bytes_left -= ctx->block_size[i];
513  }
514 
515  frame->nb_samples = ctx->sample_offset;
516  *got_frame_ptr = ctx->sample_offset > 0;
517 
518  return avpkt->size;
519 }
520 
521 static void decode_flush(AVCodecContext *avctx)
522 {
523  RALFContext *ctx = avctx->priv_data;
524 
525  ctx->has_pkt = 0;
526 }
527 
528 
530  .name = "ralf",
531  .long_name = NULL_IF_CONFIG_SMALL("RealAudio Lossless"),
532  .type = AVMEDIA_TYPE_AUDIO,
533  .id = AV_CODEC_ID_RALF,
534  .priv_data_size = sizeof(RALFContext),
535  .init = decode_init,
536  .close = decode_close,
537  .decode = decode_frame,
538  .flush = decode_flush,
539  .capabilities = AV_CODEC_CAP_CHANNEL_CONF |
541  .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
543 };
static void flush(AVCodecContext *avctx)
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:925
static double val(void *priv, double ch)
Definition: aeval.c:76
Macro definitions for various function/variable attributes.
#define av_cold
Definition: attributes.h:88
uint8_t
int32_t
Libavcodec external API header.
#define AV_RB32
Definition: intreadwrite.h:130
#define AV_RB16
Definition: intreadwrite.h:53
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:31
int ff_init_vlc_sparse(VLC *vlc_arg, 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:323
void ff_free_vlc(VLC *vlc)
Definition: bitstream.c:431
audio channel layout utility functions
#define FFMIN(a, b)
Definition: common.h:105
#define av_clip
Definition: common.h:122
#define FFMAX(a, b)
Definition: common.h:103
#define NULL
Definition: coverity.c:32
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1900
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:71
static AVFrame * frame
mode
Use these values in ebur128_init (or'ed).
Definition: ebur128.h:83
int
bitstream reader API header.
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:797
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:849
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:498
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:379
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
Definition: get_bits.h:659
exp golomb vlc stuff
static int get_ue_golomb(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to 8190.
Definition: golomb.h:55
#define AV_CH_LAYOUT_MONO
#define AV_CH_LAYOUT_STEREO
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
Definition: codec.h:104
@ AV_CODEC_ID_RALF
Definition: codec_id.h:481
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:62
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
Definition: samplefmt.h:67
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:59
for(j=16;j >0;--j)
int i
Definition: input.c:407
#define av_log2
Definition: intmath.h:83
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
const char data[16]
Definition: mxf.c:142
static const uint16_t table[]
Definition: prosumer.c:206
static int extend_code(GetBitContext *gb, int val, int range, int bits)
Definition: ralf.c:214
#define MAX_ELEMS
Definition: ralf.c:74
static av_cold int init_ralf_vlc(VLC *vlc, const uint8_t *data, int elems)
Definition: ralf.c:76
static av_cold int decode_close(AVCodecContext *avctx)
Definition: ralf.c:106
#define FILTER_RAW
Definition: ralf.c:39
AVCodec ff_ralf_decoder
Definition: ralf.c:529
static av_cold int decode_init(AVCodecContext *avctx)
Definition: ralf.c:127
#define FILTER_NONE
Definition: ralf.c:38
#define RALF_MAX_PKT_SIZE
Definition: ralf.c:50
static int decode_channel(RALFContext *ctx, GetBitContext *gb, int ch, int length, int mode, int bits)
Definition: ralf.c:228
static int decode_block(AVCodecContext *avctx, GetBitContext *gb, int16_t *dst0, int16_t *dst1)
Definition: ralf.c:341
static void decode_flush(AVCodecContext *avctx)
Definition: ralf.c:521
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
Definition: ralf.c:425
static void apply_lpc(RALFContext *ctx, int ch, int length, int bits)
Definition: ralf.c:317
static const uint8_t filter_coeffs_def[3][10][11][24]
Definition: ralfdata.h:188
#define BIAS_ELEMENTS
Definition: ralfdata.h:29
static const uint8_t long_codes_def[3][125][224]
Definition: ralfdata.h:2036
static const uint8_t filter_param_def[3][324]
Definition: ralfdata.h:35
#define CODING_MODE_ELEMENTS
Definition: ralfdata.h:30
#define SHORT_CODES_ELEMENTS
Definition: ralfdata.h:32
static const uint8_t bias_def[3][128]
Definition: ralfdata.h:123
#define FILTER_COEFFS_ELEMENTS
Definition: ralfdata.h:31
#define LONG_CODES_ELEMENTS
Definition: ralfdata.h:33
static const uint8_t short_codes_def[3][15][88]
Definition: ralfdata.h:1577
static const uint8_t coding_mode_def[3][72]
Definition: ralfdata.h:163
#define FILTERPARAM_ELEMENTS
Definition: ralfdata.h:28
#define t2
Definition: regdef.h:30
#define FF_ARRAY_ELEMS(a)
main external API structure.
Definition: avcodec.h:536
enum AVSampleFormat sample_fmt
audio sample format
Definition: avcodec.h:1204
int sample_rate
samples per second
Definition: avcodec.h:1196
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:637
int channels
number of audio channels
Definition: avcodec.h:1197
int extradata_size
Definition: avcodec.h:638
uint64_t channel_layout
Audio channel layout.
Definition: avcodec.h:1247
void * priv_data
Definition: avcodec.h:563
AVCodec.
Definition: codec.h:197
const char * name
Name of the codec implementation.
Definition: codec.h:204
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:384
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:332
This structure stores compressed data.
Definition: packet.h:346
int size
Definition: packet.h:370
uint8_t * data
Definition: packet.h:369
int block_size[1<< 12]
size of the blocks
Definition: ralf.c:67
int32_t filter[64]
Definition: ralf.c:61
uint8_t pkt[16384]
Definition: ralf.c:70
int version
Definition: ralf.c:53
int num_blocks
number of blocks inside the frame
Definition: ralf.c:65
int filter_length
length of the filter for the current channel data
Definition: ralf.c:59
VLCSet sets[3]
Definition: ralf.c:55
unsigned bias[2]
a constant value added to channel data after filtering
Definition: ralf.c:63
int32_t channel_data[2][4096]
Definition: ralf.c:56
int block_pts[1<< 12]
block start time (in milliseconds)
Definition: ralf.c:68
int filter_params
combined filter parameters for the current channel data
Definition: ralf.c:58
int filter_bits
filter precision for the current channel data
Definition: ralf.c:60
int sample_offset
Definition: ralf.c:66
int has_pkt
Definition: ralf.c:71
int max_frame_size
Definition: ralf.c:54
Definition: ralf.c:41
VLC short_codes[15]
Definition: ralf.c:46
VLC filter_params
Definition: ralf.c:42
VLC coding_mode
Definition: ralf.c:44
VLC long_codes[125]
Definition: ralf.c:47
VLC bias
Definition: ralf.c:43
VLC filter_coeffs[10][11]
Definition: ralf.c:45
Definition: vlc.h:26
int bits
Definition: vlc.h:27
VLC_TYPE(* table)[2]
code, bits
Definition: vlc.h:28
#define avpriv_request_sample(...)
#define av_log(a,...)
#define src
Definition: vp8dsp.c:255
AVFormatContext * ctx
Definition: movenc.c:48
static void set(uint8_t *a[], int ch, int index, int ch_count, enum AVSampleFormat f, double v)
Definition: swresample.c:59
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length.
Definition: unary.h:46
static const double coeff[2][5]
Definition: vf_owdenoise.c:73
int len
uint8_t bits
Definition: vp3data.h:141
static VLC code_vlc
Definition: wnv1.c:41
int acc
Definition: yuv2rgb.c:555