1 /*
2 * encoder-jpeg.h --
3 *
4 * Motion Jpeg video encoder header file
5 *
6 * Copyright (c) 1994-2002 The Regents of the University of California.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 * A. Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 * B. Redistributions in binary form must reproduce the above copyright notice,
15 * this list of conditions and the following disclaimer in the documentation
16 * and/or other materials provided with the distribution.
17 * C. Neither the names of the copyright holders nor the names of its
18 * contributors may be used to endorse or promote products derived from this
19 * software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
22 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 #include "tclcl.h"
35 #include "module.h"
36
37 #ifdef INT_64
38 #define NBIT 64
39 #define BB_INT INT_64
40 #else
41 #define NBIT 32
42 #define BB_INT u_int
43 #endif
44
45
46 class JpegEncoder : public EncoderModule {
47 public:
48 JpegEncoder();
49 void setq(int q);
50 void size(int w, int h);
51 void recv(Buffer*);
52
53 struct huffentry {
54 u_short val;
55 u_short nb;
56 };
57
58 protected:
59 int command(int argc, const char*const* argv);
60
61 virtual int flush(pktbuf* pb, int nbit, pktbuf* npb);
62 virtual int encode(const VideoFrame*);
63 void encode_blk(const short* blk, short* dcpred,
64 struct JpegEncoder::huffentry* dcht,
65 struct JpegEncoder::huffentry* acht);
66 void encode_mcu(u_int mcu, const u_char* frm);
67 void fdct(const u_char* in, int stride, short* out, const float* qt);
68
69 /* bit buffer */
70 BB_INT bb_;
71 u_int nbb_;
72
73 u_char* bs_;
74 u_char* bc_;
75
76 u_char quant_;
77 float lqt_[64];
78 float cqt_[64];
79
80 short lpred_; // dc predictors
81 short crpred_;
82 short cbpred_;
83
84 u_int nmcu_;
85 u_char w_; /* divided by 8 */
86 u_char h_;
87 };
88
89
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.