blob: 6f02687b59e63785f54caa0d24804d4eefad8c55 [file] [log] [blame]
Cyril Concolato6c788832017-10-30 16:30:35 -07001/*
Lester Lu6bc30d62021-12-16 19:13:21 +00002 * Copyright (c) 2021, Alliance for Open Media. All rights reserved
Cyril Concolato6c788832017-10-30 16:30:35 -07003 *
Lester Lu6bc30d62021-12-16 19:13:21 +00004 * This source code is subject to the terms of the BSD 3-Clause Clear License
5 * and the Alliance for Open Media Patent License 1.0. If the BSD 3-Clause Clear
6 * License was not distributed with this source code in the LICENSE file, you
7 * can obtain it at aomedia.org/license/software-license/bsd-3-c-c/. If the
8 * Alliance for Open Media Patent License 1.0 was not distributed with this
9 * source code in the PATENTS file, you can obtain it at
10 * aomedia.org/license/patent-license/.
Cyril Concolato6c788832017-10-30 16:30:35 -070011 */
James Zerne1cbb132018-08-22 14:10:36 -070012#ifndef AOM_COMMON_OBUDEC_H_
13#define AOM_COMMON_OBUDEC_H_
Cyril Concolato6c788832017-10-30 16:30:35 -070014
Tom Finegandd3e2a52018-05-23 14:33:09 -070015#include "common/tools_common.h"
Cyril Concolato6c788832017-10-30 16:30:35 -070016
17#ifdef __cplusplus
18extern "C" {
19#endif
20
Tom Finegan66ae9162018-03-19 18:12:50 -070021struct ObuDecInputContext {
22 struct AvxInputContext *avx_ctx;
23 uint8_t *buffer;
24 size_t buffer_capacity;
25 size_t bytes_buffered;
Soo-Chul Han29c46fb2018-03-23 16:02:00 -040026 int is_annexb;
Tom Finegan66ae9162018-03-19 18:12:50 -070027};
Cyril Concolato6c788832017-10-30 16:30:35 -070028
Soo-Chul Han29c46fb2018-03-23 16:02:00 -040029// Returns 1 when file data starts (if Annex B stream, after reading the
30// size of the OBU) with what appears to be a Temporal Delimiter
Tom Finegan66ae9162018-03-19 18:12:50 -070031// OBU as defined by Section 5 of the AV1 bitstream specification.
32int file_is_obu(struct ObuDecInputContext *obu_ctx);
33
34// Reads one Temporal Unit from the input file. Returns 0 when a TU is
35// successfully read, 1 when end of file is reached, and less than 0 when an
36// error occurs. Stores TU data in 'buffer'. Reallocs buffer to match TU size,
37// returns buffer capacity via 'buffer_size', and returns size of buffered data
38// via 'bytes_read'.
39int obudec_read_temporal_unit(struct ObuDecInputContext *obu_ctx,
40 uint8_t **buffer, size_t *bytes_read,
Tom Finegan82a41182018-03-30 11:32:37 -070041 size_t *buffer_size);
Tom Finegan66ae9162018-03-19 18:12:50 -070042
43void obudec_free(struct ObuDecInputContext *obu_ctx);
Cyril Concolato6c788832017-10-30 16:30:35 -070044
45#ifdef __cplusplus
46} /* extern "C" */
47#endif
48
James Zerne1cbb132018-08-22 14:10:36 -070049#endif // AOM_COMMON_OBUDEC_H_