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

📄 main.c

📁 H.263的压缩算法
💻 C
📖 第 1 页 / 共 5 页
字号:
  use_4mv = DEF_ADV_MODE || DEF_DF_MODE;  overlapping_MC = DEF_ADV_MODE;  force_intra = DEF_FORCE_INTRA;  intra_mb_refresh = DEF_INTRA_MB_REFRESH;  if (improved_pb_frames || advanced_intra_coding || deblocking_filter ||      slice_structure || pic->reference_picture_selection ||      independent_segment_decoding || alternative_inter_vlc ||      modified_quantization || scalability_mode ||       reference_picture_resampling || reduced_resolution_update ||      successive_B_frames)  {    EPTYPE = 1;  }  else  {    EPTYPE = 0;  }    pic->RLNUM = BASE_LAYER_NUM;  pic->ELNUM = BASE_LAYER_NUM;  pic->BQUANT = DEF_BQUANT;   pic->source_format = DEF_CODING_FORMAT;  rate_control_method = DEF_RC_METHOD;  start_rate_control = DEF_START_RATE_CONTROL;  pic->seek_dist = DEF_SEEK_DIST;  pic->use_gobsync = DEF_INSERT_SYNC;  pic->sync = 0;  p_picture_quant = DEF_INTER_QUANT;  i_picture_quant = DEF_INTRA_QUANT;   ref_frame_rate = (float)DEF_REF_FRAME_RATE;  chosen_frameskip = DEF_FRAMESKIP + 1;  orig_frameskip = DEF_ORIG_SKIP + 1;  seqfilename = (char *)malloc(sizeof(char)*100);  enhance_seqfilename = (char *)malloc(sizeof(char)*100);  streamname = (char *)malloc(sizeof(char)*100);  outputfile =  (char *)malloc(sizeof(char)*100);  outputfile_enhance =  (char *)malloc(sizeof(char)*100);  diff_filename=DEF_DIFFILENAME;  tracefile =  (char *)malloc(sizeof(char)*100);  seqfilename[0] = '\0';  enhance_seqfilename[0] = '\0';  strcpy(streamname, DEF_STREAMNAME);  strcpy(outputfile, DEF_OUTFILENAME);  strcpy(outputfile_enhance, DEF_OUTFILENAME_ENHANCE);  mv_outside_frame_old = DEF_UMV_MODE;  writediff = DEF_WRITE_DIFF;  trace = DEF_WRITE_TRACE;  write_repeated = DEF_WRITE_REPEATED;  prev_I_P_pic_TR = start = DEF_START_FRAME;  end = DEF_STOP_FRAME;    targetrate = 0;   /* default is variable bit rate (fixed quantizer) will be used */  frames = 0;  pframes = 0;  bframes = 0;  Bframes = 0;  total_frames_passed = 0;  pic->PB = 0;  wcopies = icopies = 1;  headerlength = DEF_HEADERLENGTH;  pic->TR = 0;  pic->QP_mean = (float)0.0;  pic->UFEP = 1;  pic->PCF = 0;  pic->TRPI = 0;  pic->PEI = 0;  pic->MODB =0;  pic->GFID = 0;  /* Initialize random generator */  srand(time(NULL));}void ProcessArguments(int argc, char *argv[], Pict *pic){  int i;  for (i = 1; i < argc; i++)   {    if (*(argv[i]) == '-') 	  {     switch(*(++argv[i]))      {        case 'a':          prev_I_P_pic_TR = start = atoi(argv[++i]);          break;        case 'b':          end = atoi(argv[++i]);          break;        case 'c':          successive_B_frames = atoi(argv[++i]);          EPTYPE = ON;          break;        case 'd':          b_picture_quant = atoi(argv[++i]);          if (b_picture_quant > 31 || b_picture_quant < 0)           {            fprintf(stderr,"b_picture_quant out of range - clipping it\n");            b_picture_quant = mmin(31,mmax(0,b_picture_quant));          }          break;        case 'e':          headerlength = atoi(argv[++i]);          break;        case 'f':          force_intra = atoi(argv[++i]);          break;        case 'g':          pic->use_gobsync = atoi(argv[++i]);;          break;        case 'H':          case 'h':          Help();          exit(0);          break;        case 'i':          strcpy(seqfilename, argv[++i]);          break;        case 'j':          intra_mb_refresh = atoi(argv[++i]);          break;        case 'k':          chosen_frameskip = atoi(argv[++i]) + 1;          break;        case 'l':          orig_frameskip = atoi(argv[++i]) + 1;          break;        case 'm':          write_repeated = ON;          break;        case 'o':          strcpy(outputfile, argv[++i]);          break;        case 'q':          p_picture_quant = atoi(argv[++i]);          if (p_picture_quant > 31 || p_picture_quant < 0)           {            fprintf(stderr,"p_picture_quant out of range - clipping it\n");            p_picture_quant = mmin(31,mmax(0,p_picture_quant));          }          break;        case 'r':          targetrate = atoi(argv[++i]);          break;        case 's':          pic->seek_dist = atoi(argv[++i]);          break;        case 't':          trace = 1;          break;		    case 'u':          scalability_mode = atoi(argv[++i]);          EPTYPE = ON;          break;		    case 'v':          enhancement_layer_quant = atoi(argv[++i]);          if (enhancement_layer_quant > 31 || enhancement_layer_quant < 0)           {            fprintf(stderr,"enhancement_layer_quant out of range - clipping it\n");            enhancement_layer_quant = mmin(31,mmax(0,enhancement_layer_quant));          }          break;        case 'w':          writediff = ON;          break;        case 'x':	        pic->source_format =  atoi(argv[++i]);          if (pic->source_format == SF_CUSTOM)          {            EPTYPE = 1;            pels = atoi(argv[++i]);            lines = atoi(argv[++i]);          }	        break;        case 'A':          i_picture_quant = atoi(argv[++i]);          if (i_picture_quant > 31 || i_picture_quant < 0)           {            fprintf(stderr,"i_picture_quant out of range - clipping it\n");            i_picture_quant = mmin(31,mmax(0,i_picture_quant));          }          break;        case 'B':          strcpy(streamname, argv[++i]);          break;        case 'C':          rate_control_method = atoi(argv[++i]);          break;        case 'D':          /* note that the Unrestricted Motion Vector mode turns on            * both long_vectors and mv_outside_frame */          pic->unrestricted_mv_mode = ON;          mv_outside_frame = ON;          long_vectors = ON;          switch (atoi(argv[++i]))           {            case  2:               /* use H.263+ Annex D (RVLC) */              EPTYPE = ON;              break;            case  3:              /* use H.263+ Annex D (RVLC), unlimited range */              EPTYPE = ON;              unlimited_unrestricted_motion_vectors = ON;              break;            case  1:              fprintf(stderr,"If any H.263+ PLUS options are enabled UMV default to RVLC, limited search range\n");              break;            default:              fprintf(stderr,"Setting UMV to default RVLC, limited search range\n");              --i;              EPTYPE = ON;                            break;          }          break;        case 'E':          syntax_arith_coding = ON;          break;        case 'F':          /* note that the Advanced Prediction mode turns on both            * advanced (8x8 vectors and OBMC) and mv_outside_frame */          /* the Extended Motion Vector mode is included in the           * Unrestricted Motion Vector mode, which of course can be           * use together with the Advanced Prediction mode */          overlapping_MC = ON;          adv_pred = ON;          use_4mv = ON;          mv_outside_frame = ON;          break;        case 'G':          pb_frames = ON;          break;        case 'I':          advanced_intra_coding = ON;                  EPTYPE = ON;                  break;        case 'J':          /* see table J.1 in H.263+ standard for dependencies */          deblocking_filter = ON;          mv_outside_frame = ON;          use_4mv = ON;                 EPTYPE = ON;           break;        case 'K':          slice_structure = ON;          EPTYPE = ON;           break;        case 'M':          improved_pb_frames = ON;	        EPTYPE = ON;          break;        case 'N':          pic -> reference_picture_selection = ON;          EPTYPE = ON;          if (*(argv[i+1]) != '-')          {            number_of_threads = atoi(argv[++i]);            frames_per_thread = atoi(argv[++i]);          }          if (*(argv[i+1]) != '-')            sync_gobs_per_frame = atoi(argv[++i]);          break;        case 'O':          strcpy(enhance_seqfilename, argv[++i]);          break;        case 'P':          reference_picture_resampling = ON;          EPTYPE = ON;           break;        case 'Q':           reduced_resolution_update = ON;          EPTYPE = ON;           break;        case 'R':          independent_segment_decoding = ON;          EPTYPE = ON;           break;        case 'S':          alternative_inter_vlc = ON;          EPTYPE = ON;           break;        case 'T':          modified_quantization = ON;          EPTYPE = ON;           break;        case 'U':          pic->BQUANT = atoi(argv[++i]);          break;        case 'Z':          ref_frame_rate = (float)atoi(argv[++i]);          break;        default:          fprintf(stderr,"Illegal option: %c\n",*argv[i]);          Help();          exit(-1);          break;      }    }   }  switch (pic->source_format)   {  case (SF_SQCIF):    fprintf(stdout, "Encoding format: SQCIF (128x96)\n");    pels = 128;    lines = 96;    break;  case (SF_QCIF):    fprintf(stdout, "Encoding format: QCIF (176x144)\n");    pels = 176;    lines = 144;    break;  case (SF_CIF):    fprintf(stdout, "Encoding format: CIF (352x288)\n");    pels = 352;    lines = 288;    break;  case (SF_4CIF):    fprintf(stdout, "Encoding format: 4CIF (704x576)\n");    pels = 704;    lines = 576;    break;  case (SF_16CIF):    fprintf(stdout, "Encoding format: 16CIF (1408x1152)\n");    pels = 1408;    lines = 1152;    break;  case (SF_CUSTOM):    if ((pels%16) || (lines%16))     {      fprintf(stdout, "Error: only custom format multiple of 16 supported\n");      exit(-1);    }     else     {      fprintf(stdout, "Encoding format: custom (%dx%d)\n", pels, lines);      break;    }   default:    fprintf(stderr,"Illegal coding format\n");    exit(-1);  }  cpels = pels/2;  base_pels = pels;  base_lines = lines;  enhancement_pels  = pels*scal_tab[0][scalability_mode];  enhancement_lines = lines*scal_tab[1][scalability_mode];  if (seqfilename[0] == '\0')   {    fprintf(stderr,"Required input parameter \'-i <filename>\' missing\n");    Help();    exit(-1);  }  if ( (scalability_mode>=3) && enhance_seqfilename[0] == '\0')   {    fprintf(stderr,"No enhancement layer input sequence has been specified \'-O <filename>\'.\n");    fprintf(stderr,"Ehancement layer sequence will be generated from base layer sequence.\n");  }  /* Can now use rate control on P frames and B frames will be inserted accordingly */  /* if (successive_B_frames && (targetrate > 0) )   {     fprintf(stderr,"Warning:");     fprintf(stderr,"Variable frame rate and temporal scalability not supported\n");     fprintf(stderr,"Resetting to fixed frame rate\n");     targetrate = 0;   } */      /* Prevents the number of B-frames inserted between P-frames (option -c) from  */  /* exceeding the frames skipped in the original sequence (option -k). */  if (successive_B_frames >= chosen_frameskip)  {    fprintf(stderr,"Warning:");    fprintf(stderr,"Number of B-frames %d can not exceeded the number of frames skipped\n",successive_B_frames);    fprintf(stderr,"between the P-frames (option -k). Option -c is reset to %d.\n",(chosen_frameskip - 1) );    successive_B_frames = chosen_frameskip - 1;  }  if (successive_B_frames && (pb_frames || improved_pb_frames))  {    fprintf(stderr,"Warning:");    fprintf(stderr,"Encoder supports either PB frames or true B pictures, not both.\n");

⌨️ 快捷键说明

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