Exemplo n.º 1
0
int y4m_read_fields(int fd, y4m_stream_info_t *si, y4m_frame_info_t *fi,
                    unsigned char *upper_field[3], 
                    unsigned char *lower_field[3])
{
  int i, y, err;
  int width = si->width;
  int height = si->height;
  
  /* Read frame header */
  if ((err = y4m_read_frame_header(fd, fi)) != Y4M_OK) return err;
  /* Read Y', Cb, and Cr planes */
  for (i = 0; i < 3; i++) {
    unsigned char *srctop = upper_field[i];
    unsigned char *srcbot = lower_field[i];
    /* alternately write one line from each */
    for (y = 0; y < height; y += 2) {
      if (y4m_read(fd, srctop, width)) return Y4M_ERR_SYSTEM;
      srctop += width;
      if (y4m_read(fd, srcbot, width)) return Y4M_ERR_SYSTEM;
      srcbot += width;
    }
    /* for chroma, width/height are half as big */
    if (i == 0) {
      width /= 2;
      height /= 2;
    }
  }
  return Y4M_OK;
}
Exemplo n.º 2
0
static int internal_read_444_fields(int fd,
				    const y4m_stream_info_t *si,
				    y4m_frame_info_t *fi,
				    uint8_t * const upper_field[3], 
				    uint8_t * const lower_field[3])
{
  int i, y, err;
  int width = y4m_si_get_width(si);
  int height = y4m_si_get_height(si);
  
  /* Read frame header */
  if ((err = y4m_read_frame_header(fd, si, fi)) != Y4M_OK) return err;
  /* Read Y', Cb, and Cr planes */
  for (i = 0; i < 3; i++) {
    uint8_t *srctop = upper_field[i];
    uint8_t *srcbot = lower_field[i];
    /* alternately write one line from each */
    for (y = 0; y < height; y += 2) {
      if (y4m_read(fd, srctop, width)) return Y4M_ERR_SYSTEM;
      srctop += width;
      if (y4m_read(fd, srcbot, width)) return Y4M_ERR_SYSTEM;
      srcbot += width;
    }
  }
  return Y4M_OK;
}
Exemplo n.º 3
0
int y4m_read_frame(int fd, const y4m_stream_info_t *si, 
		   y4m_frame_info_t *fi, uint8_t * const *frame)
{
  int err;
  
  /* Read frame header */
  if ((err = y4m_read_frame_header(fd, si, fi)) != Y4M_OK) return err;
  /* Read date */
  return y4m_read_frame_data(fd, si, fi, frame);
}
Exemplo n.º 4
0
int y4m_read_fields(int fd, const y4m_stream_info_t *si, y4m_frame_info_t *fi,
                    uint8_t * const *upper_field, 
                    uint8_t * const *lower_field)
{
  int err;
  /* Read frame header */
  if ((err = y4m_read_frame_header(fd, si, fi)) != Y4M_OK) return err;
  /* Read data */
  return y4m_read_fields_data(fd, si, fi, upper_field, lower_field);
}
Exemplo n.º 5
0
int y4m_read_frame(stream_t *s, y4m_stream_info_t *si, 
		   y4m_frame_info_t *fi, unsigned char *yuv[3])
{
  int err;
  int w = si->width;
  int h = si->height;
  
  /* Read frame header */
  if ((err = y4m_read_frame_header(s, fi)) != Y4M_OK) return err;
  /* Read luminance scanlines */
  if (y4m_read(s, yuv[0], w*h)) return Y4M_ERR_SYSTEM;
  /* Read chrominance scanlines */
  if (y4m_read(s, yuv[1], w*h/4)) return Y4M_ERR_SYSTEM;
  if (y4m_read(s, yuv[2], w*h/4)) return Y4M_ERR_SYSTEM;

  return Y4M_OK;
}
Exemplo n.º 6
0
static int internal_read_422_frame(int fd, 
				   const y4m_stream_info_t *si, 
				   y4m_frame_info_t *fi,
				   uint8_t * const yuv[3])
{
  int err;
  int w = y4m_si_get_width(si);
  int h = y4m_si_get_height(si);
  
  /* Read frame header */
  if ((err = y4m_read_frame_header(fd, si, fi)) != Y4M_OK) return err;
  /* Read luminance scanlines */
  if (y4m_read(fd, yuv[0], w*h)) return Y4M_ERR_SYSTEM;
  /* Read chrominance scanlines */
  if (y4m_read(fd, yuv[1], w*h/2)) return Y4M_ERR_SYSTEM;
  if (y4m_read(fd, yuv[2], w*h/2)) return Y4M_ERR_SYSTEM;

  return Y4M_OK;
}
Exemplo n.º 7
0
// Should probably just remove this...
int ysSource::read_frame_or_fields(int fdin, y4m_frame_info_t *frameinfo,
                                   uint8_t **frame,
                                   uint8_t **upper, uint8_t **lower)
{
  int err;
  err = y4m_read_frame_header(fdin, _stream.streaminfo(), frameinfo);
  if (err != Y4M_OK) return err;

  mjpeg_info("F-or-F:  %d  %d",
             y4m_fi_get_temporal(frameinfo),
             y4m_fi_get_spatial(frameinfo));

  /* XXXXXX what about ip/pi/420 issues? XXXXXXX */
  int sampling = y4m_fi_get_temporal(frameinfo);
  if (sampling == Y4M_SAMPLING_PROGRESSIVE) 
    return y4m_read_frame_data(fdin, _stream.streaminfo(), frameinfo, frame);
  else /* == Y4M_SAMPLING_INTERLACED */
    return y4m_read_fields_data(fdin, _stream.streaminfo(), frameinfo,
                                upper, lower);
}
Exemplo n.º 8
0
int ysSource::read_frame_header(int fdin, y4m_frame_info_t *frameinfo)
{
  return y4m_read_frame_header(fdin, _stream.streaminfo(), frameinfo);
}