forked from mia/Aegisub
added ClampSignedInteger32() to utils and used that to remove branching from YV12->RGB32 conversion, hopefully making it faster. Also, fixed a warning in lavc audio provider.
Originally committed to SVN as r988.
This commit is contained in:
parent
29923cb8e1
commit
0568af7ce0
3 changed files with 35 additions and 13 deletions
|
@ -111,7 +111,7 @@ LAVCAudioProvider::LAVCAudioProvider(wxString _filename)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
audStream = -1;
|
audStream = -1;
|
||||||
for (int i = 0; i < lavcfile->fctx->nb_streams; i++) {
|
for (unsigned int i = 0; i < lavcfile->fctx->nb_streams; i++) {
|
||||||
codecContext = lavcfile->fctx->streams[i]->codec;
|
codecContext = lavcfile->fctx->streams[i]->codec;
|
||||||
if (codecContext->codec_type == CODEC_TYPE_AUDIO) {
|
if (codecContext->codec_type == CODEC_TYPE_AUDIO) {
|
||||||
stream = lavcfile->fctx->streams[i];
|
stream = lavcfile->fctx->streams[i];
|
||||||
|
|
|
@ -57,15 +57,6 @@ void AppendBitmapMenuItem (wxMenu* parentMenu,int id,wxString text,wxString help
|
||||||
int SmallestPowerOf2(int x);
|
int SmallestPowerOf2(int x);
|
||||||
|
|
||||||
|
|
||||||
///////////
|
|
||||||
// Inlines
|
|
||||||
inline void IntSwap(int &a,int &b) {
|
|
||||||
int c = a;
|
|
||||||
a = b;
|
|
||||||
b = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////
|
//////////
|
||||||
// Macros
|
// Macros
|
||||||
#ifndef MIN
|
#ifndef MIN
|
||||||
|
@ -79,3 +70,34 @@ inline void IntSwap(int &a,int &b) {
|
||||||
#ifndef MID
|
#ifndef MID
|
||||||
#define MID(a,b,c) MAX((a),MIN((b),(c)))
|
#define MID(a,b,c) MAX((a),MIN((b),(c)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef FORCEINLINE
|
||||||
|
#ifdef __VISUALC__
|
||||||
|
#define FORCEINLINE __forceinline
|
||||||
|
#else
|
||||||
|
#define FORCEINLINE __attribute__((always_inline))
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
///////////
|
||||||
|
// Inlines
|
||||||
|
inline void IntSwap(int &a,int &b) {
|
||||||
|
int c = a;
|
||||||
|
a = b;
|
||||||
|
b = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////
|
||||||
|
// Clamp integer to range
|
||||||
|
// Code taken from http://bob.allegronetwork.com/prog/tricks.html#clamp
|
||||||
|
FORCEINLINE int ClampSignedInteger32(int x,int min,int max) {
|
||||||
|
x -= min;
|
||||||
|
x &= (~x) >> 31;
|
||||||
|
x += min;
|
||||||
|
x -= max;
|
||||||
|
x &= x >> 31;
|
||||||
|
x += max;
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
|
@ -299,9 +299,9 @@ void AegiVideoFrame::ConvertFrom(const AegiVideoFrame &source) {
|
||||||
y = (*src_y++ - 16) * 298;
|
y = (*src_y++ - 16) * 298;
|
||||||
|
|
||||||
// Assign
|
// Assign
|
||||||
*dst++ = MID(0,(y + 516 * u + 128) >> 8,255); // Blue
|
*dst++ = ClampSignedInteger32((y + 516 * u + 128) >> 8,0,255); // Blue
|
||||||
*dst++ = MID(0,(y - 100 * u - 208 * v + 128) >> 8,255); // Green
|
*dst++ = ClampSignedInteger32((y - 100 * u - 208 * v + 128) >> 8,0,255); // Green
|
||||||
*dst++ = MID(0,(y + 409 * v + 128) >> 8,255); // Red
|
*dst++ = ClampSignedInteger32((y + 409 * v + 128) >> 8,0,255); // Red
|
||||||
*dst++ = 0;
|
*dst++ = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue