Exemplo n.º 1
0
/*!
 ***********************************************************************
 * \brief
 *    Initialise Q matrix values.
 ***********************************************************************
 */
void Init_QMatrix (void)
{
  char *content;


  allocate_QMatrix ();

  if(input->ScalingMatrixPresentFlag)
  {
    printf ("Parsing QMatrix file %s ", input->QmatrixFile);
    content = GetConfigFileContent(input->QmatrixFile, 0);
    if(content!='\0')
      ParseMatrix(content, strlen (content));
    else
      printf("\nError: %s\nProceeding with default values for all matrices.", errortext);

    PatchMatrix();
    printf("\n");

    memset(UseDefaultScalingMatrix4x4Flag, 0, 6 * sizeof(short));
    UseDefaultScalingMatrix8x8Flag[0]=UseDefaultScalingMatrix8x8Flag[1]=0;

    free(content);
  }
}
Exemplo n.º 2
0
/*!
 ***********************************************************************
 * \brief
 *    Initialise Q matrix values.
 ***********************************************************************
 */
void init_qmatrix (VideoParameters *p_Vid, InputParameters *p_Inp)
{
  QuantParameters *p_Quant = p_Vid->p_Quant;
  ScaleParameters *p_QScale = p_Vid->p_QScale;
  char *content;

  allocate_QMatrix (p_Quant, p_Inp);

  if(p_Inp->ScalingMatrixPresentFlag)
  {
    printf ("Parsing QMatrix file %s ", p_Inp->QmatrixFile);
    content = GetConfigFileContent(p_Inp->QmatrixFile, 0);
    if(content!='\0')
      ParseMatrix(p_Vid, content, (int) strlen (content));
    else
      printf("\nError: %s\nProceeding with default values for all matrices.", errortext);

    PatchMatrix(p_Vid, p_Inp);
    printf("\n");

    memset(p_QScale->UseDefaultScalingMatrix4x4Flag, 0, 6 * sizeof(short));
    memset(p_QScale->UseDefaultScalingMatrix8x8Flag, 0, 6 * sizeof(short));

    free(content);
  }
}
/*!
 ***********************************************************************
 * \brief
 *    Initialise Q offset matrix values.
 ***********************************************************************
 */
void Init_QOffsetMatrix ()
{
  char *content;

  allocate_QOffsets ();

  if (params->OffsetMatrixPresentFlag)
  {
    printf ("Parsing Quantization Offset Matrix file %s ",
      params->QOffsetMatrixFile);
    content = GetConfigFileContent (params->QOffsetMatrixFile, 0);
    if (content != '\0')
      ParseQOffsetMatrix (content, strlen (content));
    else
    {
      printf
        ("\nError: %s\nProceeding with default values for all matrices.",
        errortext);
      params->OffsetMatrixPresentFlag = 0;
    }

    printf ("\n");

    free (content);
  }
  //! Now set up all offset params. This process could be reused if we wish to re-init offsets
  InitOffsetParam ();
}
Exemplo n.º 4
0
/*!
 ***********************************************************************
 * \brief
 *    Initialise Q offset matrix values.
 ***********************************************************************
 */
void init_qoffset (VideoParameters *p_Vid)
{
  char *content;
  InputParameters *p_Inp = p_Vid->p_Inp;

  allocate_QOffsets (p_Vid->p_Quant, p_Inp);

  if (p_Inp->OffsetMatrixPresentFlag)
  {
    printf ("Parsing Quantization Offset Matrix file %s ",
      p_Inp->QOffsetMatrixFile);
    content = GetConfigFileContent (p_Inp->QOffsetMatrixFile, 0);
    if (content != '\0')
      ParseQOffsetMatrix (p_Vid->p_Quant, content, (int) strlen (content));
    else
    {
      printf ("\nError: %s\nProceeding with default values for all matrices.", errortext);
      p_Inp->OffsetMatrixPresentFlag = 0;
    }

    printf ("\n");

    free (content);
  }
  //! Now set up all offset p_Inp. This process could be reused if we wish to re-init offsets
  InitOffsetParam (p_Vid->p_Quant, p_Inp);
}
XDAS_Int32 readparamfile(FILE * fname , int baseParamsOnly)
{
  XDAS_Int8 *FileBuffer = NULL ;
  XDAS_Int32 retVal ; 

  //read the content in a buffer
  FileBuffer = GetConfigFileContent(fname);

  if(FileBuffer)
  {
   retVal  = ParseContent(FileBuffer,strlen(FileBuffer),baseParamsOnly);
    return retVal ;
  }
  else
    return -1;
}
XDAS_Int32 readparamfile(FILE * fname)
{
  XDAS_Int8 *FileBuffer = NULL ;
  XDAS_Int32 retVal ; 

  /* Read entire content in a buffer */
  FileBuffer = GetConfigFileContent(fname);
 /* if the buffer address is NULL then return error */
  if(FileBuffer)
  {
    /* Parse every string into items and group them into triplets. 
     * Decode these ordered triplets into correspondign indices in the global
     * Token Map arrray provided by the user. 
     */
    retVal  = ParseContent(FileBuffer, strlen((xdc_Char *)FileBuffer));
    return retVal ;
  }
  else
    return -1;
}
Exemplo n.º 7
0
/*!
 ***********************************************************************
 * \brief
 *    Parse the command line parameters and read the config files.
 * \param ac
 *    number of command line parameters
 * \param av
 *    command line parameters
 ***********************************************************************
 */
