diff options
author | trav90 <travawine@palemoon.org> | 2018-10-19 21:52:15 -0500 |
---|---|---|
committer | trav90 <travawine@palemoon.org> | 2018-10-19 21:52:20 -0500 |
commit | bbcc64772580c8a979288791afa02d30bc476d2e (patch) | |
tree | 437ce94c3fdd7497508e5b55de06c6d011678597 /third_party/aom/examples/inspect.c | |
parent | 14805f6ddbfb173c327768fff9f81f40ce5e81b0 (diff) | |
download | uxp-bbcc64772580c8a979288791afa02d30bc476d2e.tar.gz |
Update aom to v1.0.0
Update aom to commit id d14c5bb4f336ef1842046089849dee4a301fbbf0.
Diffstat (limited to 'third_party/aom/examples/inspect.c')
-rw-r--r-- | third_party/aom/examples/inspect.c | 260 |
1 files changed, 141 insertions, 119 deletions
diff --git a/third_party/aom/examples/inspect.c b/third_party/aom/examples/inspect.c index 74e770b841..4887fc4a3d 100644 --- a/third_party/aom/examples/inspect.c +++ b/third_party/aom/examples/inspect.c @@ -19,27 +19,27 @@ #include <stdlib.h> #include <string.h> -#include "./args.h" #ifdef __EMSCRIPTEN__ #include <emscripten.h> #else #define EMSCRIPTEN_KEEPALIVE #endif +#include "config/aom_config.h" + #include "aom/aom_decoder.h" -#include "./aom_config.h" -#if CONFIG_ACCOUNTING -#include "../av1/decoder/accounting.h" -#endif -#include "../av1/decoder/inspection.h" #include "aom/aomdx.h" +#include "av1/common/onyxc_int.h" -#include "../tools_common.h" -#include "../video_reader.h" -// #include "av1/av1_dx_iface.c" -#include "../av1/common/onyxc_int.h" +#if CONFIG_ACCOUNTING +#include "av1/decoder/accounting.h" +#endif -#include "../video_common.h" +#include "av1/decoder/inspection.h" +#include "common/args.h" +#include "common/tools_common.h" +#include "common/video_common.h" +#include "common/video_reader.h" // Max JSON buffer size. const int MAX_BUFFER = 1024 * 1024 * 32; @@ -57,7 +57,10 @@ typedef enum { MOTION_VECTORS_LAYER = 1 << 9, UV_MODE_LAYER = 1 << 10, CFL_LAYER = 1 << 11, - ALL_LAYERS = (1 << 12) - 1 + DUAL_FILTER_LAYER = 1 << 12, + Q_INDEX_LAYER = 1 << 13, + SEGMENT_ID_LAYER = 1 << 14, + ALL_LAYERS = (1 << 15) - 1 } LayerType; static LayerType layers = 0; @@ -87,12 +90,16 @@ static const arg_def_t dump_skip_arg = ARG_DEF("s", "skip", 0, "Dump Skip"); static const arg_def_t dump_filter_arg = ARG_DEF("f", "filter", 0, "Dump Filter"); static const arg_def_t dump_cdef_arg = ARG_DEF("c", "cdef", 0, "Dump CDEF"); -#if CONFIG_CFL static const arg_def_t dump_cfl_arg = ARG_DEF("cfl", "chroma_from_luma", 0, "Dump Chroma from Luma Alphas"); -#endif +static const arg_def_t dump_dual_filter_type_arg = + ARG_DEF("df", "dualFilterType", 0, "Dump Dual Filter Type"); static const arg_def_t dump_reference_frame_arg = ARG_DEF("r", "referenceFrame", 0, "Dump Reference Frame"); +static const arg_def_t dump_delta_q_arg = + ARG_DEF("dq", "delta_q", 0, "Dump QIndex"); +static const arg_def_t dump_seg_id_arg = + ARG_DEF("si", "seg_id", 0, "Dump Segment ID"); static const arg_def_t usage_arg = ARG_DEF("h", "help", 0, "Help"); static const arg_def_t *main_args[] = { &limit_arg, @@ -108,14 +115,13 @@ static const arg_def_t *main_args[] = { &limit_arg, &dump_uv_mode_arg, &dump_skip_arg, &dump_filter_arg, -#if CONFIG_CDEF &dump_cdef_arg, -#endif -#if CONFIG_CFL + &dump_dual_filter_type_arg, &dump_cfl_arg, -#endif &dump_reference_frame_arg, &dump_motion_vectors_arg, + &dump_delta_q_arg, + &dump_seg_id_arg, &usage_arg, NULL }; #define ENUM(name) \ @@ -127,58 +133,35 @@ typedef struct map_entry { int value; } map_entry; -const map_entry refs_map[] = { ENUM(INTRA_FRAME), ENUM(LAST_FRAME), -#if CONFIG_EXT_REFS - ENUM(LAST2_FRAME), ENUM(LAST3_FRAME), - ENUM(GOLDEN_FRAME), ENUM(BWDREF_FRAME), - ENUM(ALTREF_FRAME), -#else - ENUM(GOLDEN_FRAME), ENUM(ALTREF_FRAME), -#endif - LAST_ENUM }; +const map_entry refs_map[] = { + ENUM(INTRA_FRAME), ENUM(LAST_FRAME), ENUM(LAST2_FRAME), + ENUM(LAST3_FRAME), ENUM(GOLDEN_FRAME), ENUM(BWDREF_FRAME), + ENUM(ALTREF2_FRAME), ENUM(ALTREF_FRAME), LAST_ENUM +}; const map_entry block_size_map[] = { -#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8 - ENUM(BLOCK_2X2), ENUM(BLOCK_2X4), ENUM(BLOCK_4X2), -#endif - ENUM(BLOCK_4X4), ENUM(BLOCK_4X8), ENUM(BLOCK_8X4), - ENUM(BLOCK_8X8), ENUM(BLOCK_8X16), ENUM(BLOCK_16X8), - ENUM(BLOCK_16X16), ENUM(BLOCK_16X32), ENUM(BLOCK_32X16), - ENUM(BLOCK_32X32), ENUM(BLOCK_32X64), ENUM(BLOCK_64X32), - ENUM(BLOCK_64X64), -#if CONFIG_EXT_PARTITION - ENUM(BLOCK_64X128), ENUM(BLOCK_128X64), ENUM(BLOCK_128X128), -#endif - ENUM(BLOCK_4X16), ENUM(BLOCK_16X4), ENUM(BLOCK_8X32), - ENUM(BLOCK_32X8), ENUM(BLOCK_16X64), ENUM(BLOCK_64X16), -#if CONFIG_EXT_PARTITION - ENUM(BLOCK_32X128), ENUM(BLOCK_128X32), -#endif - LAST_ENUM + ENUM(BLOCK_4X4), ENUM(BLOCK_4X8), ENUM(BLOCK_8X4), + ENUM(BLOCK_8X8), ENUM(BLOCK_8X16), ENUM(BLOCK_16X8), + ENUM(BLOCK_16X16), ENUM(BLOCK_16X32), ENUM(BLOCK_32X16), + ENUM(BLOCK_32X32), ENUM(BLOCK_32X64), ENUM(BLOCK_64X32), + ENUM(BLOCK_64X64), ENUM(BLOCK_64X128), ENUM(BLOCK_128X64), + ENUM(BLOCK_128X128), ENUM(BLOCK_4X16), ENUM(BLOCK_16X4), + ENUM(BLOCK_8X32), ENUM(BLOCK_32X8), ENUM(BLOCK_16X64), + ENUM(BLOCK_64X16), LAST_ENUM }; const map_entry tx_size_map[] = { -#if CONFIG_CHROMA_2X2 - ENUM(TX_2X2), -#endif ENUM(TX_4X4), ENUM(TX_8X8), ENUM(TX_16X16), ENUM(TX_32X32), -#if CONFIG_TX64X64 - ENUM(TX_64X64), -#endif - ENUM(TX_4X8), ENUM(TX_8X4), ENUM(TX_8X16), ENUM(TX_16X8), - ENUM(TX_16X32), ENUM(TX_32X16), -#if CONFIG_TX64X64 - ENUM(TX_32X64), ENUM(TX_64X32), -#endif // CONFIG_TX64X64 - ENUM(TX_4X16), ENUM(TX_16X4), ENUM(TX_8X32), ENUM(TX_32X8), - LAST_ENUM + ENUM(TX_64X64), ENUM(TX_4X8), ENUM(TX_8X4), ENUM(TX_8X16), + ENUM(TX_16X8), ENUM(TX_16X32), ENUM(TX_32X16), ENUM(TX_32X64), + ENUM(TX_64X32), ENUM(TX_4X16), ENUM(TX_16X4), ENUM(TX_8X32), + ENUM(TX_32X8), LAST_ENUM }; const map_entry tx_type_map[] = { ENUM(DCT_DCT), ENUM(ADST_DCT), ENUM(DCT_ADST), ENUM(ADST_ADST), -#if CONFIG_EXT_TX ENUM(FLIPADST_DCT), ENUM(DCT_FLIPADST), ENUM(FLIPADST_FLIPADST), @@ -191,43 +174,35 @@ const map_entry tx_type_map[] = { ENUM(DCT_DCT), ENUM(H_ADST), ENUM(V_FLIPADST), ENUM(H_FLIPADST), -#endif LAST_ENUM }; +const map_entry dual_filter_map[] = { ENUM(REG_REG), ENUM(REG_SMOOTH), + ENUM(REG_SHARP), ENUM(SMOOTH_REG), + ENUM(SMOOTH_SMOOTH), ENUM(SMOOTH_SHARP), + ENUM(SHARP_REG), ENUM(SHARP_SMOOTH), + ENUM(SHARP_SHARP), LAST_ENUM }; const map_entry prediction_mode_map[] = { - ENUM(DC_PRED), ENUM(V_PRED), ENUM(H_PRED), - ENUM(D45_PRED), ENUM(D135_PRED), ENUM(D117_PRED), - ENUM(D153_PRED), ENUM(D207_PRED), ENUM(D63_PRED), - ENUM(SMOOTH_PRED), -#if CONFIG_SMOOTH_HV - ENUM(SMOOTH_V_PRED), ENUM(SMOOTH_H_PRED), -#endif // CONFIG_SMOOTH_HV - ENUM(TM_PRED), ENUM(NEARESTMV), ENUM(NEARMV), - ENUM(ZEROMV), ENUM(NEWMV), ENUM(NEAREST_NEARESTMV), - ENUM(NEAR_NEARMV), ENUM(NEAREST_NEWMV), ENUM(NEW_NEARESTMV), - ENUM(NEAR_NEWMV), ENUM(NEW_NEARMV), ENUM(ZERO_ZEROMV), - ENUM(NEW_NEWMV), ENUM(INTRA_INVALID), LAST_ENUM + ENUM(DC_PRED), ENUM(V_PRED), ENUM(H_PRED), + ENUM(D45_PRED), ENUM(D135_PRED), ENUM(D113_PRED), + ENUM(D157_PRED), ENUM(D203_PRED), ENUM(D67_PRED), + ENUM(SMOOTH_PRED), ENUM(SMOOTH_V_PRED), ENUM(SMOOTH_H_PRED), + ENUM(PAETH_PRED), ENUM(NEARESTMV), ENUM(NEARMV), + ENUM(GLOBALMV), ENUM(NEWMV), ENUM(NEAREST_NEARESTMV), + ENUM(NEAR_NEARMV), ENUM(NEAREST_NEWMV), ENUM(NEW_NEARESTMV), + ENUM(NEAR_NEWMV), ENUM(NEW_NEARMV), ENUM(GLOBAL_GLOBALMV), + ENUM(NEW_NEWMV), ENUM(INTRA_INVALID), LAST_ENUM }; -#if CONFIG_CFL const map_entry uv_prediction_mode_map[] = { ENUM(UV_DC_PRED), ENUM(UV_V_PRED), ENUM(UV_H_PRED), ENUM(UV_D45_PRED), - ENUM(UV_D135_PRED), ENUM(UV_D117_PRED), - ENUM(UV_D153_PRED), ENUM(UV_D207_PRED), - ENUM(UV_D63_PRED), ENUM(UV_SMOOTH_PRED), -#if CONFIG_SMOOTH_HV + ENUM(UV_D135_PRED), ENUM(UV_D113_PRED), + ENUM(UV_D157_PRED), ENUM(UV_D203_PRED), + ENUM(UV_D67_PRED), ENUM(UV_SMOOTH_PRED), ENUM(UV_SMOOTH_V_PRED), ENUM(UV_SMOOTH_H_PRED), -#endif // CONFIG_SMOOTH_HV - ENUM(UV_TM_PRED), -#if CONFIG_CFL - ENUM(UV_CFL_PRED), -#endif + ENUM(UV_PAETH_PRED), ENUM(UV_CFL_PRED), ENUM(UV_MODE_INVALID), LAST_ENUM }; -#else -#define uv_prediction_mode_map prediction_mode_map -#endif #define NO_SKIP 0 #define SKIP 1 @@ -327,7 +302,7 @@ int put_map(char *buffer, const map_entry *map) { *(buf++) = ','; } } - return buf - buffer; + return (int)(buf - buffer); } int put_reference_frame(char *buffer) { @@ -365,7 +340,7 @@ int put_reference_frame(char *buffer) { if (r < mi_rows - 1) *(buf++) = ','; } buf += put_str(buf, "],\n"); - return buf - buffer; + return (int)(buf - buffer); } int put_motion_vectors(char *buffer) { @@ -404,15 +379,19 @@ int put_motion_vectors(char *buffer) { if (r < mi_rows - 1) *(buf++) = ','; } buf += put_str(buf, "],\n"); - return buf - buffer; + return (int)(buf - buffer); } int put_block_info(char *buffer, const map_entry *map, const char *name, - size_t offset) { + size_t offset, int len) { const int mi_rows = frame_data.mi_rows; const int mi_cols = frame_data.mi_cols; char *buf = buffer; - int r, c, t, v; + int r, c, t, i; + if (compress && len == 1) { + die("Can't encode scalars as arrays when RLE compression is enabled."); + return -1; + } if (map) { buf += snprintf(buf, MAX_BUFFER, " \"%sMap\": {", name); buf += put_map(buf, map); @@ -422,13 +401,36 @@ int put_block_info(char *buffer, const map_entry *map, const char *name, for (r = 0; r < mi_rows; ++r) { *(buf++) = '['; for (c = 0; c < mi_cols; ++c) { - insp_mi_data *curr_mi = &frame_data.mi_grid[r * mi_cols + c]; - v = *(((int8_t *)curr_mi) + offset); - buf += put_num(buf, 0, v, 0); + insp_mi_data *mi = &frame_data.mi_grid[r * mi_cols + c]; + int16_t *v = (int16_t *)(((int8_t *)mi) + offset); + if (len == 0) { + buf += put_num(buf, 0, v[0], 0); + } else { + buf += put_str(buf, "["); + for (i = 0; i < len; i++) { + buf += put_num(buf, 0, v[i], 0); + if (i < len - 1) { + buf += put_str(buf, ","); + } + } + buf += put_str(buf, "]"); + } if (compress) { // RLE for (t = c + 1; t < mi_cols; ++t) { insp_mi_data *next_mi = &frame_data.mi_grid[r * mi_cols + t]; - if (v != *(((int8_t *)next_mi) + offset)) { + int16_t *nv = (int16_t *)(((int8_t *)next_mi) + offset); + int same = 0; + if (len == 0) { + same = v[0] == nv[0]; + } else { + for (i = 0; i < len; i++) { + same = v[i] == nv[i]; + if (!same) { + break; + } + } + } + if (!same) { break; } } @@ -444,7 +446,7 @@ int put_block_info(char *buffer, const map_entry *map, const char *name, if (r < mi_rows - 1) *(buf++) = ','; } buf += put_str(buf, "],\n"); - return buf - buffer; + return (int)(buf - buffer); } #if CONFIG_ACCOUNTING @@ -484,7 +486,7 @@ int put_accounting(char *buffer) { if (i < num_syms - 1) *(buf++) = ','; } buf += put_str(buf, "],\n"); - return buf - buffer; + return (int)(buf - buffer); } #endif @@ -499,51 +501,62 @@ void inspect(void *pbi, void *data) { buf += put_str(buf, "{\n"); if (layers & BLOCK_SIZE_LAYER) { buf += put_block_info(buf, block_size_map, "blockSize", - offsetof(insp_mi_data, sb_type)); + offsetof(insp_mi_data, sb_type), 0); } if (layers & TRANSFORM_SIZE_LAYER) { buf += put_block_info(buf, tx_size_map, "transformSize", - offsetof(insp_mi_data, tx_size)); + offsetof(insp_mi_data, tx_size), 0); } if (layers & TRANSFORM_TYPE_LAYER) { buf += put_block_info(buf, tx_type_map, "transformType", - offsetof(insp_mi_data, tx_type)); + offsetof(insp_mi_data, tx_type), 0); + } + if (layers & DUAL_FILTER_LAYER) { + buf += put_block_info(buf, dual_filter_map, "dualFilterType", + offsetof(insp_mi_data, dual_filter_type), 0); } if (layers & MODE_LAYER) { buf += put_block_info(buf, prediction_mode_map, "mode", - offsetof(insp_mi_data, mode)); + offsetof(insp_mi_data, mode), 0); } if (layers & UV_MODE_LAYER) { buf += put_block_info(buf, uv_prediction_mode_map, "uv_mode", - offsetof(insp_mi_data, uv_mode)); + offsetof(insp_mi_data, uv_mode), 0); } if (layers & SKIP_LAYER) { - buf += put_block_info(buf, skip_map, "skip", offsetof(insp_mi_data, skip)); + buf += + put_block_info(buf, skip_map, "skip", offsetof(insp_mi_data, skip), 0); } if (layers & FILTER_LAYER) { - buf += put_block_info(buf, NULL, "filter", offsetof(insp_mi_data, filter)); + buf += + put_block_info(buf, NULL, "filter", offsetof(insp_mi_data, filter), 2); } -#if CONFIG_CDEF if (layers & CDEF_LAYER) { buf += put_block_info(buf, NULL, "cdef_level", - offsetof(insp_mi_data, cdef_level)); + offsetof(insp_mi_data, cdef_level), 0); buf += put_block_info(buf, NULL, "cdef_strength", - offsetof(insp_mi_data, cdef_strength)); + offsetof(insp_mi_data, cdef_strength), 0); } -#endif -#if CONFIG_CFL if (layers & CFL_LAYER) { buf += put_block_info(buf, NULL, "cfl_alpha_idx", - offsetof(insp_mi_data, cfl_alpha_idx)); + offsetof(insp_mi_data, cfl_alpha_idx), 0); buf += put_block_info(buf, NULL, "cfl_alpha_sign", - offsetof(insp_mi_data, cfl_alpha_sign)); + offsetof(insp_mi_data, cfl_alpha_sign), 0); + } + if (layers & Q_INDEX_LAYER) { + buf += put_block_info(buf, NULL, "delta_q", + offsetof(insp_mi_data, current_qindex), 0); + } + if (layers & SEGMENT_ID_LAYER) { + buf += put_block_info(buf, NULL, "seg_id", + offsetof(insp_mi_data, segment_id), 0); } -#endif if (layers & MOTION_VECTORS_LAYER) { buf += put_motion_vectors(buf); } if (layers & REFERENCE_FRAME_LAYER) { - buf += put_reference_frame(buf); + buf += put_block_info(buf, refs_map, "referenceFrame", + offsetof(insp_mi_data, ref_frame), 2); } #if CONFIG_ACCOUNTING if (layers & ACCOUNTING_LAYER) { @@ -561,6 +574,10 @@ void inspect(void *pbi, void *data) { frame_data.tile_mi_cols); buf += snprintf(buf, MAX_BUFFER, " \"tileRows\": %d,\n", frame_data.tile_mi_rows); + buf += snprintf(buf, MAX_BUFFER, " \"deltaQPresentFlag\": %d,\n", + frame_data.delta_q_present_flag); + buf += snprintf(buf, MAX_BUFFER, " \"deltaQRes\": %d,\n", + frame_data.delta_q_res); buf += put_str(buf, " \"config\": {"); buf += put_map(buf, config_map); buf += put_str(buf, "},\n"); @@ -608,15 +625,18 @@ int read_frame() { aom_codec_iter_t iter = NULL; size_t frame_size = 0; const unsigned char *frame = aom_video_reader_get_frame(reader, &frame_size); - if (aom_codec_decode(&codec, frame, (unsigned int)frame_size, NULL, 0) != + if (aom_codec_decode(&codec, frame, (unsigned int)frame_size, NULL) != AOM_CODEC_OK) { die_codec(&codec, "Failed to decode frame."); } - img = aom_codec_get_frame(&codec, &iter); - if (img == NULL) { + int got_any_frames = 0; + while ((img = aom_codec_get_frame(&codec, &iter))) { + ++frame_count; + got_any_frames = 1; + } + if (!got_any_frames) { return EXIT_FAILURE; } - ++frame_count; return EXIT_SUCCESS; } @@ -674,18 +694,20 @@ static void parse_args(char **argv) { layers |= SKIP_LAYER; else if (arg_match(&arg, &dump_filter_arg, argi)) layers |= FILTER_LAYER; -#if CONFIG_CDEF else if (arg_match(&arg, &dump_cdef_arg, argi)) layers |= CDEF_LAYER; -#endif -#if CONFIG_CFL else if (arg_match(&arg, &dump_cfl_arg, argi)) layers |= CFL_LAYER; -#endif else if (arg_match(&arg, &dump_reference_frame_arg, argi)) layers |= REFERENCE_FRAME_LAYER; else if (arg_match(&arg, &dump_motion_vectors_arg, argi)) layers |= MOTION_VECTORS_LAYER; + else if (arg_match(&arg, &dump_dual_filter_type_arg, argi)) + layers |= DUAL_FILTER_LAYER; + else if (arg_match(&arg, &dump_delta_q_arg, argi)) + layers |= Q_INDEX_LAYER; + else if (arg_match(&arg, &dump_seg_id_arg, argi)) + layers |= SEGMENT_ID_LAYER; else if (arg_match(&arg, &dump_all_arg, argi)) layers |= ALL_LAYERS; else if (arg_match(&arg, &compress_arg, argi)) |