| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 unsigned int dbg_postproc_flag; | 52 unsigned int dbg_postproc_flag; |
| 53 int dbg_color_ref_frame_flag; | 53 int dbg_color_ref_frame_flag; |
| 54 int dbg_color_mb_modes_flag; | 54 int dbg_color_mb_modes_flag; |
| 55 int dbg_color_b_modes_flag; | 55 int dbg_color_b_modes_flag; |
| 56 int dbg_display_mv_flag; | 56 int dbg_display_mv_flag; |
| 57 #endif | 57 #endif |
| 58 vpx_image_t img; | 58 vpx_image_t img; |
| 59 int img_setup; | 59 int img_setup; |
| 60 int img_avail; | 60 int img_avail; |
| 61 int invert_tile_order; | 61 int invert_tile_order; |
| 62 int fb_lru; |
| 63 |
| 64 /* External buffer info to save for VP9 common. */ |
| 65 vpx_codec_frame_buffer_t *fb_list; // External frame buffers |
| 66 int fb_count; // Total number of frame buffers |
| 67 vpx_realloc_frame_buffer_cb_fn_t realloc_fb_cb; |
| 68 void *user_priv; // Private data associated with the external frame buffers. |
| 62 }; | 69 }; |
| 63 | 70 |
| 64 static unsigned long priv_sz(const vpx_codec_dec_cfg_t *si, | 71 static unsigned long priv_sz(const vpx_codec_dec_cfg_t *si, |
| 65 vpx_codec_flags_t flags) { | 72 vpx_codec_flags_t flags) { |
| 66 /* Although this declaration is constant, we can't use it in the requested | 73 /* Although this declaration is constant, we can't use it in the requested |
| 67 * segments list because we want to define the requested segments list | 74 * segments list because we want to define the requested segments list |
| 68 * before defining the private type (so that the number of memory maps is | 75 * before defining the private type (so that the number of memory maps is |
| 69 * known) | 76 * known) |
| 70 */ | 77 */ |
| 71 (void)si; | 78 (void)si; |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 * configuration has not been provided, default it. | 307 * configuration has not been provided, default it. |
| 301 */ | 308 */ |
| 302 if (!ctx->postproc_cfg_set | 309 if (!ctx->postproc_cfg_set |
| 303 && (ctx->base.init_flags & VPX_CODEC_USE_POSTPROC)) { | 310 && (ctx->base.init_flags & VPX_CODEC_USE_POSTPROC)) { |
| 304 ctx->postproc_cfg.post_proc_flag = | 311 ctx->postproc_cfg.post_proc_flag = |
| 305 VP8_DEBLOCK | VP8_DEMACROBLOCK; | 312 VP8_DEBLOCK | VP8_DEMACROBLOCK; |
| 306 ctx->postproc_cfg.deblocking_level = 4; | 313 ctx->postproc_cfg.deblocking_level = 4; |
| 307 ctx->postproc_cfg.noise_level = 0; | 314 ctx->postproc_cfg.noise_level = 0; |
| 308 } | 315 } |
| 309 | 316 |
| 310 if (!optr) | 317 if (!optr) { |
| 311 res = VPX_CODEC_ERROR; | 318 res = VPX_CODEC_ERROR; |
| 312 else | 319 } else { |
| 320 VP9D_COMP *const pbi = (VP9D_COMP*)optr; |
| 321 VP9_COMMON *const cm = &pbi->common; |
| 322 if (ctx->fb_list != NULL && ctx->realloc_fb_cb != NULL && |
| 323 ctx->fb_count > 0) { |
| 324 cm->fb_list = ctx->fb_list; |
| 325 cm->fb_count = ctx->fb_count; |
| 326 cm->realloc_fb_cb = ctx->realloc_fb_cb; |
| 327 cm->user_priv = ctx->user_priv; |
| 328 } else { |
| 329 cm->fb_count = FRAME_BUFFERS; |
| 330 } |
| 331 cm->fb_lru = ctx->fb_lru; |
| 332 CHECK_MEM_ERROR(cm, cm->yv12_fb, |
| 333 vpx_calloc(cm->fb_count, sizeof(*cm->yv12_fb))); |
| 334 CHECK_MEM_ERROR(cm, cm->fb_idx_ref_cnt, |
| 335 vpx_calloc(cm->fb_count, sizeof(*cm->fb_idx_ref_cnt))); |
| 336 if (cm->fb_lru) { |
| 337 CHECK_MEM_ERROR(cm, cm->fb_idx_ref_lru, |
| 338 vpx_calloc(cm->fb_count, |
| 339 sizeof(*cm->fb_idx_ref_lru))); |
| 340 } |
| 313 ctx->pbi = optr; | 341 ctx->pbi = optr; |
| 342 } |
| 314 } | 343 } |
| 315 | 344 |
| 316 ctx->decoder_init = 1; | 345 ctx->decoder_init = 1; |
| 317 } | 346 } |
| 318 | 347 |
| 319 if (!res && ctx->pbi) { | 348 if (!res && ctx->pbi) { |
| 320 YV12_BUFFER_CONFIG sd; | 349 YV12_BUFFER_CONFIG sd; |
| 321 int64_t time_stamp = 0, time_end_stamp = 0; | 350 int64_t time_stamp = 0, time_end_stamp = 0; |
| 322 vp9_ppflags_t flags = {0}; | 351 vp9_ppflags_t flags = {0}; |
| 323 | 352 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 340 flags.noise_level = ctx->postproc_cfg.noise_level; | 369 flags.noise_level = ctx->postproc_cfg.noise_level; |
| 341 #if CONFIG_POSTPROC_VISUALIZER | 370 #if CONFIG_POSTPROC_VISUALIZER |
| 342 flags.display_ref_frame_flag = ctx->dbg_color_ref_frame_flag; | 371 flags.display_ref_frame_flag = ctx->dbg_color_ref_frame_flag; |
| 343 flags.display_mb_modes_flag = ctx->dbg_color_mb_modes_flag; | 372 flags.display_mb_modes_flag = ctx->dbg_color_mb_modes_flag; |
| 344 flags.display_b_modes_flag = ctx->dbg_color_b_modes_flag; | 373 flags.display_b_modes_flag = ctx->dbg_color_b_modes_flag; |
| 345 flags.display_mv_flag = ctx->dbg_display_mv_flag; | 374 flags.display_mv_flag = ctx->dbg_display_mv_flag; |
| 346 #endif | 375 #endif |
| 347 } | 376 } |
| 348 | 377 |
| 349 if (vp9_receive_compressed_data(ctx->pbi, data_sz, data, deadline)) { | 378 if (vp9_receive_compressed_data(ctx->pbi, data_sz, data, deadline)) { |
| 350 VP9D_COMP *pbi = (VP9D_COMP *)ctx->pbi; | 379 VP9D_COMP *pbi = (VP9D_COMP*)ctx->pbi; |
| 351 res = update_error_state(ctx, &pbi->common.error); | 380 res = update_error_state(ctx, &pbi->common.error); |
| 352 } | 381 } |
| 353 | 382 |
| 354 if (!res && 0 == vp9_get_raw_frame(ctx->pbi, &sd, &time_stamp, | 383 if (!res && 0 == vp9_get_raw_frame(ctx->pbi, &sd, &time_stamp, |
| 355 &time_end_stamp, &flags)) { | 384 &time_end_stamp, &flags)) { |
| 356 yuvconfig2image(&ctx->img, &sd, user_priv); | 385 yuvconfig2image(&ctx->img, &sd, user_priv); |
| 357 ctx->img_avail = 1; | 386 ctx->img_avail = 1; |
| 358 } | 387 } |
| 359 } | 388 } |
| 360 | 389 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 if (!(*iter)) { | 497 if (!(*iter)) { |
| 469 img = &ctx->img; | 498 img = &ctx->img; |
| 470 *iter = img; | 499 *iter = img; |
| 471 } | 500 } |
| 472 } | 501 } |
| 473 ctx->img_avail = 0; | 502 ctx->img_avail = 0; |
| 474 | 503 |
| 475 return img; | 504 return img; |
| 476 } | 505 } |
| 477 | 506 |
| 507 static vpx_codec_err_t vp9_set_frame_buffers( |
| 508 vpx_codec_alg_priv_t *ctx, |
| 509 vpx_codec_frame_buffer_t *fb_list, int fb_count, |
| 510 vpx_realloc_frame_buffer_cb_fn_t cb, void *user_priv) { |
| 511 if (fb_count < REF_FRAMES) { |
| 512 /* The application must pass in at least REF_FRAMES frame buffers. */ |
| 513 return VPX_CODEC_INVALID_PARAM; |
| 514 } else if (!ctx->pbi) { |
| 515 /* If the decoder has already been initialized, do not accept external |
| 516 * frame buffers. |
| 517 */ |
| 518 ctx->fb_list = fb_list; |
| 519 ctx->fb_count = fb_count; |
| 520 ctx->realloc_fb_cb = cb; |
| 521 ctx->user_priv = user_priv; |
| 522 return VPX_CODEC_OK; |
| 523 } |
| 524 |
| 525 return VPX_CODEC_ERROR; |
| 526 } |
| 527 |
| 478 static vpx_codec_err_t vp9_xma_get_mmap(const vpx_codec_ctx_t *ctx, | 528 static vpx_codec_err_t vp9_xma_get_mmap(const vpx_codec_ctx_t *ctx, |
| 479 vpx_codec_mmap_t *mmap, | 529 vpx_codec_mmap_t *mmap, |
| 480 vpx_codec_iter_t *iter) { | 530 vpx_codec_iter_t *iter) { |
| 481 vpx_codec_err_t res; | 531 vpx_codec_err_t res; |
| 482 const mem_req_t *seg_iter = *iter; | 532 const mem_req_t *seg_iter = *iter; |
| 483 | 533 |
| 484 /* Get address of next segment request */ | 534 /* Get address of next segment request */ |
| 485 do { | 535 do { |
| 486 if (!seg_iter) | 536 if (!seg_iter) |
| 487 seg_iter = vp9_mem_req_segs; | 537 seg_iter = vp9_mem_req_segs; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 return VPX_CODEC_OK; | 682 return VPX_CODEC_OK; |
| 633 #else | 683 #else |
| 634 return VPX_CODEC_INCAPABLE; | 684 return VPX_CODEC_INCAPABLE; |
| 635 #endif | 685 #endif |
| 636 } | 686 } |
| 637 | 687 |
| 638 static vpx_codec_err_t get_last_ref_updates(vpx_codec_alg_priv_t *ctx, | 688 static vpx_codec_err_t get_last_ref_updates(vpx_codec_alg_priv_t *ctx, |
| 639 int ctrl_id, | 689 int ctrl_id, |
| 640 va_list args) { | 690 va_list args) { |
| 641 int *update_info = va_arg(args, int *); | 691 int *update_info = va_arg(args, int *); |
| 642 VP9D_COMP *pbi = (VP9D_COMP *)ctx->pbi; | 692 VP9D_COMP *pbi = (VP9D_COMP*)ctx->pbi; |
| 643 | 693 |
| 644 if (update_info) { | 694 if (update_info) { |
| 645 *update_info = pbi->refresh_frame_flags; | 695 *update_info = pbi->refresh_frame_flags; |
| 646 | 696 |
| 647 return VPX_CODEC_OK; | 697 return VPX_CODEC_OK; |
| 648 } else { | 698 } else { |
| 649 return VPX_CODEC_INVALID_PARAM; | 699 return VPX_CODEC_INVALID_PARAM; |
| 650 } | 700 } |
| 651 } | 701 } |
| 652 | 702 |
| 653 | 703 |
| 654 static vpx_codec_err_t get_frame_corrupted(vpx_codec_alg_priv_t *ctx, | 704 static vpx_codec_err_t get_frame_corrupted(vpx_codec_alg_priv_t *ctx, |
| 655 int ctrl_id, | 705 int ctrl_id, |
| 656 va_list args) { | 706 va_list args) { |
| 657 int *corrupted = va_arg(args, int *); | 707 int *corrupted = va_arg(args, int *); |
| 658 | 708 |
| 659 if (corrupted) { | 709 if (corrupted) { |
| 660 VP9D_COMP *pbi = (VP9D_COMP *)ctx->pbi; | 710 VP9D_COMP *pbi = (VP9D_COMP*)ctx->pbi; |
| 661 if (pbi) | 711 if (pbi) |
| 662 *corrupted = pbi->common.frame_to_show->corrupted; | 712 *corrupted = pbi->common.frame_to_show->corrupted; |
| 663 else | 713 else |
| 664 return VPX_CODEC_ERROR; | 714 return VPX_CODEC_ERROR; |
| 665 return VPX_CODEC_OK; | 715 return VPX_CODEC_OK; |
| 666 } else { | 716 } else { |
| 667 return VPX_CODEC_INVALID_PARAM; | 717 return VPX_CODEC_INVALID_PARAM; |
| 668 } | 718 } |
| 669 } | 719 } |
| 670 | 720 |
| 721 static vpx_codec_err_t get_display_size(vpx_codec_alg_priv_t *ctx, |
| 722 int ctrl_id, |
| 723 va_list args) { |
| 724 int *const display_size = va_arg(args, int *); |
| 725 |
| 726 if (display_size) { |
| 727 const VP9D_COMP *const pbi = (VP9D_COMP*)ctx->pbi; |
| 728 if (pbi) { |
| 729 display_size[0] = pbi->common.display_width; |
| 730 display_size[1] = pbi->common.display_height; |
| 731 } else { |
| 732 return VPX_CODEC_ERROR; |
| 733 } |
| 734 return VPX_CODEC_OK; |
| 735 } else { |
| 736 return VPX_CODEC_INVALID_PARAM; |
| 737 } |
| 738 } |
| 739 |
| 671 static vpx_codec_err_t set_invert_tile_order(vpx_codec_alg_priv_t *ctx, | 740 static vpx_codec_err_t set_invert_tile_order(vpx_codec_alg_priv_t *ctx, |
| 672 int ctr_id, | 741 int ctr_id, |
| 673 va_list args) { | 742 va_list args) { |
| 674 ctx->invert_tile_order = va_arg(args, int); | 743 ctx->invert_tile_order = va_arg(args, int); |
| 675 return VPX_CODEC_OK; | 744 return VPX_CODEC_OK; |
| 676 } | 745 } |
| 677 | 746 |
| 747 static vpx_codec_err_t set_frame_buffer_lru_cache(vpx_codec_alg_priv_t *ctx, |
| 748 int ctr_id, |
| 749 va_list args) { |
| 750 VP9D_COMP *const pbi = (VP9D_COMP*)ctx->pbi; |
| 751 |
| 752 // Save for later to pass into vp9 common. |
| 753 ctx->fb_lru = va_arg(args, int); |
| 754 |
| 755 if (pbi) { |
| 756 VP9_COMMON *const cm = &pbi->common; |
| 757 cm->fb_lru = ctx->fb_lru; |
| 758 } |
| 759 return VPX_CODEC_OK; |
| 760 } |
| 761 |
| 678 static vpx_codec_ctrl_fn_map_t ctf_maps[] = { | 762 static vpx_codec_ctrl_fn_map_t ctf_maps[] = { |
| 679 {VP8_SET_REFERENCE, set_reference}, | 763 {VP8_SET_REFERENCE, set_reference}, |
| 680 {VP8_COPY_REFERENCE, copy_reference}, | 764 {VP8_COPY_REFERENCE, copy_reference}, |
| 681 {VP8_SET_POSTPROC, set_postproc}, | 765 {VP8_SET_POSTPROC, set_postproc}, |
| 682 {VP8_SET_DBG_COLOR_REF_FRAME, set_dbg_options}, | 766 {VP8_SET_DBG_COLOR_REF_FRAME, set_dbg_options}, |
| 683 {VP8_SET_DBG_COLOR_MB_MODES, set_dbg_options}, | 767 {VP8_SET_DBG_COLOR_MB_MODES, set_dbg_options}, |
| 684 {VP8_SET_DBG_COLOR_B_MODES, set_dbg_options}, | 768 {VP8_SET_DBG_COLOR_B_MODES, set_dbg_options}, |
| 685 {VP8_SET_DBG_DISPLAY_MV, set_dbg_options}, | 769 {VP8_SET_DBG_DISPLAY_MV, set_dbg_options}, |
| 686 {VP8D_GET_LAST_REF_UPDATES, get_last_ref_updates}, | 770 {VP8D_GET_LAST_REF_UPDATES, get_last_ref_updates}, |
| 687 {VP8D_GET_FRAME_CORRUPTED, get_frame_corrupted}, | 771 {VP8D_GET_FRAME_CORRUPTED, get_frame_corrupted}, |
| 688 {VP9_GET_REFERENCE, get_reference}, | 772 {VP9_GET_REFERENCE, get_reference}, |
| 773 {VP9D_GET_DISPLAY_SIZE, get_display_size}, |
| 689 {VP9_INVERT_TILE_DECODE_ORDER, set_invert_tile_order}, | 774 {VP9_INVERT_TILE_DECODE_ORDER, set_invert_tile_order}, |
| 775 {VP9D_SET_FRAME_BUFFER_LRU_CACHE, set_frame_buffer_lru_cache}, |
| 690 { -1, NULL}, | 776 { -1, NULL}, |
| 691 }; | 777 }; |
| 692 | 778 |
| 693 | 779 |
| 694 #ifndef VERSION_STRING | 780 #ifndef VERSION_STRING |
| 695 #define VERSION_STRING | 781 #define VERSION_STRING |
| 696 #endif | 782 #endif |
| 697 CODEC_INTERFACE(vpx_codec_vp9_dx) = { | 783 CODEC_INTERFACE(vpx_codec_vp9_dx) = { |
| 698 "WebM Project VP9 Decoder" VERSION_STRING, | 784 "WebM Project VP9 Decoder" VERSION_STRING, |
| 699 VPX_CODEC_INTERNAL_ABI_VERSION, | 785 VPX_CODEC_INTERNAL_ABI_VERSION, |
| 700 VPX_CODEC_CAP_DECODER | VP9_CAP_POSTPROC, | 786 VPX_CODEC_CAP_DECODER | VP9_CAP_POSTPROC | |
| 787 VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER, |
| 701 /* vpx_codec_caps_t caps; */ | 788 /* vpx_codec_caps_t caps; */ |
| 702 vp9_init, /* vpx_codec_init_fn_t init; */ | 789 vp9_init, /* vpx_codec_init_fn_t init; */ |
| 703 vp9_destroy, /* vpx_codec_destroy_fn_t destroy; */ | 790 vp9_destroy, /* vpx_codec_destroy_fn_t destroy; */ |
| 704 ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */ | 791 ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */ |
| 705 vp9_xma_get_mmap, /* vpx_codec_get_mmap_fn_t get_mmap; */ | 792 vp9_xma_get_mmap, /* vpx_codec_get_mmap_fn_t get_mmap; */ |
| 706 vp9_xma_set_mmap, /* vpx_codec_set_mmap_fn_t set_mmap; */ | 793 vp9_xma_set_mmap, /* vpx_codec_set_mmap_fn_t set_mmap; */ |
| 707 { // NOLINT | 794 { // NOLINT |
| 708 vp9_peek_si, /* vpx_codec_peek_si_fn_t peek_si; */ | 795 vp9_peek_si, /* vpx_codec_peek_si_fn_t peek_si; */ |
| 709 vp9_get_si, /* vpx_codec_get_si_fn_t get_si; */ | 796 vp9_get_si, /* vpx_codec_get_si_fn_t get_si; */ |
| 710 vp9_decode, /* vpx_codec_decode_fn_t decode; */ | 797 vp9_decode, /* vpx_codec_decode_fn_t decode; */ |
| 711 vp9_get_frame, /* vpx_codec_frame_get_fn_t frame_get; */ | 798 vp9_get_frame, /* vpx_codec_frame_get_fn_t frame_get; */ |
| 799 vp9_set_frame_buffers, /* vpx_codec_set_frame_buffers_fn_t set_fb; */ |
| 712 }, | 800 }, |
| 713 { // NOLINT | 801 { // NOLINT |
| 714 /* encoder functions */ | 802 /* encoder functions */ |
| 715 NOT_IMPLEMENTED, | 803 NOT_IMPLEMENTED, |
| 716 NOT_IMPLEMENTED, | 804 NOT_IMPLEMENTED, |
| 717 NOT_IMPLEMENTED, | 805 NOT_IMPLEMENTED, |
| 718 NOT_IMPLEMENTED, | 806 NOT_IMPLEMENTED, |
| 719 NOT_IMPLEMENTED, | 807 NOT_IMPLEMENTED, |
| 720 NOT_IMPLEMENTED | 808 NOT_IMPLEMENTED |
| 721 } | 809 } |
| 722 }; | 810 }; |
| OLD | NEW |