773 {
776 string("[interlaced] width must be divisible by ") +
777 std::to_string(
step) +
"!");
778 }
780 vector<char> rgb(3 * h * rgb_linesize + 4 * (
width /
step) * rgb_linesize);
781 memset(rgb.data(), 255, h * rgb_linesize);
782 char *ptr = rgb.data() + h * rgb_linesize;
783 auto fill = [&](int col1, int col2) {
785 size_t fill_len = rgb_linesize - i * 3;
786 memset(ptr, col1, fill_len);
787 memset(ptr + fill_len, col2, rgb_linesize - fill_len);
788 ptr += rgb_linesize;
789 fill_len =
MAX(0, (
int) rgb_linesize - (i + 2 *
step) * 3);
790 memset(ptr, col1, fill_len);
791 memset(ptr + fill_len, col2, rgb_linesize - fill_len);
792 ptr += rgb_linesize;
793 }
794 };
795 fill(255, 0);
796 memset(ptr, 0, h * rgb_linesize);
797 ptr += h * rgb_linesize;
798 fill(0, 255);
799 memset(ptr, 255, h * rgb_linesize);
800 vector<char> rgba(rgb.size() / 3 * 4);
801 for (unsigned i = 0; i < rgb.size(); i += 3) {
802 rgba[i / 3 * 4] = rgb[i];
803 rgba[i / 3 * 4 + 1] = rgb[i + 1];
804 rgba[i / 3 * 4 + 2] = rgb[i + 2];
805 rgba[i / 3 * 4 + 3] = 0xff;
806 }
810 }
int vc_get_linesize(unsigned int width, codec_t codec)
static constexpr int step
void testcard_convert_buffer(codec_t in_c, codec_t out_c, unsigned char *out, unsigned const char *in, int width, int height)
@ RGB
RGB 8-bit (packed into 24-bit word)
@ RGBA
RGBA 8-bit, big-endian.