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

Side by Side Diff: source/libvpx/vp8/decoder/threading.c

Issue 11555023: libvpx: Add VP9 decoder. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 8 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
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
11 11
12 #include "vpx_config.h" 12 #include "vpx_config.h"
13 #include "vpx_rtcd.h" 13 #include "vp8_rtcd.h"
14 #if !defined(WIN32) && CONFIG_OS_SUPPORT == 1 14 #if !defined(WIN32) && CONFIG_OS_SUPPORT == 1
15 # include <unistd.h> 15 # include <unistd.h>
16 #endif 16 #endif
17 #include "onyxd_int.h" 17 #include "onyxd_int.h"
18 #include "vpx_mem/vpx_mem.h" 18 #include "vpx_mem/vpx_mem.h"
19 #include "vp8/common/threading.h" 19 #include "vp8/common/threading.h"
20 20
21 #include "vp8/common/loopfilter.h" 21 #include "vp8/common/loopfilter.h"
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
39 extern void vp8_mb_init_dequantizer(VP8D_COMP *pbi, MACROBLOCKD *xd); 32 extern void vp8_mb_init_dequantizer(VP8D_COMP *pbi, MACROBLOCKD *xd);
40 33
41 static void setup_decoding_thread_data(VP8D_COMP *pbi, MACROBLOCKD *xd, MB_ROW_D EC *mbrd, int count) 34 static void setup_decoding_thread_data(VP8D_COMP *pbi, MACROBLOCKD *xd, MB_ROW_D EC *mbrd, int count)
42 { 35 {
43 VP8_COMMON *const pc = & pbi->common; 36 VP8_COMMON *const pc = & pbi->common;
44 int i; 37 int i;
45 38
46 for (i = 0; i < count; i++) 39 for (i = 0; i < count; i++)
47 { 40 {
48 MACROBLOCKD *mbd = &mbrd[i].mbd; 41 MACROBLOCKD *mbd = &mbrd[i].mbd;
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 661
669 /* limit decoding threads to the available cores */ 662 /* limit decoding threads to the available cores */
670 if (core_count > pbi->common.processor_core_count) 663 if (core_count > pbi->common.processor_core_count)
671 core_count = pbi->common.processor_core_count; 664 core_count = pbi->common.processor_core_count;
672 665
673 if (core_count > 1) 666 if (core_count > 1)
674 { 667 {
675 pbi->b_multithreaded_rd = 1; 668 pbi->b_multithreaded_rd = 1;
676 pbi->decoding_thread_count = core_count - 1; 669 pbi->decoding_thread_count = core_count - 1;
677 670
678 CALLOC_ARRAY(pbi->h_decoding_thread, pbi->decoding_thread_count); 671 CHECK_MEM_ERROR(pbi->h_decoding_thread, vpx_malloc(sizeof(pthread_t) * p bi->decoding_thread_count));
679 CALLOC_ARRAY(pbi->h_event_start_decoding, pbi->decoding_thread_count); 672 CHECK_MEM_ERROR(pbi->h_event_start_decoding, vpx_malloc(sizeof(sem_t) * pbi->decoding_thread_count));
680 CALLOC_ARRAY_ALIGNED(pbi->mb_row_di, pbi->decoding_thread_count, 32); 673 CHECK_MEM_ERROR(pbi->mb_row_di, vpx_memalign(32, sizeof(MB_ROW_DEC) * pb i->decoding_thread_count));
681 CALLOC_ARRAY(pbi->de_thread_data, pbi->decoding_thread_count); 674 vpx_memset(pbi->mb_row_di, 0, sizeof(MB_ROW_DEC) * pbi->decoding_thread_ count);
675 CHECK_MEM_ERROR(pbi->de_thread_data, vpx_malloc(sizeof(DECODETHREAD_DATA ) * pbi->decoding_thread_count));
682 676
683 for (ithread = 0; ithread < pbi->decoding_thread_count; ithread++) 677 for (ithread = 0; ithread < pbi->decoding_thread_count; ithread++)
684 { 678 {
685 sem_init(&pbi->h_event_start_decoding[ithread], 0, 0); 679 sem_init(&pbi->h_event_start_decoding[ithread], 0, 0);
686 680
687 vp8_setup_block_dptrs(&pbi->mb_row_di[ithread].mbd); 681 vp8_setup_block_dptrs(&pbi->mb_row_di[ithread].mbd);
688 682
689 pbi->de_thread_data[ithread].ithread = ithread; 683 pbi->de_thread_data[ithread].ithread = ithread;
690 pbi->de_thread_data[ithread].ptr1 = (void *)pbi; 684 pbi->de_thread_data[ithread].ptr1 = (void *)pbi;
691 pbi->de_thread_data[ithread].ptr2 = (void *) &pbi->mb_row_di[ith read]; 685 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
795 width += 16 - (width & 0xf); 789 width += 16 - (width & 0xf);
796 790
797 if (width < 640) pbi->sync_range = 1; 791 if (width < 640) pbi->sync_range = 1;
798 else if (width <= 1280) pbi->sync_range = 8; 792 else if (width <= 1280) pbi->sync_range = 8;
799 else if (width <= 2560) pbi->sync_range =16; 793 else if (width <= 2560) pbi->sync_range =16;
800 else pbi->sync_range = 32; 794 else pbi->sync_range = 32;
801 795
802 uv_width = width >>1; 796 uv_width = width >>1;
803 797
804 /* Allocate an int for each mb row. */ 798 /* Allocate an int for each mb row. */
805 CALLOC_ARRAY(pbi->mt_current_mb_col, pc->mb_rows); 799 CHECK_MEM_ERROR(pbi->mt_current_mb_col, vpx_malloc(sizeof(int) * pc->mb_ rows));
806 800
807 /* Allocate memory for above_row buffers. */ 801 /* Allocate memory for above_row buffers. */
808 CALLOC_ARRAY(pbi->mt_yabove_row, pc->mb_rows); 802 CHECK_MEM_ERROR(pbi->mt_yabove_row, vpx_malloc(sizeof(unsigned char *) * pc->mb_rows));
809 for (i = 0; i < pc->mb_rows; i++) 803 for (i=0; i< pc->mb_rows; i++)
810 CHECK_MEM_ERROR(pbi->mt_yabove_row[i], vpx_memalign(16,sizeof(unsign ed char) * (width + (VP8BORDERINPIXELS<<1)))); 804 CHECK_MEM_ERROR(pbi->mt_yabove_row[i], vpx_memalign(16,sizeof(unsign ed char) * (width + (VP8BORDERINPIXELS<<1))));
811 805
812 CALLOC_ARRAY(pbi->mt_uabove_row, pc->mb_rows); 806 CHECK_MEM_ERROR(pbi->mt_uabove_row, vpx_malloc(sizeof(unsigned char *) * pc->mb_rows));
813 for (i = 0; i < pc->mb_rows; i++) 807 for (i=0; i< pc->mb_rows; i++)
814 CHECK_MEM_ERROR(pbi->mt_uabove_row[i], vpx_memalign(16,sizeof(unsign ed char) * (uv_width + VP8BORDERINPIXELS))); 808 CHECK_MEM_ERROR(pbi->mt_uabove_row[i], vpx_memalign(16,sizeof(unsign ed char) * (uv_width + VP8BORDERINPIXELS)));
815 809
816 CALLOC_ARRAY(pbi->mt_vabove_row, pc->mb_rows); 810 CHECK_MEM_ERROR(pbi->mt_vabove_row, vpx_malloc(sizeof(unsigned char *) * pc->mb_rows));
817 for (i = 0; i < pc->mb_rows; i++) 811 for (i=0; i< pc->mb_rows; i++)
818 CHECK_MEM_ERROR(pbi->mt_vabove_row[i], vpx_memalign(16,sizeof(unsign ed char) * (uv_width + VP8BORDERINPIXELS))); 812 CHECK_MEM_ERROR(pbi->mt_vabove_row[i], vpx_memalign(16,sizeof(unsign ed char) * (uv_width + VP8BORDERINPIXELS)));
819 813
820 /* Allocate memory for left_col buffers. */ 814 /* Allocate memory for left_col buffers. */
821 CALLOC_ARRAY(pbi->mt_yleft_col, pc->mb_rows); 815 CHECK_MEM_ERROR(pbi->mt_yleft_col, vpx_malloc(sizeof(unsigned char *) * pc->mb_rows));
822 for (i = 0; i < pc->mb_rows; i++) 816 for (i=0; i< pc->mb_rows; i++)
823 CHECK_MEM_ERROR(pbi->mt_yleft_col[i], vpx_calloc(sizeof(unsigned cha r) * 16, 1)); 817 CHECK_MEM_ERROR(pbi->mt_yleft_col[i], vpx_calloc(sizeof(unsigned cha r) * 16, 1));
824 818
825 CALLOC_ARRAY(pbi->mt_uleft_col, pc->mb_rows); 819 CHECK_MEM_ERROR(pbi->mt_uleft_col, vpx_malloc(sizeof(unsigned char *) * pc->mb_rows));
826 for (i = 0; i < pc->mb_rows; i++) 820 for (i=0; i< pc->mb_rows; i++)
827 CHECK_MEM_ERROR(pbi->mt_uleft_col[i], vpx_calloc(sizeof(unsigned cha r) * 8, 1)); 821 CHECK_MEM_ERROR(pbi->mt_uleft_col[i], vpx_calloc(sizeof(unsigned cha r) * 8, 1));
828 822
829 CALLOC_ARRAY(pbi->mt_vleft_col, pc->mb_rows); 823 CHECK_MEM_ERROR(pbi->mt_vleft_col, vpx_malloc(sizeof(unsigned char *) * pc->mb_rows));
830 for (i = 0; i < pc->mb_rows; i++) 824 for (i=0; i< pc->mb_rows; i++)
831 CHECK_MEM_ERROR(pbi->mt_vleft_col[i], vpx_calloc(sizeof(unsigned cha r) * 8, 1)); 825 CHECK_MEM_ERROR(pbi->mt_vleft_col[i], vpx_calloc(sizeof(unsigned cha r) * 8, 1));
832 } 826 }
833 } 827 }
834 828
835 829
836 void vp8_decoder_remove_threads(VP8D_COMP *pbi) 830 void vp8_decoder_remove_threads(VP8D_COMP *pbi)
837 { 831 {
838 /* shutdown MB Decoding thread; */ 832 /* shutdown MB Decoding thread; */
839 if (pbi->b_multithreaded_rd) 833 if (pbi->b_multithreaded_rd)
840 { 834 {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 903
910 setup_decoding_thread_data(pbi, xd, pbi->mb_row_di, pbi->decoding_thread_cou nt); 904 setup_decoding_thread_data(pbi, xd, pbi->mb_row_di, pbi->decoding_thread_cou nt);
911 905
912 for (i = 0; i < pbi->decoding_thread_count; i++) 906 for (i = 0; i < pbi->decoding_thread_count; i++)
913 sem_post(&pbi->h_event_start_decoding[i]); 907 sem_post(&pbi->h_event_start_decoding[i]);
914 908
915 mt_decode_mb_rows(pbi, xd, 0); 909 mt_decode_mb_rows(pbi, xd, 0);
916 910
917 sem_wait(&pbi->h_event_end_decoding); /* add back for each frame */ 911 sem_wait(&pbi->h_event_end_decoding); /* add back for each frame */
918 } 912 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698