Blender  V2.93
IMB_indexer.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 #pragma once
18 
23 #ifdef WIN32
24 # include <io.h>
25 #endif
26 
27 #include "IMB_anim.h"
28 #include <stdio.h>
29 #include <stdlib.h>
30 /*
31  * separate animation index files to solve the following problems:
32  *
33  * a) different time-codes within one file (like DTS/PTS, Time-code-Track,
34  * "implicit" time-codes within DV-files and HDV-files etc.)
35  * b) seeking difficulties within FFMPEG for files with timestamp holes
36  * c) broken files that miss several frames / have varying framerates
37  * d) use proxies accordingly
38  *
39  * ... we need index files, that provide us with
40  *
41  * the binary(!) position, where we have to seek into the file *and*
42  * the continuous frame number (ignoring the holes) starting from the
43  * beginning of the file, so that we know, which proxy frame to serve.
44  *
45  * This index has to be only built once for a file and is written into
46  * the BL_proxy directory structure for later reuse in different blender files.
47  */
48 
49 typedef struct anim_index_entry {
50  int frameno;
56 
57 struct anim_index {
58  char name[1024];
59 
62 };
63 
64 struct anim_index_builder;
65 
66 typedef struct anim_index_builder {
67  FILE *fp;
68  char name[FILE_MAX];
70 
71  void *private_data;
72 
73  void (*delete_priv_data)(struct anim_index_builder *idx);
74  void (*proc_frame)(struct anim_index_builder *idx,
75  unsigned char *buffer,
76  int data_size,
77  struct anim_index_entry *entry);
79 
82  int frameno,
86  uint64_t pts);
87 
89  unsigned char *buffer,
90  int data_size,
91  int frameno,
95  uint64_t pts);
96 
97 void IMB_index_builder_finish(anim_index_builder *fp, int rollback);
98 
99 struct anim_index *IMB_indexer_open(const char *name);
100 uint64_t IMB_indexer_get_seek_pos(struct anim_index *idx, int frame_index);
101 uint64_t IMB_indexer_get_seek_pos_pts(struct anim_index *idx, int frame_index);
102 uint64_t IMB_indexer_get_seek_pos_dts(struct anim_index *idx, int frame_index);
103 
104 int IMB_indexer_get_frame_index(struct anim_index *idx, int frameno);
105 uint64_t IMB_indexer_get_pts(struct anim_index *idx, int frame_index);
106 int IMB_indexer_get_duration(struct anim_index *idx);
107 
108 int IMB_indexer_can_scan(struct anim_index *idx, int old_frame_index, int new_frame_index);
109 
110 void IMB_indexer_close(struct anim_index *idx);
111 
112 void IMB_free_indices(struct anim *anim);
113 
114 struct anim *IMB_anim_open_proxy(struct anim *anim, IMB_Proxy_Size preview_size);
116 
#define FILE_MAX
IMB_Proxy_Size
Definition: IMB_imbuf.h:317
IMB_Timecode_Type
Definition: IMB_imbuf.h:298
void IMB_index_builder_proc_frame(anim_index_builder *fp, unsigned char *buffer, int data_size, int frameno, uint64_t seek_pos, uint64_t seek_pos_pts, uint64_t seek_pos_dts, uint64_t pts)
Definition: indexer.c:123
anim_index_builder * IMB_index_builder_create(const char *name)
Definition: indexer.c:75
struct anim_index_entry anim_index_entry
uint64_t IMB_indexer_get_seek_pos(struct anim_index *idx, int frame_index)
Definition: indexer.c:248
uint64_t IMB_indexer_get_seek_pos_pts(struct anim_index *idx, int frame_index)
Definition: indexer.c:259
int IMB_timecode_to_array_index(IMB_Timecode_Type tc)
Definition: indexer.c:366
struct anim_index * IMB_anim_open_index(struct anim *anim, IMB_Timecode_Type tc)
Definition: indexer.c:1454
void IMB_index_builder_finish(anim_index_builder *fp, int rollback)
Definition: indexer.c:147
void IMB_indexer_close(struct anim_index *idx)
Definition: indexer.c:341
void IMB_index_builder_add_entry(anim_index_builder *fp, int frameno, uint64_t seek_pos, uint64_t seek_pos_pts, uint64_t seek_pos_dts, uint64_t pts)
Definition: indexer.c:109
uint64_t IMB_indexer_get_seek_pos_dts(struct anim_index *idx, int frame_index)
Definition: indexer.c:270
void IMB_free_indices(struct anim *anim)
Definition: indexer.c:1395
int IMB_indexer_get_duration(struct anim_index *idx)
Definition: indexer.c:324
struct anim * IMB_anim_open_proxy(struct anim *anim, IMB_Proxy_Size preview_size)
Definition: indexer.c:1427
int IMB_indexer_can_scan(struct anim_index *idx, int old_frame_index, int new_frame_index)
Definition: indexer.c:332
uint64_t IMB_indexer_get_pts(struct anim_index *idx, int frame_index)
Definition: indexer.c:313
struct anim_index * IMB_indexer_open(const char *name)
Definition: indexer.c:166
int IMB_proxy_size_to_array_index(IMB_Proxy_Size pr_size)
Definition: indexer.c:347
int IMB_indexer_get_frame_index(struct anim_index *idx, int frameno)
Definition: indexer.c:281
struct anim_index_builder anim_index_builder
__kernel void ccl_constant KernelData ccl_global void ccl_global char ccl_global int ccl_global char ccl_global unsigned int ccl_global float * buffer
unsigned __int64 uint64_t
Definition: stdint.h:93
void(* proc_frame)(struct anim_index_builder *idx, unsigned char *buffer, int data_size, struct anim_index_entry *entry)
Definition: IMB_indexer.h:74
char name[FILE_MAX]
Definition: IMB_indexer.h:68
void(* delete_priv_data)(struct anim_index_builder *idx)
Definition: IMB_indexer.h:73
char temp_name[FILE_MAX]
Definition: IMB_indexer.h:69
Definition: IMB_indexer.h:49
uint64_t pts
Definition: IMB_indexer.h:54
uint64_t seek_pos
Definition: IMB_indexer.h:51
uint64_t seek_pos_pts
Definition: IMB_indexer.h:52
int frameno
Definition: IMB_indexer.h:50
uint64_t seek_pos_dts
Definition: IMB_indexer.h:53
int num_entries
Definition: IMB_indexer.h:60
struct anim_index_entry * entries
Definition: IMB_indexer.h:61
char name[1024]
Definition: IMB_indexer.h:58
Definition: IMB_anim.h:87