1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
//---------------------------------------------------------------------------//
// Copyright (c) 2017-2024 Ismael Gutiérrez González. All rights reserved.
//
// This file is part of the Rusted PackFile Manager (RPFM) project,
// which can be found here: https://github.com/Frodo45127/rpfm.
//
// This file is licensed under the MIT license, which can be found here:
// https://github.com/Frodo45127/rpfm/blob/master/LICENSE.
//---------------------------------------------------------------------------//
//! CA_VP8 are a custom version of a VP8 video by CA. These files contain only video data, no audio.
//!
//! Within this module are functions to convert these files into IVF files, readable by tools such
//! FFMpeg, VLC or MPV.
//!
//! These files can usually be found under the movies folder, with the extension `.ca_vp8`. This format
//! is versioned through a `version` number in the file's header. This lib supports has support for reading
//! and writing the versions 0 and 1.
//!
//! # CA_VP8 Structure
//!
//! ## Header
//! ### V1
//!
//! | Bytes | Type | Data |
//! | ----- | -------- | -------------------------- |
//! | 4 | StringU8 | Signature of the file. |
//! | 4 | [u32] | Version of the file. |
//! | 4 | [u32] | Length of the header. |
//! | 4 | StringU8 | FourCC of the video. |
//! | 2 | [u16] | Width of the video. |
//! | 2 | [u16] | Heigth of the video. |
//! | 4 | [f32] | Milliseconds per frame. |
//! | 4 | [u32] | Unknown. |
//! | 4 | [u32] | Number of frames - 1. |
//! | 4 | [u32] | Offset of the frame table. |
//! | 4 | [u32] | Number of frames. |
//! | 4 | [u32] | Largest frame. |
//! | 1 | [u8] | Unknown value. |
//!
//! ### V0
//!
//! | Bytes | Type | Data |
//! | ----- | -------- | -------------------------- |
//! | 4 | StringU8 | Signature of the file. |
//! | 4 | [u32] | Version of the file. |
//! | 4 | [u32] | Length of the header - 8. |
//! | 4 | StringU8 | FourCC of the video. |
//! | 2 | [u16] | Width of the video. |
//! | 2 | [u16] | Heigth of the video. |
//! | 4 | [f32] | Milliseconds per frame. |
//! | 4 | [u32] | Unknown. |
//! | 4 | [u32] | Number of frames. |
//! | 4 | [u32] | Offset of the frame table. |
//! | 4 | [u32] | Number of frames. |
//! | 4 | [u32] | Largest frame. |
//!
//! ## Frames Data
//!
//! This is valid for versions 0 and 1.
//!
//! | Bytes | Type | Data |
//! | ------------------------------------ | -------------------------------------------- | -------------------------------------------------------------- |
//! | Frame table's offset - header length | &\[[u8]\] | Frames data, concatenated. |
//! | Until the end of the file | &\[[Frame Table Entry](#frame-table-entry)\] | List of entries with each frame metadata (position, size,...). |
//!
//! ## Frame Table Entry
//!
//! This is valid for versions 0 and 1.
//!
//! | Bytes | Type | Data |
//! | ---------- | --------- | ------------------------------------------------ |
//! | 4 | [u32] | Offset of the frame from the start of the file. |
//! | 4 | [u32] | Size in bytes of the frame's data. |
//! | 4 | [u32] | Optional. Unknown value. Only present sometimes. |
//! | 1 | [bool] | Is the frame a key frame? |
//!
//!
//! Credits for this module:
//! - Research and initial implementation for this was done by **John Sirett** here:
//! - <https://gitlab.com/johnsirett/ca_vp8-reverse>
//!
//! As such, the read/save functions for CaVp8 and Ivf in the submodules of this module (and only those functions)
//! are an exception to the MIT license above and are under the CC-SA 4.0 license, available here:
//! - <https://creativecommons.org/licenses/by-sa/4.0/>
use *;
use ;
use crate;
use crate;
use crate;
/// Extensions used by CaVp8 Files.
pub const EXTENSION: &str = ".ca_vp8";
/// Signature/Magic Numbers/Whatever of a IVF video file.
const SIGNATURE_IVF: &str = "DKIF";
/// Signature/Magic Numbers/Whatever of a CaVp8 video file.
const SIGNATURE_CAVP8: &str = "CAMV";
//---------------------------------------------------------------------------//
// Enum & Structs
//---------------------------------------------------------------------------//
/// This represents an entire CaVp8 File decoded in memory.
/// This struct contains the information needed to locate an specific frame from a video within the raw frame data.
/// This enum contains the list of formats this lib supports.
//---------------------------------------------------------------------------//
// Implementation
//---------------------------------------------------------------------------//