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