FFmpeg
vorbisenc.c
Go to the documentation of this file.
1 /*
2  * copyright (c) 2006 Oded Shimon <ods15@ods15.dyndns.org>
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /**
22  * @file
23  * Native Vorbis encoder.
24  * @author Oded Shimon <ods15@ods15.dyndns.org>
25  */
26 
27 #include <float.h>
28 #include "libavutil/float_dsp.h"
29 
30 #include "avcodec.h"
31 #include "encode.h"
32 #include "internal.h"
33 #include "fft.h"
34 #include "mathops.h"
35 #include "vorbis.h"
36 #include "vorbis_enc_data.h"
37 
38 #include "audio_frame_queue.h"
40 
41 #define BITSTREAM_WRITER_LE
42 #include "put_bits.h"
43 
44 #undef NDEBUG
45 #include <assert.h>
46 
47 typedef struct vorbis_enc_codebook {
48  int nentries;
49  uint8_t *lens;
50  uint32_t *codewords;
52  float min;
53  float delta;
54  int seq_p;
55  int lookup;
56  int *quantlist;
57  float *dimensions;
58  float *pow2;
60 
61 typedef struct vorbis_enc_floor_class {
62  int dim;
63  int subclass;
65  int *books;
67 
68 typedef struct vorbis_enc_floor {
71  int nclasses;
74  int rangebits;
75  int values;
78 
79 typedef struct vorbis_enc_residue {
80  int type;
81  int begin;
82  int end;
85  int classbook;
86  int8_t (*books)[8];
87  float (*maxes)[2];
89 
90 typedef struct vorbis_enc_mapping {
91  int submaps;
92  int *mux;
93  int *floor;
94  int *residue;
96  int *magnitude;
97  int *angle;
99 
100 typedef struct vorbis_enc_mode {
102  int mapping;
104 
105 typedef struct vorbis_enc_context {
106  int channels;
110  const float *win[2];
112  float *saved;
113  float *samples;
114  float *floor; // also used for tmp values for mdct
115  float *coeffs; // also used for residue after floor
116  float *scratch; // used for tmp values for psy model
117  float quality;
118 
121 
124 
125  int nfloors;
127 
130 
133 
134  int nmodes;
136 
137  int64_t next_pts;
138 
141 
142 #define MAX_CHANNELS 2
143 #define MAX_CODEBOOK_DIM 8
144 
145 #define MAX_FLOOR_CLASS_DIM 4
146 #define NUM_FLOOR_PARTITIONS 8
147 #define MAX_FLOOR_VALUES (MAX_FLOOR_CLASS_DIM*NUM_FLOOR_PARTITIONS+2)
148 
149 #define RESIDUE_SIZE 1600
150 #define RESIDUE_PART_SIZE 32
151 #define NUM_RESIDUE_PARTITIONS (RESIDUE_SIZE/RESIDUE_PART_SIZE)
152 
154  int entry)
155 {
156  av_assert2(entry >= 0);
157  av_assert2(entry < cb->nentries);
158  av_assert2(cb->lens[entry]);
159  if (put_bits_left(pb) < cb->lens[entry])
160  return AVERROR(EINVAL);
161  put_bits(pb, cb->lens[entry], cb->codewords[entry]);
162  return 0;
163 }
164 
165 static int cb_lookup_vals(int lookup, int dimensions, int entries)
166 {
167  if (lookup == 1)
168  return ff_vorbis_nth_root(entries, dimensions);
169  else if (lookup == 2)
170  return dimensions *entries;
171  return 0;
172 }
173 
175 {
176  int i;
177 
178  ff_vorbis_len2vlc(cb->lens, cb->codewords, cb->nentries);
179 
180  if (!cb->lookup) {
181  cb->pow2 = cb->dimensions = NULL;
182  } else {
183  int vals = cb_lookup_vals(cb->lookup, cb->ndimensions, cb->nentries);
184  cb->dimensions = av_malloc_array(cb->nentries, sizeof(float) * cb->ndimensions);
185  cb->pow2 = av_calloc(cb->nentries, sizeof(*cb->pow2));
186  if (!cb->dimensions || !cb->pow2)
187  return AVERROR(ENOMEM);
188  for (i = 0; i < cb->nentries; i++) {
189  float last = 0;
190  int j;
191  int div = 1;
192  for (j = 0; j < cb->ndimensions; j++) {
193  int off;
194  if (cb->lookup == 1)
195  off = (i / div) % vals; // lookup type 1
196  else
197  off = i * cb->ndimensions + j; // lookup type 2
198 
199  cb->dimensions[i * cb->ndimensions + j] = last + cb->min + cb->quantlist[off] * cb->delta;
200  if (cb->seq_p)
201  last = cb->dimensions[i * cb->ndimensions + j];
202  cb->pow2[i] += cb->dimensions[i * cb->ndimensions + j] * cb->dimensions[i * cb->ndimensions + j];
203  div *= vals;
204  }
205  cb->pow2[i] /= 2.0;
206  }
207  }
208  return 0;
209 }
210 
212 {
213  int i;
214  av_assert0(rc->type == 2);
215  rc->maxes = av_calloc(rc->classifications, sizeof(*rc->maxes));
216  if (!rc->maxes)
217  return AVERROR(ENOMEM);
218  for (i = 0; i < rc->classifications; i++) {
219  int j;
221  for (j = 0; j < 8; j++)
222  if (rc->books[i][j] != -1)
223  break;
224  if (j == 8) // zero
225  continue;
226  cb = &venc->codebooks[rc->books[i][j]];
227  assert(cb->ndimensions >= 2);
228  assert(cb->lookup);
229 
230  for (j = 0; j < cb->nentries; j++) {
231  float a;
232  if (!cb->lens[j])
233  continue;
234  a = fabs(cb->dimensions[j * cb->ndimensions]);
235  if (a > rc->maxes[i][0])
236  rc->maxes[i][0] = a;
237  a = fabs(cb->dimensions[j * cb->ndimensions + 1]);
238  if (a > rc->maxes[i][1])
239  rc->maxes[i][1] = a;
240  }
241  }
242  // small bias
243  for (i = 0; i < rc->classifications; i++) {
244  rc->maxes[i][0] += 0.8;
245  rc->maxes[i][1] += 0.8;
246  }
247  return 0;
248 }
249 
251 {
252  int ret = 0;
253 
255  if (!venc->fdsp)
256  return AVERROR(ENOMEM);
257 
258  // init windows
259  venc->win[0] = ff_vorbis_vwin[venc->log2_blocksize[0] - 6];
260  venc->win[1] = ff_vorbis_vwin[venc->log2_blocksize[1] - 6];
261 
262  if ((ret = ff_mdct_init(&venc->mdct[0], venc->log2_blocksize[0], 0, 1.0)) < 0)
263  return ret;
264  if ((ret = ff_mdct_init(&venc->mdct[1], venc->log2_blocksize[1], 0, 1.0)) < 0)
265  return ret;
266 
267  return 0;
268 }
269 
271  AVCodecContext *avctx)
272 {
274  vorbis_enc_residue *rc;
276  const uint8_t *clens, *quant;
277  int i, book, ret;
278 
279  venc->channels = avctx->channels;
280  venc->sample_rate = avctx->sample_rate;
281  venc->log2_blocksize[0] = venc->log2_blocksize[1] = 11;
282 
284  venc->codebooks = av_mallocz(sizeof(vorbis_enc_codebook) * venc->ncodebooks);
285  if (!venc->codebooks)
286  return AVERROR(ENOMEM);
287 
288  // codebook 0..14 - floor1 book, values 0..255
289  // codebook 15 residue masterbook
290  // codebook 16..29 residue
291  clens = codebooks;
293  for (book = 0; book < venc->ncodebooks; book++) {
294  vorbis_enc_codebook *cb = &venc->codebooks[book];
295  int vals;
296  cb->ndimensions = cvectors[book].dim;
297  cb->nentries = cvectors[book].real_len;
298  cb->min = cvectors[book].min;
299  cb->delta = cvectors[book].delta;
300  cb->lookup = cvectors[book].lookup;
301  cb->seq_p = 0;
302 
303  cb->lens = av_malloc_array(cb->nentries, sizeof(uint8_t));
304  cb->codewords = av_malloc_array(cb->nentries, sizeof(uint32_t));
305  if (!cb->lens || !cb->codewords)
306  return AVERROR(ENOMEM);
307  memcpy(cb->lens, clens, cvectors[book].len);
308  memset(cb->lens + cvectors[book].len, 0, cb->nentries - cvectors[book].len);
309  clens += cvectors[book].len;
310 
311  if (cb->lookup) {
312  vals = cb_lookup_vals(cb->lookup, cb->ndimensions, cb->nentries);
313  cb->quantlist = av_malloc_array(vals, sizeof(int));
314  if (!cb->quantlist)
315  return AVERROR(ENOMEM);
316  for (i = 0; i < vals; i++)
317  cb->quantlist[i] = *quant++;
318  } else {
319  cb->quantlist = NULL;
320  }
321  if ((ret = ready_codebook(cb)) < 0)
322  return ret;
323  }
324 
325  venc->nfloors = 1;
326  venc->floors = av_mallocz(sizeof(vorbis_enc_floor) * venc->nfloors);
327  if (!venc->floors)
328  return AVERROR(ENOMEM);
329 
330  // just 1 floor
331  fc = &venc->floors[0];
332  fc->partitions = NUM_FLOOR_PARTITIONS;
333  fc->partition_to_class = av_malloc(sizeof(int) * fc->partitions);
334  if (!fc->partition_to_class)
335  return AVERROR(ENOMEM);
336  fc->nclasses = 0;
337  for (i = 0; i < fc->partitions; i++) {
338  static const int a[] = {0, 1, 2, 2, 3, 3, 4, 4};
339  fc->partition_to_class[i] = a[i];
340  fc->nclasses = FFMAX(fc->nclasses, fc->partition_to_class[i]);
341  }
342  fc->nclasses++;
343  fc->classes = av_calloc(fc->nclasses, sizeof(vorbis_enc_floor_class));
344  if (!fc->classes)
345  return AVERROR(ENOMEM);
346  for (i = 0; i < fc->nclasses; i++) {
347  vorbis_enc_floor_class * c = &fc->classes[i];
348  int j, books;
349  c->dim = floor_classes[i].dim;
350  c->subclass = floor_classes[i].subclass;
351  c->masterbook = floor_classes[i].masterbook;
352  books = (1 << c->subclass);
353  c->books = av_malloc_array(books, sizeof(int));
354  if (!c->books)
355  return AVERROR(ENOMEM);
356  for (j = 0; j < books; j++)
357  c->books[j] = floor_classes[i].nbooks[j];
358  }
359  fc->multiplier = 2;
360  fc->rangebits = venc->log2_blocksize[1] - 1;
361 
362  fc->values = 2;
363  for (i = 0; i < fc->partitions; i++)
364  fc->values += fc->classes[fc->partition_to_class[i]].dim;
365 
366  fc->list = av_malloc_array(fc->values, sizeof(vorbis_floor1_entry));
367  if (!fc->list)
368  return AVERROR(ENOMEM);
369  fc->list[0].x = 0;
370  fc->list[1].x = 1 << fc->rangebits;
371  for (i = 2; i < fc->values; i++) {
372  static const int a[] = {
373  93, 23,372, 6, 46,186,750, 14, 33, 65,
374  130,260,556, 3, 10, 18, 28, 39, 55, 79,
375  111,158,220,312,464,650,850
376  };
377  fc->list[i].x = a[i - 2];
378  }
379  if (ff_vorbis_ready_floor1_list(avctx, fc->list, fc->values))
380  return AVERROR_BUG;
381 
382  venc->nresidues = 1;
383  venc->residues = av_mallocz(sizeof(vorbis_enc_residue) * venc->nresidues);
384  if (!venc->residues)
385  return AVERROR(ENOMEM);
386 
387  // single residue
388  rc = &venc->residues[0];
389  rc->type = 2;
390  rc->begin = 0;
391  rc->end = 1600;
392  rc->partition_size = 32;
393  rc->classifications = 10;
394  rc->classbook = 15;
395  rc->books = av_malloc(sizeof(*rc->books) * rc->classifications);
396  if (!rc->books)
397  return AVERROR(ENOMEM);
398  {
399  static const int8_t a[10][8] = {
400  { -1, -1, -1, -1, -1, -1, -1, -1, },
401  { -1, -1, 16, -1, -1, -1, -1, -1, },
402  { -1, -1, 17, -1, -1, -1, -1, -1, },
403  { -1, -1, 18, -1, -1, -1, -1, -1, },
404  { -1, -1, 19, -1, -1, -1, -1, -1, },
405  { -1, -1, 20, -1, -1, -1, -1, -1, },
406  { -1, -1, 21, -1, -1, -1, -1, -1, },
407  { 22, 23, -1, -1, -1, -1, -1, -1, },
408  { 24, 25, -1, -1, -1, -1, -1, -1, },
409  { 26, 27, 28, -1, -1, -1, -1, -1, },
410  };
411  memcpy(rc->books, a, sizeof a);
412  }
413  if ((ret = ready_residue(rc, venc)) < 0)
414  return ret;
415 
416  venc->nmappings = 1;
417  venc->mappings = av_mallocz(sizeof(vorbis_enc_mapping) * venc->nmappings);
418  if (!venc->mappings)
419  return AVERROR(ENOMEM);
420 
421  // single mapping
422  mc = &venc->mappings[0];
423  mc->submaps = 1;
424  mc->mux = av_malloc(sizeof(int) * venc->channels);
425  if (!mc->mux)
426  return AVERROR(ENOMEM);
427  for (i = 0; i < venc->channels; i++)
428  mc->mux[i] = 0;
429  mc->floor = av_malloc(sizeof(int) * mc->submaps);
430  mc->residue = av_malloc(sizeof(int) * mc->submaps);
431  if (!mc->floor || !mc->residue)
432  return AVERROR(ENOMEM);
433  for (i = 0; i < mc->submaps; i++) {
434  mc->floor[i] = 0;
435  mc->residue[i] = 0;
436  }
437  mc->coupling_steps = venc->channels == 2 ? 1 : 0;
438  mc->magnitude = av_malloc(sizeof(int) * mc->coupling_steps);
439  mc->angle = av_malloc(sizeof(int) * mc->coupling_steps);
440  if (!mc->magnitude || !mc->angle)
441  return AVERROR(ENOMEM);
442  if (mc->coupling_steps) {
443  mc->magnitude[0] = 0;
444  mc->angle[0] = 1;
445  }
446 
447  venc->nmodes = 2;
448  venc->modes = av_malloc(sizeof(vorbis_enc_mode) * venc->nmodes);
449  if (!venc->modes)
450  return AVERROR(ENOMEM);
451 
452  // Short block
453  venc->modes[0].blockflag = 0;
454  venc->modes[0].mapping = 0;
455  // Long block
456  venc->modes[1].blockflag = 1;
457  venc->modes[1].mapping = 0;
458 
459  venc->have_saved = 0;
460  venc->saved = av_malloc_array(sizeof(float) * venc->channels, (1 << venc->log2_blocksize[1]) / 2);
461  venc->samples = av_malloc_array(sizeof(float) * venc->channels, (1 << venc->log2_blocksize[1]));
462  venc->floor = av_malloc_array(sizeof(float) * venc->channels, (1 << venc->log2_blocksize[1]) / 2);
463  venc->coeffs = av_malloc_array(sizeof(float) * venc->channels, (1 << venc->log2_blocksize[1]) / 2);
464  venc->scratch = av_malloc_array(sizeof(float) * venc->channels, (1 << venc->log2_blocksize[1]));
465 
466  if (!venc->saved || !venc->samples || !venc->floor || !venc->coeffs || !venc->scratch)
467  return AVERROR(ENOMEM);
468 
469  if ((ret = dsp_init(avctx, venc)) < 0)
470  return ret;
471 
472  return 0;
473 }
474 
475 static void put_float(PutBitContext *pb, float f)
476 {
477  int exp, mant;
478  uint32_t res = 0;
479  mant = (int)ldexp(frexp(f, &exp), 20);
480  exp += 788 - 20;
481  if (mant < 0) {
482  res |= (1U << 31);
483  mant = -mant;
484  }
485  res |= mant | (exp << 21);
486  put_bits32(pb, res);
487 }
488 
490 {
491  int i;
492  int ordered = 0;
493 
494  put_bits(pb, 24, 0x564342); //magic
495  put_bits(pb, 16, cb->ndimensions);
496  put_bits(pb, 24, cb->nentries);
497 
498  for (i = 1; i < cb->nentries; i++)
499  if (cb->lens[i] < cb->lens[i-1])
500  break;
501  if (i == cb->nentries)
502  ordered = 1;
503 
504  put_bits(pb, 1, ordered);
505  if (ordered) {
506  int len = cb->lens[0];
507  put_bits(pb, 5, len - 1);
508  i = 0;
509  while (i < cb->nentries) {
510  int j;
511  for (j = 0; j+i < cb->nentries; j++)
512  if (cb->lens[j+i] != len)
513  break;
514  put_bits(pb, ilog(cb->nentries - i), j);
515  i += j;
516  len++;
517  }
518  } else {
519  int sparse = 0;
520  for (i = 0; i < cb->nentries; i++)
521  if (!cb->lens[i])
522  break;
523  if (i != cb->nentries)
524  sparse = 1;
525  put_bits(pb, 1, sparse);
526 
527  for (i = 0; i < cb->nentries; i++) {
528  if (sparse)
529  put_bits(pb, 1, !!cb->lens[i]);
530  if (cb->lens[i])
531  put_bits(pb, 5, cb->lens[i] - 1);
532  }
533  }
534 
535  put_bits(pb, 4, cb->lookup);
536  if (cb->lookup) {
537  int tmp = cb_lookup_vals(cb->lookup, cb->ndimensions, cb->nentries);
538  int bits = ilog(cb->quantlist[0]);
539 
540  for (i = 1; i < tmp; i++)
541  bits = FFMAX(bits, ilog(cb->quantlist[i]));
542 
543  put_float(pb, cb->min);
544  put_float(pb, cb->delta);
545 
546  put_bits(pb, 4, bits - 1);
547  put_bits(pb, 1, cb->seq_p);
548 
549  for (i = 0; i < tmp; i++)
550  put_bits(pb, bits, cb->quantlist[i]);
551  }
552 }
553 
555 {
556  int i;
557 
558  put_bits(pb, 16, 1); // type, only floor1 is supported
559 
560  put_bits(pb, 5, fc->partitions);
561 
562  for (i = 0; i < fc->partitions; i++)
563  put_bits(pb, 4, fc->partition_to_class[i]);
564 
565  for (i = 0; i < fc->nclasses; i++) {
566  int j, books;
567 
568  put_bits(pb, 3, fc->classes[i].dim - 1);
569  put_bits(pb, 2, fc->classes[i].subclass);
570 
571  if (fc->classes[i].subclass)
572  put_bits(pb, 8, fc->classes[i].masterbook);
573 
574  books = (1 << fc->classes[i].subclass);
575 
576  for (j = 0; j < books; j++)
577  put_bits(pb, 8, fc->classes[i].books[j] + 1);
578  }
579 
580  put_bits(pb, 2, fc->multiplier - 1);
581  put_bits(pb, 4, fc->rangebits);
582 
583  for (i = 2; i < fc->values; i++)
584  put_bits(pb, fc->rangebits, fc->list[i].x);
585 }
586 
588 {
589  int i;
590 
591  put_bits(pb, 16, rc->type);
592 
593  put_bits(pb, 24, rc->begin);
594  put_bits(pb, 24, rc->end);
595  put_bits(pb, 24, rc->partition_size - 1);
596  put_bits(pb, 6, rc->classifications - 1);
597  put_bits(pb, 8, rc->classbook);
598 
599  for (i = 0; i < rc->classifications; i++) {
600  int j, tmp = 0;
601  for (j = 0; j < 8; j++)
602  tmp |= (rc->books[i][j] != -1) << j;
603 
604  put_bits(pb, 3, tmp & 7);
605  put_bits(pb, 1, tmp > 7);
606 
607  if (tmp > 7)
608  put_bits(pb, 5, tmp >> 3);
609  }
610 
611  for (i = 0; i < rc->classifications; i++) {
612  int j;
613  for (j = 0; j < 8; j++)
614  if (rc->books[i][j] != -1)
615  put_bits(pb, 8, rc->books[i][j]);
616  }
617 }
618 
619 static int put_main_header(vorbis_enc_context *venc, uint8_t **out)
620 {
621  int i;
622  PutBitContext pb;
623  int len, hlens[3];
624  int buffer_len = 50000;
625  uint8_t *buffer = av_mallocz(buffer_len), *p = buffer;
626  if (!buffer)
627  return AVERROR(ENOMEM);
628 
629  // identification header
630  init_put_bits(&pb, p, buffer_len);
631  put_bits(&pb, 8, 1); //magic
632  for (i = 0; "vorbis"[i]; i++)
633  put_bits(&pb, 8, "vorbis"[i]);
634  put_bits32(&pb, 0); // version
635  put_bits(&pb, 8, venc->channels);
636  put_bits32(&pb, venc->sample_rate);
637  put_bits32(&pb, 0); // bitrate
638  put_bits32(&pb, 0); // bitrate
639  put_bits32(&pb, 0); // bitrate
640  put_bits(&pb, 4, venc->log2_blocksize[0]);
641  put_bits(&pb, 4, venc->log2_blocksize[1]);
642  put_bits(&pb, 1, 1); // framing
643 
644  flush_put_bits(&pb);
645  hlens[0] = put_bytes_output(&pb);
646  buffer_len -= hlens[0];
647  p += hlens[0];
648 
649  // comment header
650  init_put_bits(&pb, p, buffer_len);
651  put_bits(&pb, 8, 3); //magic
652  for (i = 0; "vorbis"[i]; i++)
653  put_bits(&pb, 8, "vorbis"[i]);
654  put_bits32(&pb, 0); // vendor length TODO
655  put_bits32(&pb, 0); // amount of comments
656  put_bits(&pb, 1, 1); // framing
657 
658  flush_put_bits(&pb);
659  hlens[1] = put_bytes_output(&pb);
660  buffer_len -= hlens[1];
661  p += hlens[1];
662 
663  // setup header
664  init_put_bits(&pb, p, buffer_len);
665  put_bits(&pb, 8, 5); //magic
666  for (i = 0; "vorbis"[i]; i++)
667  put_bits(&pb, 8, "vorbis"[i]);
668 
669  // codebooks
670  put_bits(&pb, 8, venc->ncodebooks - 1);
671  for (i = 0; i < venc->ncodebooks; i++)
672  put_codebook_header(&pb, &venc->codebooks[i]);
673 
674  // time domain, reserved, zero
675  put_bits(&pb, 6, 0);
676  put_bits(&pb, 16, 0);
677 
678  // floors
679  put_bits(&pb, 6, venc->nfloors - 1);
680  for (i = 0; i < venc->nfloors; i++)
681  put_floor_header(&pb, &venc->floors[i]);
682 
683  // residues
684  put_bits(&pb, 6, venc->nresidues - 1);
685  for (i = 0; i < venc->nresidues; i++)
686  put_residue_header(&pb, &venc->residues[i]);
687 
688  // mappings
689  put_bits(&pb, 6, venc->nmappings - 1);
690  for (i = 0; i < venc->nmappings; i++) {
691  vorbis_enc_mapping *mc = &venc->mappings[i];
692  int j;
693  put_bits(&pb, 16, 0); // mapping type
694 
695  put_bits(&pb, 1, mc->submaps > 1);
696  if (mc->submaps > 1)
697  put_bits(&pb, 4, mc->submaps - 1);
698 
699  put_bits(&pb, 1, !!mc->coupling_steps);
700  if (mc->coupling_steps) {
701  put_bits(&pb, 8, mc->coupling_steps - 1);
702  for (j = 0; j < mc->coupling_steps; j++) {
703  put_bits(&pb, ilog(venc->channels - 1), mc->magnitude[j]);
704  put_bits(&pb, ilog(venc->channels - 1), mc->angle[j]);
705  }
706  }
707 
708  put_bits(&pb, 2, 0); // reserved
709 
710  if (mc->submaps > 1)
711  for (j = 0; j < venc->channels; j++)
712  put_bits(&pb, 4, mc->mux[j]);
713 
714  for (j = 0; j < mc->submaps; j++) {
715  put_bits(&pb, 8, 0); // reserved time configuration
716  put_bits(&pb, 8, mc->floor[j]);
717  put_bits(&pb, 8, mc->residue[j]);
718  }
719  }
720 
721  // modes
722  put_bits(&pb, 6, venc->nmodes - 1);
723  for (i = 0; i < venc->nmodes; i++) {
724  put_bits(&pb, 1, venc->modes[i].blockflag);
725  put_bits(&pb, 16, 0); // reserved window type
726  put_bits(&pb, 16, 0); // reserved transform type
727  put_bits(&pb, 8, venc->modes[i].mapping);
728  }
729 
730  put_bits(&pb, 1, 1); // framing
731 
732  flush_put_bits(&pb);
733  hlens[2] = put_bytes_output(&pb);
734 
735  len = hlens[0] + hlens[1] + hlens[2];
736  p = *out = av_mallocz(64 + len + len/255);
737  if (!p)
738  return AVERROR(ENOMEM);
739 
740  *p++ = 2;
741  p += av_xiphlacing(p, hlens[0]);
742  p += av_xiphlacing(p, hlens[1]);
743  buffer_len = 0;
744  for (i = 0; i < 3; i++) {
745  memcpy(p, buffer + buffer_len, hlens[i]);
746  p += hlens[i];
747  buffer_len += hlens[i];
748  }
749 
750  av_freep(&buffer);
751  return p - *out;
752 }
753 
754 static float get_floor_average(vorbis_enc_floor * fc, float *coeffs, int i)
755 {
756  int begin = fc->list[fc->list[FFMAX(i-1, 0)].sort].x;
757  int end = fc->list[fc->list[FFMIN(i+1, fc->values - 1)].sort].x;
758  int j;
759  float average = 0;
760 
761  for (j = begin; j < end; j++)
762  average += fabs(coeffs[j]);
763  return average / (end - begin);
764 }
765 
767  float *coeffs, uint16_t *posts, int samples)
768 {
769  int range = 255 / fc->multiplier + 1;
770  int i;
771  float tot_average = 0.0;
772  float averages[MAX_FLOOR_VALUES];
773  for (i = 0; i < fc->values; i++) {
774  averages[i] = get_floor_average(fc, coeffs, i);
775  tot_average += averages[i];
776  }
777  tot_average /= fc->values;
778  tot_average /= venc->quality;
779 
780  for (i = 0; i < fc->values; i++) {
781  int position = fc->list[fc->list[i].sort].x;
782  float average = averages[i];
783  int j;
784 
785  average = sqrt(tot_average * average) * pow(1.25f, position*0.005f); // MAGIC!
786  for (j = 0; j < range - 1; j++)
787  if (ff_vorbis_floor1_inverse_db_table[j * fc->multiplier] > average)
788  break;
789  posts[fc->list[i].sort] = j;
790  }
791 }
792 
793 static int render_point(int x0, int y0, int x1, int y1, int x)
794 {
795  return y0 + (x - x0) * (y1 - y0) / (x1 - x0);
796 }
797 
799  PutBitContext *pb, uint16_t *posts,
800  float *floor, int samples)
801 {
802  int range = 255 / fc->multiplier + 1;
803  int coded[MAX_FLOOR_VALUES]; // first 2 values are unused
804  int i, counter;
805 
806  if (put_bits_left(pb) < 1 + 2 * ilog(range - 1))
807  return AVERROR(EINVAL);
808  put_bits(pb, 1, 1); // non zero
809  put_bits(pb, ilog(range - 1), posts[0]);
810  put_bits(pb, ilog(range - 1), posts[1]);
811  coded[0] = coded[1] = 1;
812 
813  for (i = 2; i < fc->values; i++) {
814  int predicted = render_point(fc->list[fc->list[i].low].x,
815  posts[fc->list[i].low],
816  fc->list[fc->list[i].high].x,
817  posts[fc->list[i].high],
818  fc->list[i].x);
819  int highroom = range - predicted;
820  int lowroom = predicted;
821  int room = FFMIN(highroom, lowroom);
822  if (predicted == posts[i]) {
823  coded[i] = 0; // must be used later as flag!
824  continue;
825  } else {
826  if (!coded[fc->list[i].low ])
827  coded[fc->list[i].low ] = -1;
828  if (!coded[fc->list[i].high])
829  coded[fc->list[i].high] = -1;
830  }
831  if (posts[i] > predicted) {
832  if (posts[i] - predicted > room)
833  coded[i] = posts[i] - predicted + lowroom;
834  else
835  coded[i] = (posts[i] - predicted) << 1;
836  } else {
837  if (predicted - posts[i] > room)
838  coded[i] = predicted - posts[i] + highroom - 1;
839  else
840  coded[i] = ((predicted - posts[i]) << 1) - 1;
841  }
842  }
843 
844  counter = 2;
845  for (i = 0; i < fc->partitions; i++) {
846  vorbis_enc_floor_class * c = &fc->classes[fc->partition_to_class[i]];
847  int k, cval = 0, csub = 1<<c->subclass;
848  if (c->subclass) {
849  vorbis_enc_codebook * book = &venc->codebooks[c->masterbook];
850  int cshift = 0;
851  for (k = 0; k < c->dim; k++) {
852  int l;
853  for (l = 0; l < csub; l++) {
854  int maxval = 1;
855  if (c->books[l] != -1)
856  maxval = venc->codebooks[c->books[l]].nentries;
857  // coded could be -1, but this still works, cause that is 0
858  if (coded[counter + k] < maxval)
859  break;
860  }
861  assert(l != csub);
862  cval |= l << cshift;
863  cshift += c->subclass;
864  }
865  if (put_codeword(pb, book, cval))
866  return AVERROR(EINVAL);
867  }
868  for (k = 0; k < c->dim; k++) {
869  int book = c->books[cval & (csub-1)];
870  int entry = coded[counter++];
871  cval >>= c->subclass;
872  if (book == -1)
873  continue;
874  if (entry == -1)
875  entry = 0;
876  if (put_codeword(pb, &venc->codebooks[book], entry))
877  return AVERROR(EINVAL);
878  }
879  }
880 
881  ff_vorbis_floor1_render_list(fc->list, fc->values, posts, coded,
882  fc->multiplier, floor, samples);
883 
884  return 0;
885 }
886 
888  float *num)
889 {
890  int i, entry = -1;
891  float distance = FLT_MAX;
892  assert(book->dimensions);
893  for (i = 0; i < book->nentries; i++) {
894  float * vec = book->dimensions + i * book->ndimensions, d = book->pow2[i];
895  int j;
896  if (!book->lens[i])
897  continue;
898  for (j = 0; j < book->ndimensions; j++)
899  d -= vec[j] * num[j];
900  if (distance > d) {
901  entry = i;
902  distance = d;
903  }
904  }
905  if (put_codeword(pb, book, entry))
906  return NULL;
907  return &book->dimensions[entry * book->ndimensions];
908 }
909 
911  PutBitContext *pb, float *coeffs, int samples,
912  int real_ch)
913 {
914  int pass, i, j, p, k;
915  int psize = rc->partition_size;
916  int partitions = (rc->end - rc->begin) / psize;
917  int channels = (rc->type == 2) ? 1 : real_ch;
918  int classes[MAX_CHANNELS][NUM_RESIDUE_PARTITIONS];
919  int classwords = venc->codebooks[rc->classbook].ndimensions;
920 
921  av_assert0(rc->type == 2);
922  av_assert0(real_ch == 2);
923  for (p = 0; p < partitions; p++) {
924  float max1 = 0.0, max2 = 0.0;
925  int s = rc->begin + p * psize;
926  for (k = s; k < s + psize; k += 2) {
927  max1 = FFMAX(max1, fabs(coeffs[ k / real_ch]));
928  max2 = FFMAX(max2, fabs(coeffs[samples + k / real_ch]));
929  }
930 
931  for (i = 0; i < rc->classifications - 1; i++)
932  if (max1 < rc->maxes[i][0] && max2 < rc->maxes[i][1])
933  break;
934  classes[0][p] = i;
935  }
936 
937  for (pass = 0; pass < 8; pass++) {
938  p = 0;
939  while (p < partitions) {
940  if (pass == 0)
941  for (j = 0; j < channels; j++) {
942  vorbis_enc_codebook * book = &venc->codebooks[rc->classbook];
943  int entry = 0;
944  for (i = 0; i < classwords; i++) {
945  entry *= rc->classifications;
946  entry += classes[j][p + i];
947  }
948  if (put_codeword(pb, book, entry))
949  return AVERROR(EINVAL);
950  }
951  for (i = 0; i < classwords && p < partitions; i++, p++) {
952  for (j = 0; j < channels; j++) {
953  int nbook = rc->books[classes[j][p]][pass];
954  vorbis_enc_codebook * book = &venc->codebooks[nbook];
955  float *buf = coeffs + samples*j + rc->begin + p*psize;
956  if (nbook == -1)
957  continue;
958 
959  assert(rc->type == 0 || rc->type == 2);
960  assert(!(psize % book->ndimensions));
961 
962  if (rc->type == 0) {
963  for (k = 0; k < psize; k += book->ndimensions) {
964  int l;
965  float *a = put_vector(book, pb, &buf[k]);
966  if (!a)
967  return AVERROR(EINVAL);
968  for (l = 0; l < book->ndimensions; l++)
969  buf[k + l] -= a[l];
970  }
971  } else {
972  int s = rc->begin + p * psize, a1, b1;
973  a1 = (s % real_ch) * samples;
974  b1 = s / real_ch;
975  s = real_ch * samples;
976  for (k = 0; k < psize; k += book->ndimensions) {
977  int dim, a2 = a1, b2 = b1;
978  float vec[MAX_CODEBOOK_DIM], *pv = vec;
979  for (dim = book->ndimensions; dim--; ) {
980  *pv++ = coeffs[a2 + b2];
981  if ((a2 += samples) == s) {
982  a2 = 0;
983  b2++;
984  }
985  }
986  pv = put_vector(book, pb, vec);
987  if (!pv)
988  return AVERROR(EINVAL);
989  for (dim = book->ndimensions; dim--; ) {
990  coeffs[a1 + b1] -= *pv++;
991  if ((a1 += samples) == s) {
992  a1 = 0;
993  b1++;
994  }
995  }
996  }
997  }
998  }
999  }
1000  }
1001  }
1002  return 0;
1003 }
1004 
1006 {
1007  int channel;
1008  const float * win = venc->win[1];
1009  int window_len = 1 << (venc->log2_blocksize[1] - 1);
1010  float n = (float)(1 << venc->log2_blocksize[1]) / 4.0;
1011  AVFloatDSPContext *fdsp = venc->fdsp;
1012 
1013  for (channel = 0; channel < venc->channels; channel++) {
1014  float *offset = venc->samples + channel * window_len * 2;
1015 
1016  fdsp->vector_fmul(offset, offset, win, window_len);
1017  fdsp->vector_fmul_scalar(offset, offset, 1/n, window_len);
1018 
1019  offset += window_len;
1020 
1021  fdsp->vector_fmul_reverse(offset, offset, win, window_len);
1022  fdsp->vector_fmul_scalar(offset, offset, 1/n, window_len);
1023 
1024  venc->mdct[1].mdct_calc(&venc->mdct[1], venc->coeffs + channel * window_len,
1025  venc->samples + channel * window_len * 2);
1026  }
1027  return 1;
1028 }
1029 
1030 /* Used for padding the last encoded packet */
1032 {
1033  AVFrame *f = av_frame_alloc();
1034  int ch;
1035 
1036  if (!f)
1037  return NULL;
1038 
1039  f->format = avctx->sample_fmt;
1040  f->nb_samples = avctx->frame_size;
1041  f->channel_layout = avctx->channel_layout;
1042 
1043  if (av_frame_get_buffer(f, 4)) {
1044  av_frame_free(&f);
1045  return NULL;
1046  }
1047 
1048  for (ch = 0; ch < channels; ch++) {
1049  size_t bps = av_get_bytes_per_sample(f->format);
1050  memset(f->extended_data[ch], 0, bps * f->nb_samples);
1051  }
1052  return f;
1053 }
1054 
1055 /* Set up audio samples for psy analysis and window/mdct */
1056 static void move_audio(vorbis_enc_context *venc, int sf_size)
1057 {
1058  AVFrame *cur = NULL;
1059  int frame_size = 1 << (venc->log2_blocksize[1] - 1);
1060  int subframes = frame_size / sf_size;
1061  int sf, ch;
1062 
1063  /* Copy samples from last frame into current frame */
1064  if (venc->have_saved)
1065  for (ch = 0; ch < venc->channels; ch++)
1066  memcpy(venc->samples + 2 * ch * frame_size,
1067  venc->saved + ch * frame_size, sizeof(float) * frame_size);
1068  else
1069  for (ch = 0; ch < venc->channels; ch++)
1070  memset(venc->samples + 2 * ch * frame_size, 0, sizeof(float) * frame_size);
1071 
1072  for (sf = 0; sf < subframes; sf++) {
1073  cur = ff_bufqueue_get(&venc->bufqueue);
1074 
1075  for (ch = 0; ch < venc->channels; ch++) {
1076  float *offset = venc->samples + 2 * ch * frame_size + frame_size;
1077  float *save = venc->saved + ch * frame_size;
1078  const float *input = (float *) cur->extended_data[ch];
1079  const size_t len = cur->nb_samples * sizeof(float);
1080 
1081  memcpy(offset + sf*sf_size, input, len);
1082  memcpy(save + sf*sf_size, input, len); // Move samples for next frame
1083  }
1084  av_frame_free(&cur);
1085  }
1086  venc->have_saved = 1;
1087  memcpy(venc->scratch, venc->samples, 2 * venc->channels * frame_size);
1088 }
1089 
1090 static int vorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
1091  const AVFrame *frame, int *got_packet_ptr)
1092 {
1093  vorbis_enc_context *venc = avctx->priv_data;
1094  int i, ret, need_more;
1095  int frame_size = 1 << (venc->log2_blocksize[1] - 1);
1097  vorbis_enc_mapping *mapping;
1098  PutBitContext pb;
1099 
1100  if (frame) {
1101  AVFrame *clone;
1102  if ((ret = ff_af_queue_add(&venc->afq, frame)) < 0)
1103  return ret;
1104  clone = av_frame_clone(frame);
1105  if (!clone)
1106  return AVERROR(ENOMEM);
1107  ff_bufqueue_add(avctx, &venc->bufqueue, clone);
1108  } else
1109  if (!venc->afq.remaining_samples)
1110  return 0;
1111 
1112  need_more = venc->bufqueue.available * avctx->frame_size < frame_size;
1113  need_more = frame && need_more;
1114  if (need_more)
1115  return 0;
1116 
1117  /* Pad the bufqueue with empty frames for encoding the last packet. */
1118  if (!frame) {
1119  if (venc->bufqueue.available * avctx->frame_size < frame_size) {
1120  int frames_needed = (frame_size/avctx->frame_size) - venc->bufqueue.available;
1121  int i;
1122 
1123  for (i = 0; i < frames_needed; i++) {
1124  AVFrame *empty = spawn_empty_frame(avctx, venc->channels);
1125  if (!empty)
1126  return AVERROR(ENOMEM);
1127 
1128  ff_bufqueue_add(avctx, &venc->bufqueue, empty);
1129  }
1130  }
1131  }
1132 
1133  move_audio(venc, avctx->frame_size);
1134 
1135  if (!apply_window_and_mdct(venc))
1136  return 0;
1137 
1138  if ((ret = ff_alloc_packet(avctx, avpkt, 8192)) < 0)
1139  return ret;
1140 
1141  init_put_bits(&pb, avpkt->data, avpkt->size);
1142 
1143  put_bits(&pb, 1, 0); // magic bit
1144 
1145  put_bits(&pb, ilog(venc->nmodes - 1), 1); // Mode for current frame
1146 
1147  mode = &venc->modes[1];
1148  mapping = &venc->mappings[mode->mapping];
1149  if (mode->blockflag) {
1150  put_bits(&pb, 1, 1); // Previous windowflag
1151  put_bits(&pb, 1, 1); // Next windowflag
1152  }
1153 
1154  for (i = 0; i < venc->channels; i++) {
1155  vorbis_enc_floor *fc = &venc->floors[mapping->floor[mapping->mux[i]]];
1156  uint16_t posts[MAX_FLOOR_VALUES];
1157  floor_fit(venc, fc, &venc->coeffs[i * frame_size], posts, frame_size);
1158  if (floor_encode(venc, fc, &pb, posts, &venc->floor[i * frame_size], frame_size)) {
1159  av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n");
1160  return AVERROR(EINVAL);
1161  }
1162  }
1163 
1164  for (i = 0; i < venc->channels * frame_size; i++)
1165  venc->coeffs[i] /= venc->floor[i];
1166 
1167  for (i = 0; i < mapping->coupling_steps; i++) {
1168  float *mag = venc->coeffs + mapping->magnitude[i] * frame_size;
1169  float *ang = venc->coeffs + mapping->angle[i] * frame_size;
1170  int j;
1171  for (j = 0; j < frame_size; j++) {
1172  float a = ang[j];
1173  ang[j] -= mag[j];
1174  if (mag[j] > 0)
1175  ang[j] = -ang[j];
1176  if (ang[j] < 0)
1177  mag[j] = a;
1178  }
1179  }
1180 
1181  if (residue_encode(venc, &venc->residues[mapping->residue[mapping->mux[0]]],
1182  &pb, venc->coeffs, frame_size, venc->channels)) {
1183  av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n");
1184  return AVERROR(EINVAL);
1185  }
1186 
1187  flush_put_bits(&pb);
1188  avpkt->size = put_bytes_output(&pb);
1189 
1190  ff_af_queue_remove(&venc->afq, frame_size, &avpkt->pts, &avpkt->duration);
1191 
1192  if (frame_size > avpkt->duration) {
1193  uint8_t *side = av_packet_new_side_data(avpkt, AV_PKT_DATA_SKIP_SAMPLES, 10);
1194  if (!side)
1195  return AVERROR(ENOMEM);
1196  AV_WL32(&side[4], frame_size - avpkt->duration);
1197  }
1198 
1199  *got_packet_ptr = 1;
1200  return 0;
1201 }
1202 
1203 
1205 {
1206  vorbis_enc_context *venc = avctx->priv_data;
1207  int i;
1208 
1209  if (venc->codebooks)
1210  for (i = 0; i < venc->ncodebooks; i++) {
1211  av_freep(&venc->codebooks[i].lens);
1212  av_freep(&venc->codebooks[i].codewords);
1213  av_freep(&venc->codebooks[i].quantlist);
1214  av_freep(&venc->codebooks[i].dimensions);
1215  av_freep(&venc->codebooks[i].pow2);
1216  }
1217  av_freep(&venc->codebooks);
1218 
1219  if (venc->floors)
1220  for (i = 0; i < venc->nfloors; i++) {
1221  int j;
1222  if (venc->floors[i].classes)
1223  for (j = 0; j < venc->floors[i].nclasses; j++)
1224  av_freep(&venc->floors[i].classes[j].books);
1225  av_freep(&venc->floors[i].classes);
1227  av_freep(&venc->floors[i].list);
1228  }
1229  av_freep(&venc->floors);
1230 
1231  if (venc->residues)
1232  for (i = 0; i < venc->nresidues; i++) {
1233  av_freep(&venc->residues[i].books);
1234  av_freep(&venc->residues[i].maxes);
1235  }
1236  av_freep(&venc->residues);
1237 
1238  if (venc->mappings)
1239  for (i = 0; i < venc->nmappings; i++) {
1240  av_freep(&venc->mappings[i].mux);
1241  av_freep(&venc->mappings[i].floor);
1242  av_freep(&venc->mappings[i].residue);
1243  av_freep(&venc->mappings[i].magnitude);
1244  av_freep(&venc->mappings[i].angle);
1245  }
1246  av_freep(&venc->mappings);
1247 
1248  av_freep(&venc->modes);
1249 
1250  av_freep(&venc->saved);
1251  av_freep(&venc->samples);
1252  av_freep(&venc->floor);
1253  av_freep(&venc->coeffs);
1254  av_freep(&venc->scratch);
1255  av_freep(&venc->fdsp);
1256 
1257  ff_mdct_end(&venc->mdct[0]);
1258  ff_mdct_end(&venc->mdct[1]);
1259  ff_af_queue_close(&venc->afq);
1261 
1262  return 0 ;
1263 }
1264 
1266 {
1267  vorbis_enc_context *venc = avctx->priv_data;
1268  int ret;
1269 
1270  if (avctx->channels != 2) {
1271  av_log(avctx, AV_LOG_ERROR, "Current FFmpeg Vorbis encoder only supports 2 channels.\n");
1272  return -1;
1273  }
1274 
1275  if ((ret = create_vorbis_context(venc, avctx)) < 0)
1276  goto error;
1277 
1278  avctx->bit_rate = 0;
1279  if (avctx->flags & AV_CODEC_FLAG_QSCALE)
1280  venc->quality = avctx->global_quality / (float)FF_QP2LAMBDA;
1281  else
1282  venc->quality = 8;
1283  venc->quality *= venc->quality;
1284 
1285  if ((ret = put_main_header(venc, (uint8_t**)&avctx->extradata)) < 0)
1286  goto error;
1287  avctx->extradata_size = ret;
1288 
1289  avctx->frame_size = 64;
1290  avctx->initial_padding = 1 << (venc->log2_blocksize[1] - 1);
1291 
1292  ff_af_queue_init(avctx, &venc->afq);
1293 
1294  return 0;
1295 error:
1296  vorbis_encode_close(avctx);
1297  return ret;
1298 }
1299 
1301  .name = "vorbis",
1302  .long_name = NULL_IF_CONFIG_SMALL("Vorbis"),
1303  .type = AVMEDIA_TYPE_AUDIO,
1304  .id = AV_CODEC_ID_VORBIS,
1305  .priv_data_size = sizeof(vorbis_enc_context),
1307  .encode2 = vorbis_encode_frame,
1308  .close = vorbis_encode_close,
1310  .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP,
1312  .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
1313 };
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:1012
put_codebook_header
static void put_codebook_header(PutBitContext *pb, vorbis_enc_codebook *cb)
Definition: vorbisenc.c:489
AVCodec
AVCodec.
Definition: codec.h:202
AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:69
FF_CODEC_CAP_INIT_THREADSAFE
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Definition: internal.h:42
floor_classes
static const struct @162 floor_classes[]
vorbis_enc_codebook
Definition: vorbisenc.c:47
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
put_bits32
static void av_unused put_bits32(PutBitContext *s, uint32_t value)
Write exactly 32 bits into a bitstream.
Definition: put_bits.h:290
AV_WL32
#define AV_WL32(p, v)
Definition: intreadwrite.h:426
AVCodecContext::channel_layout
uint64_t channel_layout
Audio channel layout.
Definition: avcodec.h:1043
ff_af_queue_remove
void ff_af_queue_remove(AudioFrameQueue *afq, int nb_samples, int64_t *pts, int64_t *duration)
Remove frame(s) from the queue.
Definition: audio_frame_queue.c:75
out
FILE * out
Definition: movenc.c:54
put_residue_header
static void put_residue_header(PutBitContext *pb, vorbis_enc_residue *rc)
Definition: vorbisenc.c:587
av_frame_get_buffer
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
Definition: frame.c:243
put_bytes_output
static int put_bytes_output(const PutBitContext *s)
Definition: put_bits.h:88
AVCodecContext::sample_rate
int sample_rate
samples per second
Definition: avcodec.h:992
cb
static double cb(void *priv, double x, double y)
Definition: vf_geq.c:215
ff_af_queue_close
void ff_af_queue_close(AudioFrameQueue *afq)
Close AudioFrameQueue.
Definition: audio_frame_queue.c:36
vorbis_encode_init
static av_cold int vorbis_encode_init(AVCodecContext *avctx)
Definition: vorbisenc.c:1265
sample_fmts
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:948
AV_CODEC_FLAG_QSCALE
#define AV_CODEC_FLAG_QSCALE
Use fixed qscale.
Definition: avcodec.h:210
vorbis_enc_floor::multiplier
int multiplier
Definition: vorbisenc.c:73
init_put_bits
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
Definition: put_bits.h:61
AVFloatDSPContext::vector_fmul_reverse
void(* vector_fmul_reverse)(float *dst, const float *src0, const float *src1, int len)
Calculate the entry wise product of two vectors of floats, and store the result in a vector of floats...
Definition: float_dsp.h:154
ff_af_queue_init
av_cold void ff_af_queue_init(AVCodecContext *avctx, AudioFrameQueue *afq)
Initialize AudioFrameQueue.
Definition: audio_frame_queue.c:28
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:109
FFTContext::mdct_calc
void(* mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input)
Definition: fft.h:96
vorbis_enc_codebook::pow2
float * pow2
Definition: vorbisenc.c:58
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:317
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:26
put_bits
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:220
ff_vorbis_vwin
const float *const ff_vorbis_vwin[8]
Definition: vorbis_data.c:2180
vorbis_enc_context::channels
int channels
Definition: vorbisenc.c:106
internal.h
AVPacket::data
uint8_t * data
Definition: packet.h:373
encode.h
vorbis_enc_codebook::lens
uint8_t * lens
Definition: vorbisenc.c:49
vorbis_enc_mapping::magnitude
int * magnitude
Definition: vorbisenc.c:96
codebooks
static const uint8_t codebooks[]
Definition: vorbis_enc_data.h:26
vorbis_enc_context::quality
float quality
Definition: vorbisenc.c:117
vorbis_enc_mode
Definition: vorbisenc.c:100
vorbis_enc_residue
Definition: vorbisenc.c:79
ff_mdct_init
#define ff_mdct_init
Definition: fft.h:153
vorbis_enc_floor_class
Definition: vorbisenc.c:61
vorbis_enc_context::have_saved
int have_saved
Definition: vorbisenc.c:111
vorbis_enc_mapping::angle
int * angle
Definition: vorbisenc.c:97
float.h
vorbis_enc_codebook::quantlist
int * quantlist
Definition: vorbisenc.c:56
fc
#define fc(width, name, range_min, range_max)
Definition: cbs_av1.c:551
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:391
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
NUM_FLOOR_PARTITIONS
#define NUM_FLOOR_PARTITIONS
Definition: vorbisenc.c:146
ff_vorbis_encoder
const AVCodec ff_vorbis_encoder
Definition: vorbisenc.c:1300
put_floor_header
static void put_floor_header(PutBitContext *pb, vorbis_enc_floor *fc)
Definition: vorbisenc.c:554
vorbis_enc_context::sample_rate
int sample_rate
Definition: vorbisenc.c:107
vorbis_enc_codebook::dimensions
float * dimensions
Definition: vorbisenc.c:57
ff_vorbis_nth_root
unsigned int ff_vorbis_nth_root(unsigned int x, unsigned int n)
Definition: vorbis.c:38
ff_bufqueue_get
static AVFrame * ff_bufqueue_get(struct FFBufQueue *queue)
Get the first buffer from the queue and remove it.
Definition: bufferqueue.h:98
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
vorbis_encode_close
static av_cold int vorbis_encode_close(AVCodecContext *avctx)
Definition: vorbisenc.c:1204
vorbis_enc_mapping::floor
int * floor
Definition: vorbisenc.c:93
vorbis_enc_floor_class::masterbook
int masterbook
Definition: vorbisenc.c:64
win
static float win(SuperEqualizerContext *s, float n, int N)
Definition: af_superequalizer.c:119
init
static int init
Definition: av_tx.c:47
vorbis_enc_floor::list
vorbis_floor1_entry * list
Definition: vorbisenc.c:76
put_vector
static float * put_vector(vorbis_enc_codebook *book, PutBitContext *pb, float *num)
Definition: vorbisenc.c:887
b1
static double b1(void *priv, double x, double y)
Definition: vf_xfade.c:1703
U
#define U(x)
Definition: vp56_arith.h:37
spawn_empty_frame
static AVFrame * spawn_empty_frame(AVCodecContext *avctx, int channels)
Definition: vorbisenc.c:1031
vorbis_enc_context::ncodebooks
int ncodebooks
Definition: vorbisenc.c:122
audio_frame_queue.h
ff_vorbis_floor1_render_list
void ff_vorbis_floor1_render_list(vorbis_floor1_entry *list, int values, uint16_t *y_list, int *flag, int multiplier, float *out, int samples)
Definition: vorbis.c:196
vorbis_enc_floor::partition_to_class
int * partition_to_class
Definition: vorbisenc.c:70
AVCodecContext::initial_padding
int initial_padding
Audio only.
Definition: avcodec.h:1701
vorbis_enc_context::afq
AudioFrameQueue afq
Definition: vorbisenc.c:119
put_bits_left
static int put_bits_left(PutBitContext *s)
Definition: put_bits.h:124
AVCodecContext::flags
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:463
vorbis_enc_floor_class::dim
int dim
Definition: vorbisenc.c:62
vorbis_enc_residue::maxes
float(* maxes)[2]
Definition: vorbisenc.c:87
vorbis_enc_context::mdct
FFTContext mdct[2]
Definition: vorbisenc.c:109
ff_af_queue_add
int ff_af_queue_add(AudioFrameQueue *afq, const AVFrame *f)
Add a frame to the queue.
Definition: audio_frame_queue.c:44
quant
static int quant(float coef, const float Q, const float rounding)
Quantize one coefficient.
Definition: aacenc_utils.h:59
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:97
a1
#define a1
Definition: regdef.h:47
vorbis_enc_context::coeffs
float * coeffs
Definition: vorbisenc.c:115
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
put_float
static void put_float(PutBitContext *pb, float f)
Definition: vorbisenc.c:475
AV_CODEC_CAP_EXPERIMENTAL
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
Definition: codec.h:105
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_cold
#define av_cold
Definition: attributes.h:90
vorbis_enc_context::saved
float * saved
Definition: vorbisenc.c:112
vorbis_floor1_entry
Definition: vorbis.h:31
AVCodecContext::extradata_size
int extradata_size
Definition: avcodec.h:485
vorbis_enc_residue::classbook
int classbook
Definition: vorbisenc.c:85
s
#define s(width, name)
Definition: cbs_vp9.c:257
AVCodecContext::global_quality
int global_quality
Global quality for codecs which cannot change it per frame.
Definition: avcodec.h:449
put_main_header
static int put_main_header(vorbis_enc_context *venc, uint8_t **out)
Definition: vorbisenc.c:619
floor
static __device__ float floor(float a)
Definition: cuda_runtime.h:173
dsp_init
static av_cold int dsp_init(AVCodecContext *avctx, vorbis_enc_context *venc)
Definition: vorbisenc.c:250
frame_size
int frame_size
Definition: mxfenc.c:2199
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
vorbis_encode_frame
static int vorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Definition: vorbisenc.c:1090
AudioFrameQueue::remaining_samples
int remaining_samples
Definition: audio_frame_queue.h:35
bits
uint8_t bits
Definition: vp3data.h:141
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
AudioFrameQueue
Definition: audio_frame_queue.h:32
ff_vorbis_len2vlc
int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num)
Definition: vorbis.c:56
vorbis_enc_context::residues
vorbis_enc_residue * residues
Definition: vorbisenc.c:129
vorbis_enc_floor::classes
vorbis_enc_floor_class * classes
Definition: vorbisenc.c:72
channels
channels
Definition: aptx.h:33
av_frame_clone
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:422
vorbis_enc_mapping
Definition: vorbisenc.c:90
vorbis_enc_floor_class::subclass
int subclass
Definition: vorbisenc.c:63
vorbis_enc_residue::begin
int begin
Definition: vorbisenc.c:81
vorbis_enc_residue::end
int end
Definition: vorbisenc.c:82
vorbis_enc_context::nfloors
int nfloors
Definition: vorbisenc.c:125
f
#define f(width, name)
Definition: cbs_vp9.c:255
pass
#define pass
Definition: fft_template.c:601
PutBitContext
Definition: put_bits.h:49
get_floor_average
static float get_floor_average(vorbis_enc_floor *fc, float *coeffs, int i)
Definition: vorbisenc.c:754
fabs
static __device__ float fabs(float a)
Definition: cuda_runtime.h:182
vorbis_enc_codebook::codewords
uint32_t * codewords
Definition: vorbisenc.c:50
NULL
#define NULL
Definition: coverity.c:32
residue_encode
static int residue_encode(vorbis_enc_context *venc, vorbis_enc_residue *rc, PutBitContext *pb, float *coeffs, int samples, int real_ch)
Definition: vorbisenc.c:910
AVFloatDSPContext::vector_fmul_scalar
void(* vector_fmul_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float.
Definition: float_dsp.h:85
vorbis_enc_context::nresidues
int nresidues
Definition: vorbisenc.c:128
AVCodecContext::bit_rate
int64_t bit_rate
the average bitrate
Definition: avcodec.h:433
vorbis_enc_residue::classifications
int classifications
Definition: vorbisenc.c:84
ff_bufqueue_discard_all
static void ff_bufqueue_discard_all(struct FFBufQueue *queue)
Unref and remove all buffers from the queue.
Definition: bufferqueue.h:111
mathops.h
vorbis_enc_context::fdsp
AVFloatDSPContext * fdsp
Definition: vorbisenc.c:139
floor_fit
static void floor_fit(vorbis_enc_context *venc, vorbis_enc_floor *fc, float *coeffs, uint16_t *posts, int samples)
Definition: vorbisenc.c:766
floor_encode
static int floor_encode(vorbis_enc_context *venc, vorbis_enc_floor *fc, PutBitContext *pb, uint16_t *posts, float *floor, int samples)
Definition: vorbisenc.c:798
vorbis_enc_residue::books
int8_t(* books)[8]
Definition: vorbisenc.c:86
vorbis_enc_codebook::nentries
int nentries
Definition: vorbisenc.c:48
vorbis_enc_floor::partitions
int partitions
Definition: vorbisenc.c:69
exp
int8_t exp
Definition: eval.c:72
vorbis_enc_codebook::min
float min
Definition: vorbisenc.c:52
vorbis_enc_context::floor
float * floor
Definition: vorbisenc.c:114
vorbis_enc_floor::nclasses
int nclasses
Definition: vorbisenc.c:71
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
float_dsp.h
vorbis_enc_context::win
const float * win[2]
Definition: vorbisenc.c:110
for
for(j=16;j >0;--j)
Definition: h264pred_template.c:469
put_codeword
static int put_codeword(PutBitContext *pb, vorbis_enc_codebook *cb, int entry)
Definition: vorbisenc.c:153
bufferqueue.h
ff_vorbis_ready_floor1_list
int ff_vorbis_ready_floor1_list(AVCodecContext *avctx, vorbis_floor1_entry *list, int values)
Definition: vorbis.c:106
MAX_CODEBOOK_DIM
#define MAX_CODEBOOK_DIM
Definition: vorbisenc.c:143
vorbis_enc_context::nmodes
int nmodes
Definition: vorbisenc.c:134
AVPacket::size
int size
Definition: packet.h:374
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
AVFloatDSPContext::vector_fmul
void(* vector_fmul)(float *dst, const float *src0, const float *src1, int len)
Calculate the entry wise product of two vectors of floats and store the result in a vector of floats.
Definition: float_dsp.h:38
render_point
static int render_point(int x0, int y0, int x1, int y1, int x)
Definition: vorbisenc.c:793
bps
unsigned bps
Definition: movenc.c:1597
AVCodecContext::sample_fmt
enum AVSampleFormat sample_fmt
audio sample format
Definition: avcodec.h:1000
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:59
ff_mdct_end
#define ff_mdct_end
Definition: fft.h:154
apply_window_and_mdct
static int apply_window_and_mdct(vorbis_enc_context *venc)
Definition: vorbisenc.c:1005
vorbis_enc_mode::blockflag
int blockflag
Definition: vorbisenc.c:101
move_audio
static void move_audio(vorbis_enc_context *venc, int sf_size)
Definition: vorbisenc.c:1056
av_xiphlacing
unsigned int av_xiphlacing(unsigned char *s, unsigned int v)
Encode extradata length to a buffer.
Definition: utils.c:834
AVFloatDSPContext
Definition: float_dsp.h:24
vorbis_enc_codebook::lookup
int lookup
Definition: vorbisenc.c:55
b2
static double b2(void *priv, double x, double y)
Definition: vf_xfade.c:1704
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
vorbis_enc_floor::values
int values
Definition: vorbisenc.c:75
vorbis_enc_codebook::ndimensions
int ndimensions
Definition: vorbisenc.c:51
ready_residue
static int ready_residue(vorbis_enc_residue *rc, vorbis_enc_context *venc)
Definition: vorbisenc.c:211
vorbis_enc_context::floors
vorbis_enc_floor * floors
Definition: vorbisenc.c:126
offset
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Definition: writing_filters.txt:86
ff_bufqueue_add
static void ff_bufqueue_add(void *log, struct FFBufQueue *queue, AVFrame *buf)
Add a buffer to the queue.
Definition: bufferqueue.h:71
vorbis_enc_mapping::submaps
int submaps
Definition: vorbisenc.c:91
input
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 input
Definition: filter_design.txt:172
vorbis_enc_context::mappings
vorbis_enc_mapping * mappings
Definition: vorbisenc.c:132
vorbis_enc_codebook::seq_p
int seq_p
Definition: vorbisenc.c:54
vorbis_enc_residue::type
int type
Definition: vorbisenc.c:80
vorbis_enc_codebook::delta
float delta
Definition: vorbisenc.c:53
AVCodecContext::channels
int channels
number of audio channels
Definition: avcodec.h:993
vorbis_enc_residue::partition_size
int partition_size
Definition: vorbisenc.c:83
av_assert2
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
Definition: avassert.h:64
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:397
FFTContext
Definition: fft.h:75
ready_codebook
static int ready_codebook(vorbis_enc_codebook *cb)
Definition: vorbisenc.c:174
vorbis_enc_floor_class::books
int * books
Definition: vorbisenc.c:65
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:366
create_vorbis_context
static int create_vorbis_context(vorbis_enc_context *venc, AVCodecContext *avctx)
Definition: vorbisenc.c:270
vorbis.h
av_get_bytes_per_sample
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
Definition: samplefmt.c:106
AVCodecContext::extradata
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:484
FFBufQueue
Structure holding the queue.
Definition: bufferqueue.h:49
lookup
int lookup
Definition: vorbis_enc_data.h:428
cvectors
static const struct @161 cvectors[]
AVFrame::extended_data
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:378
av_malloc_array
#define av_malloc_array(a, b)
Definition: tableprint_vlc.h:32
vorbis_enc_mapping::coupling_steps
int coupling_steps
Definition: vorbisenc.c:95
vorbis_enc_mapping::residue
int * residue
Definition: vorbisenc.c:94
FFBufQueue::available
unsigned short available
number of available buffers
Definition: bufferqueue.h:52
a2
#define a2
Definition: regdef.h:48
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
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:263
vorbis_enc_data.h
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:209
AV_PKT_DATA_SKIP_SAMPLES
@ AV_PKT_DATA_SKIP_SAMPLES
Recommmends skipping the specified number of samples.
Definition: packet.h:156
len
int len
Definition: vorbis_enc_data.h:426
vorbis_enc_floor
Definition: vorbisenc.c:68
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:271
vorbis_enc_context::scratch
float * scratch
Definition: vorbisenc.c:116
avcodec.h
vorbis_enc_context::next_pts
int64_t next_pts
Definition: vorbisenc.c:137
pv
#define pv
Definition: regdef.h:60
vorbis_enc_context::log2_blocksize
int log2_blocksize[2]
Definition: vorbisenc.c:108
dim
int dim
Definition: vorbis_enc_data.h:425
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:264
vorbis_enc_context::samples
float * samples
Definition: vorbisenc.c:113
ff_vorbis_floor1_inverse_db_table
const float ff_vorbis_floor1_inverse_db_table[256]
Definition: vorbis_data.c:2113
vorbis_enc_context::modes
vorbis_enc_mode * modes
Definition: vorbisenc.c:135
fft.h
AVCodecContext
main external API structure.
Definition: avcodec.h:383
ilog
#define ilog(i)
Definition: vorbis.h:47
av_packet_new_side_data
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, size_t size)
Allocate new information of a packet.
Definition: avpacket.c:232
buffer
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
Definition: filter_design.txt:49
mode
mode
Definition: ebur128.h:83
vorbis_enc_context
Definition: vorbisenc.c:105
AV_CODEC_CAP_DELAY
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: codec.h:82
samples
Filter the word “frame” indicates either a video frame or a group of audio samples
Definition: filter_design.txt:8
vorbis_enc_mapping::mux
int * mux
Definition: vorbisenc.c:92
MAX_FLOOR_VALUES
#define MAX_FLOOR_VALUES
Definition: vorbisenc.c:147
vorbis_enc_context::bufqueue
struct FFBufQueue bufqueue
Definition: vorbisenc.c:120
AV_CODEC_FLAG_BITEXACT
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
Definition: avcodec.h:272
flush_put_bits
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
Definition: put_bits.h:142
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:410
AVPacket
This structure stores compressed data.
Definition: packet.h:350
vorbis_enc_context::codebooks
vorbis_enc_codebook * codebooks
Definition: vorbisenc.c:123
NUM_RESIDUE_PARTITIONS
#define NUM_RESIDUE_PARTITIONS
Definition: vorbisenc.c:151
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
avpriv_float_dsp_alloc
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
Definition: float_dsp.c:135
vorbis_enc_context::nmappings
int nmappings
Definition: vorbisenc.c:131
quant_tables
static const uint8_t quant_tables[]
Definition: vorbis_enc_data.h:395
d
d
Definition: ffmpeg_filter.c:153
distance
static float distance(float x, float y, int band)
Definition: nellymoserenc.c:233
MAX_CHANNELS
#define MAX_CHANNELS
Definition: vorbisenc.c:142
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:28
AV_CODEC_ID_VORBIS
@ AV_CODEC_ID_VORBIS
Definition: codec_id.h:428
FF_QP2LAMBDA
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
Definition: avutil.h:227
int
int
Definition: ffmpeg_filter.c:153
put_bits.h
vorbis_enc_floor::rangebits
int rangebits
Definition: vorbisenc.c:74
vorbis_enc_mode::mapping
int mapping
Definition: vorbisenc.c:102
ff_alloc_packet
int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and allocate data.
Definition: encode.c:34
cb_lookup_vals
static int cb_lookup_vals(int lookup, int dimensions, int entries)
Definition: vorbisenc.c:165
channel
channel
Definition: ebur128.h:39
mc
#define mc
Definition: vf_colormatrix.c:102