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

Open Mash Cross Reference
mash/codec/decoder-jpeg.h

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

  1 /*
  2  * decoder-jpeg.h --
  3  *
  4  *      Motion Jpeg decoder 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 
 34 /* @(#) $Header: /usr/mash/src/repository/mash/mash-1/codec/decoder-jpeg.h,v 1.13 2002/02/03 03:13:33 lim Exp $ */
 35 
 36 #include "jpeg/jpeg.h"
 37 
 38 
 39 class JpegReassembler {
 40 public:
 41     JpegReassembler();
 42     ~JpegReassembler();
 43 
 44     u_char* reassemble(const rtphdr* rh, const u_char* bp, int& len);
 45 #ifdef ERROR_RECOVERY
 46     u_char* recoverReassem(const rtphdr* rh, const u_char* bp, int& len,
 47                            u_int32_t restartInterval, u_int32_t restartCount);
 48 #endif
 49 
 50     inline int badoff() const { return (badoff_); }
 51     inline int hugefrm() const { return (hugefrm_); }
 52 
 53 protected:
 54     int decimate_;
 55     int ndec_;
 56 
 57     /*
 58      * slots_ is a table of recently received packets
 59      * used in reassemble() to determine when we have
 60      * received a complete frame.
 61      */
 62 #define MAX_JPEG_SLOTS 1024
 63     int nslots_;
 64     int slotmask_;
 65     struct slot {
 66         int seqno;
 67         int eof;        /* nbytes in last pkt of frame, of
 68                          * 0 if not last pkt of frame */
 69         u_int32_t off;
 70         u_int32_t ts;
 71     }* slots_;
 72 
 73     /*
 74      * Reassembly buffers.  We do double-buffering, which allows
 75      * packets to arrive out of order across frame boundaries,
 76      * but not across an entire frame (i.e., we don't want to see
 77      * any packets from frame k+2 until we're done with frame k).
 78      * We use RTP timestamps to keep track of which frame is
 79      * allocated to which buffer.  (RTP guarantees that the
 80      * timestamps are constant across a frame, and increase
 81      * between succesive frames.  FIXME is latter really true?)
 82      */
 83     struct rbuf {
 84         int drop;
 85         u_int32_t ts;
 86         u_char* bp;
 87         u_char* current;
 88         u_int32_t restartInterval; // Size of the restart marker intervals
 89         u_int32_t restartCount;    // Number of restart markers seen before
 90         // this packet of the frame
 91         int len;
 92     };
 93 
 94 #ifdef ERROR_RECOVERY
 95     bool advancePrevPtr(rbuf* curr, rbuf * prev);
 96     bool recoverFromPrev(rbuf * curr, rbuf * prev, int recoverto);
 97 #endif
 98         
 99     rbuf rb0_;
100     rbuf rb1_;
101     int rbsize_;
102     int hugefrm_;
103     int badoff_;
104 
105     /* The 2 pointers for recovery purpose.  The current_ pointer is the
106      * location of the current data input.  The prev_ pointer is the
107      * location of the current data input of the previous frame
108      */
109     rbuf *current_;
110     rbuf *prev_;
111     bool doneodd;  // See if a complete odd frame is done
112 };
113 
114 
115 class MotionJpegDecoder : public Decoder {
116 public:
117     MotionJpegDecoder();
118     virtual ~MotionJpegDecoder();
119     int colorhist(u_int* hist) const;
120     virtual void stats(char* wrk);
121 
122     virtual int command(int argc, const char*const* argv);
123     
124 protected:
125     virtual void recv(pktbuf*);
126     virtual void redraw();
127 
128     int drop_even_;     // only used with fields, if non-zero, then
129                         // drop even fields and line double odd fields
130     int badtype_;
131 
132     // input quantization
133     int inq_;
134 
135     // JPEG/RTP parameters type code
136     int type_;
137 
138     // Length of jpeg restart interval
139     u_int32_t restart_interval_;
140 
141     // Number of jpeg restart marker has past
142     u_int32_t restart_count_;
143 
144     void configure();
145     JpegPixelDecoder* codec_;
146     JpegDecoder::config config_;
147     JpegReassembler reasm_;
148 };
149 

~ [ 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.