vp9_onyxd_if.c 12.7 KB
Newer Older
John Koleszar's avatar
John Koleszar committed
1
/*
2
 *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
John Koleszar's avatar
John Koleszar committed
3
 *
4
 *  Use of this source code is governed by a BSD-style license
5
6
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
7
 *  in the file PATENTS.  All contributing project authors may
8
 *  be found in the AUTHORS file in the root of the source tree.
John Koleszar's avatar
John Koleszar committed
9
10
11
 */


12
#include "vp9/common/vp9_onyxc_int.h"
John Koleszar's avatar
John Koleszar committed
13
#if CONFIG_POSTPROC
14
#include "vp9/common/vp9_postproc.h"
John Koleszar's avatar
John Koleszar committed
15
#endif
16
17
#include "vp9/common/vp9_onyxd.h"
#include "vp9_onyxd_int.h"
John Koleszar's avatar
John Koleszar committed
18
#include "vpx_mem/vpx_mem.h"
19
20
21
#include "vp9/common/vp9_alloccommon.h"
#include "vp9/common/vp9_loopfilter.h"
#include "vp9/common/vp9_swapyv12buffer.h"
John Koleszar's avatar
John Koleszar committed
22
#include <stdio.h>
Henrik Lundin's avatar
Henrik Lundin committed
23
#include <assert.h>
24

25
#include "vp9/common/vp9_quant_common.h"
John Koleszar's avatar
John Koleszar committed
26
#include "vpx_scale/vpxscale.h"
27
#include "vp9/common/vp9_systemdependent.h"
John Koleszar's avatar
John Koleszar committed
28
#include "vpx_ports/vpx_timer.h"
29
30
#include "vp9/decoder/vp9_decodframe.h"
#include "vp9_detokenize.h"
31
32
33
#if ARCH_ARM
#include "vpx_ports/arm.h"
#endif
John Koleszar's avatar
John Koleszar committed
34

35
static int get_free_fb(VP9_COMMON *cm);
John Koleszar's avatar
John Koleszar committed
36
static void ref_cnt_fb(int *buf, int *idx, int new_idx);
John Koleszar's avatar
John Koleszar committed
37

38
39
#define WRITE_RECON_BUFFER 0
#if WRITE_RECON_BUFFER == 1
40
static void recon_write_yuv_frame(char *name, YV12_BUFFER_CONFIG *s) {
John Koleszar's avatar
John Koleszar committed
41
42
43
  FILE *yuv_file = fopen((char *)name, "ab");
  unsigned char *src = s->y_buffer;
  int h = s->y_height;
44

John Koleszar's avatar
John Koleszar committed
45
46
47
48
  do {
    fwrite(src, s->y_width, 1,  yuv_file);
    src += s->y_stride;
  } while (--h);
49

John Koleszar's avatar
John Koleszar committed
50
51
  src = s->u_buffer;
  h = s->uv_height;
52

John Koleszar's avatar
John Koleszar committed
53
54
55
56
  do {
    fwrite(src, s->uv_width, 1,  yuv_file);
    src += s->uv_stride;
  } while (--h);
57

John Koleszar's avatar
John Koleszar committed
58
59
  src = s->v_buffer;
  h = s->uv_height;
60

John Koleszar's avatar
John Koleszar committed
61
62
63
64
  do {
    fwrite(src, s->uv_width, 1, yuv_file);
    src += s->uv_stride;
  } while (--h);
65

John Koleszar's avatar
John Koleszar committed
66
  fclose(yuv_file);
67
68
}
#endif
69
#if WRITE_RECON_BUFFER == 2
John Koleszar's avatar
John Koleszar committed
70
void write_dx_frame_to_file(YV12_BUFFER_CONFIG *frame, int this_frame) {
71

John Koleszar's avatar
John Koleszar committed
72
73
74
75
  // write the frame
  FILE *yframe;
  int i;
  char filename[255];
76

John Koleszar's avatar
John Koleszar committed
77
78
  sprintf(filename, "dx\\y%04d.raw", this_frame);
  yframe = fopen(filename, "wb");
79

John Koleszar's avatar
John Koleszar committed
80
81
82
  for (i = 0; i < frame->y_height; i++)
    fwrite(frame->y_buffer + i * frame->y_stride,
           frame->y_width, 1, yframe);
83

John Koleszar's avatar
John Koleszar committed
84
85
86
  fclose(yframe);
  sprintf(filename, "dx\\u%04d.raw", this_frame);
  yframe = fopen(filename, "wb");
87

John Koleszar's avatar
John Koleszar committed
88
89
90
  for (i = 0; i < frame->uv_height; i++)
    fwrite(frame->u_buffer + i * frame->uv_stride,
           frame->uv_width, 1, yframe);
91

John Koleszar's avatar
John Koleszar committed
92
93
94
  fclose(yframe);
  sprintf(filename, "dx\\v%04d.raw", this_frame);
  yframe = fopen(filename, "wb");
95

John Koleszar's avatar
John Koleszar committed
96
97
98
  for (i = 0; i < frame->uv_height; i++)
    fwrite(frame->v_buffer + i * frame->uv_stride,
           frame->uv_width, 1, yframe);
99

John Koleszar's avatar
John Koleszar committed
100
  fclose(yframe);
101
102
103
}
#endif

