FFmpeg
osq.c
Go to the documentation of this file.
1 /*
2  * OSQ audio decoder
3  * Copyright (c) 2023 Paul B Mahol
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "libavutil/internal.h"
23 #include "libavutil/intreadwrite.h"
24 #include "avcodec.h"
25 #include "codec_internal.h"
26 #include "decode.h"
27 #include "internal.h"
28 #define BITSTREAM_READER_LE
29 #include "get_bits.h"
30 #include "unary.h"
31 
32 #define OFFSET 5
33 
34 typedef struct OSQChannel {
35  unsigned prediction;
36  unsigned coding_mode;
38  unsigned residue_bits;
39  unsigned history[3];
40  unsigned pos, count;
41  double sum;
43 } OSQChannel;
44 
45 typedef struct OSQContext {
48 
49  uint8_t *bitstream;
50  size_t max_framesize;
52 
53  int factor;
56  uint64_t nb_samples;
57 
59 
62 } OSQContext;
63 
64 static void osq_flush(AVCodecContext *avctx)
65 {
66  OSQContext *s = avctx->priv_data;
67 
68  s->bitstream_size = 0;
69  s->pkt_offset = 0;
70 }
71 
72 static av_cold int osq_close(AVCodecContext *avctx)
73 {
74  OSQContext *s = avctx->priv_data;
75 
76  av_freep(&s->bitstream);
77  s->bitstream_size = 0;
78 
79  for (int ch = 0; ch < FF_ARRAY_ELEMS(s->decode_buffer); ch++)
80  av_freep(&s->decode_buffer[ch]);
81 
82  return 0;
83 }
84 
85 static av_cold int osq_init(AVCodecContext *avctx)
86 {
87  OSQContext *s = avctx->priv_data;
88 
89  if (avctx->extradata_size < 48)
90  return AVERROR(EINVAL);
91 
92  if (avctx->extradata[0] != 1) {
93  av_log(avctx, AV_LOG_ERROR, "Unsupported version.\n");
94  return AVERROR_INVALIDDATA;
95  }
96 
97  avctx->sample_rate = AV_RL32(avctx->extradata + 4);
98  if (avctx->sample_rate < 1)
99  return AVERROR_INVALIDDATA;
100 
103  avctx->ch_layout.nb_channels = avctx->extradata[3];
104  if (avctx->ch_layout.nb_channels < 1)
105  return AVERROR_INVALIDDATA;
106  if (avctx->ch_layout.nb_channels > FF_ARRAY_ELEMS(s->decode_buffer))
107  return AVERROR_INVALIDDATA;
108 
109  s->factor = 1;
110  switch (avctx->extradata[2]) {
111  case 8: avctx->sample_fmt = AV_SAMPLE_FMT_U8P; break;
112  case 16: avctx->sample_fmt = AV_SAMPLE_FMT_S16P; break;
113  case 20:
114  case 24: s->factor = 256;
115  avctx->sample_fmt = AV_SAMPLE_FMT_S32P; break;
116  default: return AVERROR_INVALIDDATA;
117  }
118 
119  avctx->bits_per_raw_sample = avctx->extradata[2];
120  s->nb_samples = AV_RL64(avctx->extradata + 16);
121  s->frame_samples = AV_RL16(avctx->extradata + 8);
122  s->max_framesize = (s->frame_samples * 16 + 1024) * avctx->ch_layout.nb_channels;
123 
124  s->bitstream = av_calloc(s->max_framesize + AV_INPUT_BUFFER_PADDING_SIZE, sizeof(*s->bitstream));
125  if (!s->bitstream)
126  return AVERROR(ENOMEM);
127 
128  for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
129  s->decode_buffer[ch] = av_calloc(s->frame_samples + OFFSET,
130  sizeof(*s->decode_buffer[ch]));
131  if (!s->decode_buffer[ch])
132  return AVERROR(ENOMEM);
133  }
134 
135  s->pkt = avctx->internal->in_pkt;
136 
137  return 0;
138 }
139 
140 static void reset_stats(OSQChannel *cb)
141 {
142  memset(cb->history, 0, sizeof(cb->history));
143  cb->pos = cb->count = cb->sum = 0;
144 }
145 
146 static void update_stats(OSQChannel *cb, int val)
147 {
148  cb->sum += FFABS(val) - cb->history[cb->pos];
149  cb->history[cb->pos] = FFABS(val);
150  cb->pos++;
151  cb->count++;
152  if (cb->pos >= FF_ARRAY_ELEMS(cb->history))
153  cb->pos = 0;
154 }
155 
157 {
158  double sum, x;
159  int rice_k;
160 
161  sum = cb->sum;
162  x = sum / cb->count;
163  rice_k = av_ceil_log2(x);
164  if (rice_k >= 30) {
165  rice_k = floor(sum / 1.4426952 + 0.5);
166  if (rice_k < 1)
167  rice_k = 1;
168  }
169 
170  return rice_k;
171 }
172 
173 static uint32_t get_urice(GetBitContext *gb, int k)
174 {
175  uint32_t z, x, b;
176 
177  x = get_unary(gb, 1, 512);
178  b = get_bits_long(gb, k);
179  z = b | x << k;
180 
181  return z;
182 }
183 
184 static int32_t get_srice(GetBitContext *gb, int x)
185 {
186  int32_t y = get_urice(gb, x);
187  return get_bits1(gb) ? -y : y;
188 }
189 
190 static int osq_channel_parameters(AVCodecContext *avctx, int ch)
191 {
192  OSQContext *s = avctx->priv_data;
193  OSQChannel *cb = &s->ch[ch];
194  GetBitContext *gb = &s->gb;
195 
196  cb->prev = 0;
197  cb->prediction = get_urice(gb, 5);
198  cb->coding_mode = get_urice(gb, 3);
199  if (cb->prediction >= 15)
200  return AVERROR_INVALIDDATA;
201  if (cb->coding_mode > 0 && cb->coding_mode < 3) {
202  cb->residue_parameter = get_urice(gb, 4);
203  if (!cb->residue_parameter || cb->residue_parameter >= 31)
204  return AVERROR_INVALIDDATA;
205  } else if (cb->coding_mode == 3) {
206  cb->residue_bits = get_urice(gb, 4);
207  if (!cb->residue_bits || cb->residue_bits >= 31)
208  return AVERROR_INVALIDDATA;
209  } else if (cb->coding_mode) {
210  return AVERROR_INVALIDDATA;
211  }
212 
213  if (cb->coding_mode == 2)
214  reset_stats(cb);
215 
216  return 0;
217 }
218 
219 #define A (-1)
220 #define B (-2)
221 #define C (-3)
222 #define D (-4)
223 #define E (-5)
224 #define P2 (((unsigned)dst[A] + dst[A]) - dst[B])
225 #define P3 (((unsigned)dst[A] - dst[B]) * 3 + dst[C])
226 
227 static int do_decode(AVCodecContext *avctx, AVFrame *frame, int decorrelate, int downsample)
228 {
229  OSQContext *s = avctx->priv_data;
230  const int nb_channels = avctx->ch_layout.nb_channels;
231  const int nb_samples = frame->nb_samples;
232  GetBitContext *gb = &s->gb;
233 
234  for (int n = 0; n < nb_samples; n++) {
235  for (int ch = 0; ch < nb_channels; ch++) {
236  OSQChannel *cb = &s->ch[ch];
237  int32_t *dst = s->decode_buffer[ch] + OFFSET;
238  int32_t p, prev = cb->prev;
239 
240  if (nb_channels == 2 && ch == 1 && decorrelate != s->decorrelate) {
241  if (!decorrelate) {
242  s->decode_buffer[1][OFFSET+A] += s->decode_buffer[0][OFFSET+B];
243  s->decode_buffer[1][OFFSET+B] += s->decode_buffer[0][OFFSET+C];
244  s->decode_buffer[1][OFFSET+C] += s->decode_buffer[0][OFFSET+D];
245  s->decode_buffer[1][OFFSET+D] += s->decode_buffer[0][OFFSET+E];
246  } else {
247  s->decode_buffer[1][OFFSET+A] -= s->decode_buffer[0][OFFSET+B];
248  s->decode_buffer[1][OFFSET+B] -= s->decode_buffer[0][OFFSET+C];
249  s->decode_buffer[1][OFFSET+C] -= s->decode_buffer[0][OFFSET+D];
250  s->decode_buffer[1][OFFSET+D] -= s->decode_buffer[0][OFFSET+E];
251  }
252  s->decorrelate = decorrelate;
253  }
254 
255  if (!cb->coding_mode) {
256  dst[n] = 0;
257  } else if (cb->coding_mode == 3) {
258  dst[n] = get_sbits_long(gb, cb->residue_bits);
259  } else {
260  dst[n] = get_srice(gb, cb->residue_parameter);
261  }
262 
263  if (get_bits_left(gb) < 0) {
264  av_log(avctx, AV_LOG_ERROR, "overread!\n");
265  return AVERROR_INVALIDDATA;
266  }
267 
268  p = prev / 2;
269  prev = dst[n];
270 
271  switch (cb->prediction) {
272  case 0:
273  break;
274  case 1:
275  dst[n] += (unsigned)dst[A];
276  break;
277  case 2:
278  dst[n] += (unsigned)dst[A] + p;
279  break;
280  case 3:
281  dst[n] += P2;
282  break;
283  case 4:
284  dst[n] += P2 + p;
285  break;
286  case 5:
287  dst[n] += P3;
288  break;
289  case 6:
290  dst[n] += P3 + p;
291  break;
292  case 7:
293  dst[n] += (int)(P2 + P3) / 2 + (unsigned)p;
294  break;
295  case 8:
296  dst[n] += (int)(P2 + P3) / 2;
297  break;
298  case 9:
299  dst[n] += (int)(P2 * 2 + P3) / 3 + (unsigned)p;
300  break;
301  case 10:
302  dst[n] += (int)(P2 + P3 * 2) / 3 + (unsigned)p;
303  break;
304  case 11:
305  dst[n] += (int)((unsigned)dst[A] + dst[B]) / 2;
306  break;
307  case 12:
308  dst[n] += (unsigned)dst[B];
309  break;
310  case 13:
311  dst[n] += (int)(unsigned)(dst[D] + dst[B]) / 2;
312  break;
313  case 14:
314  dst[n] += (int)((unsigned)P2 + dst[A]) / 2 + (unsigned)p;
315  break;
316  default:
317  return AVERROR_INVALIDDATA;
318  }
319 
320  cb->prev = prev;
321 
322  if (downsample)
323  dst[n] *= 256;
324 
325  dst[E] = dst[D];
326  dst[D] = dst[C];
327  dst[C] = dst[B];
328  dst[B] = dst[A];
329  dst[A] = dst[n];
330 
331  if (cb->coding_mode == 2) {
332  update_stats(cb, dst[n]);
333  cb->residue_parameter = update_residue_parameter(cb);
334  }
335 
336  if (nb_channels == 2 && ch == 1) {
337  if (decorrelate)
338  dst[n] += s->decode_buffer[0][OFFSET+n];
339  }
340 
341  if (downsample)
342  dst[A] /= 256;
343  }
344  }
345 
346  return 0;
347 }
348 
350 {
351  const int nb_channels = avctx->ch_layout.nb_channels;
352  const int nb_samples = frame->nb_samples;
353  OSQContext *s = avctx->priv_data;
354  const int factor = s->factor;
355  int ret, decorrelate, downsample;
356  GetBitContext *gb = &s->gb;
357 
358  skip_bits1(gb);
359  decorrelate = get_bits1(gb);
360  downsample = get_bits1(gb);
361 
362  for (int ch = 0; ch < nb_channels; ch++) {
363  if ((ret = osq_channel_parameters(avctx, ch)) < 0) {
364  av_log(avctx, AV_LOG_ERROR, "invalid channel parameters\n");
365  return ret;
366  }
367  }
368 
369  if ((ret = do_decode(avctx, frame, decorrelate, downsample)) < 0)
370  return ret;
371 
372  align_get_bits(gb);
373 
374  switch (avctx->sample_fmt) {
375  case AV_SAMPLE_FMT_U8P:
376  for (int ch = 0; ch < nb_channels; ch++) {
377  uint8_t *dst = (uint8_t *)frame->extended_data[ch];
378  int32_t *src = s->decode_buffer[ch] + OFFSET;
379 
380  for (int n = 0; n < nb_samples; n++)
381  dst[n] = av_clip_uint8(src[n] + 0x80);
382  }
383  break;
384  case AV_SAMPLE_FMT_S16P:
385  for (int ch = 0; ch < nb_channels; ch++) {
386  int16_t *dst = (int16_t *)frame->extended_data[ch];
387  int32_t *src = s->decode_buffer[ch] + OFFSET;
388 
389  for (int n = 0; n < nb_samples; n++)
390  dst[n] = (int16_t)src[n];
391  }
392  break;
393  case AV_SAMPLE_FMT_S32P:
394  for (int ch = 0; ch < nb_channels; ch++) {
395  int32_t *dst = (int32_t *)frame->extended_data[ch];
396  int32_t *src = s->decode_buffer[ch] + OFFSET;
397 
398  for (int n = 0; n < nb_samples; n++)
399  dst[n] = src[n] * factor;
400  }
401  break;
402  default:
403  return AVERROR_BUG;
404  }
405 
406  return 0;
407 }
408 
410 {
411  OSQContext *s = avctx->priv_data;
412  GetBitContext *gb = &s->gb;
413  int ret, n;
414 
415  while (s->bitstream_size < s->max_framesize) {
416  int size;
417 
418  if (!s->pkt->data) {
419  ret = ff_decode_get_packet(avctx, s->pkt);
420  if (ret == AVERROR_EOF && s->bitstream_size > 0)
421  break;
422  if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN))
423  return ret;
424  if (ret < 0)
425  goto fail;
426  }
427 
428  size = FFMIN(s->pkt->size - s->pkt_offset, s->max_framesize - s->bitstream_size);
429  memcpy(s->bitstream + s->bitstream_size, s->pkt->data + s->pkt_offset, size);
430  s->bitstream_size += size;
431  s->pkt_offset += size;
432 
433  if (s->pkt_offset == s->pkt->size) {
434  av_packet_unref(s->pkt);
435  s->pkt_offset = 0;
436  }
437  }
438 
439  frame->nb_samples = FFMIN(s->frame_samples, s->nb_samples);
440  if (frame->nb_samples <= 0)
441  return AVERROR_EOF;
442 
443  if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
444  goto fail;
445 
446  if ((ret = init_get_bits8(gb, s->bitstream, s->bitstream_size)) < 0)
447  goto fail;
448 
449  if ((ret = osq_decode_block(avctx, frame)) < 0)
450  goto fail;
451 
452  s->nb_samples -= frame->nb_samples;
453 
454  n = get_bits_count(gb) / 8;
455  if (n > s->bitstream_size) {
457  goto fail;
458  }
459 
460  memmove(s->bitstream, &s->bitstream[n], s->bitstream_size - n);
461  s->bitstream_size -= n;
462 
463  return 0;
464 
465 fail:
466  s->bitstream_size = 0;
467  s->pkt_offset = 0;
468  av_packet_unref(s->pkt);
469 
470  return ret;
471 }
472 
474  .p.name = "osq",
475  CODEC_LONG_NAME("OSQ (Original Sound Quality)"),
476  .p.type = AVMEDIA_TYPE_AUDIO,
477  .p.id = AV_CODEC_ID_OSQ,
478  .priv_data_size = sizeof(OSQContext),
479  .init = osq_init,
481  .close = osq_close,
482  .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF |
484  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
485  .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_U8P,
489  .flush = osq_flush,
490 };
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:423
ff_decode_get_packet
int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
Called by decoders to get the next packet for decoding.
Definition: decode.c:241
decorrelate
static void decorrelate(SnowContext *s, SubBand *b, IDWTELEM *src, int stride, int inverse, int use_median)
Definition: snowenc.c:1507
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:42
get_bits_left
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:694
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AVCodecContext::sample_rate
int sample_rate
samples per second
Definition: avcodec.h:1064
cb
static double cb(void *priv, double x, double y)
Definition: vf_geq.c:241
AV_RL64
uint64_t_TMPL AV_RL64
Definition: bytestream.h:91
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
D
#define D
Definition: osq.c:222
OSQContext::bitstream_size
size_t bitstream_size
Definition: osq.c:51
get_bits_long
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
Definition: get_bits.h:421
OSQContext::decode_buffer
int32_t * decode_buffer[2]
Definition: osq.c:58
get_bits_count
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:266
osq_flush
static void osq_flush(AVCodecContext *avctx)
Definition: osq.c:64
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:340
OSQChannel::prev
int32_t prev
Definition: osq.c:42
OSQContext::ch
OSQChannel ch[2]
Definition: osq.c:47
internal.h
b
#define b
Definition: input.c:41
AV_SAMPLE_FMT_S32P
@ AV_SAMPLE_FMT_S32P
signed 32 bits, planar
Definition: samplefmt.h:65
FFCodec
Definition: codec_internal.h:127
AVChannelLayout::order
enum AVChannelOrder order
Channel order used in this layout.
Definition: channel_layout.h:312
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:317
OSQChannel::residue_parameter
unsigned residue_parameter
Definition: osq.c:37
do_decode
static int do_decode(AVCodecContext *avctx, AVFrame *frame, int decorrelate, int downsample)
Definition: osq.c:227
P3
#define P3
Definition: osq.c:225
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
av_ceil_log2
#define av_ceil_log2
Definition: common.h:93
AVCodecContext::ch_layout
AVChannelLayout ch_layout
Audio channel layout.
Definition: avcodec.h:2107
fail
#define fail()
Definition: checkasm.h:138
OSQContext::pkt_offset
int pkt_offset
Definition: osq.c:61
GetBitContext
Definition: get_bits.h:108
OSQContext::max_framesize
size_t max_framesize
Definition: osq.c:50
OSQChannel::coding_mode
unsigned coding_mode
Definition: osq.c:36
val
static double val(void *priv, double ch)
Definition: aeval.c:78
OFFSET
#define OFFSET
Definition: osq.c:32
OSQChannel::count
unsigned count
Definition: osq.c:40
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_cold
#define av_cold
Definition: attributes.h:90
init_get_bits8
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition: get_bits.h:545
AVCodecContext::extradata_size
int extradata_size
Definition: avcodec.h:543
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:198
floor
static __device__ float floor(float a)
Definition: cuda_runtime.h:173
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AV_CHANNEL_ORDER_UNSPEC
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
Definition: channel_layout.h:112
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:365
OSQContext::nb_samples
uint64_t nb_samples
Definition: osq.c:56
AVCodecContext::bits_per_raw_sample
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:1517
C
#define C
Definition: osq.c:221
decode.h
get_bits.h
AV_RL16
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
Definition: bytestream.h:94
OSQContext
Definition: osq.c:45
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
frame
static AVFrame * frame
Definition: demux_decode.c:54
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:65
update_residue_parameter
static int update_residue_parameter(OSQChannel *cb)
Definition: osq.c:156
AVCodecContext::internal
struct AVCodecInternal * internal
Private context used for internal data.
Definition: avcodec.h:476
OSQContext::factor
int factor
Definition: osq.c:53
get_bits1
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:388
get_unary
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length.
Definition: unary.h:46
AV_CODEC_CAP_CHANNEL_CONF
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
Definition: codec.h:106
ff_get_buffer
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1617
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
AV_SAMPLE_FMT_U8P
@ AV_SAMPLE_FMT_U8P
unsigned 8 bits, planar
Definition: samplefmt.h:63
codec_internal.h
OSQChannel::sum
double sum
Definition: osq.c:41
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
AVCodecContext::sample_fmt
enum AVSampleFormat sample_fmt
audio sample format
Definition: avcodec.h:1080
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
size
int size
Definition: twinvq_data.h:10344
E
#define E
Definition: osq.c:223
skip_bits1
static void skip_bits1(GetBitContext *s)
Definition: get_bits.h:413
unary.h
AV_SAMPLE_FMT_S16P
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
Definition: samplefmt.h:64
OSQChannel::residue_bits
unsigned residue_bits
Definition: osq.c:38
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:420
OSQContext::pkt
AVPacket * pkt
Definition: osq.c:60
osq_decode_block
static int osq_decode_block(AVCodecContext *avctx, AVFrame *frame)
Definition: osq.c:349
OSQContext::gb
GetBitContext gb
Definition: osq.c:46
AVCodecContext::extradata
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:542
internal.h
OSQChannel
Definition: osq.c:34
AVFrame::extended_data
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:401
AVCodecInternal::in_pkt
AVPacket * in_pkt
This packet is used to hold the packet given to decoders implementing the .decode API; it is unused b...
Definition: internal.h:77
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
OSQChannel::history
unsigned history[3]
Definition: osq.c:39
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
osq_receive_frame
static int osq_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Definition: osq.c:409
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:262
avcodec.h
OSQContext::bitstream
uint8_t * bitstream
Definition: osq.c:49
reset_stats
static void reset_stats(OSQChannel *cb)
Definition: osq.c:140
OSQContext::frame_samples
int frame_samples
Definition: osq.c:55
OSQContext::decorrelate
int decorrelate
Definition: osq.c:54
ret
ret
Definition: filter_design.txt:187
align_get_bits
static const uint8_t * align_get_bits(GetBitContext *s)
Definition: get_bits.h:561
AV_INPUT_BUFFER_PADDING_SIZE
#define AV_INPUT_BUFFER_PADDING_SIZE
Definition: defs.h:40
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
AVCodecContext
main external API structure.
Definition: avcodec.h:441
FF_CODEC_RECEIVE_FRAME_CB
#define FF_CODEC_RECEIVE_FRAME_CB(func)
Definition: codec_internal.h:312
osq_init
static av_cold int osq_init(AVCodecContext *avctx)
Definition: osq.c:85
get_urice
static uint32_t get_urice(GetBitContext *gb, int k)
Definition: osq.c:173
ff_osq_decoder
const FFCodec ff_osq_decoder
Definition: osq.c:473
osq_close
static av_cold int osq_close(AVCodecContext *avctx)
Definition: osq.c:72
av_channel_layout_uninit
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
Definition: channel_layout.c:640
av_clip_uint8
#define av_clip_uint8
Definition: common.h:102
factor
static const int factor[16]
Definition: vf_pp7.c:78
update_stats
static void update_stats(OSQChannel *cb, int val)
Definition: osq.c:146
P2
#define P2
Definition: osq.c:224
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:468
AVPacket
This structure stores compressed data.
Definition: packet.h:468
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
osq_channel_parameters
static int osq_channel_parameters(AVCodecContext *avctx, int ch)
Definition: osq.c:190
int32_t
int32_t
Definition: audioconvert.c:56
A
#define A
Definition: osq.c:219
AVERROR_BUG
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:52
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
B
#define B
Definition: osq.c:220
OSQChannel::pos
unsigned pos
Definition: osq.c:40
get_sbits_long
static int get_sbits_long(GetBitContext *s, int n)
Read 0-32 bits as a signed integer.
Definition: get_bits.h:471
int
int
Definition: ffmpeg_filter.c:368
get_srice
static int32_t get_srice(GetBitContext *gb, int x)
Definition: osq.c:184
AV_CODEC_ID_OSQ
@ AV_CODEC_ID_OSQ
Definition: codec_id.h:546
OSQChannel::prediction
unsigned prediction
Definition: osq.c:35