Tom Finegan | 03848f5 | 2013-11-05 10:02:18 -0800 | [diff] [blame] | 1 | /* |
Krishna Rapaka | 7319db5 | 2021-09-28 20:35:29 -0700 | [diff] [blame] | 2 | * Copyright (c) 2021, Alliance for Open Media. All rights reserved |
Tom Finegan | 03848f5 | 2013-11-05 10:02:18 -0800 | [diff] [blame] | 3 | * |
Vibhoothi | 41c6dd7 | 2021-10-12 18:48:26 +0000 | [diff] [blame] | 4 | * 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 Finegan | 03848f5 | 2013-11-05 10:02:18 -0800 | [diff] [blame] | 11 | */ |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 12 | #ifndef AOM_COMMON_WEBMENC_H_ |
| 13 | #define AOM_COMMON_WEBMENC_H_ |
Tom Finegan | 03848f5 | 2013-11-05 10:02:18 -0800 | [diff] [blame] | 14 | |
| 15 | #include <stdio.h> |
| 16 | #include <stdlib.h> |
| 17 | |
Tom Finegan | 03848f5 | 2013-11-05 10:02:18 -0800 | [diff] [blame] | 18 | #include "tools_common.h" |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 19 | #include "aom/aom_encoder.h" |
Tom Finegan | 03848f5 | 2013-11-05 10:02:18 -0800 | [diff] [blame] | 20 | |
James Zern | 25cfd8e | 2014-01-18 12:16:11 -0800 | [diff] [blame] | 21 | #ifdef __cplusplus |
| 22 | extern "C" { |
| 23 | #endif |
| 24 | |
Vignesh Venkatasubramanian | 9441f10 | 2016-04-25 13:28:24 -0700 | [diff] [blame] | 25 | struct WebmOutputContext { |
Tom Finegan | 03848f5 | 2013-11-05 10:02:18 -0800 | [diff] [blame] | 26 | int debug; |
Tom Finegan | 03848f5 | 2013-11-05 10:02:18 -0800 | [diff] [blame] | 27 | FILE *stream; |
Vignesh Venkatasubramanian | 2dcbf8c | 2014-03-19 11:56:02 -0700 | [diff] [blame] | 28 | int64_t last_pts_ns; |
| 29 | void *writer; |
| 30 | void *segment; |
Tom Finegan | 03848f5 | 2013-11-05 10:02:18 -0800 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | /* Stereo 3D packed frame format */ |
Satish Kumar Suman | 4667aa1 | 2018-12-14 18:28:19 +0530 | [diff] [blame] | 34 | enum { |
Tom Finegan | 1f0c2e7 | 2013-11-06 10:02:31 -0800 | [diff] [blame] | 35 | STEREO_FORMAT_MONO = 0, |
Tom Finegan | 03848f5 | 2013-11-05 10:02:18 -0800 | [diff] [blame] | 36 | 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 Suman | 4667aa1 | 2018-12-14 18:28:19 +0530 | [diff] [blame] | 40 | } UENUM1BYTE(stereo_format_t); |
Tom Finegan | 03848f5 | 2013-11-05 10:02:18 -0800 | [diff] [blame] | 41 | |
Elliott Karpilovsky | 4e55eb7 | 2020-05-14 14:16:24 -0700 | [diff] [blame] | 42 | // 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. |
| 49 | char *extract_encoder_settings(const char *version, const char **argv, int argc, |
| 50 | const char *input_fname); |
| 51 | |
Tom Finegan | bb8157b | 2018-09-20 15:33:11 -0700 | [diff] [blame] | 52 | // The following functions wrap libwebm's mkvmuxer. All functions return 0 upon |
| 53 | // success, or -1 upon failure. |
Tom Finegan | 03848f5 | 2013-11-05 10:02:18 -0800 | [diff] [blame] | 54 | |
Tom Finegan | bb8157b | 2018-09-20 15:33:11 -0700 | [diff] [blame] | 55 | int 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 Karpilovsky | 4e55eb7 | 2020-05-14 14:16:24 -0700 | [diff] [blame] | 59 | const struct AvxRational *par, |
| 60 | const char *encoder_settings); |
Tom Finegan | 03848f5 | 2013-11-05 10:02:18 -0800 | [diff] [blame] | 61 | |
Tom Finegan | bb8157b | 2018-09-20 15:33:11 -0700 | [diff] [blame] | 62 | int write_webm_block(struct WebmOutputContext *webm_ctx, |
| 63 | const aom_codec_enc_cfg_t *cfg, |
| 64 | const aom_codec_cx_pkt_t *pkt); |
| 65 | |
| 66 | int write_webm_file_footer(struct WebmOutputContext *webm_ctx); |
Tom Finegan | 03848f5 | 2013-11-05 10:02:18 -0800 | [diff] [blame] | 67 | |
James Zern | 25cfd8e | 2014-01-18 12:16:11 -0800 | [diff] [blame] | 68 | #ifdef __cplusplus |
| 69 | } // extern "C" |
| 70 | #endif |
| 71 | |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 72 | #endif // AOM_COMMON_WEBMENC_H_ |