4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "commercials.h"
26 #include "filemediadb.h"
28 #include "preferences.h"
36 FileMediaDb::FileMediaDb(Asset *asset, File *file)
37 : FileBase(asset, file)
40 if(asset->format == FILE_UNKNOWN)
41 asset->format = FILE_MEDIADB;
43 swidth = (SWIDTH+1) & ~1;
44 sheight = (SHEIGHT+1) & ~1;
45 seq_no = frame_id = frames = -1;
46 framerate = offset = -1;;
50 FileMediaDb::~FileMediaDb()
55 int FileMediaDb::check_sig(Asset *asset)
57 return !strncmp(asset->path,"/mediadb:",9);
60 int FileMediaDb::open_file(int rd, int wr)
66 clip_id = strtol(asset->path+9,&cp,0);
67 if( !cp || cp == asset->path+9 || *cp != 0 ) result = 1;
68 if( !result ) result = MWindow::commercials->
69 get_clip_set(clip_id, title, framerate, frames);
71 asset->audio_data = 0;
72 asset->video_data = 1;
73 asset->actual_width = swidth;
74 asset->actual_height = sheight;
75 if( !asset->layers ) asset->layers = 1;
76 if( !asset->width ) asset->width = asset->actual_width;
77 if( !asset->height ) asset->height = asset->actual_height;
78 if( !asset->video_length ) asset->video_length = frames;
79 if( !asset->frame_rate ) asset->frame_rate = framerate;
90 int FileMediaDb::close_file()
94 FileBase::close_file();
98 int FileMediaDb::get_best_colormodel(Asset *asset, int driver)
103 int FileMediaDb::colormodel_supported(int colormodel)
109 int FileMediaDb::set_video_position(int64_t pos)
111 if( pos < 0 || pos >= asset->video_length )
117 int64_t FileMediaDb::get_memory_usage()
124 int FileMediaDb::write_frames(VFrame ***frames, int len)
131 int FileMediaDb::read_frame(VFrame *frame)
134 int result = MWindow::commercials->
135 get_clip_seq_no(clip_id, seq_no, offset, frame_id);
136 if( !result ) result = MWindow::commercials->
137 get_image(frame_id, frame->get_y(), sw,sh);
139 memset(frame->get_u(),0x80,swidth/2 * sheight/2);
140 memset(frame->get_v(),0x80,swidth/2 * sheight/2);