From fcaab19183db8a80822c80f13b89a7ea2218b18d Mon Sep 17 00:00:00 2001 From: kramm Date: Thu, 25 Nov 2004 13:05:48 +0000 Subject: [PATCH] initial revision. --- avi2swf/videoreader_dummy.cc | 105 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 avi2swf/videoreader_dummy.cc diff --git a/avi2swf/videoreader_dummy.cc b/avi2swf/videoreader_dummy.cc new file mode 100644 index 0000000..4887ef2 --- /dev/null +++ b/avi2swf/videoreader_dummy.cc @@ -0,0 +1,105 @@ +/* videoreader_dummy.cc + Simple example for a videoreader. + + Part of the swftools package. + + Copyright (c) 2004 Matthias Kramm + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include +#include +#include +#include "videoreader.h" + +typedef struct _my_internal +{ + int pos; + int len; //frames +} my_internal; + +typedef struct _RGBA +{ unsigned char a; + unsigned char r; + unsigned char g; + unsigned char b; +} RGBA; + +int my_getsamples(videoreader_t* v, void*buffer, int num) +{ + /* generate audio data */ + my_internal*i = (my_internal*)v->internal; + // printf("request for %d samples\n", num); + + return 0; // no audio +} + +int my_getimage(videoreader_t* v, void*buffer) +{ + /* generate video frame */ + my_internal*i = (my_internal*)v->internal; + RGBA*buf = (RGBA*)buffer; + + if(i->pos>=i->len) + return 0; /* end of video */ + + i->pos++; // next frame + + int x,y; + /* generate a simple color gradient */ + for(y=0;yheight;y++) + for(x=0;xwidth;x++) { + int r,g,b; + r = x; + g = y; + b = x+y; + buf[y*v->width + x].r = r; + buf[y*v->width + x].g = g; + buf[y*v->width + x].b = b; + buf[y*v->width + x].a = 255; + } + return v->width*v->height*4; +} +void my_close(videoreader_t* v) +{ + my_internal*i = (my_internal*)v->internal; + free(v->internal);v->internal = 0; +} +void my_setparameter(videoreader_t*v, char*name, char*value) +{ +} +int videoreader_dummy_open(videoreader_t* v, char* filename) +{ + my_internal* i; + i = (my_internal*)malloc(sizeof(my_internal)); + memset(i, 0, sizeof(my_internal)); + v->internal = i; + + i->len = 2000; //number of frames + + v->width = 320; + v->height = 200; + v->channels = 2; + v->samplerate = 44100; + v->fps = 15; + + v->getsamples = my_getsamples; + v->close = my_close; + v->getimage = my_getimage; + v->getsamples = my_getsamples; + v->setparameter = my_setparameter; + + return 0; +} -- 1.7.10.4