亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ahuff.c

?? huffman coding and decoding adaptive huffman coding and decoding it is a assignment from my cours
?? C
?? 第 1 頁 / 共 3 頁
字號:
        tree->nodes[ current_node ].weight++;        for ( new_node = current_node ; new_node > ROOT_NODE ; new_node-- )            if ( tree->nodes[ new_node - 1 ].weight >=                 tree->nodes[ current_node ].weight )                break;        if ( current_node != new_node ) {            swap_nodes( tree, current_node, new_node );            current_node = new_node;        }        current_node = tree->nodes[ current_node ].parent;    }}/* * Rebuilding the tree takes place when the counts have gone too * high.  From a simple point of view, rebuilding the tree just means that * we divide every count by two.  Unfortunately, due to truncation effects, * this means that the tree's shape might change.  Some nodes might move * up due to cumulative increases, while others may move down. */void RebuildTree( tree )TREE *tree;{    int i;    int j;    int k;    unsigned int weight;/* * To start rebuilding the table,  I collect all the leaves of the Huffman * tree and put them in the end of the tree.  While I am doing that, I * scale the counts down by a factor of 2. */    printf( "R" );    j = tree->next_free_node - 1;    for ( i = j ; i >= ROOT_NODE ; i-- ) {        if ( tree->nodes[ i ].child_is_leaf ) {            tree->nodes[ j ] = tree->nodes[ i ];            tree->nodes[ j ].weight = ( tree->nodes[ j ].weight + 1 ) / 2;            j--;        }    }/* * At this point, j points to the first free node.  I now have all the * leaves defined, and need to start building the higher nodes on the * tree. I will start adding the new internal nodes at j.  Every time * I add a new internal node to the top of the tree, I have to check to * see where it really belongs in the tree.  It might stay at the top, * but there is a good chance I might have to move it back down.  If it * does have to go down, I use the memmove() function to scoot everyone * bigger up by one node.  Note that memmove() may have to be change * to memcpy() on some UNIX systems.  The parameters are unchanged, as * memmove and  memcpy have the same set of parameters. */    for ( i = tree->next_free_node - 2 ; j >= ROOT_NODE ; i -= 2, j-- ) {        k = i + 1;        tree->nodes[ j ].weight = tree->nodes[ i ].weight +                                  tree->nodes[ k ].weight;        weight = tree->nodes[ j ].weight;        tree->nodes[ j ].child_is_leaf = FALSE;        for ( k = j + 1 ; weight < tree->nodes[ k ].weight ; k++ )            ;        k--;        memmove( &tree->nodes[ j ], &tree->nodes[ j + 1 ],                 ( k - j ) * sizeof( struct node ) );        tree->nodes[ k ].weight = weight;        tree->nodes[ k ].child = i;        tree->nodes[ k ].child_is_leaf = FALSE;    }/* * The final step in tree reconstruction is to go through and set up * all of the leaf and parent members.  This can be safely done now * that every node is in its final position in the tree. */    for ( i = tree->next_free_node - 1 ; i >= ROOT_NODE ; i-- ) {        if ( tree->nodes[ i ].child_is_leaf ) {            k = tree->nodes[ i ].child;            tree->leaf[ k ] = i;        } else {            k = tree->nodes[ i ].child;            tree->nodes[ k ].parent = tree->nodes[ k + 1 ].parent = i;        }    }}/* * Swapping nodes takes place when a node has grown too big for its * spot in the tree.  When swapping nodes i and j, we rearrange the * tree by exchanging the children under i with the children under j. */void swap_nodes( tree, i, j )TREE *tree;int i;int j;{    struct node temp;    if ( tree->nodes[ i ].child_is_leaf )        tree->leaf[ tree->nodes[ i ].child ] = j;    else {        tree->nodes[ tree->nodes[ i ].child ].parent = j;        tree->nodes[ tree->nodes[ i ].child + 1 ].parent = j;    }    if ( tree->nodes[ j ].child_is_leaf )        tree->leaf[ tree->nodes[ j ].child ] = i;    else {        tree->nodes[ tree->nodes[ j ].child ].parent = i;        tree->nodes[ tree->nodes[ j ].child + 1 ].parent = i;    }    temp = tree->nodes[ i ];    tree->nodes[ i ] = tree->nodes[ j ];    tree->nodes[ i ].parent = temp.parent;    temp.parent = tree->nodes[ j ].parent;    tree->nodes[ j ] = temp;}/* * Adding a new node to the tree is pretty simple.  It is just a matter * of splitting the lightest-weight node in the tree, which is the highest * valued node.  We split it off into two new nodes, one of which is the * one being added to the tree.  We assign the new node a weight of 0, * so the tree doesn't have to be adjusted.  It will be updated later when * the normal update process occurs.  Note that this code assumes that * the lightest node has a leaf as a child.  If this is not the case, * the tree would be broken. */void add_new_node( tree, c )TREE *tree;int c;{    int lightest_node;    int new_node;    int zero_weight_node;    lightest_node = tree->next_free_node - 1;    new_node = tree->next_free_node;    zero_weight_node = tree->next_free_node + 1;    tree->next_free_node += 2;    tree->nodes[ new_node ] = tree->nodes[ lightest_node ];    tree->nodes[ new_node ].parent = lightest_node;    tree->leaf[ tree->nodes[ new_node ].child ] = new_node;    tree->nodes[ lightest_node ].child         = new_node;    tree->nodes[ lightest_node ].child_is_leaf = FALSE;    tree->nodes[ zero_weight_node ].child           = c;    tree->nodes[ zero_weight_node ].child_is_leaf   = TRUE;    tree->nodes[ zero_weight_node ].weight          = 0;    tree->nodes[ zero_weight_node ].parent          = lightest_node;    tree->leaf[ c ] = zero_weight_node;}/* * All the code from here down is concerned with printing the tree. * Printing the tree out is basically a process of walking down through * all the nodes, with each new node to be printed getting nudged over * far enough to make room for everything that has come before. *//* * This array is used to keep track of all the nodes that are in a given * row.  The nodes are kept in a linked list.  This array is used to keep * track of the first member.  The subsequent members will be found in * a linked list in the positions[] array. */struct row {    int first_member;    int count;} rows[ 32 ];/* * The positions[] array is used to keep track of the row and column of each * node in the tree.  The next_member element points to the next node * in the row for the given node.  The column is calculated on the fly, * and represents the actual column that a given number is to be printed in. * Note that the column for a node is not an actual column on the page.  For * purposes of analysis, it is assumed that each node takes up exactly one * column.  So, if printing out the actual values in a node takes up for * spaces on the printed page, we might want to allocate five physical print * columns for each column in the array. */struct location {    int row;    int next_member;    int column;} positions[ NODE_TABLE_COUNT ];/* * This is the main routine called to print out a Huffman tree.  It first * calls the print_codes function, which prints out the binary codes * for each symbol.  After that, it calculates the row and column that * each node will be printed in, then prints the tree out.  This code * is not documented in the book, since it is essentially irrelevant to * the data compression process.  However, it is nice to be able to * print out the tree. */void PrintTree( tree )TREE *tree;{    int i;    int min;    print_codes( tree );    for ( i = 0 ; i < 32 ; i++ ) {        rows[ i ].count = 0;        rows[ i ].first_member = -1;    }    calculate_rows( tree, ROOT_NODE, 0 );    calculate_columns( tree, ROOT_NODE, 0 );    min = find_minimum_column( tree, ROOT_NODE, 31 );    rescale_columns( min );    print_tree( tree, 0, 31 );}/* * This routine is called to print out the Huffman code for each symbol. * The real work is done by the print_code routine, which racks up the * bits and puts them out in the right order. */void print_codes( tree )TREE *tree;{    int i;    printf( "\n" );    for ( i = 0 ; i < SYMBOL_COUNT  ; i++ )        if ( tree->leaf[ i ] != -1 ) {             if ( isprint( i ) )                 printf( "%5c: ", i );             else                 printf( "<%3d>: ", i );            printf( "%5u", tree->nodes[ tree->leaf[ i ] ].weight );            printf( " " );            print_code( tree, i );            printf( "\n" );        }}/* * print_code is a workhorse routine that prints out the Huffman code for * a given symbol.  It ends up looking a lot like EncodeSymbol(), since * it more or less has to do the same work.  The major difference is that * instead of calling OutputBit, this routine calls putc, with a character * argument. */void print_code( tree, c )TREE *tree;int c;{    unsigned long code;    unsigned long current_bit;    int code_size;    int current_node;    int i;    code = 0;    current_bit = 1;    code_size = 0;    current_node = tree->leaf[ c ];    while ( current_node != ROOT_NODE ) {        if ( current_node & 1 )            code |= current_bit;        current_bit <<= 1;        code_size++;        current_node = tree->nodes[ current_node ].parent;    };    for ( i = 0 ; i < code_size ; i++ ) {        current_bit >>= 1;        if ( code & current_bit )            putc( '1', stdout );        else            putc( '0', stdout );    }}/* * In order to print out the tree, I need to calculate the row and column * where each node will be printed.  The rows are easier than the columns, * and I do them first.  It is easy to keep track of what row a node is * in as I walk through the tree.  As I walk through the tree, I also keep * track of the order the nodes appear in a given row, by adding them to * a linked list in the proper order.  After calculate_rows() has been * recursively called all the way through the tree, I have a linked list of * nodes for each row.  This same linked list is used later to calculate * which column each node appears in. */void calculate_rows( tree, node, level )TREE *tree;int node;int level;{    if ( rows[ level ].first_member == -1 ) {        rows[ level ].first_member = node;        rows[ level ].count = 0;        positions[ node ].row = level;        positions[ node ].next_member = -1;    } else {        positions[ node ].row = level;        positions[ node ].next_member = rows[ level ].first_member;        rows[ level ].first_member = node;        rows[ level ].count++;    }    if ( !tree->nodes[ node ].child_is_leaf ) {        calculate_rows( tree, tree->nodes[ node ].child, level + 1 );        calculate_rows( tree, tree->nodes[ node ].child + 1, level + 1 );    }}/* * After I know which row each of the nodes is in, I can start the * hard work, which is calculating the columns.  This routine gets

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久久久亚洲综合影院红桃 | 有坂深雪av一区二区精品| 国产麻豆成人精品| 久久久精品人体av艺术| 成人小视频在线| 国产精品国产三级国产aⅴ入口| 欧美精品黑人性xxxx| 奇米亚洲午夜久久精品| 久久精品视频一区二区| 成人国产精品免费| 一区二区久久久| 欧美日韩中文国产| 韩国成人在线视频| 国产精品久久一级| 欧美视频一区在线| 国产在线精品一区二区三区不卡| 国产情人综合久久777777| 99久久精品免费看| 午夜久久久久久久久久一区二区| 91精品国产一区二区人妖| 国产剧情一区在线| 亚洲免费观看高清| 日韩精品资源二区在线| 99综合影院在线| 石原莉奈一区二区三区在线观看| 久久久久亚洲综合| 在线观看av不卡| 国产九九视频一区二区三区| 亚洲欧美日本在线| 精品播放一区二区| 在线一区二区三区四区| 激情六月婷婷久久| 亚洲欧美精品午睡沙发| 日韩一区二区精品葵司在线 | 首页欧美精品中文字幕| 国产欧美一区二区精品久导航| 日本韩国一区二区三区视频| 麻豆精品一区二区av白丝在线| 欧美国产一区二区| 91精品蜜臀在线一区尤物| 成人av在线观| 5月丁香婷婷综合| 成人精品gif动图一区| 日韩专区欧美专区| 亚洲欧美日韩电影| 国产欧美一区二区精品性色| 91精品国产一区二区| 色综合夜色一区| 国产成人亚洲精品青草天美| 蜜臀av亚洲一区中文字幕| 亚洲精品国产第一综合99久久| 久久久久久夜精品精品免费| 欧美猛男超大videosgay| 成人sese在线| 国产激情视频一区二区三区欧美| 亚洲国产日韩a在线播放| 国产精品国产自产拍高清av| 久久久国产综合精品女国产盗摄| 91精品国产麻豆国产自产在线 | 在线观看国产一区二区| 国产成人免费视频| 国产中文一区二区三区| 免费看黄色91| 午夜国产精品一区| 亚洲成人动漫在线免费观看| 一区二区三区精品视频| 亚洲少妇最新在线视频| 中文字幕免费不卡| 日韩国产欧美视频| 亚洲午夜精品一区二区三区他趣| 国产精品美日韩| 中国av一区二区三区| 国产精品日产欧美久久久久| 久久一区二区三区四区| 精品国产成人在线影院| 日韩免费看的电影| 欧美xxxx老人做受| 欧美成人video| 欧美mv日韩mv亚洲| 久久影院午夜论| 久久久久久麻豆| 国产精品美女久久久久高潮| 国产午夜亚洲精品午夜鲁丝片 | 91麻豆精品国产91久久久久久久久 | 91精品福利在线一区二区三区| 欧美放荡的少妇| 91.com视频| 精品国产成人系列| 国产精品免费久久| 亚洲男人的天堂一区二区 | 性做久久久久久久免费看| 亚洲成人一区在线| 美女视频网站久久| 国产激情精品久久久第一区二区| 国产成人午夜精品影院观看视频| 成熟亚洲日本毛茸茸凸凹| 99久久精品国产一区二区三区| 色哟哟欧美精品| 欧美日本韩国一区二区三区视频| 337p亚洲精品色噜噜| 欧美哺乳videos| 国产午夜精品美女毛片视频| 国产精品久久看| 一区二区高清免费观看影视大全| 亚洲成a人v欧美综合天堂下载| 老色鬼精品视频在线观看播放| 国产资源在线一区| 日本二三区不卡| 欧美一区二区三区在线| 国产日产欧美一区| 亚洲一区二区三区中文字幕| 美脚の诱脚舐め脚责91 | voyeur盗摄精品| 欧美亚洲国产一卡| 精品国产一区二区精华| 国产精品国产自产拍高清av王其| 亚洲成人手机在线| 国产又黄又大久久| 一本大道久久精品懂色aⅴ| 91精品国产欧美日韩| 中文字幕一区二区三区在线不卡| 婷婷丁香久久五月婷婷| 激情久久五月天| 欧美日韩精品一区视频| 国产亚洲一区字幕| 天堂影院一区二区| av中文字幕不卡| 欧美一级二级三级蜜桃| 一区二区三区国产精华| 韩国女主播一区| 欧美日韩免费观看一区三区| 国产日韩欧美高清在线| 蜜臀av性久久久久蜜臀aⅴ| 色综合色狠狠综合色| 国产欧美一区二区精品性色超碰| 午夜av一区二区三区| 成人精品免费网站| 精品国精品国产尤物美女| 亚洲国产精品久久不卡毛片 | 99re这里只有精品视频首页| 日韩精品专区在线影院观看| 亚洲狠狠爱一区二区三区| 国产99久久久久| 欧美大度的电影原声| 亚洲综合无码一区二区| 99热99精品| 国产色产综合产在线视频| 日产国产欧美视频一区精品| 日本高清成人免费播放| 国产精品久久久久久亚洲伦| 国产精品一区二区果冻传媒| 欧美一区二区久久| 亚洲国产日产av| 欧美综合色免费| 亚洲伦理在线精品| 成av人片一区二区| 中文字幕免费不卡在线| 国产麻豆精品在线| 久久久青草青青国产亚洲免观| 男人操女人的视频在线观看欧美| 欧美日韩一级片在线观看| 亚洲男人的天堂网| 色哟哟欧美精品| 亚洲精品免费电影| 欧美亚洲一区二区在线观看| 亚洲图片激情小说| 色欧美88888久久久久久影院| 国产精品人成在线观看免费 | 精品福利在线导航| 韩国欧美一区二区| xfplay精品久久| 国产一区二区h| 中文在线一区二区| 99久久伊人精品| 亚洲摸摸操操av| 91福利社在线观看| 亚洲福利一区二区| 91精品国产综合久久小美女| 日本成人在线网站| 日韩欧美国产一区二区三区 | 欧美午夜片在线看| 亚洲国产成人一区二区三区| 亚洲成av人片一区二区三区| 777奇米成人网| 极品少妇xxxx精品少妇| 欧美不卡在线视频| 国产黄人亚洲片| 自拍视频在线观看一区二区| 欧美午夜一区二区三区| 奇米888四色在线精品| 日韩欧美一级精品久久| 国产精一品亚洲二区在线视频| 国产精品女同互慰在线看| av电影在线观看不卡| 亚洲午夜免费电影| 久久午夜色播影院免费高清| 国产成人啪免费观看软件| 一区二区三区国产豹纹内裤在线| 91麻豆精品国产91久久久更新时间| 日本不卡视频在线|