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

📄 poly.cpp

📁 1、简介 此代码是IS0 13818-5 MPEG2系统层协议分析代码
💻 CPP
字号:
/* Copyright (C) 1995, Tektronix Inc. All Rights Reserved. * *   Usage Restrictions * * License is granted to copy, to use, and to make and to use derivative * works for research and evaluation purposes only. * *   Disclaimer of Warranty * * These software programs are available to the user without any license * fee or royalty on an "as is" basis.  Tektronix Inc. disclaims any and * all warranties, whether express, implied, or statuary, including any * implied warranties or merchantability or of fitness for a particular * purpose.  In no event shall the copyright-holder be liable for any  * incidental, punitive, or consequential damages of any kind whatsoever * arising from the use of these programs. * * This disclaimer of warranty extends to the user of these programs and * user's customers, employees, agents, transferees, successors, and * assigns. * * The Tektronix Inc. does not represent or warrant that the programs * furnished hereunder are free of infringement of any third-party * patents.*//* Poly implementation */#include "Poly.H"extern "C"{#include <stdio.h>}static unsigned short int g[] ={0,1,1,0,1,1,0,1, 1,0,1,1,1,0,0,0, 1,0,0,0,0,0,1,1, 0,0,1,0,0,0,0,0};Poly::Poly (){  for (int i=0; i<32; i++)    shift_reg[i] = 1;}void Poly::push_bit (char data_bit) // data_bit range = '0', '1'{  int i;  char obit;    obit = data_bit -= '0';    data_bit ^= shift_reg[31];  i = 31;  while (i !=0)    {      if (g[i])	shift_reg[i] = shift_reg[i-1] ^ data_bit;      else	shift_reg[i] = shift_reg[i-1];      i--;    }  shift_reg[0] = data_bit;}int Poly::poly_cmp (char* bstr) {    char bit;    int    i;    unsigned long vali, valg;    // bit 31 is MSB    vali = valg = 0;    for (i=31; i >= 0; i--)      {	vali <<=  1;	valg <<=  1;	vali += bstr[i] - '0'; 	valg += shift_reg[i];       }    if ( vali == valg) return 1;    else if ( vali == ~valg ) return 2;    else return 0;}void Poly::print_bits (){  for (int i = 31; i >= 0; --i)    putc('0'+shift_reg[i], stdout);}

⌨️ 快捷键说明

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