Blender V2.61 - r43446

IMB_indexer.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  *
00019  * Contributor(s): Peter Schlaile
00020  *
00021  * ***** END GPL LICENSE BLOCK *****
00022  */
00023 
00024 
00025 #ifndef IMB_INDEXER_H
00026 #define IMB_INDEXER_H
00027 
00028 #ifdef WIN32
00029 #  include <io.h>
00030 #endif
00031 
00032 #include <stdlib.h>
00033 #include <stdio.h>
00034 #include "BKE_utildefines.h"
00035 #include "IMB_anim.h"
00036 
00037 /*
00038   separate animation index files to solve the following problems:
00039 
00040   a) different timecodes within one file (like DTS/PTS, Timecode-Track, 
00041      "implicit" timecodes within DV-files and HDV-files etc.)
00042   b) seeking difficulties within ffmpeg for files with timestamp holes
00043   c) broken files that miss several frames / have varying framerates
00044   d) use proxies accordingly
00045 
00046   ... we need index files, that provide us with 
00047   
00048   the binary(!) position, where we have to seek into the file *and*
00049   the continuous frame number (ignoring the holes) starting from the 
00050   beginning of the file, so that we know, which proxy frame to serve.
00051 
00052   This index has to be only built once for a file and is written into
00053   the BL_proxy directory structure for later reuse in different blender files.
00054 
00055 */
00056 
00057 typedef struct anim_index_entry {
00058     int frameno;
00059     unsigned long long seek_pos;
00060     unsigned long long seek_pos_dts;
00061     unsigned long long pts;
00062 } anim_index_entry;
00063 
00064 struct anim_index {
00065     char name[256];
00066 
00067     int num_entries;
00068     struct anim_index_entry * entries;
00069 };
00070 
00071 struct anim_index_builder;
00072 
00073 typedef struct anim_index_builder {
00074     FILE * fp;
00075     char name[FILE_MAX];
00076     char temp_name[FILE_MAX];
00077 
00078     void * private_data;
00079 
00080     void (*delete_priv_data)(struct anim_index_builder * idx);
00081     void (*proc_frame)(struct anim_index_builder * idx,
00082                        unsigned char * buffer,
00083                        int data_size,
00084                        struct anim_index_entry * entry);
00085 } anim_index_builder;
00086 
00087 anim_index_builder * IMB_index_builder_create(const char * name);
00088 void IMB_index_builder_add_entry(
00089         anim_index_builder * fp,
00090         int frameno, unsigned long long seek_pos,
00091         unsigned long long seek_pos_dts,
00092         unsigned long long pts);
00093 
00094 void IMB_index_builder_proc_frame(
00095         anim_index_builder * fp,
00096         unsigned char * buffer,
00097         int data_size,
00098         int frameno, unsigned long long seek_pos,
00099         unsigned long long seek_pos_dts,
00100         unsigned long long pts);
00101 
00102 void IMB_index_builder_finish(anim_index_builder * fp, int rollback);
00103 
00104 struct anim_index * IMB_indexer_open(const char * name);
00105 unsigned long long IMB_indexer_get_seek_pos(
00106     struct anim_index * idx, int frameno_index);
00107 unsigned long long IMB_indexer_get_seek_pos_dts(
00108     struct anim_index * idx, int frameno_index);
00109 
00110 int IMB_indexer_get_frame_index(struct anim_index * idx, int frameno);
00111 unsigned long long IMB_indexer_get_pts(struct anim_index * idx, 
00112                        int frame_index);
00113 int IMB_indexer_get_duration(struct anim_index * idx);
00114 
00115 int IMB_indexer_can_scan(struct anim_index * idx, 
00116                          int old_frame_index, int new_frame_index);
00117 
00118 void IMB_indexer_close(struct anim_index * idx);
00119 
00120 void IMB_free_indices(struct anim * anim);
00121 
00122 int IMB_anim_index_get_frame_index(
00123     struct anim * anim, IMB_Timecode_Type tc, int position);
00124 
00125 struct anim * IMB_anim_open_proxy(
00126     struct anim * anim, IMB_Proxy_Size preview_size);
00127 struct anim_index * IMB_anim_open_index(
00128     struct anim * anim, IMB_Timecode_Type tc);
00129 
00130 int IMB_proxy_size_to_array_index(IMB_Proxy_Size pr_size);
00131 int IMB_timecode_to_array_index(IMB_Timecode_Type tc);
00132 
00133 #endif