Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
| 3 | * |
| 4 | * This source code is subject to the terms of the BSD 2 Clause License and |
| 5 | * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License |
| 6 | * was not distributed with this source code in the LICENSE file, you can |
| 7 | * obtain it at www.aomedia.org/license/software. If the Alliance for Open |
| 8 | * Media Patent License 1.0 was not distributed with this source code in the |
| 9 | * PATENTS file, you can obtain it at www.aomedia.org/license/patent. |
| 10 | */ |
| 11 | |
| 12 | // Inspect Decoder |
| 13 | // ================ |
| 14 | // |
| 15 | // This is a simple decoder loop that writes JSON stats to stdout. This tool |
| 16 | // can also be compiled with Emscripten and used as a library. |
| 17 | |
| 18 | #include <stdio.h> |
| 19 | #include <stdlib.h> |
| 20 | #include <string.h> |
| 21 | |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 22 | #ifdef __EMSCRIPTEN__ |
| 23 | #include <emscripten.h> |
| 24 | #else |
| 25 | #define EMSCRIPTEN_KEEPALIVE |
| 26 | #endif |
| 27 | |
Tom Finegan | 60e653d | 2018-05-22 11:34:58 -0700 | [diff] [blame] | 28 | #include "config/aom_config.h" |
Tom Finegan | 7790213 | 2018-05-21 10:19:15 -0700 | [diff] [blame] | 29 | |
| 30 | #include "aom/aom_decoder.h" |
Nathan E. Egge | 1e41275 | 2017-05-04 21:09:39 -0400 | [diff] [blame] | 31 | #include "aom/aomdx.h" |
Wan-Teh Chang | f2d15ee | 2020-03-10 09:24:43 -0700 | [diff] [blame] | 32 | #include "av1/common/av1_common_int.h" |
Nathan E. Egge | 1e41275 | 2017-05-04 21:09:39 -0400 | [diff] [blame] | 33 | |
Tom Finegan | 7790213 | 2018-05-21 10:19:15 -0700 | [diff] [blame] | 34 | #if CONFIG_ACCOUNTING |
| 35 | #include "av1/decoder/accounting.h" |
| 36 | #endif |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 37 | |
Tom Finegan | 7790213 | 2018-05-21 10:19:15 -0700 | [diff] [blame] | 38 | #include "av1/decoder/inspection.h" |
| 39 | #include "common/args.h" |
| 40 | #include "common/tools_common.h" |
| 41 | #include "common/video_common.h" |
| 42 | #include "common/video_reader.h" |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 43 | |
| 44 | // Max JSON buffer size. |
Sarah Parker | c531345 | 2019-04-25 12:22:58 -0700 | [diff] [blame] | 45 | const int MAX_BUFFER = 1024 * 1024 * 256; |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 46 | |
| 47 | typedef enum { |
| 48 | ACCOUNTING_LAYER = 1, |
| 49 | BLOCK_SIZE_LAYER = 1 << 1, |
| 50 | TRANSFORM_SIZE_LAYER = 1 << 2, |
| 51 | TRANSFORM_TYPE_LAYER = 1 << 3, |
| 52 | MODE_LAYER = 1 << 4, |
| 53 | SKIP_LAYER = 1 << 5, |
| 54 | FILTER_LAYER = 1 << 6, |
| 55 | CDEF_LAYER = 1 << 7, |
| 56 | REFERENCE_FRAME_LAYER = 1 << 8, |
| 57 | MOTION_VECTORS_LAYER = 1 << 9, |
Luc Trudeau | 0be435a | 2017-04-07 23:38:52 -0400 | [diff] [blame] | 58 | UV_MODE_LAYER = 1 << 10, |
Luc Trudeau | f89056a | 2017-04-28 16:07:22 -0400 | [diff] [blame] | 59 | CFL_LAYER = 1 << 11, |
Ankur Saxena | 6e6b697 | 2017-10-20 22:10:10 -0700 | [diff] [blame] | 60 | DUAL_FILTER_LAYER = 1 << 12, |
Yushin Cho | c24351c | 2017-10-24 14:59:08 -0700 | [diff] [blame] | 61 | Q_INDEX_LAYER = 1 << 13, |
Yushin Cho | 4be87e0 | 2017-10-25 16:27:04 -0700 | [diff] [blame] | 62 | SEGMENT_ID_LAYER = 1 << 14, |
Jim Bankoski | 21b68a0 | 2018-10-19 13:28:25 -0700 | [diff] [blame] | 63 | MOTION_MODE_LAYER = 1 << 15, |
| 64 | COMPOUND_TYPE_LAYER = 1 << 16, |
Hui Su | 83684e1 | 2019-03-19 12:17:34 -0700 | [diff] [blame] | 65 | INTRABC_LAYER = 1 << 17, |
| 66 | PALETTE_LAYER = 1 << 18, |
| 67 | UV_PALETTE_LAYER = 1 << 19, |
| 68 | ALL_LAYERS = (1 << 20) - 1 |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 69 | } LayerType; |
| 70 | |
| 71 | static LayerType layers = 0; |
| 72 | |
| 73 | static int stop_after = 0; |
Michael Bebenita | f1207b6 | 2017-04-14 22:30:56 -0700 | [diff] [blame] | 74 | static int compress = 0; |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 75 | |
| 76 | static const arg_def_t limit_arg = |
| 77 | ARG_DEF(NULL, "limit", 1, "Stop decoding after n frames"); |
| 78 | static const arg_def_t dump_all_arg = ARG_DEF("A", "all", 0, "Dump All"); |
Michael Bebenita | f1207b6 | 2017-04-14 22:30:56 -0700 | [diff] [blame] | 79 | static const arg_def_t compress_arg = |
| 80 | ARG_DEF("x", "compress", 0, "Compress JSON using RLE"); |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 81 | static const arg_def_t dump_accounting_arg = |
| 82 | ARG_DEF("a", "accounting", 0, "Dump Accounting"); |
| 83 | static const arg_def_t dump_block_size_arg = |
| 84 | ARG_DEF("bs", "blockSize", 0, "Dump Block Size"); |
| 85 | static const arg_def_t dump_motion_vectors_arg = |
| 86 | ARG_DEF("mv", "motionVectors", 0, "Dump Motion Vectors"); |
| 87 | static const arg_def_t dump_transform_size_arg = |
| 88 | ARG_DEF("ts", "transformSize", 0, "Dump Transform Size"); |
| 89 | static const arg_def_t dump_transform_type_arg = |
| 90 | ARG_DEF("tt", "transformType", 0, "Dump Transform Type"); |
| 91 | static const arg_def_t dump_mode_arg = ARG_DEF("m", "mode", 0, "Dump Mode"); |
Jim Bankoski | 21b68a0 | 2018-10-19 13:28:25 -0700 | [diff] [blame] | 92 | static const arg_def_t dump_motion_mode_arg = |
| 93 | ARG_DEF("mm", "motion_mode", 0, "Dump Motion Modes"); |
| 94 | static const arg_def_t dump_compound_type_arg = |
| 95 | ARG_DEF("ct", "compound_type", 0, "Dump Compound Types"); |
Luc Trudeau | 0be435a | 2017-04-07 23:38:52 -0400 | [diff] [blame] | 96 | static const arg_def_t dump_uv_mode_arg = |
| 97 | ARG_DEF("uvm", "uv_mode", 0, "Dump UV Intra Prediction Modes"); |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 98 | static const arg_def_t dump_skip_arg = ARG_DEF("s", "skip", 0, "Dump Skip"); |
| 99 | static const arg_def_t dump_filter_arg = |
| 100 | ARG_DEF("f", "filter", 0, "Dump Filter"); |
| 101 | static const arg_def_t dump_cdef_arg = ARG_DEF("c", "cdef", 0, "Dump CDEF"); |
Luc Trudeau | f89056a | 2017-04-28 16:07:22 -0400 | [diff] [blame] | 102 | static const arg_def_t dump_cfl_arg = |
| 103 | ARG_DEF("cfl", "chroma_from_luma", 0, "Dump Chroma from Luma Alphas"); |
Ankur Saxena | 6e6b697 | 2017-10-20 22:10:10 -0700 | [diff] [blame] | 104 | static const arg_def_t dump_dual_filter_type_arg = |
| 105 | ARG_DEF("df", "dualFilterType", 0, "Dump Dual Filter Type"); |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 106 | static const arg_def_t dump_reference_frame_arg = |
| 107 | ARG_DEF("r", "referenceFrame", 0, "Dump Reference Frame"); |
Yushin Cho | c24351c | 2017-10-24 14:59:08 -0700 | [diff] [blame] | 108 | static const arg_def_t dump_delta_q_arg = |
| 109 | ARG_DEF("dq", "delta_q", 0, "Dump QIndex"); |
Yushin Cho | 4be87e0 | 2017-10-25 16:27:04 -0700 | [diff] [blame] | 110 | static const arg_def_t dump_seg_id_arg = |
| 111 | ARG_DEF("si", "seg_id", 0, "Dump Segment ID"); |
Hui Su | 83684e1 | 2019-03-19 12:17:34 -0700 | [diff] [blame] | 112 | static const arg_def_t dump_intrabc_arg = |
| 113 | ARG_DEF("ibc", "intrabc", 0, "Dump If IntraBC Is Used"); |
| 114 | static const arg_def_t dump_palette_arg = |
| 115 | ARG_DEF("plt", "palette", 0, "Dump Palette Size"); |
| 116 | static const arg_def_t dump_uv_palette_arg = |
| 117 | ARG_DEF("uvp", "uv_palette", 0, "Dump UV Palette Size"); |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 118 | static const arg_def_t usage_arg = ARG_DEF("h", "help", 0, "Help"); |
Jim Bankoski | c04ce61 | 2018-12-20 15:45:33 -0800 | [diff] [blame] | 119 | static const arg_def_t skip_non_transform_arg = ARG_DEF( |
| 120 | "snt", "skip_non_transform", 1, "Skip is counted as a non transform."); |
Jim Bankoski | 2b4176f | 2019-01-17 06:36:01 -0800 | [diff] [blame] | 121 | static const arg_def_t combined_arg = |
| 122 | ARG_DEF("comb", "combined", 1, "combinining parameters into one output."); |
| 123 | |
Jim Bankoski | 2e55dde | 2019-01-29 14:12:15 +0000 | [diff] [blame] | 124 | int combined_parm_list[15]; |
Jim Bankoski | 2b4176f | 2019-01-17 06:36:01 -0800 | [diff] [blame] | 125 | int combined_parm_count = 0; |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 126 | |
| 127 | static const arg_def_t *main_args[] = { &limit_arg, |
| 128 | &dump_all_arg, |
Michael Bebenita | f1207b6 | 2017-04-14 22:30:56 -0700 | [diff] [blame] | 129 | &compress_arg, |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 130 | #if CONFIG_ACCOUNTING |
| 131 | &dump_accounting_arg, |
| 132 | #endif |
| 133 | &dump_block_size_arg, |
| 134 | &dump_transform_size_arg, |
| 135 | &dump_transform_type_arg, |
| 136 | &dump_mode_arg, |
Luc Trudeau | 0be435a | 2017-04-07 23:38:52 -0400 | [diff] [blame] | 137 | &dump_uv_mode_arg, |
Jim Bankoski | 21b68a0 | 2018-10-19 13:28:25 -0700 | [diff] [blame] | 138 | &dump_motion_mode_arg, |
| 139 | &dump_compound_type_arg, |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 140 | &dump_skip_arg, |
| 141 | &dump_filter_arg, |
| 142 | &dump_cdef_arg, |
Ankur Saxena | 6e6b697 | 2017-10-20 22:10:10 -0700 | [diff] [blame] | 143 | &dump_dual_filter_type_arg, |
Luc Trudeau | f89056a | 2017-04-28 16:07:22 -0400 | [diff] [blame] | 144 | &dump_cfl_arg, |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 145 | &dump_reference_frame_arg, |
| 146 | &dump_motion_vectors_arg, |
Yushin Cho | c24351c | 2017-10-24 14:59:08 -0700 | [diff] [blame] | 147 | &dump_delta_q_arg, |
Yushin Cho | 4be87e0 | 2017-10-25 16:27:04 -0700 | [diff] [blame] | 148 | &dump_seg_id_arg, |
Hui Su | 83684e1 | 2019-03-19 12:17:34 -0700 | [diff] [blame] | 149 | &dump_intrabc_arg, |
| 150 | &dump_palette_arg, |
| 151 | &dump_uv_palette_arg, |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 152 | &usage_arg, |
Jim Bankoski | c04ce61 | 2018-12-20 15:45:33 -0800 | [diff] [blame] | 153 | &skip_non_transform_arg, |
Jim Bankoski | 2b4176f | 2019-01-17 06:36:01 -0800 | [diff] [blame] | 154 | &combined_arg, |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 155 | NULL }; |
| 156 | #define ENUM(name) \ |
| 157 | { #name, name } |
| 158 | #define LAST_ENUM \ |
| 159 | { NULL, 0 } |
| 160 | typedef struct map_entry { |
| 161 | const char *name; |
| 162 | int value; |
| 163 | } map_entry; |
| 164 | |
Michael Bebenita | b9f5256 | 2017-10-30 16:18:18 -0700 | [diff] [blame] | 165 | const map_entry refs_map[] = { |
| 166 | ENUM(INTRA_FRAME), ENUM(LAST_FRAME), ENUM(LAST2_FRAME), |
| 167 | ENUM(LAST3_FRAME), ENUM(GOLDEN_FRAME), ENUM(BWDREF_FRAME), |
| 168 | ENUM(ALTREF2_FRAME), ENUM(ALTREF_FRAME), LAST_ENUM |
| 169 | }; |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 170 | |
Yue Chen | 8fe9eda | 2018-03-21 14:41:58 -0700 | [diff] [blame] | 171 | const map_entry block_size_map[] = { |
| 172 | ENUM(BLOCK_4X4), ENUM(BLOCK_4X8), ENUM(BLOCK_8X4), |
| 173 | ENUM(BLOCK_8X8), ENUM(BLOCK_8X16), ENUM(BLOCK_16X8), |
| 174 | ENUM(BLOCK_16X16), ENUM(BLOCK_16X32), ENUM(BLOCK_32X16), |
| 175 | ENUM(BLOCK_32X32), ENUM(BLOCK_32X64), ENUM(BLOCK_64X32), |
| 176 | ENUM(BLOCK_64X64), ENUM(BLOCK_64X128), ENUM(BLOCK_128X64), |
| 177 | ENUM(BLOCK_128X128), ENUM(BLOCK_4X16), ENUM(BLOCK_16X4), |
| 178 | ENUM(BLOCK_8X32), ENUM(BLOCK_32X8), ENUM(BLOCK_16X64), |
| 179 | ENUM(BLOCK_64X16), LAST_ENUM |
| 180 | }; |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 181 | |
Jim Bankoski | c04ce61 | 2018-12-20 15:45:33 -0800 | [diff] [blame] | 182 | #define TX_SKIP -1 |
| 183 | |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 184 | const map_entry tx_size_map[] = { |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 185 | ENUM(TX_4X4), ENUM(TX_8X8), ENUM(TX_16X16), ENUM(TX_32X32), |
Yaowu Xu | d3d4159 | 2018-02-14 13:26:52 -0800 | [diff] [blame] | 186 | ENUM(TX_64X64), ENUM(TX_4X8), ENUM(TX_8X4), ENUM(TX_8X16), |
| 187 | ENUM(TX_16X8), ENUM(TX_16X32), ENUM(TX_32X16), ENUM(TX_32X64), |
| 188 | ENUM(TX_64X32), ENUM(TX_4X16), ENUM(TX_16X4), ENUM(TX_8X32), |
Jim Bankoski | b2eb1ab | 2018-10-16 10:19:45 -0700 | [diff] [blame] | 189 | ENUM(TX_32X8), ENUM(TX_16X64), ENUM(TX_64X16), LAST_ENUM |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 190 | }; |
| 191 | |
| 192 | const map_entry tx_type_map[] = { ENUM(DCT_DCT), |
| 193 | ENUM(ADST_DCT), |
| 194 | ENUM(DCT_ADST), |
| 195 | ENUM(ADST_ADST), |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 196 | ENUM(FLIPADST_DCT), |
| 197 | ENUM(DCT_FLIPADST), |
| 198 | ENUM(FLIPADST_FLIPADST), |
| 199 | ENUM(ADST_FLIPADST), |
| 200 | ENUM(FLIPADST_ADST), |
| 201 | ENUM(IDTX), |
| 202 | ENUM(V_DCT), |
| 203 | ENUM(H_DCT), |
| 204 | ENUM(V_ADST), |
| 205 | ENUM(H_ADST), |
| 206 | ENUM(V_FLIPADST), |
| 207 | ENUM(H_FLIPADST), |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 208 | LAST_ENUM }; |
Ankur Saxena | 6e6b697 | 2017-10-20 22:10:10 -0700 | [diff] [blame] | 209 | const map_entry dual_filter_map[] = { ENUM(REG_REG), ENUM(REG_SMOOTH), |
| 210 | ENUM(REG_SHARP), ENUM(SMOOTH_REG), |
| 211 | ENUM(SMOOTH_SMOOTH), ENUM(SMOOTH_SHARP), |
| 212 | ENUM(SHARP_REG), ENUM(SHARP_SMOOTH), |
| 213 | ENUM(SHARP_SHARP), LAST_ENUM }; |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 214 | |
Sebastien Alaiwan | 0bdea0d | 2017-10-02 15:15:05 +0200 | [diff] [blame] | 215 | const map_entry prediction_mode_map[] = { |
Urvang Joshi | b7301cd | 2017-11-09 15:08:56 -0800 | [diff] [blame] | 216 | ENUM(DC_PRED), ENUM(V_PRED), ENUM(H_PRED), |
Hui Su | 69ae7b8 | 2018-02-20 20:10:51 -0800 | [diff] [blame] | 217 | ENUM(D45_PRED), ENUM(D135_PRED), ENUM(D113_PRED), |
| 218 | ENUM(D157_PRED), ENUM(D203_PRED), ENUM(D67_PRED), |
Urvang Joshi | b7301cd | 2017-11-09 15:08:56 -0800 | [diff] [blame] | 219 | ENUM(SMOOTH_PRED), ENUM(SMOOTH_V_PRED), ENUM(SMOOTH_H_PRED), |
| 220 | ENUM(PAETH_PRED), ENUM(NEARESTMV), ENUM(NEARMV), |
| 221 | ENUM(GLOBALMV), ENUM(NEWMV), ENUM(NEAREST_NEARESTMV), |
| 222 | ENUM(NEAR_NEARMV), ENUM(NEAREST_NEWMV), ENUM(NEW_NEARESTMV), |
| 223 | ENUM(NEAR_NEWMV), ENUM(NEW_NEARMV), ENUM(GLOBAL_GLOBALMV), |
| 224 | ENUM(NEW_NEWMV), ENUM(INTRA_INVALID), LAST_ENUM |
Sebastien Alaiwan | 0bdea0d | 2017-10-02 15:15:05 +0200 | [diff] [blame] | 225 | }; |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 226 | |
Jim Bankoski | 21b68a0 | 2018-10-19 13:28:25 -0700 | [diff] [blame] | 227 | const map_entry motion_mode_map[] = { ENUM(SIMPLE_TRANSLATION), |
| 228 | ENUM(OBMC_CAUSAL), // 2-sided OBMC |
| 229 | ENUM(WARPED_CAUSAL), // 2-sided WARPED |
| 230 | LAST_ENUM }; |
| 231 | |
| 232 | const map_entry compound_type_map[] = { ENUM(COMPOUND_AVERAGE), |
| 233 | ENUM(COMPOUND_WEDGE), |
| 234 | ENUM(COMPOUND_DIFFWTD), LAST_ENUM }; |
| 235 | |
Luc Trudeau | d6d9eee | 2017-07-12 12:36:50 -0400 | [diff] [blame] | 236 | const map_entry uv_prediction_mode_map[] = { |
Luc Trudeau | 6e1cd78 | 2017-06-21 13:52:36 -0400 | [diff] [blame] | 237 | ENUM(UV_DC_PRED), ENUM(UV_V_PRED), |
| 238 | ENUM(UV_H_PRED), ENUM(UV_D45_PRED), |
Hui Su | 69ae7b8 | 2018-02-20 20:10:51 -0800 | [diff] [blame] | 239 | ENUM(UV_D135_PRED), ENUM(UV_D113_PRED), |
| 240 | ENUM(UV_D157_PRED), ENUM(UV_D203_PRED), |
| 241 | ENUM(UV_D67_PRED), ENUM(UV_SMOOTH_PRED), |
Luc Trudeau | d6d9eee | 2017-07-12 12:36:50 -0400 | [diff] [blame] | 242 | ENUM(UV_SMOOTH_V_PRED), ENUM(UV_SMOOTH_H_PRED), |
Luc Trudeau | 3ec16a3 | 2018-03-01 20:58:09 -0500 | [diff] [blame] | 243 | ENUM(UV_PAETH_PRED), ENUM(UV_CFL_PRED), |
Luc Trudeau | 6e1cd78 | 2017-06-21 13:52:36 -0400 | [diff] [blame] | 244 | ENUM(UV_MODE_INVALID), LAST_ENUM |
Luc Trudeau | d6d9eee | 2017-07-12 12:36:50 -0400 | [diff] [blame] | 245 | }; |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 246 | #define NO_SKIP 0 |
| 247 | #define SKIP 1 |
| 248 | |
| 249 | const map_entry skip_map[] = { ENUM(SKIP), ENUM(NO_SKIP), LAST_ENUM }; |
| 250 | |
Hien Ho | 830b897 | 2019-04-04 15:51:14 -0700 | [diff] [blame] | 251 | const map_entry intrabc_map[] = { { "INTRABC", 1 }, |
| 252 | { "NO_INTRABC", 0 }, |
| 253 | LAST_ENUM }; |
Hui Su | 83684e1 | 2019-03-19 12:17:34 -0700 | [diff] [blame] | 254 | |
| 255 | const map_entry palette_map[] = { |
| 256 | { "ZERO_COLORS", 0 }, { "TWO_COLORS", 2 }, { "THREE_COLORS", 3 }, |
| 257 | { "FOUR_COLORS", 4 }, { "FIVE_COLORS", 5 }, { "SIX_COLORS", 6 }, |
| 258 | { "SEVEN_COLORS", 7 }, { "EIGHT_COLORS", 8 }, LAST_ENUM |
| 259 | }; |
| 260 | |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 261 | const map_entry config_map[] = { ENUM(MI_SIZE), LAST_ENUM }; |
| 262 | |
| 263 | static const char *exec_name; |
| 264 | |
Jim Bankoski | 2b4176f | 2019-01-17 06:36:01 -0800 | [diff] [blame] | 265 | struct parm_offset { |
| 266 | char parm[60]; |
| 267 | char offset; |
| 268 | }; |
| 269 | struct parm_offset parm_offsets[] = { |
| 270 | { "blockSize", offsetof(insp_mi_data, sb_type) }, |
| 271 | { "transformSize", offsetof(insp_mi_data, tx_size) }, |
| 272 | { "transformType", offsetof(insp_mi_data, tx_type) }, |
| 273 | { "dualFilterType", offsetof(insp_mi_data, dual_filter_type) }, |
| 274 | { "mode", offsetof(insp_mi_data, mode) }, |
| 275 | { "uv_mode", offsetof(insp_mi_data, uv_mode) }, |
| 276 | { "motion_mode", offsetof(insp_mi_data, motion_mode) }, |
| 277 | { "compound_type", offsetof(insp_mi_data, compound_type) }, |
| 278 | { "referenceFrame", offsetof(insp_mi_data, ref_frame) }, |
| 279 | { "skip", offsetof(insp_mi_data, skip) }, |
| 280 | }; |
| 281 | int parm_count = sizeof(parm_offsets) / sizeof(parm_offsets[0]); |
| 282 | |
| 283 | int convert_to_indices(char *str, int *indices, int maxCount, int *count) { |
| 284 | *count = 0; |
| 285 | do { |
| 286 | char *comma = strchr(str, ','); |
| 287 | int length = (comma ? (int)(comma - str) : (int)strlen(str)); |
| 288 | int i; |
| 289 | for (i = 0; i < parm_count; ++i) { |
| 290 | if (!strncmp(str, parm_offsets[i].parm, length)) { |
| 291 | break; |
| 292 | } |
| 293 | } |
| 294 | if (i == parm_count) return 0; |
| 295 | indices[(*count)++] = i; |
| 296 | if (*count > maxCount) return 0; |
| 297 | str += length + 1; |
| 298 | } while (strlen(str) > 0); |
| 299 | return 1; |
| 300 | } |
| 301 | |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 302 | insp_frame_data frame_data; |
| 303 | int frame_count = 0; |
| 304 | int decoded_frame_count = 0; |
| 305 | aom_codec_ctx_t codec; |
| 306 | AvxVideoReader *reader = NULL; |
| 307 | const AvxVideoInfo *info = NULL; |
| 308 | aom_image_t *img = NULL; |
| 309 | |
| 310 | void on_frame_decoded_dump(char *json) { |
| 311 | #ifdef __EMSCRIPTEN__ |
| 312 | EM_ASM_({ Module.on_frame_decoded_json($0); }, json); |
| 313 | #else |
| 314 | printf("%s", json); |
| 315 | #endif |
| 316 | } |
| 317 | |
| 318 | // Writing out the JSON buffer using snprintf is very slow, especially when |
| 319 | // compiled with emscripten, these functions speed things up quite a bit. |
| 320 | int put_str(char *buffer, const char *str) { |
| 321 | int i; |
| 322 | for (i = 0; str[i] != '\0'; i++) { |
| 323 | buffer[i] = str[i]; |
| 324 | } |
| 325 | return i; |
| 326 | } |
| 327 | |
Michael Bebenita | 4aee17d | 2017-07-05 14:03:36 -0700 | [diff] [blame] | 328 | int put_str_with_escape(char *buffer, const char *str) { |
| 329 | int i; |
| 330 | int j = 0; |
| 331 | for (i = 0; str[i] != '\0'; i++) { |
Thomas Daede | 3a1bd78 | 2017-07-21 12:17:10 -0700 | [diff] [blame] | 332 | if (str[i] < ' ') { |
| 333 | continue; |
| 334 | } else if (str[i] == '"' || str[i] == '\\') { |
Michael Bebenita | 4aee17d | 2017-07-05 14:03:36 -0700 | [diff] [blame] | 335 | buffer[j++] = '\\'; |
| 336 | } |
| 337 | buffer[j++] = str[i]; |
| 338 | } |
| 339 | return j; |
| 340 | } |
| 341 | |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 342 | int put_num(char *buffer, char prefix, int num, char suffix) { |
| 343 | int i = 0; |
| 344 | char *buf = buffer; |
| 345 | int is_neg = 0; |
| 346 | if (prefix) { |
| 347 | buf[i++] = prefix; |
| 348 | } |
| 349 | if (num == 0) { |
| 350 | buf[i++] = '0'; |
| 351 | } else { |
| 352 | if (num < 0) { |
| 353 | num = -num; |
| 354 | is_neg = 1; |
| 355 | } |
| 356 | int s = i; |
| 357 | while (num != 0) { |
| 358 | buf[i++] = '0' + (num % 10); |
| 359 | num = num / 10; |
| 360 | } |
| 361 | if (is_neg) { |
| 362 | buf[i++] = '-'; |
| 363 | } |
| 364 | int e = i - 1; |
| 365 | while (s < e) { |
| 366 | int t = buf[s]; |
| 367 | buf[s] = buf[e]; |
| 368 | buf[e] = t; |
| 369 | s++; |
| 370 | e--; |
| 371 | } |
| 372 | } |
| 373 | if (suffix) { |
| 374 | buf[i++] = suffix; |
| 375 | } |
| 376 | return i; |
| 377 | } |
| 378 | |
| 379 | int put_map(char *buffer, const map_entry *map) { |
| 380 | char *buf = buffer; |
| 381 | const map_entry *entry = map; |
| 382 | while (entry->name != NULL) { |
| 383 | *(buf++) = '"'; |
| 384 | buf += put_str(buf, entry->name); |
| 385 | *(buf++) = '"'; |
| 386 | buf += put_num(buf, ':', entry->value, 0); |
| 387 | entry++; |
| 388 | if (entry->name != NULL) { |
| 389 | *(buf++) = ','; |
| 390 | } |
| 391 | } |
Yushin Cho | f674157 | 2017-10-24 20:07:46 -0700 | [diff] [blame] | 392 | return (int)(buf - buffer); |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 393 | } |
| 394 | |
| 395 | int put_reference_frame(char *buffer) { |
| 396 | const int mi_rows = frame_data.mi_rows; |
| 397 | const int mi_cols = frame_data.mi_cols; |
| 398 | char *buf = buffer; |
Michael Bebenita | f1207b6 | 2017-04-14 22:30:56 -0700 | [diff] [blame] | 399 | int r, c, t; |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 400 | buf += put_str(buf, " \"referenceFrameMap\": {"); |
| 401 | buf += put_map(buf, refs_map); |
| 402 | buf += put_str(buf, "},\n"); |
| 403 | buf += put_str(buf, " \"referenceFrame\": ["); |
| 404 | for (r = 0; r < mi_rows; ++r) { |
| 405 | *(buf++) = '['; |
| 406 | for (c = 0; c < mi_cols; ++c) { |
| 407 | insp_mi_data *mi = &frame_data.mi_grid[r * mi_cols + c]; |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 408 | buf += put_num(buf, '[', mi->ref_frame[0], 0); |
| 409 | buf += put_num(buf, ',', mi->ref_frame[1], ']'); |
Michael Bebenita | f1207b6 | 2017-04-14 22:30:56 -0700 | [diff] [blame] | 410 | if (compress) { // RLE |
| 411 | for (t = c + 1; t < mi_cols; ++t) { |
| 412 | insp_mi_data *next_mi = &frame_data.mi_grid[r * mi_cols + t]; |
| 413 | if (mi->ref_frame[0] != next_mi->ref_frame[0] || |
| 414 | mi->ref_frame[1] != next_mi->ref_frame[1]) { |
| 415 | break; |
| 416 | } |
| 417 | } |
| 418 | if (t - c > 1) { |
| 419 | *(buf++) = ','; |
| 420 | buf += put_num(buf, '[', t - c - 1, ']'); |
| 421 | c = t - 1; |
| 422 | } |
| 423 | } |
| 424 | if (c < mi_cols - 1) *(buf++) = ','; |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 425 | } |
| 426 | *(buf++) = ']'; |
| 427 | if (r < mi_rows - 1) *(buf++) = ','; |
| 428 | } |
| 429 | buf += put_str(buf, "],\n"); |
Yushin Cho | f674157 | 2017-10-24 20:07:46 -0700 | [diff] [blame] | 430 | return (int)(buf - buffer); |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 431 | } |
| 432 | |
| 433 | int put_motion_vectors(char *buffer) { |
| 434 | const int mi_rows = frame_data.mi_rows; |
| 435 | const int mi_cols = frame_data.mi_cols; |
| 436 | char *buf = buffer; |
Michael Bebenita | f1207b6 | 2017-04-14 22:30:56 -0700 | [diff] [blame] | 437 | int r, c, t; |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 438 | buf += put_str(buf, " \"motionVectors\": ["); |
| 439 | for (r = 0; r < mi_rows; ++r) { |
| 440 | *(buf++) = '['; |
| 441 | for (c = 0; c < mi_cols; ++c) { |
| 442 | insp_mi_data *mi = &frame_data.mi_grid[r * mi_cols + c]; |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 443 | buf += put_num(buf, '[', mi->mv[0].col, 0); |
| 444 | buf += put_num(buf, ',', mi->mv[0].row, 0); |
| 445 | buf += put_num(buf, ',', mi->mv[1].col, 0); |
| 446 | buf += put_num(buf, ',', mi->mv[1].row, ']'); |
Michael Bebenita | f1207b6 | 2017-04-14 22:30:56 -0700 | [diff] [blame] | 447 | if (compress) { // RLE |
| 448 | for (t = c + 1; t < mi_cols; ++t) { |
| 449 | insp_mi_data *next_mi = &frame_data.mi_grid[r * mi_cols + t]; |
| 450 | if (mi->mv[0].col != next_mi->mv[0].col || |
| 451 | mi->mv[0].row != next_mi->mv[0].row || |
| 452 | mi->mv[1].col != next_mi->mv[1].col || |
| 453 | mi->mv[1].row != next_mi->mv[1].row) { |
| 454 | break; |
| 455 | } |
| 456 | } |
| 457 | if (t - c > 1) { |
| 458 | *(buf++) = ','; |
| 459 | buf += put_num(buf, '[', t - c - 1, ']'); |
| 460 | c = t - 1; |
| 461 | } |
| 462 | } |
| 463 | if (c < mi_cols - 1) *(buf++) = ','; |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 464 | } |
| 465 | *(buf++) = ']'; |
| 466 | if (r < mi_rows - 1) *(buf++) = ','; |
| 467 | } |
| 468 | buf += put_str(buf, "],\n"); |
Yushin Cho | f674157 | 2017-10-24 20:07:46 -0700 | [diff] [blame] | 469 | return (int)(buf - buffer); |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 470 | } |
| 471 | |
Jim Bankoski | 2b4176f | 2019-01-17 06:36:01 -0800 | [diff] [blame] | 472 | int put_combined(char *buffer) { |
| 473 | const int mi_rows = frame_data.mi_rows; |
| 474 | const int mi_cols = frame_data.mi_cols; |
| 475 | char *buf = buffer; |
| 476 | int r, c, p; |
| 477 | buf += put_str(buf, " \""); |
| 478 | for (p = 0; p < combined_parm_count; ++p) { |
| 479 | if (p) buf += put_str(buf, "&"); |
| 480 | buf += put_str(buf, parm_offsets[combined_parm_list[p]].parm); |
| 481 | } |
| 482 | buf += put_str(buf, "\": ["); |
| 483 | for (r = 0; r < mi_rows; ++r) { |
| 484 | *(buf++) = '['; |
| 485 | for (c = 0; c < mi_cols; ++c) { |
| 486 | insp_mi_data *mi = &frame_data.mi_grid[r * mi_cols + c]; |
| 487 | *(buf++) = '['; |
| 488 | for (p = 0; p < combined_parm_count; ++p) { |
| 489 | if (p) *(buf++) = ','; |
| 490 | int16_t *v = (int16_t *)(((int8_t *)mi) + |
| 491 | parm_offsets[combined_parm_list[p]].offset); |
| 492 | buf += put_num(buf, 0, v[0], 0); |
| 493 | } |
| 494 | *(buf++) = ']'; |
| 495 | if (c < mi_cols - 1) *(buf++) = ','; |
| 496 | } |
| 497 | *(buf++) = ']'; |
| 498 | if (r < mi_rows - 1) *(buf++) = ','; |
| 499 | } |
| 500 | buf += put_str(buf, "],\n"); |
| 501 | return (int)(buf - buffer); |
| 502 | } |
| 503 | |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 504 | int put_block_info(char *buffer, const map_entry *map, const char *name, |
Michael Bebenita | 14e1b74 | 2017-10-24 12:49:15 -0700 | [diff] [blame] | 505 | size_t offset, int len) { |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 506 | const int mi_rows = frame_data.mi_rows; |
| 507 | const int mi_cols = frame_data.mi_cols; |
| 508 | char *buf = buffer; |
Michael Bebenita | 14e1b74 | 2017-10-24 12:49:15 -0700 | [diff] [blame] | 509 | int r, c, t, i; |
| 510 | if (compress && len == 1) { |
| 511 | die("Can't encode scalars as arrays when RLE compression is enabled."); |
| 512 | return -1; |
| 513 | } |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 514 | if (map) { |
| 515 | buf += snprintf(buf, MAX_BUFFER, " \"%sMap\": {", name); |
| 516 | buf += put_map(buf, map); |
| 517 | buf += put_str(buf, "},\n"); |
| 518 | } |
| 519 | buf += snprintf(buf, MAX_BUFFER, " \"%s\": [", name); |
| 520 | for (r = 0; r < mi_rows; ++r) { |
| 521 | *(buf++) = '['; |
| 522 | for (c = 0; c < mi_cols; ++c) { |
Michael Bebenita | 14e1b74 | 2017-10-24 12:49:15 -0700 | [diff] [blame] | 523 | insp_mi_data *mi = &frame_data.mi_grid[r * mi_cols + c]; |
Yushin Cho | c24351c | 2017-10-24 14:59:08 -0700 | [diff] [blame] | 524 | int16_t *v = (int16_t *)(((int8_t *)mi) + offset); |
Michael Bebenita | 14e1b74 | 2017-10-24 12:49:15 -0700 | [diff] [blame] | 525 | if (len == 0) { |
| 526 | buf += put_num(buf, 0, v[0], 0); |
| 527 | } else { |
| 528 | buf += put_str(buf, "["); |
| 529 | for (i = 0; i < len; i++) { |
| 530 | buf += put_num(buf, 0, v[i], 0); |
| 531 | if (i < len - 1) { |
| 532 | buf += put_str(buf, ","); |
| 533 | } |
| 534 | } |
| 535 | buf += put_str(buf, "]"); |
| 536 | } |
Michael Bebenita | f1207b6 | 2017-04-14 22:30:56 -0700 | [diff] [blame] | 537 | if (compress) { // RLE |
| 538 | for (t = c + 1; t < mi_cols; ++t) { |
| 539 | insp_mi_data *next_mi = &frame_data.mi_grid[r * mi_cols + t]; |
Yushin Cho | c24351c | 2017-10-24 14:59:08 -0700 | [diff] [blame] | 540 | int16_t *nv = (int16_t *)(((int8_t *)next_mi) + offset); |
Michael Bebenita | 14e1b74 | 2017-10-24 12:49:15 -0700 | [diff] [blame] | 541 | int same = 0; |
| 542 | if (len == 0) { |
| 543 | same = v[0] == nv[0]; |
| 544 | } else { |
| 545 | for (i = 0; i < len; i++) { |
| 546 | same = v[i] == nv[i]; |
| 547 | if (!same) { |
| 548 | break; |
| 549 | } |
| 550 | } |
| 551 | } |
| 552 | if (!same) { |
Michael Bebenita | f1207b6 | 2017-04-14 22:30:56 -0700 | [diff] [blame] | 553 | break; |
| 554 | } |
| 555 | } |
| 556 | if (t - c > 1) { |
| 557 | *(buf++) = ','; |
| 558 | buf += put_num(buf, '[', t - c - 1, ']'); |
| 559 | c = t - 1; |
| 560 | } |
| 561 | } |
| 562 | if (c < mi_cols - 1) *(buf++) = ','; |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 563 | } |
| 564 | *(buf++) = ']'; |
| 565 | if (r < mi_rows - 1) *(buf++) = ','; |
| 566 | } |
| 567 | buf += put_str(buf, "],\n"); |
Yushin Cho | f674157 | 2017-10-24 20:07:46 -0700 | [diff] [blame] | 568 | return (int)(buf - buffer); |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 569 | } |
| 570 | |
| 571 | #if CONFIG_ACCOUNTING |
| 572 | int put_accounting(char *buffer) { |
| 573 | char *buf = buffer; |
| 574 | int i; |
| 575 | const Accounting *accounting = frame_data.accounting; |
| 576 | if (accounting == NULL) { |
| 577 | printf("XXX\n"); |
| 578 | return 0; |
| 579 | } |
| 580 | const int num_syms = accounting->syms.num_syms; |
| 581 | const int num_strs = accounting->syms.dictionary.num_strs; |
| 582 | buf += put_str(buf, " \"symbolsMap\": ["); |
| 583 | for (i = 0; i < num_strs; i++) { |
| 584 | buf += snprintf(buf, MAX_BUFFER, "\"%s\"", |
| 585 | accounting->syms.dictionary.strs[i]); |
| 586 | if (i < num_strs - 1) *(buf++) = ','; |
| 587 | } |
| 588 | buf += put_str(buf, "],\n"); |
| 589 | buf += put_str(buf, " \"symbols\": [\n "); |
| 590 | AccountingSymbolContext context; |
| 591 | context.x = -2; |
| 592 | context.y = -2; |
| 593 | AccountingSymbol *sym; |
| 594 | for (i = 0; i < num_syms; i++) { |
| 595 | sym = &accounting->syms.syms[i]; |
| 596 | if (memcmp(&context, &sym->context, sizeof(AccountingSymbolContext)) != 0) { |
| 597 | buf += put_num(buf, '[', sym->context.x, 0); |
| 598 | buf += put_num(buf, ',', sym->context.y, ']'); |
| 599 | } else { |
| 600 | buf += put_num(buf, '[', sym->id, 0); |
| 601 | buf += put_num(buf, ',', sym->bits, 0); |
| 602 | buf += put_num(buf, ',', sym->samples, ']'); |
| 603 | } |
| 604 | context = sym->context; |
| 605 | if (i < num_syms - 1) *(buf++) = ','; |
| 606 | } |
| 607 | buf += put_str(buf, "],\n"); |
Yushin Cho | f674157 | 2017-10-24 20:07:46 -0700 | [diff] [blame] | 608 | return (int)(buf - buffer); |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 609 | } |
| 610 | #endif |
| 611 | |
Jim Bankoski | c04ce61 | 2018-12-20 15:45:33 -0800 | [diff] [blame] | 612 | int skip_non_transform = 0; |
| 613 | |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 614 | void inspect(void *pbi, void *data) { |
| 615 | /* Fetch frame data. */ |
Jim Bankoski | c04ce61 | 2018-12-20 15:45:33 -0800 | [diff] [blame] | 616 | ifd_inspect(&frame_data, pbi, skip_non_transform); |
Jim Bankoski | 3f73287 | 2018-10-29 06:54:18 -0700 | [diff] [blame] | 617 | |
| 618 | // Show existing frames just show a reference buffer we've already decoded. |
| 619 | // There's no information to show. |
| 620 | if (frame_data.show_existing_frame) return; |
| 621 | |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 622 | (void)data; |
| 623 | // We allocate enough space and hope we don't write out of bounds. Totally |
| 624 | // unsafe but this speeds things up, especially when compiled to Javascript. |
| 625 | char *buffer = aom_malloc(MAX_BUFFER); |
| 626 | char *buf = buffer; |
| 627 | buf += put_str(buf, "{\n"); |
| 628 | if (layers & BLOCK_SIZE_LAYER) { |
| 629 | buf += put_block_info(buf, block_size_map, "blockSize", |
Michael Bebenita | 14e1b74 | 2017-10-24 12:49:15 -0700 | [diff] [blame] | 630 | offsetof(insp_mi_data, sb_type), 0); |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 631 | } |
| 632 | if (layers & TRANSFORM_SIZE_LAYER) { |
| 633 | buf += put_block_info(buf, tx_size_map, "transformSize", |
Michael Bebenita | 14e1b74 | 2017-10-24 12:49:15 -0700 | [diff] [blame] | 634 | offsetof(insp_mi_data, tx_size), 0); |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 635 | } |
| 636 | if (layers & TRANSFORM_TYPE_LAYER) { |
| 637 | buf += put_block_info(buf, tx_type_map, "transformType", |
Michael Bebenita | 14e1b74 | 2017-10-24 12:49:15 -0700 | [diff] [blame] | 638 | offsetof(insp_mi_data, tx_type), 0); |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 639 | } |
Ankur Saxena | 6e6b697 | 2017-10-20 22:10:10 -0700 | [diff] [blame] | 640 | if (layers & DUAL_FILTER_LAYER) { |
| 641 | buf += put_block_info(buf, dual_filter_map, "dualFilterType", |
Michael Bebenita | 14e1b74 | 2017-10-24 12:49:15 -0700 | [diff] [blame] | 642 | offsetof(insp_mi_data, dual_filter_type), 0); |
Ankur Saxena | 6e6b697 | 2017-10-20 22:10:10 -0700 | [diff] [blame] | 643 | } |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 644 | if (layers & MODE_LAYER) { |
| 645 | buf += put_block_info(buf, prediction_mode_map, "mode", |
Michael Bebenita | 14e1b74 | 2017-10-24 12:49:15 -0700 | [diff] [blame] | 646 | offsetof(insp_mi_data, mode), 0); |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 647 | } |
Luc Trudeau | 0be435a | 2017-04-07 23:38:52 -0400 | [diff] [blame] | 648 | if (layers & UV_MODE_LAYER) { |
Luc Trudeau | d6d9eee | 2017-07-12 12:36:50 -0400 | [diff] [blame] | 649 | buf += put_block_info(buf, uv_prediction_mode_map, "uv_mode", |
Michael Bebenita | 14e1b74 | 2017-10-24 12:49:15 -0700 | [diff] [blame] | 650 | offsetof(insp_mi_data, uv_mode), 0); |
Luc Trudeau | 0be435a | 2017-04-07 23:38:52 -0400 | [diff] [blame] | 651 | } |
Jim Bankoski | 21b68a0 | 2018-10-19 13:28:25 -0700 | [diff] [blame] | 652 | if (layers & MOTION_MODE_LAYER) { |
| 653 | buf += put_block_info(buf, motion_mode_map, "motion_mode", |
| 654 | offsetof(insp_mi_data, motion_mode), 0); |
| 655 | } |
| 656 | if (layers & COMPOUND_TYPE_LAYER) { |
| 657 | buf += put_block_info(buf, compound_type_map, "compound_type", |
| 658 | offsetof(insp_mi_data, compound_type), 0); |
| 659 | } |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 660 | if (layers & SKIP_LAYER) { |
Michael Bebenita | 14e1b74 | 2017-10-24 12:49:15 -0700 | [diff] [blame] | 661 | buf += |
Michael Bebenita | 7a144cd | 2017-11-07 11:26:34 -0800 | [diff] [blame] | 662 | put_block_info(buf, skip_map, "skip", offsetof(insp_mi_data, skip), 0); |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 663 | } |
| 664 | if (layers & FILTER_LAYER) { |
Michael Bebenita | 14e1b74 | 2017-10-24 12:49:15 -0700 | [diff] [blame] | 665 | buf += |
| 666 | put_block_info(buf, NULL, "filter", offsetof(insp_mi_data, filter), 2); |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 667 | } |
| 668 | if (layers & CDEF_LAYER) { |
Michael Bebenita | 0955881 | 2017-04-01 20:10:53 -0700 | [diff] [blame] | 669 | buf += put_block_info(buf, NULL, "cdef_level", |
Michael Bebenita | 14e1b74 | 2017-10-24 12:49:15 -0700 | [diff] [blame] | 670 | offsetof(insp_mi_data, cdef_level), 0); |
Michael Bebenita | 0955881 | 2017-04-01 20:10:53 -0700 | [diff] [blame] | 671 | buf += put_block_info(buf, NULL, "cdef_strength", |
Michael Bebenita | 14e1b74 | 2017-10-24 12:49:15 -0700 | [diff] [blame] | 672 | offsetof(insp_mi_data, cdef_strength), 0); |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 673 | } |
Luc Trudeau | f89056a | 2017-04-28 16:07:22 -0400 | [diff] [blame] | 674 | if (layers & CFL_LAYER) { |
Luc Trudeau | a9bd85f | 2017-05-11 14:37:56 -0400 | [diff] [blame] | 675 | buf += put_block_info(buf, NULL, "cfl_alpha_idx", |
Michael Bebenita | 14e1b74 | 2017-10-24 12:49:15 -0700 | [diff] [blame] | 676 | offsetof(insp_mi_data, cfl_alpha_idx), 0); |
Luc Trudeau | 9bab28b | 2017-05-11 15:23:02 -0400 | [diff] [blame] | 677 | buf += put_block_info(buf, NULL, "cfl_alpha_sign", |
Michael Bebenita | 14e1b74 | 2017-10-24 12:49:15 -0700 | [diff] [blame] | 678 | offsetof(insp_mi_data, cfl_alpha_sign), 0); |
Luc Trudeau | f89056a | 2017-04-28 16:07:22 -0400 | [diff] [blame] | 679 | } |
Yushin Cho | c24351c | 2017-10-24 14:59:08 -0700 | [diff] [blame] | 680 | if (layers & Q_INDEX_LAYER) { |
| 681 | buf += put_block_info(buf, NULL, "delta_q", |
| 682 | offsetof(insp_mi_data, current_qindex), 0); |
| 683 | } |
Yushin Cho | 4be87e0 | 2017-10-25 16:27:04 -0700 | [diff] [blame] | 684 | if (layers & SEGMENT_ID_LAYER) { |
| 685 | buf += put_block_info(buf, NULL, "seg_id", |
| 686 | offsetof(insp_mi_data, segment_id), 0); |
| 687 | } |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 688 | if (layers & MOTION_VECTORS_LAYER) { |
| 689 | buf += put_motion_vectors(buf); |
| 690 | } |
Hui Su | 83684e1 | 2019-03-19 12:17:34 -0700 | [diff] [blame] | 691 | if (layers & INTRABC_LAYER) { |
| 692 | buf += put_block_info(buf, intrabc_map, "intrabc", |
| 693 | offsetof(insp_mi_data, intrabc), 0); |
| 694 | } |
| 695 | if (layers & PALETTE_LAYER) { |
| 696 | buf += put_block_info(buf, palette_map, "palette", |
| 697 | offsetof(insp_mi_data, palette), 0); |
| 698 | } |
| 699 | if (layers & UV_PALETTE_LAYER) { |
| 700 | buf += put_block_info(buf, palette_map, "uv_palette", |
| 701 | offsetof(insp_mi_data, uv_palette), 0); |
| 702 | } |
Jim Bankoski | 2b4176f | 2019-01-17 06:36:01 -0800 | [diff] [blame] | 703 | if (combined_parm_count > 0) buf += put_combined(buf); |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 704 | if (layers & REFERENCE_FRAME_LAYER) { |
Michael Bebenita | 14e1b74 | 2017-10-24 12:49:15 -0700 | [diff] [blame] | 705 | buf += put_block_info(buf, refs_map, "referenceFrame", |
| 706 | offsetof(insp_mi_data, ref_frame), 2); |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 707 | } |
| 708 | #if CONFIG_ACCOUNTING |
| 709 | if (layers & ACCOUNTING_LAYER) { |
| 710 | buf += put_accounting(buf); |
| 711 | } |
| 712 | #endif |
Jim Bankoski | 21b68a0 | 2018-10-19 13:28:25 -0700 | [diff] [blame] | 713 | buf += |
| 714 | snprintf(buf, MAX_BUFFER, " \"frame\": %d,\n", frame_data.frame_number); |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 715 | buf += snprintf(buf, MAX_BUFFER, " \"showFrame\": %d,\n", |
| 716 | frame_data.show_frame); |
| 717 | buf += snprintf(buf, MAX_BUFFER, " \"frameType\": %d,\n", |
| 718 | frame_data.frame_type); |
| 719 | buf += snprintf(buf, MAX_BUFFER, " \"baseQIndex\": %d,\n", |
| 720 | frame_data.base_qindex); |
Michael Bebenita | 2c2e561 | 2017-04-06 22:19:04 -0400 | [diff] [blame] | 721 | buf += snprintf(buf, MAX_BUFFER, " \"tileCols\": %d,\n", |
| 722 | frame_data.tile_mi_cols); |
| 723 | buf += snprintf(buf, MAX_BUFFER, " \"tileRows\": %d,\n", |
| 724 | frame_data.tile_mi_rows); |
Yushin Cho | c24351c | 2017-10-24 14:59:08 -0700 | [diff] [blame] | 725 | buf += snprintf(buf, MAX_BUFFER, " \"deltaQPresentFlag\": %d,\n", |
| 726 | frame_data.delta_q_present_flag); |
| 727 | buf += snprintf(buf, MAX_BUFFER, " \"deltaQRes\": %d,\n", |
| 728 | frame_data.delta_q_res); |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 729 | buf += put_str(buf, " \"config\": {"); |
| 730 | buf += put_map(buf, config_map); |
| 731 | buf += put_str(buf, "},\n"); |
Michael Bebenita | 4aee17d | 2017-07-05 14:03:36 -0700 | [diff] [blame] | 732 | buf += put_str(buf, " \"configString\": \""); |
| 733 | buf += put_str_with_escape(buf, aom_codec_build_config()); |
| 734 | buf += put_str(buf, "\"\n"); |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 735 | decoded_frame_count++; |
| 736 | buf += put_str(buf, "},\n"); |
| 737 | *(buf++) = 0; |
| 738 | on_frame_decoded_dump(buffer); |
| 739 | aom_free(buffer); |
| 740 | } |
| 741 | |
| 742 | void ifd_init_cb() { |
| 743 | aom_inspect_init ii; |
| 744 | ii.inspect_cb = inspect; |
| 745 | ii.inspect_ctx = NULL; |
| 746 | aom_codec_control(&codec, AV1_SET_INSPECTION_CALLBACK, &ii); |
| 747 | } |
| 748 | |
| 749 | EMSCRIPTEN_KEEPALIVE |
| 750 | int open_file(char *file) { |
| 751 | if (file == NULL) { |
| 752 | // The JS analyzer puts the .ivf file at this location. |
| 753 | file = "/tmp/input.ivf"; |
| 754 | } |
| 755 | reader = aom_video_reader_open(file); |
| 756 | if (!reader) die("Failed to open %s for reading.", file); |
| 757 | info = aom_video_reader_get_info(reader); |
Elliott Karpilovsky | cbe219b | 2020-04-22 16:21:06 -0700 | [diff] [blame] | 758 | aom_codec_iface_t *decoder = get_aom_decoder_by_fourcc(info->codec_fourcc); |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 759 | if (!decoder) die("Unknown input codec."); |
Elliott Karpilovsky | cbe219b | 2020-04-22 16:21:06 -0700 | [diff] [blame] | 760 | fprintf(stderr, "Using %s\n", aom_codec_iface_name(decoder)); |
| 761 | if (aom_codec_dec_init(&codec, decoder, NULL, 0)) |
James Zern | dad374f | 2020-05-06 19:13:19 -0700 | [diff] [blame] | 762 | die("Failed to initialize decoder."); |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 763 | ifd_init(&frame_data, info->frame_width, info->frame_height); |
| 764 | ifd_init_cb(); |
| 765 | return EXIT_SUCCESS; |
| 766 | } |
| 767 | |
Jim Bankoski | 8aced4b | 2018-10-01 13:03:41 -0700 | [diff] [blame] | 768 | Av1DecodeReturn adr; |
| 769 | int have_frame = 0; |
| 770 | const unsigned char *frame; |
| 771 | const unsigned char *end_frame; |
| 772 | size_t frame_size = 0; |
| 773 | |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 774 | EMSCRIPTEN_KEEPALIVE |
| 775 | int read_frame() { |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 776 | img = NULL; |
Jim Bankoski | 8aced4b | 2018-10-01 13:03:41 -0700 | [diff] [blame] | 777 | |
Jim Bankoski | 3f73287 | 2018-10-29 06:54:18 -0700 | [diff] [blame] | 778 | // This loop skips over any frames that are show_existing_frames, as |
| 779 | // there is nothing to analyze. |
| 780 | do { |
| 781 | if (!have_frame) { |
| 782 | if (!aom_video_reader_read_frame(reader)) return EXIT_FAILURE; |
| 783 | frame = aom_video_reader_get_frame(reader, &frame_size); |
Jim Bankoski | 8aced4b | 2018-10-01 13:03:41 -0700 | [diff] [blame] | 784 | |
Jim Bankoski | 3f73287 | 2018-10-29 06:54:18 -0700 | [diff] [blame] | 785 | have_frame = 1; |
| 786 | end_frame = frame + frame_size; |
| 787 | } |
| 788 | |
| 789 | if (aom_codec_decode(&codec, frame, (unsigned int)frame_size, &adr) != |
| 790 | AOM_CODEC_OK) { |
| 791 | die_codec(&codec, "Failed to decode frame."); |
| 792 | } |
| 793 | |
| 794 | frame = adr.buf; |
| 795 | if (frame == end_frame) have_frame = 0; |
| 796 | } while (adr.show_existing); |
Jim Bankoski | 8aced4b | 2018-10-01 13:03:41 -0700 | [diff] [blame] | 797 | |
David Barker | 6d7210b | 2018-06-07 11:48:03 +0100 | [diff] [blame] | 798 | int got_any_frames = 0; |
David Michael Barr | 870358b | 2018-07-05 22:36:49 +0900 | [diff] [blame] | 799 | aom_image_t *frame_img; |
Jim Bankoski | 8aced4b | 2018-10-01 13:03:41 -0700 | [diff] [blame] | 800 | struct av1_ref_frame ref_dec; |
| 801 | ref_dec.idx = adr.idx; |
Jim Bankoski | 3f73287 | 2018-10-29 06:54:18 -0700 | [diff] [blame] | 802 | |
| 803 | // ref_dec.idx is the index to the reference buffer idx to AV1_GET_REFERENCE |
| 804 | // if its -1 the decoder didn't update any reference buffer and the only |
| 805 | // way to see the frame is aom_codec_get_frame. |
| 806 | if (ref_dec.idx == -1) { |
| 807 | aom_codec_iter_t iter = NULL; |
| 808 | img = frame_img = aom_codec_get_frame(&codec, &iter); |
| 809 | ++frame_count; |
| 810 | got_any_frames = 1; |
| 811 | } else if (!aom_codec_control(&codec, AV1_GET_REFERENCE, &ref_dec)) { |
Jim Bankoski | 8aced4b | 2018-10-01 13:03:41 -0700 | [diff] [blame] | 812 | img = frame_img = &ref_dec.img; |
David Barker | 6d7210b | 2018-06-07 11:48:03 +0100 | [diff] [blame] | 813 | ++frame_count; |
| 814 | got_any_frames = 1; |
| 815 | } |
| 816 | if (!got_any_frames) { |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 817 | return EXIT_FAILURE; |
| 818 | } |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 819 | return EXIT_SUCCESS; |
| 820 | } |
| 821 | |
| 822 | EMSCRIPTEN_KEEPALIVE |
| 823 | const char *get_aom_codec_build_config() { return aom_codec_build_config(); } |
| 824 | |
| 825 | EMSCRIPTEN_KEEPALIVE |
| 826 | int get_bit_depth() { return img->bit_depth; } |
| 827 | |
| 828 | EMSCRIPTEN_KEEPALIVE |
Michael Bebenita | bf1f9ee | 2017-06-16 15:54:08 -0700 | [diff] [blame] | 829 | int get_bits_per_sample() { return img->bps; } |
| 830 | |
| 831 | EMSCRIPTEN_KEEPALIVE |
| 832 | int get_image_format() { return img->fmt; } |
| 833 | |
| 834 | EMSCRIPTEN_KEEPALIVE |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 835 | unsigned char *get_plane(int plane) { return img->planes[plane]; } |
| 836 | |
| 837 | EMSCRIPTEN_KEEPALIVE |
| 838 | int get_plane_stride(int plane) { return img->stride[plane]; } |
| 839 | |
| 840 | EMSCRIPTEN_KEEPALIVE |
| 841 | int get_plane_width(int plane) { return aom_img_plane_width(img, plane); } |
| 842 | |
| 843 | EMSCRIPTEN_KEEPALIVE |
| 844 | int get_plane_height(int plane) { return aom_img_plane_height(img, plane); } |
| 845 | |
| 846 | EMSCRIPTEN_KEEPALIVE |
| 847 | int get_frame_width() { return info->frame_width; } |
| 848 | |
| 849 | EMSCRIPTEN_KEEPALIVE |
| 850 | int get_frame_height() { return info->frame_height; } |
| 851 | |
| 852 | static void parse_args(char **argv) { |
| 853 | char **argi, **argj; |
| 854 | struct arg arg; |
| 855 | (void)dump_accounting_arg; |
Alex Converse | 0ec34d2 | 2017-04-03 14:54:07 -0700 | [diff] [blame] | 856 | (void)dump_cdef_arg; |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 857 | for (argi = argj = argv; (*argj = *argi); argi += arg.argv_step) { |
| 858 | arg.argv_step = 1; |
| 859 | if (arg_match(&arg, &dump_block_size_arg, argi)) layers |= BLOCK_SIZE_LAYER; |
| 860 | #if CONFIG_ACCOUNTING |
| 861 | else if (arg_match(&arg, &dump_accounting_arg, argi)) |
| 862 | layers |= ACCOUNTING_LAYER; |
| 863 | #endif |
| 864 | else if (arg_match(&arg, &dump_transform_size_arg, argi)) |
| 865 | layers |= TRANSFORM_SIZE_LAYER; |
| 866 | else if (arg_match(&arg, &dump_transform_type_arg, argi)) |
| 867 | layers |= TRANSFORM_TYPE_LAYER; |
| 868 | else if (arg_match(&arg, &dump_mode_arg, argi)) |
| 869 | layers |= MODE_LAYER; |
Luc Trudeau | 0be435a | 2017-04-07 23:38:52 -0400 | [diff] [blame] | 870 | else if (arg_match(&arg, &dump_uv_mode_arg, argi)) |
| 871 | layers |= UV_MODE_LAYER; |
Jim Bankoski | 21b68a0 | 2018-10-19 13:28:25 -0700 | [diff] [blame] | 872 | else if (arg_match(&arg, &dump_motion_mode_arg, argi)) |
| 873 | layers |= MOTION_MODE_LAYER; |
| 874 | else if (arg_match(&arg, &dump_compound_type_arg, argi)) |
| 875 | layers |= COMPOUND_TYPE_LAYER; |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 876 | else if (arg_match(&arg, &dump_skip_arg, argi)) |
| 877 | layers |= SKIP_LAYER; |
| 878 | else if (arg_match(&arg, &dump_filter_arg, argi)) |
| 879 | layers |= FILTER_LAYER; |
| 880 | else if (arg_match(&arg, &dump_cdef_arg, argi)) |
| 881 | layers |= CDEF_LAYER; |
Luc Trudeau | f89056a | 2017-04-28 16:07:22 -0400 | [diff] [blame] | 882 | else if (arg_match(&arg, &dump_cfl_arg, argi)) |
| 883 | layers |= CFL_LAYER; |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 884 | else if (arg_match(&arg, &dump_reference_frame_arg, argi)) |
| 885 | layers |= REFERENCE_FRAME_LAYER; |
| 886 | else if (arg_match(&arg, &dump_motion_vectors_arg, argi)) |
| 887 | layers |= MOTION_VECTORS_LAYER; |
Ankur Saxena | 6e6b697 | 2017-10-20 22:10:10 -0700 | [diff] [blame] | 888 | else if (arg_match(&arg, &dump_dual_filter_type_arg, argi)) |
| 889 | layers |= DUAL_FILTER_LAYER; |
Yushin Cho | c24351c | 2017-10-24 14:59:08 -0700 | [diff] [blame] | 890 | else if (arg_match(&arg, &dump_delta_q_arg, argi)) |
| 891 | layers |= Q_INDEX_LAYER; |
Yushin Cho | 4be87e0 | 2017-10-25 16:27:04 -0700 | [diff] [blame] | 892 | else if (arg_match(&arg, &dump_seg_id_arg, argi)) |
| 893 | layers |= SEGMENT_ID_LAYER; |
Hui Su | 83684e1 | 2019-03-19 12:17:34 -0700 | [diff] [blame] | 894 | else if (arg_match(&arg, &dump_intrabc_arg, argi)) |
| 895 | layers |= INTRABC_LAYER; |
| 896 | else if (arg_match(&arg, &dump_palette_arg, argi)) |
| 897 | layers |= PALETTE_LAYER; |
| 898 | else if (arg_match(&arg, &dump_uv_palette_arg, argi)) |
| 899 | layers |= UV_PALETTE_LAYER; |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 900 | else if (arg_match(&arg, &dump_all_arg, argi)) |
| 901 | layers |= ALL_LAYERS; |
Michael Bebenita | f1207b6 | 2017-04-14 22:30:56 -0700 | [diff] [blame] | 902 | else if (arg_match(&arg, &compress_arg, argi)) |
| 903 | compress = 1; |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 904 | else if (arg_match(&arg, &usage_arg, argi)) |
| 905 | usage_exit(); |
| 906 | else if (arg_match(&arg, &limit_arg, argi)) |
| 907 | stop_after = arg_parse_uint(&arg); |
Jim Bankoski | c04ce61 | 2018-12-20 15:45:33 -0800 | [diff] [blame] | 908 | else if (arg_match(&arg, &skip_non_transform_arg, argi)) |
| 909 | skip_non_transform = arg_parse_uint(&arg); |
Jim Bankoski | 2b4176f | 2019-01-17 06:36:01 -0800 | [diff] [blame] | 910 | else if (arg_match(&arg, &combined_arg, argi)) |
| 911 | convert_to_indices( |
| 912 | (char *)arg.val, combined_parm_list, |
| 913 | sizeof(combined_parm_list) / sizeof(combined_parm_list[0]), |
| 914 | &combined_parm_count); |
Michael Bebenita | f4f27fe | 2017-03-02 17:40:44 -0800 | [diff] [blame] | 915 | else |
| 916 | argj++; |
| 917 | } |
| 918 | } |
| 919 | |
| 920 | static const char *exec_name; |
| 921 | |
| 922 | void usage_exit(void) { |
| 923 | fprintf(stderr, "Usage: %s src_filename <options>\n", exec_name); |
| 924 | fprintf(stderr, "\nOptions:\n"); |
| 925 | arg_show_usage(stderr, main_args); |
| 926 | exit(EXIT_FAILURE); |
| 927 | } |
| 928 | |
| 929 | EMSCRIPTEN_KEEPALIVE |
| 930 | int main(int argc, char **argv) { |
| 931 | exec_name = argv[0]; |
| 932 | parse_args(argv); |
| 933 | if (argc >= 2) { |
| 934 | open_file(argv[1]); |
| 935 | printf("[\n"); |
| 936 | while (1) { |
| 937 | if (stop_after && (decoded_frame_count >= stop_after)) break; |
| 938 | if (read_frame()) break; |
| 939 | } |
| 940 | printf("null\n"); |
| 941 | printf("]"); |
| 942 | } else { |
| 943 | usage_exit(); |
| 944 | } |
| 945 | } |
| 946 | |
| 947 | EMSCRIPTEN_KEEPALIVE |
| 948 | void quit() { |
| 949 | if (aom_codec_destroy(&codec)) die_codec(&codec, "Failed to destroy codec"); |
| 950 | aom_video_reader_close(reader); |
| 951 | } |
| 952 | |
| 953 | EMSCRIPTEN_KEEPALIVE |
| 954 | void set_layers(LayerType v) { layers = v; } |
Michael Bebenita | f1207b6 | 2017-04-14 22:30:56 -0700 | [diff] [blame] | 955 | |
| 956 | EMSCRIPTEN_KEEPALIVE |
| 957 | void set_compress(int v) { compress = v; } |