blob: 4783bf26477aeffa14dffe4aa7723fed85ed014b [file] [log] [blame]
Tom Finegan03848f52013-11-05 10:02:18 -08001/*
Krishna Rapaka7319db52021-09-28 20:35:29 -07002 * Copyright (c) 2021, Alliance for Open Media. All rights reserved
Tom Finegan03848f52013-11-05 10:02:18 -08003 *
Vibhoothi41c6dd72021-10-12 18:48:26 +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/.
Tom Finegan03848f52013-11-05 10:02:18 -080011 */
James Zerne1cbb132018-08-22 14:10:36 -070012#ifndef AOM_COMMON_WEBMENC_H_
13#define AOM_COMMON_WEBMENC_H_
Tom Finegan03848f52013-11-05 10:02:18 -080014
15#include <stdio.h>
16#include <stdlib.h>
17
Tom Finegan03848f52013-11-05 10:02:18 -080018#include "tools_common.h"
Yaowu Xuf883b422016-08-30 14:01:10 -070019#include "aom/aom_encoder.h"
Tom Finegan03848f52013-11-05 10:02:18 -080020
James Zern25cfd8e2014-01-18 12:16:11 -080021#ifdef __cplusplus
22extern "C" {
23#endif
24
Vignesh Venkatasubramanian9441f102016-04-25 13:28:24 -070025struct WebmOutputContext {
Tom Finegan03848f52013-11-05 10:02:18 -080026 int debug;
Tom Finegan03848f52013-11-05 10:02:18 -080027 FILE *stream;
Vignesh Venkatasubramanian2dcbf8c2014-03-19 11:56:02 -070028 int64_t last_pts_ns;
29 void *writer;
30 void *segment;
Tom Finegan03848f52013-11-05 10:02:18 -080031};
32
33/* Stereo 3D packed frame format */
Satish Kumar Suman4667aa12018-12-14 18:28:19 +053034enum {
Tom Finegan1f0c2e72013-11-06 10:02:31 -080035 STEREO_FORMAT_MONO = 0,
Tom Finegan03848f52013-11-05 10:02:18 -080036 STEREO_FORMAT_LEFT_RIGHT = 1,
37 STEREO_FORMAT_BOTTOM_TOP = 2,
38 STEREO_FORMAT_TOP_BOTTOM = 3,
39 STEREO_FORMAT_RIGHT_LEFT = 11
Satish Kumar Suman4667aa12018-12-14 18:28:19 +053040} UENUM1BYTE(stereo_format_t);
Tom Finegan03848f52013-11-05 10:02:18 -080041
Elliott Karpilovsky4e55eb72020-05-14 14:16:24 -070042// Simplistic mechanism to extract encoder settings, without having
43// to re-invoke the entire flag-parsing logic. It lists the codec version
44// and then copies the arguments as-is from argv, but skips the binary name,
45// any arguments that match the input filename, and the output flags "-o"
46// and "--output" (and the following argument for those flags). The caller
47// is responsible for free-ing the returned string. If there is insufficient
48// memory, it returns nullptr.
49char *extract_encoder_settings(const char *version, const char **argv, int argc,
50 const char *input_fname);
51
Tom Fineganbb8157b2018-09-20 15:33:11 -070052// The following functions wrap libwebm's mkvmuxer. All functions return 0 upon
53// success, or -1 upon failure.
Tom Finegan03848f52013-11-05 10:02:18 -080054
Tom Fineganbb8157b2018-09-20 15:33:11 -070055int write_webm_file_header(struct WebmOutputContext *webm_ctx,
56 aom_codec_ctx_t *encoder_ctx,
57 const aom_codec_enc_cfg_t *cfg,
58 stereo_format_t stereo_fmt, unsigned int fourcc,
Elliott Karpilovsky4e55eb72020-05-14 14:16:24 -070059 const struct AvxRational *par,
60 const char *encoder_settings);
Tom Finegan03848f52013-11-05 10:02:18 -080061
Tom Fineganbb8157b2018-09-20 15:33:11 -070062int write_webm_block(struct WebmOutputContext *webm_ctx,
63 const aom_codec_enc_cfg_t *cfg,
64 const aom_codec_cx_pkt_t *pkt);
65
66int write_webm_file_footer(struct WebmOutputContext *webm_ctx);
Tom Finegan03848f52013-11-05 10:02:18 -080067
James Zern25cfd8e2014-01-18 12:16:11 -080068#ifdef __cplusplus
69} // extern "C"
70#endif
71
James Zerne1cbb132018-08-22 14:10:36 -070072#endif // AOM_COMMON_WEBMENC_H_