more sensible names for scanline parameters

pull/11/head
Oona Räisänen 2015-07-17 10:05:53 +03:00
rodzic 7dc9a17709
commit 714ca8b6c1
6 zmienionych plików z 70 dodań i 70 usunięć

Wyświetl plik

@ -84,7 +84,7 @@ void saveCurrentPic() {
printf(" Saving to %s\n", pngfilename->str);
scaledpb = gdk_pixbuf_scale_simple (pixbuf_rx, ModeSpec[CurrentPic.Mode].ImgWidth,
ModeSpec[CurrentPic.Mode].ImgHeight * ModeSpec[CurrentPic.Mode].YScale, GDK_INTERP_HYPER);
ModeSpec[CurrentPic.Mode].NumLines * ModeSpec[CurrentPic.Mode].LineHeight, GDK_INTERP_HYPER);
ensure_dir_exists(g_key_file_get_string(config,"slowrx","rxdir",NULL));
gdk_pixbuf_savev(scaledpb, pngfilename->str, "png", NULL, NULL, NULL);
@ -176,7 +176,7 @@ void evt_clickimg(GtkWidget *widget, GdkEventButton* event, GdkWindowEdge edge)
if (event->type == GDK_BUTTON_PRESS && event->button == 1 && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(gui.tog_setedge))) {
x = event->x * (ModeSpec[CurrentPic.Mode].ImgWidth / 500.0);
y = event->y * (ModeSpec[CurrentPic.Mode].ImgWidth / 500.0) / ModeSpec[CurrentPic.Mode].YScale;
y = event->y * (ModeSpec[CurrentPic.Mode].ImgWidth / 500.0) / ModeSpec[CurrentPic.Mode].LineHeight;
if (secondpress) {
secondpress=FALSE;
@ -187,7 +187,7 @@ void evt_clickimg(GtkWidget *widget, GdkEventButton* event, GdkWindowEdge edge)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(gui.tog_setedge),FALSE);
// Adjust sample rate, if in sensible limits
newrate = CurrentPic.Rate + CurrentPic.Rate * (dx * ModeSpec[CurrentPic.Mode].PixelLen) / (dy * ModeSpec[CurrentPic.Mode].YScale * ModeSpec[CurrentPic.Mode].LineLen);
newrate = CurrentPic.Rate + CurrentPic.Rate * (dx * ModeSpec[CurrentPic.Mode].PixelLen) / (dy * ModeSpec[CurrentPic.Mode].LineHeight * ModeSpec[CurrentPic.Mode].LineLen);
if (newrate > 32000 && newrate < 56000) {
CurrentPic.Rate = newrate;

Wyświetl plik

@ -115,8 +115,8 @@ typedef struct ModeSpec {
double PixelLen;
double LineLen;
gushort ImgWidth;
gushort ImgHeight;
guchar YScale;
gushort NumLines;
guchar LineHeight;
guchar ColorEnc;
} _ModeSpec;

Wyświetl plik

@ -18,8 +18,8 @@
* PixelLen Duration of one pixel in seconds
* LineLen Time in seconds from the beginning of a sync pulse to the beginning of the next one
* ImgWidth Pixels per scanline
* ImgHeight Number of scanlines
* YScale Height of one scanline in pixels (1 or 2)
* Lines Number of scanlines
* LineHeight Height of one scanline in pixels (1 or 2)
* ColorEnc Color format (GBR, RGB, YUV, BW)
*
*
@ -45,8 +45,8 @@ _ModeSpec ModeSpec[] = {
.PixelLen = 0.4576e-3,
.LineLen = 446.446e-3,
.ImgWidth = 320,
.ImgHeight = 256,
.YScale = 1,
.NumLines = 256,
.LineHeight = 1,
.ColorEnc = GBR },
[M2] = { // N7CXI, 2000
@ -58,8 +58,8 @@ _ModeSpec ModeSpec[] = {
.PixelLen = 0.2288e-3,
.LineLen = 226.7986e-3,
.ImgWidth = 320,
.ImgHeight = 256,
.YScale = 1,
.NumLines = 256,
.LineHeight = 1,
.ColorEnc = GBR },
[M3] = { // KB4YZ, 1999
@ -71,8 +71,8 @@ _ModeSpec ModeSpec[] = {
.PixelLen = 0.2288e-3,
.LineLen = 446.446e-3,
.ImgWidth = 320,
.ImgHeight = 128,
.YScale = 2,
.NumLines = 128,
.LineHeight = 2,
.ColorEnc = GBR },
[M4] = { // KB4YZ, 1999
@ -84,8 +84,8 @@ _ModeSpec ModeSpec[] = {
.PixelLen = 0.2288e-3,
.LineLen = 226.7986e-3,
.ImgWidth = 320,
.ImgHeight = 128,
.YScale = 2,
.NumLines = 128,
.LineHeight = 2,
.ColorEnc = GBR },
[S1] = { // N7CXI, 2000
@ -97,8 +97,8 @@ _ModeSpec ModeSpec[] = {
.PixelLen = 0.4320e-3,
.LineLen = 428.38e-3,
.ImgWidth = 320,
.ImgHeight = 256,
.YScale = 1,
.NumLines = 256,
.LineHeight = 1,
.ColorEnc = GBR },
[S2] = { // N7CXI, 2000
@ -110,8 +110,8 @@ _ModeSpec ModeSpec[] = {
.PixelLen = 0.2752e-3,
.LineLen = 277.692e-3,
.ImgWidth = 320,
.ImgHeight = 256,
.YScale = 1,
.NumLines = 256,
.LineHeight = 1,
.ColorEnc = GBR },
[SDX] = { // N7CXI, 2000
@ -123,8 +123,8 @@ _ModeSpec ModeSpec[] = {
.PixelLen = 1.08053e-3,
.LineLen = 1050.3e-3,
.ImgWidth = 320,
.ImgHeight = 256,
.YScale = 1,
.NumLines = 256,
.LineHeight = 1,
.ColorEnc = GBR },
[R72] = { // N7CXI, 2000
@ -136,8 +136,8 @@ _ModeSpec ModeSpec[] = {
.PixelLen = 0.2875e-3,
.LineLen = 300e-3,
.ImgWidth = 320,
.ImgHeight = 240,
.YScale = 1,
.NumLines = 240,
.LineHeight = 1,
.ColorEnc = YUV },
[R36] = { // N7CXI, 2000
@ -149,8 +149,8 @@ _ModeSpec ModeSpec[] = {
.PixelLen = 0.1375e-3,
.LineLen = 150e-3,
.ImgWidth = 320,
.ImgHeight = 240,
.YScale = 1,
.NumLines = 240,
.LineHeight = 1,
.ColorEnc = YUV },
[R24] = { // N7CXI, 2000
@ -162,8 +162,8 @@ _ModeSpec ModeSpec[] = {
.PixelLen = 0.1375e-3,
.LineLen = 150e-3,
.ImgWidth = 320,
.ImgHeight = 240,
.YScale = 1,
.NumLines = 240,
.LineHeight = 1,
.ColorEnc = YUV },
[R24BW] = { // N7CXI, 2000
@ -175,8 +175,8 @@ _ModeSpec ModeSpec[] = {
.PixelLen = 0.291e-3,
.LineLen = 100e-3,
.ImgWidth = 320,
.ImgHeight = 240,
.YScale = 1,
.NumLines = 240,
.LineHeight = 1,
.ColorEnc = BW },
[R12BW] = { // N7CXI, 2000
@ -188,8 +188,8 @@ _ModeSpec ModeSpec[] = {
.PixelLen = 0.291e-3,
.LineLen = 100e-3,
.ImgWidth = 320,
.ImgHeight = 120,
.YScale = 2,
.NumLines = 120,
.LineHeight = 2,
.ColorEnc = BW },
[R8BW] = { // N7CXI, 2000
@ -201,8 +201,8 @@ _ModeSpec ModeSpec[] = {
.PixelLen = 0.188e-3,
.LineLen = 67e-3,
.ImgWidth = 320,
.ImgHeight = 120,
.YScale = 2,
.NumLines = 120,
.LineHeight = 2,
.ColorEnc = BW },
[W2120] = { // KB4YZ, 1999
@ -214,8 +214,8 @@ _ModeSpec ModeSpec[] = {
.PixelLen = 0.489039081e-3,
.LineLen = 475.530018e-3,
.ImgWidth = 320,
.ImgHeight = 256,
.YScale = 1,
.NumLines = 256,
.LineHeight = 1,
.ColorEnc = RGB },
[W2180] = { // N7CXI, 2000
@ -227,8 +227,8 @@ _ModeSpec ModeSpec[] = {
.PixelLen = 0.734532e-3,
.LineLen = 711.0225e-3,
.ImgWidth = 320,
.ImgHeight = 256,
.YScale = 1,
.NumLines = 256,
.LineHeight = 1,
.ColorEnc = RGB },
[PD50] = { // N7CXI, 2000
@ -240,8 +240,8 @@ _ModeSpec ModeSpec[] = {
.PixelLen = 0.286e-3,
.LineLen = 388.16e-3,
.ImgWidth = 320,
.ImgHeight = 256,
.YScale = 1,
.NumLines = 256,
.LineHeight = 1,
.ColorEnc = YUV },
[PD90] = { // N7CXI, 2000
@ -253,8 +253,8 @@ _ModeSpec ModeSpec[] = {
.PixelLen = 0.532e-3,
.LineLen = 703.04e-3,
.ImgWidth = 320,
.ImgHeight = 256,
.YScale = 1,
.NumLines = 256,
.LineHeight = 1,
.ColorEnc = YUV },
[PD120] = { // N7CXI, 2000
@ -266,8 +266,8 @@ _ModeSpec ModeSpec[] = {
.PixelLen = 0.19e-3,
.LineLen = 508.48e-3,
.ImgWidth = 640,
.ImgHeight = 496,
.YScale = 1,
.NumLines = 496,
.LineHeight = 1,
.ColorEnc = YUV },
[PD160] = { // N7CXI, 2000
@ -279,8 +279,8 @@ _ModeSpec ModeSpec[] = {
.PixelLen = 0.382e-3,
.LineLen = 804.416e-3,
.ImgWidth = 512,
.ImgHeight = 400,
.YScale = 1,
.NumLines = 400,
.LineHeight = 1,
.ColorEnc = YUV },
[PD180] = { // N7CXI, 2000
@ -292,8 +292,8 @@ _ModeSpec ModeSpec[] = {
.PixelLen = 0.286e-3,
.LineLen = 754.24e-3,
.ImgWidth = 640,
.ImgHeight = 496,
.YScale = 1,
.NumLines = 496,
.LineHeight = 1,
.ColorEnc = YUV },
[PD240] = { // N7CXI, 2000
@ -305,8 +305,8 @@ _ModeSpec ModeSpec[] = {
.PixelLen = 0.382e-3,
.LineLen = 1000e-3,
.ImgWidth = 640,
.ImgHeight = 496,
.YScale = 1,
.NumLines = 496,
.LineHeight = 1,
.ColorEnc = YUV },
[PD290] = { // N7CXI, 2000
@ -318,8 +318,8 @@ _ModeSpec ModeSpec[] = {
.PixelLen = 0.286e-3,
.LineLen = 937.28e-3,
.ImgWidth = 800,
.ImgHeight = 616,
.YScale = 1,
.NumLines = 616,
.LineHeight = 1,
.ColorEnc = YUV },
[P3] = { // N7CXI, 2000
@ -331,8 +331,8 @@ _ModeSpec ModeSpec[] = {
.PixelLen = 0.2083e-3,
.LineLen = 409.375e-3,
.ImgWidth = 640,
.ImgHeight = 496,
.YScale = 1,
.NumLines = 496,
.LineHeight = 1,
.ColorEnc = RGB },
[P5] = { // N7CXI, 2000
@ -344,8 +344,8 @@ _ModeSpec ModeSpec[] = {
.PixelLen = 0.3125e-3,
.LineLen = 614.065e-3,
.ImgWidth = 640,
.ImgHeight = 496,
.YScale = 1,
.NumLines = 496,
.LineHeight = 1,
.ColorEnc = RGB },
[P7] = { // N7CXI, 2000
@ -357,8 +357,8 @@ _ModeSpec ModeSpec[] = {
.PixelLen = 0.4167e-3,
.LineLen = 818.747e-3,
.ImgWidth = 640,
.ImgHeight = 496,
.YScale = 1,
.NumLines = 496,
.LineHeight = 1,
.ColorEnc = RGB }
};

Wyświetl plik

@ -83,14 +83,14 @@ void *Listen() {
// Allocate space for cached Lum
free(StoredLum);
StoredLum = calloc( (int)((ModeSpec[CurrentPic.Mode].LineLen * ModeSpec[CurrentPic.Mode].ImgHeight + 1) * 44100), sizeof(guchar));
StoredLum = calloc( (int)((ModeSpec[CurrentPic.Mode].LineLen * ModeSpec[CurrentPic.Mode].NumLines + 1) * 44100), sizeof(guchar));
if (StoredLum == NULL) {
perror("Listen: Unable to allocate memory for Lum");
exit(EXIT_FAILURE);
}
// Allocate space for sync signal
HasSync = calloc((int)(ModeSpec[CurrentPic.Mode].LineLen * ModeSpec[CurrentPic.Mode].ImgHeight / (13.0/44100) +1), sizeof(gboolean));
HasSync = calloc((int)(ModeSpec[CurrentPic.Mode].LineLen * ModeSpec[CurrentPic.Mode].NumLines / (13.0/44100) +1), sizeof(gboolean));
if (HasSync == NULL) {
perror("Listen: Unable to allocate memory for sync signal");
exit(EXIT_FAILURE);
@ -154,7 +154,7 @@ void *Listen() {
// Add thumbnail to iconview
CurrentPic.thumbbuf = gdk_pixbuf_scale_simple (pixbuf_rx, 100,
100.0/ModeSpec[CurrentPic.Mode].ImgWidth * ModeSpec[CurrentPic.Mode].ImgHeight * ModeSpec[CurrentPic.Mode].YScale, GDK_INTERP_HYPER);
100.0/ModeSpec[CurrentPic.Mode].ImgWidth * ModeSpec[CurrentPic.Mode].NumLines * ModeSpec[CurrentPic.Mode].LineHeight, GDK_INTERP_HYPER);
gdk_threads_enter ();
gtk_list_store_prepend (savedstore, &iter);
gtk_list_store_set (savedstore, &iter, 0, CurrentPic.thumbbuf, 1, id, -1);
@ -169,7 +169,7 @@ void *Listen() {
LumFile = fopen(lumfilename,"w");
if (LumFile == NULL)
perror("Unable to open luma file for writing");
fwrite(StoredLum,1,(ModeSpec[Mode].LineLen * ModeSpec[Mode].ImgHeight) * 44100,LumFile);
fwrite(StoredLum,1,(ModeSpec[Mode].LineLen * ModeSpec[Mode].NumLines) * 44100,LumFile);
fclose(LumFile);*/
saveCurrentPic();

6
sync.c
Wyświetl plik

@ -34,7 +34,7 @@ double FindSync (guchar Mode, double Rate, int *Skip) {
// Draw the 2D sync signal at current rate
for (y=0; y<ModeSpec[Mode].ImgHeight; y++) {
for (y=0; y<ModeSpec[Mode].NumLines; y++) {
for (x=0; x<LineWidth; x++) {
t = (y + 1.0*x/LineWidth) * ModeSpec[Mode].LineLen;
SyncImg[x][y] = HasSync[ (int)( t * Rate / 13.0) ];
@ -47,7 +47,7 @@ double FindSync (guchar Mode, double Rate, int *Skip) {
memset(lines, 0, sizeof(lines[0][0]) * (MAXSLANT-MINSLANT)*2 * 600);
// Find white pixels
for (cy = 0; cy < ModeSpec[Mode].ImgHeight; cy++) {
for (cy = 0; cy < ModeSpec[Mode].NumLines; cy++) {
for (cx = 0; cx < LineWidth; cx++) {
if (SyncImg[cx][cy]) {
@ -95,7 +95,7 @@ double FindSync (guchar Mode, double Rate, int *Skip) {
// accumulate a 1-dim array of the position of the sync pulse
memset(xAcc, 0, sizeof(xAcc[0]) * 700);
for (y=0; y<ModeSpec[Mode].ImgHeight; y++) {
for (y=0; y<ModeSpec[Mode].NumLines; y++) {
for (x=0; x<700; x++) {
t = y * ModeSpec[Mode].LineLen + x/700.0 * ModeSpec[Mode].LineLen;
xAcc[x] += HasSync[ (int)(t / (13.0/44100) * Rate/44100) ];

12
video.c
Wyświetl plik

@ -47,7 +47,7 @@ gboolean GetVideo(guchar Mode, double Rate, int Skip, gboolean Redraw) {
} _PixelGrid;
_PixelGrid *PixelGrid;
PixelGrid = calloc( ModeSpec[Mode].ImgWidth * ModeSpec[Mode].ImgHeight * 3, sizeof(_PixelGrid) );
PixelGrid = calloc( ModeSpec[Mode].ImgWidth * ModeSpec[Mode].NumLines * 3, sizeof(_PixelGrid) );
// Initialize Hann windows of different lengths
@ -105,7 +105,7 @@ gboolean GetVideo(guchar Mode, double Rate, int Skip, gboolean Redraw) {
// Plan ahead the time instants (in samples) at which to take pixels out
int PixelIdx = 0;
for (y=0; y<ModeSpec[Mode].ImgHeight; y++) {
for (y=0; y<ModeSpec[Mode].NumLines; y++) {
for (Channel=0; Channel<NumChans; Channel++) {
for (x=0; x<ModeSpec[Mode].ImgWidth; x++) {
@ -157,7 +157,7 @@ gboolean GetVideo(guchar Mode, double Rate, int Skip, gboolean Redraw) {
// Initialize pixbuffer
if (!Redraw) {
g_object_unref(pixbuf_rx);
pixbuf_rx = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, ModeSpec[Mode].ImgWidth, ModeSpec[Mode].ImgHeight);
pixbuf_rx = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, ModeSpec[Mode].ImgWidth, ModeSpec[Mode].NumLines);
gdk_pixbuf_fill(pixbuf_rx, 0);
}
@ -167,13 +167,13 @@ gboolean GetVideo(guchar Mode, double Rate, int Skip, gboolean Redraw) {
g_object_unref(pixbuf_disp);
pixbuf_disp = gdk_pixbuf_scale_simple(pixbuf_rx, 500,
500.0/ModeSpec[Mode].ImgWidth * ModeSpec[Mode].ImgHeight * ModeSpec[Mode].YScale, GDK_INTERP_BILINEAR);
500.0/ModeSpec[Mode].ImgWidth * ModeSpec[Mode].NumLines * ModeSpec[Mode].LineHeight, GDK_INTERP_BILINEAR);
gdk_threads_enter();
gtk_image_set_from_pixbuf(GTK_IMAGE(gui.image_rx), pixbuf_disp);
gdk_threads_leave();
Length = ModeSpec[Mode].LineLen * ModeSpec[Mode].ImgHeight * 44100;
Length = ModeSpec[Mode].LineLen * ModeSpec[Mode].NumLines * 44100;
SyncTargetBin = GetBin(1200+CurrentPic.HedrShift, FFTLen);
Abort = FALSE;
SyncSampleNum = 0;
@ -381,7 +381,7 @@ gboolean GetVideo(guchar Mode, double Rate, int Skip, gboolean Redraw) {
// Scale and update image
g_object_unref(pixbuf_disp);
pixbuf_disp = gdk_pixbuf_scale_simple(pixbuf_rx, 500,
500.0/ModeSpec[Mode].ImgWidth * ModeSpec[Mode].ImgHeight * ModeSpec[Mode].YScale, GDK_INTERP_BILINEAR);
500.0/ModeSpec[Mode].ImgWidth * ModeSpec[Mode].NumLines * ModeSpec[Mode].LineHeight, GDK_INTERP_BILINEAR);
gdk_threads_enter();
gtk_image_set_from_pixbuf(GTK_IMAGE(gui.image_rx), pixbuf_disp);