104
void vp9_initialize_dec(void) {
John Koleszar's avatar
John Koleszar committed
105
  static int init_done = 0;
John Koleszar's avatar
John Koleszar committed
106

John Koleszar's avatar
John Koleszar committed
107
  if (!init_done) {
108
109
    vp9_initialize_common();
    vp9_init_quant_tables();
John Koleszar's avatar
John Koleszar committed
110
111
    init_done = 1;
  }
John Koleszar's avatar
John Koleszar committed
112
113
}

114
VP9D_PTR vp9_create_decompressor(VP9D_CONFIG *oxcf) {
115
  VP9D_COMP *pbi = vpx_memalign(32, sizeof(VP9D_COMP));
John Koleszar's avatar
John Koleszar committed
116

John Koleszar's avatar
John Koleszar committed
117
118
  if (!pbi)
    return NULL;
John Koleszar's avatar
John Koleszar committed
119

120
  vpx_memset(pbi, 0, sizeof(VP9D_COMP));
John Koleszar's avatar
John Koleszar committed
121

John Koleszar's avatar
John Koleszar committed
122
123
  if (setjmp(pbi->common.error.jmp)) {
    pbi->common.error.setjmp = 0;
124
    vp9_remove_decompressor(pbi);
John Koleszar's avatar
John Koleszar committed
125
126
    return 0;
  }
John Koleszar's avatar
John Koleszar committed
127

John Koleszar's avatar
John Koleszar committed
128
  pbi->common.error.setjmp = 1;
129
  vp9_initialize_dec();
John Koleszar's avatar
John Koleszar committed
130

131
  vp9_create_common(&pbi->common);
John Koleszar's avatar
John Koleszar committed
132

John Koleszar's avatar
John Koleszar committed
133
134
  pbi->common.current_video_frame = 0;
  pbi->ready_for_new_data = 1;
John Koleszar's avatar
John Koleszar committed
135

136
137
138
  /* vp9_init_de_quantizer() is first called here. Add check in
   * frame_init_dequantizer() to avoid unnecessary calling of
   * vp9_init_de_quantizer() for every frame.
John Koleszar's avatar
John Koleszar committed
139
   */
140
  vp9_init_de_quantizer(pbi);
John Koleszar's avatar
John Koleszar committed
141

142
  vp9_loop_filter_init(&pbi->common);
John Koleszar's avatar
John Koleszar committed
143

John Koleszar's avatar
John Koleszar committed
144
  pbi->common.error.setjmp = 0;
145

John Koleszar's avatar
John Koleszar committed
146
  pbi->decoded_key_frame = 0;
147

148
  return (VP9D_PTR) pbi;
John Koleszar's avatar
John Koleszar committed
149
150
}

