1 /*
2 * crdef.h --
3 *
4 * The bit definitions for the values stored in the conditional
5 * replenishment vector.
6 *
7 * Copyright (c) 1993-2002 The Regents of the University of California.
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 *
13 * A. Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * B. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * C. Neither the names of the copyright holders nor the names of its
19 * contributors may be used to endorse or promote products derived from this
20 * software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
23 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *
34 * @(#) $Header: /usr/mash/src/repository/mash/mash-1/codec/crdef.h,v 1.9 2002/02/03 03:13:32 lim Exp $
35 */
36
37 /*
38 * The bit definitions for the values stored in the conditional
39 * replenishment vector. We use a variant of the algorithm used
40 * in nv (which is very similar to the algorithms in many hardware
41 * codecs) where we only send a block if it changes beyond some threshold
42 * due to scene motion. In this case, we send it at a "low-quality"
43 * to trade of quality for frame rate in areas of high motion.
44 * We then age the block and after it hasn't changed for a few frames
45 * we send a higher quality version. Finally, the process that scans
46 * the background filling in blocks sends the highest quality version.
47 *
48 * A finite state machine defines the algorithm. When motion is detected,
49 * the block is reset to state MOTION. On no motion, it is aged to AGE1,
50 * AGE2, ... etc., until it reaches state AGEn (the age threshold), and
51 * then it transitions to IDLE. If the background process finds a block
52 * in the IDLE state, it can promote it to the BG state. On the next
53 * frame, it reverts to the IDLE state.
54 *
55 * Blocks are transmitted only in the MOTION, AGEn, and BG state,
56 * at low, medium, and high quality, respectively. The high bit
57 * is reserved to indicate the block is in one of these states
58 * and should be sent.
59 */
60
61 #ifndef mash_crdef_h
62 #define mash_crdef_h
63
64 #include "config.h"
65 #include <sys/types.h>
66
67 #define CR_SEND 0xc0
68 #define CR_LQ 0x40
69 #define CR_MQ 0x80
70 #define CR_HQ 0xc0
71 #define CR_QUALITY(s) ((s) & CR_SEND)
72
73 #define CR_AGE_BIT 0x20
74 #define CR_MOTION_BIT 0x10
75 /*
76 * The threshold for aging a block. This value cannot
77 * be larger than 15 without changing the layout of
78 * CR record (i.e., it would need to otherwise be wider)
79 */
80 #define CR_AGETHRESH 15
81
82
83 class ConditionalReplenisher {
84 public:
85 ConditionalReplenisher();
86 ~ConditionalReplenisher();
87 void crinit(int w, int h);
88 int age_blocks();
89 void send_all();
90 void mark_all_send();
91 inline void fillrate(int v) { idle_high_ = v; }
92 protected:
93 int get_level();
94 int frmno_;
95 int blkw_;
96 int blkh_;
97 int scan_;
98 int nblk_;
99 u_char* crvec_;
100 int rover_;
101 private:
102 int idle_low_;
103 int idle_high_;
104
105 };
106
107 #endif /* mash_crdef_h */
108
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.