xref: /aosp_15_r20/external/libgav1/examples/ivf_parser.h (revision 095378508e87ed692bf8dfeb34008b65b3735891)
1 /*
2  * Copyright 2019 The libgav1 Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef LIBGAV1_EXAMPLES_IVF_PARSER_H_
18 #define LIBGAV1_EXAMPLES_IVF_PARSER_H_
19 
20 #include <cstddef>
21 #include <cstdint>
22 
23 namespace libgav1 {
24 
25 struct IvfFileHeader {
26   IvfFileHeader() = default;
27   IvfFileHeader(const IvfFileHeader& rhs) = default;
28   IvfFileHeader& operator=(const IvfFileHeader& rhs) = default;
29   IvfFileHeader(IvfFileHeader&& rhs) = default;
30   IvfFileHeader& operator=(IvfFileHeader&& rhs) = default;
31 
32   size_t width = 0;
33   size_t height = 0;
34   size_t frame_rate_numerator = 0;
35   size_t frame_rate_denominator = 0;
36 };
37 
38 struct IvfFrameHeader {
39   IvfFrameHeader() = default;
40   IvfFrameHeader(const IvfFrameHeader& rhs) = default;
41   IvfFrameHeader& operator=(const IvfFrameHeader& rhs) = default;
42   IvfFrameHeader(IvfFrameHeader&& rhs) = default;
43   IvfFrameHeader& operator=(IvfFrameHeader&& rhs) = default;
44 
45   size_t frame_size = 0;
46   int64_t timestamp = 0;
47 };
48 
49 bool ParseIvfFileHeader(const uint8_t* header_buffer,
50                         IvfFileHeader* ivf_file_header);
51 
52 bool ParseIvfFrameHeader(const uint8_t* header_buffer,
53                          IvfFrameHeader* ivf_frame_header);
54 
55 }  // namespace libgav1
56 
57 #endif  // LIBGAV1_EXAMPLES_IVF_PARSER_H_
58