void Configure (int ac, char *av[])
{
  char *content;
  int CLcount, ContentLen, NumberParams;
  char *filename=DEFAULTCONFIGFILENAME;

  memset (&configinput, 0, sizeof (InputParameters));
  //Set default parameters.
  printf ("Setting Default Parameters...\n");
  InitEncoderParams();

  // Process default config file
  CLcount = 1;

  if (ac==2)
  {
    if (0 == strncmp (av[1], "-h", 2))
    {
      JMHelpExit();
    }
  }

  if (ac>=3)
  {
    if (0 == strncmp (av[1], "-d", 2))
    {
      filename=av[2];
      CLcount = 3;
    }
    if (0 == strncmp (av[1], "-h", 2))
    {
      JMHelpExit();
    }
  }
  printf ("Parsing Configfile %s", filename);
  content = GetConfigFileContent (filename);
  if (NULL==content)
    error (errortext, 300);
  ParseContent (content, strlen(content));
  printf ("\n");
  free (content);

  // Parse the command line

  while (CLcount < ac)
  {
    if (0 == strncmp (av[CLcount], "-h", 2))
    {
      JMHelpExit();
    }
    
    if (0 == strncmp (av[CLcount], "-f", 2))  // A file parameter?
    {
      content = GetConfigFileContent (av[CLcount+1]);
      if (NULL==content)
        error (errortext, 300);
      printf ("Parsing Configfile %s", av[CLcount+1]);
      ParseContent (content, strlen (content));
      printf ("\n");
      free (content);
      CLcount += 2;
    } else
    {
      if (0 == strncmp (av[CLcount], "-p", 2))  // A config change?
      {
        // Collect all data until next parameter (starting with -<x> (x is any character)),
        // put it into content, and parse content.

        CLcount++;
        ContentLen = 0;
        NumberParams = CLcount;

        // determine the necessary size for content
        while (NumberParams < ac && av[NumberParams][0] != '-')
          ContentLen += strlen (av[NumberParams++]);        // Space for all the strings
        ContentLen += 1000;                     // Additional 1000 bytes for spaces and \0s


        if ((content = malloc (ContentLen))==NULL) no_mem_exit("Configure: content");;
        content[0] = '\0';

        // concatenate all parameters identified before

        while (CLcount < NumberParams)
        {
          char *source = &av[CLcount][0];
          char *destin = &content[strlen (content)];

          while (*source != '\0')
          {
            if (*source == '=')  // The Parser expects whitespace before and after '='
            {
              *destin++=' '; *destin++='='; *destin++=' ';  // Hence make sure we add it
            } else
              *destin++=*source;
            source++;
          }
          *destin = '\0';
          CLcount++;
        }
        printf ("Parsing command line string '%s'", content);
        ParseContent (content, strlen(content));
        free (content);
        printf ("\n");
      }
      else
      {
        snprintf (errortext, ET_SIZE, "Error in command line, ac %d, around string '%s', missing -f or -p parameters?", CLcount, av[CLcount]);
        error (errortext, 300);
      }
    }
  }
  printf ("\n");
  PatchInp();
  if (input->DisplayEncParams)
    DisplayEncoderParams();
}
Exemplo n.º 8
0
/*
*************************************************************************
* Function:Parse the command line parameters and read the config files.
* Input: ac
         number of command line parameters
      av
        command line parameters
* Output:
* Return: 
* Attention:
*************************************************************************
*/
void c_avs_enc::Configure (char *av)
{
  char *content;  
  Map[0].TokenName  =    "GOPLength";                
  Map[1].TokenName  =    "FramesToBeEncoded";        
  Map[2].TokenName  =    "QPFirstFrame";             
  Map[3].TokenName  =    "QPRemainingFrame";         
  Map[4].TokenName  =    "UseHadamard";              
  Map[5].TokenName  =    "SearchRange";              
  Map[6].TokenName  =    "NumberReferenceFrames";    
  Map[7].TokenName  =    "SourceWidth";              
  Map[8].TokenName  =    "SourceHeight";             
  Map[9].TokenName  =    "InputFile";                
  Map[10].TokenName =    "InputHeaderLength";        
  Map[11].TokenName =    "OutputFile";               
  Map[12].TokenName =    "ReconFile";                
  Map[13].TokenName =    "TraceFile";                
  Map[14].TokenName =    "NumberBFrames";            
  Map[15].TokenName =    "QPBPicture";               
  Map[16].TokenName =    "InterSearch16x16";         
  Map[17].TokenName =    "InterSearch16x8";          
  Map[18].TokenName =    "InterSearch8x16";          
  Map[19].TokenName =    "InterSearch8x8";           
  Map[20].TokenName =    "RDOptimization";           
  Map[21].TokenName =    "InterlaceCodingOption";    
  Map[22].TokenName =    "LoopFilterDisable";        
  Map[23].TokenName =    "LoopFilterParameter";      
  Map[24].TokenName =    "LoopFilterAlphaOffset";    
  Map[25].TokenName =    "LoopFilterBetaOffset";     
  Map[26].TokenName =    "Progressive_frame";        
  Map[27].TokenName =    "Dct_Adaptive_Flag";        
  Map[28].TokenName =    "NumberOfRowsInSlice";      
  Map[29].TokenName =    "SliceParameter";           
  Map[30].TokenName =    "WeightEnable";             
  Map[31].TokenName =    "FrameRate";                
  Map[32].TokenName =    "ChromaFormat";             
  Map[33].TokenName =    "RateControlEnable";        
  Map[34].TokenName =    "Bitrate";                  
  Map[35].TokenName =    "InitialQP";                
  Map[36].TokenName =    "BasicUnit";                
  Map[37].TokenName =    "ChannelType";              
  Map[38].TokenName =    NULL;                       
  Map[0].Place  = &configinput.GopLength;                 
  Map[1].Place  = &configinput.no_frames;                 
  Map[2].Place  = &configinput.qp0;                       
  Map[3].Place  = &configinput.qpN;                       
  Map[4].Place  = &configinput.hadamard;                  
  Map[5].Place  = &configinput.search_range;              
  Map[6].Place  = &configinput.no_multpred;               
  Map[7].Place  = &configinput.img_width;                 
  Map[8].Place  = &configinput.img_height;                
  Map[9].Place  = &configinput.infile;                    
  Map[10].Place = &configinput.infile_header;             
  Map[11].Place = &configinput.outfile;                   
  Map[12].Place = &configinput.ReconFile;                 
  Map[13].Place = &configinput.TraceFile;                 
  Map[14].Place = &configinput.successive_Bframe;         
  Map[15].Place = &configinput.qpB;                       
  Map[16].Place = &configinput.InterSearch16x16;          
  Map[17].Place = &configinput.InterSearch16x8 ;          
  Map[18].Place = &configinput.InterSearch8x16;           
  Map[19].Place = &configinput.InterSearch8x8 ;           
  Map[20].Place = &configinput.rdopt;                     
  Map[21].Place = &configinput.InterlaceCodingOption;     
  Map[22].Place = &configinput.loop_filter_disable;       
  Map[23].Place = &configinput.loop_filter_parameter_flag;
  Map[24].Place = &configinput.alpha_c_offset;            
  Map[25].Place = &configinput.beta_offset;               
  Map[26].Place = &configinput.progressive_frame;         
  Map[27].Place = &configinput.dct_adaptive_flag;         
  Map[28].Place = &configinput.slice_row_nr;              
  Map[29].Place = &configinput.slice_parameter;           
  Map[30].Place = &configinput.picture_weighting_flag;    
  Map[31].Place = &configinput.frame_rate_code;           
  Map[32].Place = &configinput.chroma_format;             
  Map[33].Place = &configinput.RCEnable;                  
  Map[34].Place = &configinput.bit_rate;                  
  Map[35].Place = &configinput.SeinitialQP;               
  Map[36].Place = &configinput.basicunit;                 
  Map[37].Place = &configinput.channel_type;              
  Map[38].Place = NULL;
  Map[0].Type  =  0;
  Map[1].Type  =  0;
  Map[2].Type  =  0;
  Map[3].Type  =  0;
  Map[4].Type  =  0;
  Map[5].Type  =  0;
  Map[6].Type  =  0;
  Map[7].Type  =  0;
  Map[8].Type  =  0;
  Map[9].Type  =  1;
  Map[10].Type =  0;
  Map[11].Type =  1;
  Map[12].Type =  1;
  Map[13].Type =  1;
  Map[14].Type =  0;
  Map[15].Type =  0;
  Map[16].Type =  0;
  Map[17].Type =  0;
  Map[18].Type =  0;
  Map[19].Type =  0;
  Map[20].Type =  0;
  Map[21].Type =  0;
  Map[22].Type =  0;
  Map[23].Type =  0;
  Map[24].Type =  0;
  Map[25].Type =  0;
  Map[26].Type =  0;
  Map[27].Type =  0;
  Map[28].Type =  0;
  Map[29].Type =  0;
  Map[30].Type =  0;
  Map[31].Type =  0;
  Map[32].Type =  0;
  Map[33].Type =  0;
  Map[34].Type =  0;
  Map[35].Type =  0;
  Map[36].Type =  0;
  Map[37].Type =  0;
  Map[38].Type = -1;
  
  memset (&configinput, 0, sizeof (InputParameters));
  
  // Process default config file
  // Parse the command line
  
      content = GetConfigFileContent (av);
      printf ("Parsing Configfile %s", av);
      ParseContent (content, (int_32_t)strlen (content));
      printf ("\n");
      free (content);  
  printf ("\n");
}