View Issue Details

IDProjectCategoryView StatusLast Update
0000177JVT JM H.264/AVC reference softwareencoderpublic2009-05-08 22:54
ReporterMichael Cutler Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
Status newResolutionopen 
Product VersionJM 15.1 
Summary0000177: Error "Parsing error in quantization offset config file: '=' expected as the second token in each item."
DescriptionProblem:
--------

The default "q_offset.cfg" file provided in the ZIP file with 15.1 doesn't work with the encoder, even though it appears to be correctly formatted. I haven't made any custom configuration, I have just tried to run the samples provided in the "bin" directory and it does not work.


Steps to Reproduce:
-------------------

$ wget http://iphome.hhi.de/suehring/tml/download/jm15.1.zip
$ unzip jm15.1.zip
$ cd JM
$ make
...
$ cd bin/
$ ./lencod.exe
Setting Default Parameters...
Parsing Configfile encoder.cfg..................................................................................................................................................................................................................................................................................................................................................................................

 Parsing error in quantization offset config file: '=' expected as the second token in each item.
Parsing Quantization Offset Matrix file q_offset.cfg
$
TagsNo tags attached.

Activities

2009-05-08 16:16

 

q_offset.cfg (3,473 bytes)

Michael Cutler

2009-05-08 16:22

reporter   ~0000309

Converting the "q_offset.cfg" file using 'dos2unix' fixes this problem, could this be a bug in the way "q_offsets.c" parses the configuration files?

$ dos2unix q_offset.cfg
dos2unix: converting file q_offset.cfg to UNIX format ...
$ ./lencod.exe
Setting Default Parameters...
Parsing Configfile encoder.cfg..................................................................................................................................................................................................................................................................................................................................................................................

Parsing Quantization Offset Matrix file q_offset.cfg ....................
------------------------------- JM 15.1 (FRExt) -------------------------------
 Input YUV file : foreman_part_qcif.yuv
 Output H.264 bitstream : test.264
 Output YUV file : test_rec.yuv
 YUV Format : YUV 4:2:0
 Frames to be encoded I-P/B : 2/1
 Freq. for encoded bitstream : 30.00
 PicInterlace / MbInterlace : 0/0
 Transform8x8Mode : 1
....

Alexis Michael Tourapis

2009-05-08 22:54

developer   ~0000311

I don't consider this as an important problem, but you may try adding a check in ParseQOffsetMatrix for also '\r'. See the following code from the upcoming version 16.0

void ParseQOffsetMatrix (QuantParameters *p_Quant, char *buf, int bufsize)
{
  char *items[MAX_ITEMS_TO_PARSE] = {NULL};
  int MapIdx;
  int item = 0;
  int InString = 0, InItem = 0;
  char *p = buf;
  char *bufend = &buf[bufsize];
  int IntContent;
  int i, j, range, type, cnt;
  short *OffsetList;

  while (p < bufend)
  {
    switch (*p)
    {
      //case 13:
        //p++;
        //break;
      case '#': // Found comment
        *p = '\0'; // Replace '#' with '\0' in case of comment immediately following integer or string
        while ((*p != '\n' && *p != '\r') && p < bufend) // Skip till EOL or EOF, whichever comes first
          p++;
        InString = 0;
        InItem = 0;
        break;
      case '\n':
      case '\r':
        InItem = 0;
        InString = 0;
      *p++ = '\0';
        break;
      case ' ':
      case '\t': // Skip whitespace, leave state unchanged
        if (InString)
          p++;
        else
        { // Terminate non-strings once whitespace is found
          *p++ = '\0';
          InItem = 0;
        }
        break;

      case '"': // Begin/End of String
        *p++ = '\0';
        if (!InString)
        {
          items[item++] = p;
          InItem = ~InItem;
        }
        else
          InItem = 0;
        InString = ~InString; // Toggle
        break;

      case ',':
        p++;
        InItem = 0;
        break;

      default:
        if (!InItem)
        {
          items[item++] = p;
          InItem = ~InItem;
        }
        p++;
    }
  }

  item--;

  for (i = 0; i < item; i += cnt)
  {
    cnt = 0;
    if (0 > (MapIdx = CheckOffsetParameterName (items[i + cnt], &type)))
    {
      snprintf (errortext, ET_SIZE,
        " Parsing error in quantization offset config file: Parameter Name '%s' not recognized.",
        items[i + cnt]);
      error (errortext, 300);
    }
    cnt++;
    if (strcmp ("=", items[i + cnt]))
    {
      snprintf (errortext, ET_SIZE,
        " Parsing error in quantization offset config file: '=' expected as the second token in each item.");
      error (errortext, 300);
    }
    cnt++;

    if (!type) //4x4 Matrix
    {
      range = 16;
      OffsetList = p_Quant->OffsetList4x4input[MapIdx];
      offset4x4_check[MapIdx] = 1; //to indicate matrix found in cfg file
    }
    else //8x8 matrix
    {
      range = 64;
      OffsetList = p_Quant->OffsetList8x8input[MapIdx];
      offset8x8_check[MapIdx] = 1; //to indicate matrix found in cfg file
    }

    for (j = 0; j < range; j++)
    {
      if (1 != sscanf (items[i + cnt + j], "%d", &IntContent))
      {
        snprintf (errortext, ET_SIZE,
          " Parsing error in quantization offset file: Expected numerical value for Parameter of %s, found '%s'.",
          items[i], items[i + cnt + j]);
        error (errortext, 300);
      }

      OffsetList[j] = (short) IntContent; //save value in matrix
    }
    cnt += j;
    printf (".");
  }
}

Issue History

Date Modified Username Field Change
2009-05-08 16:14 Michael Cutler New Issue
2009-05-08 16:16 Michael Cutler File Added: q_offset.cfg
2009-05-08 16:22 Michael Cutler Note Added: 0000309
2009-05-08 22:54 Alexis Michael Tourapis Note Added: 0000311