]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/vorbis_enc.c
Remove hack added to make "make checkheaders" pass, it is unneeded now
[ffmpeg] / libavcodec / vorbis_enc.c
index 3d6378572490148fcaad1a62aacfe4ce4281fe72..0cb644b46b82d6edca4e747fa07bace12af73436 100644 (file)
@@ -30,6 +30,9 @@
 #include "vorbis.h"
 #include "vorbis_enc_data.h"
 
+#define BITSTREAM_WRITER_LE
+#include "bitstream.h"
+
 #undef NDEBUG
 #include <assert.h>
 
@@ -118,53 +121,9 @@ typedef struct {
 
     int nmodes;
     vorbis_mode_t * modes;
-} venc_context_t;
-
-typedef struct {
-    int total;
-    int total_pos;
-    int pos;
-    uint8_t * buf_ptr;
-} PutBitContext;
-
-static inline void init_put_bits(PutBitContext * pb, uint8_t * buf, int buffer_len) {
-    pb->total = buffer_len * 8;
-    pb->total_pos = 0;
-    pb->pos = 0;
-    pb->buf_ptr = buf;
-}
-
-static void put_bits(PutBitContext * pb, int bits, uint64_t val) {
-    if ((pb->total_pos += bits) >= pb->total) return;
-    if (!bits) return;
-    if (pb->pos) {
-        if (pb->pos > bits) {
-            *pb->buf_ptr |= val << (8 - pb->pos);
-            pb->pos -= bits;
-            bits = 0;
-        } else {
-            *pb->buf_ptr++ |= (val << (8 - pb->pos)) & 0xFF;
-            val >>= pb->pos;
-            bits -= pb->pos;
-            pb->pos = 0;
-        }
-    }
-    for (; bits >= 8; bits -= 8) {
-        *pb->buf_ptr++ = val & 0xFF;
-        val >>= 8;
-    }
-    if (bits) {
-        *pb->buf_ptr = val;
-        pb->pos = 8 - bits;
-    }
-}
 
-static inline void flush_put_bits(PutBitContext * pb) {
-}
-
-static inline int put_bits_count(PutBitContext * pb) {
-    return pb->total_pos;
-}
+    int64_t sample_count;
+} venc_context_t;
 
 static inline void put_codeword(PutBitContext * pb, codebook_t * cb, int entry) {
     assert(entry >= 0);
@@ -254,7 +213,7 @@ static void create_vorbis_context(venc_context_t * venc, AVCodecContext * avccon
     venc->sample_rate = avccontext->sample_rate;
     venc->log2_blocksize[0] = venc->log2_blocksize[1] = 11;
 
-    venc->ncodebooks = sizeof(cvectors)/sizeof(cvectors[0]);
+    venc->ncodebooks = FF_ARRAY_ELEMS(cvectors);
     venc->codebooks = av_malloc(sizeof(codebook_t) * venc->ncodebooks);
 
     // codebook 0..14 - floor1 book, values 0..255
@@ -1010,6 +969,8 @@ static int vorbis_encode_frame(AVCodecContext * avccontext, unsigned char * pack
 
     residue_encode(venc, &venc->residues[mapping->residue[mapping->mux[0]]], &pb, venc->coeffs, samples, venc->channels);
 
+    avccontext->coded_frame->pts = venc->sample_count;
+    venc->sample_count += avccontext->frame_size;
     flush_put_bits(&pb);
     return (put_bits_count(&pb) + 7) / 8;
 }