xref: /aosp_15_r20/external/libaom/common/webmenc.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 #ifndef AOM_COMMON_WEBMENC_H_
12*77c1e3ccSAndroid Build Coastguard Worker #define AOM_COMMON_WEBMENC_H_
13*77c1e3ccSAndroid Build Coastguard Worker 
14*77c1e3ccSAndroid Build Coastguard Worker #include <stdio.h>
15*77c1e3ccSAndroid Build Coastguard Worker #include <stdlib.h>
16*77c1e3ccSAndroid Build Coastguard Worker 
17*77c1e3ccSAndroid Build Coastguard Worker #include "tools_common.h"
18*77c1e3ccSAndroid Build Coastguard Worker #include "aom/aom_encoder.h"
19*77c1e3ccSAndroid Build Coastguard Worker 
20*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus
21*77c1e3ccSAndroid Build Coastguard Worker extern "C" {
22*77c1e3ccSAndroid Build Coastguard Worker #endif
23*77c1e3ccSAndroid Build Coastguard Worker 
24*77c1e3ccSAndroid Build Coastguard Worker struct WebmOutputContext {
25*77c1e3ccSAndroid Build Coastguard Worker   int debug;
26*77c1e3ccSAndroid Build Coastguard Worker   FILE *stream;
27*77c1e3ccSAndroid Build Coastguard Worker   int64_t last_pts_ns;
28*77c1e3ccSAndroid Build Coastguard Worker   void *writer;
29*77c1e3ccSAndroid Build Coastguard Worker   void *segment;
30*77c1e3ccSAndroid Build Coastguard Worker };
31*77c1e3ccSAndroid Build Coastguard Worker 
32*77c1e3ccSAndroid Build Coastguard Worker /* Stereo 3D packed frame format */
33*77c1e3ccSAndroid Build Coastguard Worker enum {
34*77c1e3ccSAndroid Build Coastguard Worker   STEREO_FORMAT_MONO = 0,
35*77c1e3ccSAndroid Build Coastguard Worker   STEREO_FORMAT_LEFT_RIGHT = 1,
36*77c1e3ccSAndroid Build Coastguard Worker   STEREO_FORMAT_BOTTOM_TOP = 2,
37*77c1e3ccSAndroid Build Coastguard Worker   STEREO_FORMAT_TOP_BOTTOM = 3,
38*77c1e3ccSAndroid Build Coastguard Worker   STEREO_FORMAT_RIGHT_LEFT = 11
39*77c1e3ccSAndroid Build Coastguard Worker } UENUM1BYTE(stereo_format_t);
40*77c1e3ccSAndroid Build Coastguard Worker 
41*77c1e3ccSAndroid Build Coastguard Worker // Simplistic mechanism to extract encoder settings, without having
42*77c1e3ccSAndroid Build Coastguard Worker // to re-invoke the entire flag-parsing logic. It lists the codec version
43*77c1e3ccSAndroid Build Coastguard Worker // and then copies the arguments as-is from argv, but skips the binary name,
44*77c1e3ccSAndroid Build Coastguard Worker // any arguments that match the input filename, and the output flags "-o"
45*77c1e3ccSAndroid Build Coastguard Worker // and "--output" (and the following argument for those flags). The caller
46*77c1e3ccSAndroid Build Coastguard Worker // is responsible for free-ing the returned string. If there is insufficient
47*77c1e3ccSAndroid Build Coastguard Worker // memory, it returns nullptr.
48*77c1e3ccSAndroid Build Coastguard Worker char *extract_encoder_settings(const char *version, const char **argv, int argc,
49*77c1e3ccSAndroid Build Coastguard Worker                                const char *input_fname);
50*77c1e3ccSAndroid Build Coastguard Worker 
51*77c1e3ccSAndroid Build Coastguard Worker // The following functions wrap libwebm's mkvmuxer. All functions return 0 upon
52*77c1e3ccSAndroid Build Coastguard Worker // success, or -1 upon failure.
53*77c1e3ccSAndroid Build Coastguard Worker 
54*77c1e3ccSAndroid Build Coastguard Worker int write_webm_file_header(struct WebmOutputContext *webm_ctx,
55*77c1e3ccSAndroid Build Coastguard Worker                            aom_codec_ctx_t *encoder_ctx,
56*77c1e3ccSAndroid Build Coastguard Worker                            const aom_codec_enc_cfg_t *cfg,
57*77c1e3ccSAndroid Build Coastguard Worker                            stereo_format_t stereo_fmt, unsigned int fourcc,
58*77c1e3ccSAndroid Build Coastguard Worker                            const struct AvxRational *par,
59*77c1e3ccSAndroid Build Coastguard Worker                            const char *encoder_settings);
60*77c1e3ccSAndroid Build Coastguard Worker 
61*77c1e3ccSAndroid Build Coastguard Worker int write_webm_block(struct WebmOutputContext *webm_ctx,
62*77c1e3ccSAndroid Build Coastguard Worker                      const aom_codec_enc_cfg_t *cfg,
63*77c1e3ccSAndroid Build Coastguard Worker                      const aom_codec_cx_pkt_t *pkt);
64*77c1e3ccSAndroid Build Coastguard Worker 
65*77c1e3ccSAndroid Build Coastguard Worker int write_webm_file_footer(struct WebmOutputContext *webm_ctx);
66*77c1e3ccSAndroid Build Coastguard Worker 
67*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus
68*77c1e3ccSAndroid Build Coastguard Worker }  // extern "C"
69*77c1e3ccSAndroid Build Coastguard Worker #endif
70*77c1e3ccSAndroid Build Coastguard Worker 
71*77c1e3ccSAndroid Build Coastguard Worker #endif  // AOM_COMMON_WEBMENC_H_
72