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

Side by Side Diff: source/libvpx/vp8/vp8_dx_iface.c

Issue 12077018: libvpx: Pull from upstream (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 7 years, 11 months 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/vp8/encoder/onyx_if.c ('k') | source/libvpx/vp9/decoder/vp9_decodframe.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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 #if CONFIG_POSTPROC_VISUALIZER 70 #if CONFIG_POSTPROC_VISUALIZER
71 unsigned int dbg_postproc_flag; 71 unsigned int dbg_postproc_flag;
72 int dbg_color_ref_frame_flag; 72 int dbg_color_ref_frame_flag;
73 int dbg_color_mb_modes_flag; 73 int dbg_color_mb_modes_flag;
74 int dbg_color_b_modes_flag; 74 int dbg_color_b_modes_flag;
75 int dbg_display_mv_flag; 75 int dbg_display_mv_flag;
76 #endif 76 #endif
77 vpx_image_t img; 77 vpx_image_t img;
78 int img_setup; 78 int img_setup;
79 void *user_priv; 79 void *user_priv;
80 FRAGMENT_DATA fragments;
80 }; 81 };
81 82
82 static unsigned long vp8_priv_sz(const vpx_codec_dec_cfg_t *si, vpx_codec_flags_ t flags) 83 static unsigned long vp8_priv_sz(const vpx_codec_dec_cfg_t *si, vpx_codec_flags_ t flags)
83 { 84 {
84 /* Although this declaration is constant, we can't use it in the requested 85 /* Although this declaration is constant, we can't use it in the requested
85 * segments list because we want to define the requested segments list 86 * segments list because we want to define the requested segments list
86 * before defining the private type (so that the number of memory maps is 87 * before defining the private type (so that the number of memory maps is
87 * known) 88 * known)
88 */ 89 */
89 (void)si; 90 (void)si;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 mmap.sz = sizeof(vpx_codec_alg_priv_t); 209 mmap.sz = sizeof(vpx_codec_alg_priv_t);
209 mmap.align = vp8_mem_req_segs[0].align; 210 mmap.align = vp8_mem_req_segs[0].align;
210 mmap.flags = vp8_mem_req_segs[0].flags; 211 mmap.flags = vp8_mem_req_segs[0].flags;
211 212
212 res = vp8_mmap_alloc(&mmap); 213 res = vp8_mmap_alloc(&mmap);
213 214
214 if (!res) 215 if (!res)
215 { 216 {
216 vp8_init_ctx(ctx, &mmap); 217 vp8_init_ctx(ctx, &mmap);
217 218
219 /* initialize number of fragments to zero */
220 ctx->priv->alg_priv->fragments.count = 0;
221 /* is input fragments enabled? */
222 ctx->priv->alg_priv->fragments.enabled =
223 (ctx->priv->alg_priv->base.init_flags &
224 VPX_CODEC_USE_INPUT_FRAGMENTS);
225
218 ctx->priv->alg_priv->defer_alloc = 1; 226 ctx->priv->alg_priv->defer_alloc = 1;
219 /*post processing level initialized to do nothing */ 227 /*post processing level initialized to do nothing */
220 } 228 }
221 } 229 }
222 230
223 return res; 231 return res;
224 } 232 }
225 233
226 static vpx_codec_err_t vp8_destroy(vpx_codec_alg_priv_t *ctx) 234 static vpx_codec_err_t vp8_destroy(vpx_codec_alg_priv_t *ctx)
227 { 235 {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 img->stride[VPX_PLANE_U] = yv12->uv_stride; 344 img->stride[VPX_PLANE_U] = yv12->uv_stride;
337 img->stride[VPX_PLANE_V] = yv12->uv_stride; 345 img->stride[VPX_PLANE_V] = yv12->uv_stride;
338 img->stride[VPX_PLANE_ALPHA] = yv12->y_stride; 346 img->stride[VPX_PLANE_ALPHA] = yv12->y_stride;
339 img->bps = 12; 347 img->bps = 12;
340 img->user_priv = user_priv; 348 img->user_priv = user_priv;
341 img->img_data = yv12->buffer_alloc; 349 img->img_data = yv12->buffer_alloc;
342 img->img_data_owner = 0; 350 img->img_data_owner = 0;
343 img->self_allocd = 0; 351 img->self_allocd = 0;
344 } 352 }
345 353
354 static int
355 update_fragments(vpx_codec_alg_priv_t *ctx,
356 const uint8_t *data,
357 unsigned int data_sz,
358 vpx_codec_err_t *res)
359 {
360 *res = VPX_CODEC_OK;
361
362 if (ctx->fragments.count == 0)
363 {
364 /* New frame, reset fragment pointers and sizes */
365 vpx_memset((void*)ctx->fragments.ptrs, 0, sizeof(ctx->fragments.ptrs));
366 vpx_memset(ctx->fragments.sizes, 0, sizeof(ctx->fragments.sizes));
367 }
368 if (ctx->fragments.enabled && !(data == NULL && data_sz == 0))
369 {
370 /* Store a pointer to this fragment and return. We haven't
371 * received the complete frame yet, so we will wait with decoding.
372 */
373 ctx->fragments.ptrs[ctx->fragments.count] = data;
374 ctx->fragments.sizes[ctx->fragments.count] = data_sz;
375 ctx->fragments.count++;
376 if (ctx->fragments.count > (1 << EIGHT_PARTITION) + 1)
377 {
378 ctx->fragments.count = 0;
379 *res = VPX_CODEC_INVALID_PARAM;
380 return -1;
381 }
382 return 0;
383 }
384
385 if (!ctx->fragments.enabled)
386 {
387 ctx->fragments.ptrs[0] = data;
388 ctx->fragments.sizes[0] = data_sz;
389 ctx->fragments.count = 1;
390 }
391
392 return 1;
393 }
394
346 static vpx_codec_err_t vp8_decode(vpx_codec_alg_priv_t *ctx, 395 static vpx_codec_err_t vp8_decode(vpx_codec_alg_priv_t *ctx,
347 const uint8_t *data, 396 const uint8_t *data,
348 unsigned int data_sz, 397 unsigned int data_sz,
349 void *user_priv, 398 void *user_priv,
350 long deadline) 399 long deadline)
351 { 400 {
352 vpx_codec_err_t res = VPX_CODEC_OK; 401 vpx_codec_err_t res = VPX_CODEC_OK;
353 unsigned int resolution_change = 0; 402 unsigned int resolution_change = 0;
354 unsigned int w, h; 403 unsigned int w, h;
355 404
405
406 /* Update the input fragment data */
407 if(update_fragments(ctx, data, data_sz, &res) <= 0)
408 return res;
409
356 /* Determine the stream parameters. Note that we rely on peek_si to 410 /* Determine the stream parameters. Note that we rely on peek_si to
357 * validate that we have a buffer that does not wrap around the top 411 * validate that we have a buffer that does not wrap around the top
358 * of the heap. 412 * of the heap.
359 */ 413 */
360 w = ctx->si.w; 414 w = ctx->si.w;
361 h = ctx->si.h; 415 h = ctx->si.h;
362 416
363 res = ctx->base.iface->dec.peek_si(data, data_sz, &ctx->si); 417 res = ctx->base.iface->dec.peek_si(ctx->fragments.ptrs[0],
418 ctx->fragments.sizes[0], &ctx->si);
364 419
365 if((res == VPX_CODEC_UNSUP_BITSTREAM) && !ctx->si.is_kf) 420 if((res == VPX_CODEC_UNSUP_BITSTREAM) && !ctx->si.is_kf)
366 { 421 {
367 /* the peek function returns an error for non keyframes, however for 422 /* the peek function returns an error for non keyframes, however for
368 * this case, it is not an error */ 423 * this case, it is not an error */
369 res = VPX_CODEC_OK; 424 res = VPX_CODEC_OK;
370 } 425 }
371 426
372 if(!ctx->decoder_init && !ctx->si.is_kf) 427 if(!ctx->decoder_init && !ctx->si.is_kf)
373 res = VPX_CODEC_UNSUP_BITSTREAM; 428 res = VPX_CODEC_UNSUP_BITSTREAM;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 VP8D_CONFIG oxcf; 469 VP8D_CONFIG oxcf;
415 struct VP8D_COMP* optr; 470 struct VP8D_COMP* optr;
416 471
417 oxcf.Width = ctx->si.w; 472 oxcf.Width = ctx->si.w;
418 oxcf.Height = ctx->si.h; 473 oxcf.Height = ctx->si.h;
419 oxcf.Version = 9; 474 oxcf.Version = 9;
420 oxcf.postprocess = 0; 475 oxcf.postprocess = 0;
421 oxcf.max_threads = ctx->cfg.threads; 476 oxcf.max_threads = ctx->cfg.threads;
422 oxcf.error_concealment = 477 oxcf.error_concealment =
423 (ctx->base.init_flags & VPX_CODEC_USE_ERROR_CONCEALMENT); 478 (ctx->base.init_flags & VPX_CODEC_USE_ERROR_CONCEALMENT);
424 oxcf.input_fragments =
425 (ctx->base.init_flags & VPX_CODEC_USE_INPUT_FRAGMENTS);
426 479
427 optr = vp8dx_create_decompressor(&oxcf); 480 optr = vp8dx_create_decompressor(&oxcf);
428 481
429 /* If postprocessing was enabled by the application and a 482 /* If postprocessing was enabled by the application and a
430 * configuration has not been provided, default it. 483 * configuration has not been provided, default it.
431 */ 484 */
432 if (!ctx->postproc_cfg_set 485 if (!ctx->postproc_cfg_set
433 && (ctx->base.init_flags & VPX_CODEC_USE_POSTPROC)) 486 && (ctx->base.init_flags & VPX_CODEC_USE_POSTPROC))
434 { 487 {
435 ctx->postproc_cfg.post_proc_flag = 488 ctx->postproc_cfg.post_proc_flag =
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 (void)prev_mb_rows; 590 (void)prev_mb_rows;
538 #endif 591 #endif
539 } 592 }
540 593
541 pbi->common.error.setjmp = 0; 594 pbi->common.error.setjmp = 0;
542 595
543 /* required to get past the first get_free_fb() call */ 596 /* required to get past the first get_free_fb() call */
544 ctx->pbi->common.fb_idx_ref_cnt[0] = 0; 597 ctx->pbi->common.fb_idx_ref_cnt[0] = 0;
545 } 598 }
546 599
600 /* update the pbi fragment data */
601 ctx->pbi->num_fragments = ctx->fragments.count;
602 ctx->pbi->input_fragments = ctx->fragments.enabled;
603 vpx_memcpy(ctx->pbi->fragments, ctx->fragments.ptrs,
604 sizeof(ctx->fragments.ptrs));
605 vpx_memcpy(ctx->pbi->fragment_sizes, ctx->fragments.sizes,
606 sizeof(ctx->fragments.sizes));
607
608
547 ctx->user_priv = user_priv; 609 ctx->user_priv = user_priv;
548 if (vp8dx_receive_compressed_data(ctx->pbi, data_sz, data, deadline)) 610 if (vp8dx_receive_compressed_data(ctx->pbi, data_sz, data, deadline))
549 { 611 {
550 VP8D_COMP *pbi = (VP8D_COMP *)ctx->pbi; 612 VP8D_COMP *pbi = (VP8D_COMP *)ctx->pbi;
551 res = update_error_state(ctx, &pbi->common.error); 613 res = update_error_state(ctx, &pbi->common.error);
552 } 614 }
615
616 /* get ready for the next series of fragments */
617 ctx->fragments.count = 0;
553 } 618 }
554 619
555 return res; 620 return res;
556 } 621 }
557 622
558 static vpx_image_t *vp8_get_frame(vpx_codec_alg_priv_t *ctx, 623 static vpx_image_t *vp8_get_frame(vpx_codec_alg_priv_t *ctx,
559 vpx_codec_iter_t *iter) 624 vpx_codec_iter_t *iter)
560 { 625 {
561 vpx_image_t *img = NULL; 626 vpx_image_t *img = NULL;
562 627
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 }, 958 },
894 { /* encoder functions */ 959 { /* encoder functions */
895 NOT_IMPLEMENTED, 960 NOT_IMPLEMENTED,
896 NOT_IMPLEMENTED, 961 NOT_IMPLEMENTED,
897 NOT_IMPLEMENTED, 962 NOT_IMPLEMENTED,
898 NOT_IMPLEMENTED, 963 NOT_IMPLEMENTED,
899 NOT_IMPLEMENTED, 964 NOT_IMPLEMENTED,
900 NOT_IMPLEMENTED 965 NOT_IMPLEMENTED
901 } 966 }
902 }; 967 };
OLDNEW
« no previous file with comments | « source/libvpx/vp8/encoder/onyx_if.c ('k') | source/libvpx/vp9/decoder/vp9_decodframe.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698