151
void vp9_remove_decompressor(VP9D_PTR ptr) {
152
  VP9D_COMP *pbi = (VP9D_COMP *) ptr;
John Koleszar's avatar
John Koleszar committed
153

John Koleszar's avatar
John Koleszar committed
154
155
  if (!pbi)
    return;
156

John Koleszar's avatar
John Koleszar committed
157
158
159
  // Delete sementation map
  if (pbi->common.last_frame_seg_map != 0)
    vpx_free(pbi->common.last_frame_seg_map);
John Koleszar's avatar
John Koleszar committed
160

161
  vp9_remove_common(&pbi->common);
John Koleszar's avatar
John Koleszar committed
162
163
  vpx_free(pbi->mbc);
  vpx_free(pbi);
John Koleszar's avatar
John Koleszar committed
164
165
166
}


167
vpx_codec_err_t vp9_get_reference_dec(VP9D_PTR ptr, VP9_REFFRAME ref_frame_flag,
168
                                      YV12_BUFFER_CONFIG *sd) {
169
170
  VP9D_COMP *pbi = (VP9D_COMP *) ptr;
  VP9_COMMON *cm = &pbi->common;
John Koleszar's avatar
John Koleszar committed
171
172
  int ref_fb_idx;

173
  if (ref_frame_flag == VP9_LAST_FLAG)
John Koleszar's avatar
John Koleszar committed
174
    ref_fb_idx = cm->lst_fb_idx;
175
  else if (ref_frame_flag == VP9_GOLD_FLAG)
John Koleszar's avatar
John Koleszar committed
176
    ref_fb_idx = cm->gld_fb_idx;
177
  else if (ref_frame_flag == VP9_ALT_FLAG)
John Koleszar's avatar
John Koleszar committed
178
179
180
181
182
183
    ref_fb_idx = cm->alt_fb_idx;
  else {
    vpx_internal_error(&pbi->common.error, VPX_CODEC_ERROR,
                       "Invalid reference frame");
    return pbi->common.error.error_code;
  }
John Koleszar's avatar
John Koleszar committed
184

John Koleszar's avatar
John Koleszar committed
185
186
187
188
189
190
191
  if (cm->yv12_fb[ref_fb_idx].y_height != sd->y_height ||
      cm->yv12_fb[ref_fb_idx].y_width != sd->y_width ||
      cm->yv12_fb[ref_fb_idx].uv_height != sd->uv_height ||
      cm->yv12_fb[ref_fb_idx].uv_width != sd->uv_width) {
    vpx_internal_error(&pbi->common.error, VPX_CODEC_ERROR,
                       "Incorrect buffer dimensions");
  } else
John Koleszar's avatar
John Koleszar committed
192
    vp8_yv12_copy_frame(&cm->yv12_fb[ref_fb_idx], sd);
193

John Koleszar's avatar
John Koleszar committed
194
  return pbi->common.error.error_code;
John Koleszar's avatar
John Koleszar committed
195
}
196
197


