OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 vp9_rtcd(); | 43 vp9_rtcd(); |
44 vpx_dsp_rtcd(); | 44 vpx_dsp_rtcd(); |
45 vpx_scale_rtcd(); | 45 vpx_scale_rtcd(); |
46 vp9_init_intra_predictors(); | 46 vp9_init_intra_predictors(); |
47 init_done = 1; | 47 init_done = 1; |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 static void vp9_dec_setup_mi(VP9_COMMON *cm) { | 51 static void vp9_dec_setup_mi(VP9_COMMON *cm) { |
52 cm->mi = cm->mip + cm->mi_stride + 1; | 52 cm->mi = cm->mip + cm->mi_stride + 1; |
53 memset(cm->mip, 0, cm->mi_stride * (cm->mi_rows + 1) * sizeof(*cm->mip)); | |
54 cm->mi_grid_visible = cm->mi_grid_base + cm->mi_stride + 1; | 53 cm->mi_grid_visible = cm->mi_grid_base + cm->mi_stride + 1; |
55 memset(cm->mi_grid_base, 0, | 54 memset(cm->mi_grid_base, 0, |
56 cm->mi_stride * (cm->mi_rows + 1) * sizeof(*cm->mi_grid_base)); | 55 cm->mi_stride * (cm->mi_rows + 1) * sizeof(*cm->mi_grid_base)); |
57 } | 56 } |
58 | 57 |
59 static int vp9_dec_alloc_mi(VP9_COMMON *cm, int mi_size) { | 58 static int vp9_dec_alloc_mi(VP9_COMMON *cm, int mi_size) { |
60 cm->mip = vpx_calloc(mi_size, sizeof(*cm->mip)); | 59 cm->mip = vpx_calloc(mi_size, sizeof(*cm->mip)); |
61 if (!cm->mip) | 60 if (!cm->mip) |
62 return 1; | 61 return 1; |
63 cm->mi_alloc_size = mi_size; | 62 cm->mi_alloc_size = mi_size; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 } | 204 } |
206 | 205 |
207 if (!equal_dimensions(ref_buf->buf, sd)) { | 206 if (!equal_dimensions(ref_buf->buf, sd)) { |
208 vpx_internal_error(&cm->error, VPX_CODEC_ERROR, | 207 vpx_internal_error(&cm->error, VPX_CODEC_ERROR, |
209 "Incorrect buffer dimensions"); | 208 "Incorrect buffer dimensions"); |
210 } else { | 209 } else { |
211 int *ref_fb_ptr = &ref_buf->idx; | 210 int *ref_fb_ptr = &ref_buf->idx; |
212 | 211 |
213 // Find an empty frame buffer. | 212 // Find an empty frame buffer. |
214 const int free_fb = get_free_fb(cm); | 213 const int free_fb = get_free_fb(cm); |
| 214 if (cm->new_fb_idx == INVALID_IDX) |
| 215 return VPX_CODEC_MEM_ERROR; |
| 216 |
215 // Decrease ref_count since it will be increased again in | 217 // Decrease ref_count since it will be increased again in |
216 // ref_cnt_fb() below. | 218 // ref_cnt_fb() below. |
217 --frame_bufs[free_fb].ref_count; | 219 --frame_bufs[free_fb].ref_count; |
218 | 220 |
219 // Manage the reference counters and copy image. | 221 // Manage the reference counters and copy image. |
220 ref_cnt_fb(frame_bufs, ref_fb_ptr, free_fb); | 222 ref_cnt_fb(frame_bufs, ref_fb_ptr, free_fb); |
221 ref_buf->buf = &frame_bufs[*ref_fb_ptr].buf; | 223 ref_buf->buf = &frame_bufs[*ref_fb_ptr].buf; |
222 vp8_yv12_copy_frame(sd, ref_buf->buf); | 224 vp8_yv12_copy_frame(sd, ref_buf->buf); |
223 } | 225 } |
224 | 226 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 } | 294 } |
293 | 295 |
294 pbi->ready_for_new_data = 0; | 296 pbi->ready_for_new_data = 0; |
295 | 297 |
296 // Check if the previous frame was a frame without any references to it. | 298 // Check if the previous frame was a frame without any references to it. |
297 // Release frame buffer if not decoding in frame parallel mode. | 299 // Release frame buffer if not decoding in frame parallel mode. |
298 if (!pbi->frame_parallel_decode && cm->new_fb_idx >= 0 | 300 if (!pbi->frame_parallel_decode && cm->new_fb_idx >= 0 |
299 && frame_bufs[cm->new_fb_idx].ref_count == 0) | 301 && frame_bufs[cm->new_fb_idx].ref_count == 0) |
300 pool->release_fb_cb(pool->cb_priv, | 302 pool->release_fb_cb(pool->cb_priv, |
301 &frame_bufs[cm->new_fb_idx].raw_frame_buffer); | 303 &frame_bufs[cm->new_fb_idx].raw_frame_buffer); |
| 304 // Find a free frame buffer. Return error if can not find any. |
302 cm->new_fb_idx = get_free_fb(cm); | 305 cm->new_fb_idx = get_free_fb(cm); |
| 306 if (cm->new_fb_idx == INVALID_IDX) |
| 307 return VPX_CODEC_MEM_ERROR; |
303 | 308 |
304 // Assign a MV array to the frame buffer. | 309 // Assign a MV array to the frame buffer. |
305 cm->cur_frame = &pool->frame_bufs[cm->new_fb_idx]; | 310 cm->cur_frame = &pool->frame_bufs[cm->new_fb_idx]; |
306 | 311 |
307 pbi->hold_ref_buf = 0; | 312 pbi->hold_ref_buf = 0; |
308 if (pbi->frame_parallel_decode) { | 313 if (pbi->frame_parallel_decode) { |
309 VP9Worker *const worker = pbi->frame_worker_owner; | 314 VP9Worker *const worker = pbi->frame_worker_owner; |
310 vp9_frameworker_lock_stats(worker); | 315 vp9_frameworker_lock_stats(worker); |
311 frame_bufs[cm->new_fb_idx].frame_worker_owner = worker; | 316 frame_bufs[cm->new_fb_idx].frame_worker_owner = worker; |
312 // Reset decoding progress. | 317 // Reset decoding progress. |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 | 500 |
496 for (j = 0; j < mag; ++j) | 501 for (j = 0; j < mag; ++j) |
497 this_sz |= (*x++) << (j * 8); | 502 this_sz |= (*x++) << (j * 8); |
498 sizes[i] = this_sz; | 503 sizes[i] = this_sz; |
499 } | 504 } |
500 *count = frames; | 505 *count = frames; |
501 } | 506 } |
502 } | 507 } |
503 return VPX_CODEC_OK; | 508 return VPX_CODEC_OK; |
504 } | 509 } |
OLD | NEW |