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

📄 gethdr.c

📁 H.263的压缩算法
💻 C
📖 第 1 页 / 共 2 页
字号:
      {        PAR_width = getbits (8);        PAR_height = getbits (8);      }    }    if (source_format != SF_CUSTOM)    {        horizontal_size = lines[source_format];        vertical_size = pels[source_format];    }    mb_width = horizontal_size / 16;    mb_height = vertical_size / 16;   /* Need to store previous (reference layer) values     * for interpolation purposes, as the new values,     * i.e. of the spatially scaled layer, depend on     * the type of spatial scalability in use. */    ref_coded_picture_width = coded_picture_width;    coded_picture_width = horizontal_size;    ref_coded_picture_height = coded_picture_height;    coded_picture_height = vertical_size;    ref_chrom_width = chrom_width;     chrom_width = coded_picture_width >> 1;    ref_chrom_height = chrom_height;    chrom_height = coded_picture_height >> 1;        if (optional_custom_PCF)    {      if (trace)        fprintf (trace_file, "\noptional_custom_PCF \n");      if (UFEP)      {        clock_conversion_code = getbits (1);        if (trace)        {          fprintf (trace_file, "\nclock_conversion_code: ");          printbits (clock_conversion_code, 1, 1);        }        clock_divisor = getbits (7);        if (trace)        {          fprintf (trace_file, "\nclock_divisor: ");          printbits (clock_divisor, 7, 7);        }        CP_clock_frequency = (int) (1800 / ((float) clock_divisor * (8 + clock_conversion_code)) * 1000);      }      /* regardless of the value of UFEP */      extended_temporal_reference = getbits (2);      if (trace)      {        fprintf (trace_file, "\nextended_temporal_reference: ");        printbits (extended_temporal_reference, 2, 2);      }      temp_ref = extended_temporal_reference << 8 + temp_ref;      if (PCT_B == pict_type)      {        true_b_trb = temp_ref - prev_non_disposable_temp_ref;      } else      {        trd = temp_ref - prev_non_disposable_temp_ref;      }      if (trd < 0)        trd += 1024;    }    if (UFEP && long_vectors)    {      if (getbits(1))       {        unlimited_unrestricted_motion_vectors = 0;        if (trace)        {          fprintf (trace_file, "\nunlimited_unrestricted_motion_vectors indicator: ");          printbits (1, 1, 1);        }      }      else       {        flushbits(1);        unlimited_unrestricted_motion_vectors = 1;        if (trace)        {          fprintf (trace_file, "\nunlimited_unrestricted_motion_vectors indicator: ");          printbits (1, 2, 2);        }      }    }    if (UFEP && slice_structured_mode)    {      SSS_rectangular_slices = getbits (1);      if (trace)      {        fprintf (trace_file, "\nSSS_rectangular_slices: ");        printbits (SSS_rectangular_slices, 1, 1);      }      SSS_arbitary_slice_ordering = getbits (1);      if (trace)      {        fprintf (trace_file, "\nSSS_arbitary_slice_ordering: ");        printbits (SSS_arbitary_slice_ordering, 1, 1);      }    }    if ((pict_type == PCT_B) || (pict_type == PCT_EI) || (pict_type == PCT_EP))    {      /* optional temporal, SNR and spatial scalability mode in use */      enhancement_layer_num = getbits (4);      if (trace)      {        fprintf (trace_file, "\nenhancement_layer_num: ");        printbits (enhancement_layer_num, 4, 4);      }      if (UFEP)      {        reference_layer_number = getbits (4);        if (trace)        {          fprintf (trace_file, "\nreference_layer_number: ");          printbits (reference_layer_number, 4, 4);        }      }      if (1 != enhancement_layer_num)      {        if (source_format != base_source_format)        {          if (source_format != SF_CUSTOM)          {            scalability_mode = SPATIAL_SCALABILITY_HV;          }          else if (coded_picture_width != ref_coded_picture_width)          {            scalability_mode = SPATIAL_SCALABILITY_H;          }          else           {            scalability_mode = SPATIAL_SCALABILITY_V;          }        }        else        {          scalability_mode = SNR_SCALABILITY;        }      }       }    else    {      enhancement_layer_num = reference_layer_number = 1;    }    if (reference_picture_selection_mode)    {      if (UFEP)      {        MF_of_reference_picture_selection = getbits (3);        if (trace)        {          fprintf (trace_file, "\nMF_of_reference_picture_selection: ");          printbits (MF_of_reference_picture_selection, 3, 3);        }      }      TRPI = getbits (1);      if (trace)      {        fprintf (trace_file, "\nTRPI: ");        printbits (TRPI, 1, 1);      }      if (TRPI)      {        /* temporal reference for prediction exists */                temporal_reference_for_prediction = getbits (10);        if (trace)        {          fprintf (trace_file, "\ntemporal_reference_for_prediction: ");          printbits (temporal_reference_for_prediction, 10, 10);        }       }      if (showbits (1))      {        /* backward channel message exists */        /* BCM(backward channel message) is not implemented */        flushbits (1);        if (!quiet)          printf ("error: BCM(backward channel message) is not implemented in this version\n");        exit (-1);      }      else      {        /* BCM is not present */        BCI = getbits (2);        if (trace)        {          fprintf (trace_file, "\nBCI: ");          printbits (BCI, 2, 2);        }      }      }    if (reference_picture_resampling_mode)    {        /* reading RPRP info is not implemented */      if (!quiet)        printf ("error: RPRP reading is not implemented in this version\n");      exit (-1);    }    pic_quant = getbits (5);    quant = pic_quant;    if (trace)    {      fprintf (trace_file, "\nquant: ");      printbits (quant, 5, 5);    }  }   else  {    plus_type = 0;    rtype = 0;    source_format = tmp;    enhancement_layer_num = reference_layer_number = 1;    horizontal_size = lines[source_format];    vertical_size = pels[source_format];    mb_width = horizontal_size / 16;    mb_height = vertical_size / 16;    /* Need to store previous (reference layer) values      * for interpolation purposes, as the new values,      * i.e. of the spatially scaled layer, depend on      * the type of spatial scalability in use. */    ref_coded_picture_width = coded_picture_width = horizontal_size;    ref_coded_picture_height = coded_picture_height = vertical_size;    ref_chrom_width = chrom_width = coded_picture_width >> 1;    ref_chrom_height = chrom_height = coded_picture_height >> 1;    true_B_frame = OFF;    prev_non_disposable_temp_ref = next_non_disposable_temp_ref;    next_non_disposable_temp_ref = temp_ref;    trd = temp_ref - prev_non_disposable_temp_ref;    if (trd < 0)      trd += 256;    pict_type = getbits (1);    if (trace)    {      fprintf (trace_file, "\npict_type: ");      printbits (pict_type, 1, 1);    }    mv_outside_frame = getbits (1);    if (trace)    {      fprintf (trace_file, "\nmv_outside_frame: ");      printbits (mv_outside_frame, 1, 1);    }    long_vectors = (mv_outside_frame ? 1 : 0);    syntax_arith_coding = getbits (1);    if (trace)    {      fprintf (trace_file, "\nsyntax_arith_coding: ");      printbits (syntax_arith_coding, 1, 1);    }    adv_pred_mode = getbits (1);    if (trace)    {      fprintf (trace_file, "\nadv_pred_mode: ");      printbits (adv_pred_mode, 1, 1);    }    mv_outside_frame = (adv_pred_mode ? 1 : mv_outside_frame);    overlapping_MC = (adv_pred_mode ? 1 : 0);    use_4mv = (adv_pred_mode ? 1 : 0);    pb_frame = getbits (1);    if (trace)    {      fprintf (trace_file, "\npb_frame: ");      printbits (pb_frame, 1, 1);    }       pic_quant = getbits (5);    quant = pic_quant;    if (trace)    {      fprintf (trace_file, "\nquant: ");      printbits (quant, 5, 5);    }    tmp = getbits (1);    if (trace)    {      fprintf (trace_file, "\nCPM: ");      printbits (tmp, 5, 5);    }    if (tmp)    {      if (!quiet)        printf ("error: CPM not supported in this version\n");      exit (-1);    }  }  if (pb_frame)  {    if (optional_custom_PCF)    {      trb = getbits (5);      if (trace)      {        fprintf (trace_file, "\ntrb: ");        printbits (trb, 5, 5);      }    } else    {      trb = getbits (3);      if (trace)      {        fprintf (trace_file, "\ntrb: ");        printbits (trb, 3, 3);      }    }    bquant = getbits (2);    if (trace)    {      fprintf (trace_file, "\nbquant: ");      printbits (bquant, 2, 2);    }  } else  {    trb = 0;  }#ifdef USE_TIME  if (framerate > 0 && trd > 0)    doframerate (0);#endif  pei = getbits (1);  if (trace)  {    fprintf (trace_file, "\npei: ");    printbits (pei, 1, 1);  }pspare:  if (pei)  {    /* extra info for possible future backward compatible additions */    getbits (8);                /* not used */    pei = getbits (1);    if (pei)      goto pspare;              /* keep on reading pspare until pei=0 */  }  if (verbose > 0)  {    /* $printf("picture header (byte %d)\n",(pos>>3)-4);$ */    if (verbose > 1)    {      printf ("  temp_ref=%d\n", temp_ref);      /* $printf("  pict_type=%d\n",pict_type); printf("       * source_format=%d\n", source_format); printf("       * quant=%d\n",quant); if (syntax_arith_coding) printf("  SAC coding       * mode used \n"); if (mv_outside_frame) printf("  unrestricted       * motion vector mode used\n"); if (adv_pred_mode) printf("       * advanced prediction mode used\n");$ */      if (pb_frame)      {        /* $printf("  pb-frames mode used\n");$ */        printf ("  trb=%d\n", trb);        /* $printf("  bquant=%d\n", bquant);$ */      }    }  }  if (trace)  {    fprintf (trace_file, "\n--------------------------------------------------------\n");  }}/* get the GOB header *//* author: <guyc@ece.ubc.ca */void getgobheader(){  int BCI = 0;    /* GFID is not allowed to change unless PTYPE in picture header   * changes */  gfid = getbits (2);  if (trace)  {    fprintf (trace_file, "\ngfid: ");    printbits (gfid, 2, 2);  }  /* NB: in error-prone environments the decoder can use this  * value to determine whether a picture header where the PTYPE  * has changed, has been lost */  /* we now use it and assume that a picture change is *   * from INTRA to INTER or INTER to INTRA only */  if (gfid != pgfid && newgob)  {    if (pict_type == PCT_INTRA)      pict_type = PCT_INTER;    else if (pict_type == PCT_INTER)      pict_type = PCT_INTRA;  }    quant = getbits (5);  if (trace)  {    fprintf (trace_file, "\nquant: ");    printbits (quant, 5, 5);  }  /* Support for Annex N at the GOB level */  if (reference_picture_selection_mode)  {    TRI = getbits (1);    if (trace)    {      fprintf (trace_file, "\nTRI: ");      printbits(TRI,1,1);    }    if (TRI)    {      /* Temporal reference of GOB */      temp_ref = optional_custom_PCF?getbits (10):getbits(8);      if (trace)      {        fprintf (trace_file, "\ntemp_ref: ");        printbits (temp_ref, optional_custom_PCF?10:8, optional_custom_PCF?10:8);      }    }    /* Temporal Reference for Prediction indication bit */    TRPI = getbits (1);    if (trace)    {      fprintf (trace_file, "\nTRPI: ");      printbits (TRPI, 1, 1);    }    if (TRPI)    {      /* temporal reference for prediction exists */      temporal_reference_for_prediction = getbits (10);      if (trace)      {        fprintf (trace_file, "\ntemporal_reference_for_prediction: ");        printbits (temporal_reference_for_prediction, 10, 10);      }     }    if (showbits (1))    {      /* backward channel message exists */      /* BCM(backward channel message) is not implemented */      flushbits (1);      if (!quiet)        printf ("error: BCM(backward channel message) is not implemented in this version\n");      exit (-1);    }    else    {      /* BCM is not present */      BCI = getbits (2);      if (trace)      {        fprintf (trace_file, "\nBCI: ");        printbits (BCI, 2, 2);      }    }    }  pgfid = gfid;}void initoptions (){  mv_outside_frame = 0;  syntax_arith_coding = 0;  adv_pred_mode = 0;  pb_frame = 0;  long_vectors = 0;  plus_type = 0;  optional_custom_PCF = 0;  advanced_intra_coding = 0;  deblocking_filter_mode = 0;  slice_structured_mode = 0;  reference_picture_selection_mode = 0;  independently_segmented_decoding_mode = 0;  alternative_inter_VLC_mode = 0;  modified_quantization_mode = 0;  reduced_resolution_update_mode = 0;  reference_picture_resampling_mode = 0;  rtype = 0;}

⌨️ 快捷键说明

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