libobs/media-io: Add frame copying function
This commit is contained in:
parent
5d0551eb27
commit
8e1549820b
@ -86,3 +86,31 @@ void video_frame_init(struct video_frame *frame, enum video_format format,
|
||||
}
|
||||
}
|
||||
|
||||
void video_frame_copy(struct video_frame *dst, const struct video_frame *src,
|
||||
enum video_format format, uint32_t cy)
|
||||
{
|
||||
switch (format) {
|
||||
case VIDEO_FORMAT_NONE:
|
||||
return;
|
||||
|
||||
case VIDEO_FORMAT_I420:
|
||||
memcpy(dst->data[0], src->data[0], src->linesize[0] * cy);
|
||||
memcpy(dst->data[1], src->data[1], src->linesize[1] * cy / 2);
|
||||
memcpy(dst->data[2], src->data[2], src->linesize[2] * cy / 2);
|
||||
break;
|
||||
|
||||
case VIDEO_FORMAT_NV12:
|
||||
memcpy(dst->data[0], src->data[0], src->linesize[0] * cy);
|
||||
memcpy(dst->data[1], src->data[1], src->linesize[1] * cy / 2);
|
||||
break;
|
||||
|
||||
case VIDEO_FORMAT_YVYU:
|
||||
case VIDEO_FORMAT_YUY2:
|
||||
case VIDEO_FORMAT_UYVY:
|
||||
case VIDEO_FORMAT_RGBA:
|
||||
case VIDEO_FORMAT_BGRA:
|
||||
case VIDEO_FORMAT_BGRX:
|
||||
memcpy(dst->data[0], src->data[0], src->linesize[0] * cy);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -53,3 +53,7 @@ static inline void video_frame_destroy(struct video_frame *frame)
|
||||
bfree(frame);
|
||||
}
|
||||
}
|
||||
|
||||
EXPORT void video_frame_copy(struct video_frame *dst,
|
||||
const struct video_frame *src, enum video_format format,
|
||||
uint32_t height);
|
||||
|
Loading…
x
Reference in New Issue
Block a user