Line data Source code
1 : /* 2 : * Copyright(c) 2019 Intel Corporation 3 : * SPDX - License - Identifier: BSD - 2 - Clause - Patent 4 : */ 5 : 6 : #include <stdlib.h> 7 : #include <stdint.h> 8 : 9 : #include "EbCodingUnit.h" 10 : #include "EbDefinitions.h" 11 : #include "EbTransformUnit.h" 12 : #include "EbPictureControlSet.h" 13 : 14 360 : void largest_coding_unit_dctor(EbPtr p) 15 : { 16 360 : LargestCodingUnit* obj = (LargestCodingUnit*)p; 17 360 : EB_DELETE(obj->quantized_coeff); 18 360 : EB_FREE_ARRAY(obj->av1xd); 19 360 : EB_FREE_ARRAY(obj->final_cu_arr); 20 360 : EB_FREE_ARRAY(obj->cu_partition_array); 21 360 : } 22 : /* 23 : Tasks & Questions 24 : -Need a GetEmptyChain function for testing sub partitions. Tie it to an Itr? 25 : -How many empty CUs do we need? We need to have enough for the max CU count AND 26 : enough for temp storage when calculating a subdivision. 27 : -Where do we store temp reconstructed picture data while deciding to subdivide or not? 28 : -Need a ReconPicture for each candidate. 29 : -I don't see a way around doing the copies in temp memory and then copying it in... 30 : */ 31 360 : EbErrorType largest_coding_unit_ctor( 32 : LargestCodingUnit *larget_coding_unit_ptr, 33 : uint8_t sb_size_pix, 34 : uint16_t sb_origin_x, 35 : uint16_t sb_origin_y, 36 : uint16_t sb_index, 37 : PictureControlSet *picture_control_set) 38 : 39 : { 40 : uint32_t tu_index; 41 : EbPictureBufferDescInitData coeffInitData; 42 : 43 360 : larget_coding_unit_ptr->dctor = largest_coding_unit_dctor; 44 : 45 : // ************ SB *************** 46 : // Which borderLargestCuSize is not a power of two 47 : 48 : // Which borderLargestCuSize is not a power of two 49 360 : larget_coding_unit_ptr->picture_control_set_ptr = picture_control_set; 50 : 51 360 : larget_coding_unit_ptr->origin_x = sb_origin_x; 52 360 : larget_coding_unit_ptr->origin_y = sb_origin_y; 53 : 54 360 : larget_coding_unit_ptr->index = sb_index; 55 : 56 : uint32_t cu_i; 57 360 : uint32_t tot_cu_num = sb_size_pix == 128 ? 1024 : 256; 58 360 : larget_coding_unit_ptr->final_cu_count = tot_cu_num; 59 : 60 360 : EB_MALLOC_ARRAY(larget_coding_unit_ptr->final_cu_arr, tot_cu_num); 61 360 : EB_MALLOC_ARRAY(larget_coding_unit_ptr->av1xd, tot_cu_num); 62 : 63 92520 : for (cu_i = 0; cu_i < tot_cu_num; ++cu_i) { 64 552960 : for (tu_index = 0; tu_index < TRANSFORM_UNIT_MAX_COUNT; ++tu_index) 65 460800 : larget_coding_unit_ptr->final_cu_arr[cu_i].transform_unit_array[tu_index].tu_index = tu_index; 66 92160 : larget_coding_unit_ptr->final_cu_arr[cu_i].leaf_index = cu_i; 67 92160 : larget_coding_unit_ptr->final_cu_arr[cu_i].av1xd = larget_coding_unit_ptr->av1xd + cu_i; 68 : } 69 : 70 360 : uint32_t max_block_count = sb_size_pix == 128 ? BLOCK_MAX_COUNT_SB_128 : BLOCK_MAX_COUNT_SB_64; 71 : 72 360 : EB_MALLOC_ARRAY(larget_coding_unit_ptr->cu_partition_array, max_block_count); 73 : 74 360 : coeffInitData.buffer_enable_mask = PICTURE_BUFFER_DESC_FULL_MASK; 75 360 : coeffInitData.max_width = SB_STRIDE_Y; 76 360 : coeffInitData.max_height = SB_STRIDE_Y; 77 360 : coeffInitData.bit_depth = EB_32BIT; 78 360 : coeffInitData.color_format = picture_control_set->color_format; 79 360 : coeffInitData.left_padding = 0; 80 360 : coeffInitData.right_padding = 0; 81 360 : coeffInitData.top_padding = 0; 82 360 : coeffInitData.bot_padding = 0; 83 360 : coeffInitData.split_mode = EB_FALSE; 84 : 85 360 : EB_NEW( 86 : larget_coding_unit_ptr->quantized_coeff, 87 : eb_picture_buffer_desc_ctor, 88 : (EbPtr)&coeffInitData); 89 : 90 360 : return EB_ErrorNone; 91 : }