Commit 4be2f3a2 authored by ameko asa's avatar ameko asa
Browse files

uncap resolution, remove vis check/alsa support

parent c609ba48
......@@ -156,10 +156,8 @@ int cal_header(float cnt_freq, float dat_freq, float drate)
return 0;
}
int decode(int *reset, struct img **img, char *img_name, float cnt_freq, float dat_freq, float drate)
int decode(int *reset, struct img **img, char *img_name, float cnt_freq, float dat_freq, float drate, int width, int height)
{
const int width = 320;
const int height = 240;
const double sync_porch_sec = 0.003l;
const double porch_sec = 0.0015l;
const double y_sec = 0.088l;
......@@ -413,10 +411,20 @@ int main(int argc, char **argv)
struct pcm *pcm;
char *pcm_name = "default";
char *img_name = 0;
if (argc != 1)
int width = 320;
int height = 240;
if (argc < 2) {
fprintf(stderr, "usage: %s <input.wav> <output.ppm> <width> <height>\n", argv[0]);
return 1;
}
if (argc > 1)
pcm_name = argv[1];
if (argc == 3)
if (argc > 2)
img_name = argv[2];
if (argc > 3)
width = atoi(argv[3]);
if (argc > 4)
height = atoi(argv[4]);
if (!open_pcm_read(&pcm, pcm_name))
return 1;
......@@ -456,11 +464,11 @@ int main(int argc, char **argv)
int code = 0;
if (!vis_code(&vis_reset, &code, cnt_freq, drate))
continue;
if (0x88 != code) {
/*if (0x88 != code) {
fprintf(stderr, "%s got unsupported VIS 0x%x, ignoring\n", string_time("%F %T"), code);
vis_mode = 0;
continue;
}
}*/
fprintf(stderr, "%s got VIS = 0x%x\n", string_time("%F %T"), code);
dat_mode = 1;
dat_reset = 1;
......@@ -468,7 +476,7 @@ int main(int argc, char **argv)
}
if (dat_mode) {
if (decode(&dat_reset, &img, img_name, cnt_freq, dat_freq, drate))
if (decode(&dat_reset, &img, img_name, cnt_freq, dat_freq, drate, width, height))
dat_mode = 0;
}
}
......
......@@ -78,10 +78,11 @@ void odd_seperator()
}
void y_scan(int y)
{
float n = (float)img->width;
for (int ticks = 0; ticks < y_len; ticks++) {
float xf = fclampf((320.0 * ticks) / (float)y_len, 0.0, 319.0);
float xf = fclampf((n * ticks) / (float)y_len, 0.0, n - 1.0);
int x0 = xf;
int x1 = fclampf(x0 + 1, 0.0, 319.0);
int x1 = fclampf(x0 + 1, 0.0, n - 1.0);
int off0 = 3 * y * img->width + 3 * x0;
int off1 = 3 * y * img->width + 3 * x1;
float R0 = linear(img->pixel[off0 + 0]);
......@@ -99,10 +100,11 @@ void y_scan(int y)
void v_scan(int y)
{
float n = ((float)img->width) / 2.0;
for (int ticks = 0; ticks < uv_len; ticks++) {
float xf = fclampf((160.0 * ticks) / (float)uv_len, 0.0, 159.0);
float xf = fclampf((n * ticks) / (float)uv_len, 0.0, n - 1.0);
int x0 = xf;
int x1 = fclampf(x0 + 1, 0.0, 159.0);
int x1 = fclampf(x0 + 1, 0.0, n - 1.0);
int evn0 = 3 * y * img->width + 6 * x0;
int evn1 = 3 * y * img->width + 6 * x1;
int odd0 = 3 * (y + 1) * img->width + 6 * x0;
......@@ -121,10 +123,11 @@ void v_scan(int y)
}
void u_scan(int y)
{
float n = ((float)img->width) / 2.0;
for (int ticks = 0; ticks < uv_len; ticks++) {
float xf = fclampf((160.0 * ticks) / (float)uv_len, 0.0, 159.0);
float xf = fclampf((n * ticks) / (float)uv_len, 0.0, n - 1.0);
int x0 = xf;
int x1 = fclampf(x0 + 1, 0.0, 159.0);
int x1 = fclampf(x0 + 1, 0.0, n - 1.0);
int evn0 = 3 * (y - 1) * img->width + 6 * x0;
int evn1 = 3 * (y - 1) * img->width + 6 * x1;
int odd0 = 3 * y * img->width + 6 * x0;
......@@ -152,18 +155,19 @@ int main(int argc, char **argv)
if (!open_img_read(&img, argv[1]))
return 1;
if (320 != img->width || 240 != img->height) {
/*if (320 != img->width || 240 != img->height) {
fprintf(stderr, "image not 320x240\n");
close_img(img);
return 1;
}
}*/
char *pcm_name = "default";
if (argc > 2)
pcm_name = argv[2];
if (argc > 3)
rate = atoi(argv[3]);
if (!open_pcm_write(&pcm, pcm_name, rate, 1, 37.5))
float p = ((float)img->height / 240.0) * 37.5;
if (!open_pcm_write(&pcm, pcm_name, rate, 1, p))
return 1;
rate = rate_pcm(pcm);
......
......@@ -10,7 +10,7 @@ You should have received a copy of the CC0 Public Domain Dedication along with t
#include <string.h>
#include <stdlib.h>
#include "pcm.h"
#include "alsa.h"
//#include "alsa.h"
#include "wav.h"
void close_pcm(struct pcm *pcm)
......@@ -45,8 +45,8 @@ int write_pcm(struct pcm *pcm, short *buff, int frames)
int open_pcm_read(struct pcm **p, char *name)
{
if (strstr(name, "plughw:") == name || strstr(name, "hw:") == name || strstr(name, "default") == name)
return open_alsa_read(p, name);
//if (strstr(name, "plughw:") == name || strstr(name, "hw:") == name || strstr(name, "default") == name)
//return open_alsa_read(p, name);
if (strstr(name, ".wav") == (name + (strlen(name) - strlen(".wav"))))
return open_wav_read(p, name);
return 0;
......@@ -54,8 +54,8 @@ int open_pcm_read(struct pcm **p, char *name)
int open_pcm_write(struct pcm **p, char *name, int rate, int channels, float seconds)
{
if (strstr(name, "plughw:") == name || strstr(name, "hw:") == name || strstr(name, "default") == name)
return open_alsa_write(p, name, rate, channels, seconds);
//if (strstr(name, "plughw:") == name || strstr(name, "hw:") == name || strstr(name, "default") == name)
//return open_alsa_write(p, name, rate, channels, seconds);
if (strstr(name, ".wav") == (name + (strlen(name) - strlen(".wav"))))
return open_wav_write(p, name, rate, channels, seconds);
return 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment