blob: e5d56bd6d2c998c78d8a1ebe214e78c531745c72 [file] [log] [blame]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001/*
Yaowu Xu9c01aa12016-09-01 14:32:49 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Yaowu Xuc27fc142016-08-22 16:08:15 -07003 *
Yaowu Xu9c01aa12016-09-01 14:32:49 -07004 * 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.
Yaowu Xuc27fc142016-08-22 16:08:15 -070010 */
11
12#include <stdlib.h>
13#include <string.h>
14
Yaowu Xuf883b422016-08-30 14:01:10 -070015#include "./aom_config.h"
16#include "./aom_version.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070017
Yaowu Xuf883b422016-08-30 14:01:10 -070018#include "aom/internal/aom_codec_internal.h"
19#include "aom/aomdx.h"
20#include "aom/aom_decoder.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070021#include "aom_dsp/bitreader_buffer.h"
Yaowu Xuf883b422016-08-30 14:01:10 -070022#include "aom_dsp/aom_dsp_common.h"
Soo-Chul Hanf8589862018-01-24 03:13:14 +000023#include "aom_ports/mem_ops.h"
Yaowu Xuf883b422016-08-30 14:01:10 -070024#include "aom_util/aom_thread.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070025
26#include "av1/common/alloccommon.h"
27#include "av1/common/frame_buffers.h"
28#include "av1/common/enums.h"
29
30#include "av1/decoder/decoder.h"
31#include "av1/decoder/decodeframe.h"
Tom Finegan13ee28c2018-02-26 19:37:41 -080032#include "av1/decoder/obu.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070033
Yaowu Xuf883b422016-08-30 14:01:10 -070034#include "av1/av1_iface_common.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070035
Yaowu Xuc27fc142016-08-22 16:08:15 -070036// This limit is due to framebuffer numbers.
37// TODO(hkuang): Remove this limit after implementing ondemand framebuffers.
38#define FRAME_CACHE_SIZE 6 // Cache maximum 6 decoded frames.
39
40typedef struct cache_frame {
41 int fb_idx;
Yaowu Xuf883b422016-08-30 14:01:10 -070042 aom_image_t img;
Andrey Norkin6f1c2f72018-01-15 20:08:52 -080043#if CONFIG_FILM_GRAIN
44 aom_film_grain_t film_grain_params;
45#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -070046} cache_frame;
47
Yaowu Xuf883b422016-08-30 14:01:10 -070048struct aom_codec_alg_priv {
49 aom_codec_priv_t base;
50 aom_codec_dec_cfg_t cfg;
Ralph Gilesafe71d92017-05-03 13:18:57 -070051 aom_codec_stream_info_t si;
Yaowu Xuc27fc142016-08-22 16:08:15 -070052 int postproc_cfg_set;
Yaowu Xuf883b422016-08-30 14:01:10 -070053 aom_postproc_cfg_t postproc_cfg;
Yaowu Xuf883b422016-08-30 14:01:10 -070054 aom_image_t img;
Yaowu Xuc27fc142016-08-22 16:08:15 -070055 int img_avail;
56 int flushed;
57 int invert_tile_order;
58 int last_show_frame; // Index of last output frame.
59 int byte_alignment;
60 int skip_loop_filter;
61 int decode_tile_row;
62 int decode_tile_col;
Yunqing Wang8ae64a92018-01-12 12:26:44 -080063 unsigned int tile_mode;
Yaowu Xuc27fc142016-08-22 16:08:15 -070064
Yaowu Xuf883b422016-08-30 14:01:10 -070065 AVxWorker *frame_workers;
Yaowu Xuc27fc142016-08-22 16:08:15 -070066 int num_frame_workers;
67 int next_submit_worker_id;
68 int last_submit_worker_id;
69 int next_output_worker_id;
70 int available_threads;
71 cache_frame frame_cache[FRAME_CACHE_SIZE];
Andrey Norkin6f1c2f72018-01-15 20:08:52 -080072#if CONFIG_FILM_GRAIN
73 aom_image_t *image_with_grain;
74#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -070075 int frame_cache_write;
76 int frame_cache_read;
77 int num_cache_frames;
78 int need_resync; // wait for key/intra-only frame
79 // BufferPool that holds all reference frames. Shared by all the FrameWorkers.
80 BufferPool *buffer_pool;
81
Yaowu Xuf883b422016-08-30 14:01:10 -070082 // External frame buffer info to save for AV1 common.
Yaowu Xuc27fc142016-08-22 16:08:15 -070083 void *ext_priv; // Private data associated with the external frame buffers.
Yaowu Xuf883b422016-08-30 14:01:10 -070084 aom_get_frame_buffer_cb_fn_t get_ext_fb_cb;
85 aom_release_frame_buffer_cb_fn_t release_ext_fb_cb;
Nathan E. Egge2cf03b12017-02-22 16:19:59 -050086
87#if CONFIG_INSPECTION
88 aom_inspect_cb inspect_cb;
89 void *inspect_ctx;
90#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -070091};
92
Yaowu Xuf883b422016-08-30 14:01:10 -070093static aom_codec_err_t decoder_init(aom_codec_ctx_t *ctx,
94 aom_codec_priv_enc_mr_cfg_t *data) {
95 // This function only allocates space for the aom_codec_alg_priv_t
Yaowu Xuc27fc142016-08-22 16:08:15 -070096 // structure. More memory may be required at the time the stream
97 // information becomes known.
98 (void)data;
99
100 if (!ctx->priv) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700101 aom_codec_alg_priv_t *const priv =
102 (aom_codec_alg_priv_t *)aom_calloc(1, sizeof(*priv));
103 if (priv == NULL) return AOM_CODEC_MEM_ERROR;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700104
Yaowu Xuf883b422016-08-30 14:01:10 -0700105 ctx->priv = (aom_codec_priv_t *)priv;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700106 ctx->priv->init_flags = ctx->init_flags;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700107 priv->flushed = 0;
Debargha Mukherjee5521a182018-03-06 12:29:01 -0800108
Thomas Daede85b49002017-07-10 17:43:06 -0700109 // TODO(tdaede): this should not be exposed to the API
110 priv->cfg.allow_lowbitdepth = CONFIG_LOWBITDEPTH;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700111 if (ctx->config.dec) {
112 priv->cfg = *ctx->config.dec;
113 ctx->config.dec = &priv->cfg;
Maxym Dmytrychenkocc6e0e12018-02-05 16:35:37 +0100114 // default values
Debargha Mukherjee2ccf4b92018-02-27 17:30:46 -0800115 priv->cfg.cfg.ext_partition = 1;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700116 }
Andrey Norkin6f1c2f72018-01-15 20:08:52 -0800117#if CONFIG_FILM_GRAIN
118 priv->image_with_grain = NULL;
119#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -0700120 }
121
Yaowu Xuf883b422016-08-30 14:01:10 -0700122 return AOM_CODEC_OK;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700123}
124
Yaowu Xuf883b422016-08-30 14:01:10 -0700125static aom_codec_err_t decoder_destroy(aom_codec_alg_priv_t *ctx) {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700126 if (ctx->frame_workers != NULL) {
127 int i;
128 for (i = 0; i < ctx->num_frame_workers; ++i) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700129 AVxWorker *const worker = &ctx->frame_workers[i];
Yaowu Xuc27fc142016-08-22 16:08:15 -0700130 FrameWorkerData *const frame_worker_data =
131 (FrameWorkerData *)worker->data1;
Yaowu Xuf883b422016-08-30 14:01:10 -0700132 aom_get_worker_interface()->end(worker);
Yaowu Xu568bf102017-10-17 12:43:27 -0700133 aom_free(frame_worker_data->pbi->common.tpl_mvs);
134 frame_worker_data->pbi->common.tpl_mvs = NULL;
Yaowu Xuf883b422016-08-30 14:01:10 -0700135 av1_remove_common(&frame_worker_data->pbi->common);
Yaowu Xuf883b422016-08-30 14:01:10 -0700136 av1_free_restoration_buffers(&frame_worker_data->pbi->common);
Yaowu Xuf883b422016-08-30 14:01:10 -0700137 av1_decoder_remove(frame_worker_data->pbi);
138 aom_free(frame_worker_data->scratch_buffer);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700139#if CONFIG_MULTITHREAD
140 pthread_mutex_destroy(&frame_worker_data->stats_mutex);
141 pthread_cond_destroy(&frame_worker_data->stats_cond);
142#endif
Yaowu Xuf883b422016-08-30 14:01:10 -0700143 aom_free(frame_worker_data);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700144 }
145#if CONFIG_MULTITHREAD
146 pthread_mutex_destroy(&ctx->buffer_pool->pool_mutex);
147#endif
148 }
149
150 if (ctx->buffer_pool) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700151 av1_free_ref_frame_buffers(ctx->buffer_pool);
152 av1_free_internal_frame_buffers(&ctx->buffer_pool->int_frame_buffers);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700153 }
154
Yaowu Xuf883b422016-08-30 14:01:10 -0700155 aom_free(ctx->frame_workers);
156 aom_free(ctx->buffer_pool);
Andrey Norkin6f1c2f72018-01-15 20:08:52 -0800157#if CONFIG_FILM_GRAIN
158 if (ctx->image_with_grain) aom_img_free(ctx->image_with_grain);
159#endif
Yaowu Xuf883b422016-08-30 14:01:10 -0700160 aom_free(ctx);
161 return AOM_CODEC_OK;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700162}
163
Hui Sudf5b2912018-03-16 15:34:01 -0700164static size_t get_obu_length_field_size(const uint8_t *data, size_t data_sz) {
165 const size_t max_bytes = AOMMIN(sizeof(uint64_t), data_sz);
Vignesh Venkatasubramanian03391a22018-03-09 12:25:55 -0800166 size_t length_field_size = 1;
Hui Sudf5b2912018-03-16 15:34:01 -0700167 for (size_t i = 0; i < max_bytes && (data[i] & 0x80); ++i) {
Vignesh Venkatasubramanian03391a22018-03-09 12:25:55 -0800168 ++length_field_size;
169 }
170 return length_field_size;
171}
172
Sebastien Alaiwan2b1ec182017-12-21 09:38:27 +0100173static aom_codec_err_t decoder_peek_si_internal(const uint8_t *data,
174 unsigned int data_sz,
175 aom_codec_stream_info_t *si,
176 int *is_intra_only) {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700177 int intra_only_flag = 0;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700178
Hui Sudf5b2912018-03-16 15:34:01 -0700179 if (data + data_sz <= data || data_sz < 1) return AOM_CODEC_INVALID_PARAM;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700180
Tom Fineganf277ca32018-02-26 12:09:52 -0800181 si->w = 0;
Tom Finegan13ee28c2018-02-26 19:37:41 -0800182 si->h = 0;
183 si->is_kf = 0;
184
185 // TODO(tomfinegan): This function needs Sequence and Frame Header OBUs to
186 // operate properly. At present it hard codes the values to 1 for the keyframe
187 // and intra only flags, and assumes the data being parsed is a Sequence
188 // Header OBU.
Tom Fineganf277ca32018-02-26 12:09:52 -0800189 intra_only_flag = 1;
Tom Finegan13ee28c2018-02-26 19:37:41 -0800190 si->is_kf = 1;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700191
Vignesh Venkatasubramanian03391a22018-03-09 12:25:55 -0800192 struct aom_read_bit_buffer rb = { data, data + data_sz, 0, NULL, NULL };
Tom Finegan13ee28c2018-02-26 19:37:41 -0800193 const uint8_t obu_header = (uint8_t)aom_rb_read_literal(&rb, 8);
194 OBU_TYPE obu_type;
195
196 if (get_obu_type(obu_header, &obu_type) != 0)
197 return AOM_CODEC_UNSUP_BITSTREAM;
198
Vignesh Venkatasubramanian03391a22018-03-09 12:25:55 -0800199 // One byte has been consumed by the OBU header.
Tom Finegan5427be12018-03-14 18:45:39 -0700200 rb.bit_buffer += get_obu_length_field_size(data + 1, data_sz - 1) * 8;
Vignesh Venkatasubramanian03391a22018-03-09 12:25:55 -0800201
Tom Finegan13ee28c2018-02-26 19:37:41 -0800202 // This check is disabled because existing behavior is depended upon by
203 // decoder tests (see decode_test_driver.cc), scalability_decoder (see
204 // scalable_decoder.c), and decode_once() in this file.
205 // if (obu_type != OBU_SEQUENCE_HEADER)
206 // return AOM_CODEC_INVALID_PARAM;
207
Yaowu Xu811a5fc2018-03-18 15:09:20 -0700208 av1_read_profile(&rb); // profile
209#if !CONFIG_SCALABILITY
Tom Fineganf277ca32018-02-26 12:09:52 -0800210 aom_rb_read_literal(&rb, 4); // level
Yaowu Xu811a5fc2018-03-18 15:09:20 -0700211#else
Tom Fineganf277ca32018-02-26 12:09:52 -0800212 int i;
213 si->enhancement_layers_cnt = aom_rb_read_literal(&rb, 2);
Yaowu Xu811a5fc2018-03-18 15:09:20 -0700214 for (i = 0; i <= (int)si->enhancement_layers_cnt; i++) {
Tom Fineganf277ca32018-02-26 12:09:52 -0800215 aom_rb_read_literal(&rb, 4); // level for each enhancement layer
216 }
Soo-Chul Hanf8589862018-01-24 03:13:14 +0000217#endif // CONFIG_SCALABILITY
218
Tom Fineganf277ca32018-02-26 12:09:52 -0800219 int num_bits_width = aom_rb_read_literal(&rb, 4) + 1;
220 int num_bits_height = aom_rb_read_literal(&rb, 4) + 1;
221 int max_frame_width = aom_rb_read_literal(&rb, num_bits_width) + 1;
222 int max_frame_height = aom_rb_read_literal(&rb, num_bits_height) + 1;
223 si->w = max_frame_width;
224 si->h = max_frame_height;
Tom Fineganf277ca32018-02-26 12:09:52 -0800225
Yaowu Xuc27fc142016-08-22 16:08:15 -0700226 if (is_intra_only != NULL) *is_intra_only = intra_only_flag;
Yaowu Xuf883b422016-08-30 14:01:10 -0700227 return AOM_CODEC_OK;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700228}
229
Yaowu Xuf883b422016-08-30 14:01:10 -0700230static aom_codec_err_t decoder_peek_si(const uint8_t *data,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700231 unsigned int data_sz,
Yaowu Xuf883b422016-08-30 14:01:10 -0700232 aom_codec_stream_info_t *si) {
Sebastien Alaiwan2b1ec182017-12-21 09:38:27 +0100233 return decoder_peek_si_internal(data, data_sz, si, NULL);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700234}
235
Yaowu Xuf883b422016-08-30 14:01:10 -0700236static aom_codec_err_t decoder_get_si(aom_codec_alg_priv_t *ctx,
237 aom_codec_stream_info_t *si) {
Ralph Gilesafe71d92017-05-03 13:18:57 -0700238 memcpy(si, &ctx->si, sizeof(*si));
Yaowu Xuc27fc142016-08-22 16:08:15 -0700239
Yaowu Xuf883b422016-08-30 14:01:10 -0700240 return AOM_CODEC_OK;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700241}
242
Yaowu Xuf883b422016-08-30 14:01:10 -0700243static void set_error_detail(aom_codec_alg_priv_t *ctx,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700244 const char *const error) {
245 ctx->base.err_detail = error;
246}
247
Yaowu Xuf883b422016-08-30 14:01:10 -0700248static aom_codec_err_t update_error_state(
249 aom_codec_alg_priv_t *ctx, const struct aom_internal_error_info *error) {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700250 if (error->error_code)
251 set_error_detail(ctx, error->has_detail ? error->detail : NULL);
252
253 return error->error_code;
254}
255
Yaowu Xuf883b422016-08-30 14:01:10 -0700256static void init_buffer_callbacks(aom_codec_alg_priv_t *ctx) {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700257 int i;
258
259 for (i = 0; i < ctx->num_frame_workers; ++i) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700260 AVxWorker *const worker = &ctx->frame_workers[i];
Yaowu Xuc27fc142016-08-22 16:08:15 -0700261 FrameWorkerData *const frame_worker_data = (FrameWorkerData *)worker->data1;
Yaowu Xuf883b422016-08-30 14:01:10 -0700262 AV1_COMMON *const cm = &frame_worker_data->pbi->common;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700263 BufferPool *const pool = cm->buffer_pool;
264
265 cm->new_fb_idx = INVALID_IDX;
266 cm->byte_alignment = ctx->byte_alignment;
267 cm->skip_loop_filter = ctx->skip_loop_filter;
268
269 if (ctx->get_ext_fb_cb != NULL && ctx->release_ext_fb_cb != NULL) {
270 pool->get_fb_cb = ctx->get_ext_fb_cb;
271 pool->release_fb_cb = ctx->release_ext_fb_cb;
272 pool->cb_priv = ctx->ext_priv;
273 } else {
Yaowu Xuf883b422016-08-30 14:01:10 -0700274 pool->get_fb_cb = av1_get_frame_buffer;
275 pool->release_fb_cb = av1_release_frame_buffer;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700276
Yaowu Xuf883b422016-08-30 14:01:10 -0700277 if (av1_alloc_internal_frame_buffers(&pool->int_frame_buffers))
278 aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700279 "Failed to initialize internal frame buffers");
280
281 pool->cb_priv = &pool->int_frame_buffers;
282 }
283 }
284}
285
Yaowu Xuf883b422016-08-30 14:01:10 -0700286static void set_default_ppflags(aom_postproc_cfg_t *cfg) {
287 cfg->post_proc_flag = AOM_DEBLOCK | AOM_DEMACROBLOCK;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700288 cfg->deblocking_level = 4;
289 cfg->noise_level = 0;
290}
291
292static int frame_worker_hook(void *arg1, void *arg2) {
293 FrameWorkerData *const frame_worker_data = (FrameWorkerData *)arg1;
294 const uint8_t *data = frame_worker_data->data;
295 (void)arg2;
296
Yaowu Xuf883b422016-08-30 14:01:10 -0700297 frame_worker_data->result = av1_receive_compressed_data(
Yaowu Xuc27fc142016-08-22 16:08:15 -0700298 frame_worker_data->pbi, frame_worker_data->data_size, &data);
299 frame_worker_data->data_end = data;
300
Debargha Mukherjee5521a182018-03-06 12:29:01 -0800301 if (frame_worker_data->result != 0) {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700302 // Check decode result in serial decode.
303 frame_worker_data->pbi->cur_buf->buf.corrupted = 1;
304 frame_worker_data->pbi->need_resync = 1;
305 }
306 return !frame_worker_data->result;
307}
308
Yaowu Xuf883b422016-08-30 14:01:10 -0700309static aom_codec_err_t init_decoder(aom_codec_alg_priv_t *ctx) {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700310 int i;
Yaowu Xuf883b422016-08-30 14:01:10 -0700311 const AVxWorkerInterface *const winterface = aom_get_worker_interface();
Yaowu Xuc27fc142016-08-22 16:08:15 -0700312
313 ctx->last_show_frame = -1;
314 ctx->next_submit_worker_id = 0;
315 ctx->last_submit_worker_id = 0;
316 ctx->next_output_worker_id = 0;
317 ctx->frame_cache_read = 0;
318 ctx->frame_cache_write = 0;
319 ctx->num_cache_frames = 0;
320 ctx->need_resync = 1;
Debargha Mukherjee5521a182018-03-06 12:29:01 -0800321 ctx->num_frame_workers = 1;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700322 if (ctx->num_frame_workers > MAX_DECODE_THREADS)
323 ctx->num_frame_workers = MAX_DECODE_THREADS;
324 ctx->available_threads = ctx->num_frame_workers;
325 ctx->flushed = 0;
326
Yaowu Xuf883b422016-08-30 14:01:10 -0700327 ctx->buffer_pool = (BufferPool *)aom_calloc(1, sizeof(BufferPool));
328 if (ctx->buffer_pool == NULL) return AOM_CODEC_MEM_ERROR;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700329
330#if CONFIG_MULTITHREAD
331 if (pthread_mutex_init(&ctx->buffer_pool->pool_mutex, NULL)) {
332 set_error_detail(ctx, "Failed to allocate buffer pool mutex");
Yaowu Xuf883b422016-08-30 14:01:10 -0700333 return AOM_CODEC_MEM_ERROR;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700334 }
335#endif
336
Yaowu Xuf883b422016-08-30 14:01:10 -0700337 ctx->frame_workers = (AVxWorker *)aom_malloc(ctx->num_frame_workers *
Yaowu Xuc27fc142016-08-22 16:08:15 -0700338 sizeof(*ctx->frame_workers));
339 if (ctx->frame_workers == NULL) {
340 set_error_detail(ctx, "Failed to allocate frame_workers");
Yaowu Xuf883b422016-08-30 14:01:10 -0700341 return AOM_CODEC_MEM_ERROR;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700342 }
343
344 for (i = 0; i < ctx->num_frame_workers; ++i) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700345 AVxWorker *const worker = &ctx->frame_workers[i];
Yaowu Xuc27fc142016-08-22 16:08:15 -0700346 FrameWorkerData *frame_worker_data = NULL;
347 winterface->init(worker);
Yaowu Xuf883b422016-08-30 14:01:10 -0700348 worker->data1 = aom_memalign(32, sizeof(FrameWorkerData));
Yaowu Xuc27fc142016-08-22 16:08:15 -0700349 if (worker->data1 == NULL) {
350 set_error_detail(ctx, "Failed to allocate frame_worker_data");
Yaowu Xuf883b422016-08-30 14:01:10 -0700351 return AOM_CODEC_MEM_ERROR;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700352 }
353 frame_worker_data = (FrameWorkerData *)worker->data1;
Yaowu Xuf883b422016-08-30 14:01:10 -0700354 frame_worker_data->pbi = av1_decoder_create(ctx->buffer_pool);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700355 if (frame_worker_data->pbi == NULL) {
356 set_error_detail(ctx, "Failed to allocate frame_worker_data");
Yaowu Xuf883b422016-08-30 14:01:10 -0700357 return AOM_CODEC_MEM_ERROR;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700358 }
Maxym Dmytrychenkocc6e0e12018-02-05 16:35:37 +0100359 frame_worker_data->pbi->common.options = &ctx->cfg.cfg;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700360 frame_worker_data->pbi->frame_worker_owner = worker;
361 frame_worker_data->worker_id = i;
362 frame_worker_data->scratch_buffer = NULL;
363 frame_worker_data->scratch_buffer_size = 0;
364 frame_worker_data->frame_context_ready = 0;
365 frame_worker_data->received_frame = 0;
366#if CONFIG_MULTITHREAD
367 if (pthread_mutex_init(&frame_worker_data->stats_mutex, NULL)) {
368 set_error_detail(ctx, "Failed to allocate frame_worker_data mutex");
Yaowu Xuf883b422016-08-30 14:01:10 -0700369 return AOM_CODEC_MEM_ERROR;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700370 }
371
372 if (pthread_cond_init(&frame_worker_data->stats_cond, NULL)) {
373 set_error_detail(ctx, "Failed to allocate frame_worker_data cond");
Yaowu Xuf883b422016-08-30 14:01:10 -0700374 return AOM_CODEC_MEM_ERROR;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700375 }
376#endif
Sebastien Alaiwan8b7a4e12017-06-13 11:25:57 +0200377 frame_worker_data->pbi->allow_lowbitdepth = ctx->cfg.allow_lowbitdepth;
378
Yaowu Xuc27fc142016-08-22 16:08:15 -0700379 // If decoding in serial mode, FrameWorker thread could create tile worker
380 // thread or loopfilter thread.
Debargha Mukherjee5521a182018-03-06 12:29:01 -0800381 frame_worker_data->pbi->max_threads = ctx->cfg.threads;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700382 frame_worker_data->pbi->inv_tile_order = ctx->invert_tile_order;
Yunqing Wang8ae64a92018-01-12 12:26:44 -0800383 frame_worker_data->pbi->common.large_scale_tile = ctx->tile_mode;
384 frame_worker_data->pbi->dec_tile_row = ctx->decode_tile_row;
385 frame_worker_data->pbi->dec_tile_col = ctx->decode_tile_col;
Yaowu Xuf883b422016-08-30 14:01:10 -0700386 worker->hook = (AVxWorkerHook)frame_worker_hook;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700387 if (!winterface->reset(worker)) {
388 set_error_detail(ctx, "Frame Worker thread creation failed");
Yaowu Xuf883b422016-08-30 14:01:10 -0700389 return AOM_CODEC_MEM_ERROR;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700390 }
391 }
392
393 // If postprocessing was enabled by the application and a
394 // configuration has not been provided, default it.
Yaowu Xuf883b422016-08-30 14:01:10 -0700395 if (!ctx->postproc_cfg_set && (ctx->base.init_flags & AOM_CODEC_USE_POSTPROC))
Yaowu Xuc27fc142016-08-22 16:08:15 -0700396 set_default_ppflags(&ctx->postproc_cfg);
397
398 init_buffer_callbacks(ctx);
399
Yaowu Xuf883b422016-08-30 14:01:10 -0700400 return AOM_CODEC_OK;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700401}
402
Yaowu Xuf883b422016-08-30 14:01:10 -0700403static INLINE void check_resync(aom_codec_alg_priv_t *const ctx,
404 const AV1Decoder *const pbi) {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700405 // Clear resync flag if worker got a key frame or intra only frame.
406 if (ctx->need_resync == 1 && pbi->need_resync == 0 &&
407 (pbi->common.intra_only || pbi->common.frame_type == KEY_FRAME))
408 ctx->need_resync = 0;
409}
410
Yaowu Xuf883b422016-08-30 14:01:10 -0700411static aom_codec_err_t decode_one(aom_codec_alg_priv_t *ctx,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700412 const uint8_t **data, unsigned int data_sz,
Sean DuBois47cc2552018-01-23 07:44:16 +0000413 void *user_priv) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700414 const AVxWorkerInterface *const winterface = aom_get_worker_interface();
Yaowu Xuc27fc142016-08-22 16:08:15 -0700415
416 // Determine the stream parameters. Note that we rely on peek_si to
417 // validate that we have a buffer that does not wrap around the top
418 // of the heap.
419 if (!ctx->si.h) {
420 int is_intra_only = 0;
Yaowu Xuf883b422016-08-30 14:01:10 -0700421 const aom_codec_err_t res =
Sebastien Alaiwan2b1ec182017-12-21 09:38:27 +0100422 decoder_peek_si_internal(*data, data_sz, &ctx->si, &is_intra_only);
Yaowu Xuf883b422016-08-30 14:01:10 -0700423 if (res != AOM_CODEC_OK) return res;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700424
Yaowu Xuf883b422016-08-30 14:01:10 -0700425 if (!ctx->si.is_kf && !is_intra_only) return AOM_CODEC_ERROR;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700426 }
427
Debargha Mukherjee5521a182018-03-06 12:29:01 -0800428 AVxWorker *const worker = ctx->frame_workers;
429 FrameWorkerData *const frame_worker_data = (FrameWorkerData *)worker->data1;
430 frame_worker_data->data = *data;
431 frame_worker_data->data_size = data_sz;
432 frame_worker_data->user_priv = user_priv;
433 frame_worker_data->received_frame = 1;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700434
Nathan E. Egge2cf03b12017-02-22 16:19:59 -0500435#if CONFIG_INSPECTION
Debargha Mukherjee5521a182018-03-06 12:29:01 -0800436 frame_worker_data->pbi->inspect_cb = ctx->inspect_cb;
437 frame_worker_data->pbi->inspect_ctx = ctx->inspect_ctx;
Nathan E. Egge2cf03b12017-02-22 16:19:59 -0500438#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -0700439
Debargha Mukherjee5521a182018-03-06 12:29:01 -0800440 frame_worker_data->pbi->common.large_scale_tile = ctx->tile_mode;
441 frame_worker_data->pbi->dec_tile_row = ctx->decode_tile_row;
442 frame_worker_data->pbi->dec_tile_col = ctx->decode_tile_col;
Yunqing Wang2a5575e2018-02-23 16:02:18 -0800443
Debargha Mukherjee5521a182018-03-06 12:29:01 -0800444 worker->had_error = 0;
445 winterface->execute(worker);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700446
Debargha Mukherjee5521a182018-03-06 12:29:01 -0800447 // Update data pointer after decode.
448 *data = frame_worker_data->data_end;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700449
Debargha Mukherjee5521a182018-03-06 12:29:01 -0800450 if (worker->had_error)
451 return update_error_state(ctx, &frame_worker_data->pbi->common.error);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700452
Debargha Mukherjee5521a182018-03-06 12:29:01 -0800453 check_resync(ctx, frame_worker_data->pbi);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700454
Yaowu Xuf883b422016-08-30 14:01:10 -0700455 return AOM_CODEC_OK;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700456}
457
Yaowu Xuf883b422016-08-30 14:01:10 -0700458static aom_codec_err_t decoder_decode(aom_codec_alg_priv_t *ctx,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700459 const uint8_t *data, unsigned int data_sz,
Sean DuBois47cc2552018-01-23 07:44:16 +0000460 void *user_priv) {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700461 const uint8_t *data_start = data;
462 const uint8_t *const data_end = data + data_sz;
Yaowu Xub02d0b12017-12-15 01:32:34 +0000463 aom_codec_err_t res = AOM_CODEC_OK;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700464 uint32_t frame_sizes[8];
Soo-Chul Han38427e82017-09-27 15:06:13 -0400465 int frame_count = 0;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700466
467 if (data == NULL && data_sz == 0) {
468 ctx->flushed = 1;
Yaowu Xuf883b422016-08-30 14:01:10 -0700469 return AOM_CODEC_OK;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700470 }
471
472 // Reset flushed when receiving a valid frame.
473 ctx->flushed = 0;
474
475 // Initialize the decoder workers on the first frame.
476 if (ctx->frame_workers == NULL) {
Urvang Joshi454280d2016-10-14 16:51:44 -0700477 res = init_decoder(ctx);
Yaowu Xuf883b422016-08-30 14:01:10 -0700478 if (res != AOM_CODEC_OK) return res;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700479 }
Debargha Mukherjee5521a182018-03-06 12:29:01 -0800480 // Decode in serial mode.
481 if (frame_count > 0) {
482 int i;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700483
Debargha Mukherjee5521a182018-03-06 12:29:01 -0800484 for (i = 0; i < frame_count; ++i) {
485 const uint8_t *data_start_copy = data_start;
486 const uint32_t frame_size = frame_sizes[i];
487 if (data_start < data || frame_size > (uint32_t)(data_end - data_start)) {
488 set_error_detail(ctx, "Invalid frame size in index");
489 return AOM_CODEC_CORRUPT_FRAME;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700490 }
491
Debargha Mukherjee5521a182018-03-06 12:29:01 -0800492 res = decode_one(ctx, &data_start_copy, frame_size, user_priv);
Yaowu Xuf883b422016-08-30 14:01:10 -0700493 if (res != AOM_CODEC_OK) return res;
Debargha Mukherjee5521a182018-03-06 12:29:01 -0800494
495 data_start += frame_size;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700496 }
497 } else {
Debargha Mukherjee5521a182018-03-06 12:29:01 -0800498 while (data_start < data_end) {
499 const uint32_t frame_size = (uint32_t)(data_end - data_start);
500 res = decode_one(ctx, &data_start, frame_size, user_priv);
501 if (res != AOM_CODEC_OK) return res;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700502
Debargha Mukherjee5521a182018-03-06 12:29:01 -0800503 // Account for suboptimal termination by the encoder.
Yaowu Xuc27fc142016-08-22 16:08:15 -0700504 while (data_start < data_end) {
Debargha Mukherjee5521a182018-03-06 12:29:01 -0800505 const uint8_t marker = data_start[0];
506 if (marker) break;
507 ++data_start;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700508 }
509 }
510 }
511
512 return res;
513}
514
Andrey Norkin6f1c2f72018-01-15 20:08:52 -0800515#if CONFIG_FILM_GRAIN
516aom_image_t *add_grain_if_needed(aom_image_t *img, aom_image_t *grain_img_buf,
517 aom_film_grain_t *grain_params) {
518 if (!grain_params->apply_grain) return img;
519
520 if (grain_img_buf &&
521 (img->d_w != grain_img_buf->d_w || img->d_h != grain_img_buf->d_h ||
Andrey Norkin4352fed2018-03-01 17:01:49 -0800522 img->fmt != grain_img_buf->fmt || !(img->d_h % 2) || !(img->d_w % 2))) {
Andrey Norkin6f1c2f72018-01-15 20:08:52 -0800523 aom_img_free(grain_img_buf);
524 grain_img_buf = NULL;
525 }
526 if (!grain_img_buf) {
Andrey Norkin4352fed2018-03-01 17:01:49 -0800527 int w_even = img->d_w % 2 ? img->d_w + 1 : img->d_w;
528 int h_even = img->d_h % 2 ? img->d_h + 1 : img->d_h;
529 grain_img_buf = aom_img_alloc(NULL, img->fmt, w_even, h_even, 16);
Andrey Norkin6f1c2f72018-01-15 20:08:52 -0800530 grain_img_buf->bit_depth = img->bit_depth;
531 }
532
533 av1_add_film_grain(grain_params, img, grain_img_buf);
534
535 return grain_img_buf;
536}
537#endif
538
Yaowu Xuf883b422016-08-30 14:01:10 -0700539static aom_image_t *decoder_get_frame(aom_codec_alg_priv_t *ctx,
540 aom_codec_iter_t *iter) {
541 aom_image_t *img = NULL;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700542
Yaowu Xuc27fc142016-08-22 16:08:15 -0700543 // Output the frames in the cache first.
544 if (ctx->num_cache_frames > 0) {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700545 ctx->last_show_frame = ctx->frame_cache[ctx->frame_cache_read].fb_idx;
546 if (ctx->need_resync) return NULL;
547 img = &ctx->frame_cache[ctx->frame_cache_read].img;
548 ctx->frame_cache_read = (ctx->frame_cache_read + 1) % FRAME_CACHE_SIZE;
549 --ctx->num_cache_frames;
Andrey Norkin6f1c2f72018-01-15 20:08:52 -0800550#if CONFIG_FILM_GRAIN
551 return add_grain_if_needed(
552 img, ctx->image_with_grain,
553 &ctx->frame_cache[ctx->frame_cache_read].film_grain_params);
554#else
Yaowu Xuc27fc142016-08-22 16:08:15 -0700555 return img;
Andrey Norkin6f1c2f72018-01-15 20:08:52 -0800556#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -0700557 }
558
559 // iter acts as a flip flop, so an image is only returned on the first
560 // call to get_frame.
561 if (*iter == NULL && ctx->frame_workers != NULL) {
562 do {
563 YV12_BUFFER_CONFIG sd;
Yaowu Xuf883b422016-08-30 14:01:10 -0700564 const AVxWorkerInterface *const winterface = aom_get_worker_interface();
565 AVxWorker *const worker = &ctx->frame_workers[ctx->next_output_worker_id];
Yaowu Xuc27fc142016-08-22 16:08:15 -0700566 FrameWorkerData *const frame_worker_data =
567 (FrameWorkerData *)worker->data1;
568 ctx->next_output_worker_id =
569 (ctx->next_output_worker_id + 1) % ctx->num_frame_workers;
570 // Wait for the frame from worker thread.
571 if (winterface->sync(worker)) {
572 // Check if worker has received any frames.
573 if (frame_worker_data->received_frame == 1) {
574 ++ctx->available_threads;
575 frame_worker_data->received_frame = 0;
576 check_resync(ctx, frame_worker_data->pbi);
577 }
Yaowu Xuf883b422016-08-30 14:01:10 -0700578 if (av1_get_raw_frame(frame_worker_data->pbi, &sd) == 0) {
579 AV1_COMMON *const cm = &frame_worker_data->pbi->common;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700580 RefCntBuffer *const frame_bufs = cm->buffer_pool->frame_bufs;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700581 ctx->last_show_frame = frame_worker_data->pbi->common.new_fb_idx;
582 if (ctx->need_resync) return NULL;
583 yuvconfig2image(&ctx->img, &sd, frame_worker_data->user_priv);
584
Imdad Sardharwallaaf8e2642018-01-19 11:46:34 +0000585 const int num_planes = av1_num_planes(cm);
Yunqing Wangeeb08a92017-07-07 21:25:18 -0700586 if (cm->single_tile_decoding &&
Yunqing Wangd8cd55f2017-02-27 12:16:00 -0800587 frame_worker_data->pbi->dec_tile_row >= 0) {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700588 const int tile_row =
Yaowu Xuf883b422016-08-30 14:01:10 -0700589 AOMMIN(frame_worker_data->pbi->dec_tile_row, cm->tile_rows - 1);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700590 const int mi_row = tile_row * cm->tile_height;
591 const int ssy = ctx->img.y_chroma_shift;
592 int plane;
593 ctx->img.planes[0] += mi_row * MI_SIZE * ctx->img.stride[0];
Imdad Sardharwallaaf8e2642018-01-19 11:46:34 +0000594 if (num_planes > 1) {
595 for (plane = 1; plane < MAX_MB_PLANE; ++plane) {
596 ctx->img.planes[plane] +=
597 mi_row * (MI_SIZE >> ssy) * ctx->img.stride[plane];
598 }
Yaowu Xuc27fc142016-08-22 16:08:15 -0700599 }
600 ctx->img.d_h =
Yaowu Xuf883b422016-08-30 14:01:10 -0700601 AOMMIN(cm->tile_height, cm->mi_rows - mi_row) * MI_SIZE;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700602 }
603
Yunqing Wangeeb08a92017-07-07 21:25:18 -0700604 if (cm->single_tile_decoding &&
Yunqing Wangd8cd55f2017-02-27 12:16:00 -0800605 frame_worker_data->pbi->dec_tile_col >= 0) {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700606 const int tile_col =
Yaowu Xuf883b422016-08-30 14:01:10 -0700607 AOMMIN(frame_worker_data->pbi->dec_tile_col, cm->tile_cols - 1);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700608 const int mi_col = tile_col * cm->tile_width;
609 const int ssx = ctx->img.x_chroma_shift;
610 int plane;
611 ctx->img.planes[0] += mi_col * MI_SIZE;
Imdad Sardharwallaaf8e2642018-01-19 11:46:34 +0000612 if (num_planes > 1) {
613 for (plane = 1; plane < MAX_MB_PLANE; ++plane) {
614 ctx->img.planes[plane] += mi_col * (MI_SIZE >> ssx);
615 }
Yaowu Xuc27fc142016-08-22 16:08:15 -0700616 }
617 ctx->img.d_w =
Yaowu Xuf883b422016-08-30 14:01:10 -0700618 AOMMIN(cm->tile_width, cm->mi_cols - mi_col) * MI_SIZE;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700619 }
Yaowu Xuc27fc142016-08-22 16:08:15 -0700620
621 ctx->img.fb_priv = frame_bufs[cm->new_fb_idx].raw_frame_buffer.priv;
622 img = &ctx->img;
Soo-Chul Hanf8589862018-01-24 03:13:14 +0000623#if CONFIG_SCALABILITY
624 img->temporal_id = cm->temporal_layer_id;
625 img->enhancement_id = cm->enhancement_layer_id;
626#endif
Andrey Norkin6f1c2f72018-01-15 20:08:52 -0800627#if CONFIG_FILM_GRAIN
628 return add_grain_if_needed(
629 img, ctx->image_with_grain,
630 &frame_worker_data->pbi->common.film_grain_params);
631#else
Yaowu Xuc27fc142016-08-22 16:08:15 -0700632 return img;
Andrey Norkin6f1c2f72018-01-15 20:08:52 -0800633#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -0700634 }
635 } else {
636 // Decoding failed. Release the worker thread.
637 frame_worker_data->received_frame = 0;
638 ++ctx->available_threads;
639 ctx->need_resync = 1;
640 if (ctx->flushed != 1) return NULL;
641 }
642 } while (ctx->next_output_worker_id != ctx->next_submit_worker_id);
643 }
644 return NULL;
645}
646
Yaowu Xuf883b422016-08-30 14:01:10 -0700647static aom_codec_err_t decoder_set_fb_fn(
648 aom_codec_alg_priv_t *ctx, aom_get_frame_buffer_cb_fn_t cb_get,
649 aom_release_frame_buffer_cb_fn_t cb_release, void *cb_priv) {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700650 if (cb_get == NULL || cb_release == NULL) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700651 return AOM_CODEC_INVALID_PARAM;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700652 } else if (ctx->frame_workers == NULL) {
653 // If the decoder has already been initialized, do not accept changes to
654 // the frame buffer functions.
655 ctx->get_ext_fb_cb = cb_get;
656 ctx->release_ext_fb_cb = cb_release;
657 ctx->ext_priv = cb_priv;
Yaowu Xuf883b422016-08-30 14:01:10 -0700658 return AOM_CODEC_OK;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700659 }
660
Yaowu Xuf883b422016-08-30 14:01:10 -0700661 return AOM_CODEC_ERROR;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700662}
663
Yaowu Xuf883b422016-08-30 14:01:10 -0700664static aom_codec_err_t ctrl_set_reference(aom_codec_alg_priv_t *ctx,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700665 va_list args) {
Thomas Daede497d1952017-08-08 17:33:06 -0700666 av1_ref_frame_t *const data = va_arg(args, av1_ref_frame_t *);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700667
Yaowu Xuc27fc142016-08-22 16:08:15 -0700668 if (data) {
Thomas Daede497d1952017-08-08 17:33:06 -0700669 av1_ref_frame_t *const frame = data;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700670 YV12_BUFFER_CONFIG sd;
Yaowu Xuf883b422016-08-30 14:01:10 -0700671 AVxWorker *const worker = ctx->frame_workers;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700672 FrameWorkerData *const frame_worker_data = (FrameWorkerData *)worker->data1;
673 image2yuvconfig(&frame->img, &sd);
Thomas Daede497d1952017-08-08 17:33:06 -0700674 return av1_set_reference_dec(&frame_worker_data->pbi->common, frame->idx,
Yaowu Xuf883b422016-08-30 14:01:10 -0700675 &sd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700676 } else {
Yaowu Xuf883b422016-08-30 14:01:10 -0700677 return AOM_CODEC_INVALID_PARAM;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700678 }
679}
680
Yaowu Xuf883b422016-08-30 14:01:10 -0700681static aom_codec_err_t ctrl_copy_reference(aom_codec_alg_priv_t *ctx,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700682 va_list args) {
Thomas Daede497d1952017-08-08 17:33:06 -0700683 const av1_ref_frame_t *const frame = va_arg(args, av1_ref_frame_t *);
Urvang Joshi77853e52016-07-15 12:47:01 -0700684 if (frame) {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700685 YV12_BUFFER_CONFIG sd;
Yaowu Xuf883b422016-08-30 14:01:10 -0700686 AVxWorker *const worker = ctx->frame_workers;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700687 FrameWorkerData *const frame_worker_data = (FrameWorkerData *)worker->data1;
688 image2yuvconfig(&frame->img, &sd);
Thomas Daede497d1952017-08-08 17:33:06 -0700689 return av1_copy_reference_dec(frame_worker_data->pbi, frame->idx, &sd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700690 } else {
Yaowu Xuf883b422016-08-30 14:01:10 -0700691 return AOM_CODEC_INVALID_PARAM;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700692 }
693}
694
Yaowu Xuf883b422016-08-30 14:01:10 -0700695static aom_codec_err_t ctrl_get_reference(aom_codec_alg_priv_t *ctx,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700696 va_list args) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700697 av1_ref_frame_t *data = va_arg(args, av1_ref_frame_t *);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700698 if (data) {
699 YV12_BUFFER_CONFIG *fb;
Yaowu Xuf883b422016-08-30 14:01:10 -0700700 AVxWorker *const worker = ctx->frame_workers;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700701 FrameWorkerData *const frame_worker_data = (FrameWorkerData *)worker->data1;
702 fb = get_ref_frame(&frame_worker_data->pbi->common, data->idx);
Yaowu Xuf883b422016-08-30 14:01:10 -0700703 if (fb == NULL) return AOM_CODEC_ERROR;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700704 yuvconfig2image(&data->img, fb, NULL);
Yaowu Xuf883b422016-08-30 14:01:10 -0700705 return AOM_CODEC_OK;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700706 } else {
Yaowu Xuf883b422016-08-30 14:01:10 -0700707 return AOM_CODEC_INVALID_PARAM;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700708 }
709}
710
Yaowu Xuf883b422016-08-30 14:01:10 -0700711static aom_codec_err_t ctrl_get_new_frame_image(aom_codec_alg_priv_t *ctx,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700712 va_list args) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700713 aom_image_t *new_img = va_arg(args, aom_image_t *);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700714 if (new_img) {
715 YV12_BUFFER_CONFIG new_frame;
Yaowu Xuf883b422016-08-30 14:01:10 -0700716 AVxWorker *const worker = ctx->frame_workers;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700717 FrameWorkerData *const frame_worker_data = (FrameWorkerData *)worker->data1;
718
Yaowu Xuf883b422016-08-30 14:01:10 -0700719 if (av1_get_frame_to_show(frame_worker_data->pbi, &new_frame) == 0) {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700720 yuvconfig2image(new_img, &new_frame, NULL);
Yaowu Xuf883b422016-08-30 14:01:10 -0700721 return AOM_CODEC_OK;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700722 } else {
Yaowu Xuf883b422016-08-30 14:01:10 -0700723 return AOM_CODEC_ERROR;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700724 }
725 } else {
Yaowu Xuf883b422016-08-30 14:01:10 -0700726 return AOM_CODEC_INVALID_PARAM;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700727 }
728}
729
Yaowu Xuf883b422016-08-30 14:01:10 -0700730static aom_codec_err_t ctrl_set_postproc(aom_codec_alg_priv_t *ctx,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700731 va_list args) {
732 (void)ctx;
733 (void)args;
Yaowu Xuf883b422016-08-30 14:01:10 -0700734 return AOM_CODEC_INCAPABLE;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700735}
736
Yaowu Xuf883b422016-08-30 14:01:10 -0700737static aom_codec_err_t ctrl_set_dbg_options(aom_codec_alg_priv_t *ctx,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700738 va_list args) {
739 (void)ctx;
740 (void)args;
Yaowu Xuf883b422016-08-30 14:01:10 -0700741 return AOM_CODEC_INCAPABLE;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700742}
743
Yaowu Xuf883b422016-08-30 14:01:10 -0700744static aom_codec_err_t ctrl_get_last_ref_updates(aom_codec_alg_priv_t *ctx,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700745 va_list args) {
746 int *const update_info = va_arg(args, int *);
747
Yaowu Xuc27fc142016-08-22 16:08:15 -0700748 if (update_info) {
749 if (ctx->frame_workers) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700750 AVxWorker *const worker = ctx->frame_workers;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700751 FrameWorkerData *const frame_worker_data =
752 (FrameWorkerData *)worker->data1;
753 *update_info = frame_worker_data->pbi->refresh_frame_flags;
Yaowu Xuf883b422016-08-30 14:01:10 -0700754 return AOM_CODEC_OK;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700755 } else {
Yaowu Xuf883b422016-08-30 14:01:10 -0700756 return AOM_CODEC_ERROR;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700757 }
758 }
759
Yaowu Xuf883b422016-08-30 14:01:10 -0700760 return AOM_CODEC_INVALID_PARAM;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700761}
762
Peter Boströma1f64322017-01-19 11:35:30 -0500763static aom_codec_err_t ctrl_get_last_quantizer(aom_codec_alg_priv_t *ctx,
764 va_list args) {
765 int *const arg = va_arg(args, int *);
766 if (arg == NULL) return AOM_CODEC_INVALID_PARAM;
767 *arg =
768 ((FrameWorkerData *)ctx->frame_workers[0].data1)->pbi->common.base_qindex;
769 return AOM_CODEC_OK;
770}
771
Yaowu Xuf883b422016-08-30 14:01:10 -0700772static aom_codec_err_t ctrl_get_frame_corrupted(aom_codec_alg_priv_t *ctx,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700773 va_list args) {
774 int *corrupted = va_arg(args, int *);
775
776 if (corrupted) {
777 if (ctx->frame_workers) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700778 AVxWorker *const worker = ctx->frame_workers;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700779 FrameWorkerData *const frame_worker_data =
780 (FrameWorkerData *)worker->data1;
781 RefCntBuffer *const frame_bufs =
782 frame_worker_data->pbi->common.buffer_pool->frame_bufs;
783 if (frame_worker_data->pbi->common.frame_to_show == NULL)
Yaowu Xuf883b422016-08-30 14:01:10 -0700784 return AOM_CODEC_ERROR;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700785 if (ctx->last_show_frame >= 0)
786 *corrupted = frame_bufs[ctx->last_show_frame].buf.corrupted;
Yaowu Xuf883b422016-08-30 14:01:10 -0700787 return AOM_CODEC_OK;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700788 } else {
Yaowu Xuf883b422016-08-30 14:01:10 -0700789 return AOM_CODEC_ERROR;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700790 }
791 }
792
Yaowu Xuf883b422016-08-30 14:01:10 -0700793 return AOM_CODEC_INVALID_PARAM;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700794}
795
Yaowu Xuf883b422016-08-30 14:01:10 -0700796static aom_codec_err_t ctrl_get_frame_size(aom_codec_alg_priv_t *ctx,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700797 va_list args) {
798 int *const frame_size = va_arg(args, int *);
799
Yaowu Xuc27fc142016-08-22 16:08:15 -0700800 if (frame_size) {
801 if (ctx->frame_workers) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700802 AVxWorker *const worker = ctx->frame_workers;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700803 FrameWorkerData *const frame_worker_data =
804 (FrameWorkerData *)worker->data1;
Yaowu Xuf883b422016-08-30 14:01:10 -0700805 const AV1_COMMON *const cm = &frame_worker_data->pbi->common;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700806 frame_size[0] = cm->width;
807 frame_size[1] = cm->height;
Yaowu Xuf883b422016-08-30 14:01:10 -0700808 return AOM_CODEC_OK;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700809 } else {
Yaowu Xuf883b422016-08-30 14:01:10 -0700810 return AOM_CODEC_ERROR;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700811 }
812 }
813
Yaowu Xuf883b422016-08-30 14:01:10 -0700814 return AOM_CODEC_INVALID_PARAM;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700815}
816
Yaowu Xuf883b422016-08-30 14:01:10 -0700817static aom_codec_err_t ctrl_get_render_size(aom_codec_alg_priv_t *ctx,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700818 va_list args) {
819 int *const render_size = va_arg(args, int *);
820
Yaowu Xuc27fc142016-08-22 16:08:15 -0700821 if (render_size) {
822 if (ctx->frame_workers) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700823 AVxWorker *const worker = ctx->frame_workers;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700824 FrameWorkerData *const frame_worker_data =
825 (FrameWorkerData *)worker->data1;
Yaowu Xuf883b422016-08-30 14:01:10 -0700826 const AV1_COMMON *const cm = &frame_worker_data->pbi->common;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700827 render_size[0] = cm->render_width;
828 render_size[1] = cm->render_height;
Yaowu Xuf883b422016-08-30 14:01:10 -0700829 return AOM_CODEC_OK;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700830 } else {
Yaowu Xuf883b422016-08-30 14:01:10 -0700831 return AOM_CODEC_ERROR;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700832 }
833 }
834
Yaowu Xuf883b422016-08-30 14:01:10 -0700835 return AOM_CODEC_INVALID_PARAM;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700836}
837
Yaowu Xuf883b422016-08-30 14:01:10 -0700838static aom_codec_err_t ctrl_get_bit_depth(aom_codec_alg_priv_t *ctx,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700839 va_list args) {
840 unsigned int *const bit_depth = va_arg(args, unsigned int *);
Yaowu Xuf883b422016-08-30 14:01:10 -0700841 AVxWorker *const worker = &ctx->frame_workers[ctx->next_output_worker_id];
Yaowu Xuc27fc142016-08-22 16:08:15 -0700842
843 if (bit_depth) {
844 if (worker) {
845 FrameWorkerData *const frame_worker_data =
846 (FrameWorkerData *)worker->data1;
Yaowu Xuf883b422016-08-30 14:01:10 -0700847 const AV1_COMMON *const cm = &frame_worker_data->pbi->common;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700848 *bit_depth = cm->bit_depth;
Yaowu Xuf883b422016-08-30 14:01:10 -0700849 return AOM_CODEC_OK;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700850 } else {
Yaowu Xuf883b422016-08-30 14:01:10 -0700851 return AOM_CODEC_ERROR;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700852 }
853 }
854
Yaowu Xuf883b422016-08-30 14:01:10 -0700855 return AOM_CODEC_INVALID_PARAM;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700856}
857
Yaowu Xuf883b422016-08-30 14:01:10 -0700858static aom_codec_err_t ctrl_set_invert_tile_order(aom_codec_alg_priv_t *ctx,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700859 va_list args) {
860 ctx->invert_tile_order = va_arg(args, int);
Yaowu Xuf883b422016-08-30 14:01:10 -0700861 return AOM_CODEC_OK;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700862}
863
Yaowu Xuf883b422016-08-30 14:01:10 -0700864static aom_codec_err_t ctrl_set_byte_alignment(aom_codec_alg_priv_t *ctx,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700865 va_list args) {
866 const int legacy_byte_alignment = 0;
867 const int min_byte_alignment = 32;
868 const int max_byte_alignment = 1024;
869 const int byte_alignment = va_arg(args, int);
870
871 if (byte_alignment != legacy_byte_alignment &&
872 (byte_alignment < min_byte_alignment ||
873 byte_alignment > max_byte_alignment ||
874 (byte_alignment & (byte_alignment - 1)) != 0))
Yaowu Xuf883b422016-08-30 14:01:10 -0700875 return AOM_CODEC_INVALID_PARAM;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700876
877 ctx->byte_alignment = byte_alignment;
878 if (ctx->frame_workers) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700879 AVxWorker *const worker = ctx->frame_workers;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700880 FrameWorkerData *const frame_worker_data = (FrameWorkerData *)worker->data1;
881 frame_worker_data->pbi->common.byte_alignment = byte_alignment;
882 }
Yaowu Xuf883b422016-08-30 14:01:10 -0700883 return AOM_CODEC_OK;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700884}
885
Yaowu Xuf883b422016-08-30 14:01:10 -0700886static aom_codec_err_t ctrl_set_skip_loop_filter(aom_codec_alg_priv_t *ctx,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700887 va_list args) {
888 ctx->skip_loop_filter = va_arg(args, int);
889
890 if (ctx->frame_workers) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700891 AVxWorker *const worker = ctx->frame_workers;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700892 FrameWorkerData *const frame_worker_data = (FrameWorkerData *)worker->data1;
893 frame_worker_data->pbi->common.skip_loop_filter = ctx->skip_loop_filter;
894 }
895
Yaowu Xuf883b422016-08-30 14:01:10 -0700896 return AOM_CODEC_OK;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700897}
898
Nathan E. Eggec9862e02016-10-05 21:28:36 -0400899static aom_codec_err_t ctrl_get_accounting(aom_codec_alg_priv_t *ctx,
900 va_list args) {
901#if !CONFIG_ACCOUNTING
902 (void)ctx;
903 (void)args;
904 return AOM_CODEC_INCAPABLE;
905#else
906 if (ctx->frame_workers) {
907 AVxWorker *const worker = ctx->frame_workers;
908 FrameWorkerData *const frame_worker_data = (FrameWorkerData *)worker->data1;
909 AV1Decoder *pbi = frame_worker_data->pbi;
910 Accounting **acct = va_arg(args, Accounting **);
911 *acct = &pbi->accounting;
912 return AOM_CODEC_OK;
913 }
914 return AOM_CODEC_ERROR;
915#endif
916}
Yaowu Xuf883b422016-08-30 14:01:10 -0700917static aom_codec_err_t ctrl_set_decode_tile_row(aom_codec_alg_priv_t *ctx,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700918 va_list args) {
919 ctx->decode_tile_row = va_arg(args, int);
Yaowu Xuf883b422016-08-30 14:01:10 -0700920 return AOM_CODEC_OK;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700921}
922
Yaowu Xuf883b422016-08-30 14:01:10 -0700923static aom_codec_err_t ctrl_set_decode_tile_col(aom_codec_alg_priv_t *ctx,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700924 va_list args) {
925 ctx->decode_tile_col = va_arg(args, int);
Yaowu Xuf883b422016-08-30 14:01:10 -0700926 return AOM_CODEC_OK;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700927}
928
Yunqing Wang8ae64a92018-01-12 12:26:44 -0800929static aom_codec_err_t ctrl_set_tile_mode(aom_codec_alg_priv_t *ctx,
930 va_list args) {
931 ctx->tile_mode = va_arg(args, unsigned int);
932 return AOM_CODEC_OK;
933}
934
Nathan E. Egge2cf03b12017-02-22 16:19:59 -0500935static aom_codec_err_t ctrl_set_inspection_callback(aom_codec_alg_priv_t *ctx,
936 va_list args) {
937#if !CONFIG_INSPECTION
938 (void)ctx;
939 (void)args;
940 return AOM_CODEC_INCAPABLE;
941#else
942 aom_inspect_init *init = va_arg(args, aom_inspect_init *);
943 ctx->inspect_cb = init->inspect_cb;
944 ctx->inspect_ctx = init->inspect_ctx;
945 return AOM_CODEC_OK;
946#endif
947}
948
Yaowu Xuf883b422016-08-30 14:01:10 -0700949static aom_codec_ctrl_fn_map_t decoder_ctrl_maps[] = {
Thomas Daede497d1952017-08-08 17:33:06 -0700950 { AV1_COPY_REFERENCE, ctrl_copy_reference },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700951
952 // Setters
Thomas Daede497d1952017-08-08 17:33:06 -0700953 { AV1_SET_REFERENCE, ctrl_set_reference },
Yaowu Xuf883b422016-08-30 14:01:10 -0700954 { AOM_SET_POSTPROC, ctrl_set_postproc },
955 { AOM_SET_DBG_COLOR_REF_FRAME, ctrl_set_dbg_options },
956 { AOM_SET_DBG_COLOR_MB_MODES, ctrl_set_dbg_options },
957 { AOM_SET_DBG_COLOR_B_MODES, ctrl_set_dbg_options },
958 { AOM_SET_DBG_DISPLAY_MV, ctrl_set_dbg_options },
959 { AV1_INVERT_TILE_DECODE_ORDER, ctrl_set_invert_tile_order },
Yaowu Xuf883b422016-08-30 14:01:10 -0700960 { AV1_SET_BYTE_ALIGNMENT, ctrl_set_byte_alignment },
961 { AV1_SET_SKIP_LOOP_FILTER, ctrl_set_skip_loop_filter },
962 { AV1_SET_DECODE_TILE_ROW, ctrl_set_decode_tile_row },
963 { AV1_SET_DECODE_TILE_COL, ctrl_set_decode_tile_col },
Yunqing Wang8ae64a92018-01-12 12:26:44 -0800964 { AV1_SET_TILE_MODE, ctrl_set_tile_mode },
Nathan E. Egge2cf03b12017-02-22 16:19:59 -0500965 { AV1_SET_INSPECTION_CALLBACK, ctrl_set_inspection_callback },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700966
967 // Getters
Yaowu Xuf883b422016-08-30 14:01:10 -0700968 { AOMD_GET_FRAME_CORRUPTED, ctrl_get_frame_corrupted },
Peter Boströma1f64322017-01-19 11:35:30 -0500969 { AOMD_GET_LAST_QUANTIZER, ctrl_get_last_quantizer },
970 { AOMD_GET_LAST_REF_UPDATES, ctrl_get_last_ref_updates },
Yaowu Xuf883b422016-08-30 14:01:10 -0700971 { AV1D_GET_BIT_DEPTH, ctrl_get_bit_depth },
Peter Boströma1f64322017-01-19 11:35:30 -0500972 { AV1D_GET_DISPLAY_SIZE, ctrl_get_render_size },
Yaowu Xuf883b422016-08-30 14:01:10 -0700973 { AV1D_GET_FRAME_SIZE, ctrl_get_frame_size },
Nathan E. Eggec9862e02016-10-05 21:28:36 -0400974 { AV1_GET_ACCOUNTING, ctrl_get_accounting },
Yaowu Xuf883b422016-08-30 14:01:10 -0700975 { AV1_GET_NEW_FRAME_IMAGE, ctrl_get_new_frame_image },
Peter Boströma1f64322017-01-19 11:35:30 -0500976 { AV1_GET_REFERENCE, ctrl_get_reference },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700977
978 { -1, NULL },
979};
980
981#ifndef VERSION_STRING
982#define VERSION_STRING
983#endif
Yaowu Xuf883b422016-08-30 14:01:10 -0700984CODEC_INTERFACE(aom_codec_av1_dx) = {
985 "AOMedia Project AV1 Decoder" VERSION_STRING,
986 AOM_CODEC_INTERNAL_ABI_VERSION,
987 AOM_CODEC_CAP_DECODER |
988 AOM_CODEC_CAP_EXTERNAL_FRAME_BUFFER, // aom_codec_caps_t
989 decoder_init, // aom_codec_init_fn_t
990 decoder_destroy, // aom_codec_destroy_fn_t
991 decoder_ctrl_maps, // aom_codec_ctrl_fn_map_t
Yaowu Xuc27fc142016-08-22 16:08:15 -0700992 {
993 // NOLINT
Yaowu Xuf883b422016-08-30 14:01:10 -0700994 decoder_peek_si, // aom_codec_peek_si_fn_t
995 decoder_get_si, // aom_codec_get_si_fn_t
996 decoder_decode, // aom_codec_decode_fn_t
997 decoder_get_frame, // aom_codec_frame_get_fn_t
998 decoder_set_fb_fn, // aom_codec_set_fb_fn_t
Yaowu Xuc27fc142016-08-22 16:08:15 -0700999 },
1000 {
1001 // NOLINT
1002 0,
Yaowu Xuf883b422016-08-30 14:01:10 -07001003 NULL, // aom_codec_enc_cfg_map_t
1004 NULL, // aom_codec_encode_fn_t
1005 NULL, // aom_codec_get_cx_data_fn_t
1006 NULL, // aom_codec_enc_config_set_fn_t
1007 NULL, // aom_codec_get_global_headers_fn_t
1008 NULL, // aom_codec_get_preview_frame_fn_t
1009 NULL // aom_codec_enc_mr_get_mem_loc_fn_t
Yaowu Xuc27fc142016-08-22 16:08:15 -07001010 }
1011};