X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Ffilegif.C;h=88c4eb9038aae8accd24c56b2e91b839d8e21ca1;hb=018c9250fb76528e1eae0b031c6126aa50b0ecc8;hp=6462fdca8af1a9e093a299e8f00ca0f82951d497;hpb=cb1a1530246ad67fb9be9aa2dbba5b88eb63e933;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/cinelerra/filegif.C b/cinelerra-5.1/cinelerra/filegif.C index 6462fdca..88c4eb90 100644 --- a/cinelerra-5.1/cinelerra/filegif.C +++ b/cinelerra-5.1/cinelerra/filegif.C @@ -18,20 +18,28 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ - +#ifdef HAVE_GIFLIB #include "asset.h" #include "bcsignals.h" #include "file.h" #include "filegif.h" #include "gif_lib.h" #include "mainerror.h" -#include "interlacemodes.h" #include "vframe.h" #include #include #include #include +#include + +//from "getarg.h" +extern "C" +int GifQuantizeBuffer(unsigned int Width, unsigned int Height, + int *ColorMapSize, GifByteType * RedInput, + GifByteType * GreenInput, GifByteType * BlueInput, + GifByteType * OutputBuffer, + GifColorType * OutputColorMap); FileGIF::FileGIF(Asset *asset, File *file) : FileBase(asset, file) @@ -493,6 +501,65 @@ FrameWriterUnit* FileGIFList::new_writer_unit(FrameWriter *writer) return new GIFUnit(this, writer); } +int FileGIFList::verify_file_list() +{ + // go through all .gif files in the list and + // verify their sizes match or not. + //printf("\nAsset Path: %s\n", asset->path); + FILE *stream = fopen(asset->path, "rb"); + if (stream) { + char string[BCTEXTLEN]; + int width, height, prev_width=-1, prev_height=-1; + // build the path prefix + char prefix[BCTEXTLEN], *bp = prefix, *cp = strrchr(asset->path, '/'); + for( int i=0, n=!cp ? 0 : cp-asset->path; ipath[i]; + *bp = 0; + // read entire input file + while( !feof(stream) && fgets(string, BCTEXTLEN, stream) ) { + int len = strlen(string); + if(!len || string[0] == '#' || string[0] == ' ' || isalnum(string[0])) continue; + if( string[len-1] == '\n' ) string[len-1] = 0; + // a possible .gif file path? fetch it + char path[BCTEXTLEN], *pp = path, *ep = pp + sizeof(path)-1; + if( string[0] == '.' && string[1] == '/' && prefix[0] ) + pp += snprintf(pp, ep-pp, "%s/", prefix); + snprintf(pp, ep-pp, "%s", string); + // check if a valid file exists + if(!access(path, R_OK)) { + // check file header for size + FILE *gif_file_temp = fopen(path, "rb"); + if (gif_file_temp) { + unsigned char test[16]; + int ret = fread(test, 16, 1, gif_file_temp); + fclose(gif_file_temp); + if( ret < 1 ) continue; + // get height and width of gif file + width = test[6] | (test[7] << 8); + height = test[8] | (test[9] << 8); + // test with previous + if ( (prev_width == -1) && (prev_height == -1) ) { + prev_width = width; + prev_height = height; + continue; + } + else if ( (prev_width != width) || (prev_height != height) ) { + // this is the error case we are trying to avoid + fclose(stream); + return 0; + } + } + + } + } + fclose(stream); + return 1; + } + // not sure if our function should be the one to raise not found error + perror(asset->path); + return 0; +} + + GIFUnit::GIFUnit(FileGIFList *file, FrameWriter *writer) : FrameWriterUnit(writer) { @@ -505,3 +572,4 @@ GIFUnit::~GIFUnit() delete temp_frame; } +#endif