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/attributes.h"
23 #include "libavutil/internal.h"
24 #include "libavutil/intreadwrite.h"
25 #include "libavutil/mem.h"
26 #include "avcodec.h"
27 #include "codec_internal.h"
28 #include "decode.h"
29 #include "internal.h"
30 #define BITSTREAM_READER_LE
31 #include "get_bits.h"
32 #include "unary.h"
33 
34 #define OFFSET 5
35 
36 typedef struct OSQChannel {
37  unsigned prediction;
38  unsigned coding_mode;
40  unsigned residue_bits;
41  unsigned history[3];
42  unsigned pos, count;
43  double sum;
45 } OSQChannel;
46 
47 typedef struct OSQContext {
50 
51  uint8_t *bitstream;
52  size_t max_framesize;
54 
55  int factor;
58  uint64_t nb_samples;
59 
61 
64 } OSQContext;
65 
66 static av_cold void osq_flush(AVCodecContext *avctx)
67 {
68  OSQContext *s = avctx->priv_data;
69 
70  s->bitstream_size = 0;
71  s->pkt_offset = 0;
72 }
73 
74 static av_cold int osq_close(AVCodecContext *avctx)
75 {
76  OSQContext *s = avctx->priv_data;
77 
78  av_freep(&s->bitstream);
79  s->bitstream_size = 0;
80 
81  for (int ch = 0; ch < FF_ARRAY_ELEMS(s->decode_buffer); ch++)
82  av_freep(&s->decode_buffer[ch]);
83 
84  return 0;
85 }
86 
87 static av_cold int osq_init(AVCodecContext *avctx)
88 {
89  OSQContext *s = avctx->priv_data;
90 
91  if (avctx->extradata_size < 48)
92  return AVERROR(EINVAL);
93 
94  if (avctx->extradata[0] != 1) {
95  av_log(avctx, AV_LOG_ERROR, "Unsupported version.\n");
96  return AVERROR_INVALIDDATA;
97  }
98 
99  avctx->sample_rate = AV_RL32(avctx->extradata + 4);
100  if (avctx->sample_rate < 1)
101  return AVERROR_INVALIDDATA;
102 
105  avctx->ch_layout.nb_channels = avctx->extradata[3];
106  if (avctx->ch_layout.nb_channels < 1)
107  return AVERROR_INVALIDDATA;
108  if (avctx->ch_layout.nb_channels > FF_ARRAY_ELEMS(s->decode_buffer))
109  return AVERROR_INVALIDDATA;
110 
111  s->factor = 1;
112  switch (avctx->extradata[2]) {
113  case 8: avctx->sample_fmt = AV_SAMPLE_FMT_U8P; break;
114  case 16: avctx->sample_fmt = AV_SAMPLE_FMT_S16P; break;
115  case 20:
116  case 24: s->factor = 256;
117  avctx->sample_fmt = AV_SAMPLE_FMT_S32P; break;
118  default: return AVERROR_INVALIDDATA;
119  }
120 
121  avctx->bits_per_raw_sample = avctx->extradata[2];
122  s->nb_samples = AV_RL64(avctx->extradata + 16);
123  s->frame_samples = AV_RL16(avctx->extradata + 8);
124  s->max_framesize = (s->frame_samples * 16 + 1024) * avctx->ch_layout.nb_channels;
125 
126  s->bitstream = av_calloc(s->max_framesize + AV_INPUT_BUFFER_PADDING_SIZE, sizeof(*s->bitstream));
127  if (!s->bitstream)
128  return AVERROR(ENOMEM);
129 
130  for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
131  s->decode_buffer[ch] = av_calloc(s->frame_samples + OFFSET,
132  sizeof(*s->decode_buffer[ch]));
133  if (!s->decode_buffer[ch])
134  return AVERROR(ENOMEM);
135  }
136 
137  s->pkt = avctx->internal->in_pkt;
138 
139  return 0;
140 }
141 
142 static void reset_stats(OSQChannel *cb)
143 {
144  memset(cb->history, 0, sizeof(cb->history));
145  cb->pos = cb->count = cb->sum = 0;
146 }
147 
148 static void update_stats(OSQChannel *cb, int val)
149 {
150  cb->sum += FFABS((int64_t)val) - cb->history[cb->pos];
151  cb->history[cb->pos] = FFABS((int64_t)val);
152  cb->pos++;
153  cb->count++;
154  //NOTE for this to make sense count would need to be limited to FF_ARRAY_ELEMS(cb->history)
155  //Otherwise the average computation later makes no sense
156  if (cb->pos >= FF_ARRAY_ELEMS(cb->history))
157  cb->pos = 0;
158 }
159 
161 {
162  double sum, x;
163  int rice_k;
164 
165  sum = cb->sum;
166  if (!sum)
167  return 0;
168  x = sum / cb->count;
169  av_assert2(x <= 0x80000000U);
170  rice_k = av_ceil_log2(x);
171  if (rice_k >= 30) {
172  double f = floor(sum / 1.4426952 + 0.5);
173  if (f <= 1) {
174  rice_k = 1;
175  } else if (f >= 31) {
176  rice_k = 31;
177  } else
178  rice_k = f;
179  }
180 
181  return rice_k;
182 }
183 
184 static uint32_t get_urice(GetBitContext *gb, int k)
185 {
186  uint32_t z, x, b;
187 
188  x = get_unary(gb, 1, 512);
189  b = get_bits_long(gb, k);
190  z = b | x << k;
191 
192  return z;
193 }
194 
195 static int32_t get_srice(GetBitContext *gb, int x)
196 {
197  uint32_t y = get_urice(gb, x);
198  return get_bits1(gb) ? -y : y;
199 }
200 
201 static int osq_channel_parameters(AVCodecContext *avctx, int ch)
202 {
203  OSQContext *s = avctx->priv_data;
204  OSQChannel *cb = &s->ch[ch];
205  GetBitContext *gb = &s->gb;
206 
207  cb->prev = 0;
208  cb->prediction = get_urice(gb, 5);
209  cb->coding_mode = get_urice(gb, 3);
210  if (cb->prediction >= 15)
211  return AVERROR_INVALIDDATA;
212  if (cb->coding_mode > 0 && cb->coding_mode < 3) {
213  cb->residue_parameter = get_urice(gb, 4);
214  if (!cb->residue_parameter || cb->residue_parameter >= 31)
215  return AVERROR_INVALIDDATA;
216  if (cb->coding_mode == 2)
217  avpriv_request_sample(avctx, "coding mode 2");
218  } else if (cb->coding_mode == 3) {
219  cb->residue_bits = get_urice(gb, 4);
220  if (!cb->residue_bits || cb->residue_bits >= 31)
221  return AVERROR_INVALIDDATA;
222  } else if (cb->coding_mode) {
223  return AVERROR_INVALIDDATA;
224  }
225 
226  if (cb->coding_mode == 2)
227  reset_stats(cb);
228 
229  return 0;
230 }
231 
232 #define A (-1)
233 #define B (-2)
234 #define C (-3)
235 #define D (-4)
236 #define E (-5)
237 #define P2 (((unsigned)dst[A] + dst[A]) - dst[B])
238 #define P3 (((unsigned)dst[A] - dst[B]) * 3 + dst[C])
239 
240 static int do_decode(AVCodecContext *avctx, AVFrame *frame, int decorrelate, int downsample)
241 {
242  OSQContext *s = avctx->priv_data;
243  const int nb_channels = avctx->ch_layout.nb_channels;
244  const int nb_samples = frame->nb_samples;
245  GetBitContext *gb = &s->gb;
246 
247  for (int n = 0; n < nb_samples; n++) {
248  for (int ch = 0; ch < nb_channels; ch++) {
249  OSQChannel *cb = &s->ch[ch];
250  int32_t *dst = s->decode_buffer[ch] + OFFSET;
251  int32_t p, prev = cb->prev;
252 
253  if (nb_channels == 2 && ch == 1 && decorrelate != s->decorrelate) {
254  if (!decorrelate) {
255  s->decode_buffer[1][OFFSET+A] += s->decode_buffer[0][OFFSET+B];
256  s->decode_buffer[1][OFFSET+B] += s->decode_buffer[0][OFFSET+C];
257  s->decode_buffer[1][OFFSET+C] += s->decode_buffer[0][OFFSET+D];
258  s->decode_buffer[1][OFFSET+D] += s->decode_buffer[0][OFFSET+E];
259  } else {
260  s->decode_buffer[1][OFFSET+A] -= s->decode_buffer[0][OFFSET+B];
261  s->decode_buffer[1][OFFSET+B] -= s->decode_buffer[0][OFFSET+C];
262  s->decode_buffer[1][OFFSET+C] -= s->decode_buffer[0][OFFSET+D];
263  s->decode_buffer[1][OFFSET+D] -= s->decode_buffer[0][OFFSET+E];
264  }
265  s->decorrelate = decorrelate;
266  }
267 
268  if (!cb->coding_mode) {
269  dst[n] = 0;
270  } else if (cb->coding_mode == 3) {
271  dst[n] = get_sbits_long(gb, cb->residue_bits);
272  } else {
273  dst[n] = get_srice(gb, cb->residue_parameter);
274  }
275 
276  if (get_bits_left(gb) < 0) {
277  av_log(avctx, AV_LOG_ERROR, "overread!\n");
278  return AVERROR_INVALIDDATA;
279  }
280 
281  p = prev / 2;
282  prev = dst[n];
283 
284  switch (cb->prediction) {
285  case 0:
286  break;
287  case 1:
288  dst[n] += (unsigned)dst[A];
289  break;
290  case 2:
291  dst[n] += (unsigned)dst[A] + p;
292  break;
293  case 3:
294  dst[n] += P2;
295  break;
296  case 4:
297  dst[n] += P2 + p;
298  break;
299  case 5:
300  dst[n] += P3;
301  break;
302  case 6:
303  dst[n] += P3 + p;
304  break;
305  case 7:
306  dst[n] += (int)(P2 + P3) / 2 + (unsigned)p;
307  break;
308  case 8:
309  dst[n] += (int)(P2 + P3) / 2 + 0U;
310  break;
311  case 9:
312  dst[n] += (int)(P2 * 2 + P3) / 3 + (unsigned)p;
313  break;
314  case 10:
315  dst[n] += (int)(P2 + P3 * 2) / 3 + (unsigned)p;
316  break;
317  case 11:
318  dst[n] += (int)((unsigned)dst[A] + dst[B]) / 2 + 0U;
319  break;
320  case 12:
321  dst[n] += (unsigned)dst[B];
322  break;
323  case 13:
324  dst[n] += (int)((unsigned)dst[D] + dst[B]) / 2 + 0U;
325  break;
326  case 14:
327  dst[n] += (int)((unsigned)P2 + dst[A]) / 2 + (unsigned)p;
328  break;
329  default:
330  return AVERROR_INVALIDDATA;
331  }
332 
333  cb->prev = prev;
334 
335  if (downsample)
336  dst[n] *= 256U;
337 
338  dst[E] = dst[D];
339  dst[D] = dst[C];
340  dst[C] = dst[B];
341  dst[B] = dst[A];
342  dst[A] = dst[n];
343 
344  if (cb->coding_mode == 2) {
345  update_stats(cb, dst[n]);
346  cb->residue_parameter = update_residue_parameter(cb);
347  }
348 
349  if (nb_channels == 2 && ch == 1) {
350  if (decorrelate)
351  dst[n] += (unsigned)s->decode_buffer[0][OFFSET+n];
352  }
353 
354  if (downsample)
355  dst[A] /= 256;
356  }
357  }
358 
359  return 0;
360 }
361 
363 {
364  const int nb_channels = avctx->ch_layout.nb_channels;
365  const int nb_samples = frame->nb_samples;
366  OSQContext *s = avctx->priv_data;
367  const unsigned factor = s->factor;
368  int ret, decorrelate, downsample;
369  GetBitContext *gb = &s->gb;
370 
371  skip_bits1(gb);
372  decorrelate = get_bits1(gb);
373  downsample = get_bits1(gb);
374 
375  for (int ch = 0; ch < nb_channels; ch++) {
376  if ((ret = osq_channel_parameters(avctx, ch)) < 0) {
377  av_log(avctx, AV_LOG_ERROR, "invalid channel parameters\n");
378  return ret;
379  }
380  }
381 
382  if ((ret = do_decode(avctx, frame, decorrelate, downsample)) < 0)
383  return ret;
384 
385  align_get_bits(gb);
386 
387  switch (avctx->sample_fmt) {
388  case AV_SAMPLE_FMT_U8P:
389  for (int ch = 0; ch < nb_channels; ch++) {
390  uint8_t *dst = (uint8_t *)frame->extended_data[ch];
391  int32_t *src = s->decode_buffer[ch] + OFFSET;
392 
393  for (int n = 0; n < nb_samples; n++)
394  dst[n] = av_clip_uint8(src[n] + 0x80);
395  }
396  break;
397  case AV_SAMPLE_FMT_S16P:
398  for (int ch = 0; ch < nb_channels; ch++) {
399  int16_t *dst = (int16_t *)frame->extended_data[ch];
400  int32_t *src = s->decode_buffer[ch] + OFFSET;
401 
402  for (int n = 0; n < nb_samples; n++)
403  dst[n] = (int16_t)src[n];
404  }
405  break;
406  case AV_SAMPLE_FMT_S32P:
407  for (int ch = 0; ch < nb_channels; ch++) {
408  int32_t *dst = (int32_t *)frame->extended_data[ch];
409  int32_t *src = s->decode_buffer[ch] + OFFSET;
410 
411  for (int n = 0; n < nb_samples; n++)
412  dst[n] = src[n] * factor;
413  }
414  break;
415  default:
416  return AVERROR_BUG;
417  }
418 
419  return 0;
420 }
421 
423 {
424  OSQContext *s = avctx->priv_data;
425  GetBitContext *gb = &s->gb;
426  int ret, n;
427 
428  while (s->bitstream_size < s->max_framesize) {
429  int size;
430 
431  if (!s->pkt->data) {
432  ret = ff_decode_get_packet(avctx, s->pkt);
433  if (ret == AVERROR_EOF && s->bitstream_size > 0)
434  break;
435  if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN))
436  return ret;
437  if (ret < 0)
438  goto fail;
439  }
440 
441  size = FFMIN(s->pkt->size - s->pkt_offset, s->max_framesize - s->bitstream_size);
442  memcpy(s->bitstream + s->bitstream_size, s->pkt->data + s->pkt_offset, size);
443  s->bitstream_size += size;
444  s->pkt_offset += size;
445 
446  if (s->pkt_offset == s->pkt->size) {
447  av_packet_unref(s->pkt);
448  s->pkt_offset = 0;
449  }
450  }
451 
452  frame->nb_samples = FFMIN(s->frame_samples, s->nb_samples);
453  if (frame->nb_samples <= 0)
454  return AVERROR_EOF;
455 
456  if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
457  goto fail;
458 
459  if ((ret = init_get_bits8(gb, s->bitstream, s->bitstream_size)) < 0)
460  goto fail;
461 
462  if ((ret = osq_decode_block(avctx, frame)) < 0)
463  goto fail;
464 
465  s->nb_samples -= frame->nb_samples;
466 
467  n = get_bits_count(gb) / 8;
468  if (n > s->bitstream_size) {
470  goto fail;
471  }
472 
473  memmove(s->bitstream, &s->bitstream[n], s->bitstream_size - n);
474  s->bitstream_size -= n;
475 
476  return 0;
477 
478 fail:
479  s->bitstream_size = 0;
480  s->pkt_offset = 0;
481  av_packet_unref(s->pkt);
482 
483  return ret;
484 }
485 
487  .p.name = "osq",
488  CODEC_LONG_NAME("OSQ (Original Sound Quality)"),
489  .p.type = AVMEDIA_TYPE_AUDIO,
490  .p.id = AV_CODEC_ID_OSQ,
491  .priv_data_size = sizeof(OSQContext),
492  .init = osq_init,
494  .close = osq_close,
495  .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF |
497  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
499  .flush = osq_flush,
500 };
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: packet.c:433
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:245
decorrelate
static void decorrelate(SnowContext *s, SubBand *b, IDWTELEM *src, int stride, int inverse, int use_median)
Definition: snowenc.c:1514
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:689
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:1024
cb
static double cb(void *priv, double x, double y)
Definition: vf_geq.c:247
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:235
OSQContext::bitstream_size
size_t bitstream_size
Definition: osq.c:53
get_bits_long
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
Definition: get_bits.h:419
int64_t
long long int64_t
Definition: coverity.c:34
OSQContext::decode_buffer
int32_t * decode_buffer[2]
Definition: osq.c:60
get_bits_count
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:250
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:427
OSQChannel::prev
int32_t prev
Definition: osq.c:44
OSQContext::ch
OSQChannel ch[2]
Definition: osq.c:49
internal.h
b
#define b
Definition: input.c:42
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:324
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:329
OSQChannel::residue_parameter
unsigned residue_parameter
Definition: osq.c:39
do_decode
static int do_decode(AVCodecContext *avctx, AVFrame *frame, int decorrelate, int downsample)
Definition: osq.c:240
P3
#define P3
Definition: osq.c:238
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
av_ceil_log2
#define av_ceil_log2
Definition: common.h:97
AVCodecContext::ch_layout
AVChannelLayout ch_layout
Audio channel layout.
Definition: avcodec.h:1039
fail
#define fail()
Definition: checkasm.h:200
OSQContext::pkt_offset
int pkt_offset
Definition: osq.c:63
GetBitContext
Definition: get_bits.h:109
OSQContext::max_framesize
size_t max_framesize
Definition: osq.c:52
OSQChannel::coding_mode
unsigned coding_mode
Definition: osq.c:38
val
static double val(void *priv, double ch)
Definition: aeval.c:77
OFFSET
#define OFFSET
Definition: osq.c:34
OSQChannel::count
unsigned count
Definition: osq.c:42
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
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:539
AVCodecContext::extradata_size
int extradata_size
Definition: avcodec.h:515
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:201
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:119
OSQContext::nb_samples
uint64_t nb_samples
Definition: osq.c:58
AVCodecContext::bits_per_raw_sample
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:1553
C
#define C
Definition: osq.c:234
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:47
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:331
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:74
update_residue_parameter
static int update_residue_parameter(OSQChannel *cb)
Definition: osq.c:160
AVCodecContext::internal
struct AVCodecInternal * internal
Private context used for internal data.
Definition: avcodec.h:466
OSQContext::factor
int factor
Definition: osq.c:55
get_bits1
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:386
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:91
f
f
Definition: af_crystalizer.c:122
ff_get_buffer
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1720
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
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:43
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:87
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:424
AVCodecContext::sample_fmt
enum AVSampleFormat sample_fmt
audio sample format
Definition: avcodec.h:1031
size
int size
Definition: twinvq_data.h:10344
E
#define E
Definition: osq.c:236
attributes.h
skip_bits1
static void skip_bits1(GetBitContext *s)
Definition: get_bits.h:411
CODEC_SAMPLEFMTS
#define CODEC_SAMPLEFMTS(...)
Definition: codec_internal.h:385
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:40
av_assert2
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
Definition: avassert.h:68
OSQContext::pkt
AVPacket * pkt
Definition: osq.c:62
osq_decode_block
static int osq_decode_block(AVCodecContext *avctx, AVFrame *frame)
Definition: osq.c:362
OSQContext::gb
GetBitContext gb
Definition: osq.c:48
AVCodecContext::extradata
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
Definition: avcodec.h:514
internal.h
OSQChannel
Definition: osq.c:36
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:83
OSQChannel::history
unsigned history[3]
Definition: osq.c:41
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:179
osq_receive_frame
static int osq_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Definition: osq.c:422
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:264
avcodec.h
OSQContext::bitstream
uint8_t * bitstream
Definition: osq.c:51
reset_stats
static void reset_stats(OSQChannel *cb)
Definition: osq.c:142
OSQContext::frame_samples
int frame_samples
Definition: osq.c:57
OSQContext::decorrelate
int decorrelate
Definition: osq.c:56
ret
ret
Definition: filter_design.txt:187
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:265
align_get_bits
static const uint8_t * align_get_bits(GetBitContext *s)
Definition: get_bits.h:555
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
U
#define U(x)
Definition: vpx_arith.h:37
AVCodecContext
main external API structure.
Definition: avcodec.h:431
FF_CODEC_RECEIVE_FRAME_CB
#define FF_CODEC_RECEIVE_FRAME_CB(func)
Definition: codec_internal.h:354
osq_init
static av_cold int osq_init(AVCodecContext *avctx)
Definition: osq.c:87
get_urice
static uint32_t get_urice(GetBitContext *gb, int k)
Definition: osq.c:184
ff_osq_decoder
const FFCodec ff_osq_decoder
Definition: osq.c:486
osq_close
static av_cold int osq_close(AVCodecContext *avctx)
Definition: osq.c:74
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:442
Windows::Graphics::DirectX::Direct3D11::p
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
Definition: vsrc_gfxcapture_winrt.hpp:53
osq_flush
static av_cold void osq_flush(AVCodecContext *avctx)
Definition: osq.c:66
av_clip_uint8
#define av_clip_uint8
Definition: common.h:106
factor
static const int factor[16]
Definition: vf_pp7.c:80
mem.h
update_stats
static void update_stats(OSQChannel *cb, int val)
Definition: osq.c:148
avpriv_request_sample
#define avpriv_request_sample(...)
Definition: tableprint_vlc.h:37
P2
#define P2
Definition: osq.c:237
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:458
AVPacket
This structure stores compressed data.
Definition: packet.h:535
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
osq_channel_parameters
static int osq_channel_parameters(AVCodecContext *avctx, int ch)
Definition: osq.c:201
int32_t
int32_t
Definition: audioconvert.c:56
A
#define A
Definition: osq.c:232
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:233
OSQChannel::pos
unsigned pos
Definition: osq.c:42
get_sbits_long
static int get_sbits_long(GetBitContext *s, int n)
Read 0-32 bits as a signed integer.
Definition: get_bits.h:469
get_srice
static int32_t get_srice(GetBitContext *gb, int x)
Definition: osq.c:195
AV_CODEC_ID_OSQ
@ AV_CODEC_ID_OSQ
Definition: codec_id.h:555
OSQChannel::prediction
unsigned prediction
Definition: osq.c:37
src
#define src
Definition: vp8dsp.c:248