1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker * Copyright (c) 2016, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker *
4*77c1e3ccSAndroid Build Coastguard Worker * This source code is subject to the terms of the BSD 2 Clause License and
5*77c1e3ccSAndroid Build Coastguard Worker * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6*77c1e3ccSAndroid Build Coastguard Worker * was not distributed with this source code in the LICENSE file, you can
7*77c1e3ccSAndroid Build Coastguard Worker * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8*77c1e3ccSAndroid Build Coastguard Worker * Media Patent License 1.0 was not distributed with this source code in the
9*77c1e3ccSAndroid Build Coastguard Worker * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker */
11*77c1e3ccSAndroid Build Coastguard Worker
12*77c1e3ccSAndroid Build Coastguard Worker #include <assert.h>
13*77c1e3ccSAndroid Build Coastguard Worker #include <limits.h>
14*77c1e3ccSAndroid Build Coastguard Worker #include <stdio.h>
15*77c1e3ccSAndroid Build Coastguard Worker
16*77c1e3ccSAndroid Build Coastguard Worker #include "config/av1_rtcd.h"
17*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_dsp_rtcd.h"
18*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_scale_rtcd.h"
19*77c1e3ccSAndroid Build Coastguard Worker
20*77c1e3ccSAndroid Build Coastguard Worker #include "aom_dsp/aom_dsp_common.h"
21*77c1e3ccSAndroid Build Coastguard Worker #include "aom_mem/aom_mem.h"
22*77c1e3ccSAndroid Build Coastguard Worker #include "aom_ports/aom_timer.h"
23*77c1e3ccSAndroid Build Coastguard Worker #include "aom_util/aom_pthread.h"
24*77c1e3ccSAndroid Build Coastguard Worker #include "aom_util/aom_thread.h"
25*77c1e3ccSAndroid Build Coastguard Worker
26*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/alloccommon.h"
27*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/av1_common_int.h"
28*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/av1_loopfilter.h"
29*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/quant_common.h"
30*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/reconinter.h"
31*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/reconintra.h"
32*77c1e3ccSAndroid Build Coastguard Worker
33*77c1e3ccSAndroid Build Coastguard Worker #include "av1/decoder/decodeframe.h"
34*77c1e3ccSAndroid Build Coastguard Worker #include "av1/decoder/decoder.h"
35*77c1e3ccSAndroid Build Coastguard Worker #include "av1/decoder/detokenize.h"
36*77c1e3ccSAndroid Build Coastguard Worker #include "av1/decoder/obu.h"
37*77c1e3ccSAndroid Build Coastguard Worker
initialize_dec(void)38*77c1e3ccSAndroid Build Coastguard Worker static void initialize_dec(void) {
39*77c1e3ccSAndroid Build Coastguard Worker av1_rtcd();
40*77c1e3ccSAndroid Build Coastguard Worker aom_dsp_rtcd();
41*77c1e3ccSAndroid Build Coastguard Worker aom_scale_rtcd();
42*77c1e3ccSAndroid Build Coastguard Worker av1_init_intra_predictors();
43*77c1e3ccSAndroid Build Coastguard Worker av1_init_wedge_masks();
44*77c1e3ccSAndroid Build Coastguard Worker }
45*77c1e3ccSAndroid Build Coastguard Worker
dec_set_mb_mi(CommonModeInfoParams * mi_params,int width,int height,BLOCK_SIZE min_partition_size)46*77c1e3ccSAndroid Build Coastguard Worker static void dec_set_mb_mi(CommonModeInfoParams *mi_params, int width,
47*77c1e3ccSAndroid Build Coastguard Worker int height, BLOCK_SIZE min_partition_size) {
48*77c1e3ccSAndroid Build Coastguard Worker (void)min_partition_size;
49*77c1e3ccSAndroid Build Coastguard Worker // Ensure that the decoded width and height are both multiples of
50*77c1e3ccSAndroid Build Coastguard Worker // 8 luma pixels (note: this may only be a multiple of 4 chroma pixels if
51*77c1e3ccSAndroid Build Coastguard Worker // subsampling is used).
52*77c1e3ccSAndroid Build Coastguard Worker // This simplifies the implementation of various experiments,
53*77c1e3ccSAndroid Build Coastguard Worker // eg. cdef, which operates on units of 8x8 luma pixels.
54*77c1e3ccSAndroid Build Coastguard Worker const int aligned_width = ALIGN_POWER_OF_TWO(width, 3);
55*77c1e3ccSAndroid Build Coastguard Worker const int aligned_height = ALIGN_POWER_OF_TWO(height, 3);
56*77c1e3ccSAndroid Build Coastguard Worker
57*77c1e3ccSAndroid Build Coastguard Worker mi_params->mi_cols = aligned_width >> MI_SIZE_LOG2;
58*77c1e3ccSAndroid Build Coastguard Worker mi_params->mi_rows = aligned_height >> MI_SIZE_LOG2;
59*77c1e3ccSAndroid Build Coastguard Worker mi_params->mi_stride = calc_mi_size(mi_params->mi_cols);
60*77c1e3ccSAndroid Build Coastguard Worker
61*77c1e3ccSAndroid Build Coastguard Worker mi_params->mb_cols = ROUND_POWER_OF_TWO(mi_params->mi_cols, 2);
62*77c1e3ccSAndroid Build Coastguard Worker mi_params->mb_rows = ROUND_POWER_OF_TWO(mi_params->mi_rows, 2);
63*77c1e3ccSAndroid Build Coastguard Worker mi_params->MBs = mi_params->mb_rows * mi_params->mb_cols;
64*77c1e3ccSAndroid Build Coastguard Worker
65*77c1e3ccSAndroid Build Coastguard Worker mi_params->mi_alloc_bsize = BLOCK_4X4;
66*77c1e3ccSAndroid Build Coastguard Worker mi_params->mi_alloc_stride = mi_params->mi_stride;
67*77c1e3ccSAndroid Build Coastguard Worker
68*77c1e3ccSAndroid Build Coastguard Worker assert(mi_size_wide[mi_params->mi_alloc_bsize] ==
69*77c1e3ccSAndroid Build Coastguard Worker mi_size_high[mi_params->mi_alloc_bsize]);
70*77c1e3ccSAndroid Build Coastguard Worker }
71*77c1e3ccSAndroid Build Coastguard Worker
dec_setup_mi(CommonModeInfoParams * mi_params)72*77c1e3ccSAndroid Build Coastguard Worker static void dec_setup_mi(CommonModeInfoParams *mi_params) {
73*77c1e3ccSAndroid Build Coastguard Worker const int mi_grid_size =
74*77c1e3ccSAndroid Build Coastguard Worker mi_params->mi_stride * calc_mi_size(mi_params->mi_rows);
75*77c1e3ccSAndroid Build Coastguard Worker memset(mi_params->mi_grid_base, 0,
76*77c1e3ccSAndroid Build Coastguard Worker mi_grid_size * sizeof(*mi_params->mi_grid_base));
77*77c1e3ccSAndroid Build Coastguard Worker }
78*77c1e3ccSAndroid Build Coastguard Worker
dec_free_mi(CommonModeInfoParams * mi_params)79*77c1e3ccSAndroid Build Coastguard Worker static void dec_free_mi(CommonModeInfoParams *mi_params) {
80*77c1e3ccSAndroid Build Coastguard Worker aom_free(mi_params->mi_alloc);
81*77c1e3ccSAndroid Build Coastguard Worker mi_params->mi_alloc = NULL;
82*77c1e3ccSAndroid Build Coastguard Worker mi_params->mi_alloc_size = 0;
83*77c1e3ccSAndroid Build Coastguard Worker aom_free(mi_params->mi_grid_base);
84*77c1e3ccSAndroid Build Coastguard Worker mi_params->mi_grid_base = NULL;
85*77c1e3ccSAndroid Build Coastguard Worker mi_params->mi_grid_size = 0;
86*77c1e3ccSAndroid Build Coastguard Worker aom_free(mi_params->tx_type_map);
87*77c1e3ccSAndroid Build Coastguard Worker mi_params->tx_type_map = NULL;
88*77c1e3ccSAndroid Build Coastguard Worker }
89*77c1e3ccSAndroid Build Coastguard Worker
av1_decoder_create(BufferPool * const pool)90*77c1e3ccSAndroid Build Coastguard Worker AV1Decoder *av1_decoder_create(BufferPool *const pool) {
91*77c1e3ccSAndroid Build Coastguard Worker AV1Decoder *volatile const pbi = aom_memalign(32, sizeof(*pbi));
92*77c1e3ccSAndroid Build Coastguard Worker if (!pbi) return NULL;
93*77c1e3ccSAndroid Build Coastguard Worker av1_zero(*pbi);
94*77c1e3ccSAndroid Build Coastguard Worker
95*77c1e3ccSAndroid Build Coastguard Worker AV1_COMMON *volatile const cm = &pbi->common;
96*77c1e3ccSAndroid Build Coastguard Worker cm->seq_params = &pbi->seq_params;
97*77c1e3ccSAndroid Build Coastguard Worker cm->error = &pbi->error;
98*77c1e3ccSAndroid Build Coastguard Worker
99*77c1e3ccSAndroid Build Coastguard Worker // The jmp_buf is valid only for the duration of the function that calls
100*77c1e3ccSAndroid Build Coastguard Worker // setjmp(). Therefore, this function must reset the 'setjmp' field to 0
101*77c1e3ccSAndroid Build Coastguard Worker // before it returns.
102*77c1e3ccSAndroid Build Coastguard Worker if (setjmp(pbi->error.jmp)) {
103*77c1e3ccSAndroid Build Coastguard Worker pbi->error.setjmp = 0;
104*77c1e3ccSAndroid Build Coastguard Worker av1_decoder_remove(pbi);
105*77c1e3ccSAndroid Build Coastguard Worker return NULL;
106*77c1e3ccSAndroid Build Coastguard Worker }
107*77c1e3ccSAndroid Build Coastguard Worker
108*77c1e3ccSAndroid Build Coastguard Worker pbi->error.setjmp = 1;
109*77c1e3ccSAndroid Build Coastguard Worker
110*77c1e3ccSAndroid Build Coastguard Worker CHECK_MEM_ERROR(cm, cm->fc,
111*77c1e3ccSAndroid Build Coastguard Worker (FRAME_CONTEXT *)aom_memalign(32, sizeof(*cm->fc)));
112*77c1e3ccSAndroid Build Coastguard Worker CHECK_MEM_ERROR(
113*77c1e3ccSAndroid Build Coastguard Worker cm, cm->default_frame_context,
114*77c1e3ccSAndroid Build Coastguard Worker (FRAME_CONTEXT *)aom_memalign(32, sizeof(*cm->default_frame_context)));
115*77c1e3ccSAndroid Build Coastguard Worker memset(cm->fc, 0, sizeof(*cm->fc));
116*77c1e3ccSAndroid Build Coastguard Worker memset(cm->default_frame_context, 0, sizeof(*cm->default_frame_context));
117*77c1e3ccSAndroid Build Coastguard Worker
118*77c1e3ccSAndroid Build Coastguard Worker pbi->need_resync = 1;
119*77c1e3ccSAndroid Build Coastguard Worker initialize_dec();
120*77c1e3ccSAndroid Build Coastguard Worker
121*77c1e3ccSAndroid Build Coastguard Worker // Initialize the references to not point to any frame buffers.
122*77c1e3ccSAndroid Build Coastguard Worker for (int i = 0; i < REF_FRAMES; i++) {
123*77c1e3ccSAndroid Build Coastguard Worker cm->ref_frame_map[i] = NULL;
124*77c1e3ccSAndroid Build Coastguard Worker }
125*77c1e3ccSAndroid Build Coastguard Worker
126*77c1e3ccSAndroid Build Coastguard Worker cm->current_frame.frame_number = 0;
127*77c1e3ccSAndroid Build Coastguard Worker pbi->decoding_first_frame = 1;
128*77c1e3ccSAndroid Build Coastguard Worker pbi->common.buffer_pool = pool;
129*77c1e3ccSAndroid Build Coastguard Worker
130*77c1e3ccSAndroid Build Coastguard Worker cm->seq_params->bit_depth = AOM_BITS_8;
131*77c1e3ccSAndroid Build Coastguard Worker
132*77c1e3ccSAndroid Build Coastguard Worker cm->mi_params.free_mi = dec_free_mi;
133*77c1e3ccSAndroid Build Coastguard Worker cm->mi_params.setup_mi = dec_setup_mi;
134*77c1e3ccSAndroid Build Coastguard Worker cm->mi_params.set_mb_mi = dec_set_mb_mi;
135*77c1e3ccSAndroid Build Coastguard Worker
136*77c1e3ccSAndroid Build Coastguard Worker av1_loop_filter_init(cm);
137*77c1e3ccSAndroid Build Coastguard Worker
138*77c1e3ccSAndroid Build Coastguard Worker av1_qm_init(&cm->quant_params, av1_num_planes(cm));
139*77c1e3ccSAndroid Build Coastguard Worker av1_loop_restoration_precal();
140*77c1e3ccSAndroid Build Coastguard Worker
141*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_ACCOUNTING
142*77c1e3ccSAndroid Build Coastguard Worker pbi->acct_enabled = 1;
143*77c1e3ccSAndroid Build Coastguard Worker aom_accounting_init(&pbi->accounting);
144*77c1e3ccSAndroid Build Coastguard Worker #endif
145*77c1e3ccSAndroid Build Coastguard Worker
146*77c1e3ccSAndroid Build Coastguard Worker pbi->error.setjmp = 0;
147*77c1e3ccSAndroid Build Coastguard Worker
148*77c1e3ccSAndroid Build Coastguard Worker aom_get_worker_interface()->init(&pbi->lf_worker);
149*77c1e3ccSAndroid Build Coastguard Worker pbi->lf_worker.thread_name = "aom lf worker";
150*77c1e3ccSAndroid Build Coastguard Worker
151*77c1e3ccSAndroid Build Coastguard Worker return pbi;
152*77c1e3ccSAndroid Build Coastguard Worker }
153*77c1e3ccSAndroid Build Coastguard Worker
av1_dealloc_dec_jobs(struct AV1DecTileMTData * tile_mt_info)154*77c1e3ccSAndroid Build Coastguard Worker void av1_dealloc_dec_jobs(struct AV1DecTileMTData *tile_mt_info) {
155*77c1e3ccSAndroid Build Coastguard Worker if (tile_mt_info != NULL) {
156*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_MULTITHREAD
157*77c1e3ccSAndroid Build Coastguard Worker if (tile_mt_info->job_mutex != NULL) {
158*77c1e3ccSAndroid Build Coastguard Worker pthread_mutex_destroy(tile_mt_info->job_mutex);
159*77c1e3ccSAndroid Build Coastguard Worker aom_free(tile_mt_info->job_mutex);
160*77c1e3ccSAndroid Build Coastguard Worker }
161*77c1e3ccSAndroid Build Coastguard Worker #endif
162*77c1e3ccSAndroid Build Coastguard Worker aom_free(tile_mt_info->job_queue);
163*77c1e3ccSAndroid Build Coastguard Worker // clear the structure as the source of this call may be a resize in which
164*77c1e3ccSAndroid Build Coastguard Worker // case this call will be followed by an _alloc() which may fail.
165*77c1e3ccSAndroid Build Coastguard Worker av1_zero(*tile_mt_info);
166*77c1e3ccSAndroid Build Coastguard Worker }
167*77c1e3ccSAndroid Build Coastguard Worker }
168*77c1e3ccSAndroid Build Coastguard Worker
av1_dec_free_cb_buf(AV1Decoder * pbi)169*77c1e3ccSAndroid Build Coastguard Worker void av1_dec_free_cb_buf(AV1Decoder *pbi) {
170*77c1e3ccSAndroid Build Coastguard Worker aom_free(pbi->cb_buffer_base);
171*77c1e3ccSAndroid Build Coastguard Worker pbi->cb_buffer_base = NULL;
172*77c1e3ccSAndroid Build Coastguard Worker pbi->cb_buffer_alloc_size = 0;
173*77c1e3ccSAndroid Build Coastguard Worker }
174*77c1e3ccSAndroid Build Coastguard Worker
av1_decoder_remove(AV1Decoder * pbi)175*77c1e3ccSAndroid Build Coastguard Worker void av1_decoder_remove(AV1Decoder *pbi) {
176*77c1e3ccSAndroid Build Coastguard Worker int i;
177*77c1e3ccSAndroid Build Coastguard Worker
178*77c1e3ccSAndroid Build Coastguard Worker if (!pbi) return;
179*77c1e3ccSAndroid Build Coastguard Worker
180*77c1e3ccSAndroid Build Coastguard Worker // Free the tile list output buffer.
181*77c1e3ccSAndroid Build Coastguard Worker aom_free_frame_buffer(&pbi->tile_list_outbuf);
182*77c1e3ccSAndroid Build Coastguard Worker
183*77c1e3ccSAndroid Build Coastguard Worker aom_get_worker_interface()->end(&pbi->lf_worker);
184*77c1e3ccSAndroid Build Coastguard Worker aom_free(pbi->lf_worker.data1);
185*77c1e3ccSAndroid Build Coastguard Worker
186*77c1e3ccSAndroid Build Coastguard Worker if (pbi->thread_data) {
187*77c1e3ccSAndroid Build Coastguard Worker for (int worker_idx = 1; worker_idx < pbi->num_workers; worker_idx++) {
188*77c1e3ccSAndroid Build Coastguard Worker DecWorkerData *const thread_data = pbi->thread_data + worker_idx;
189*77c1e3ccSAndroid Build Coastguard Worker if (thread_data->td != NULL) {
190*77c1e3ccSAndroid Build Coastguard Worker av1_free_mc_tmp_buf(thread_data->td);
191*77c1e3ccSAndroid Build Coastguard Worker aom_free(thread_data->td);
192*77c1e3ccSAndroid Build Coastguard Worker }
193*77c1e3ccSAndroid Build Coastguard Worker }
194*77c1e3ccSAndroid Build Coastguard Worker aom_free(pbi->thread_data);
195*77c1e3ccSAndroid Build Coastguard Worker }
196*77c1e3ccSAndroid Build Coastguard Worker aom_free(pbi->dcb.xd.seg_mask);
197*77c1e3ccSAndroid Build Coastguard Worker
198*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < pbi->num_workers; ++i) {
199*77c1e3ccSAndroid Build Coastguard Worker AVxWorker *const worker = &pbi->tile_workers[i];
200*77c1e3ccSAndroid Build Coastguard Worker aom_get_worker_interface()->end(worker);
201*77c1e3ccSAndroid Build Coastguard Worker }
202*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_MULTITHREAD
203*77c1e3ccSAndroid Build Coastguard Worker if (pbi->row_mt_mutex_ != NULL) {
204*77c1e3ccSAndroid Build Coastguard Worker pthread_mutex_destroy(pbi->row_mt_mutex_);
205*77c1e3ccSAndroid Build Coastguard Worker aom_free(pbi->row_mt_mutex_);
206*77c1e3ccSAndroid Build Coastguard Worker }
207*77c1e3ccSAndroid Build Coastguard Worker if (pbi->row_mt_cond_ != NULL) {
208*77c1e3ccSAndroid Build Coastguard Worker pthread_cond_destroy(pbi->row_mt_cond_);
209*77c1e3ccSAndroid Build Coastguard Worker aom_free(pbi->row_mt_cond_);
210*77c1e3ccSAndroid Build Coastguard Worker }
211*77c1e3ccSAndroid Build Coastguard Worker #endif
212*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < pbi->allocated_tiles; i++) {
213*77c1e3ccSAndroid Build Coastguard Worker TileDataDec *const tile_data = pbi->tile_data + i;
214*77c1e3ccSAndroid Build Coastguard Worker av1_dec_row_mt_dealloc(&tile_data->dec_row_mt_sync);
215*77c1e3ccSAndroid Build Coastguard Worker }
216*77c1e3ccSAndroid Build Coastguard Worker aom_free(pbi->tile_data);
217*77c1e3ccSAndroid Build Coastguard Worker aom_free(pbi->tile_workers);
218*77c1e3ccSAndroid Build Coastguard Worker
219*77c1e3ccSAndroid Build Coastguard Worker if (pbi->num_workers > 0) {
220*77c1e3ccSAndroid Build Coastguard Worker av1_loop_filter_dealloc(&pbi->lf_row_sync);
221*77c1e3ccSAndroid Build Coastguard Worker av1_loop_restoration_dealloc(&pbi->lr_row_sync);
222*77c1e3ccSAndroid Build Coastguard Worker av1_dealloc_dec_jobs(&pbi->tile_mt_info);
223*77c1e3ccSAndroid Build Coastguard Worker }
224*77c1e3ccSAndroid Build Coastguard Worker
225*77c1e3ccSAndroid Build Coastguard Worker av1_dec_free_cb_buf(pbi);
226*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_ACCOUNTING
227*77c1e3ccSAndroid Build Coastguard Worker aom_accounting_clear(&pbi->accounting);
228*77c1e3ccSAndroid Build Coastguard Worker #endif
229*77c1e3ccSAndroid Build Coastguard Worker av1_free_mc_tmp_buf(&pbi->td);
230*77c1e3ccSAndroid Build Coastguard Worker aom_img_metadata_array_free(pbi->metadata);
231*77c1e3ccSAndroid Build Coastguard Worker av1_remove_common(&pbi->common);
232*77c1e3ccSAndroid Build Coastguard Worker aom_free(pbi);
233*77c1e3ccSAndroid Build Coastguard Worker }
234*77c1e3ccSAndroid Build Coastguard Worker
av1_visit_palette(AV1Decoder * const pbi,MACROBLOCKD * const xd,aom_reader * r,palette_visitor_fn_t visit)235*77c1e3ccSAndroid Build Coastguard Worker void av1_visit_palette(AV1Decoder *const pbi, MACROBLOCKD *const xd,
236*77c1e3ccSAndroid Build Coastguard Worker aom_reader *r, palette_visitor_fn_t visit) {
237*77c1e3ccSAndroid Build Coastguard Worker if (!is_inter_block(xd->mi[0])) {
238*77c1e3ccSAndroid Build Coastguard Worker for (int plane = 0; plane < AOMMIN(2, av1_num_planes(&pbi->common));
239*77c1e3ccSAndroid Build Coastguard Worker ++plane) {
240*77c1e3ccSAndroid Build Coastguard Worker if (plane == 0 || xd->is_chroma_ref) {
241*77c1e3ccSAndroid Build Coastguard Worker if (xd->mi[0]->palette_mode_info.palette_size[plane])
242*77c1e3ccSAndroid Build Coastguard Worker visit(xd, plane, r);
243*77c1e3ccSAndroid Build Coastguard Worker } else {
244*77c1e3ccSAndroid Build Coastguard Worker assert(xd->mi[0]->palette_mode_info.palette_size[plane] == 0);
245*77c1e3ccSAndroid Build Coastguard Worker }
246*77c1e3ccSAndroid Build Coastguard Worker }
247*77c1e3ccSAndroid Build Coastguard Worker }
248*77c1e3ccSAndroid Build Coastguard Worker }
249*77c1e3ccSAndroid Build Coastguard Worker
equal_dimensions(const YV12_BUFFER_CONFIG * a,const YV12_BUFFER_CONFIG * b)250*77c1e3ccSAndroid Build Coastguard Worker static int equal_dimensions(const YV12_BUFFER_CONFIG *a,
251*77c1e3ccSAndroid Build Coastguard Worker const YV12_BUFFER_CONFIG *b) {
252*77c1e3ccSAndroid Build Coastguard Worker return a->y_height == b->y_height && a->y_width == b->y_width &&
253*77c1e3ccSAndroid Build Coastguard Worker a->uv_height == b->uv_height && a->uv_width == b->uv_width;
254*77c1e3ccSAndroid Build Coastguard Worker }
255*77c1e3ccSAndroid Build Coastguard Worker
av1_copy_reference_dec(AV1Decoder * pbi,int idx,YV12_BUFFER_CONFIG * sd)256*77c1e3ccSAndroid Build Coastguard Worker aom_codec_err_t av1_copy_reference_dec(AV1Decoder *pbi, int idx,
257*77c1e3ccSAndroid Build Coastguard Worker YV12_BUFFER_CONFIG *sd) {
258*77c1e3ccSAndroid Build Coastguard Worker AV1_COMMON *cm = &pbi->common;
259*77c1e3ccSAndroid Build Coastguard Worker const int num_planes = av1_num_planes(cm);
260*77c1e3ccSAndroid Build Coastguard Worker
261*77c1e3ccSAndroid Build Coastguard Worker const YV12_BUFFER_CONFIG *const cfg = get_ref_frame(cm, idx);
262*77c1e3ccSAndroid Build Coastguard Worker if (cfg == NULL) {
263*77c1e3ccSAndroid Build Coastguard Worker aom_internal_error(&pbi->error, AOM_CODEC_ERROR, "No reference frame");
264*77c1e3ccSAndroid Build Coastguard Worker return AOM_CODEC_ERROR;
265*77c1e3ccSAndroid Build Coastguard Worker }
266*77c1e3ccSAndroid Build Coastguard Worker if (!equal_dimensions(cfg, sd))
267*77c1e3ccSAndroid Build Coastguard Worker aom_internal_error(&pbi->error, AOM_CODEC_ERROR,
268*77c1e3ccSAndroid Build Coastguard Worker "Incorrect buffer dimensions");
269*77c1e3ccSAndroid Build Coastguard Worker else
270*77c1e3ccSAndroid Build Coastguard Worker aom_yv12_copy_frame(cfg, sd, num_planes);
271*77c1e3ccSAndroid Build Coastguard Worker
272*77c1e3ccSAndroid Build Coastguard Worker return pbi->error.error_code;
273*77c1e3ccSAndroid Build Coastguard Worker }
274*77c1e3ccSAndroid Build Coastguard Worker
equal_dimensions_and_border(const YV12_BUFFER_CONFIG * a,const YV12_BUFFER_CONFIG * b)275*77c1e3ccSAndroid Build Coastguard Worker static int equal_dimensions_and_border(const YV12_BUFFER_CONFIG *a,
276*77c1e3ccSAndroid Build Coastguard Worker const YV12_BUFFER_CONFIG *b) {
277*77c1e3ccSAndroid Build Coastguard Worker return a->y_height == b->y_height && a->y_width == b->y_width &&
278*77c1e3ccSAndroid Build Coastguard Worker a->uv_height == b->uv_height && a->uv_width == b->uv_width &&
279*77c1e3ccSAndroid Build Coastguard Worker a->y_stride == b->y_stride && a->uv_stride == b->uv_stride &&
280*77c1e3ccSAndroid Build Coastguard Worker a->border == b->border &&
281*77c1e3ccSAndroid Build Coastguard Worker (a->flags & YV12_FLAG_HIGHBITDEPTH) ==
282*77c1e3ccSAndroid Build Coastguard Worker (b->flags & YV12_FLAG_HIGHBITDEPTH);
283*77c1e3ccSAndroid Build Coastguard Worker }
284*77c1e3ccSAndroid Build Coastguard Worker
av1_set_reference_dec(AV1_COMMON * cm,int idx,int use_external_ref,YV12_BUFFER_CONFIG * sd)285*77c1e3ccSAndroid Build Coastguard Worker aom_codec_err_t av1_set_reference_dec(AV1_COMMON *cm, int idx,
286*77c1e3ccSAndroid Build Coastguard Worker int use_external_ref,
287*77c1e3ccSAndroid Build Coastguard Worker YV12_BUFFER_CONFIG *sd) {
288*77c1e3ccSAndroid Build Coastguard Worker const int num_planes = av1_num_planes(cm);
289*77c1e3ccSAndroid Build Coastguard Worker YV12_BUFFER_CONFIG *ref_buf = NULL;
290*77c1e3ccSAndroid Build Coastguard Worker
291*77c1e3ccSAndroid Build Coastguard Worker // Get the destination reference buffer.
292*77c1e3ccSAndroid Build Coastguard Worker ref_buf = get_ref_frame(cm, idx);
293*77c1e3ccSAndroid Build Coastguard Worker
294*77c1e3ccSAndroid Build Coastguard Worker if (ref_buf == NULL) {
295*77c1e3ccSAndroid Build Coastguard Worker aom_internal_error(cm->error, AOM_CODEC_ERROR, "No reference frame");
296*77c1e3ccSAndroid Build Coastguard Worker return AOM_CODEC_ERROR;
297*77c1e3ccSAndroid Build Coastguard Worker }
298*77c1e3ccSAndroid Build Coastguard Worker
299*77c1e3ccSAndroid Build Coastguard Worker if (!use_external_ref) {
300*77c1e3ccSAndroid Build Coastguard Worker if (!equal_dimensions(ref_buf, sd)) {
301*77c1e3ccSAndroid Build Coastguard Worker aom_internal_error(cm->error, AOM_CODEC_ERROR,
302*77c1e3ccSAndroid Build Coastguard Worker "Incorrect buffer dimensions");
303*77c1e3ccSAndroid Build Coastguard Worker } else {
304*77c1e3ccSAndroid Build Coastguard Worker // Overwrite the reference frame buffer.
305*77c1e3ccSAndroid Build Coastguard Worker aom_yv12_copy_frame(sd, ref_buf, num_planes);
306*77c1e3ccSAndroid Build Coastguard Worker }
307*77c1e3ccSAndroid Build Coastguard Worker } else {
308*77c1e3ccSAndroid Build Coastguard Worker if (!equal_dimensions_and_border(ref_buf, sd)) {
309*77c1e3ccSAndroid Build Coastguard Worker aom_internal_error(cm->error, AOM_CODEC_ERROR,
310*77c1e3ccSAndroid Build Coastguard Worker "Incorrect buffer dimensions");
311*77c1e3ccSAndroid Build Coastguard Worker } else {
312*77c1e3ccSAndroid Build Coastguard Worker // Overwrite the reference frame buffer pointers.
313*77c1e3ccSAndroid Build Coastguard Worker // Once we no longer need the external reference buffer, these pointers
314*77c1e3ccSAndroid Build Coastguard Worker // are restored.
315*77c1e3ccSAndroid Build Coastguard Worker ref_buf->store_buf_adr[0] = ref_buf->y_buffer;
316*77c1e3ccSAndroid Build Coastguard Worker ref_buf->store_buf_adr[1] = ref_buf->u_buffer;
317*77c1e3ccSAndroid Build Coastguard Worker ref_buf->store_buf_adr[2] = ref_buf->v_buffer;
318*77c1e3ccSAndroid Build Coastguard Worker ref_buf->y_buffer = sd->y_buffer;
319*77c1e3ccSAndroid Build Coastguard Worker ref_buf->u_buffer = sd->u_buffer;
320*77c1e3ccSAndroid Build Coastguard Worker ref_buf->v_buffer = sd->v_buffer;
321*77c1e3ccSAndroid Build Coastguard Worker ref_buf->use_external_reference_buffers = 1;
322*77c1e3ccSAndroid Build Coastguard Worker }
323*77c1e3ccSAndroid Build Coastguard Worker }
324*77c1e3ccSAndroid Build Coastguard Worker
325*77c1e3ccSAndroid Build Coastguard Worker return cm->error->error_code;
326*77c1e3ccSAndroid Build Coastguard Worker }
327*77c1e3ccSAndroid Build Coastguard Worker
av1_copy_new_frame_dec(AV1_COMMON * cm,YV12_BUFFER_CONFIG * new_frame,YV12_BUFFER_CONFIG * sd)328*77c1e3ccSAndroid Build Coastguard Worker aom_codec_err_t av1_copy_new_frame_dec(AV1_COMMON *cm,
329*77c1e3ccSAndroid Build Coastguard Worker YV12_BUFFER_CONFIG *new_frame,
330*77c1e3ccSAndroid Build Coastguard Worker YV12_BUFFER_CONFIG *sd) {
331*77c1e3ccSAndroid Build Coastguard Worker const int num_planes = av1_num_planes(cm);
332*77c1e3ccSAndroid Build Coastguard Worker
333*77c1e3ccSAndroid Build Coastguard Worker if (!equal_dimensions_and_border(new_frame, sd))
334*77c1e3ccSAndroid Build Coastguard Worker aom_internal_error(cm->error, AOM_CODEC_ERROR,
335*77c1e3ccSAndroid Build Coastguard Worker "Incorrect buffer dimensions");
336*77c1e3ccSAndroid Build Coastguard Worker else
337*77c1e3ccSAndroid Build Coastguard Worker aom_yv12_copy_frame(new_frame, sd, num_planes);
338*77c1e3ccSAndroid Build Coastguard Worker
339*77c1e3ccSAndroid Build Coastguard Worker return cm->error->error_code;
340*77c1e3ccSAndroid Build Coastguard Worker }
341*77c1e3ccSAndroid Build Coastguard Worker
release_current_frame(AV1Decoder * pbi)342*77c1e3ccSAndroid Build Coastguard Worker static void release_current_frame(AV1Decoder *pbi) {
343*77c1e3ccSAndroid Build Coastguard Worker AV1_COMMON *const cm = &pbi->common;
344*77c1e3ccSAndroid Build Coastguard Worker BufferPool *const pool = cm->buffer_pool;
345*77c1e3ccSAndroid Build Coastguard Worker
346*77c1e3ccSAndroid Build Coastguard Worker cm->cur_frame->buf.corrupted = 1;
347*77c1e3ccSAndroid Build Coastguard Worker lock_buffer_pool(pool);
348*77c1e3ccSAndroid Build Coastguard Worker decrease_ref_count(cm->cur_frame, pool);
349*77c1e3ccSAndroid Build Coastguard Worker unlock_buffer_pool(pool);
350*77c1e3ccSAndroid Build Coastguard Worker cm->cur_frame = NULL;
351*77c1e3ccSAndroid Build Coastguard Worker }
352*77c1e3ccSAndroid Build Coastguard Worker
353*77c1e3ccSAndroid Build Coastguard Worker // If any buffer updating is signaled it should be done here.
354*77c1e3ccSAndroid Build Coastguard Worker // Consumes a reference to cm->cur_frame.
355*77c1e3ccSAndroid Build Coastguard Worker //
356*77c1e3ccSAndroid Build Coastguard Worker // This functions returns void. It reports failure by setting
357*77c1e3ccSAndroid Build Coastguard Worker // pbi->error.error_code.
update_frame_buffers(AV1Decoder * pbi,int frame_decoded)358*77c1e3ccSAndroid Build Coastguard Worker static void update_frame_buffers(AV1Decoder *pbi, int frame_decoded) {
359*77c1e3ccSAndroid Build Coastguard Worker int ref_index = 0, mask;
360*77c1e3ccSAndroid Build Coastguard Worker AV1_COMMON *const cm = &pbi->common;
361*77c1e3ccSAndroid Build Coastguard Worker BufferPool *const pool = cm->buffer_pool;
362*77c1e3ccSAndroid Build Coastguard Worker
363*77c1e3ccSAndroid Build Coastguard Worker if (frame_decoded) {
364*77c1e3ccSAndroid Build Coastguard Worker lock_buffer_pool(pool);
365*77c1e3ccSAndroid Build Coastguard Worker
366*77c1e3ccSAndroid Build Coastguard Worker // In ext-tile decoding, the camera frame header is only decoded once. So,
367*77c1e3ccSAndroid Build Coastguard Worker // we don't update the references here.
368*77c1e3ccSAndroid Build Coastguard Worker if (!pbi->camera_frame_header_ready) {
369*77c1e3ccSAndroid Build Coastguard Worker // The following for loop needs to release the reference stored in
370*77c1e3ccSAndroid Build Coastguard Worker // cm->ref_frame_map[ref_index] before storing a reference to
371*77c1e3ccSAndroid Build Coastguard Worker // cm->cur_frame in cm->ref_frame_map[ref_index].
372*77c1e3ccSAndroid Build Coastguard Worker for (mask = cm->current_frame.refresh_frame_flags; mask; mask >>= 1) {
373*77c1e3ccSAndroid Build Coastguard Worker if (mask & 1) {
374*77c1e3ccSAndroid Build Coastguard Worker decrease_ref_count(cm->ref_frame_map[ref_index], pool);
375*77c1e3ccSAndroid Build Coastguard Worker cm->ref_frame_map[ref_index] = cm->cur_frame;
376*77c1e3ccSAndroid Build Coastguard Worker ++cm->cur_frame->ref_count;
377*77c1e3ccSAndroid Build Coastguard Worker }
378*77c1e3ccSAndroid Build Coastguard Worker ++ref_index;
379*77c1e3ccSAndroid Build Coastguard Worker }
380*77c1e3ccSAndroid Build Coastguard Worker }
381*77c1e3ccSAndroid Build Coastguard Worker
382*77c1e3ccSAndroid Build Coastguard Worker if (cm->show_existing_frame || cm->show_frame) {
383*77c1e3ccSAndroid Build Coastguard Worker if (pbi->output_all_layers) {
384*77c1e3ccSAndroid Build Coastguard Worker // Append this frame to the output queue
385*77c1e3ccSAndroid Build Coastguard Worker if (pbi->num_output_frames >= MAX_NUM_SPATIAL_LAYERS) {
386*77c1e3ccSAndroid Build Coastguard Worker // We can't store the new frame anywhere, so drop it and return an
387*77c1e3ccSAndroid Build Coastguard Worker // error
388*77c1e3ccSAndroid Build Coastguard Worker cm->cur_frame->buf.corrupted = 1;
389*77c1e3ccSAndroid Build Coastguard Worker decrease_ref_count(cm->cur_frame, pool);
390*77c1e3ccSAndroid Build Coastguard Worker pbi->error.error_code = AOM_CODEC_UNSUP_BITSTREAM;
391*77c1e3ccSAndroid Build Coastguard Worker } else {
392*77c1e3ccSAndroid Build Coastguard Worker pbi->output_frames[pbi->num_output_frames] = cm->cur_frame;
393*77c1e3ccSAndroid Build Coastguard Worker pbi->num_output_frames++;
394*77c1e3ccSAndroid Build Coastguard Worker }
395*77c1e3ccSAndroid Build Coastguard Worker } else {
396*77c1e3ccSAndroid Build Coastguard Worker // Replace any existing output frame
397*77c1e3ccSAndroid Build Coastguard Worker assert(pbi->num_output_frames == 0 || pbi->num_output_frames == 1);
398*77c1e3ccSAndroid Build Coastguard Worker if (pbi->num_output_frames > 0) {
399*77c1e3ccSAndroid Build Coastguard Worker decrease_ref_count(pbi->output_frames[0], pool);
400*77c1e3ccSAndroid Build Coastguard Worker }
401*77c1e3ccSAndroid Build Coastguard Worker pbi->output_frames[0] = cm->cur_frame;
402*77c1e3ccSAndroid Build Coastguard Worker pbi->num_output_frames = 1;
403*77c1e3ccSAndroid Build Coastguard Worker }
404*77c1e3ccSAndroid Build Coastguard Worker } else {
405*77c1e3ccSAndroid Build Coastguard Worker decrease_ref_count(cm->cur_frame, pool);
406*77c1e3ccSAndroid Build Coastguard Worker }
407*77c1e3ccSAndroid Build Coastguard Worker
408*77c1e3ccSAndroid Build Coastguard Worker unlock_buffer_pool(pool);
409*77c1e3ccSAndroid Build Coastguard Worker } else {
410*77c1e3ccSAndroid Build Coastguard Worker // Nothing was decoded, so just drop this frame buffer
411*77c1e3ccSAndroid Build Coastguard Worker lock_buffer_pool(pool);
412*77c1e3ccSAndroid Build Coastguard Worker decrease_ref_count(cm->cur_frame, pool);
413*77c1e3ccSAndroid Build Coastguard Worker unlock_buffer_pool(pool);
414*77c1e3ccSAndroid Build Coastguard Worker }
415*77c1e3ccSAndroid Build Coastguard Worker cm->cur_frame = NULL;
416*77c1e3ccSAndroid Build Coastguard Worker
417*77c1e3ccSAndroid Build Coastguard Worker if (!pbi->camera_frame_header_ready) {
418*77c1e3ccSAndroid Build Coastguard Worker // Invalidate these references until the next frame starts.
419*77c1e3ccSAndroid Build Coastguard Worker for (ref_index = 0; ref_index < INTER_REFS_PER_FRAME; ref_index++) {
420*77c1e3ccSAndroid Build Coastguard Worker cm->remapped_ref_idx[ref_index] = INVALID_IDX;
421*77c1e3ccSAndroid Build Coastguard Worker }
422*77c1e3ccSAndroid Build Coastguard Worker }
423*77c1e3ccSAndroid Build Coastguard Worker }
424*77c1e3ccSAndroid Build Coastguard Worker
av1_receive_compressed_data(AV1Decoder * pbi,size_t size,const uint8_t ** psource)425*77c1e3ccSAndroid Build Coastguard Worker int av1_receive_compressed_data(AV1Decoder *pbi, size_t size,
426*77c1e3ccSAndroid Build Coastguard Worker const uint8_t **psource) {
427*77c1e3ccSAndroid Build Coastguard Worker AV1_COMMON *volatile const cm = &pbi->common;
428*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *source = *psource;
429*77c1e3ccSAndroid Build Coastguard Worker pbi->error.error_code = AOM_CODEC_OK;
430*77c1e3ccSAndroid Build Coastguard Worker pbi->error.has_detail = 0;
431*77c1e3ccSAndroid Build Coastguard Worker
432*77c1e3ccSAndroid Build Coastguard Worker if (size == 0) {
433*77c1e3ccSAndroid Build Coastguard Worker // This is used to signal that we are missing frames.
434*77c1e3ccSAndroid Build Coastguard Worker // We do not know if the missing frame(s) was supposed to update
435*77c1e3ccSAndroid Build Coastguard Worker // any of the reference buffers, but we act conservative and
436*77c1e3ccSAndroid Build Coastguard Worker // mark only the last buffer as corrupted.
437*77c1e3ccSAndroid Build Coastguard Worker //
438*77c1e3ccSAndroid Build Coastguard Worker // TODO(jkoleszar): Error concealment is undefined and non-normative
439*77c1e3ccSAndroid Build Coastguard Worker // at this point, but if it becomes so, [0] may not always be the correct
440*77c1e3ccSAndroid Build Coastguard Worker // thing to do here.
441*77c1e3ccSAndroid Build Coastguard Worker RefCntBuffer *ref_buf = get_ref_frame_buf(cm, LAST_FRAME);
442*77c1e3ccSAndroid Build Coastguard Worker if (ref_buf != NULL) ref_buf->buf.corrupted = 1;
443*77c1e3ccSAndroid Build Coastguard Worker }
444*77c1e3ccSAndroid Build Coastguard Worker
445*77c1e3ccSAndroid Build Coastguard Worker if (assign_cur_frame_new_fb(cm) == NULL) {
446*77c1e3ccSAndroid Build Coastguard Worker pbi->error.error_code = AOM_CODEC_MEM_ERROR;
447*77c1e3ccSAndroid Build Coastguard Worker return 1;
448*77c1e3ccSAndroid Build Coastguard Worker }
449*77c1e3ccSAndroid Build Coastguard Worker
450*77c1e3ccSAndroid Build Coastguard Worker // The jmp_buf is valid only for the duration of the function that calls
451*77c1e3ccSAndroid Build Coastguard Worker // setjmp(). Therefore, this function must reset the 'setjmp' field to 0
452*77c1e3ccSAndroid Build Coastguard Worker // before it returns.
453*77c1e3ccSAndroid Build Coastguard Worker if (setjmp(pbi->error.jmp)) {
454*77c1e3ccSAndroid Build Coastguard Worker const AVxWorkerInterface *const winterface = aom_get_worker_interface();
455*77c1e3ccSAndroid Build Coastguard Worker int i;
456*77c1e3ccSAndroid Build Coastguard Worker
457*77c1e3ccSAndroid Build Coastguard Worker pbi->error.setjmp = 0;
458*77c1e3ccSAndroid Build Coastguard Worker
459*77c1e3ccSAndroid Build Coastguard Worker // Synchronize all threads immediately as a subsequent decode call may
460*77c1e3ccSAndroid Build Coastguard Worker // cause a resize invalidating some allocations.
461*77c1e3ccSAndroid Build Coastguard Worker winterface->sync(&pbi->lf_worker);
462*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < pbi->num_workers; ++i) {
463*77c1e3ccSAndroid Build Coastguard Worker winterface->sync(&pbi->tile_workers[i]);
464*77c1e3ccSAndroid Build Coastguard Worker }
465*77c1e3ccSAndroid Build Coastguard Worker
466*77c1e3ccSAndroid Build Coastguard Worker release_current_frame(pbi);
467*77c1e3ccSAndroid Build Coastguard Worker return -1;
468*77c1e3ccSAndroid Build Coastguard Worker }
469*77c1e3ccSAndroid Build Coastguard Worker
470*77c1e3ccSAndroid Build Coastguard Worker pbi->error.setjmp = 1;
471*77c1e3ccSAndroid Build Coastguard Worker
472*77c1e3ccSAndroid Build Coastguard Worker int frame_decoded =
473*77c1e3ccSAndroid Build Coastguard Worker aom_decode_frame_from_obus(pbi, source, source + size, psource);
474*77c1e3ccSAndroid Build Coastguard Worker
475*77c1e3ccSAndroid Build Coastguard Worker if (frame_decoded < 0) {
476*77c1e3ccSAndroid Build Coastguard Worker assert(pbi->error.error_code != AOM_CODEC_OK);
477*77c1e3ccSAndroid Build Coastguard Worker release_current_frame(pbi);
478*77c1e3ccSAndroid Build Coastguard Worker pbi->error.setjmp = 0;
479*77c1e3ccSAndroid Build Coastguard Worker return 1;
480*77c1e3ccSAndroid Build Coastguard Worker }
481*77c1e3ccSAndroid Build Coastguard Worker
482*77c1e3ccSAndroid Build Coastguard Worker #if TXCOEFF_TIMER
483*77c1e3ccSAndroid Build Coastguard Worker cm->cum_txcoeff_timer += cm->txcoeff_timer;
484*77c1e3ccSAndroid Build Coastguard Worker fprintf(stderr,
485*77c1e3ccSAndroid Build Coastguard Worker "txb coeff block number: %d, frame time: %ld, cum time %ld in us\n",
486*77c1e3ccSAndroid Build Coastguard Worker cm->txb_count, cm->txcoeff_timer, cm->cum_txcoeff_timer);
487*77c1e3ccSAndroid Build Coastguard Worker cm->txcoeff_timer = 0;
488*77c1e3ccSAndroid Build Coastguard Worker cm->txb_count = 0;
489*77c1e3ccSAndroid Build Coastguard Worker #endif
490*77c1e3ccSAndroid Build Coastguard Worker
491*77c1e3ccSAndroid Build Coastguard Worker // Note: At this point, this function holds a reference to cm->cur_frame
492*77c1e3ccSAndroid Build Coastguard Worker // in the buffer pool. This reference is consumed by update_frame_buffers().
493*77c1e3ccSAndroid Build Coastguard Worker update_frame_buffers(pbi, frame_decoded);
494*77c1e3ccSAndroid Build Coastguard Worker
495*77c1e3ccSAndroid Build Coastguard Worker if (frame_decoded) {
496*77c1e3ccSAndroid Build Coastguard Worker pbi->decoding_first_frame = 0;
497*77c1e3ccSAndroid Build Coastguard Worker }
498*77c1e3ccSAndroid Build Coastguard Worker
499*77c1e3ccSAndroid Build Coastguard Worker if (pbi->error.error_code != AOM_CODEC_OK) {
500*77c1e3ccSAndroid Build Coastguard Worker pbi->error.setjmp = 0;
501*77c1e3ccSAndroid Build Coastguard Worker return 1;
502*77c1e3ccSAndroid Build Coastguard Worker }
503*77c1e3ccSAndroid Build Coastguard Worker
504*77c1e3ccSAndroid Build Coastguard Worker if (!cm->show_existing_frame) {
505*77c1e3ccSAndroid Build Coastguard Worker if (cm->seg.enabled) {
506*77c1e3ccSAndroid Build Coastguard Worker if (cm->prev_frame &&
507*77c1e3ccSAndroid Build Coastguard Worker (cm->mi_params.mi_rows == cm->prev_frame->mi_rows) &&
508*77c1e3ccSAndroid Build Coastguard Worker (cm->mi_params.mi_cols == cm->prev_frame->mi_cols)) {
509*77c1e3ccSAndroid Build Coastguard Worker cm->last_frame_seg_map = cm->prev_frame->seg_map;
510*77c1e3ccSAndroid Build Coastguard Worker } else {
511*77c1e3ccSAndroid Build Coastguard Worker cm->last_frame_seg_map = NULL;
512*77c1e3ccSAndroid Build Coastguard Worker }
513*77c1e3ccSAndroid Build Coastguard Worker }
514*77c1e3ccSAndroid Build Coastguard Worker }
515*77c1e3ccSAndroid Build Coastguard Worker
516*77c1e3ccSAndroid Build Coastguard Worker // Update progress in frame parallel decode.
517*77c1e3ccSAndroid Build Coastguard Worker pbi->error.setjmp = 0;
518*77c1e3ccSAndroid Build Coastguard Worker
519*77c1e3ccSAndroid Build Coastguard Worker return 0;
520*77c1e3ccSAndroid Build Coastguard Worker }
521*77c1e3ccSAndroid Build Coastguard Worker
522*77c1e3ccSAndroid Build Coastguard Worker // Get the frame at a particular index in the output queue
av1_get_raw_frame(AV1Decoder * pbi,size_t index,YV12_BUFFER_CONFIG ** sd,aom_film_grain_t ** grain_params)523*77c1e3ccSAndroid Build Coastguard Worker int av1_get_raw_frame(AV1Decoder *pbi, size_t index, YV12_BUFFER_CONFIG **sd,
524*77c1e3ccSAndroid Build Coastguard Worker aom_film_grain_t **grain_params) {
525*77c1e3ccSAndroid Build Coastguard Worker if (index >= pbi->num_output_frames) return -1;
526*77c1e3ccSAndroid Build Coastguard Worker *sd = &pbi->output_frames[index]->buf;
527*77c1e3ccSAndroid Build Coastguard Worker *grain_params = &pbi->output_frames[index]->film_grain_params;
528*77c1e3ccSAndroid Build Coastguard Worker return 0;
529*77c1e3ccSAndroid Build Coastguard Worker }
530*77c1e3ccSAndroid Build Coastguard Worker
531*77c1e3ccSAndroid Build Coastguard Worker // Get the highest-spatial-layer output
532*77c1e3ccSAndroid Build Coastguard Worker // TODO(rachelbarker): What should this do?
av1_get_frame_to_show(AV1Decoder * pbi,YV12_BUFFER_CONFIG * frame)533*77c1e3ccSAndroid Build Coastguard Worker int av1_get_frame_to_show(AV1Decoder *pbi, YV12_BUFFER_CONFIG *frame) {
534*77c1e3ccSAndroid Build Coastguard Worker if (pbi->num_output_frames == 0) return -1;
535*77c1e3ccSAndroid Build Coastguard Worker
536*77c1e3ccSAndroid Build Coastguard Worker *frame = pbi->output_frames[pbi->num_output_frames - 1]->buf;
537*77c1e3ccSAndroid Build Coastguard Worker return 0;
538*77c1e3ccSAndroid Build Coastguard Worker }
539