From c9862e05f5d1cab419b3b83bb585e2bb8fd5e377 Mon Sep 17 00:00:00 2001 From: "Nathan E. Egge" Date: Wed, 5 Oct 2016 21:28:36 -0400 Subject: [PATCH] Add a decoder control to retrieve accounting data. This decoder control requires AV1 to be compiled with --enable-accounting. Note that bit accounting data is only available after a frame has been decoded. Change-Id: I8a15213d9f2587638e0edb62932738e985160e03 --- aom/aomdx.h | 16 +++++++++++++++- av1/av1_dx_iface.c | 19 +++++++++++++++++++ av1/common/accounting.h | 6 ++++-- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/aom/aomdx.h b/aom/aomdx.h index f9d156675..19256fb8c 100644 --- a/aom/aomdx.h +++ b/aom/aomdx.h @@ -37,6 +37,10 @@ extern aom_codec_iface_t aom_codec_av1_dx_algo; extern aom_codec_iface_t *aom_codec_av1_dx(void); /*!@} - end algorithm interface member group*/ +/** Data structure that stores bit accounting for debug + */ +typedef struct Accounting Accounting; + /*!\enum aom_dec_control_id * \brief AOM decoder control functions * @@ -103,6 +107,14 @@ enum aom_dec_control_id { */ AV1_SET_SKIP_LOOP_FILTER, + /** control function to retrieve a pointer to the Accounting struct. When + * compiled without --enable-accounting, this returns AOM_CODEC_INCAPABLE. + * If called before a frame has been decoded, this returns AOM_CODEC_ERROR. + * The caller should ensure that AOM_CODEC_OK is returned before attempting + * to dereference the Accounting pointer. + */ + AV1_GET_ACCOUNTING, + AOM_DECODER_CTRL_ID_MAX, /** control function to set the range of tile decoding. A value that is @@ -163,12 +175,14 @@ AOM_CTRL_USE_TYPE(AV1D_GET_FRAME_SIZE, int *) #define AOM_CTRL_AV1D_GET_FRAME_SIZE AOM_CTRL_USE_TYPE(AV1_INVERT_TILE_DECODE_ORDER, int) #define AOM_CTRL_AV1_INVERT_TILE_DECODE_ORDER +AOM_CTRL_USE_TYPE(AV1_GET_ACCOUNTING, Accounting **) +#define AOM_CTRL_AV1_GET_ACCOUNTING AOM_CTRL_USE_TYPE(AV1_SET_DECODE_TILE_ROW, int) #define AOM_CTRL_AV1_SET_DECODE_TILE_ROW AOM_CTRL_USE_TYPE(AV1_SET_DECODE_TILE_COL, int) #define AOM_CTRL_AV1_SET_DECODE_TILE_COL /*!\endcond */ -/*! @} - end defgroup vp8_decoder */ +/*! @} - end defgroup aom_decoder */ #ifdef __cplusplus } // extern "C" diff --git a/av1/av1_dx_iface.c b/av1/av1_dx_iface.c index 43cc3a23f..2caed9002 100644 --- a/av1/av1_dx_iface.c +++ b/av1/av1_dx_iface.c @@ -1083,6 +1083,24 @@ static aom_codec_err_t ctrl_set_skip_loop_filter(aom_codec_alg_priv_t *ctx, return AOM_CODEC_OK; } +static aom_codec_err_t ctrl_get_accounting(aom_codec_alg_priv_t *ctx, + va_list args) { +#if !CONFIG_ACCOUNTING + (void)ctx; + (void)args; + return AOM_CODEC_INCAPABLE; +#else + if (ctx->frame_workers) { + AVxWorker *const worker = ctx->frame_workers; + FrameWorkerData *const frame_worker_data = (FrameWorkerData *)worker->data1; + AV1Decoder *pbi = frame_worker_data->pbi; + Accounting **acct = va_arg(args, Accounting **); + *acct = &pbi->accounting; + return AOM_CODEC_OK; + } + return AOM_CODEC_ERROR; +#endif +} static aom_codec_err_t ctrl_set_decode_tile_row(aom_codec_alg_priv_t *ctx, va_list args) { ctx->decode_tile_row = va_arg(args, int); @@ -1119,6 +1137,7 @@ static aom_codec_ctrl_fn_map_t decoder_ctrl_maps[] = { { AV1D_GET_DISPLAY_SIZE, ctrl_get_render_size }, { AV1D_GET_BIT_DEPTH, ctrl_get_bit_depth }, { AV1D_GET_FRAME_SIZE, ctrl_get_frame_size }, + { AV1_GET_ACCOUNTING, ctrl_get_accounting }, { AV1_GET_NEW_FRAME_IMAGE, ctrl_get_new_frame_image }, { -1, NULL }, diff --git a/av1/common/accounting.h b/av1/common/accounting.h index 04be32677..1fe1d9a8d 100644 --- a/av1/common/accounting.h +++ b/av1/common/accounting.h @@ -54,14 +54,16 @@ typedef struct { AccountingDictionary dictionary; } AccountingSymbols; -typedef struct { +typedef struct Accounting Accounting; + +struct Accounting { AccountingSymbols syms; /** Size allocated for symbols (not all may be used). */ int num_syms_allocated; int16_t hash_dictionary[AOM_ACCOUNTING_HASH_SIZE]; AccountingSymbolContext context; uint32_t last_tell_frac; -} Accounting; +}; void aom_accounting_init(Accounting *accounting); void aom_accounting_reset(Accounting *accounting);