now able to enable / disable interpolation / decimation

master
Ahmet Inan 2011-09-26 13:24:23 +02:00
rodzic 39b7fa3b8e
commit bf05c488aa
3 zmienionych plików z 40 dodań i 5 usunięć

Wyświetl plik

@ -1,5 +1,5 @@
CFLAGS = -D_GNU_SOURCE=1 -W -Wall -O3 -std=c99 -ffast-math
CFLAGS = -DUP=1 -DDN=1 -D_GNU_SOURCE=1 -W -Wall -O3 -std=c99 -ffast-math
LDFLAGS = -lm -lasound
all: encode decode debug

20
debug.c
Wyświetl plik

@ -81,12 +81,23 @@ int main(int argc, char **argv)
int evn_count = 0;
int first_hor_sync = 0;
#if DN && UP
// 320 / 0.088 = 160 / 0.044 = 40000 / 11 = 3636.(36)~ pixels per second for Y, U and V
int64_t factor_L = 40000;
int64_t factor_M = 11 * rate;
int64_t factor_D = gcd(factor_L, factor_M);
factor_L /= factor_D;
factor_M /= factor_D;
#endif
#if DN && !UP
int64_t factor_L = 1;
// factor_M * step should be smaller than pixel length
int64_t factor_M = rate * 0.088 / 320.0;
#endif
#if !DN
int64_t factor_L = 1;
int64_t factor_M = 1;
#endif
// we want odd number of taps, 4 and 2 ms window length gives best results
int cnt_taps = 1 | (int)(rate * factor_L * 0.004);
@ -192,10 +203,11 @@ int main(int argc, char **argv)
begin_vis_hi = vis_hi ? 0 : begin_vis_hi;
static int ticks = 0;
printf("%f %f %f %d %d %d %d %d %d %d %d\n", (float)ticks++ * dstep, dat_freq, cnt_freq,
50*hor_sync+950, 50*cal_leader+850, 50*cal_break+750,
50*vis_ss+650, 50*vis_lo+550, 50*vis_hi+450,
50*sep_evn+350, 50*sep_odd+250);
if (ticks++ < 5.0 * drate)
printf("%f %f %f %d %d %d %d %d %d %d %d\n", (float)ticks * dstep, dat_freq, cnt_freq,
50*hor_sync+950, 50*cal_leader+850, 50*cal_break+750,
50*vis_ss+650, 50*vis_lo+550, 50*vis_hi+450,
50*sep_evn+350, 50*sep_odd+250);
if (cal_leader && !cal_break && got_cal_break &&
cal_ticks >= (int)(drate * (cal_leader_len + cal_break_len) * leader_tolerance) &&

Wyświetl plik

@ -25,9 +25,21 @@ void process_line(uint8_t *pixel, uint8_t *y_pixel, uint8_t *uv_pixel, int y_wid
if (n % 2)
for (int y = n-1, l = 0; l < 2 && y < height; l++, y++) {
for (int x = 0; x < width; x++) {
#if DN && UP
uint8_t Y = y_pixel[x + l*y_width];
uint8_t U = uv_pixel[x/2 + uv_width];
uint8_t V = uv_pixel[x/2];
#else
float y_xf = (float)x * (float)y_width / (float)width;
float uv_xf = (float)x * (float)uv_width / (float)width;
int y_x0 = y_xf;
int uv_x0 = uv_xf;
int y_x1 = fclampf(0, y_width, y_xf + 1);
int uv_x1 = fclampf(0, uv_width, uv_xf + 1);
uint8_t Y = flerpf(y_pixel[y_x0 + l*y_width], y_pixel[y_x1 + l*y_width], y_xf - (float)y_x0);
uint8_t U = flerpf(uv_pixel[uv_x0 + uv_width], uv_pixel[uv_x1 + uv_width], uv_xf - (float)uv_x0);
uint8_t V = flerpf(uv_pixel[uv_x0], uv_pixel[uv_x1], uv_xf - (float)uv_x0);
#endif
uint8_t *p = pixel + 3 * width * y + 3 * x;
p[0] = R_YUV(Y, U, V);
p[1] = G_YUV(Y, U, V);
@ -98,12 +110,23 @@ int main(int argc, char **argv)
int evn_count = 0;
int first_hor_sync = 0;
#if DN && UP
// 320 / 0.088 = 160 / 0.044 = 40000 / 11 = 3636.(36)~ pixels per second for Y, U and V
int64_t factor_L = 40000;
int64_t factor_M = 11 * rate;
int64_t factor_D = gcd(factor_L, factor_M);
factor_L /= factor_D;
factor_M /= factor_D;
#endif
#if DN && !UP
int64_t factor_L = 1;
// factor_M * step should be smaller than pixel length
int64_t factor_M = rate * 0.088 / 320.0;
#endif
#if !DN
int64_t factor_L = 1;
int64_t factor_M = 1;
#endif
// we want odd number of taps, 4 and 2 ms window length gives best results
int cnt_taps = 1 | (int)(rate * factor_L * 0.004);