Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Side by Side Diff: source/libvpx/vp9/decoder/vp9_decoder.c

Issue 756673003: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp9/decoder/vp9_decoder.h ('k') | source/libvpx/vp9/decoder/vp9_detokenize.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 25 matching lines...) Expand all
36 static void initialize_dec() { 36 static void initialize_dec() {
37 static int init_done = 0; 37 static int init_done = 0;
38 38
39 if (!init_done) { 39 if (!init_done) {
40 vp9_rtcd(); 40 vp9_rtcd();
41 vp9_init_intra_predictors(); 41 vp9_init_intra_predictors();
42 init_done = 1; 42 init_done = 1;
43 } 43 }
44 } 44 }
45 45
46 static void vp9_dec_setup_mi(VP9_COMMON *cm) {
47 cm->mi = cm->mip + cm->mi_stride + 1;
48 vpx_memset(cm->mip, 0, cm->mi_stride * (cm->mi_rows + 1) * sizeof(*cm->mip));
49 }
50
51 static int vp9_dec_alloc_mi(VP9_COMMON *cm, int mi_size) {
52 cm->mip = vpx_calloc(mi_size, sizeof(*cm->mip));
53 if (!cm->mip)
54 return 1;
55 cm->mi_alloc_size = mi_size;
56 return 0;
57 }
58
59 static void vp9_dec_free_mi(VP9_COMMON *cm) {
60 vpx_free(cm->mip);
61 cm->mip = NULL;
62 }
63
46 VP9Decoder *vp9_decoder_create() { 64 VP9Decoder *vp9_decoder_create() {
47 VP9Decoder *const pbi = vpx_memalign(32, sizeof(*pbi)); 65 VP9Decoder *const pbi = vpx_memalign(32, sizeof(*pbi));
48 VP9_COMMON *const cm = pbi ? &pbi->common : NULL; 66 VP9_COMMON *const cm = pbi ? &pbi->common : NULL;
49 67
50 if (!cm) 68 if (!cm)
51 return NULL; 69 return NULL;
52 70
53 vp9_zero(*pbi); 71 vp9_zero(*pbi);
54 72
55 if (setjmp(cm->error.jmp)) { 73 if (setjmp(cm->error.jmp)) {
56 cm->error.setjmp = 0; 74 cm->error.setjmp = 0;
57 vp9_decoder_remove(pbi); 75 vp9_decoder_remove(pbi);
58 return NULL; 76 return NULL;
59 } 77 }
60 78
61 cm->error.setjmp = 1; 79 cm->error.setjmp = 1;
80
81 CHECK_MEM_ERROR(cm, cm->fc,
82 (FRAME_CONTEXT *)vpx_calloc(1, sizeof(*cm->fc)));
83 CHECK_MEM_ERROR(cm, cm->frame_contexts,
84 (FRAME_CONTEXT *)vpx_calloc(FRAME_CONTEXTS,
85 sizeof(*cm->frame_contexts)));
86
62 pbi->need_resync = 1; 87 pbi->need_resync = 1;
63 initialize_dec(); 88 initialize_dec();
64 89
65 // Initialize the references to not point to any frame buffers. 90 // Initialize the references to not point to any frame buffers.
66 vpx_memset(&cm->ref_frame_map, -1, sizeof(cm->ref_frame_map)); 91 vpx_memset(&cm->ref_frame_map, -1, sizeof(cm->ref_frame_map));
67 92
68 cm->current_video_frame = 0; 93 cm->current_video_frame = 0;
69 pbi->ready_for_new_data = 1; 94 pbi->ready_for_new_data = 1;
70 cm->bit_depth = VPX_BITS_8; 95 cm->bit_depth = VPX_BITS_8;
71 cm->dequant_bit_depth = VPX_BITS_8; 96 cm->dequant_bit_depth = VPX_BITS_8;
72 97
98 cm->alloc_mi = vp9_dec_alloc_mi;
99 cm->free_mi = vp9_dec_free_mi;
100 cm->setup_mi = vp9_dec_setup_mi;
101
73 // vp9_init_dequantizer() is first called here. Add check in 102 // vp9_init_dequantizer() is first called here. Add check in
74 // frame_init_dequantizer() to avoid unnecessary calling of 103 // frame_init_dequantizer() to avoid unnecessary calling of
75 // vp9_init_dequantizer() for every frame. 104 // vp9_init_dequantizer() for every frame.
76 vp9_init_dequantizer(cm); 105 vp9_init_dequantizer(cm);
77 106
78 vp9_loop_filter_init(cm); 107 vp9_loop_filter_init(cm);
79 108
80 cm->error.setjmp = 0; 109 cm->error.setjmp = 0;
81 110
82 vp9_get_worker_interface()->init(&pbi->lf_worker); 111 vp9_get_worker_interface()->init(&pbi->lf_worker);
83 112
84 return pbi; 113 return pbi;
85 } 114 }
86 115
87 void vp9_decoder_remove(VP9Decoder *pbi) { 116 void vp9_decoder_remove(VP9Decoder *pbi) {
88 VP9_COMMON *const cm = &pbi->common; 117 VP9_COMMON *const cm = &pbi->common;
89 int i; 118 int i;
90 119
91 vp9_get_worker_interface()->end(&pbi->lf_worker); 120 vp9_get_worker_interface()->end(&pbi->lf_worker);
92 vpx_free(pbi->lf_worker.data1); 121 vpx_free(pbi->lf_worker.data1);
93 vpx_free(pbi->tile_data); 122 vpx_free(pbi->tile_data);
94 for (i = 0; i < pbi->num_tile_workers; ++i) { 123 for (i = 0; i < pbi->num_tile_workers; ++i) {
95 VP9Worker *const worker = &pbi->tile_workers[i]; 124 VP9Worker *const worker = &pbi->tile_workers[i];
96 vp9_get_worker_interface()->end(worker); 125 vp9_get_worker_interface()->end(worker);
97 vpx_free(worker->data1);
98 vpx_free(worker->data2);
99 } 126 }
127 vpx_free(pbi->tile_worker_data);
128 vpx_free(pbi->tile_worker_info);
100 vpx_free(pbi->tile_workers); 129 vpx_free(pbi->tile_workers);
101 130
102 if (pbi->num_tile_workers > 0) { 131 if (pbi->num_tile_workers > 0) {
103 vp9_loop_filter_dealloc(&pbi->lf_row_sync); 132 vp9_loop_filter_dealloc(&pbi->lf_row_sync);
104 } 133 }
105 134
106 vp9_remove_common(cm); 135 vp9_remove_common(cm);
107 vpx_free(pbi); 136 vpx_free(pbi);
108 } 137 }
109 138
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 } 262 }
234 263
235 pbi->ready_for_new_data = 0; 264 pbi->ready_for_new_data = 0;
236 265
237 // Check if the previous frame was a frame without any references to it. 266 // Check if the previous frame was a frame without any references to it.
238 if (cm->new_fb_idx >= 0 && cm->frame_bufs[cm->new_fb_idx].ref_count == 0) 267 if (cm->new_fb_idx >= 0 && cm->frame_bufs[cm->new_fb_idx].ref_count == 0)
239 cm->release_fb_cb(cm->cb_priv, 268 cm->release_fb_cb(cm->cb_priv,
240 &cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer); 269 &cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer);
241 cm->new_fb_idx = get_free_fb(cm); 270 cm->new_fb_idx = get_free_fb(cm);
242 271
272 // Assign a MV array to the frame buffer.
273 cm->cur_frame = &cm->frame_bufs[cm->new_fb_idx];
274
243 if (setjmp(cm->error.jmp)) { 275 if (setjmp(cm->error.jmp)) {
244 pbi->need_resync = 1; 276 pbi->need_resync = 1;
245 cm->error.setjmp = 0; 277 cm->error.setjmp = 0;
246 vp9_clear_system_state(); 278 vp9_clear_system_state();
247 279
248 // We do not know if the missing frame(s) was supposed to update 280 // We do not know if the missing frame(s) was supposed to update
249 // any of the reference buffers, but we act conservative and 281 // any of the reference buffers, but we act conservative and
250 // mark only the last buffer as corrupted. 282 // mark only the last buffer as corrupted.
251 // 283 //
252 // TODO(jkoleszar): Error concealment is undefined and non-normative 284 // TODO(jkoleszar): Error concealment is undefined and non-normative
(...skipping 12 matching lines...) Expand all
265 297
266 vp9_decode_frame(pbi, source, source + size, psource); 298 vp9_decode_frame(pbi, source, source + size, psource);
267 299
268 swap_frame_buffers(pbi); 300 swap_frame_buffers(pbi);
269 301
270 vp9_clear_system_state(); 302 vp9_clear_system_state();
271 303
272 cm->last_width = cm->width; 304 cm->last_width = cm->width;
273 cm->last_height = cm->height; 305 cm->last_height = cm->height;
274 306
275 if (!cm->show_existing_frame) 307 if (!cm->show_existing_frame) {
276 cm->last_show_frame = cm->show_frame; 308 cm->last_show_frame = cm->show_frame;
277 if (cm->show_frame) { 309 cm->prev_frame = cm->cur_frame;
278 if (!cm->show_existing_frame) 310 }
279 vp9_swap_mi_and_prev_mi(cm);
280 311
312 if (cm->show_frame)
281 cm->current_video_frame++; 313 cm->current_video_frame++;
282 }
283 314
284 cm->error.setjmp = 0; 315 cm->error.setjmp = 0;
285 return retcode; 316 return retcode;
286 } 317 }
287 318
288 int vp9_get_raw_frame(VP9Decoder *pbi, YV12_BUFFER_CONFIG *sd, 319 int vp9_get_raw_frame(VP9Decoder *pbi, YV12_BUFFER_CONFIG *sd,
289 vp9_ppflags_t *flags) { 320 vp9_ppflags_t *flags) {
290 VP9_COMMON *const cm = &pbi->common; 321 VP9_COMMON *const cm = &pbi->common;
291 int ret = -1; 322 int ret = -1;
292 #if !CONFIG_VP9_POSTPROC 323 #if !CONFIG_VP9_POSTPROC
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 404
374 for (j = 0; j < mag; ++j) 405 for (j = 0; j < mag; ++j)
375 this_sz |= (*x++) << (j * 8); 406 this_sz |= (*x++) << (j * 8);
376 sizes[i] = this_sz; 407 sizes[i] = this_sz;
377 } 408 }
378 *count = frames; 409 *count = frames;
379 } 410 }
380 } 411 }
381 return VPX_CODEC_OK; 412 return VPX_CODEC_OK;
382 } 413 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/decoder/vp9_decoder.h ('k') | source/libvpx/vp9/decoder/vp9_detokenize.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698