xref: /aosp_15_r20/external/libaom/common/video_reader.h (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker  * Copyright (c) 2016, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker  *
4*77c1e3ccSAndroid Build Coastguard Worker  * This source code is subject to the terms of the BSD 2 Clause License and
5*77c1e3ccSAndroid Build Coastguard Worker  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6*77c1e3ccSAndroid Build Coastguard Worker  * was not distributed with this source code in the LICENSE file, you can
7*77c1e3ccSAndroid Build Coastguard Worker  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8*77c1e3ccSAndroid Build Coastguard Worker  * Media Patent License 1.0 was not distributed with this source code in the
9*77c1e3ccSAndroid Build Coastguard Worker  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker  */
11*77c1e3ccSAndroid Build Coastguard Worker 
12*77c1e3ccSAndroid Build Coastguard Worker #ifndef AOM_COMMON_VIDEO_READER_H_
13*77c1e3ccSAndroid Build Coastguard Worker #define AOM_COMMON_VIDEO_READER_H_
14*77c1e3ccSAndroid Build Coastguard Worker 
15*77c1e3ccSAndroid Build Coastguard Worker #include "common/video_common.h"
16*77c1e3ccSAndroid Build Coastguard Worker 
17*77c1e3ccSAndroid Build Coastguard Worker // The following code is work in progress. It is going to  support transparent
18*77c1e3ccSAndroid Build Coastguard Worker // reading of input files. Right now only IVF format is supported for
19*77c1e3ccSAndroid Build Coastguard Worker // simplicity. The main goal the API is to be simple and easy to use in example
20*77c1e3ccSAndroid Build Coastguard Worker // code and in aomenc/aomdec later. All low-level details like memory
21*77c1e3ccSAndroid Build Coastguard Worker // buffer management are hidden from API users.
22*77c1e3ccSAndroid Build Coastguard Worker struct AvxVideoReaderStruct;
23*77c1e3ccSAndroid Build Coastguard Worker typedef struct AvxVideoReaderStruct AvxVideoReader;
24*77c1e3ccSAndroid Build Coastguard Worker 
25*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus
26*77c1e3ccSAndroid Build Coastguard Worker extern "C" {
27*77c1e3ccSAndroid Build Coastguard Worker #endif
28*77c1e3ccSAndroid Build Coastguard Worker 
29*77c1e3ccSAndroid Build Coastguard Worker // Opens the input file for reading and inspects it to determine file type.
30*77c1e3ccSAndroid Build Coastguard Worker // Returns an opaque AvxVideoReader* upon success, or NULL upon failure.
31*77c1e3ccSAndroid Build Coastguard Worker // Right now only IVF format is supported.
32*77c1e3ccSAndroid Build Coastguard Worker AvxVideoReader *aom_video_reader_open(const char *filename);
33*77c1e3ccSAndroid Build Coastguard Worker 
34*77c1e3ccSAndroid Build Coastguard Worker // Frees all resources associated with AvxVideoReader* returned from
35*77c1e3ccSAndroid Build Coastguard Worker // aom_video_reader_open() call.
36*77c1e3ccSAndroid Build Coastguard Worker void aom_video_reader_close(AvxVideoReader *reader);
37*77c1e3ccSAndroid Build Coastguard Worker 
38*77c1e3ccSAndroid Build Coastguard Worker // Reads frame from the file and stores it in internal buffer.
39*77c1e3ccSAndroid Build Coastguard Worker int aom_video_reader_read_frame(AvxVideoReader *reader);
40*77c1e3ccSAndroid Build Coastguard Worker 
41*77c1e3ccSAndroid Build Coastguard Worker // Returns the pointer to memory buffer with frame data read by last call to
42*77c1e3ccSAndroid Build Coastguard Worker // aom_video_reader_read_frame().
43*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *aom_video_reader_get_frame(AvxVideoReader *reader, size_t *size);
44*77c1e3ccSAndroid Build Coastguard Worker 
45*77c1e3ccSAndroid Build Coastguard Worker // Returns the pts of the frame.
46*77c1e3ccSAndroid Build Coastguard Worker int64_t aom_video_reader_get_frame_pts(AvxVideoReader *reader);
47*77c1e3ccSAndroid Build Coastguard Worker // Return the reader file.
48*77c1e3ccSAndroid Build Coastguard Worker FILE *aom_video_reader_get_file(AvxVideoReader *reader);
49*77c1e3ccSAndroid Build Coastguard Worker 
50*77c1e3ccSAndroid Build Coastguard Worker // Fills AvxVideoInfo with information from opened video file.
51*77c1e3ccSAndroid Build Coastguard Worker const AvxVideoInfo *aom_video_reader_get_info(AvxVideoReader *reader);
52*77c1e3ccSAndroid Build Coastguard Worker 
53*77c1e3ccSAndroid Build Coastguard Worker // Set fourcc.
54*77c1e3ccSAndroid Build Coastguard Worker void aom_video_reader_set_fourcc(AvxVideoReader *reader, uint32_t fourcc);
55*77c1e3ccSAndroid Build Coastguard Worker 
56*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus
57*77c1e3ccSAndroid Build Coastguard Worker }  // extern "C"
58*77c1e3ccSAndroid Build Coastguard Worker #endif
59*77c1e3ccSAndroid Build Coastguard Worker 
60*77c1e3ccSAndroid Build Coastguard Worker #endif  // AOM_COMMON_VIDEO_READER_H_
61