added experimental sdl output support

master
Ahmet İnan 2011-10-23 20:54:33 +02:00
rodzic 3b27180505
commit 34b6e8247b
6 zmienionych plików z 83 dodań i 7 usunięć

Wyświetl plik

@ -1,6 +1,6 @@
CFLAGS = -DUP=0 -DDN=1 -D_GNU_SOURCE=1 -W -Wall -O3 -std=c99 -ffast-math
LDFLAGS = -lm -lasound
CFLAGS = -g -DUP=0 -DDN=1 -D_GNU_SOURCE=1 -W -Wall -O3 -std=c99 -ffast-math $(shell sdl-config --cflags)
LDFLAGS = -lm -lasound $(shell sdl-config --libs)
all: encode decode debug
@ -35,9 +35,9 @@ fun: all
clean:
rm -f encode decode debug *.o {8000,11025,16000,40000,44100,48000}.{ppm,wav,dat}
encode: encode.o mmap_file.o pcm.o wav.o alsa.o yuv.o img.o ppm.o
encode: encode.o mmap_file.o pcm.o wav.o alsa.o yuv.o img.o ppm.o sdl.o
decode: decode.o mmap_file.o pcm.o wav.o alsa.o window.o ddc.o delay.o yuv.o img.o ppm.o
decode: decode.o mmap_file.o pcm.o wav.o alsa.o window.o ddc.o delay.o yuv.o img.o ppm.o sdl.o
debug: debug.o mmap_file.o pcm.o wav.o alsa.o window.o ddc.o delay.o yuv.o img.o ppm.o
debug: debug.o mmap_file.o pcm.o wav.o alsa.o window.o ddc.o delay.o yuv.o img.o ppm.o sdl.o

Wyświetl plik

@ -130,7 +130,7 @@ int main(int argc, char **argv)
const int width = (0.150 + 3.0 * sync_porch_len) * drate + 20;
const int height = 256;
img_t *img;
img_t *img = 0;
int hor_ticks = 0;
int y_pixel_x = 0;

Wyświetl plik

@ -359,7 +359,7 @@ int main(int argc, char **argv)
short *buff = (short *)malloc(sizeof(short) * channels * factor_M);
img_t *img;
img_t *img = 0;
for (int out = factor_L;; out++) {
if (out >= factor_L) {

3
img.c
Wyświetl plik

@ -9,6 +9,7 @@ You should have received a copy of the CC0 Public Domain Dedication along with t
#include <string.h>
#include "img.h"
#include "ppm.h"
#include "sdl.h"
void close_img(img_t *img)
{
@ -27,6 +28,8 @@ int open_img_write(img_t **p, char *name, int width, int height)
{
if (strstr(name, ".ppm") == (name + (strlen(name) - strlen(".ppm"))))
return open_ppm_write(p, name, width, height);
if (strstr(name, "sdl:") == name)
return open_sdl_write(p, name, width, height);
return 0;
}

60
sdl.c 100644
Wyświetl plik

@ -0,0 +1,60 @@
/*
robot36 - encode and decode images using SSTV in Robot 36 mode
Written in 2011 by <Ahmet Inan> <xdsopl@googlemail.com>
To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <SDL.h>
#include "img.h"
typedef struct {
void (*close)(img_t *);
uint8_t *pixel;
int width;
int height;
SDL_Surface *screen;
} sdl_t;
void close_sdl(img_t *img)
{
sdl_t *sdl = (sdl_t *)img;
(void)sdl;
SDL_Quit();
}
int open_sdl_write(img_t **p, char *name, int width, int height)
{
sdl_t *sdl = (sdl_t *)malloc(sizeof(sdl_t));
sdl->close = close_sdl;
atexit(SDL_Quit);
SDL_Init(SDL_INIT_VIDEO);
sdl->screen = SDL_SetVideoMode(width, height, 24, SDL_SWSURFACE);
if (!sdl->screen) {
fprintf(stderr, "couldnt open %s window %dx%d@24\n", name, width, height);
SDL_Quit();
free(sdl);
return 0;
}
if (sdl->screen->format->BytesPerPixel != 3 || sdl->screen->w != width || sdl->screen->h != height) {
fprintf(stderr, "requested %dx%d@24 but got %s window %dx%d@24\n", width, height, name, sdl->screen->w, sdl->screen->h);
SDL_Quit();
free(sdl);
return 0;
}
SDL_WM_SetCaption("robot36", "robot36");
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
sdl->pixel = sdl->screen->pixels;
memset(sdl->pixel, 0, width * height * 3);
*p = (img_t *)sdl;
return 1;
}

13
sdl.h 100644
Wyświetl plik

@ -0,0 +1,13 @@
/*
robot36 - encode and decode images using SSTV in Robot 36 mode
Written in 2011 by <Ahmet Inan> <xdsopl@googlemail.com>
To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
#ifndef SDL_H
#define SDL_H
#include "img.h"
int open_sdl_write(img_t **, char *, int, int);
#endif