• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/iserver/libav-0.8.8/libavcodec/

Lines Matching defs:venc

195 static int ready_residue(vorbis_enc_residue *rc, vorbis_enc_context *venc)
210 cb = &venc->codebooks[rc->books[i][j]];
234 static int create_vorbis_context(vorbis_enc_context *venc,
242 venc->channels = avccontext->channels;
243 venc->sample_rate = avccontext->sample_rate;
244 venc->log2_blocksize[0] = venc->log2_blocksize[1] = 11;
246 venc->ncodebooks = FF_ARRAY_ELEMS(cvectors);
247 venc->codebooks = av_malloc(sizeof(vorbis_enc_codebook) * venc->ncodebooks);
248 if (!venc->codebooks)
254 for (book = 0; book < venc->ncodebooks; book++) {
255 vorbis_enc_codebook *cb = &venc->codebooks[book];
285 venc->nfloors = 1;
286 venc->floors = av_malloc(sizeof(vorbis_enc_floor) * venc->nfloors);
287 if (!venc->floors)
291 fc = &venc->floors[0];
320 fc->rangebits = venc->log2_blocksize[0] - 1;
342 venc->nresidues = 1;
343 venc->residues = av_malloc(sizeof(vorbis_enc_residue) * venc->nresidues);
344 if (!venc->residues)
348 rc = &venc->residues[0];
373 if ((ret = ready_residue(rc, venc)) < 0)
376 venc->nmappings = 1;
377 venc->mappings = av_malloc(sizeof(vorbis_enc_mapping) * venc->nmappings);
378 if (!venc->mappings)
382 mc = &venc->mappings[0];
384 mc->mux = av_malloc(sizeof(int) * venc->channels);
387 for (i = 0; i < venc->channels; i++)
397 mc->coupling_steps = venc->channels == 2 ? 1 : 0;
407 venc->nmodes = 1;
408 venc->modes = av_malloc(sizeof(vorbis_enc_mode) * venc->nmodes);
409 if (!venc->modes)
413 venc->modes[0].blockflag = 0;
414 venc->modes[0].mapping = 0;
416 venc->have_saved = 0;
417 venc->saved = av_malloc(sizeof(float) * venc->channels * (1 << venc->log2_blocksize[1]) / 2);
418 venc->samples = av_malloc(sizeof(float) * venc->channels * (1 << venc->log2_blocksize[1]));
419 venc->floor = av_malloc(sizeof(float) * venc->channels * (1 << venc->log2_blocksize[1]) / 2);
420 venc->coeffs = av_malloc(sizeof(float) * venc->channels * (1 << venc->log2_blocksize[1]) / 2);
421 if (!venc->saved || !venc->samples || !venc->floor || !venc->coeffs)
424 venc->win[0] = ff_vorbis_vwin[venc->log2_blocksize[0] - 6];
425 venc->win[1] = ff_vorbis_vwin[venc->log2_blocksize[1] - 6];
427 if ((ret = ff_mdct_init(&venc->mdct[0], venc->log2_blocksize[0], 0, 1.0)) < 0)
429 if ((ret = ff_mdct_init(&venc->mdct[1], venc->log2_blocksize[1], 0, 1.0)) < 0)
579 static int put_main_header(vorbis_enc_context *venc, uint8_t **out)
593 put_bits(&pb, 8, venc->channels);
594 put_bits32(&pb, venc->sample_rate);
598 put_bits(&pb, 4, venc->log2_blocksize[0]);
599 put_bits(&pb, 4, venc->log2_blocksize[1]);
628 put_bits(&pb, 8, venc->ncodebooks - 1);
629 for (i = 0; i < venc->ncodebooks; i++)
630 put_codebook_header(&pb, &venc->codebooks[i]);
637 put_bits(&pb, 6, venc->nfloors - 1);
638 for (i = 0; i < venc->nfloors; i++)
639 put_floor_header(&pb, &venc->floors[i]);
642 put_bits(&pb, 6, venc->nresidues - 1);
643 for (i = 0; i < venc->nresidues; i++)
644 put_residue_header(&pb, &venc->residues[i]);
647 put_bits(&pb, 6, venc->nmappings - 1);
648 for (i = 0; i < venc->nmappings; i++) {
649 vorbis_enc_mapping *mc = &venc->mappings[i];
661 put_bits(&pb, ilog(venc->channels - 1), mc->magnitude[j]);
662 put_bits(&pb, ilog(venc->channels - 1), mc->angle[j]);
669 for (j = 0; j < venc->channels; j++)
680 put_bits(&pb, 6, venc->nmodes - 1);
681 for (i = 0; i < venc->nmodes; i++) {
682 put_bits(&pb, 1, venc->modes[i].blockflag);
685 put_bits(&pb, 8, venc->modes[i].mapping);
723 static void floor_fit(vorbis_enc_context *venc, vorbis_enc_floor *fc,
735 tot_average /= venc->quality;
755 static void floor_encode(vorbis_enc_context *venc, vorbis_enc_floor *fc,
804 vorbis_enc_codebook * book = &venc->codebooks[c->masterbook];
811 maxval = venc->codebooks[c->books[l]].nentries;
830 put_codeword(pb, &venc->codebooks[book], entry);
860 static void residue_encode(vorbis_enc_context *venc, vorbis_enc_residue *rc,
869 int classwords = venc->codebooks[rc->classbook].ndimentions;
892 vorbis_enc_codebook * book = &venc->codebooks[rc->classbook];
903 vorbis_enc_codebook * book = &venc->codebooks[nbook];
949 static int apply_window_and_mdct(vorbis_enc_context *venc, const signed short *audio,
953 const float * win = venc->win[0];
954 int window_len = 1 << (venc->log2_blocksize[0] - 1);
955 float n = (float)(1 << venc->log2_blocksize[0]) / 4.;
958 if (!venc->have_saved && !samples)
961 if (venc->have_saved) {
962 for (channel = 0; channel < venc->channels; channel++)
963 memcpy(venc->samples + channel * window_len * 2,
964 venc->saved + channel * window_len, sizeof(float) * window_len);
966 for (channel = 0; channel < venc->channels; channel++)
967 memset(venc->samples + channel * window_len * 2, 0,
972 for (channel = 0; channel < venc->channels; channel++) {
973 float * offset = venc->samples + channel*window_len*2 + window_len;
975 for (i = 0; i < samples; i++, j += venc->channels)
979 for (channel = 0; channel < venc->channels; channel++)
980 memset(venc->samples + channel * window_len * 2 + window_len,
984 for (channel = 0; channel < venc->channels; channel++)
985 venc->mdct[0].mdct_calc(&venc->mdct[0], venc->coeffs + channel * window_len,
986 venc->samples + channel * window_len * 2);
989 for (channel = 0; channel < venc->channels; channel++) {
990 float *offset = venc->saved + channel * window_len;
992 for (i = 0; i < samples; i++, j += venc->channels)
995 venc->have_saved = 1;
997 venc->have_saved = 0;
1007 vorbis_enc_context *venc = avccontext->priv_data;
1015 if (!apply_window_and_mdct(venc, audio, samples))
1017 samples = 1 << (venc->log2_blocksize[0] - 1);
1023 put_bits(&pb, ilog(venc->nmodes - 1), 0); // 0 bits, the mode
1025 mode = &venc->modes[0];
1026 mapping = &venc->mappings[mode->mapping];
1032 for (i = 0; i < venc->channels; i++) {
1033 vorbis_enc_floor *fc = &venc->floors[mapping->floor[mapping->mux[i]]];
1035 floor_fit(venc, fc, &venc->coeffs[i * samples], posts, samples);
1036 floor_encode(venc, fc, &pb, posts, &venc->floor[i * samples], samples);
1039 for (i = 0; i < venc->channels * samples; i++)
1040 venc->coeffs[i] /= venc->floor[i];
1043 float *mag = venc->coeffs + mapping->magnitude[i] * samples;
1044 float *ang = venc->coeffs + mapping->angle[i] * samples;
1056 residue_encode(venc, &venc->residues[mapping->residue[mapping->mux[0]]],
1057 &pb, venc->coeffs, samples, venc->channels);
1059 avccontext->coded_frame->pts = venc->sample_count;
1060 venc->sample_count += avccontext->frame_size;
1068 vorbis_enc_context *venc = avccontext->priv_data;
1071 if (venc->codebooks)
1072 for (i = 0; i < venc->ncodebooks; i++) {
1073 av_freep(&venc->codebooks[i].lens);
1074 av_freep(&venc->codebooks[i].codewords);
1075 av_freep(&venc->codebooks[i].quantlist);
1076 av_freep(&venc->codebooks[i].dimentions);
1077 av_freep(&venc->codebooks[i].pow2);
1079 av_freep(&venc->codebooks);
1081 if (venc->floors)
1082 for (i = 0; i < venc->nfloors; i++) {
1084 if (venc->floors[i].classes)
1085 for (j = 0; j < venc->floors[i].nclasses; j++)
1086 av_freep(&venc->floors[i].classes[j].books);
1087 av_freep(&venc->floors[i].classes);
1088 av_freep(&venc->floors[i].partition_to_class);
1089 av_freep(&venc->floors[i].list);
1091 av_freep(&venc->floors);
1093 if (venc->residues)
1094 for (i = 0; i < venc->nresidues; i++) {
1095 av_freep(&venc->residues[i].books);
1096 av_freep(&venc->residues[i].maxes);
1098 av_freep(&venc->residues);
1100 if (venc->mappings)
1101 for (i = 0; i < venc->nmappings; i++) {
1102 av_freep(&venc->mappings[i].mux);
1103 av_freep(&venc->mappings[i].floor);
1104 av_freep(&venc->mappings[i].residue);
1105 av_freep(&venc->mappings[i].magnitude);
1106 av_freep(&venc->mappings[i].angle);
1108 av_freep(&venc->mappings);
1110 av_freep(&venc->modes);
1112 av_freep(&venc->saved);
1113 av_freep(&venc->samples);
1114 av_freep(&venc->floor);
1115 av_freep(&venc->coeffs);
1117 ff_mdct_end(&venc->mdct[0]);
1118 ff_mdct_end(&venc->mdct[1]);
1128 vorbis_enc_context *venc = avccontext->priv_data;
1136 if ((ret = create_vorbis_context(venc, avccontext)) < 0)
1140 venc->quality = avccontext->global_quality / (float)FF_QP2LAMBDA / 10.;
1142 venc->quality = 0.03;
1143 venc->quality *= venc->quality;
1145 if ((ret = put_main_header(venc, (uint8_t**)&avccontext->extradata)) < 0)
1149 avccontext->frame_size = 1 << (venc->log2_blocksize[0] - 1);