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

📄 paul.c

📁 spiht for linux this is used to decod and encode vedio i wich all enjoy
💻 C
📖 第 1 页 / 共 2 页
字号:
            if (current_symbol->flag == QCCAVQSIDEINFO_FLAG_UPDATE)        {          /*  Update codebook  */          if ((current_symbol =                QccAVQSideInfoSymbolReadDesired(sideinfo,                                               QCCAVQSIDEINFO_VECTOR,                                               current_symbol)) == NULL)            {              QccErrorAddMessage("(QccAVQPaulDecode): Error calling QccAVQSideInfoSymbolReadDesired()");              goto QccAVQError;            }          QccVectorCopy((QccVector)codebook->codewords[codebook_size - 1],                         current_symbol->vector, vector_dimension);          if (QccVQCodebookMoveCodewordToFront(codebook,                                                codebook_size - 1))            {              QccErrorAddMessage("(QccAVQPaulEncode): Error calling QccVQCodebookMoveCodewordToFront()");              goto QccAVQError;            }        }      else        {          /*  No codebook update  */          if (QccVQCodebookMoveCodewordToFront(codebook,                                               channel->channel_symbols[current_vector]))            {              QccErrorAddMessage("(QccAVQPaulEncode): Error calling QccVQCodebookMoveCodewordToFront()");              goto QccAVQError;            }        }            QccVectorCopy(dataset->vectors[current_vector],                    (QccVector)codebook->codewords[0],                    vector_dimension);    }    return_value = 0;  goto QccAVQExit;   QccAVQError:  return_value = 1; QccAVQExit:  if (current_symbol != NULL)    QccAVQSideInfoSymbolFree(current_symbol);  return(return_value);}int QccAVQPaulCalcRate(QccChannel *channel,                        QccAVQSideInfo *sideinfo,                       FILE *outfile,                        double *rate,                        int verbose,                       int entropy_code_sideinfo){  int return_value;  int total_updated, num_input_vectors;  double channel_entropy;  double num_bits_channel, num_bits_sideinfo, num_bits_total;  double num_bits_sideinfo_updatevectors, num_bits_sideinfo_flags;  double total_rate, channel_rate, sideinfo_rate;  double sideinfo_updatevectors_rate, sideinfo_flags_rate;  int symbol, component;  int precision;  QccAVQSideInfoSymbol *sideinfo_symbol = NULL;  QccChannel sideinfo_channel;  double sideinfo_entropy, sideinfo_flags_entropy;  double prob1, prob2;    if ((outfile == NULL) ||      (channel == NULL) ||      (sideinfo == NULL))    return(0);    if ((sideinfo_symbol =        QccAVQSideInfoSymbolAlloc(sideinfo->vector_dimension)) == NULL)    {      QccErrorAddMessage("(QccAVQPaulCalcRate): Error calling QccAVQSideInfoSymbolAlloc()");      goto Error;    }  QccChannelInitialize(&sideinfo_channel);  sideinfo_channel.channel_length = channel->channel_length *    sideinfo->vector_dimension;  sideinfo_channel.alphabet_size = sideinfo->codebook_coder.num_levels;  sideinfo_channel.access_block_size = QCCCHANNEL_ACCESSWHOLEFILE;  if (QccChannelAlloc(&sideinfo_channel))    {      QccErrorAddMessage("(QccAVQPaulCalcRate): Error calling QccChannelAlloc()");      goto Error;    }  sideinfo_channel.channel_length = 0;  num_input_vectors = sideinfo->N;  total_updated = 0;  for (symbol = 0; symbol < num_input_vectors; symbol++)    {      if (QccAVQSideInfoSymbolReadNextFlag(sideinfo,                                           sideinfo_symbol) == NULL)        {          QccErrorAddMessage("(QccAVQPaulCalcRate): Error calling QccAVQSideInfoSymbolReadNextFlag()");          goto Error;        }      if (sideinfo_symbol->flag == QCCAVQSIDEINFO_FLAG_UPDATE)        {          if (QccAVQSideInfoSymbolReadDesired(sideinfo,                                              QCCAVQSIDEINFO_VECTOR,                                              sideinfo_symbol) == NULL)            {              QccErrorAddMessage("(QccAVQPaulCalcRate): Error calling QccAVQSideInfoSymbolReadDesired()");              goto Error;            }          for (component = 0; component < sideinfo->vector_dimension;               component++, sideinfo_channel.channel_length++)            sideinfo_channel.channel_symbols              [sideinfo_channel.channel_length] =               sideinfo_symbol->vector_indices[component];          total_updated++;        }    }  if ((sideinfo_entropy = QccChannelEntropy(&sideinfo_channel, 1)) < 0)    {      QccErrorAddMessage("(QccAVQPaulCalcRate): Error calling QccChannelEntropy()");      goto Error;    }  if (QccChannelRemoveNullSymbols(channel))    {      QccErrorAddMessage("(QccAVQPaulCalcRate): Error calling QccChannelRemoveNullSymbols()");      goto Error;    }  if ((channel_entropy = QccChannelEntropy(channel, 1)) < 0)    {      QccErrorAddMessage("(QccAVQPaulCalcRate): Error calling QccChannelEntropy()");      goto Error;    }    prob1 = (double)total_updated/num_input_vectors;  prob2 = 1.0 - prob1;  sideinfo_flags_entropy =    (-prob1*QccMathLog2(prob1) - prob2*QccMathLog2(prob2));  if (!entropy_code_sideinfo)    {      precision =         (int)(log((double)sideinfo->codebook_coder.num_levels)/log(2.0) + 0.5);      num_bits_sideinfo_flags = num_input_vectors;      num_bits_sideinfo_updatevectors =        total_updated * sideinfo->vector_dimension * precision;    }  else    {      num_bits_sideinfo_flags = num_input_vectors * sideinfo_flags_entropy;      num_bits_sideinfo_updatevectors =        total_updated * sideinfo->vector_dimension * sideinfo_entropy;    }  num_bits_channel = (num_input_vectors - total_updated) * channel_entropy;  num_bits_sideinfo =     num_bits_sideinfo_flags + num_bits_sideinfo_updatevectors;  num_bits_total = num_bits_channel + num_bits_sideinfo;  channel_rate = num_bits_channel/num_input_vectors/sideinfo->vector_dimension;  sideinfo_updatevectors_rate =    num_bits_sideinfo_updatevectors /     num_input_vectors/sideinfo->vector_dimension;  sideinfo_flags_rate =    num_bits_sideinfo_flags /     num_input_vectors/sideinfo->vector_dimension;  sideinfo_rate =     num_bits_sideinfo/num_input_vectors/sideinfo->vector_dimension;  total_rate =     num_bits_total/num_input_vectors/sideinfo->vector_dimension;    if (verbose >= 2)    {      fprintf(outfile,              "Rate of the Paul algorithm with channel\n   %s\n",              channel->filename);      fprintf(outfile,              "     and side information\n   %s\n",              sideinfo->filename);      fprintf(outfile,              "---------------------------------------------------\n");      fprintf(outfile,              "  Rate for VQ channel: %f\n",              channel_rate);      fprintf(outfile,              "  Rate for side information:\t");      fprintf(outfile,              "%.2f%% of vectors updated\n",              QccMathPercent(total_updated, num_input_vectors));      fprintf(outfile,              "      Rate for flags:\t\t%f (%5.2f%% of total rate)\n",              sideinfo_flags_rate,              QccMathPercent(sideinfo_flags_rate, total_rate));      fprintf(outfile,              "      Rate for update vectors:\t%f (%5.2f%% of total rate)\n",              sideinfo_updatevectors_rate,              QccMathPercent(sideinfo_updatevectors_rate, total_rate));      fprintf(outfile,              "    Total side information:\t%f (%5.2f%% of total rate)\n",              sideinfo_rate,              QccMathPercent(sideinfo_rate, total_rate));      fprintf(outfile,              "---------------------------------------------------\n");      fprintf(outfile,              "  Overall rate:      %f bits per original source symbol\n",               total_rate);    }  else    if (verbose == 1)      fprintf(outfile,              "%f\n", total_rate);    if (rate != NULL)    *rate = total_rate;    return_value = 0;  goto Return; Error:  return_value = 1; Return:  QccAVQSideInfoSymbolFree(sideinfo_symbol);  QccChannelFree(&sideinfo_channel);  return(return_value);}

⌨️ 快捷键说明

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