FFmpeg
wmaenc.c
Go to the documentation of this file.
1 /*
2  * WMA compatible encoder
3  * Copyright (c) 2007 Michael Niedermayer
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 "config_components.h"
23 
24 #include "libavutil/attributes.h"
25 #include "libavutil/ffmath.h"
26 
27 #include "avcodec.h"
28 #include "codec_internal.h"
29 #include "encode.h"
30 #include "wma.h"
31 #include "libavutil/avassert.h"
32 
33 
35 {
36  WMACodecContext *s = avctx->priv_data;
37  int i, flags1, flags2, block_align;
38  uint8_t *extradata;
39  int ret;
40 
41  s->avctx = avctx;
42 
43  if (avctx->ch_layout.nb_channels > MAX_CHANNELS) {
44  av_log(avctx, AV_LOG_ERROR,
45  "too many channels: got %i, need %i or fewer\n",
47  return AVERROR(EINVAL);
48  }
49 
50  if (avctx->sample_rate > 48000) {
51  av_log(avctx, AV_LOG_ERROR, "sample rate is too high: %d > 48kHz\n",
52  avctx->sample_rate);
53  return AVERROR(EINVAL);
54  }
55 
56  if (avctx->bit_rate < 24 * 1000) {
57  av_log(avctx, AV_LOG_ERROR,
58  "bitrate too low: got %"PRId64", need 24000 or higher\n",
59  avctx->bit_rate);
60  return AVERROR(EINVAL);
61  }
62 
63  /* extract flag info */
64  flags1 = 0;
65  flags2 = 1;
66  if (avctx->codec->id == AV_CODEC_ID_WMAV1) {
67  extradata = av_malloc(4);
68  if (!extradata)
69  return AVERROR(ENOMEM);
70  avctx->extradata_size = 4;
71  AV_WL16(extradata, flags1);
72  AV_WL16(extradata + 2, flags2);
73  } else if (avctx->codec->id == AV_CODEC_ID_WMAV2) {
74  extradata = av_mallocz(10);
75  if (!extradata)
76  return AVERROR(ENOMEM);
77  avctx->extradata_size = 10;
78  AV_WL32(extradata, flags1);
79  AV_WL16(extradata + 4, flags2);
80  } else {
81  av_assert0(0);
82  }
83  avctx->extradata = extradata;
84  s->use_exp_vlc = flags2 & 0x0001;
85  s->use_bit_reservoir = flags2 & 0x0002;
86  s->use_variable_block_len = flags2 & 0x0004;
87  if (avctx->ch_layout.nb_channels == 2)
88  s->ms_stereo = 1;
89 
90  if ((ret = ff_wma_init(avctx, flags2)) < 0)
91  return ret;
92 
93  /* init MDCT */
94  for (i = 0; i < s->nb_block_sizes; i++) {
95  float scale = 1.0f;
96  ret = av_tx_init(&s->mdct_ctx[i], &s->mdct_fn[i], AV_TX_FLOAT_MDCT,
97  0, 1 << (s->frame_len_bits - i), &scale, 0);
98  if (ret < 0)
99  return ret;
100  }
101 
102  block_align = avctx->bit_rate * (int64_t) s->frame_len /
103  (avctx->sample_rate * 8);
104  block_align = FFMIN(block_align, MAX_CODED_SUPERFRAME_SIZE);
105  avctx->block_align = block_align;
106  avctx->frame_size = avctx->initial_padding = s->frame_len;
107 
108  return 0;
109 }
110 
112 {
113  WMACodecContext *s = avctx->priv_data;
114  const float *const *audio = (const float *const *) frame->extended_data;
115  int len = frame->nb_samples;
116  int window_index = s->frame_len_bits - s->block_len_bits;
117  AVTXContext *mdct = s->mdct_ctx[window_index];
118  av_tx_fn mdct_fn = s->mdct_fn[window_index];
119  int ch;
120  const float *win = s->windows[window_index];
121  int window_len = 1 << s->block_len_bits;
122  float n = 2.0 * 32768.0 / window_len;
123 
124  for (ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
125  memcpy(s->output, s->frame_out[ch], window_len * sizeof(*s->output));
126  s->fdsp->vector_fmul_scalar(s->frame_out[ch], audio[ch], n, len);
127  s->fdsp->vector_fmul_reverse(&s->output[window_len], s->frame_out[ch],
128  win, len);
129  s->fdsp->vector_fmul(s->frame_out[ch], s->frame_out[ch], win, len);
130  mdct_fn(mdct, s->coefs[ch], s->output, sizeof(float));
131  if (!isfinite(s->coefs[ch][0])) {
132  av_log(avctx, AV_LOG_ERROR, "Input contains NaN/+-Inf\n");
133  return AVERROR(EINVAL);
134  }
135  }
136 
137  return 0;
138 }
139 
140 // FIXME use for decoding too
141 static void init_exp(WMACodecContext *s, int ch, const int *exp_param)
142 {
143  int n;
144  const uint16_t *ptr;
145  float v, *q, max_scale, *q_end;
146 
147  ptr = s->exponent_bands[s->frame_len_bits - s->block_len_bits];
148  q = s->exponents[ch];
149  q_end = q + s->block_len;
150  max_scale = 0;
151  while (q < q_end) {
152  /* XXX: use a table */
153  v = ff_exp10(*exp_param++ *(1.0 / 16.0));
154  max_scale = FFMAX(max_scale, v);
155  n = *ptr++;
156  do {
157  *q++ = v;
158  } while (--n);
159  }
160  s->max_exponent[ch] = max_scale;
161 }
162 
163 static void encode_exp_vlc(WMACodecContext *s, int ch, const int *exp_param)
164 {
165  int last_exp;
166  const uint16_t *ptr;
167  float *q, *q_end;
168 
169  ptr = s->exponent_bands[s->frame_len_bits - s->block_len_bits];
170  q = s->exponents[ch];
171  q_end = q + s->block_len;
172  if (s->version == 1) {
173  last_exp = *exp_param++;
174  av_assert0(last_exp - 10 >= 0 && last_exp - 10 < 32);
175  put_bits(&s->pb, 5, last_exp - 10);
176  q += *ptr++;
177  } else
178  last_exp = 36;
179  while (q < q_end) {
180  int exp = *exp_param++;
181  int code = exp - last_exp + 60;
182  av_assert1(code >= 0 && code < 120);
185  /* XXX: use a table */
186  q += *ptr++;
187  last_exp = exp;
188  }
189 }
190 
191 static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE],
192  int total_gain)
193 {
194  int channels = s->avctx->ch_layout.nb_channels;
195  int v, bsize, ch, coef_nb_bits, parse_exponents;
196  float mdct_norm;
197  int nb_coefs[MAX_CHANNELS];
198  static const int fixed_exp[25] = {
199  20, 20, 20, 20, 20,
200  20, 20, 20, 20, 20,
201  20, 20, 20, 20, 20,
202  20, 20, 20, 20, 20,
203  20, 20, 20, 20, 20
204  };
205 
206  // FIXME remove duplication relative to decoder
207  if (s->use_variable_block_len) {
208  av_assert0(0); // FIXME not implemented
209  } else {
210  /* fixed block len */
211  s->next_block_len_bits = s->frame_len_bits;
212  s->prev_block_len_bits = s->frame_len_bits;
213  s->block_len_bits = s->frame_len_bits;
214  }
215 
216  s->block_len = 1 << s->block_len_bits;
217 // av_assert0((s->block_pos + s->block_len) <= s->frame_len);
218  bsize = s->frame_len_bits - s->block_len_bits;
219 
220  // FIXME factor
221  v = s->coefs_end[bsize] - s->coefs_start;
222  for (ch = 0; ch < channels; ch++)
223  nb_coefs[ch] = v;
224  {
225  int n4 = s->block_len / 2;
226  mdct_norm = 1.0 / (float) n4;
227  if (s->version == 1)
228  mdct_norm *= sqrt(n4);
229  }
230 
231  if (channels == 2)
232  put_bits(&s->pb, 1, !!s->ms_stereo);
233 
234  for (ch = 0; ch < channels; ch++) {
235  // FIXME only set channel_coded when needed, instead of always
236  s->channel_coded[ch] = 1;
237  if (s->channel_coded[ch])
238  init_exp(s, ch, fixed_exp);
239  }
240 
241  for (ch = 0; ch < channels; ch++) {
242  if (s->channel_coded[ch]) {
243  WMACoef *coefs1;
244  float *coefs, *exponents, mult;
245  int i, n;
246 
247  coefs1 = s->coefs1[ch];
248  exponents = s->exponents[ch];
249  mult = ff_exp10(total_gain * 0.05) / s->max_exponent[ch];
250  mult *= mdct_norm;
251  coefs = src_coefs[ch];
252  if (s->use_noise_coding && 0) {
253  av_assert0(0); // FIXME not implemented
254  } else {
255  coefs += s->coefs_start;
256  n = nb_coefs[ch];
257  for (i = 0; i < n; i++) {
258  double t = *coefs++ / (exponents[i] * mult);
259  if (t < -32768 || t > 32767)
260  return -1;
261 
262  coefs1[i] = lrint(t);
263  }
264  }
265  }
266  }
267 
268  v = 0;
269  for (ch = 0; ch < channels; ch++) {
270  int a = s->channel_coded[ch];
271  put_bits(&s->pb, 1, a);
272  v |= a;
273  }
274 
275  if (!v)
276  return 1;
277 
278  for (v = total_gain - 1; v >= 127; v -= 127)
279  put_bits(&s->pb, 7, 127);
280  put_bits(&s->pb, 7, v);
281 
282  coef_nb_bits = ff_wma_total_gain_to_bits(total_gain);
283 
284  if (s->use_noise_coding) {
285  for (ch = 0; ch < channels; ch++) {
286  if (s->channel_coded[ch]) {
287  int i, n;
288  n = s->exponent_high_sizes[bsize];
289  for (i = 0; i < n; i++) {
290  put_bits(&s->pb, 1, s->high_band_coded[ch][i] = 0);
291  if (0)
292  nb_coefs[ch] -= s->exponent_high_bands[bsize][i];
293  }
294  }
295  }
296  }
297 
298  parse_exponents = 1;
299  if (s->block_len_bits != s->frame_len_bits)
300  put_bits(&s->pb, 1, parse_exponents);
301 
302  if (parse_exponents) {
303  for (ch = 0; ch < channels; ch++) {
304  if (s->channel_coded[ch]) {
305  if (s->use_exp_vlc) {
306  encode_exp_vlc(s, ch, fixed_exp);
307  } else {
308  av_assert0(0); // FIXME not implemented
309 // encode_exp_lsp(s, ch);
310  }
311  }
312  }
313  } else
314  av_assert0(0); // FIXME not implemented
315 
316  for (ch = 0; ch < channels; ch++) {
317  if (s->channel_coded[ch]) {
318  int run, tindex;
319  WMACoef *ptr, *eptr;
320  tindex = (ch == 1 && s->ms_stereo);
321  ptr = &s->coefs1[ch][0];
322  eptr = ptr + nb_coefs[ch];
323 
324  run = 0;
325  for (; ptr < eptr; ptr++) {
326  if (*ptr) {
327  int level = *ptr;
328  int abs_level = FFABS(level);
329  int code = 0;
330  if (abs_level <= s->coef_vlcs[tindex]->max_level)
331  if (run < s->coef_vlcs[tindex]->levels[abs_level - 1])
332  code = run + s->int_table[tindex][abs_level - 1];
333 
334  av_assert2(code < s->coef_vlcs[tindex]->n);
335  put_bits(&s->pb, s->coef_vlcs[tindex]->huffbits[code],
336  s->coef_vlcs[tindex]->huffcodes[code]);
337 
338  if (code == 0) {
339  if (1 << coef_nb_bits <= abs_level)
340  return -1;
341 
342  put_bits(&s->pb, coef_nb_bits, abs_level);
343  put_bits(&s->pb, s->frame_len_bits, run);
344  }
345  // FIXME the sign is flipped somewhere
346  put_bits(&s->pb, 1, level < 0);
347  run = 0;
348  } else
349  run++;
350  }
351  if (run)
352  put_bits(&s->pb, s->coef_vlcs[tindex]->huffbits[1],
353  s->coef_vlcs[tindex]->huffcodes[1]);
354  }
355  if (s->version == 1 && channels >= 2)
356  align_put_bits(&s->pb);
357  }
358  return 0;
359 }
360 
361 static int encode_frame(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE],
362  uint8_t *buf, int buf_size, int total_gain)
363 {
364  init_put_bits(&s->pb, buf, buf_size);
365 
366  if (s->use_bit_reservoir)
367  av_assert0(0); // FIXME not implemented
368  else if (encode_block(s, src_coefs, total_gain) < 0)
369  return INT_MAX;
370 
371  align_put_bits(&s->pb);
372 
373  return put_bits_count(&s->pb) / 8 - s->avctx->block_align;
374 }
375 
376 static int encode_superframe(AVCodecContext *avctx, AVPacket *avpkt,
377  const AVFrame *frame, int *got_packet_ptr)
378 {
379  WMACodecContext *s = avctx->priv_data;
380  int i, total_gain, ret, error;
381 
382  s->block_len_bits = s->frame_len_bits; // required by non variable block len
383  s->block_len = 1 << s->block_len_bits;
384 
385  ret = apply_window_and_mdct(avctx, frame);
386 
387  if (ret < 0)
388  return ret;
389 
390  if (s->ms_stereo) {
391  float a, b;
392  int i;
393 
394  for (i = 0; i < s->block_len; i++) {
395  a = s->coefs[0][i] * 0.5;
396  b = s->coefs[1][i] * 0.5;
397  s->coefs[0][i] = a + b;
398  s->coefs[1][i] = a - b;
399  }
400  }
401 
402  if ((ret = ff_alloc_packet(avctx, avpkt, 2 * MAX_CODED_SUPERFRAME_SIZE)) < 0)
403  return ret;
404 
405  total_gain = 128;
406  for (i = 64; i; i >>= 1) {
407  error = encode_frame(s, s->coefs, avpkt->data, avpkt->size,
408  total_gain - i);
409  if (error <= 0)
410  total_gain -= i;
411  }
412 
413  while(total_gain <= 128 && error > 0)
414  error = encode_frame(s, s->coefs, avpkt->data, avpkt->size, total_gain++);
415  if (error > 0) {
416  av_log(avctx, AV_LOG_ERROR, "Invalid input data or requested bitrate too low, cannot encode\n");
417  avpkt->size = 0;
418  return AVERROR(EINVAL);
419  }
420  av_assert0((put_bits_count(&s->pb) & 7) == 0);
421  i = avctx->block_align - put_bytes_count(&s->pb, 0);
422  av_assert0(i>=0);
423  while(i--)
424  put_bits(&s->pb, 8, 'N');
425 
426  flush_put_bits(&s->pb);
427  av_assert0(put_bits_ptr(&s->pb) - s->pb.buf == avctx->block_align);
428 
429  if (frame->pts != AV_NOPTS_VALUE)
430  avpkt->pts = frame->pts - ff_samples_to_time_base(avctx, avctx->initial_padding);
431 
432  avpkt->size = avctx->block_align;
433  *got_packet_ptr = 1;
434  return 0;
435 }
436 
437 #if CONFIG_WMAV1_ENCODER
438 const FFCodec ff_wmav1_encoder = {
439  .p.name = "wmav1",
440  CODEC_LONG_NAME("Windows Media Audio 1"),
441  .p.type = AVMEDIA_TYPE_AUDIO,
442  .p.id = AV_CODEC_ID_WMAV1,
444  .priv_data_size = sizeof(WMACodecContext),
445  .init = encode_init,
447  .close = ff_wma_end,
448  .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
450  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
451 };
452 #endif
453 #if CONFIG_WMAV2_ENCODER
454 const FFCodec ff_wmav2_encoder = {
455  .p.name = "wmav2",
456  CODEC_LONG_NAME("Windows Media Audio 2"),
457  .p.type = AVMEDIA_TYPE_AUDIO,
458  .p.id = AV_CODEC_ID_WMAV2,
460  .priv_data_size = sizeof(WMACodecContext),
461  .init = encode_init,
463  .close = ff_wma_end,
464  .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
466  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
467 };
468 #endif
error
static void error(const char *err)
Definition: target_bsf_fuzzer.c:31
AVCodecContext::frame_size
int frame_size
Number of samples per channel in an audio frame.
Definition: avcodec.h:1092
AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:66
nb_coefs
static int nb_coefs(int length, int level, uint64_t sn)
Definition: af_afwtdn.c:513
ff_exp10
static av_always_inline double ff_exp10(double x)
Compute 10^x for floating point values.
Definition: ffmath.h:42
level
uint8_t level
Definition: svq3.c:204
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
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
AV_WL32
#define AV_WL32(p, v)
Definition: intreadwrite.h:424
align_put_bits
static void align_put_bits(PutBitContext *s)
Pad the bitstream with zeros up to the next byte boundary.
Definition: put_bits.h:420
coef_vlcs
static const CoefVLCTable coef_vlcs[6]
Definition: wmadata.h:1371
AVCodecContext::sample_rate
int sample_rate
samples per second
Definition: avcodec.h:1064
AVTXContext
Definition: tx_priv.h:235
init_put_bits
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
Definition: put_bits.h:62
apply_window_and_mdct
static int apply_window_and_mdct(AVCodecContext *avctx, const AVFrame *frame)
Definition: wmaenc.c:111
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:340
put_bits
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:222
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:452
AVPacket::data
uint8_t * data
Definition: packet.h:491
encode.h
b
#define b
Definition: input.c:41
put_bytes_count
static int put_bytes_count(const PutBitContext *s, int round_up)
Definition: put_bits.h:100
init_exp
static void init_exp(WMACodecContext *s, int ch, const int *exp_param)
Definition: wmaenc.c:141
FFCodec
Definition: codec_internal.h:127
AV_CODEC_ID_WMAV2
@ AV_CODEC_ID_WMAV2
Definition: codec_id.h:450
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:317
av_tx_init
av_cold int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type, int inv, int len, const void *scale, uint64_t flags)
Initialize a transform context with the given configuration (i)MDCTs with an odd length are currently...
Definition: tx.c:901
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:30
win
static float win(SuperEqualizerContext *s, float n, int N)
Definition: af_superequalizer.c:119
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
AVCodecContext::codec
const struct AVCodec * codec
Definition: avcodec.h:450
WMACoef
float WMACoef
type for decoded coefficients, int16_t would be enough for wma 1/2
Definition: wma.h:58
AVCodecContext::ch_layout
AVChannelLayout ch_layout
Audio channel layout.
Definition: avcodec.h:2107
encode_block
static int encode_block(WMACodecContext *s, float(*src_coefs)[BLOCK_MAX_SIZE], int total_gain)
Definition: wmaenc.c:191
AVCodecContext::initial_padding
int initial_padding
Audio only.
Definition: avcodec.h:1794
scale
static av_always_inline float scale(float x, float s)
Definition: vf_v360.c:1389
FF_CODEC_ENCODE_CB
#define FF_CODEC_ENCODE_CB(func)
Definition: codec_internal.h:315
WMACodecContext
Definition: wma.h:68
encode_init
static av_cold int encode_init(AVCodecContext *avctx)
Definition: wmaenc.c:34
mult
static int16_t mult(Float11 *f1, Float11 *f2)
Definition: g726.c:60
AV_CODEC_ID_WMAV1
@ AV_CODEC_ID_WMAV1
Definition: codec_id.h:449
avassert.h
lrint
#define lrint
Definition: tablegen.h:53
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
av_tx_fn
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.
Definition: tx.h:151
float
float
Definition: af_crystalizer.c:121
AVCodecContext::extradata_size
int extradata_size
Definition: avcodec.h:543
AV_TX_FLOAT_MDCT
@ AV_TX_FLOAT_MDCT
Standard MDCT with a sample data type of float, double or int32_t, respecively.
Definition: tx.h:68
s
#define s(width, name)
Definition: cbs_vp9.c:198
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:365
AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
Definition: codec.h:159
BLOCK_MAX_SIZE
#define BLOCK_MAX_SIZE
Definition: wma.h:36
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
channels
channels
Definition: aptx.h:31
isfinite
#define isfinite(x)
Definition: libm.h:359
wma.h
ff_wma_total_gain_to_bits
int ff_wma_total_gain_to_bits(int total_gain)
Definition: wma.c:352
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
ff_wmav1_encoder
const FFCodec ff_wmav1_encoder
run
uint8_t run
Definition: svq3.c:203
parse_exponents
static int parse_exponents(DBEContext *s, DBEChannel *c)
Definition: dolby_e.c:663
ff_samples_to_time_base
static av_always_inline int64_t ff_samples_to_time_base(const AVCodecContext *avctx, int64_t samples)
Rescale from sample rate to AVCodecContext.time_base.
Definition: encode.h:84
AVCodecContext::bit_rate
int64_t bit_rate
the average bitrate
Definition: avcodec.h:491
ff_wmav2_encoder
const FFCodec ff_wmav2_encoder
encode_superframe
static int encode_superframe(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Definition: wmaenc.c:376
exp
int8_t exp
Definition: eval.c:72
MAX_CODED_SUPERFRAME_SIZE
#define MAX_CODED_SUPERFRAME_SIZE
Definition: wma.h:46
ff_wma_end
int ff_wma_end(AVCodecContext *avctx)
Definition: wma.c:366
ff_aac_scalefactor_bits
const uint8_t ff_aac_scalefactor_bits[121]
Definition: aactab.c:111
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
AVPacket::size
int size
Definition: packet.h:492
codec_internal.h
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
ff_wma_init
av_cold int ff_wma_init(AVCodecContext *avctx, int flags2)
Definition: wma.c:78
AV_WL16
#define AV_WL16(p, v)
Definition: intreadwrite.h:410
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
fixed_exp
static int fixed_exp(int x)
Definition: aacsbr_fixed.c:110
attributes.h
MAX_CHANNELS
#define MAX_CHANNELS
Definition: aac.h:46
AVCodec::id
enum AVCodecID id
Definition: codec.h:201
av_assert2
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
Definition: avassert.h:67
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:420
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:484
code
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
Definition: filter_design.txt:178
put_bits_count
static int put_bits_count(PutBitContext *s)
Definition: put_bits.h:80
AVCodecContext::extradata
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:542
AVFrame::extended_data
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:401
av_assert1
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:56
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:254
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
len
int len
Definition: vorbis_enc_data.h:426
avcodec.h
ret
ret
Definition: filter_design.txt:187
encode_frame
static int encode_frame(WMACodecContext *s, float(*src_coefs)[BLOCK_MAX_SIZE], uint8_t *buf, int buf_size, int total_gain)
Definition: wmaenc.c:361
AVCodecContext::block_align
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs.
Definition: avcodec.h:1113
AVCodecContext
main external API structure.
Definition: avcodec.h:441
put_bits_ptr
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
Definition: put_bits.h:377
encode_exp_vlc
static void encode_exp_vlc(WMACodecContext *s, int ch, const int *exp_param)
Definition: wmaenc.c:163
ffmath.h
flush_put_bits
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
Definition: put_bits.h:143
AVPacket
This structure stores compressed data.
Definition: packet.h:468
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:468
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
ff_alloc_packet
int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and allocate data.
Definition: encode.c:61
ff_aac_scalefactor_code
const uint32_t ff_aac_scalefactor_code[121]
Definition: aactab.c:92