~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Open Mash Cross Reference
mash/codec/p64/p64.h

Component: ~ [ mash ] ~ [ apps ] ~ [ gsm ] ~ [ lib ] ~ [ otcl ] ~ [ srm ] ~ [ tcl8.3 ] ~ [ tclcl ] ~ [ tk8.3 ] ~ [ tutorials ] ~

  1 /*
  2  * p64.h --
  3  *
  4  *      P64 header file.
  5  *
  6  * Copyright (c) 1993-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  * @(#) $Header: /usr/mash/src/repository/mash/mash-1/codec/p64/p64.h,v 1.8 2002/04/25 01:17:35 lim Exp $
 34  */
 35 
 36 #ifndef lib_p64_h
 37 #define lib_p64_h
 38 
 39 #include <sys/types.h>
 40 
 41 struct huffcode;
 42 
 43 #define MBPERGOB 33
 44 
 45 class P64Decoder {
 46     public:
 47         virtual ~P64Decoder();
 48         u_char* frame() const { return (back_); }
 49 
 50         // ndblk() returns the number of blocks decoded. The P64 codec counts 
 51         //      macroblocks, though. Therefore we have to multiply times the number 
 52         //      of blocks per macroblock (6, i.e. 4Y, 1U, and 1V)
 53         inline int ndblk() const { return (6*ndmblk_); }
 54         inline void resetndblk() { ndmblk_ = 0; }
 55 
 56         inline int width() const { return (width_); }
 57         inline int height() const { return (height_); }
 58         virtual int decode(const u_char* bp, int cc,
 59                            int sbit, int ebit, int mba, int gob,
 60                            int quant, int mvdh, int mvdv);
 61         virtual void sync();
 62         inline void bb(int& x, int& y, int& w, int& h) {
 63                 x = bbx_; y = bby_; w = bbw_; h = bbh_;
 64         };
 65         inline u_int bad_psc() const { return (bad_psc_); }
 66         inline u_int bad_bits() const { return (bad_bits_); }
 67         inline u_int bad_GOBno() const { return (bad_GOBno_); }
 68         inline u_int bad_fmt() const { return (bad_fmt_); }
 69         inline int seenMaxGob() const { return (maxgob_ >= ngob_ - 1); }
 70         inline u_int gobquant() const { return (gobquant_); }
 71 
 72         inline void marks(u_char* p) { marks_ = p; }
 73         inline void mark(int v) { mark_ = v; }
 74     protected:
 75         P64Decoder();
 76         void init();
 77         virtual void allocate() = 0;
 78         void inithuff();
 79         void initquant();
 80         virtual void err(const char* msg ...) const;
 81         int quantize(int v, int q);
 82 #ifdef INT_64
 83         int parse_block(short* blk, INT_64* mask);
 84 #else
 85         int parse_block(short* blk, u_int* mask);
 86 #endif
 87         void decode_block(u_int tc, u_int x, u_int y, u_int stride,
 88                           u_char* front, u_char* back, int sf);
 89         void filter(u_char* in, u_char* out, u_int stride);
 90         void mvblk(u_char* in, u_char* out, u_int stride);
 91         void mvblka(u_char*, u_char*, u_int stride);
 92 
 93         int parse_picture_hdr();
 94         int parse_sc();
 95         int parse_gob_hdr(int);
 96         int parse_mb_hdr(u_int& cbp);
 97         int decode_gob(u_int gob);
 98         int decode_mb();
 99 
100         u_int size_;
101         u_char* fs_;
102         u_char* front_;
103         u_char* back_;
104 
105         struct hufftab {
106                 int maxlen;
107                 const short* prefix;
108         };
109         hufftab ht_mba_;
110         hufftab ht_mvd_;
111         hufftab ht_cbp_;
112         hufftab ht_tcoeff_;
113         hufftab ht_mtype_;
114 
115         u_int bb_;              /* 32-bit bit buffer */
116         int nbb_;               /* number bits in bit buffer */
117         const u_short* bs_;     /* input bit stream (less bits in bb_) */
118         const u_short* es_;     /* pointer to end if input stream */
119         const u_short* ps_;     /* packet start (for error reporting) */
120         int pebit_;             /* packet end bit (for error reporting) */
121 
122 #define MBST_FRESH      0
123 #define MBST_OLD        1
124 #define MBST_NEW        2
125         u_char* mbst_;
126         short* qt_;
127         u_short* coord_;
128 
129         u_int width_;           /* width of Y component */
130         u_int height_;          /* height of Y component */
131 
132 #define IT_QCIF 0
133 #define IT_CIF  1
134         u_int fmt_;             /* image format (CIF/QCIF) */
135         u_int ngob_;            /* number of gobs (12 for CIF, 3 for QCIF) */
136         u_int maxgob_;          /* max gob seen this frame */
137         int ndmblk_;            /* number of decoded macroblocks. As H.261 is always 4:2:0, 
138                            one macroblock is composed of 6 8x8-pixels blocks, 
139                            4 Y, 1 U, and 1 V */
140         u_int gobquant_;        /* last gob quantizer (for info funtion) */
141 
142         u_int mt_;              /* macroblock type (flags in p64-huff.h) */
143         u_int gob_;             /* current gob index */
144         int mba_;               /* macroblock address (predictor) */
145         int mvdh_;              /* motion vector (predictor) */
146         int mvdv_;              /* motion vector (predictor) */
147 
148         /* bounding box */
149         u_int minx_;
150         u_int miny_;
151         u_int maxx_;
152         u_int maxy_;
153         u_int bbx_;
154         u_int bby_;
155         u_int bbw_;
156         u_int bbh_;
157 
158         /*
159          * Table to indicate which blocks have changed.
160          */
161         u_char* marks_;
162         int mark_;
163 
164         /* error counters */
165         int bad_psc_;
166         int bad_bits_;
167         int bad_GOBno_;
168         int bad_fmt_;           /* # times RTP fmt != H.261 fmt */
169 
170         u_char mb_state_[16 * 64];
171         /* inverse quantization via table lookup */
172         short quant_[32 * 256];
173         /* gob/mba to coordinate mappings */
174         u_short base_[16 * 64];
175 };
176 
177 class FullP64Decoder : public P64Decoder {
178     public:
179         FullP64Decoder();
180     protected:
181         virtual void allocate();
182         void mbcopy(u_int mba);
183         void swap();
184         virtual void sync();
185 };
186 
187 class IntraP64Decoder : public P64Decoder {
188     public:
189         IntraP64Decoder();
190     protected:
191         virtual void allocate();
192 };
193 
194 #endif
195 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.