From 9fe583540cce55478a24568803fc687bd0e1658f Mon Sep 17 00:00:00 2001 From: Andrew Armenia Date: Fri, 26 Nov 2010 22:58:58 -0500 Subject: [PATCH] make DecklinkOutput a bit smarter regarding pixel formats --- core/output_adapter.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core/output_adapter.h b/core/output_adapter.h index 246033e..31c85a7 100644 --- a/core/output_adapter.h +++ b/core/output_adapter.h @@ -131,6 +131,14 @@ class DecklinkOutput : public OutputAdapter, unsigned char *data_ptr; int i; + Picture *convert; + + if (in_frame->pix_fmt != UYVY8) { + convert = in_frame->convert_to_format(UYVY8); + } else { + convert = in_frame; + } + if (free_frames.empty( )) { throw std::runtime_error("Can't set next frame when no frames free!"); } @@ -143,11 +151,15 @@ class DecklinkOutput : public OutputAdapter, int blit_max_h = (in_frame->h < 480) ? in_frame->h : 480; for (i = 0; i < blit_max_h; ++i) { - memcpy(data_ptr + 1440*i, in_frame->data + in_frame->line_pitch*i, 2*blit_max_w); + memcpy(data_ptr + 1440*i, convert->data + convert->line_pitch*i, 2*blit_max_w); } ready_frames.push_back(frame); + if (convert != in_frame) { + Picture::free(convert); + } + } bool ReadyForNextFrame(void) {