ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/freemol/trunk/src/mpeg_encode/src/fsize.c
Revision: 22
Committed: Mon Jul 7 22:16:37 2008 UTC (14 years ago) by wdelano
File size: 3585 byte(s)
Log Message:
initial checkin of mpeg_encode source
Line User Rev File contents
1 wdelano 22 /*===========================================================================*
2     * fsize.c *
3     * *
4     * procedures to keep track of frame size *
5     * *
6     * EXPORTED PROCEDURES: *
7     * Fsize_Reset *
8     * Fsize_Note *
9     * Fsize_Validate *
10     * *
11     * EXPORTED VARIABLES: *
12     * Fsize_x *
13     * Fsize_y *
14     * *
15     *===========================================================================*/
16    
17     /*
18     * Copyright (c) 1995 The Regents of the University of California.
19     * All rights reserved.
20     *
21     * Permission to use, copy, modify, and distribute this software and its
22     * documentation for any purpose, without fee, and without written agreement is
23     * hereby granted, provided that the above copyright notice and the following
24     * two paragraphs appear in all copies of this software.
25     *
26     * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
27     * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
28     * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
29     * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30     *
31     * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
32     * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
33     * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
34     * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
35     * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
36     */
37    
38    
39     /*==============*
40     * HEADER FILES *
41     *==============*/
42    
43     #include "all.h"
44     #include "fsize.h"
45     #include "dct.h"
46    
47    
48     /*==================*
49     * GLOBAL VARIABLES *
50     *==================*/
51     int Fsize_x = 0;
52     int Fsize_y = 0;
53    
54    
55     /*=====================*
56     * EXPORTED PROCEDURES *
57     *=====================*/
58    
59     /*===========================================================================*
60     *
61     * Fsize_Reset
62     *
63     * reset the frame size to 0
64     *
65     * RETURNS: nothing
66     *
67     * SIDE EFFECTS: Fsize_x, Fsize_y
68     *
69     *===========================================================================*/
70     void
71     Fsize_Reset()
72     {
73     Fsize_x = Fsize_y = 0;
74     }
75    
76    
77     /*===========================================================================*
78     *
79     * Fsize_Validate
80     *
81     * make sure that the x, y values are 16-pixel aligned
82     *
83     * RETURNS: modifies the x, y values to 16-pixel alignment
84     *
85     * SIDE EFFECTS: none
86     *
87     *===========================================================================*/
88     void
89     Fsize_Validate(x, y)
90     int *x;
91     int *y;
92     {
93     *x &= ~(DCTSIZE * 2 - 1);
94     *y &= ~(DCTSIZE * 2 - 1);
95     }
96    
97    
98     /*===========================================================================*
99     *
100     * Fsize_Note
101     *
102     * note the given frame size and modify the global values as appropriate
103     *
104     * RETURNS: nothing
105     *
106     * SIDE EFFECTS: Fsize_x, Fsize_y
107     *
108     *===========================================================================*/
109     void
110     Fsize_Note(id, width, height)
111     int id;
112     int width;
113     int height;
114     {
115     Fsize_x = width;
116     Fsize_y = height;
117     Fsize_Validate(&Fsize_x, &Fsize_y);
118    
119     if ((Fsize_x==0) || (Fsize_y==0)) {
120     fprintf(stderr,"Frame %d: size is zero!\n",id);
121     /* exit(1); */
122     }
123    
124     #ifdef BLEAH
125     if (Fsize_x == 0) {
126     Fsize_x = width;
127     Fsize_y = height;
128     Fsize_Validate(&Fsize_x, &Fsize_y);
129     } else if (width < Fsize_x || height < Fsize_y) {
130     fprintf(stderr, "Frame %d: wrong size: (%d,%d). Should be greater or equal to: (%d,%d)\n",
131     id, width, height, Fsize_x, Fsize_y);
132     exit(1);
133     }
134     #endif
135     }