198
vpx_codec_err_t vp9_set_reference_dec(VP9D_PTR ptr, VP9_REFFRAME ref_frame_flag,
199
                                      YV12_BUFFER_CONFIG *sd) {
200
201
  VP9D_COMP *pbi = (VP9D_COMP *) ptr;
  VP9_COMMON *cm = &pbi->common;
John Koleszar's avatar
John Koleszar committed
202
203
204
  int *ref_fb_ptr = NULL;
  int free_fb;

205
  if (ref_frame_flag == VP9_LAST_FLAG)
John Koleszar's avatar
John Koleszar committed
206
    ref_fb_ptr = &cm->lst_fb_idx;
207
  else if (ref_frame_flag == VP9_GOLD_FLAG)
John Koleszar's avatar
John Koleszar committed
208
    ref_fb_ptr = &cm->gld_fb_idx;
209
  else if (ref_frame_flag == VP9_ALT_FLAG)
John Koleszar's avatar
John Koleszar committed
210
211
212
213
214
215
    ref_fb_ptr = &cm->alt_fb_idx;
  else {
    vpx_internal_error(&pbi->common.error, VPX_CODEC_ERROR,
                       "Invalid reference frame");
    return pbi->common.error.error_code;
  }
216

John Koleszar's avatar
John Koleszar committed
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
  if (cm->yv12_fb[*ref_fb_ptr].y_height != sd->y_height ||
      cm->yv12_fb[*ref_fb_ptr].y_width != sd->y_width ||
      cm->yv12_fb[*ref_fb_ptr].uv_height != sd->uv_height ||
      cm->yv12_fb[*ref_fb_ptr].uv_width != sd->uv_width) {
    vpx_internal_error(&pbi->common.error, VPX_CODEC_ERROR,
                       "Incorrect buffer dimensions");
  } else {
    /* Find an empty frame buffer. */
    free_fb = get_free_fb(cm);
    /* Decrease fb_idx_ref_cnt since it will be increased again in
     * ref_cnt_fb() below. */
    cm->fb_idx_ref_cnt[free_fb]--;

    /* Manage the reference counters and copy image. */
    ref_cnt_fb(cm->fb_idx_ref_cnt, ref_fb_ptr, free_fb);
John Koleszar's avatar
John Koleszar committed
232
    vp8_yv12_copy_frame(sd, &cm->yv12_fb[*ref_fb_ptr]);
John Koleszar's avatar
John Koleszar committed
233
  }
234

John Koleszar's avatar
John Koleszar committed
235
  return pbi->common.error.error_code;
John Koleszar's avatar
John Koleszar committed
236
237
}

238
/*For ARM NEON, d8-d15 are callee-saved registers, and need to be saved by us.*/
John Koleszar's avatar
John Koleszar committed
239
#if HAVE_ARMV7
240
241
extern void vp9_push_neon(int64_t *store);
extern void vp9_pop_neon(int64_t *store);
John Koleszar's avatar
John Koleszar committed
242
#endif
243

244
static int get_free_fb(VP9_COMMON *cm) {
John Koleszar's avatar
John Koleszar committed
245
246
247
248
  int i;
  for (i = 0; i < NUM_YV12_BUFFERS; i++)
    if (cm->fb_idx_ref_cnt[i] == 0)
      break;
249

John Koleszar's avatar
John Koleszar committed
250
251
252
  assert(i < NUM_YV12_BUFFERS);
  cm->fb_idx_ref_cnt[i] = 1;
  return i;
253
254
}

John Koleszar's avatar
John Koleszar committed
255
256
257
static void ref_cnt_fb(int *buf, int *idx, int new_idx) {
  if (buf[*idx] > 0)
    buf[*idx]--;
258

John Koleszar's avatar
John Koleszar committed
259
  *idx = new_idx;
260

John Koleszar's avatar
John Koleszar committed
261
  buf[new_idx]++;
262
263
}

264
/* If any buffer copy / swapping is signalled it should be done here. */
265
static int swap_frame_buffers(VP9_COMMON *cm) {
John Koleszar's avatar
John Koleszar committed
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
  int err = 0;

  /* The alternate reference frame or golden frame can be updated
   *  using the new, last, or golden/alt ref frame.  If it
   *  is updated using the newly decoded frame it is a refresh.
   *  An update using the last or golden/alt ref frame is a copy.
   */
  if (cm->copy_buffer_to_arf) {
    int new_fb = 0;

    if (cm->copy_buffer_to_arf == 1)
      new_fb = cm->lst_fb_idx;
    else if (cm->copy_buffer_to_arf == 2)
      new_fb = cm->gld_fb_idx;
    else
      err = -1;
282

John Koleszar's avatar
John Koleszar committed
283
284
    ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->alt_fb_idx, new_fb);
  }
285

John Koleszar's avatar
John Koleszar committed
286
287
  if (cm->copy_buffer_to_gf) {
    int new_fb = 0;
288

John Koleszar's avatar
John Koleszar committed
289
290
291
292
293
294
    if (cm->copy_buffer_to_gf == 1)
      new_fb = cm->lst_fb_idx;
    else if (cm->copy_buffer_to_gf == 2)
      new_fb = cm->alt_fb_idx;
    else
      err = -1;
295

John Koleszar's avatar
John Koleszar committed
296
297
    ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->gld_fb_idx, new_fb);
  }
