Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 274305
Collapse All | Expand All

(-)svgalib-1.9.25/utils/gtf/gtfcalc.c (-16 / +18 lines)
Lines 64-70 Link Here
64
64
65
/*-------------------------- Implementation -------------------------------*/
65
/*-------------------------- Implementation -------------------------------*/
66
66
67
static double round(double v)
67
static double svg_round(double v);
68
69
double svg_round(double v)
68
{
70
{
69
	return floor(v + 0.5);
71
	return floor(v + 0.5);
70
}
72
}
Lines 84-92 Link Here
84
****************************************************************************/
86
****************************************************************************/
85
{
87
{
86
	c->margin = GC.margin;
88
	c->margin = GC.margin;
87
	c->cellGran = round(GC.cellGran);
89
	c->cellGran = svg_round(GC.cellGran);
88
	c->minPorch = round(GC.minPorch);
90
	c->minPorch = svg_round(GC.minPorch);
89
	c->vSyncRqd = round(GC.vSyncRqd);
91
	c->vSyncRqd = svg_round(GC.vSyncRqd);
90
	c->hSync = GC.hSync;
92
	c->hSync = GC.hSync;
91
	c->minVSyncBP = GC.minVSyncBP;
93
	c->minVSyncBP = GC.minVSyncBP;
92
	if (GC.k == 0)
94
	if (GC.k == 0)
Lines 140-152 Link Here
140
	vFreq = hFreq = dotClock = freq;
142
	vFreq = hFreq = dotClock = freq;
141
143
142
	/* Round pixels to character cell granularity */
144
	/* Round pixels to character cell granularity */
143
	hPixels = round(hPixels / c.cellGran) * c.cellGran;
145
	hPixels = svg_round(hPixels / c.cellGran) * c.cellGran;
144
146
145
	/* For interlaced mode halve the vertical parameters, and double
147
	/* For interlaced mode halve the vertical parameters, and double
146
	 * the required field refresh rate.
148
	 * the required field refresh rate.
147
	 */
149
	 */
148
	if (wantInterlace) {
150
	if (wantInterlace) {
149
		vLines = round(vLines / 2);
151
		vLines = svg_round(vLines / 2);
150
		vFieldRate = vFreq * 2;
152
		vFieldRate = vFreq * 2;
151
		dotClock = dotClock * 2;
153
		dotClock = dotClock * 2;
152
		interlace = 0.5;
154
		interlace = 0.5;
Lines 158-165 Link Here
158
160
159
	/* Determine the lines for margins */
161
	/* Determine the lines for margins */
160
	if (wantMargins) {
162
	if (wantMargins) {
161
		topMarginLines = round(c.margin / 100 * vLines);
163
		topMarginLines = svg_round(c.margin / 100 * vLines);
162
		botMarginLines = round(c.margin / 100 * vLines);
164
		botMarginLines = svg_round(c.margin / 100 * vLines);
163
		}
165
		}
164
	else {
166
	else {
165
		topMarginLines = 0;
167
		topMarginLines = 0;
Lines 173-183 Link Here
173
				(vLines + (2*topMarginLines) + c.minPorch + interlace) * 1000000;
175
				(vLines + (2*topMarginLines) + c.minPorch + interlace) * 1000000;
174
176
175
			/* Find the number of lines in vSync + back porch */
177
			/* Find the number of lines in vSync + back porch */
176
			vSyncBP = round(c.minVSyncBP / hPeriodEst);
178
			vSyncBP = svg_round(c.minVSyncBP / hPeriodEst);
177
			}
179
			}
178
		else if (type == GTF_lockHF) {
180
		else if (type == GTF_lockHF) {
179
			/* Find the number of lines in vSync + back porch */
181
			/* Find the number of lines in vSync + back porch */
180
			vSyncBP = round((c.minVSyncBP * hFreq) / 1000);
182
			vSyncBP = svg_round((c.minVSyncBP * hFreq) / 1000);
181
			}
183
			}
182
184
183
		/* Find the number of lines in the V back porch alone */
185
		/* Find the number of lines in the V back porch alone */
Lines 205-212 Link Here
205
207
206
	/* Find the number of pixels in the left and right margins */
208
	/* Find the number of pixels in the left and right margins */
207
	if (wantMargins) {
209
	if (wantMargins) {
208
		leftMarginPixels = round(hPixels * c.margin) / (100 * c.cellGran);
210
		leftMarginPixels = svg_round(hPixels * c.margin) / (100 * c.cellGran);
209
		rightMarginPixels = round(hPixels * c.margin) / (100 * c.cellGran);
211
		rightMarginPixels = svg_round(hPixels * c.margin) / (100 * c.cellGran);
210
		}
212
		}
211
	else {
213
	else {
212
		leftMarginPixels = 0;
214
		leftMarginPixels = 0;
Lines 235-251 Link Here
235
		}
237
		}
236
238
237
	/* Find the number of pixels in blanking time */
239
	/* Find the number of pixels in blanking time */
238
	hBlankPixels = round((hTotalActivePixels * idealDutyCycle) /
240
	hBlankPixels = svg_round((hTotalActivePixels * idealDutyCycle) /
239
		((100 - idealDutyCycle) * 2 * c.cellGran)) * (2 * c.cellGran);
241
		((100 - idealDutyCycle) * 2 * c.cellGran)) * (2 * c.cellGran);
240
242
241
	/* Find the total number of pixels */
243
	/* Find the total number of pixels */
242
	hTotalPixels = hTotalActivePixels + hBlankPixels;
244
	hTotalPixels = hTotalActivePixels + hBlankPixels;
243
245
244
	/* Find the horizontal back porch */
246
	/* Find the horizontal back porch */
245
	hBackPorch = round((hBlankPixels / 2) / c.cellGran) * c.cellGran;
247
	hBackPorch = svg_round((hBlankPixels / 2) / c.cellGran) * c.cellGran;
246
248
247
	/* Find the horizontal sync width */
249
	/* Find the horizontal sync width */
248
	hSyncWidth = round(((c.hSync/100) * hTotalPixels) / c.cellGran) * c.cellGran;
250
	hSyncWidth = svg_round(((c.hSync/100) * hTotalPixels) / c.cellGran) * c.cellGran;
249
251
250
	/* Find the horizontal sync + back porch */
252
	/* Find the horizontal sync + back porch */
251
	hSyncBP = hBackPorch + hSyncWidth;
253
	hSyncBP = hBackPorch + hSyncWidth;
Lines 258-264 Link Here
258
		hPeriod = 1000 / hFreq;
260
		hPeriod = 1000 / hFreq;
259
261
260
		/* Find the number of lines in vSync + back porch */
262
		/* Find the number of lines in vSync + back porch */
261
		vSyncBP = round((c.minVSyncBP * hFreq) / 1000);
263
		vSyncBP = svg_round((c.minVSyncBP * hFreq) / 1000);
262
264
263
		/* Find the number of lines in the V back porch alone */
265
		/* Find the number of lines in the V back porch alone */
264
		vBackPorch = vSyncBP - c.vSyncRqd;
266
		vBackPorch = vSyncBP - c.vSyncRqd;

Return to bug 274305