⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dst_codeword_heap.c

📁 关于视频压缩的jpeg2000压缩算法,C编写
💻 C
字号:
/*****************************************************************************//* Copyright 1998, Hewlett-Packard Company                                   *//* All rights reserved                                                       *//* File: "dst_codeword_heap.c"                                               *//* Description: Implementation of the `dst_codeword_heap' object to manage   *//*              efficient dynamic resizing and recycling of storage for      *//*              compressed code words produced by a coding engine.           *//* Author: David Taubman                                                     *//* Affiliation: Hewlett-Packard and                                          *//*              The University of New South Wales, Australia                 *//* Version: V3.1A                                                            *//* Last Revised: 14 January, 1999                                            *//*****************************************************************************/#include <local_services.h>#include <stdlib.h>#include <string.h>#include <assert.h>#include <ifc.h>#include "dst_codeword_heap.h"/*****************************************************************************//* STATIC                        __get_unit                                  *//*****************************************************************************/static dst_heap_unit_ptr  __get_unit(dst_codeword_heap_ref self){  dst_heap_group_ptr scan;  dst_heap_unit_ptr unit;  int i;  for (scan=self->heap; scan != NULL; scan=scan->next)    if (scan->free_units)      break;  if (scan == NULL)    {      scan = (dst_heap_group_ptr)        local_malloc(DST_CODE_MEM_KEY,sizeof(dst_heap_group));      scan->next = self->heap;      self->heap = scan;      scan->free_units = DST_HEAP_GROUP_UNITS;      for (unit=scan->units, i=DST_HEAP_GROUP_UNITS; i > 0; i--, unit++)        {          unit->next = NULL;          unit->group = NULL;        }    }  for (unit=scan->units, i=DST_HEAP_GROUP_UNITS; i > 0; i--, unit++)    if (unit->group == NULL)      break;  assert(i > 0);  scan->free_units--;  unit->group = scan;  unit->next = NULL;  return(unit);}/*****************************************************************************//* STATIC                        __return_unit                               *//*****************************************************************************/static void  __return_unit(dst_codeword_heap_ref self, dst_heap_unit_ptr unit){  dst_heap_group_ptr group;  group = unit->group;  assert((group != NULL) && (group->free_units < DST_HEAP_GROUP_UNITS));  group->free_units++;  unit->group = NULL;}/*****************************************************************************//* STATIC                         __terminate                                *//*****************************************************************************/static void  __terminate(dst_codeword_heap_ref self){  dst_heap_group_ptr tmp;  while ((tmp=self->heap) != NULL)    {      self->heap = tmp->next;      local_free(tmp);    }  local_free(self);}/*****************************************************************************//* EXTERN                    create_dst_codeword_heap                        *//*****************************************************************************/dst_codeword_heap_ref  create_dst_codeword_heap(void){  dst_codeword_heap_ref result;  result = (dst_codeword_heap_ref)    local_malloc(DST_CODE_MEM_KEY,sizeof(dst_codeword_heap_obj));  memset(result,0,sizeof(dst_codeword_heap_obj));  result->get_unit = __get_unit;  result->return_unit = __return_unit;  result->terminate = __terminate;  return(result);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -