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 av_cold int osq_close(AVCodecContext *avctx)
65 {
66  OSQContext *s = avctx->priv_data;
67 
68  av_freep(&s->bitstream);
69  s->bitstream_size = 0;
70 
71  for (int ch = 0; ch < FF_ARRAY_ELEMS(s->decode_buffer); ch++)
72  av_freep(&s->decode_buffer[ch]);
73 
74  return 0;
75 }
76 
77 static av_cold int osq_init(AVCodecContext *avctx)
78 {
79  OSQContext *s = avctx->priv_data;
80 
81  if (avctx->extradata_size < 48)
82  return AVERROR(EINVAL);
83 
84  if (avctx->extradata[0] != 1) {
85  av_log(avctx, AV_LOG_ERROR, "Unsupported version.\n");
86  return AVERROR_INVALIDDATA;
87  }
88 
89  avctx->sample_rate = AV_RL32(avctx->extradata + 4);
90  if (avctx->sample_rate < 1)
91  return AVERROR_INVALIDDATA;
92 
95  avctx->ch_layout.nb_channels = avctx->extradata[3];
96  if (avctx->ch_layout.nb_channels < 1)
97  return AVERROR_INVALIDDATA;
98  if (avctx->ch_layout.nb_channels > FF_ARRAY_ELEMS(s->decode_buffer))
99  return AVERROR_INVALIDDATA;
100 
101  s->factor = 1;
102  switch (avctx->extradata[2]) {
103  case 8: avctx->sample_fmt = AV_SAMPLE_FMT_U8P; break;
104  case 16: avctx->sample_fmt = AV_SAMPLE_FMT_S16P; break;
105  case 20:
106  case 24: s->factor = 256;
107  avctx->sample_fmt = AV_SAMPLE_FMT_S32P; break;
108  default: return AVERROR_INVALIDDATA;
109  }
110 
111  avctx->bits_per_raw_sample = avctx->extradata[2];
112  s->nb_samples = AV_RL64(avctx->extradata + 16);
113  s->frame_samples = AV_RL16(avctx->extradata + 8);
114  s->max_framesize = (s->frame_samples * 16 + 1024) * avctx->ch_layout.nb_channels;
115 
116  s->bitstream = av_calloc(s->max_framesize + AV_INPUT_BUFFER_PADDING_SIZE, sizeof(*s->bitstream));
117  if (!s->bitstream)
118  return AVERROR(ENOMEM);
119 
120  for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
121  s->decode_buffer[ch] = av_calloc(s->frame_samples + OFFSET,
122  sizeof(*s->decode_buffer[ch]));
123  if (!s->decode_buffer[ch])
124  return AVERROR(ENOMEM);
125  }
126 
127  s->pkt = avctx->internal->in_pkt;
128 
129  return 0;
130 }
131 
132 static void reset_stats(OSQChannel *cb)
133 {
134  memset(cb->history, 0, sizeof(cb->history));
135  cb->pos = cb->count = cb->sum = 0;
136 }
137 
138 static void update_stats(OSQChannel *cb, int val)
139 {
140  cb->sum += FFABS(val) - cb->history[cb->pos];
141  cb->history[cb->pos] = FFABS(val);
142  cb->pos++;
143  cb->count++;
144  if (cb->pos >= FF_ARRAY_ELEMS(cb->history))
145  cb->pos = 0;
146 }
147 
149 {
150  double sum, x;
151  int rice_k;
152 
153  sum = cb->sum;
154  x = sum / cb->count;
155  rice_k = av_ceil_log2(x);
156  if (rice_k >= 30) {
157  rice_k = floor(sum / 1.4426952 + 0.5);
158  if (rice_k < 1)
159  rice_k = 1;
160  }
161 
162  return rice_k;
163 }
164 
165 static uint32_t get_urice(GetBitContext *gb, int k)
166 {
167  uint32_t z, x, b;
168 
169  x = get_unary(gb, 1, 512);
170  b = get_bits_long(gb, k);
171  z = b | x << k;
172 
173  return z;
174 }
175 
176 static int32_t get_srice(GetBitContext *gb, int x)
177 {
178  int32_t y = get_urice(gb, x);
179  return get_bits1(gb) ? -y : y;
180 }
181 
182 static int osq_channel_parameters(AVCodecContext *avctx, int ch)
183 {
184  OSQContext *s = avctx->priv_data;
185  OSQChannel *cb = &s->ch[ch];
186  GetBitContext *gb = &s->gb;
187 
188  cb->prev = 0;
189  cb->prediction = get_urice(gb, 5);
190  cb->coding_mode = get_urice(gb, 3);
191  if (cb->prediction >= 15)
192  return AVERROR_INVALIDDATA;
193  if (cb->coding_mode > 0 && cb->coding_mode < 3) {
194  cb->residue_parameter = get_urice(gb, 4);
195  if (!cb->residue_parameter || cb->residue_parameter >= 31)
196  return AVERROR_INVALIDDATA;
197  } else if (cb->coding_mode == 3) {
198  cb->residue_bits = get_urice(gb, 4);
199  if (!cb->residue_bits || cb->residue_bits >= 31)
200  return AVERROR_INVALIDDATA;
201  } else if (cb->coding_mode) {
202  return AVERROR_INVALIDDATA;
203  }
204 
205  if (cb->coding_mode == 2)
206  reset_stats(cb);
207 
208  return 0;
209 }
210 
211 #define A (-1)
212 #define B (-2)
213 #define C (-3)
214 #define D (-4)
215 #define E (-5)
216 #define P2 ((dst[A] + dst[A]) - dst[B])
217 #define P3 ((dst[A] - dst[B]) * 3 + dst[C])
218 
219 static int do_decode(AVCodecContext *avctx, AVFrame *frame, int decorrelate, int downsample)
220 {
221  OSQContext *s = avctx->priv_data;
222  const int nb_channels = avctx->ch_layout.nb_channels;
223  const int nb_samples = frame->nb_samples;
224  GetBitContext *gb = &s->gb;
225 
226  for (int n = 0; n < nb_samples; n++) {
227  for (int ch = 0; ch < nb_channels; ch++) {
228  OSQChannel *cb = &s->ch[ch];
229  int32_t *dst = s->decode_buffer[ch] + OFFSET;
230  int32_t p, prev = cb->prev;
231 
232  if (nb_channels == 2 && ch == 1 && decorrelate != s->decorrelate) {
233  if (!decorrelate) {
234  s->decode_buffer[1][OFFSET+A] += s->decode_buffer[0][OFFSET+B];
235  s->decode_buffer[1][OFFSET+B] += s->decode_buffer[0][OFFSET+C];
236  s->decode_buffer[1][OFFSET+C] += s->decode_buffer[0][OFFSET+D];
237  s->decode_buffer[1][OFFSET+D] += s->decode_buffer[0][OFFSET+E];
238  } else {
239  s->decode_buffer[1][OFFSET+A] -= s->decode_buffer[0][OFFSET+B];
240  s->decode_buffer[1][OFFSET+B] -= s->decode_buffer[0][OFFSET+C];
241  s->decode_buffer[1][OFFSET+C] -= s->decode_buffer[0][OFFSET+D];
242  s->decode_buffer[1][OFFSET+D] -= s->decode_buffer[0][OFFSET+E];
243  }
244  s->decorrelate = decorrelate;
245  }
246 
247  if (!cb->coding_mode) {
248  dst[n] = 0;
249  } else if (cb->coding_mode == 3) {
250  dst[n] = get_sbits_long(gb, cb->residue_bits);
251  } else {
252  dst[n] = get_srice(gb, cb->residue_parameter);
253  }
254 
255  if (get_bits_left(gb) < 0) {
256  av_log(avctx, AV_LOG_ERROR, "overread!\n");
257  return AVERROR_INVALIDDATA;
258  }
259 
260  p = prev / 2;
261  prev = dst[n];
262 
263  switch (cb->prediction) {
264  case 0:
265  break;
266  case 1:
267  dst[n] += dst[A];
268  break;
269  case 2:
270  dst[n] += dst[A] + p;
271  break;
272  case 3:
273  dst[n] += P2;
274  break;
275  case 4:
276  dst[n] += P2 + p;
277  break;
278  case 5:
279  dst[n] += P3;
280  break;
281  case 6:
282  dst[n] += P3 + p;
283  break;
284  case 7:
285  dst[n] += (P2 + P3) / 2 + p;
286  break;
287  case 8:
288  dst[n] += (P2 + P3) / 2;
289  break;
290  case 9:
291  dst[n] += (P2 * 2 + P3) / 3 + p;
292  break;
293  case 10:
294  dst[n] += (P2 + P3 * 2) / 3 + p;
295  break;
296  case 11:
297  dst[n] += (dst[A] + dst[B]) / 2;
298  break;
299  case 12:
300  dst[n] += dst[B];
301  break;
302  case 13:
303  dst[n] += (dst[D] + dst[B]) / 2;
304  break;
305  case 14:
306  dst[n] += (P2 + dst[A]) / 2 + p;
307  break;
308  default:
309  return AVERROR_INVALIDDATA;
310  }
311 
312  cb->prev = prev;
313 
314  if (downsample)
315  dst[n] *= 256;
316 
317  dst[E] = dst[D];
318  dst[D] = dst[C];
319  dst[C] = dst[B];
320  dst[B] = dst[A];
321  dst[A] = dst[n];
322 
323  if (cb->coding_mode == 2) {
324  update_stats(cb, dst[n]);
325  cb->residue_parameter = update_residue_parameter(cb);
326  }
327 
328  if (nb_channels == 2 && ch == 1) {
329  if (decorrelate)
330  dst[n] += s->decode_buffer[0][OFFSET+n];
331  }
332 
333  if (downsample)
334  dst[A] /= 256;
335  }
336  }
337 
338  return 0;
339 }
340 
342 {
343  const int nb_channels = avctx->ch_layout.nb_channels;
344  const int nb_samples = frame->nb_samples;
345  OSQContext *s = avctx->priv_data;
346  const int factor = s->factor;
347  int ret, decorrelate, downsample;
348  GetBitContext *gb = &s->gb;
349 
350  skip_bits1(gb);
351  decorrelate = get_bits1(gb);
352  downsample = get_bits1(gb);
353 
354  for (int ch = 0; ch < nb_channels; ch++) {
355  if ((ret = osq_channel_parameters(avctx, ch)) < 0) {
356  av_log(avctx, AV_LOG_ERROR, "invalid channel parameters\n");
357  return ret;
358  }
359  }
360 
361  if ((ret = do_decode(avctx, frame, decorrelate, downsample)) < 0)
362  return ret;
363 
364  align_get_bits(gb);
365 
366  switch (avctx->sample_fmt) {
367  case AV_SAMPLE_FMT_U8P:
368  for (int ch = 0; ch < nb_channels; ch++) {
369  uint8_t *dst = (uint8_t *)frame->extended_data[ch];
370  int32_t *src = s->decode_buffer[ch] + OFFSET;
371 
372  for (int n = 0; n < nb_samples; n++)
373  dst[n] = av_clip_uint8(src[n] + 0x80);
374  }
375  break;
376  case AV_SAMPLE_FMT_S16P:
377  for (int ch = 0; ch < nb_channels; ch++) {
378  int16_t *dst = (int16_t *)frame->extended_data[ch];
379  int32_t *src = s->decode_buffer[ch] + OFFSET;
380 
381  for (int n = 0; n < nb_samples; n++)
382  dst[n] = (int16_t)src[n];
383  }
384  break;
385  case AV_SAMPLE_FMT_S32P:
386  for (int ch = 0; ch < nb_channels; ch++) {
387  int32_t *dst = (int32_t *)frame->extended_data[ch];
388  int32_t *src = s->decode_buffer[ch] + OFFSET;
389 
390  for (int n = 0; n < nb_samples; n++)
391  dst[n] = src[n] * factor;
392  }
393  break;
394  default:
395  return AVERROR_BUG;
396  }
397 
398  return 0;
399 }
400 
402 {
403  OSQContext *s = avctx->priv_data;
404  GetBitContext *gb = &s->gb;
405  int ret, n;
406 
407  while (s->bitstream_size < s->max_framesize) {
408  int size;
409 
410  if (!s->pkt->data) {
411  ret = ff_decode_get_packet(avctx, s->pkt);
412  if (ret == AVERROR_EOF && s->bitstream_size > 0)
413  break;
414  if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN))
415  return ret;
416  if (ret < 0)
417  goto fail;
418  }
419 
420  size = FFMIN(s->pkt->size - s->pkt_offset, s->max_framesize - s->bitstream_size);
421  memcpy(s->bitstream + s->bitstream_size, s->pkt->data + s->pkt_offset, size);
422  s->bitstream_size += size;
423  s->pkt_offset += size;
424 
425  if (s->pkt_offset == s->pkt->size) {
426  av_packet_unref(s->pkt);
427  s->pkt_offset = 0;
428  }
429  }
430 
431  frame->nb_samples = FFMIN(s->frame_samples, s->nb_samples);
432  if (frame->nb_samples <= 0)
433  return AVERROR_EOF;
434 
435  if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
436  goto fail;
437 
438  if ((ret = init_get_bits8(gb, s->bitstream, s->bitstream_size)) < 0)
439  goto fail;
440 
441  if ((ret = osq_decode_block(avctx, frame)) < 0)
442  goto fail;
443 
444  s->nb_samples -= frame->nb_samples;
445 
446  n = get_bits_count(gb) / 8;
447  if (n > s->bitstream_size) {
449  goto fail;
450  }
451 
452  memmove(s->bitstream, &s->bitstream[n], s->bitstream_size - n);
453  s->bitstream_size -= n;
454 
455  return 0;
456 
457 fail:
458  s->bitstream_size = 0;
459  s->pkt_offset = 0;
460  av_packet_unref(s->pkt);
461 
462  return ret;
463 }
464 
466  .p.name = "osq",
467  CODEC_LONG_NAME("OSQ (Original Sound Quality)"),
468  .p.type = AVMEDIA_TYPE_AUDIO,
469  .p.id = AV_CODEC_ID_OSQ,
470  .priv_data_size = sizeof(OSQContext),
471  .init = osq_init,
473  .close = osq_close,
474  .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF |
476  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
477  .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_U8P,
481 };
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:214
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
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:314
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:319
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:219
P3
#define P3
Definition: osq.c:217
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:141
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:213
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:148
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:215
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:341
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:401
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:132
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:77
get_urice
static uint32_t get_urice(GetBitContext *gb, int k)
Definition: osq.c:165
ff_osq_decoder
const FFCodec ff_osq_decoder
Definition: osq.c:465
osq_close
static av_cold int osq_close(AVCodecContext *avctx)
Definition: osq.c:64
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:642
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:138
P2
#define P2
Definition: osq.c:216
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:182
int32_t
int32_t
Definition: audioconvert.c:56
A
#define A
Definition: osq.c:211
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:212
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
get_srice
static int32_t get_srice(GetBitContext *gb, int x)
Definition: osq.c:176
AV_CODEC_ID_OSQ
@ AV_CODEC_ID_OSQ
Definition: codec_id.h:547
OSQChannel::prediction
unsigned prediction
Definition: osq.c:35