UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
interlaced_video_pattern_generator Struct Reference
Inheritance diagram for interlaced_video_pattern_generator:
Inheritance graph
Collaboration diagram for interlaced_video_pattern_generator:
Collaboration graph

Public Member Functions

 interlaced_video_pattern_generator (int w, int h, codec_t color_spec)
 
char * get_next () override
 
- Public Member Functions inherited from video_pattern_generator
virtual ~video_pattern_generator ()
 

Private Attributes

int cur_idx = 0
 
vector< char > data
 
int height
 
size_t linesize
 
int width
 

Static Private Attributes

static constexpr int step = 3
 

Detailed Description

Definition at line 770 of file video_pattern_generator.cpp.

Constructor & Destructor Documentation

◆ interlaced_video_pattern_generator()

interlaced_video_pattern_generator::interlaced_video_pattern_generator ( int w,
int h,
codec_t color_spec )
inline

Definition at line 771 of file video_pattern_generator.cpp.

772 : width(w), height(h), linesize(vc_get_linesize(width, color_spec))
773 {
774 if (width % step != 0) {
775 throw ug_runtime_error(
776 string("[interlaced] width must be divisible by ") +
777 std::to_string(step) + "!");
778 }
779 size_t rgb_linesize = vc_get_linesize(width, RGB);
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) {
784 for (int i = 0; i < width; i += step) {
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 }
807 data.resize(3 * h * linesize + 4 * linesize * (w / step) +
809 testcard_convert_buffer(RGBA, color_spec, (unsigned char *) data.data(), (unsigned char *) rgba.data(), width, 3 * height + 4 * (width / step));
810 }
int vc_get_linesize(unsigned int width, codec_t codec)
#define MAX(a, b)
Definition macros.h:65
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)
Definition types.h:80
@ RGBA
RGBA 8-bit, big-endian.
Definition types.h:70
#define MAX_PADDING
Definition video_codec.h:63

References data, height, linesize, MAX, MAX_PADDING, RGB, RGBA, step, testcard_convert_buffer(), vc_get_linesize(), and width.

Here is the call graph for this function:

Member Function Documentation

◆ get_next()

char * interlaced_video_pattern_generator::get_next ( )
inlineoverridevirtual

Implements video_pattern_generator.

Definition at line 811 of file video_pattern_generator.cpp.

811 {
812 auto *out = (char *) data.data() + cur_idx * linesize;
813 cur_idx += 8;
814 if (cur_idx >= 2 * height + 4 * width / step) {
815 cur_idx = 0;
816 }
817
818 return out;
819 }

References cur_idx, data, height, linesize, step, and width.

Member Data Documentation

◆ cur_idx

int interlaced_video_pattern_generator::cur_idx = 0
private

Definition at line 825 of file video_pattern_generator.cpp.

Referenced by get_next().

◆ data

vector<char> interlaced_video_pattern_generator::data
private

Definition at line 826 of file video_pattern_generator.cpp.

Referenced by interlaced_video_pattern_generator(), and get_next().

◆ height

int interlaced_video_pattern_generator::height
private

Definition at line 823 of file video_pattern_generator.cpp.

Referenced by interlaced_video_pattern_generator(), and get_next().

◆ linesize

size_t interlaced_video_pattern_generator::linesize
private

Definition at line 824 of file video_pattern_generator.cpp.

Referenced by interlaced_video_pattern_generator(), and get_next().

◆ step

int interlaced_video_pattern_generator::step = 3
staticconstexprprivate

Definition at line 821 of file video_pattern_generator.cpp.

Referenced by interlaced_video_pattern_generator(), and get_next().

◆ width

int interlaced_video_pattern_generator::width
private

Definition at line 822 of file video_pattern_generator.cpp.

Referenced by interlaced_video_pattern_generator(), and get_next().


The documentation for this struct was generated from the following file: