History

postproc/postprocess_template: Compute packedYScale and QPCorrecture without floats

Michael Niedermayer committed 11 years ago

Commit ebe919c1 parent c41e0ae1 file · +5 −5Browse files

Showing the changes to libpostproc (1 of 1 file). Show all

Unified · Split

libpostproc/postprocess_template.c+5−5
@@ -3372,7 +3372,7 @@ static void RENAME(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[ · 3371 unmodified lines
33723372 int i;
33733373 uint64_t maxClipped;
33743374 uint64_t clipped;
3375− double scale;
3375+ AVRational scale;
33763376
33773377 c.frameNum++;
33783378 // first frame is fscked so we ignore it
@@ -3397,13 +3397,13 @@ static void RENAME(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[ · 18 unmodified lines
33973397 clipped-= yHistogram[white];
33983398 }
33993399
3400− scale= (double)(c.ppMode.maxAllowedY - c.ppMode.minAllowedY) / (double)(white-black);
3400+ scale = (AVRational){c.ppMode.maxAllowedY - c.ppMode.minAllowedY, white - black};
34013401
34023402 #if TEMPLATE_PP_MMXEXT
3403− c.packedYScale= (uint16_t)(scale*256.0 + 0.5);
3403+ c.packedYScale = (uint16_t)av_rescale(scale.num, 256, scale.den);
34043404 c.packedYOffset= (((black*c.packedYScale)>>8) - c.ppMode.minAllowedY) & 0xFFFF;
34053405 #else
3406− c.packedYScale= (uint16_t)(scale*1024.0 + 0.5);
3406+ c.packedYScale = (uint16_t)av_rescale(scale.num, 1024, scale.den);
34073407 c.packedYOffset= (black - c.ppMode.minAllowedY) & 0xFFFF;
34083408 #endif
34093409
@@ -3413,7 +3413,7 @@ static void RENAME(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[ · 3 unmodified lines
34133413 c.packedYScale|= c.packedYScale<<32;
34143414 c.packedYScale|= c.packedYScale<<16;
34153415
3416− if(mode & LEVEL_FIX) QPCorrecture= (int)(scale*256*256 + 0.5);
3416+ if(mode & LEVEL_FIX) QPCorrecture= (int)av_rescale(scale.num, 256*256, scale.den);
34173417 else QPCorrecture= 256*256;
34183418 }else{
34193419 c.packedYScale= 0x0100010001000100LL;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t