298

John Koleszar's avatar
John Koleszar committed
299
300
  if (cm->refresh_golden_frame)
    ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->gld_fb_idx, cm->new_fb_idx);
301

John Koleszar's avatar
John Koleszar committed
302
303
  if (cm->refresh_alt_ref_frame)
    ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->alt_fb_idx, cm->new_fb_idx);
304

John Koleszar's avatar
John Koleszar committed
305
306
  if (cm->refresh_last_frame) {
    ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->lst_fb_idx, cm->new_fb_idx);
307

John Koleszar's avatar
John Koleszar committed
308
309
310
    cm->frame_to_show = &cm->yv12_fb[cm->lst_fb_idx];
  } else
    cm->frame_to_show = &cm->yv12_fb[cm->new_fb_idx];
311

John Koleszar's avatar
John Koleszar committed
312
  cm->fb_idx_ref_cnt[cm->new_fb_idx]--;
313

John Koleszar's avatar
John Koleszar committed
314
  return err;
315
316
}

317
int vp9_receive_compressed_data(VP9D_PTR ptr, unsigned long size,
318
                                const unsigned char **psource,
319
                                int64_t time_stamp) {
320
#if HAVE_ARMV7
John Koleszar's avatar
John Koleszar committed
321
  int64_t dx_store_reg[8];
322
#endif
323
324
  VP9D_COMP *pbi = (VP9D_COMP *) ptr;
  VP9_COMMON *cm = &pbi->common;
325
  const unsigned char *source = *psource;
John Koleszar's avatar
John Koleszar committed
326
  int retcode = 0;
John Koleszar's avatar
John Koleszar committed
327

John Koleszar's avatar
John Koleszar committed
328
329
  /*if(pbi->ready_for_new_data == 0)
      return -1;*/
John Koleszar's avatar
John Koleszar committed
330

John Koleszar's avatar
John Koleszar committed
331
332
333
  if (ptr == 0) {
    return -1;
  }
John Koleszar's avatar
John Koleszar committed
334

John Koleszar's avatar
John Koleszar committed
335
  pbi->common.error.error_code = VPX_CODEC_OK;
John Koleszar's avatar
John Koleszar committed
336

John Koleszar's avatar
John Koleszar committed
337
338
  pbi->Source = source;
  pbi->source_sz = size;
Paul Wilkins's avatar
Paul Wilkins committed
339

John Koleszar's avatar
John Koleszar committed
340
341
342
343
344
345
346
347
  if (pbi->source_sz == 0) {
    /* This is used to signal that we are missing frames.
     * We do not know if the missing frame(s) was supposed to update
     * any of the reference buffers, but we act conservative and
     * mark only the last buffer as corrupted.
     */
    cm->yv12_fb[cm->lst_fb_idx].corrupted = 1;
  }
348

349
350
#if HAVE_ARMV7
#if CONFIG_RUNTIME_CPU_DETECT
John Koleszar's avatar
John Koleszar committed
351
  if (cm->rtcd.flags & HAS_NEON)
352
#endif
John Koleszar's avatar
John Koleszar committed
353
  {
354
    vp9_push_neon(dx_store_reg);
John Koleszar's avatar
John Koleszar committed
355
  }
356
357
#endif

John Koleszar's avatar
John Koleszar committed
358
  cm->new_fb_idx = get_free_fb(cm);
359

John Koleszar's avatar
John Koleszar committed
360
  if (setjmp(pbi->common.error.jmp)) {
361
362
#if HAVE_ARMV7
#if CONFIG_RUNTIME_CPU_DETECT
John Koleszar's avatar
John Koleszar committed
363
    if (cm->rtcd.flags & HAS_NEON)
364
#endif
John Koleszar's avatar
John Koleszar committed
365
    {
366
      vp9_pop_neon(dx_store_reg);
John Koleszar's avatar
John Koleszar committed
367
    }
368
#endif
John Koleszar's avatar
John Koleszar committed
369
    pbi->common.error.setjmp = 0;
John Koleszar's avatar
John Koleszar committed
370

John Koleszar's avatar
John Koleszar committed
371
372
373
374
375
    /* We do not know if the missing frame(s) was supposed to update
     * any of the reference buffers, but we act conservative and
     * mark only the last buffer as corrupted.
     */
    cm->yv12_fb[cm->lst_fb_idx].corrupted = 1;
John Koleszar's avatar
John Koleszar committed
376

John Koleszar's avatar
John Koleszar committed
377
378
379
380
    if (cm->fb_idx_ref_cnt[cm->new_fb_idx] > 0)
      cm->fb_idx_ref_cnt[cm->new_fb_idx]--;
    return -1;
  }
John Koleszar's avatar
John Koleszar committed
381

John Koleszar's avatar
John Koleszar committed
382
  pbi->common.error.setjmp = 1;
Paul Wilkins's avatar
Paul Wilkins committed
383

384
  retcode = vp9_decode_frame(pbi, psource);
John Koleszar's avatar
John Koleszar committed
385

John Koleszar's avatar
John Koleszar committed
386
  if (retcode < 0) {
John Koleszar's avatar
John Koleszar committed
387
#if HAVE_ARMV7
388
#if CONFIG_RUNTIME_CPU_DETECT
John Koleszar's avatar
John Koleszar committed
389
    if (cm->rtcd.flags & HAS_NEON)
John Koleszar's avatar
John Koleszar committed
390
#endif
John Koleszar's avatar
John Koleszar committed
391
    {
392
      vp9_pop_neon(dx_store_reg);
John Koleszar's avatar
John Koleszar committed
393
    }
John Koleszar's avatar
John Koleszar committed
394
395
396
397
398
399
400
#endif
    pbi->common.error.error_code = VPX_CODEC_ERROR;
    pbi->common.error.setjmp = 0;
    if (cm->fb_idx_ref_cnt[cm->new_fb_idx] > 0)
      cm->fb_idx_ref_cnt[cm->new_fb_idx]--;
    return retcode;
  }
John Koleszar's avatar
John Koleszar committed
401

John Koleszar's avatar
John Koleszar committed
402
403
  {
    if (swap_frame_buffers(cm)) {
404
405
#if HAVE_ARMV7
#if CONFIG_RUNTIME_CPU_DETECT
John Koleszar's avatar
John Koleszar committed
406
      if (cm->rtcd.flags & HAS_NEON)
407
#endif
John Koleszar's avatar
John Koleszar committed
408
      {
409
        vp9_pop_neon(dx_store_reg);
John Koleszar's avatar
John Koleszar committed
410
      }
411
#endif
John Koleszar's avatar
John Koleszar committed
412
413
414
415
      pbi->common.error.error_code = VPX_CODEC_ERROR;
      pbi->common.error.setjmp = 0;
      return -1;
    }
John Koleszar's avatar
John Koleszar committed
416

417
#if WRITE_RECON_BUFFER == 2
John Koleszar's avatar
John Koleszar committed
418
419
420
421
422
423
    if (cm->show_frame)
      write_dx_frame_to_file(cm->frame_to_show,
                             cm->current_video_frame);
    else
      write_dx_frame_to_file(cm->frame_to_show,
                             cm->current_video_frame + 1000);
424
425
#endif

John Koleszar's avatar
John Koleszar committed
426
427
    if (cm->filter_level) {
      /* Apply the loop filter if appropriate. */
428
      vp9_loop_filter_frame(cm, &pbi->mb);
John Koleszar's avatar
John Koleszar committed
429
    }
John Koleszar's avatar
John Koleszar committed
430
    vp8_yv12_extend_frame_borders(cm->frame_to_show);
John Koleszar's avatar
John Koleszar committed
431
  }
John Koleszar's avatar
John Koleszar committed
432

433
#if WRITE_RECON_BUFFER == 1
John Koleszar's avatar
John Koleszar committed
434
  if (cm->show_frame)
435
    recon_write_yuv_frame("recon.yuv", cm->frame_to_show);
436
#endif
437

438
  vp9_clear_system_state();
John Koleszar's avatar
John Koleszar committed
439

John Koleszar's avatar
John Koleszar committed
440
441
442
443
444
445
446
  if (cm->show_frame) {
    vpx_memcpy(cm->prev_mip, cm->mip,
               (cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO));
  } else {
    vpx_memset(cm->prev_mip, 0,
               (cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO));
  }
447

448
  /*vp9_print_modes_and_motion_vectors(cm->mi, cm->mb_rows,cm->mb_cols,
449
                                       cm->current_video_frame);*/
John Koleszar's avatar
John Koleszar committed
450

John Koleszar's avatar
John Koleszar committed
451
452
  if (cm->show_frame)
    cm->current_video_frame++;
John Koleszar's avatar
John Koleszar committed
453

John Koleszar's avatar
John Koleszar committed
454
455
456
  pbi->ready_for_new_data = 0;
  pbi->last_time_stamp = time_stamp;
  pbi->source_sz = 0;
John Koleszar's avatar
John Koleszar committed
457
458

#if HAVE_ARMV7
459
#if CONFIG_RUNTIME_CPU_DETECT
John Koleszar's avatar
John Koleszar committed
460
  if (cm->rtcd.flags & HAS_NEON)
461
#endif
John Koleszar's avatar
John Koleszar committed
462
  {
463
    vp9_pop_neon(dx_store_reg);
John Koleszar's avatar
John Koleszar committed
464
  }
John Koleszar's avatar
John Koleszar committed
465
#endif
John Koleszar's avatar
John Koleszar committed
466
467
  pbi->common.error.setjmp = 0;
  return retcode;
John Koleszar's avatar
John Koleszar committed
468
}
469

