void decode_and_reconstruct_block_inter (uint8_t *rec, int stride, int size, int qp, uint8_t *pblock, int16_t *coeffq,int tb_split){ int16_t *rcoeff = thor_alloc(2*MAX_TR_SIZE*MAX_TR_SIZE, 16); int16_t *rblock = thor_alloc(2*MAX_TR_SIZE*MAX_TR_SIZE, 16); int16_t *rblock2 = thor_alloc(2*MAX_TR_SIZE*MAX_TR_SIZE, 16); if (tb_split){ int size2 = size/2; int i,j,k,index; for (i=0;i<size;i+=size2){ for (j=0;j<size;j+=size2){ index = 2*(i/size2) + (j/size2); dequantize (coeffq+index*size2*size2,rcoeff,qp,size2); inverse_transform (rcoeff, rblock2, size2); /* Copy from compact block of quarter size to full size */ for (k=0;k<size2;k++){ memcpy(rblock+(i+k)*size+j,rblock2+k*size2,size2*sizeof(int16_t)); } } } } else{ dequantize (coeffq,rcoeff,qp,size); inverse_transform (rcoeff, rblock, size); } reconstruct_block(rblock,pblock,rec,size,stride); thor_free(rcoeff); thor_free(rblock); thor_free(rblock2); }
bool leveldb_chain_keeper::end_slice(size_t slice_begin_index, block_detail_list& sliced_blocks) { leveldb_transaction_batch batch; leveldb_iterator it(db_.block->NewIterator(leveldb::ReadOptions())); data_chunk raw_depth = uncast_type(slice_begin_index); for (it->Seek(slice(raw_depth)); it->Valid(); it->Next()) { block_detail_ptr sliced_block = reconstruct_block(common_, it->value().ToString()); if (!sliced_block) return false; // Add to list of sliced blocks sliced_blocks.push_back(sliced_block); // Make sure to delete hash secondary index too. const hash_digest& block_hash = sliced_block->hash(); // Delete block header... batch.block.Delete(it->key()); // And it's secondary index. batch.block_hash.Delete(slice_block_hash(block_hash)); // Remove txs + spends + addresses too const auto& transactions = sliced_block->actual().transactions; for (const transaction_type& block_tx: transactions) if (!clear_transaction_data(batch, block_tx)) return false; } leveldb::WriteOptions options; // Execute batches. db_.write(batch); return true; }
void decode_and_reconstruct_block_intra (uint8_t *rec, int stride, int size, int qp, uint8_t *pblock, int16_t *coeffq, int tb_split, int upright_available,int downleft_available, intra_mode_t intra_mode,int ypos,int xpos,int width,int comp, qmtx_t ** iwmatrix){ int16_t *rcoeff = thor_alloc(2*MAX_TR_SIZE*MAX_TR_SIZE, 16); int16_t *rblock = thor_alloc(2*MAX_TR_SIZE*MAX_TR_SIZE, 16); int16_t *rblock2 = thor_alloc(2*MAX_TR_SIZE*MAX_TR_SIZE, 16); uint8_t* left_data = (uint8_t*)thor_alloc(2*MAX_TR_SIZE+2,16)+1; uint8_t* top_data = (uint8_t*)thor_alloc(2*MAX_TR_SIZE+2,16)+1; uint8_t top_left; if (tb_split){ int size2 = size/2; int i,j,index; for (i=0;i<size;i+=size2){ for (j=0;j<size;j+=size2){ make_top_and_left(left_data,top_data,&top_left,rec,stride,&rec[i*stride+j],stride,i,j,ypos,xpos,size2,upright_available,downleft_available,1); get_intra_prediction(left_data,top_data,top_left,ypos+i,xpos+j,size2,pblock,intra_mode); index = 2*(i/size2) + (j/size2); dequantize (coeffq+index*size2*size2, rcoeff, qp, size2, iwmatrix ? iwmatrix[log2i(size2/4)] : NULL, MAX_QUANT_SIZE); inverse_transform (rcoeff, rblock2, size2); reconstruct_block(rblock2,pblock,&rec[i*stride+j],size2,stride); } } } else{ make_top_and_left(left_data,top_data,&top_left,rec,stride,NULL,0,0,0,ypos,xpos,size,upright_available,downleft_available,0); get_intra_prediction(left_data,top_data,top_left,ypos,xpos,size,pblock,intra_mode); dequantize (coeffq, rcoeff, qp, size, iwmatrix ? iwmatrix[log2i(size/4)] : NULL, MAX_QUANT_SIZE); inverse_transform (rcoeff, rblock, size); reconstruct_block(rblock,pblock,rec,size,stride); } thor_free(top_data - 1); thor_free(left_data - 1); thor_free(rcoeff); thor_free(rblock); thor_free(rblock2); }
bool leveldb_chain_keeper::end_slice(size_t slice_begin_index, block_detail_list& sliced_blocks) { leveldb::WriteBatch blk_batch, blk_hash_batch; leveldb_transaction_batch tx_batch; leveldb_iterator it(db_blocks_->NewIterator(leveldb::ReadOptions())); data_chunk raw_depth = uncast_type(slice_begin_index); for (it->Seek(slice(raw_depth)); it->Valid(); it->Next()) { std::stringstream ss; ss.str(it->value().ToString()); protobuf::Block proto_block; proto_block.ParseFromIstream(&ss); // Convert protobuf block header into actual block block_type sliced_block; if (!reconstruct_block(common_, proto_block, sliced_block)) return false; // Add to list of sliced blocks block_detail_ptr sliced_detail = std::make_shared<block_detail>(sliced_block); sliced_blocks.push_back(sliced_detail); // Make sure to delete hash secondary index too. hash_digest block_hash = hash_block_header(sliced_block); // Delete block header... blk_batch.Delete(it->key()); // And it's secondary index. blk_hash_batch.Delete(slice_block_hash(block_hash)); // Remove txs + spends + addresses too for (const transaction_type& block_tx: sliced_block.transactions) if (!clear_transaction_data(tx_batch, block_tx)) return false; } leveldb::WriteOptions options; // Execute batches. db_blocks_->Write(options, &blk_batch); db_blocks_hash_->Write(options, &blk_hash_batch); db_txs_->Write(options, &tx_batch.tx_batch); db_spends_->Write(options, &tx_batch.spends_batch); db_address_->Write(options, &tx_batch.address_batch); return true; }