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