Closed GoogleCodeExporter closed 9 years ago
Raising priority to reflect that this is really useful.
Ideally share the I420 code and only add a matrix parameter.
Original comment by fbarch...@google.com
on 12 Sep 2013 at 1:13
For matrix constants my tests show its faster to generate or pass them, than to
have them as static vectors. The vector can often be 32 bits and use pshufd to
splat it to the full register.
Original comment by fbarch...@google.com
on 2 Nov 2013 at 12:41
This is the matrix from jdcolor.c
* R = Y + 1.40200 * Cr
* G = Y - 0.34414 * Cb - 0.71414 * Cr
* B = Y + 1.77200 * Cb
Original comment by fbarch...@google.com
on 25 Oct 2014 at 12:07
Interested in J420ToARGB, J420ToABGR, J420ToRAW. Thanks a lot for your work on
libyuv.
Original comment by boris...@gmail.com
on 6 Nov 2014 at 9:47
I'll commit to J420ToARGB
but doing permutations of all formats would lead to code sprawl, so I'll at
least need to internally write the functions in a way that shares code with
different color matrix.
A 2nd step to convert ARGBToRAW etc can be done in place, or you can call the
low levels on a row by row basis.
This color space, which in theory should be used for motion jpeg on cameras,
may be what NV12 is using on Android?
Original comment by fbarch...@google.com
on 11 Dec 2014 at 7:44
C version is up for review. https://webrtc-codereview.appspot.com/32929004/
Original comment by fbarch...@google.com
on 25 Dec 2014 at 1:33
r1212 implements C version of J420ToARGB. Not well tested or optimized. This
is the reference code in row_common.cc
// C reference code that mimics the YUV assembly.
// * R = Y + 1.40200 * Cr
// * G = Y - 0.34414 * Cb - 0.71414 * Cr
// * B = Y + 1.77200 * Cb
#define YGJ 64 /* (int8)(1.000 * 64) */
#define UBJ 113 /* (int8)(1.772 * 64) */
#define UGJ -22 /* (int8)(-0.34414 * 64) */
#define URJ 0
#define VBJ 0
#define VGJ -46 /* (int8)(-0.71414 * 64) */
#define VRJ 90 /* (int8)(1.402 * 64) */
// Bias
#define BBJ UBJ * 128 + VBJ * 128
#define BGJ UGJ * 128 + VGJ * 128
#define BRJ URJ * 128 + VRJ * 128
static __inline void YuvJPixel(uint8 y, uint8 u, uint8 v,
uint8* b, uint8* g, uint8* r) {
int32 y1 = ((int32)(y)) * YGJ;
*b = Clamp((int32)((u * UBJ + v * VBJ) - (BBJ) + y1) >> 6);
*g = Clamp((int32)((u * UGJ + v * VGJ) - (BGJ) + y1) >> 6);
*r = Clamp((int32)((u * URJ + v * VRJ) - (BRJ) + y1) >> 6);
}
void J422ToARGBRow_C(const uint8* src_y,
const uint8* src_u,
const uint8* src_v,
uint8* rgb_buf,
int width) {
int x;
for (x = 0; x < width - 1; x += 2) {
YuvJPixel(src_y[0], src_u[0], src_v[0],
rgb_buf + 0, rgb_buf + 1, rgb_buf + 2);
rgb_buf[3] = 255;
YuvJPixel(src_y[1], src_u[0], src_v[0],
rgb_buf + 4, rgb_buf + 5, rgb_buf + 6);
rgb_buf[7] = 255;
src_y += 2;
src_u += 1;
src_v += 1;
rgb_buf += 8; // Advance 2 pixels.
}
if (width & 1) {
YuvJPixel(src_y[0], src_u[0], src_v[0],
rgb_buf + 0, rgb_buf + 1, rgb_buf + 2);
rgb_buf[3] = 255;
}
}
Original comment by fbarch...@google.com
on 29 Dec 2014 at 7:22
Anyone able to confirm that J420ToARGB is working as expected?
Original comment by fbarch...@google.com
on 12 Jan 2015 at 5:45
wrote 2 tests - TestI420 and TestJ420. The conversion works with 2 caveats.
I420 is less accurate than J420. error of 6 for I420 vs 3 for J420.
subsampling introduces high difference. test does 2x2 pixels to test only the
colorspace.
The conversion is working but not optimized.
Original comment by fbarch...@google.com
on 13 Jan 2015 at 10:28
I can confirm that J420ToARGB works as expected. Comparing with libjpeg-turbo,
I see differences of 1-2.
Original comment by boris...@gmail.com
on 20 Feb 2015 at 10:29
Original issue reported on code.google.com by
fbarch...@google.com
on 3 Jun 2013 at 4:57