diff --git a/src/video_codec.c b/src/video_codec.c index 02bb7aff1..d64612776 100644 --- a/src/video_codec.c +++ b/src/video_codec.c @@ -612,6 +612,24 @@ static void vc_deinterlace_unaligned(unsigned char *src, long src_linesize, int } #endif +/** + * Extended version of vc_deinterlace(). The former version was in-place only. + * This allows to output to different buffer. + */ +void vc_deinterlace_ex(unsigned char *src, size_t src_linesize, unsigned char *dst, size_t dst_pitch, size_t lines) +{ + for (size_t y = 0; y < lines; y += 2) { + for (size_t x = 0; x < src_linesize; ++x) { + int val = (*src + src[src_linesize] + 1) >> 1; + *dst = dst[dst_pitch] = val; + src++; + dst++; + } + src += src_linesize; + dst += dst_pitch; + } +} + /** * @brief Converts v210 to UYVY * @param[out] dst 4-byte aligned output buffer where UYVY will be stored diff --git a/src/video_codec.h b/src/video_codec.h index 4567a8f71..f2327fa9a 100644 --- a/src/video_codec.h +++ b/src/video_codec.h @@ -93,6 +93,7 @@ bool codec_is_in_set(codec_t codec, codec_t *set) ATTRIBUTE(pure); int codec_is_const_size(codec_t codec) ATTRIBUTE(pure); void vc_deinterlace(unsigned char *src, long src_linesize, int lines); +void vc_deinterlace_ex(unsigned char *src, size_t src_linesize, unsigned char *dst, size_t dst_pitch, size_t lines); void vc_copylineDVS10(unsigned char *dst, const unsigned char *src, int dst_len); void vc_copylinev210(unsigned char *dst, const unsigned char *src, int dst_len); void vc_copylineYUYV(unsigned char *dst, const unsigned char *src, int dst_len);