File: bool_encoder.hh

package info (click to toggle)
lepton 1.2.1+20170405-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 53,248 kB
  • ctags: 3,431
  • sloc: cpp: 24,345; ansic: 7,872; python: 330; makefile: 246; sh: 92; perl: 30
file content (35 lines) | stat: -rw-r--r-- 1,029 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef BOOL_ENCODER_HH
#define BOOL_ENCODER_HH

#include <vector>
#include <iostream>

#include <assert.h>
#include "branch.hh"
#include "../../io/MemReadWriter.hh"
#include "JpegArithmeticCoder.hh"
#include "vpx_bool_writer.hh"
/* Routines taken from ISO/IEC 10918-1 : 1993(E) */

class JpegBoolEncoder : public Sirikata::MemReadWriter {
    Sirikata::ArithmeticCoder jpeg_coder_;
public:
    JpegBoolEncoder(const Sirikata::JpegAllocator<unsigned char>&alloc=Sirikata::JpegAllocator<unsigned char>())
        : MemReadWriter(alloc), jpeg_coder_(true) {
    }
    void put( const bool value, Branch & branch ) {
        jpeg_coder_.arith_encode(this, &branch.probability_, value);
    }
    void finish(std::vector< uint8_t, Sirikata::JpegAllocator<unsigned char> >& retval) {
        jpeg_coder_.finish_encode(this);
        
        return retval.swap(buffer());
    }
};

#ifdef JPEG_ENCODER
class BoolEncoder : public JpegBoolEncoder{};
#else
class BoolEncoder : public VPXBoolWriter{};
#endif
#endif /* BOOL_ENCODER_HH */