Problem With Global Structures

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Harry

    #1

    Problem With Global Structures


    Good Day,


    I am writing a code for the H.264 Video codec.I am using VC++
    compiler,but programming is in c only.I have grouped the related global
    variables under one structure in a header file called global.h.Like
    this i have two three structures in global.h.

    To initialise the structure members in global.h,I declared structure
    variables in c files wherever the structure members are used.

    For example
    This is one of the structure in global.h

    typedef struct
    {
    int YUV;
    int img_height;
    int img_width;
    int intra_period;
    int IntraPeriod;//period of I-frames
    int SPPicturePeriod icity; // SP-Picture Periodicity (0=not used)
    int BReferencePictu res; //Referenced B coded pictures (0=off, 1=on)
    int start_frame_no_ in_this_IGOP;
    int BitDepthLuma;
    int BitDepthChroma;
    int InterSearch16x1 6;
    int InterSearch16x8 ;
    int InterSearch8x16 ;
    int InterSearch8x8;
    int InterSearch8x4;
    int InterSearch4x8;
    int InterSearch4x4;
    int Transform8x8Mod e;
    int symbolMode;//Symbol mode (Entropy coding method: 0=UVLC, 1=CABAC)
    int EnableIPCM;
    int NoBframes;//no of b frames to be inserted
    int UseHadamard;// Hadamard SymbolModeform (0=not used, 1=used)
    int FrameSkip;//no of frames to be skipped
    int RDopt;//2 means Fast High Complexity Mode\
    }InputParameter s;


    In the above structure,for example if i want to initialize the
    img_width,img_h eight variables with some value in a c file where it is
    used,for example call it encoder.c,I have declared structure variable
    like as

    InputParameters inputs,*input=& inputs;

    Now i can initialize the variable in any of the following ways

    inputs.img_widt h=176; (or) input->img_width=17 6;
    inputs.img_heig ht=144; (or)input->img_height=144 ;

    But i am getting the following error when i comile the c file,encoder.c

    c:\documents and settings\hari\d esktop\enocoder \encoder.c(4) : error
    C2143: syntax error : missing '{' before '.'
    c:\documents and settings\hari\d esktop\enocoder \encoder.c(4) : error
    C2059: syntax error : '.'



    Can you suggest any other way for initailsing the structure member
    variables direclty with some values.....

    Thanks in advance

  • Nils O. Selåsdal

    #2
    Re: Problem With Global Structures

    Harry wrote:
    Good Day,
    >
    >
    I am writing a code for the H.264 Video codec.I am using VC++
    compiler,but programming is in c only.I have grouped the related global
    variables under one structure in a header file called global.h.Like
    this i have two three structures in global.h.
    >
    To initialise the structure members in global.h,I declared structure
    variables in c files wherever the structure members are used.
    >
    For example
    This is one of the structure in global.h
    >
    typedef struct
    {
    int YUV;
    int img_height;
    int img_width;
    int intra_period;
    int IntraPeriod;//period of I-frames
    int SPPicturePeriod icity; // SP-Picture Periodicity (0=not used)
    int BReferencePictu res; //Referenced B coded pictures (0=off, 1=on)
    int start_frame_no_ in_this_IGOP;
    int BitDepthLuma;
    int BitDepthChroma;
    int InterSearch16x1 6;
    int InterSearch16x8 ;
    int InterSearch8x16 ;
    int InterSearch8x8;
    int InterSearch8x4;
    int InterSearch4x8;
    int InterSearch4x4;
    int Transform8x8Mod e;
    int symbolMode;//Symbol mode (Entropy coding method: 0=UVLC, 1=CABAC)
    int EnableIPCM;
    int NoBframes;//no of b frames to be inserted
    int UseHadamard;// Hadamard SymbolModeform (0=not used, 1=used)
    int FrameSkip;//no of frames to be skipped
    int RDopt;//2 means Fast High Complexity Mode\
    }InputParameter s;
    >
    >
    In the above structure,for example if i want to initialize the
    img_width,img_h eight variables with some value in a c file where it is
    used,for example call it encoder.c,I have declared structure variable
    like as
    >
    InputParameters inputs,*input=& inputs;
    >
    Now i can initialize the variable in any of the following ways
    >
    inputs.img_widt h=176; (or) input->img_width=17 6;
    inputs.img_heig ht=144; (or)input->img_height=144 ;
    This is assignment not initialization, and needs to be done within a
    function body.

    If you want to initialize it:
    InputParameters inputs = { 1,2,3,4 };

    With C99, you can specify which members to initialize:
    InputParameters inputs = { .img_width=176, .img_height=144 };
    But i am getting the following error when i comile the c file,encoder.c
    >
    c:\documents and settings\hari\d esktop\enocoder \encoder.c(4) : error
    C2143: syntax error : missing '{' before '.'
    c:\documents and settings\hari\d esktop\enocoder \encoder.c(4) : error
    C2059: syntax error : '.'
    >
    >
    >
    Can you suggest any other way for initailsing the structure member
    variables direclty with some values.....
    >
    Thanks in advance
    >

    Comment

    • Harry

      #3
      Re: Problem With Global Structures


      Nils O. Selåsdal wrote:
      Harry wrote:
      Good Day,


      I am writing a code for the H.264 Video codec.I am using VC++
      compiler,but programming is in c only.I have grouped the related global
      variables under one structure in a header file called global.h.Like
      this i have two three structures in global.h.

      To initialise the structure members in global.h,I declared structure
      variables in c files wherever the structure members are used.

      For example
      This is one of the structure in global.h

      typedef struct
      {
      int YUV;
      int img_height;
      int img_width;
      int intra_period;
      int IntraPeriod;//period of I-frames
      int SPPicturePeriod icity; // SP-Picture Periodicity (0=not used)
      int BReferencePictu res; //Referenced B coded pictures (0=off, 1=on)
      int start_frame_no_ in_this_IGOP;
      int BitDepthLuma;
      int BitDepthChroma;
      int InterSearch16x1 6;
      int InterSearch16x8 ;
      int InterSearch8x16 ;
      int InterSearch8x8;
      int InterSearch8x4;
      int InterSearch4x8;
      int InterSearch4x4;
      int Transform8x8Mod e;
      int symbolMode;//Symbol mode (Entropy coding method: 0=UVLC, 1=CABAC)
      int EnableIPCM;
      int NoBframes;//no of b frames to be inserted
      int UseHadamard;// Hadamard SymbolModeform (0=not used, 1=used)
      int FrameSkip;//no of frames to be skipped
      int RDopt;//2 means Fast High Complexity Mode\
      }InputParameter s;


      In the above structure,for example if i want to initialize the
      img_width,img_h eight variables with some value in a c file where it is
      used,for example call it encoder.c,I have declared structure variable
      like as

      InputParameters inputs,*input=& inputs;

      Now i can initialize the variable in any of the following ways

      inputs.img_widt h=176; (or) input->img_width=17 6;
      inputs.img_heig ht=144; (or)input->img_height=144 ;
      This is assignment not initialization, and needs to be done within a
      function body.
      >
      If you want to initialize it:
      InputParameters inputs = { 1,2,3,4 };
      >
      With C99, you can specify which members to initialize:
      InputParameters inputs = { .img_width=176, .img_height=144 };
      >
      But i am getting the following error when i comile the c file,encoder.c

      c:\documents and settings\hari\d esktop\enocoder \encoder.c(4) : error
      C2143: syntax error : missing '{' before '.'
      c:\documents and settings\hari\d esktop\enocoder \encoder.c(4) : error
      C2059: syntax error : '.'



      Can you suggest any other way for initailsing the structure member
      variables direclty with some values.....

      Thanks in advance

      I know that this is the way to assign values to structrure member
      variables,but if there are too many variables in the structure we can't
      go on like...{2,6,7,. .......}....... what is wrong with my way of
      assigning the initial values to the structure member variables

      Comment

      • Nils O. Selåsdal

        #4
        Re: Problem With Global Structures

        Harry wrote:
        Nils O. Selåsdal wrote:
        >Harry wrote:
        >>Good Day,
        >>>
        >>>
        >>I am writing a code for the H.264 Video codec.I am using VC++
        >>compiler,bu t programming is in c only.I have grouped the related global
        >>variables under one structure in a header file called global.h.Like
        >>this i have two three structures in global.h.
        >>>
        >>To initialise the structure members in global.h,I declared structure
        >>variables in c files wherever the structure members are used.
        >>>
        >>For example
        >>This is one of the structure in global.h
        >>>
        >>typedef struct
        >>{
        >> int YUV;
        >> int img_height;
        >> int img_width;
        >> int intra_period;
        >> int IntraPeriod;//period of I-frames
        >> int SPPicturePeriod icity; // SP-Picture Periodicity (0=not used)
        >> int BReferencePictu res; //Referenced B coded pictures (0=off, 1=on)
        >> int start_frame_no_ in_this_IGOP;
        >> int BitDepthLuma;
        >> int BitDepthChroma;
        >> int InterSearch16x1 6;
        >> int InterSearch16x8 ;
        >> int InterSearch8x16 ;
        >> int InterSearch8x8;
        >> int InterSearch8x4;
        >> int InterSearch4x8;
        >> int InterSearch4x4;
        >> int Transform8x8Mod e;
        >> int symbolMode;//Symbol mode (Entropy coding method: 0=UVLC, 1=CABAC)
        >> int EnableIPCM;
        >> int NoBframes;//no of b frames to be inserted
        >> int UseHadamard;// Hadamard SymbolModeform (0=not used, 1=used)
        >> int FrameSkip;//no of frames to be skipped
        >> int RDopt;//2 means Fast High Complexity Mode\
        >>}InputParamet ers;
        >>>
        >>>
        >>In the above structure,for example if i want to initialize the
        >>img_width,img _height variables with some value in a c file where it is
        >>used,for example call it encoder.c,I have declared structure variable
        >>like as
        >>>
        >>InputParamete rs inputs,*input=& inputs;
        >>>
        >>Now i can initialize the variable in any of the following ways
        >>>
        >>inputs.img_wi dth=176; (or) input->img_width=17 6;
        >>inputs.img_he ight=144; (or)input->img_height=144 ;
        >This is assignment not initialization, and needs to be done within a
        >function body.
        >>
        >If you want to initialize it:
        >InputParameter s inputs = { 1,2,3,4 };
        >>
        >With C99, you can specify which members to initialize:
        >InputParameter s inputs = { .img_width=176, .img_height=144 };
        >>
        >>But i am getting the following error when i comile the c file,encoder.c
        >>>
        >>c:\document s and settings\hari\d esktop\enocoder \encoder.c(4) : error
        >>C2143: syntax error : missing '{' before '.'
        >>c:\document s and settings\hari\d esktop\enocoder \encoder.c(4) : error
        >>C2059: syntax error : '.'
        >>>
        >>>
        >>>
        >>Can you suggest any other way for initailsing the structure member
        >>variables direclty with some values.....
        >>>
        >>Thanks in advance
        >>>
        >
        >
        I know that this is the way to assign values to structrure member
        variables,but if there are too many variables in the structure we can't
        go on like...{2,6,7,. .......}....... what is wrong with my way of
        assigning the initial values to the structure member variables
        There is nothing wrong with that, but as I said you need to do that
        within a function body. It is unclear if your code tries to do that
        at file scope - which is not legal. So, put that code in main, or
        another function you call pretty quick..


        As I also mentioned, provided you have a C99 compiler, you can
        specify which members to initialize. I'm not sure this is supported
        by Microsoft..

        Comment

        • Harry

          #5
          Re: Problem With Global Structures


          Nils O. Selåsdal wrote:
          Harry wrote:
          Nils O. Selåsdal wrote:
          Harry wrote:
          >Good Day,
          >>
          >>
          >I am writing a code for the H.264 Video codec.I am using VC++
          >compiler,but programming is in c only.I have grouped the related global
          >variables under one structure in a header file called global.h.Like
          >this i have two three structures in global.h.
          >>
          >To initialise the structure members in global.h,I declared structure
          >variables in c files wherever the structure members are used.
          >>
          >For example
          >This is one of the structure in global.h
          >>
          >typedef struct
          >{
          > int YUV;
          > int img_height;
          > int img_width;
          > int intra_period;
          > int IntraPeriod;//period of I-frames
          > int SPPicturePeriod icity; // SP-Picture Periodicity (0=not used)
          > int BReferencePictu res; //Referenced B coded pictures (0=off, 1=on)
          > int start_frame_no_ in_this_IGOP;
          > int BitDepthLuma;
          > int BitDepthChroma;
          > int InterSearch16x1 6;
          > int InterSearch16x8 ;
          > int InterSearch8x16 ;
          > int InterSearch8x8;
          > int InterSearch8x4;
          > int InterSearch4x8;
          > int InterSearch4x4;
          > int Transform8x8Mod e;
          > int symbolMode;//Symbol mode (Entropy coding method: 0=UVLC, 1=CABAC)
          > int EnableIPCM;
          > int NoBframes;//no of b frames to be inserted
          > int UseHadamard;// Hadamard SymbolModeform (0=not used, 1=used)
          > int FrameSkip;//no of frames to be skipped
          > int RDopt;//2 means Fast High Complexity Mode\
          >}InputParamete rs;
          >>
          >>
          >In the above structure,for example if i want to initialize the
          >img_width,img_ height variables with some value in a c file where it is
          >used,for example call it encoder.c,I have declared structure variable
          >like as
          >>
          >InputParameter s inputs,*input=& inputs;
          >>
          >Now i can initialize the variable in any of the following ways
          >>
          >inputs.img_wid th=176; (or) input->img_width=17 6;
          >inputs.img_hei ght=144; (or)input->img_height=144 ;
          This is assignment not initialization, and needs to be done within a
          function body.
          >
          If you want to initialize it:
          InputParameters inputs = { 1,2,3,4 };
          >
          With C99, you can specify which members to initialize:
          InputParameters inputs = { .img_width=176, .img_height=144 };
          >
          >But i am getting the following error when i comile the c file,encoder..c
          >>
          >c:\documents and settings\hari\d esktop\enocoder \encoder.c(4) : error
          >C2143: syntax error : missing '{' before '.'
          >c:\documents and settings\hari\d esktop\enocoder \encoder.c(4) : error
          >C2059: syntax error : '.'
          >>
          >>
          >>
          >Can you suggest any other way for initailsing the structure member
          >variables direclty with some values.....
          >>
          >Thanks in advance
          >>

          I know that this is the way to assign values to structrure member
          variables,but if there are too many variables in the structure we can't
          go on like...{2,6,7,. .......}....... what is wrong with my way of
          assigning the initial values to the structure member variables
          >
          There is nothing wrong with that, but as I said you need to do that
          within a function body. It is unclear if your code tries to do that
          at file scope - which is not legal. So, put that code in main, or
          another function you call pretty quick..
          >
          >
          As I also mentioned, provided you have a C99 compiler, you can
          specify which members to initialize. I'm not sure this is supported
          by Microsoft..
          Thanks for your help dude

          Comment

          Working...