470
int vp9_get_raw_frame(VP9D_PTR ptr, YV12_BUFFER_CONFIG *sd,
471
                      int64_t *time_stamp, int64_t *time_end_stamp,
472
                      vp9_ppflags_t *flags) {
John Koleszar's avatar
John Koleszar committed
473
  int ret = -1;
474
  VP9D_COMP *pbi = (VP9D_COMP *) ptr;
John Koleszar's avatar
John Koleszar committed
475

John Koleszar's avatar
John Koleszar committed
476
477
  if (pbi->ready_for_new_data == 1)
    return ret;
John Koleszar's avatar
John Koleszar committed
478

John Koleszar's avatar
John Koleszar committed
479
480
481
  /* ie no raw frame to show!!! */
  if (pbi->common.show_frame == 0)
    return ret;
John Koleszar's avatar
John Koleszar committed
482

John Koleszar's avatar
John Koleszar committed
483
484
485
  pbi->ready_for_new_data = 1;
  *time_stamp = pbi->last_time_stamp;
  *time_end_stamp = 0;
John Koleszar's avatar
John Koleszar committed
486

John Koleszar's avatar
John Koleszar committed
487
  sd->clrtype = pbi->common.clr_type;
John Koleszar's avatar
John Koleszar committed
488
#if CONFIG_POSTPROC
489
  ret = vp9_post_proc_frame(&pbi->common, sd, flags);
John Koleszar's avatar
John Koleszar committed
490
491
#else

John Koleszar's avatar
John Koleszar committed
492
493
494
495
496
497
498
499
500
  if (pbi->common.frame_to_show) {
    *sd = *pbi->common.frame_to_show;
    sd->y_width = pbi->common.Width;
    sd->y_height = pbi->common.Height;
    sd->uv_height = pbi->common.Height / 2;
    ret = 0;
  } else {
    ret = -1;
  }
John Koleszar's avatar
John Koleszar committed
501

502
#endif /*!CONFIG_POSTPROC*/
503
  vp9_clear_system_state();
John Koleszar's avatar
John Koleszar committed
504
  return ret;
John Koleszar's avatar
John Koleszar committed
505
}