Home | History | Annotate | Download | only in src

Lines Matching refs:block

55 #define CV_GET_LAST_ELEM( seq, block ) \
56 ((block)->data + ((block)->count - 1)*((seq)->elem_size))
162 CvMemBlock *block;
171 for( block = storage->bottom; block != 0; k++ )
173 CvMemBlock *temp = block;
175 block = block->next;
256 /* Moves stack pointer to next block.
270 CvMemBlock *block;
274 CV_CALL( block = (CvMemBlock *)cvAlloc( storage->block_size ));
284 block = parent->top;
287 if( block == parent->top ) /* the single allocated block */
289 assert( parent->bottom == block );
295 /* cut the block from the parent's list of blocks */
296 parent->top->next = block->next;
297 if( block->next )
298 block->next->prev = parent->top;
302 /* link block */
303 block->next = 0;
304 block->prev = storage->top;
307 storage->top->next = block;
309 storage->top = storage->bottom = block;
397 CV_ERROR( CV_StsOutOfRange, "Too large memory block is requested" );
515 CV_ERROR( CV_StsOutOfRange, "Storage block size is too small "
529 CvSeqBlock *block;
540 block = seq->first;
543 while( index >= (count = block->count) )
545 block = block->next;
553 block = block->prev;
554 total -= block->count;
560 return block->data + index * seq->elem_size;
572 CvSeqBlock *block;
581 block = first_block = seq->first;
586 if( (unsigned)(element - block->data) < (unsigned) (block->count * elem_size) )
589 *_block = block;
591 id = (int)((size_t)(element - block->data) >> id);
593 id = (int)((size_t)(element - block->data) / elem_size);
594 id += block->start_index - seq->first->start_index;
597 block = block->next;
598 if( block == first_block )
669 reader.block = reader.block->next;
670 reader.ptr = reader.block->data;
671 reader.block_max = reader.ptr + reader.block->count*elem_size;
686 void *array, int total, CvSeq *seq, CvSeqBlock * block )
697 if( !seq || ((!array || !block) && total > 0) )
720 seq->first = block;
721 block->prev = block->next = block;
722 block->start_index = 0;
723 block->count = total;
724 block->data = (schar *) array;
745 CvSeqBlock *block;
749 block = seq->free_blocks;
751 if( !block )
763 /* If there is a free space just after last allocated block
764 and it is big enough then enlarge the last block.
765 This can happen only if the new block is added to the end of sequence: */
799 CV_CALL( block = (CvSeqBlock*)cvMemStorageAlloc( storage, delta ));
800 block->data = (schar*)cvAlignPtr( block + 1, CV_STRUCT_ALIGN );
801 block->count = delta - ICV_ALIGNED_SEQ_BLOCK_SIZE;
802 block->prev = block->next = 0;
807 seq->free_blocks = block->next;
812 seq->first = block;
813 block->prev = block->next = block;
817 block->prev = seq->first->prev;
818 block->next = seq->first;
819 block->prev->next = block->next->prev = block;
823 * total number of bytes in the block.
826 * of sequence elements in the block:
828 assert( block->count % seq->elem_size == 0 && block->count > 0 );
832 seq->ptr = block->data;
833 seq->block_max = block->data + block->count;
834 block->start_index = block == block->prev ? 0 :
835 block->prev->start_index + block->prev->count;
839 int delta = block->count / seq->elem_size;
840 block->data += block->count;
842 if( block != block->prev )
845 seq->first = block;
849 seq->block_max = seq->ptr = block->data;
852 block->start_index = 0;
856 block->start_index += delta;
857 block = block->next;
858 if( block == seq->first )
863 block->count = 0;
868 /* Recycle a sequence block: */
876 CvSeqBlock *block = seq->first;
878 assert( (in_front_of ? block : block->prev)->count == 0 );
880 if( block == block->prev ) /* single block case */
882 block->count = (int)(seq->block_max - block->data) + block->start_index * seq->elem_size;
883 block->data = seq->block_max - block->count;
892 block = block->prev;
893 assert( seq->ptr == block->data );
895 block->count = (int)(seq->block_max - seq->ptr);
896 seq->block_max = seq->ptr = block->prev->data +
897 block->prev->count * seq->elem_size;
901 int delta = block->start_index;
903 block->count = delta * seq->elem_size;
904 block->data -= block->count;
909 block->start_index -= delta;
910 block = block->next;
911 if( block == seq->first )
915 seq->first = block->next;
918 block->prev->next = block->next;
919 block->next->prev = block->prev;
922 assert( block->count > 0 && block->count % seq->elem_size == 0 );
923 block->next = seq->free_blocks;
924 seq->free_blocks = block;
949 writer->block = seq->first ? seq->first->prev : 0;
994 if( writer->block )
998 CvSeqBlock *block = first_block;
1000 writer->block->count = (int)((writer->ptr - writer->block->data) / seq->elem_size);
1001 assert( writer->block->count > 0 );
1005 total += block->count;
1006 block = block->next;
1008 while( block != first_block );
1033 /* Truncate the last block: */
1034 if( writer->block && writer->seq->storage )
1039 assert( writer->block->count > 0 );
1057 /* Create new sequence block: */
1076 writer->block = seq->first->prev;
1100 reader->block = 0;
1128 reader->block = last_block;
1132 reader->block = first_block;
1135 reader->block_min = reader->block->data;
1136 reader->block_max = reader->block_min + reader->block->count * seq->elem_size;
1141 reader->block = 0;
1150 /* Change the current reading block
1167 reader->block = reader->block->next;
1168 reader->ptr = reader->block->data;
1172 reader->block = reader->block->prev;
1173 reader->ptr = CV_GET_LAST_ELEM( reader->seq, reader->block );
1175 reader->block_min = reader->block->data;
1176 reader->block_max = reader->block_min + reader->block->count * reader->seq->elem_size;
1202 index += reader->block->start_index - reader->delta_index;
1221 CvSeqBlock *block;
1245 block = reader->seq->first;
1246 if( index >= (count = block->count) )
1252 block = block->next;
1255 while( index >= (count = block->count) );
1261 block = block->prev;
1262 total -= block->count;
1268 reader->ptr = block->data + index * elem_size;
1269 if( reader->block != block )
1271 reader->block = block;
1272 reader->block_min = block->data;
1273 block->data + block->count * elem_size;
1280 block = reader->block;
1288 reader->block = block = block->next;
1289 reader->block_min = ptr = block->data;
1290 reader->block_max = block->data + block->count*elem_size;
1300 reader->block = block = block->prev;
1301 reader->block_min = block->data;
1302 reader->block_max = ptr = block->data + block->count*elem_size;
1389 CvSeqBlock *block;
1399 block = seq->first;
1401 if( !block || block->start_index == 0 )
1405 block = seq->first;
1406 assert( block->start_index > 0 );
1409 ptr = block->data -= elem_size;
1413 block->count++;
1414 block->start_index--;
1428 CvSeqBlock *block;
1440 block = seq->first;
1443 CV_MEMCPY_AUTO( element, block->data, elem_size );
1444 block->data += elem_size;
1445 block->start_index++;
1448 if( --(block->count) == 0 )
1462 CvSeqBlock *block;
1506 block = seq->first->prev;
1507 block->count++;
1508 block_size = (int)(ptr - block->data);
1510 while( before_index < block->start_index - delta_index )
1512 CvSeqBlock *prev_block = block->prev;
1514 memmove( block->data + elem_size, block->data, block_size - elem_size );
1516 memcpy( block->data, prev_block->data + block_size - elem_size, elem_size );
1517 block = prev_block;
1520 assert( block != seq->first->prev );
1523 before_index = (before_index - block->start_index + delta_index) * elem_size;
1524 memmove( block->data + before_index + elem_size, block->data + before_index,
1527 ret_ptr = block->data + before_index;
1535 block = seq->first;
1537 if( block->start_index == 0 )
1541 block = seq->first;
1544 delta_index = block->start_index;
1545 block->count++;
1546 block->start_index--;
1547 block->data -= elem_size;
1549 while( before_index > block->start_index - delta_index + block->count )
1551 CvSeqBlock *next_block = block->next;
1553 block_size = block->count * elem_size;
1554 memmove( block->data, block->data + elem_size, block_size - elem_size );
1555 memcpy( block->data + block_size - elem_size, next_block->data, elem_size );
1556 block = next_block;
1559 assert( block != seq->first );
1562 before_index = (before_index - block->start_index + delta_index) * elem_size;
1563 memmove( block->data, block->data + elem_size, before_index - elem_size );
1565 ret_ptr = block->data + before_index - elem_size;
1587 CvSeqBlock *block;
1616 block = seq->first;
1618 delta_index = block->start_index;
1619 while( block->start_index - delta_index + block->count <= index )
1620 block = block->next;
1622 ptr = block->data + (index - block->start_index + delta_index) * elem_size;
1627 block_size = block->count * elem_size - (int)(ptr - block->data);
1629 while( block != seq->first->prev ) /* while not the last block */
1631 CvSeqBlock *next_block = block->next;
1635 block = next_block;
1636 ptr = block->data;
1637 block_size = block->count * elem_size;
1646 block_size = (int)(ptr - block->data);
1648 while( block != seq->first )
1650 CvSeqBlock *prev_block = block->prev;
1652 memmove( block->data + elem_size, block->data, block_size - elem_size );
1654 memcpy( block->data, prev_block->data + block_size - elem_size, elem_size );
1655 block = prev_block;
1658 memmove( block->data + elem_size, block->data, block_size - elem_size );
1659 block->data += elem_size;
1660 block->start_index++;
1664 if( --block->count == 0 )
1717 CvSeqBlock* block = seq->first;
1723 if( !block || block->start_index == 0 )
1727 block = seq->first;
1728 assert( block->start_index > 0 );
1731 delta = MIN( block->start_index, count );
1733 block->start_index -= delta;
1734 block->count += delta;
1737 block->data -= delta;
1740 memcpy( block->data, elements + count*elem_size, delta );
1851 CvSeqBlock *block, *first_block = 0, *last_block = 0;
1887 block = (CvSeqBlock*)cvMemStorageAlloc( storage, sizeof(*block) );
1890 first_block = subseq->first = block->prev = block->next = block;
1891 block->start_index = 0;
1895 block->prev = last_block;
1896 block->next = first_block;
1897 last_block->next = first_block->prev = block;
1898 block->start_index = last_block->start_index + last_block->count;
1900 last_block = block;
1901 block->data = reader.ptr;
1902 block->count = bl;
1908 reader.block = reader.block->next;
1909 reader.ptr = reader.block->data;
1910 count = reader.block->count;
2011 CvSeqBlock block;
2028 &from_header, &block ));
2130 CvSeqBlock* block;
2139 (pos).block = (reader).block; \
2147 (reader).block = (pos).block; \
2209 if( left.block == right.block )
2226 if( ptr2.block != ptr.block )
2228 ptr2.block = ptr.block;