| 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 11 matching lines...) Expand all Loading... |
| 22 #include "vp8/common/extend.h" | 22 #include "vp8/common/extend.h" |
| 23 #include "vpx_ports/vpx_timer.h" | 23 #include "vpx_ports/vpx_timer.h" |
| 24 #include "detokenize.h" | 24 #include "detokenize.h" |
| 25 #include "vp8/common/reconintra4x4.h" | 25 #include "vp8/common/reconintra4x4.h" |
| 26 #include "vp8/common/reconinter.h" | 26 #include "vp8/common/reconinter.h" |
| 27 #include "vp8/common/setupintrarecon.h" | 27 #include "vp8/common/setupintrarecon.h" |
| 28 #if CONFIG_ERROR_CONCEALMENT | 28 #if CONFIG_ERROR_CONCEALMENT |
| 29 #include "error_concealment.h" | 29 #include "error_concealment.h" |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 #define CALLOC_ARRAY(p, n) CHECK_MEM_ERROR((p), vpx_calloc(sizeof(*(p)), (n))) |
| 33 #define CALLOC_ARRAY_ALIGNED(p, n, algn) do { \ |
| 34 CHECK_MEM_ERROR((p), vpx_memalign((algn), sizeof(*(p)) * (n))); \ |
| 35 memset((p), 0, (n) * sizeof(*(p))); \ |
| 36 } while (0) |
| 37 |
| 38 |
| 32 extern void vp8_mb_init_dequantizer(VP8D_COMP *pbi, MACROBLOCKD *xd); | 39 extern void vp8_mb_init_dequantizer(VP8D_COMP *pbi, MACROBLOCKD *xd); |
| 33 | 40 |
| 34 static void setup_decoding_thread_data(VP8D_COMP *pbi, MACROBLOCKD *xd, MB_ROW_D
EC *mbrd, int count) | 41 static void setup_decoding_thread_data(VP8D_COMP *pbi, MACROBLOCKD *xd, MB_ROW_D
EC *mbrd, int count) |
| 35 { | 42 { |
| 36 VP8_COMMON *const pc = & pbi->common; | 43 VP8_COMMON *const pc = & pbi->common; |
| 37 int i; | 44 int i; |
| 38 | 45 |
| 39 for (i = 0; i < count; i++) | 46 for (i = 0; i < count; i++) |
| 40 { | 47 { |
| 41 MACROBLOCKD *mbd = &mbrd[i].mbd; | 48 MACROBLOCKD *mbd = &mbrd[i].mbd; |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 | 668 |
| 662 /* limit decoding threads to the available cores */ | 669 /* limit decoding threads to the available cores */ |
| 663 if (core_count > pbi->common.processor_core_count) | 670 if (core_count > pbi->common.processor_core_count) |
| 664 core_count = pbi->common.processor_core_count; | 671 core_count = pbi->common.processor_core_count; |
| 665 | 672 |
| 666 if (core_count > 1) | 673 if (core_count > 1) |
| 667 { | 674 { |
| 668 pbi->b_multithreaded_rd = 1; | 675 pbi->b_multithreaded_rd = 1; |
| 669 pbi->decoding_thread_count = core_count - 1; | 676 pbi->decoding_thread_count = core_count - 1; |
| 670 | 677 |
| 671 CHECK_MEM_ERROR(pbi->h_decoding_thread, vpx_malloc(sizeof(pthread_t) * p
bi->decoding_thread_count)); | 678 CALLOC_ARRAY(pbi->h_decoding_thread, pbi->decoding_thread_count); |
| 672 CHECK_MEM_ERROR(pbi->h_event_start_decoding, vpx_malloc(sizeof(sem_t) *
pbi->decoding_thread_count)); | 679 CALLOC_ARRAY(pbi->h_event_start_decoding, pbi->decoding_thread_count); |
| 673 CHECK_MEM_ERROR(pbi->mb_row_di, vpx_memalign(32, sizeof(MB_ROW_DEC) * pb
i->decoding_thread_count)); | 680 CALLOC_ARRAY_ALIGNED(pbi->mb_row_di, pbi->decoding_thread_count, 32); |
| 674 vpx_memset(pbi->mb_row_di, 0, sizeof(MB_ROW_DEC) * pbi->decoding_thread_
count); | 681 CALLOC_ARRAY(pbi->de_thread_data, pbi->decoding_thread_count); |
| 675 CHECK_MEM_ERROR(pbi->de_thread_data, vpx_malloc(sizeof(DECODETHREAD_DATA
) * pbi->decoding_thread_count)); | |
| 676 | 682 |
| 677 for (ithread = 0; ithread < pbi->decoding_thread_count; ithread++) | 683 for (ithread = 0; ithread < pbi->decoding_thread_count; ithread++) |
| 678 { | 684 { |
| 679 sem_init(&pbi->h_event_start_decoding[ithread], 0, 0); | 685 sem_init(&pbi->h_event_start_decoding[ithread], 0, 0); |
| 680 | 686 |
| 681 vp8_setup_block_dptrs(&pbi->mb_row_di[ithread].mbd); | 687 vp8_setup_block_dptrs(&pbi->mb_row_di[ithread].mbd); |
| 682 | 688 |
| 683 pbi->de_thread_data[ithread].ithread = ithread; | 689 pbi->de_thread_data[ithread].ithread = ithread; |
| 684 pbi->de_thread_data[ithread].ptr1 = (void *)pbi; | 690 pbi->de_thread_data[ithread].ptr1 = (void *)pbi; |
| 685 pbi->de_thread_data[ithread].ptr2 = (void *) &pbi->mb_row_di[ith
read]; | 691 pbi->de_thread_data[ithread].ptr2 = (void *) &pbi->mb_row_di[ith
read]; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 width += 16 - (width & 0xf); | 795 width += 16 - (width & 0xf); |
| 790 | 796 |
| 791 if (width < 640) pbi->sync_range = 1; | 797 if (width < 640) pbi->sync_range = 1; |
| 792 else if (width <= 1280) pbi->sync_range = 8; | 798 else if (width <= 1280) pbi->sync_range = 8; |
| 793 else if (width <= 2560) pbi->sync_range =16; | 799 else if (width <= 2560) pbi->sync_range =16; |
| 794 else pbi->sync_range = 32; | 800 else pbi->sync_range = 32; |
| 795 | 801 |
| 796 uv_width = width >>1; | 802 uv_width = width >>1; |
| 797 | 803 |
| 798 /* Allocate an int for each mb row. */ | 804 /* Allocate an int for each mb row. */ |
| 799 CHECK_MEM_ERROR(pbi->mt_current_mb_col, vpx_malloc(sizeof(int) * pc->mb_
rows)); | 805 CALLOC_ARRAY(pbi->mt_current_mb_col, pc->mb_rows); |
| 800 | 806 |
| 801 /* Allocate memory for above_row buffers. */ | 807 /* Allocate memory for above_row buffers. */ |
| 802 CHECK_MEM_ERROR(pbi->mt_yabove_row, vpx_malloc(sizeof(unsigned char *) *
pc->mb_rows)); | 808 CALLOC_ARRAY(pbi->mt_yabove_row, pc->mb_rows); |
| 803 for (i=0; i< pc->mb_rows; i++) | 809 for (i = 0; i < pc->mb_rows; i++) |
| 804 CHECK_MEM_ERROR(pbi->mt_yabove_row[i], vpx_memalign(16,sizeof(unsign
ed char) * (width + (VP8BORDERINPIXELS<<1)))); | 810 CHECK_MEM_ERROR(pbi->mt_yabove_row[i], vpx_memalign(16,sizeof(unsign
ed char) * (width + (VP8BORDERINPIXELS<<1)))); |
| 805 | 811 |
| 806 CHECK_MEM_ERROR(pbi->mt_uabove_row, vpx_malloc(sizeof(unsigned char *) *
pc->mb_rows)); | 812 CALLOC_ARRAY(pbi->mt_uabove_row, pc->mb_rows); |
| 807 for (i=0; i< pc->mb_rows; i++) | 813 for (i = 0; i < pc->mb_rows; i++) |
| 808 CHECK_MEM_ERROR(pbi->mt_uabove_row[i], vpx_memalign(16,sizeof(unsign
ed char) * (uv_width + VP8BORDERINPIXELS))); | 814 CHECK_MEM_ERROR(pbi->mt_uabove_row[i], vpx_memalign(16,sizeof(unsign
ed char) * (uv_width + VP8BORDERINPIXELS))); |
| 809 | 815 |
| 810 CHECK_MEM_ERROR(pbi->mt_vabove_row, vpx_malloc(sizeof(unsigned char *) *
pc->mb_rows)); | 816 CALLOC_ARRAY(pbi->mt_vabove_row, pc->mb_rows); |
| 811 for (i=0; i< pc->mb_rows; i++) | 817 for (i = 0; i < pc->mb_rows; i++) |
| 812 CHECK_MEM_ERROR(pbi->mt_vabove_row[i], vpx_memalign(16,sizeof(unsign
ed char) * (uv_width + VP8BORDERINPIXELS))); | 818 CHECK_MEM_ERROR(pbi->mt_vabove_row[i], vpx_memalign(16,sizeof(unsign
ed char) * (uv_width + VP8BORDERINPIXELS))); |
| 813 | 819 |
| 814 /* Allocate memory for left_col buffers. */ | 820 /* Allocate memory for left_col buffers. */ |
| 815 CHECK_MEM_ERROR(pbi->mt_yleft_col, vpx_malloc(sizeof(unsigned char *) *
pc->mb_rows)); | 821 CALLOC_ARRAY(pbi->mt_yleft_col, pc->mb_rows); |
| 816 for (i=0; i< pc->mb_rows; i++) | 822 for (i = 0; i < pc->mb_rows; i++) |
| 817 CHECK_MEM_ERROR(pbi->mt_yleft_col[i], vpx_calloc(sizeof(unsigned cha
r) * 16, 1)); | 823 CHECK_MEM_ERROR(pbi->mt_yleft_col[i], vpx_calloc(sizeof(unsigned cha
r) * 16, 1)); |
| 818 | 824 |
| 819 CHECK_MEM_ERROR(pbi->mt_uleft_col, vpx_malloc(sizeof(unsigned char *) *
pc->mb_rows)); | 825 CALLOC_ARRAY(pbi->mt_uleft_col, pc->mb_rows); |
| 820 for (i=0; i< pc->mb_rows; i++) | 826 for (i = 0; i < pc->mb_rows; i++) |
| 821 CHECK_MEM_ERROR(pbi->mt_uleft_col[i], vpx_calloc(sizeof(unsigned cha
r) * 8, 1)); | 827 CHECK_MEM_ERROR(pbi->mt_uleft_col[i], vpx_calloc(sizeof(unsigned cha
r) * 8, 1)); |
| 822 | 828 |
| 823 CHECK_MEM_ERROR(pbi->mt_vleft_col, vpx_malloc(sizeof(unsigned char *) *
pc->mb_rows)); | 829 CALLOC_ARRAY(pbi->mt_vleft_col, pc->mb_rows); |
| 824 for (i=0; i< pc->mb_rows; i++) | 830 for (i = 0; i < pc->mb_rows; i++) |
| 825 CHECK_MEM_ERROR(pbi->mt_vleft_col[i], vpx_calloc(sizeof(unsigned cha
r) * 8, 1)); | 831 CHECK_MEM_ERROR(pbi->mt_vleft_col[i], vpx_calloc(sizeof(unsigned cha
r) * 8, 1)); |
| 826 } | 832 } |
| 827 } | 833 } |
| 828 | 834 |
| 829 | 835 |
| 830 void vp8_decoder_remove_threads(VP8D_COMP *pbi) | 836 void vp8_decoder_remove_threads(VP8D_COMP *pbi) |
| 831 { | 837 { |
| 832 /* shutdown MB Decoding thread; */ | 838 /* shutdown MB Decoding thread; */ |
| 833 if (pbi->b_multithreaded_rd) | 839 if (pbi->b_multithreaded_rd) |
| 834 { | 840 { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 | 909 |
| 904 setup_decoding_thread_data(pbi, xd, pbi->mb_row_di, pbi->decoding_thread_cou
nt); | 910 setup_decoding_thread_data(pbi, xd, pbi->mb_row_di, pbi->decoding_thread_cou
nt); |
| 905 | 911 |
| 906 for (i = 0; i < pbi->decoding_thread_count; i++) | 912 for (i = 0; i < pbi->decoding_thread_count; i++) |
| 907 sem_post(&pbi->h_event_start_decoding[i]); | 913 sem_post(&pbi->h_event_start_decoding[i]); |
| 908 | 914 |
| 909 mt_decode_mb_rows(pbi, xd, 0); | 915 mt_decode_mb_rows(pbi, xd, 0); |
| 910 | 916 |
| 911 sem_wait(&pbi->h_event_end_decoding); /* add back for each frame */ | 917 sem_wait(&pbi->h_event_end_decoding); /* add back for each frame */ |
| 912 } | 918 } |
| OLD | NEW |