mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[android] fix yuv conversion - remove define (#50951)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/50951 Test Plan: Imported from OSS Reviewed By: fmassa Differential Revision: D26021488 Pulled By: IvanKobzarev fbshipit-source-id: 6d295762bb1160a3ed8bafac08e03e1eeb07d688
This commit is contained in:
committed by
Facebook GitHub Bot
parent
8ab1a1495d
commit
c908ebd4a1
@ -4,8 +4,6 @@
|
||||
|
||||
#include "jni.h"
|
||||
|
||||
#define clamp0255(x) x > 255 ? 255 : x < 0 ? 0 : x
|
||||
|
||||
namespace pytorch_vision_jni {
|
||||
|
||||
static void imageYUV420CenterCropToFloatBuffer(
|
||||
@ -112,9 +110,12 @@ static void imageYUV420CenterCropToFloatBuffer(
|
||||
ri = (a0 + 1634 * vi) >> 10;
|
||||
gi = (a0 - 833 * vi - 400 * ui) >> 10;
|
||||
bi = (a0 + 2066 * ui) >> 10;
|
||||
outData[wr++] = (clamp0255(ri) - normMeanRm255) / normStdRm255;
|
||||
outData[wg++] = (clamp0255(gi) - normMeanGm255) / normStdGm255;
|
||||
outData[wb++] = (clamp0255(bi) - normMeanBm255) / normStdBm255;
|
||||
ri = ri > 255 ? 255 : ri < 0 ? 0 : ri;
|
||||
gi = gi > 255 ? 255 : gi < 0 ? 0 : gi;
|
||||
bi = bi > 255 ? 255 : bi < 0 ? 0 : bi;
|
||||
outData[wr++] = (ri - normMeanRm255) / normStdRm255;
|
||||
outData[wg++] = (gi - normMeanGm255) / normStdGm255;
|
||||
outData[wb++] = (bi - normMeanBm255) / normStdBm255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user