Changeset 1023 in SHVCSoftware


Ignore:
Timestamp:
6 Feb 2015, 19:21:09 (10 years ago)
Author:
interdigital
Message:
  1. add code to support base layer bitstream extraction
  2. keep VPS for rewriting process so the output bitstream can be decoded by HM
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-dev/source/App/utils/ExtractAddLS/ExtractAddLS.c

    r1005 r1023  
    277277  NalUnitHeader nalu;
    278278  int numStartCodeZeros;
    279   int nalIsSpsPpsEob;
     279  int nalIsVpsSpsPpsEob;
    280280  int nalIsVpsSpsPpsEos;
    281281  int removeNal;
     
    289289  {
    290290    fprintf(stderr, "\n  Usage: ExtractAddLS <infile> <outfile> <max temporal ID> <list of layer IDs> \n\n");
    291     fprintf(stderr, "  If only one layer ID is given, independent non-base layer rewriting process\n");
    292     fprintf(stderr, "  is performed\n");
     291    fprintf(stderr, "  If only one layer ID 0 is given, base layer extration process is performed\n");
     292    fprintf(stderr, "  If only one non-zero layer ID is given, independent non-base layer rewriting\n");
     293    fprintf(stderr, "  process is performed\n");
    293294    fprintf(stderr, "  If more than one layer ID is given, sub-bitstream extraction process for\n");
    294295    fprintf(stderr, "  additional layer sets is performed (Layer ID list should exactly match\n");
     
    321322  {
    322323    layerIdListTarget[layerIdx] = atoi(argv[i]);
    323     if (layerIdListTarget[layerIdx] < 1 || layerIdListTarget[layerIdx] > 7)
     324    if (layerIdListTarget[layerIdx] < 0 || layerIdListTarget[layerIdx] > 7)
    324325    {
    325326      fprintf(stderr, "Invalid layer ID (must be in range 1-7)\n");
     
    345346    if (numLayerIds == 1)
    346347    {
    347       /* independent non-base layer rewriting process */
    348 
    349       nalIsSpsPpsEob = (nalu.nalUnitType == NAL_UNIT_SPS || nalu.nalUnitType == NAL_UNIT_PPS || nalu.nalUnitType == NAL_UNIT_EOB);
    350 
    351       removeNal = (!nalIsSpsPpsEob && (nalu.nuhLayerId != assignedBaseLayerId))
    352                 || (nalIsSpsPpsEob && (nalu.nuhLayerId != 0) && (nalu.nuhLayerId != assignedBaseLayerId))
    353                 || (nalu.nalUnitType == NAL_UNIT_VPS)
    354                 || ((nalu.nuhTemporalIdPlus1 - 1) > tIdTarget);
    355 
     348      /* base layer or independent non-base layer bitstream extraction */
     349
     350      /* temporary keep VPS so the extracted/rewriting bitstream can be decoded by HM */
     351      nalIsVpsSpsPpsEob = (nalu.nalUnitType == NAL_UNIT_VPS || nalu.nalUnitType == NAL_UNIT_SPS || nalu.nalUnitType == NAL_UNIT_PPS || nalu.nalUnitType == NAL_UNIT_EOB);
     352      removeNal = (!nalIsVpsSpsPpsEob && (nalu.nuhLayerId != assignedBaseLayerId))
     353                  || (nalIsVpsSpsPpsEob && (nalu.nuhLayerId != 0))
     354                  || ((nalu.nuhTemporalIdPlus1 - 1) > tIdTarget);
    356355      nalu.nuhLayerId = 0;
    357356    }
     
    403402      i = 0;
    404403
    405       if (numLayerIds > 1 && nalu.nalUnitType == NAL_UNIT_VPS)
     404      if (numLayerIds == 1 && nalu.nalUnitType == NAL_UNIT_VPS)
     405      {
     406        char nalByte = fgetc(inFile);
     407        nalByte = nalByte | (0x0C);  // set vps_max_layers_minus1 bits(5-4) to 0 for HM decoder
     408        nalByte = nalByte & ~(0x03); // set vps_max_layers_minus1 bits(3-0) to 0 for HM decoder
     409        fputc(nalByte, outFile);
     410        i++;
     411        nalByte = fgetc(inFile);
     412        nalByte = nalByte & ~(0xF0);
     413        fputc(nalByte, outFile);
     414        i++;
     415      }
     416      else if (numLayerIds > 1 && nalu.nalUnitType == NAL_UNIT_VPS)
    406417      {
    407418        /* sub-bitstream extraction process for additional layer sets */
Note: See TracChangeset for help on using the changeset viewer.