title: skipping choma part reading in yuv 420 using fseek
body: <p>I wants to read only Luma content from the 4-2-0 YUV input.
  I wrote a code for that which works fine and able to dump only luma content into a separate file.</p>
  <p><strong>CODE:</strong></p>
  <pre><code>int main() 
  {
      size_t size = 0;
      uint32_t frame_number = 0;
      
  FILE* f0_in = fopen(&quot;input_420p.yuv&quot;, &quot;r&quot;);
  if (NULL == f0_in) {
      printf(&quot;REF: Error in opening input file \n&quot;);
      return 0;
  }
  
  FILE* f0_luma = fopen(&quot;input_420p_LumaContent.y&quot;, &quot;w&quot;);
  if (NULL == f0_luma) {
      printf(&quot;REF: Error in opening output file for luma \n&quot;);
      return 0;
  }
  
  uint32_t width_luma = 1632;
  uint32_t height_luma = 1280;
  
  uint32_t width_chroma = width_luma/2;
  uint32_t height_chroma = height_luma/2;
  
  uint32_t luma_size = width_luma * height_luma;
  uint32_t chroma_size = width_chroma * height_chroma;
  
  uint32_t frame_size = luma_size + 2*chroma_size;
  
  unsigned char *inputLumaY;
  unsigned char *inputChromaCB;
  unsigned char *inputChromaCR;
  
  inputLumaY = (unsigned char*) malloc(sizeof(unsigned char) * width_luma * height_luma);
  if (inputLumaY == NULL) {
      exit (1);
  }
  
  inputChromaCB = (unsigned char*) malloc(sizeof(unsigned char) * width_chroma * height_chroma);
  if (inputChromaCB == NULL) {
      exit (1);
  }
  
  inputChromaCR = (unsigned char*) malloc(sizeof(unsigned char) * width_chroma * height_chroma);
  if (inputChromaCR == NULL) {
      exit (1);
  }
  
  /* frame loop */
  while (!feof(f0_in))
  {
  
      size =  fread(inputLumaY, 1, luma_size, f0_in);
      if (size == 0) {
          printf (&quot;REF: Error in reading luma content: %zu\n&quot;, size);
          break;
      }
  
      size += fread(inputChromaCB, 1, chroma_size, f0_in);
      if (size == 0) {
          printf (&quot;REF: Error in reading cb content: %zu\n&quot;, size);
          break;
      }
  
      size += fread(inputChromaCR, 1, chroma_size, f0_in);
      if (size == 0) {
          printf (&quot;REF: Error in reading cr content: %zu\n&quot;, size);
          break;
      }
  
  
      if (size == frame_size)
      {
          fwrite((void *)inputLumaY, sizeof(unsigned char)  , luma_size, f0_luma);
  
      }
  
      printf(&quot;Frame number:%d\n&quot;,frame_number);
  
      frame_number++;
  
  
  }
    
  free(inputChromaCR);
  free(inputChromaCB);
  free(inputLumaY);
  fclose(f0_in);
  fclose(f0_luma);
  
  return 0;
  }
  </code></pre>
  <p><strong>Query:</strong>
  I want to skip reading chroma part and wants to use <code>fseek</code> instead. So, because of fseek code will point to the next luma frame index for the next frame.</p>
  <p>Can any one suggest the way for doing so.</p>
  <p><strong>Reason:</strong> I want to operate on Luma and wants to avoid the chroma buffer allocation in code. If I will able to replace file reading for chroma, then I will remove chroma buffer allocation.</p>