oops: fix double swap mistake of u & v and r & b

in robot36 v is on even lines and u is on odd lines
in robot72 v comes first, then u

still need to investigate why there is a discrepancy between renderscript rgba and java bitmap rgba
pull/6/head
Ahmet Inan 2014-12-05 15:53:13 +01:00
rodzic e5da88f27f
commit 5c0dd886ab
2 zmienionych plików z 22 dodań i 23 usunięć

Wyświetl plik

@ -33,6 +33,11 @@ uchar *value_buffer;
uchar4 *pixel_buffer;
static inline uchar4 rgb(uchar r, uchar g, uchar b) { return (uchar4){ b, g, r, 255 }; }
static inline uchar4 yuv(uchar y, uchar u, uchar v)
{
uchar4 bgra = rsYuvToRGBA_uchar4(y, u, v);
return rgb(bgra[0], bgra[1], bgra[2]);
}
static void reset()
{
@ -54,11 +59,11 @@ static void robot36_decoder()
if (vpos & 1) {
for (int i = 0; i < bitmap_width; ++i) {
uchar even_y = value_buffer[i * (y_end-y_begin) / bitmap_width + y_begin];
uchar u = value_buffer[i * (u_end-u_begin) / bitmap_width + u_begin];
uchar v = value_buffer[i * (v_end-v_begin) / bitmap_width + v_begin];
uchar odd_y = value_buffer[i * (y_end-y_begin) / bitmap_width + even_hpos + y_begin];
uchar v = value_buffer[i * (v_end-v_begin) / bitmap_width + even_hpos + v_begin];
pixel_buffer[bitmap_width * (vpos-1) + i] = rsYuvToRGBA_uchar4(even_y, u, v);
pixel_buffer[bitmap_width * vpos + i] = rsYuvToRGBA_uchar4(odd_y, u, v);
uchar u = value_buffer[i * (u_end-u_begin) / bitmap_width + even_hpos + u_begin];
pixel_buffer[bitmap_width * (vpos-1) + i] = yuv(even_y, u, v);
pixel_buffer[bitmap_width * vpos + i] = yuv(odd_y, u, v);
}
if (prev_timeout)
hpos -= scanline_length;
@ -82,7 +87,7 @@ static void yuv_decoder()
uchar y = value_buffer[i * (y_end-y_begin) / bitmap_width + y_begin];
uchar u = value_buffer[i * (u_end-u_begin) / bitmap_width + u_begin];
uchar v = value_buffer[i * (v_end-v_begin) / bitmap_width + v_begin];
pixel_buffer[bitmap_width * vpos + i] = rsYuvToRGBA_uchar4(y, u, v);
pixel_buffer[bitmap_width * vpos + i] = yuv(y, u, v);
}
if (hpos >= maximum_length)
hpos -= scanline_length;

Wyświetl plik

@ -58,21 +58,16 @@ void robot36_mode()
const float sync_porch_seconds = 0.003f;
const float sep_porch_seconds = 0.0015f;
const float y_scan_seconds = 0.088f;
const float u_scan_seconds = 0.044f;
const float v_scan_seconds = 0.044f;
const float uv_scan_seconds = 0.044f;
const float seperator_seconds = 0.0045f;
seperator_length = seperator_seconds * sample_rate;
sync_length = tolerance * sync_seconds * sample_rate;
y_begin = (sync_porch_seconds - settling_time) * sample_rate;
y_end = y_begin + y_scan_seconds * sample_rate;
u_sep_begin = y_end;
u_sep_end = u_sep_begin + seperator_seconds * sample_rate;
u_begin = u_sep_end + sep_porch_seconds * sample_rate;
u_end = u_begin + u_scan_seconds * sample_rate;
v_sep_begin = u_sep_begin;
v_sep_end = u_sep_end;
v_begin = v_sep_end + sep_porch_seconds * sample_rate;
v_end = v_begin + v_scan_seconds * sample_rate;
u_sep_begin = v_sep_begin = y_end;
u_sep_end = v_sep_end = u_sep_begin + seperator_seconds * sample_rate;
u_begin = v_begin = u_sep_end + sep_porch_seconds * sample_rate;
u_end = v_end = u_begin + uv_scan_seconds * sample_rate;
scanline_length = robot36_scanline_length;
maximum_length = scanline_length + sync_porch_seconds * sample_rate;
}
@ -87,21 +82,20 @@ void robot72_mode()
const float sync_porch_seconds = 0.003f;
const float sep_porch_seconds = 0.0015f;
const float y_scan_seconds = 0.138f;
const float u_scan_seconds = 0.069f;
const float v_scan_seconds = 0.069f;
const float uv_scan_seconds = 0.069f;
const float seperator_seconds = 0.0045f;
seperator_length = seperator_seconds * sample_rate;
sync_length = tolerance * sync_seconds * sample_rate;
y_begin = (sync_porch_seconds - settling_time) * sample_rate;
y_end = y_begin + y_scan_seconds * sample_rate;
u_sep_begin = y_end;
u_sep_end = u_sep_begin + seperator_seconds * sample_rate;
u_begin = u_sep_end + sep_porch_seconds * sample_rate;
u_end = u_begin + u_scan_seconds * sample_rate;
v_sep_begin = u_end;
v_sep_begin = y_end;
v_sep_end = v_sep_begin + seperator_seconds * sample_rate;
v_begin = v_sep_end + sep_porch_seconds * sample_rate;
v_end = v_begin + v_scan_seconds * sample_rate;
v_end = v_begin + uv_scan_seconds * sample_rate;
u_sep_begin = v_end;
u_sep_end = u_sep_begin + seperator_seconds * sample_rate;
u_begin = u_sep_end + sep_porch_seconds * sample_rate;
u_end = u_begin + uv_scan_seconds * sample_rate;
scanline_length = robot72_scanline_length;
maximum_length = scanline_length + sync_porch_seconds * sample_rate;
}