43
43
#define memalign(align,size) malloc (size)
46
#define ALIGNMENT_BYTES 8
46
#define ALIGNMENT_BYTES 16
47
47
#define ALIGN(a) a=((a+ALIGNMENT_BYTES-1)/ALIGNMENT_BYTES)*ALIGNMENT_BYTES
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));
310
310
video_frame_alloc(ret, format, 1);
311
ret->timecode = GAVL_TIMECODE_INVALID_MASK;
316
317
gavl_video_frame_t * ret = calloc(1, sizeof(gavl_video_frame_t));
318
319
video_frame_alloc(ret, format, 0);
320
ret->timecode = GAVL_TIMECODE_INVALID_MASK;
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);
1636
1640
case GAVL_GRAY_FLOAT:
1637
1641
RGB_FLOAT_TO_Y_FLOAT(color[0], color[1], color[2], color_float[0]);
1710
void gavl_video_frame_copy_metadata(gavl_video_frame_t * dst,
1711
const gavl_video_frame_t * src)
1713
dst->timestamp = src->timestamp;
1714
dst->duration = src->duration;
1715
dst->timecode = src->timecode;
1716
dst->interlace_mode = src->interlace_mode;
1719
void gavl_video_frame_set_strides(gavl_video_frame_t * frame,
1720
const gavl_video_format_t * format)
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);
1730
gavl_pixelformat_chroma_sub(format->pixelformat, &sub_h, &sub_v);
1732
for(i = 0; i < num_planes; i++)
1734
frame->strides[i] = bytes_per_line;
1736
frame->strides[i] /= sub_h;
1740
void gavl_video_frame_set_planes(gavl_video_frame_t * frame,
1741
const gavl_video_format_t * format,
1747
int num_planes = gavl_pixelformat_num_planes(format->pixelformat);
1748
if(!frame->strides[0])
1749
gavl_video_frame_set_strides(frame, format);
1751
gavl_pixelformat_chroma_sub(format->pixelformat, &sub_h, &sub_v);
1753
for(i = 0; i < num_planes; i++)
1755
frame->planes[i] = buffer;
1756
advance = frame->strides[i] * format->frame_height;