You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

657 lines
18KB

  1. /*
  2. * copyright (c) 2006 Oded Shimon <ods15@ods15.dyndns.org>
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. /**
  19. * @file vorbis_enc.c
  20. * Native Vorbis encoder.
  21. * @author Oded Shimon <ods15@ods15.dyndns.org>
  22. */
  23. #include "avcodec.h"
  24. #undef NDEBUG
  25. #include <assert.h>
  26. //#define ALT_BITSTREAM_WRITER
  27. //#include "bitstream.h"
  28. typedef struct {
  29. int len;
  30. uint32_t codeword;
  31. } cb_entry_t;
  32. typedef struct {
  33. int nentries;
  34. cb_entry_t * entries;
  35. int ndimentions;
  36. float min;
  37. float delta;
  38. int seq_p;
  39. int lookup;
  40. int * quantlist;
  41. float * dimentions;
  42. } codebook_t;
  43. typedef struct {
  44. int dim;
  45. int subclass;
  46. int masterbook;
  47. int * books;
  48. } floor_class_t;
  49. typedef struct {
  50. int partitions;
  51. int * partition_to_class;
  52. int nclasses;
  53. floor_class_t * classes;
  54. int multiplier;
  55. int rangebits;
  56. int values;
  57. struct { int x; } * list;
  58. } floor_t;
  59. typedef struct {
  60. int type;
  61. int begin;
  62. int end;
  63. int partition_size;
  64. int classifications;
  65. int classbook;
  66. int (*books)[8];
  67. } residue_t;
  68. typedef struct {
  69. int submaps;
  70. int * mux;
  71. int * floor;
  72. int * residue;
  73. } mapping_t;
  74. typedef struct {
  75. int blockflag;
  76. int mapping;
  77. } vorbis_mode_t;
  78. typedef struct {
  79. int channels;
  80. int sample_rate;
  81. int blocksize[2]; // in (1<<n) format
  82. int ncodebooks;
  83. codebook_t * codebooks;
  84. int nfloors;
  85. floor_t * floors;
  86. int nresidues;
  87. residue_t * residues;
  88. int nmappings;
  89. mapping_t * mappings;
  90. int nmodes;
  91. vorbis_mode_t * modes;
  92. } venc_context_t;
  93. typedef struct {
  94. int total;
  95. int total_pos;
  96. int pos;
  97. uint8_t * buf_ptr;
  98. } PutBitContext;
  99. static inline void init_put_bits(PutBitContext * pb, uint8_t * buf, int buffer_len) {
  100. pb->total = buffer_len * 8;
  101. pb->total_pos = 0;
  102. pb->pos = 0;
  103. pb->buf_ptr = buf;
  104. }
  105. static void put_bits(PutBitContext * pb, int bits, uint64_t val) {
  106. if ((pb->total_pos += bits) >= pb->total) return;
  107. if (!bits) return;
  108. if (pb->pos) {
  109. if (pb->pos > bits) {
  110. *pb->buf_ptr |= val << (8 - pb->pos);
  111. pb->pos -= bits;
  112. bits = 0;
  113. } else {
  114. *pb->buf_ptr++ |= (val << (8 - pb->pos)) & 0xFF;
  115. val >>= pb->pos;
  116. bits -= pb->pos;
  117. pb->pos = 0;
  118. }
  119. }
  120. for (; bits >= 8; bits -= 8) {
  121. *pb->buf_ptr++ = val & 0xFF;
  122. val >>= 8;
  123. }
  124. if (bits) {
  125. *pb->buf_ptr = val;
  126. pb->pos = 8 - bits;
  127. }
  128. }
  129. static inline void flush_put_bits(PutBitContext * pb) {
  130. }
  131. static inline int put_bits_count(PutBitContext * pb) {
  132. return pb->total_pos;
  133. }
  134. static int cb_lookup_vals(int lookup, int dimentions, int entries) {
  135. if (lookup == 1) {
  136. int tmp, i;
  137. for (tmp = 0; ; tmp++) {
  138. int n = 1;
  139. for (i = 0; i < dimentions; i++) n *= tmp;
  140. if (n > entries) break;
  141. }
  142. return tmp - 1;
  143. } else if (lookup == 2) return dimentions * entries;
  144. return 0;
  145. }
  146. static void ready_codebook(codebook_t * cb) {
  147. int h[33] = { 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
  148. int i;
  149. for (i = 0; i < cb->nentries; i++) {
  150. cb_entry_t * e = &cb->entries[i];
  151. int j = 0;
  152. if (h[0]) h[0] = 0;
  153. else for (j = e->len; !h[j]; j--) assert(j);
  154. e->codeword = h[j];
  155. h[j] = 0;
  156. for (j++; j <= e->len; j++) h[j] = e->codeword | (1 << (j - 1));
  157. }
  158. for (i = 0; i < 33; i++) assert(!h[i]);
  159. if (!cb->lookup) cb->dimentions = NULL;
  160. else {
  161. int vals = cb_lookup_vals(cb->lookup, cb->ndimentions, cb->nentries);
  162. cb->dimentions = av_malloc(sizeof(float) * cb->nentries * cb->ndimentions);
  163. for (i = 0; i < cb->nentries; i++) {
  164. float last = 0;
  165. int j;
  166. int div = 1;
  167. for (j = 0; j < cb->ndimentions; j++) {
  168. int off;
  169. if (cb->lookup == 1) off = (i / div) % vals; // lookup type 1
  170. else off = i * cb->ndimentions + j; // lookup type 2
  171. cb->dimentions[i * cb->ndimentions + j] = last + cb->min + cb->quantlist[off] * cb->delta;
  172. if (cb->seq_p) last = cb->dimentions[i * cb->ndimentions + j];
  173. div *= vals;
  174. }
  175. }
  176. }
  177. }
  178. static void create_vorbis_context(venc_context_t * venc, AVCodecContext * avccontext) {
  179. codebook_t * cb;
  180. floor_t * fc;
  181. residue_t * rc;
  182. mapping_t * mc;
  183. int i, book;
  184. venc->channels = avccontext->channels;
  185. venc->sample_rate = avccontext->sample_rate;
  186. venc->blocksize[0] = venc->blocksize[1] = 8;
  187. venc->ncodebooks = 10;
  188. venc->codebooks = av_malloc(sizeof(codebook_t) * venc->ncodebooks);
  189. // codebook 1 - floor1 book, values 0..255
  190. cb = &venc->codebooks[0];
  191. cb->nentries = 256;
  192. cb->entries = av_malloc(sizeof(cb_entry_t) * cb->nentries);
  193. for (i = 0; i < cb->nentries; i++) cb->entries[i].len = 8;
  194. cb->ndimentions = 0;
  195. cb->min = 0.;
  196. cb->delta = 0.;
  197. cb->seq_p = 0;
  198. cb->lookup = 0;
  199. cb->quantlist = NULL;
  200. ready_codebook(cb);
  201. // codebook 2 - residue classbook, values 0..1, dimentions 200
  202. cb = &venc->codebooks[1];
  203. cb->nentries = 2;
  204. cb->entries = av_malloc(sizeof(cb_entry_t) * cb->nentries);
  205. for (i = 0; i < cb->nentries; i++) cb->entries[i].len = 1;
  206. cb->ndimentions = 200;
  207. cb->min = 0.;
  208. cb->delta = 0.;
  209. cb->seq_p = 0;
  210. cb->lookup = 0;
  211. cb->quantlist = NULL;
  212. ready_codebook(cb);
  213. // codebook 3..10 - vector, for the residue, values -32767..32767, dimentions 1
  214. for (book = 0; book < 8; book++) {
  215. cb = &venc->codebooks[2 + book];
  216. cb->nentries = 5;
  217. cb->entries = av_malloc(sizeof(cb_entry_t) * cb->nentries);
  218. for (i = 0; i < cb->nentries; i++) cb->entries[i].len = i == 2 ? 1 : 3;
  219. cb->ndimentions = 1;
  220. cb->delta = 1 << ((7 - book) * 2);
  221. cb->min = -cb->delta*2;
  222. cb->seq_p = 0;
  223. cb->lookup = 2;
  224. cb->quantlist = av_malloc(sizeof(int) * cb_lookup_vals(cb->lookup, cb->ndimentions, cb->nentries));
  225. for (i = 0; i < cb->nentries; i++) cb->quantlist[i] = i;
  226. ready_codebook(cb);
  227. }
  228. venc->nfloors = 1;
  229. venc->floors = av_malloc(sizeof(floor_t) * venc->nfloors);
  230. // just 1 floor
  231. fc = &venc->floors[0];
  232. fc->partitions = 1;
  233. fc->partition_to_class = av_malloc(sizeof(int) * fc->partitions);
  234. for (i = 0; i < fc->partitions; i++) fc->partition_to_class[i] = 0;
  235. fc->nclasses = 1;
  236. fc->classes = av_malloc(sizeof(floor_class_t) * fc->nclasses);
  237. for (i = 0; i < fc->nclasses; i++) {
  238. floor_class_t * c = &fc->classes[i];
  239. int j, books;
  240. c->dim = 1;
  241. c->subclass = 0;
  242. c->masterbook = 0;
  243. books = (1 << c->subclass);
  244. c->books = av_malloc(sizeof(int) * books);
  245. for (j = 0; j < books; j++) c->books[j] = 0;
  246. }
  247. fc->multiplier = 1;
  248. fc->rangebits = venc->blocksize[0];
  249. fc->values = 2;
  250. for (i = 0; i < fc->partitions; i++)
  251. fc->values += fc->classes[fc->partition_to_class[i]].dim;
  252. fc->list = av_malloc(sizeof(*fc->list) * fc->values);
  253. fc->list[0].x = 0;
  254. fc->list[1].x = 1 << fc->rangebits;
  255. for (i = 2; i < fc->values; i++) fc->list[i].x = i * 5;
  256. venc->nresidues = 1;
  257. venc->residues = av_malloc(sizeof(residue_t) * venc->nresidues);
  258. // single residue
  259. rc = &venc->residues[0];
  260. rc->type = 0;
  261. rc->begin = 0;
  262. rc->end = 1 << venc->blocksize[0];
  263. rc->partition_size = 64;
  264. rc->classifications = 1;
  265. rc->classbook = 1;
  266. rc->books = av_malloc(sizeof(int[8]) * rc->classifications);
  267. for (i = 0; i < 8; i++) rc->books[0][i] = 2 + i;
  268. venc->nmappings = 1;
  269. venc->mappings = av_malloc(sizeof(mapping_t) * venc->nmappings);
  270. // single mapping
  271. mc = &venc->mappings[0];
  272. mc->submaps = 1;
  273. mc->mux = av_malloc(sizeof(int) * venc->channels);
  274. for (i = 0; i < venc->channels; i++) mc->mux[i] = 0;
  275. mc->floor = av_malloc(sizeof(int) * mc->submaps);
  276. mc->residue = av_malloc(sizeof(int) * mc->submaps);
  277. for (i = 0; i < mc->submaps; i++) {
  278. mc->floor[i] = 0;
  279. mc->residue[i] = 0;
  280. }
  281. venc->nmodes = 1;
  282. venc->modes = av_malloc(sizeof(vorbis_mode_t) * venc->nmodes);
  283. // single mode
  284. venc->modes[0].blockflag = 0;
  285. venc->modes[0].mapping = 0;
  286. }
  287. static inline int ilog(unsigned int a) {
  288. int i;
  289. for (i = 0; a >> i; i++);
  290. return i;
  291. }
  292. static void put_float(PutBitContext * pb, float f) {
  293. int exp, mant;
  294. uint32_t res = 0;
  295. mant = (int)ldexp(frexp(f, &exp), 20);
  296. exp += 788 - 20;
  297. if (mant < 0) { res |= (1 << 31); mant = -mant; }
  298. res |= mant | (exp << 21);
  299. put_bits(pb, 32, res);
  300. }
  301. static void put_codebook_header(PutBitContext * pb, codebook_t * cb) {
  302. int i;
  303. int ordered = 0;
  304. put_bits(pb, 24, 0x564342); //magic
  305. put_bits(pb, 16, cb->ndimentions);
  306. put_bits(pb, 24, cb->nentries);
  307. for (i = 1; i < cb->nentries; i++) if (cb->entries[i].len < cb->entries[i-1].len) break;
  308. if (i == cb->nentries) ordered = 1;
  309. put_bits(pb, 1, ordered);
  310. if (ordered) {
  311. int len = cb->entries[0].len;
  312. put_bits(pb, 5, len);
  313. i = 0;
  314. while (i < cb->nentries) {
  315. int j;
  316. for (j = 0; j+i < cb->nentries; j++) if (cb->entries[j+i].len != len) break;
  317. put_bits(pb, ilog(cb->nentries - i), j);
  318. i += j;
  319. len++;
  320. }
  321. } else {
  322. int sparse = 0;
  323. for (i = 0; i < cb->nentries; i++) if (!cb->entries[i].len) break;
  324. if (i != cb->nentries) sparse = 1;
  325. put_bits(pb, 1, sparse);
  326. for (i = 0; i < cb->nentries; i++) {
  327. if (sparse) put_bits(pb, 1, !!cb->entries[i].len);
  328. if (cb->entries[i].len) put_bits(pb, 5, cb->entries[i].len - 1);
  329. }
  330. }
  331. put_bits(pb, 4, cb->lookup);
  332. if (cb->lookup) {
  333. int tmp = cb_lookup_vals(cb->lookup, cb->ndimentions, cb->nentries);
  334. int bits = ilog(cb->quantlist[0]);
  335. for (i = 1; i < tmp; i++) bits = FFMAX(bits, ilog(cb->quantlist[i]));
  336. put_float(pb, cb->min);
  337. put_float(pb, cb->delta);
  338. put_bits(pb, 4, bits - 1);
  339. put_bits(pb, 1, cb->seq_p);
  340. for (i = 0; i < tmp; i++) put_bits(pb, bits, cb->quantlist[i]);
  341. }
  342. }
  343. static void put_floor_header(PutBitContext * pb, floor_t * fc) {
  344. int i;
  345. put_bits(pb, 16, 1); // type, only floor1 is supported
  346. put_bits(pb, 5, fc->partitions);
  347. for (i = 0; i < fc->partitions; i++) put_bits(pb, 4, fc->partition_to_class[i]);
  348. for (i = 0; i < fc->nclasses; i++) {
  349. int j, books;
  350. put_bits(pb, 3, fc->classes[i].dim - 1);
  351. put_bits(pb, 2, fc->classes[i].subclass);
  352. if (fc->classes[i].subclass) put_bits(pb, 8, fc->classes[i].masterbook);
  353. books = (1 << fc->classes[i].subclass);
  354. for (j = 0; j < books; j++) put_bits(pb, 8, fc->classes[i].books[j] + 1);
  355. }
  356. put_bits(pb, 2, fc->multiplier - 1);
  357. put_bits(pb, 4, fc->rangebits);
  358. for (i = 2; i < fc->values; i++) put_bits(pb, fc->rangebits, fc->list[i].x);
  359. }
  360. static void put_residue_header(PutBitContext * pb, residue_t * rc) {
  361. int i;
  362. put_bits(pb, 16, rc->type);
  363. put_bits(pb, 24, rc->begin);
  364. put_bits(pb, 24, rc->end);
  365. put_bits(pb, 24, rc->partition_size - 1);
  366. put_bits(pb, 6, rc->classifications - 1);
  367. put_bits(pb, 8, rc->classbook);
  368. for (i = 0; i < rc->classifications; i++) {
  369. int j, tmp = 0;
  370. for (j = 0; j < 8; j++) tmp |= (!!rc->books[i][j]) << j;
  371. put_bits(pb, 3, tmp & 7);
  372. put_bits(pb, 1, tmp > 7);
  373. if (tmp > 7) put_bits(pb, 5, tmp >> 3);
  374. }
  375. for (i = 0; i < rc->classifications; i++) {
  376. int j;
  377. for (j = 0; j < 8; j++)
  378. if (rc->books[i][j])
  379. put_bits(pb, 8, rc->books[i][j]);
  380. }
  381. }
  382. static int put_main_header(venc_context_t * venc, uint8_t ** out) {
  383. int i;
  384. PutBitContext pb;
  385. uint8_t buffer[50000] = {0}, * p = buffer;
  386. int buffer_len = sizeof buffer;
  387. int len, hlens[3];
  388. // identification header
  389. init_put_bits(&pb, p, buffer_len);
  390. put_bits(&pb, 8, 1); //magic
  391. for (i = 0; "vorbis"[i]; i++) put_bits(&pb, 8, "vorbis"[i]);
  392. put_bits(&pb, 32, 0); // version
  393. put_bits(&pb, 8, venc->channels);
  394. put_bits(&pb, 32, venc->sample_rate);
  395. put_bits(&pb, 32, 0); // bitrate
  396. put_bits(&pb, 32, 0); // bitrate
  397. put_bits(&pb, 32, 0); // bitrate
  398. put_bits(&pb, 4, venc->blocksize[0]);
  399. put_bits(&pb, 4, venc->blocksize[1]);
  400. put_bits(&pb, 1, 1); // framing
  401. flush_put_bits(&pb);
  402. hlens[0] = (put_bits_count(&pb) + 7) / 8;
  403. buffer_len -= hlens[0];
  404. p += hlens[0];
  405. // comment header
  406. init_put_bits(&pb, p, buffer_len);
  407. put_bits(&pb, 8, 3); //magic
  408. for (i = 0; "vorbis"[i]; i++) put_bits(&pb, 8, "vorbis"[i]);
  409. put_bits(&pb, 32, 0); // vendor length TODO
  410. put_bits(&pb, 32, 0); // amount of comments
  411. put_bits(&pb, 1, 1); // framing
  412. flush_put_bits(&pb);
  413. hlens[1] = (put_bits_count(&pb) + 7) / 8;
  414. buffer_len -= hlens[1];
  415. p += hlens[1];
  416. // setup header
  417. init_put_bits(&pb, p, buffer_len);
  418. put_bits(&pb, 8, 5); //magic
  419. for (i = 0; "vorbis"[i]; i++) put_bits(&pb, 8, "vorbis"[i]);
  420. // codebooks
  421. put_bits(&pb, 8, venc->ncodebooks - 1);
  422. for (i = 0; i < venc->ncodebooks; i++) put_codebook_header(&pb, &venc->codebooks[i]);
  423. // time domain, reserved, zero
  424. put_bits(&pb, 6, 0);
  425. put_bits(&pb, 16, 0);
  426. // floors
  427. put_bits(&pb, 6, venc->nfloors - 1);
  428. for (i = 0; i < venc->nfloors; i++) put_floor_header(&pb, &venc->floors[i]);
  429. // residues
  430. put_bits(&pb, 6, venc->nresidues - 1);
  431. for (i = 0; i < venc->nresidues; i++) put_residue_header(&pb, &venc->residues[i]);
  432. // mappings
  433. put_bits(&pb, 6, venc->nmappings - 1);
  434. for (i = 0; i < venc->nmappings; i++) {
  435. mapping_t * mc = &venc->mappings[i];
  436. int j;
  437. put_bits(&pb, 16, 0); // mapping type
  438. put_bits(&pb, 1, mc->submaps > 1);
  439. if (mc->submaps > 1) put_bits(&pb, 4, mc->submaps - 1);
  440. put_bits(&pb, 1, 0); // channel coupling
  441. put_bits(&pb, 2, 0); // reserved
  442. if (mc->submaps > 1) for (j = 0; j < venc->channels; j++) put_bits(&pb, 4, mc->mux[j]);
  443. for (j = 0; j < mc->submaps; j++) {
  444. put_bits(&pb, 8, 0); // reserved time configuration
  445. put_bits(&pb, 8, mc->floor[j]);
  446. put_bits(&pb, 8, mc->residue[j]);
  447. }
  448. }
  449. // modes
  450. put_bits(&pb, 6, venc->nmodes - 1);
  451. for (i = 0; i < venc->nmodes; i++) {
  452. put_bits(&pb, 1, venc->modes[i].blockflag);
  453. put_bits(&pb, 16, 0); // reserved window type
  454. put_bits(&pb, 16, 0); // reserved transform type
  455. put_bits(&pb, 8, venc->modes[i].mapping);
  456. }
  457. put_bits(&pb, 1, 1); // framing
  458. flush_put_bits(&pb);
  459. hlens[2] = (put_bits_count(&pb) + 7) / 8;
  460. len = hlens[0] + hlens[1] + hlens[2];
  461. p = *out = av_mallocz(64 + len + len/255);
  462. *p++ = 2;
  463. p += av_xiphlacing(p, hlens[0]);
  464. p += av_xiphlacing(p, hlens[1]);
  465. buffer_len = 0;
  466. for (i = 0; i < 3; i++) {
  467. memcpy(p, buffer + buffer_len, hlens[i]);
  468. p += hlens[i];
  469. buffer_len += hlens[i];
  470. }
  471. return p - *out;
  472. }
  473. static int vorbis_encode_init(AVCodecContext * avccontext)
  474. {
  475. venc_context_t * venc = avccontext->priv_data;
  476. create_vorbis_context(venc, avccontext);
  477. //if (avccontext->flags & CODEC_FLAG_QSCALE) avccontext->global_quality / (float)FF_QP2LAMBDA); else avccontext->bit_rate;
  478. //if(avccontext->cutoff > 0) cfreq = avccontext->cutoff / 1000.0;
  479. avccontext->extradata_size = put_main_header(venc, (uint8_t**)&avccontext->extradata);
  480. avccontext->frame_size = 1 << venc->blocksize[0];
  481. avccontext->coded_frame = avcodec_alloc_frame();
  482. avccontext->coded_frame->key_frame = 1;
  483. return 0;
  484. }
  485. static int vorbis_encode_frame(AVCodecContext * avccontext, unsigned char * packets, int buf_size, void *data)
  486. {
  487. #if 0
  488. venc_context_t * venc = avccontext->priv_data;
  489. signed short * audio = data;
  490. int samples = data ? avccontext->frame_size : 0;
  491. avccontext->coded_frame->pts = av_rescale_q(op2->granulepos, (AVRational){1, avccontext->sample_rate}, avccontext->time_base);
  492. memcpy(packets, compressed_frame, l);
  493. #endif
  494. return data ? 50 : 0;
  495. }
  496. static int vorbis_encode_close(AVCodecContext * avccontext)
  497. {
  498. venc_context_t * venc = avccontext->priv_data;
  499. int i;
  500. if (venc->codebooks) for (i = 0; i < venc->ncodebooks; i++) {
  501. av_freep(&venc->codebooks[i].entries);
  502. av_freep(&venc->codebooks[i].quantlist);
  503. av_freep(&venc->codebooks[i].dimentions);
  504. }
  505. av_freep(&venc->codebooks);
  506. if (venc->floors) for (i = 0; i < venc->nfloors; i++) {
  507. int j;
  508. av_freep(&venc->floors[i].classes);
  509. if (venc->floors[i].classes)
  510. for (j = 0; j < venc->floors[i].nclasses; j++)
  511. av_freep(&venc->floors[i].classes[j].books);
  512. av_freep(&venc->floors[i].partition_to_class);
  513. av_freep(&venc->floors[i].list);
  514. }
  515. av_freep(&venc->floors);
  516. if (venc->residues) for (i = 0; i < venc->nresidues; i++) {
  517. av_freep(&venc->residues[i].books);
  518. }
  519. av_freep(&venc->residues);
  520. if (venc->mappings) for (i = 0; i < venc->nmappings; i++) {
  521. av_freep(&venc->mappings[i].mux);
  522. av_freep(&venc->mappings[i].floor);
  523. av_freep(&venc->mappings[i].residue);
  524. }
  525. av_freep(&venc->mappings);
  526. av_freep(&venc->modes);
  527. av_freep(&avccontext->coded_frame);
  528. av_freep(&avccontext->extradata);
  529. return 0 ;
  530. }
  531. AVCodec oggvorbis_encoder = {
  532. "vorbis",
  533. CODEC_TYPE_AUDIO,
  534. CODEC_ID_VORBIS,
  535. sizeof(venc_context_t),
  536. vorbis_encode_init,
  537. vorbis_encode_frame,
  538. vorbis_encode_close,
  539. .capabilities= CODEC_CAP_DELAY,
  540. };