+int FileGIFList::colormodel_supported(int colormodel) { return BC_RGB888; }
+int FileGIFList::get_best_colormodel(Asset *asset, int driver) { return BC_RGB888; }
+
+int FileGIFList::read_frame_header(char *path)
+{
+ FILE *stream = fopen(path, "rb");
+ if( stream ) {
+ unsigned char test[16];
+ int ret = fread(test, 16, 1, stream);
+ fclose(stream);
+ if( ret < 1 ) return 1;
+ asset->format = FILE_GIF_LIST;
+ asset->width = test[6] | (test[7] << 8);
+ asset->height = test[8] | (test[9] << 8);
+ return 0;
+ }
+ perror(path);
+ return 1;
+}
+
+int FileGIFList::read_frame(VFrame *output, char *path)
+{
+ Asset *asset = new Asset(path);
+ FileGIF gif(asset, file);
+ int ret = gif.ropen_path(path);
+ if( !ret )
+ ret = gif.read_frame(output);
+ asset->remove_user();
+ return ret;
+}
+
+int FileGIFList::write_frame(VFrame *frame, VFrame *data, FrameWriterUnit *unit)
+{
+ int native_cmodel = BC_RGB888;
+ if( frame->get_color_model() != native_cmodel ) {
+ GIFUnit *gif_unit = (GIFUnit *)unit;
+ if( !gif_unit->temp_frame ) gif_unit->temp_frame =
+ new VFrame(frame->get_w(), frame->get_h(), native_cmodel);
+ gif_unit->temp_frame->transfer_from(frame);
+ frame = gif_unit->temp_frame;
+ }
+
+ FileGIF gif(asset, file);
+ int ret = gif.wopen_data(data);
+ if( !ret )
+ ret = gif.write_frame(frame);
+ return ret;
+}
+
+FrameWriterUnit* FileGIFList::new_writer_unit(FrameWriter *writer)
+{
+ return new GIFUnit(this, writer);
+}
+
+GIFUnit::GIFUnit(FileGIFList *file, FrameWriter *writer)
+ : FrameWriterUnit(writer)
+{
+ this->file = file;
+ temp_frame = 0;
+}
+
+GIFUnit::~GIFUnit()
+{
+ delete temp_frame;
+}
+