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

📄 paul.c

📁 spiht for linux this is used to decod and encode vedio i wich all enjoy
💻 C
📖 第 1 页 / 共 2 页
字号:
/* *  * QccPack: Quantization, compression, and coding libraries * Copyright (C) 1997-2009  James E. Fowler *  * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. *  * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Library General Public License for more details. *  * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, * MA 02139, USA. *  */#include "libQccPack.h"static int QccAVQPaulSendSideInfo(QccAVQSideInfo *sideinfo,                                   QccAVQSideInfoSymbol *updatevector_symbol,                                  int update_flag){  QccAVQSideInfoSymbol flag_symbol;    flag_symbol.type = QCCAVQSIDEINFO_FLAG;  flag_symbol.flag = update_flag;  flag_symbol.vector = NULL;  flag_symbol.vector_indices = NULL;  if (QccAVQSideInfoSymbolWrite(sideinfo, &flag_symbol))    {      QccErrorAddMessage("(QccAVQPaulSendSideInfo): Error calling QccAVQSideInfoSymbolWrite()");      return(1);    }    if (update_flag == QCCAVQSIDEINFO_FLAG_UPDATE)    {      updatevector_symbol->type = QCCAVQSIDEINFO_VECTOR;      if (QccAVQSideInfoSymbolWrite(sideinfo, updatevector_symbol))        {          QccErrorAddMessage("(QccAVQPaulSendSideInfo): Error calling QccAVQSideInfoSymbolWrite()");          return(1);        }    }    return(0);}int QccAVQPaulEncode(const QccDataset *dataset,                     QccVQCodebook *codebook,                     QccChannel *channel,                     QccAVQSideInfo *sideinfo,                     double distortion_threshold,                     QccVQDistortionMeasure distortion_measure){  int return_value;  int block_size;  int vector_dimension;  int current_vector;  double winning_distortion;  int winner;  QccDataset tmp_dataset;  int codebook_size;  QccAVQSideInfoSymbol *new_codeword_symbol = NULL;    if ((dataset == NULL) || (codebook == NULL) || (channel == NULL) ||      (sideinfo == NULL))    return(0);  if ((dataset->vectors == NULL) ||       (codebook->codewords == NULL))    return(0);    vector_dimension = dataset->vector_dimension;  if ((vector_dimension != codebook->codeword_dimension) ||      (vector_dimension != sideinfo->vector_dimension))    {      QccErrorAddMessage("(QccAVQPaulEncode): Codebook %s, dataset %s, and sideinfo %s",                         codebook->filename, dataset->filename, sideinfo->filename);      QccErrorAddMessage("have different vector dimensions");      goto QccAVQError;    }    block_size = QccDatasetGetBlockSize(dataset);    QccDatasetInitialize(&tmp_dataset);  tmp_dataset.num_vectors = 1;  tmp_dataset.vector_dimension = dataset->vector_dimension;  tmp_dataset.access_block_size = QCCDATASET_ACCESSWHOLEFILE;  tmp_dataset.num_blocks_accessed = 0;  if (QccDatasetAlloc(&tmp_dataset))    {      QccErrorAddMessage("(QccAVQPaulEncode): Error calling QccDatasetAlloc()");      goto QccAVQError;    }    if ((new_codeword_symbol =        QccAVQSideInfoSymbolAlloc(vector_dimension)) == NULL)    {      QccErrorAddMessage("(QccAVQgtrEncode): Error calling QccAVQSideInfoSymbolAlloc()");      goto QccAVQError;    }  new_codeword_symbol->type = QCCAVQSIDEINFO_VECTOR;  codebook_size = codebook->num_codewords;    for (current_vector = 0; current_vector < block_size; current_vector++)    {      QccVectorCopy(tmp_dataset.vectors[0],                    dataset->vectors[current_vector],                    vector_dimension);            if (QccVQVectorQuantization(&tmp_dataset, codebook,                                   (QccVector)&winning_distortion, &winner,                                  distortion_measure))        {          QccErrorAddMessage("(QccAVQPaulEncode): Error calling QccVQVectorQuantization()");          goto QccAVQError;        }            QccVectorCopy(new_codeword_symbol->vector,                    dataset->vectors[current_vector],                    vector_dimension);      QccAVQSideInfoCodebookCoder(sideinfo, new_codeword_symbol);      if (winning_distortion > distortion_threshold)        {          /*  Update codebook  */          QccVectorCopy((QccVector)codebook->codewords[codebook_size - 1],                         new_codeword_symbol->vector, vector_dimension);          if (QccVQCodebookMoveCodewordToFront(codebook,                                                codebook_size - 1))            {              QccErrorAddMessage("(QccAVQPaulEncode): Error calling QccVQCodebookMoveCodewordToFront()");              goto QccAVQError;            }                    channel->channel_symbols[current_vector] = QCCCHANNEL_NULLSYMBOL;                    if (QccAVQPaulSendSideInfo(sideinfo, new_codeword_symbol,                                      QCCAVQSIDEINFO_FLAG_UPDATE))            {              QccErrorAddMessage("(QccAVQPaulEncode): Error calling QccAVQPaulSendSideInfo()");              goto QccAVQError;            }        }      else        {          /*  No codebook update  */          QccVQCodebookMoveCodewordToFront(codebook, winner);          channel->channel_symbols[current_vector] = winner;                    if (QccAVQPaulSendSideInfo(sideinfo, NULL,                                      QCCAVQSIDEINFO_FLAG_NOUPDATE))            {              QccErrorAddMessage("(QccAVQPaulEncode): Error calling QccAVQPaulSendSideInfo()");              goto QccAVQError;            }        }    }    return_value = 0;  goto QccAVQExit;   QccAVQError:  return_value = 1; QccAVQExit:  QccDatasetFree(&tmp_dataset);  if (new_codeword_symbol != NULL)    QccAVQSideInfoSymbolFree(new_codeword_symbol);  return(return_value);}int QccAVQPaulDecode(QccDataset *dataset,                     QccVQCodebook *codebook,                     const QccChannel *channel,                     QccAVQSideInfo *sideinfo){  int return_value;  int vector_dimension, block_size, codebook_size;  int current_vector;  QccAVQSideInfoSymbol *current_symbol = NULL;    if ((dataset == NULL) || (codebook == NULL) || (channel == NULL) ||      (sideinfo == NULL))    return(0);  if (sideinfo->fileptr == NULL)    return(0);  if ((dataset->vectors == NULL) ||       (codebook->codewords == NULL) ||      (channel->channel_symbols == NULL))    return(0);    vector_dimension = dataset->vector_dimension;  if ((vector_dimension != codebook->codeword_dimension) ||      (vector_dimension != sideinfo->vector_dimension))    {      QccErrorAddMessage("(QccAVQPaulEncode): Codebook %s, dataset %s, and sideinfo %s",                         codebook->filename, dataset->filename, sideinfo->filename);      QccErrorAddMessage("have different vector dimensions");      goto QccAVQError;    }    if ((current_symbol = QccAVQSideInfoSymbolAlloc(vector_dimension)) == NULL)    {      QccErrorAddMessage("(QccAVQPaulDecode): Error calling QccAVQSideInfoSymbolAlloc()");      goto QccAVQError;    }    block_size = QccDatasetGetBlockSize(dataset);    codebook_size = codebook->num_codewords;    for (current_vector = 0; current_vector < block_size; current_vector++)    {      if ((current_symbol =            QccAVQSideInfoSymbolReadDesired(sideinfo,                                           QCCAVQSIDEINFO_FLAG,                                           current_symbol)) == NULL)        {          QccErrorAddMessage("(QccAVQPaulDecode): Error calling QccAVQSideInfoSymbolReadDesired()");          goto QccAVQError;        }

⌨️ 快捷键说明

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