1 /* $Id: runlength.h,v 1.1 2010/02/07 14:07:25 fredette Exp $ */
2 
3 /* tme/runlength.h - header file for run length: */
4 
5 /*
6  * Copyright (c) 2010 Matt Fredette
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
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *      This product includes software developed by Matt Fredette.
20  * 4. The name of the author may not be used to endorse or promote products
21  *    derived from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 #ifndef _TME_RUNLENGTH_H
37 #define _TME_RUNLENGTH_H
38 
39 #include <tme/common.h>
40 _TME_RCSID("$Id: runlength.h,v 1.1 2010/02/07 14:07:25 fredette Exp $");
41 
42 /* types: */
43 
44 /* a runlength value: */
45 typedef tme_uint32_t tme_runlength_t;
46 
47 /* the runlength state: */
48 struct tme_runlength {
49 
50   /* the runlength history count: */
51   unsigned int tme_runlength_history_count;
52 
53   /* the runlength history: */
54   tme_runlength_t *_tme_runlength_history;
55 
56   /* the next position in the runlength history: */
57   unsigned int _tme_runlength_history_next;
58 
59   /* the runlength history sum: */
60   double _tme_runlength_history_sum;
61 
62   /* the runlength cycles target: */
63   double _tme_runlength_cycles_elapsed_target;
64 
65   /* the start time of the run: */
66   union tme_value64 tme_runlength_cycles_start;
67 
68   /* the current runlength value: */
69   tme_runlength_t tme_runlength_value;
70 };
71 
72 /* prototypes: */
73 
74 /* this initializes runlength state: */
75 void tme_runlength_init _TME_P((struct tme_runlength *));
76 
77 /* this sets the runlength cycles target: */
78 void tme_runlength_target_cycles _TME_P((struct tme_runlength *, union tme_value64));
79 
80 /* this updates the runlength: */
81 void tme_runlength_update _TME_P((struct tme_runlength *));
82 
83 #endif /* !_TME_RUNLENGTH_H */
84