~ubuntu-branches/ubuntu/trusty/gavl/trusty

« back to all changes in this revision

Viewing changes to gavl/videoframe.c

  • Committer: Bazaar Package Importer
  • Author(s): Romain Beauxis
  • Date: 2009-01-17 20:38:33 UTC
  • mfrom: (1.1.3 upstream) (4.1.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090117203833-t8fq1e1jdquyelmy
Tags: 1.1.0-2
Fixed debian/copyright 

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
#define memalign(align,size) malloc (size)
44
44
#endif
45
45
 
46
 
#define ALIGNMENT_BYTES 8
 
46
#define ALIGNMENT_BYTES 16
47
47
#define ALIGN(a) a=((a+ALIGNMENT_BYTES-1)/ALIGNMENT_BYTES)*ALIGNMENT_BYTES
48
48
 
49
49
static void video_frame_alloc(gavl_video_frame_t * ret,
308
308
  gavl_video_frame_t * ret = calloc(1, sizeof(gavl_video_frame_t));
309
309
  if(format)
310
310
    video_frame_alloc(ret, format, 1);
 
311
  ret->timecode = GAVL_TIMECODE_INVALID_MASK;
311
312
  return ret;
312
313
  }
313
314
 
316
317
  gavl_video_frame_t * ret = calloc(1, sizeof(gavl_video_frame_t));
317
318
  if(format)
318
319
    video_frame_alloc(ret, format, 0);
 
320
  ret->timecode = GAVL_TIMECODE_INVALID_MASK;
319
321
  return ret;
320
322
  }
321
323
 
796
798
  
797
799
  }
798
800
 
 
801
 
 
802
 
799
803
static void flip_scanline_1(uint8_t * dst, uint8_t * src, int len)
800
804
  {
801
805
  int i;
1631
1635
      RGB_FLOAT_TO_YUV_16(color[0], color[1], color[2], packed_64[0],
1632
1636
                          packed_64[1], packed_64[2]);
1633
1637
      RGB_FLOAT_TO_16(color[3], packed_64[3]);
1634
 
      fill_planar_16(frame, format, packed_64);
 
1638
      fill_64_packed(frame, format, packed_64);
1635
1639
      break;
1636
1640
    case GAVL_GRAY_FLOAT:
1637
1641
      RGB_FLOAT_TO_Y_FLOAT(color[0], color[1], color[2], color_float[0]);
1702
1706
      return;
1703
1707
    }
1704
1708
  }
 
1709
 
 
1710
void gavl_video_frame_copy_metadata(gavl_video_frame_t * dst,
 
1711
                                    const gavl_video_frame_t * src)
 
1712
  {
 
1713
  dst->timestamp       = src->timestamp;
 
1714
  dst->duration        = src->duration;
 
1715
  dst->timecode        = src->timecode;
 
1716
  dst->interlace_mode  = src->interlace_mode;
 
1717
  }
 
1718
 
 
1719
void gavl_video_frame_set_strides(gavl_video_frame_t * frame,
 
1720
                                  const gavl_video_format_t * format)
 
1721
  {
 
1722
  int i;
 
1723
  int bytes_per_line;
 
1724
  int sub_h, sub_v;
 
1725
  int num_planes = gavl_pixelformat_num_planes(format->pixelformat);
 
1726
  bytes_per_line = gavl_pixelformat_is_planar(format->pixelformat) ?
 
1727
    format->frame_width * gavl_pixelformat_bytes_per_component(format->pixelformat) :
 
1728
    format->frame_width * gavl_pixelformat_bytes_per_pixel(format->pixelformat);
 
1729
 
 
1730
  gavl_pixelformat_chroma_sub(format->pixelformat, &sub_h, &sub_v);
 
1731
 
 
1732
  for(i = 0; i < num_planes; i++)
 
1733
    {
 
1734
    frame->strides[i] = bytes_per_line;
 
1735
    if(i)
 
1736
      frame->strides[i] /= sub_h;
 
1737
    }
 
1738
  }
 
1739
  
 
1740
void gavl_video_frame_set_planes(gavl_video_frame_t * frame,
 
1741
                                 const gavl_video_format_t * format,
 
1742
                                 uint8_t * buffer)
 
1743
  {
 
1744
  int i;
 
1745
  int sub_h, sub_v;
 
1746
  int advance;
 
1747
  int num_planes = gavl_pixelformat_num_planes(format->pixelformat);
 
1748
  if(!frame->strides[0])
 
1749
    gavl_video_frame_set_strides(frame, format);
 
1750
 
 
1751
  gavl_pixelformat_chroma_sub(format->pixelformat, &sub_h, &sub_v);
 
1752
 
 
1753
  for(i = 0; i < num_planes; i++)
 
1754
    {
 
1755
    frame->planes[i] = buffer;
 
1756
    advance = frame->strides[i] * format->frame_height;
 
1757
    if(i)
 
1758
      advance /= sub_v;
 
1759
    buffer += advance;
 
1760
    }
 
1761
  
 
1762
  }