Mercurial > libavcodec.hg
changeset 3839:c5ec6d7710ba libavcodec
Original Commit: r36 | ods15 | 2006-09-23 08:43:09 +0300 (Sat, 23 Sep 2006) | 2 lines
starting point for packet encode, writing floor
author | ods15 |
---|---|
date | Mon, 02 Oct 2006 05:56:18 +0000 |
parents | 6ccaab22c4d6 |
children | bb414feb6a0d |
files | vorbis_enc.c |
diffstat | 1 files changed, 35 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/vorbis_enc.c Mon Oct 02 05:56:16 2006 +0000 +++ b/vorbis_enc.c Mon Oct 02 05:56:18 2006 +0000 @@ -589,14 +589,45 @@ static int vorbis_encode_frame(AVCodecContext * avccontext, unsigned char * packets, int buf_size, void *data) { -#if 0 venc_context_t * venc = avccontext->priv_data; signed short * audio = data; int samples = data ? avccontext->frame_size : 0; + vorbis_mode_t * mode; + mapping_t * mapping; + PutBitContext pb; + int i; - avccontext->coded_frame->pts = av_rescale_q(op2->granulepos, (AVRational){1, avccontext->sample_rate}, avccontext->time_base); - memcpy(packets, compressed_frame, l); -#endif + init_put_bits(&pb, packets, buf_size); + + put_bits(&pb, 1, 0); // magic bit + + put_bits(&pb, ilog(venc->nmodes - 1), 0); // 0 bits, the mode + + mode = &venc->modes[0]; + mapping = &venc->mappings[mode->mapping]; + if (mode->blockflag) { + put_bits(&pb, 1, 0); + put_bits(&pb, 1, 0); + } + + for (i = 0; i < venc->channels; i++) { + floor_t * fc = &venc->floors[mapping->floor[mapping->mux[i]]]; + int range = 255 / fc->multiplier + 1; + int j; + put_bits(&pb, 1, 1); // non zero + put_bits(&pb, ilog(range - 1), 113); // magic value - 3.7180282E-05 + put_bits(&pb, ilog(range - 1), 113); // both sides of X + for (j = 0; j < fc->partitions; j++) { + floor_class_t * c = &fc->classes[fc->partition_to_class[j]]; + codebook_t * book = &venc->codebooks[c->books[0]]; + int entry = 0; + int k; + for (k = 0; k < c->dim; k++) { + put_bits(&pb, book->entries[entry].len, book->entries[entry].codeword); + } + } + } + return data ? 50 : 0; }