Skip to content

Commit

Permalink
DVD/Bluray: Use qBound instead of std::clamp
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-kendall committed Apr 9, 2020
1 parent 0fc7abb commit 490e0b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions mythtv/libs/libmythtv/Bluray/bdringbuffer.cpp
Expand Up @@ -65,9 +65,9 @@ void BDOverlay::SetPalette(const BD_PG_PALETTE_ENTRY *Palette)
int cr = Palette[i].Cr;
int cb = Palette[i].Cb;
int a = Palette[i].T;
int r = std::clamp(int(y + 1.4022 * (cr - 128)), 0, 0xff);
int b = std::clamp(int(y + 1.7710 * (cb - 128)), 0, 0xff);
int g = std::clamp(int(1.7047 * y - (0.1952 * b) - (0.5647 * r)), 0, 0xff);
int r = qBound(0, int(y + 1.4022 * (cr - 128)), 0xff);
int b = qBound(0, int(y + 1.7710 * (cb - 128)), 0xff);
int g = qBound(0, int(1.7047 * y - (0.1952 * b) - (0.5647 * r)), 0xff);
rgbpalette.push_back(static_cast<uint>((a << 24) | (r << 16) | (g << 8) | b));
}
m_image.setColorTable(rgbpalette);
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythtv/DVD/mythdvdbuffer.cpp
Expand Up @@ -1995,9 +1995,9 @@ void MythDVDBuffer::GuessPalette(uint32_t *RGBAPalette, const uint8_t *Palette,
uint y = (yuv >> 16) & 0xff;
uint cr = (yuv >> 8) & 0xff;
uint cb = (yuv >> 0) & 0xff;
uint r = std::clamp(uint(y + 1.4022 * (cr - 128)), 0U, 0xFFU);
uint b = std::clamp(uint(y + 1.7710 * (cb - 128)), 0U, 0xFFU);
uint g = std::clamp(uint(1.7047 * y - (0.1952 * b) - (0.5647 * r)), 0U, 0xFFU);
uint r = qBound(0U, uint(y + 1.4022 * (cr - 128)), 0xFFU);
uint b = qBound(0U, uint(y + 1.7710 * (cb - 128)), 0xFFU);
uint g = qBound(0U, uint(1.7047 * y - (0.1952 * b) - (0.5647 * r)), 0xFFU);
RGBAPalette[i] = ((Alpha[i] * 17U) << 24) | (r << 16 )| (g << 8) | b;
}
}
Expand Down

0 comments on commit 490e0b1

Please sign in to comment.