Commit 3607ec57 authored by Nathan E. Egge's avatar Nathan E. Egge Committed by Nathan Egge
Browse files

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
parent d8e7f2c9
......@@ -37,6 +37,8 @@ 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*/
typedef struct Accounting Accounting;
/*!\enum aom_dec_control_id
* \brief AOM decoder control functions
*
......@@ -103,6 +105,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
};
......@@ -154,6 +164,8 @@ 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
/*!\endcond */
/*! @} - end defgroup aom_decoder */
......
......@@ -1013,6 +1013,25 @@ 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_ctrl_fn_map_t decoder_ctrl_maps[] = {
{ AOM_COPY_REFERENCE, ctrl_copy_reference },
......@@ -1035,6 +1054,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 },
{ -1, NULL },
};
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment