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:
Rodrigo Braz Monteiro 2007-04-03 21:05:33 +00:00
parent 29923cb8e1
commit 0568af7ce0
3 changed files with 35 additions and 13 deletions

View File

@ -111,7 +111,7 @@ LAVCAudioProvider::LAVCAudioProvider(wxString _filename)
}
#endif
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;
if (codecContext->codec_type == CODEC_TYPE_AUDIO) {
stream = lavcfile->fctx->streams[i];

View File

@ -57,15 +57,6 @@ void AppendBitmapMenuItem (wxMenu* parentMenu,int id,wxString text,wxString help
int SmallestPowerOf2(int x);
///////////
// Inlines
inline void IntSwap(int &a,int &b) {
int c = a;
a = b;
b = c;
}
//////////
// Macros
#ifndef MIN
@ -79,3 +70,34 @@ inline void IntSwap(int &a,int &b) {
#ifndef MID
#define MID(a,b,c) MAX((a),MIN((b),(c)))
#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;
}

View File

@ -299,9 +299,9 @@ void AegiVideoFrame::ConvertFrom(const AegiVideoFrame &source) {
y = (*src_y++ - 16) * 298;
// Assign
*dst++ = MID(0,(y + 516 * u + 128) >> 8,255); // Blue
*dst++ = MID(0,(y - 100 * u - 208 * v + 128) >> 8,255); // Green
*dst++ = MID(0,(y + 409 * v + 128) >> 8,255); // Red
*dst++ = ClampSignedInteger32((y + 516 * u + 128) >> 8,0,255); // Blue
*dst++ = ClampSignedInteger32((y - 100 * u - 208 * v + 128) >> 8,0,255); // Green
*dst++ = ClampSignedInteger32((y + 409 * v + 128) >> 8,0,255); // Red
*dst++ = 0;
}
}