UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
video_pattern_generator.cpp File Reference
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstring>
#include <iostream>
#include <memory>
#include <random>
#include <utility>
#include <vector>
#include "color.h"
#include "debug.h"
#include "pixfmt_conv.h"
#include "ug_runtime_error.hpp"
#include "utils/color_out.h"
#include "utils/macros.h"
#include "utils/string_view_utils.hpp"
#include "utils/text.h"
#include "video.h"
#include "video_capture/testcard_common.h"
#include "video_pattern_generator.h"
Include dependency graph for video_pattern_generator.cpp:

Go to the source code of this file.

Classes

struct  gray_video_pattern_generator
 
class  image_pattern
 
class  image_pattern_bars
 
class  image_pattern_blank
 
class  image_pattern_diagonal
 
class  image_pattern_ebu_smpte_bars< f, columns >
 
class  image_pattern_gradient
 
class  image_pattern_gradient2
 
class  image_pattern_noise
 
class  image_pattern_raw
 
class  image_pattern_smpte_bars
 
struct  image_pattern_strips
 
class  image_pattern_text
 
class  image_pattern_uv_plane
 
struct  interlaced_video_pattern_generator
 
struct  still_image_video_pattern_generator
 
struct  video_pattern_generator
 

Macros

#define BLANK_USAGE   "blank[=0x<AABBGGRR>]"
 
#define MOD_NAME   "[vid. patt. generator] "
 

Enumerations

enum class  generator_depth { bits8 , bits16 }
 

Functions

video_pattern_generator_t video_pattern_generator_create (const char *config, int width, int height, codec_t color_spec, int offset)
 
void video_pattern_generator_destroy (video_pattern_generator_t s)
 
void video_pattern_generator_fill_data (video_pattern_generator_t s, const char *data)
 
char * video_pattern_generator_next_frame (video_pattern_generator_t s)
 

Variables

constexpr size_t headroom = 128
 
constexpr int rg48_bpp = 6
 

Detailed Description

Macro Definition Documentation

◆ BLANK_USAGE

#define BLANK_USAGE   "blank[=0x<AABBGGRR>]"

◆ MOD_NAME

Enumeration Type Documentation

◆ generator_depth

enum class generator_depth
strong
Enumerator
bits8 

RGBA.

bits16 

RG48.

Definition at line 98 of file video_pattern_generator.cpp.

98 {
99 bits8,
100 bits16
101};

Function Documentation

◆ video_pattern_generator_create()

video_pattern_generator_t video_pattern_generator_create ( const char * config,
int width,
int height,
codec_t color_spec,
int offset )
Parameters
offsetoffset between still image frames (in bytes)

Definition at line 830 of file video_pattern_generator.cpp.

831{
832
833 if (string(config) == "help") {
834 col() << "Pattern to use, one of: \n";
835 for (const auto *p :
836 {
837 "bars",
839 "diagonal*",
840 "ebu_bars",
841 "gradient[=0x<AABBGGRR>]",
842 "gradient2*",
843 "gray",
844 "interlaced",
845 "noise",
846 "raw=0xXX[YYZZ..]",
847 "smpte_bars",
848 "strips*",
849 "uv_plane[=<y_lvl>]",
850 }) {
851 col() << "\t- " << SBOLD(p) << "\n";
852 }
853
854 col() << "\nNotes:\n";
855
856 col() << "\t- patterns " SBOLD("'gradient'") ", "
857 SBOLD("'gradient2'") ", " SBOLD("'noise'") " and "
858 SBOLD("'uv_plane'") " generate higher bit-depth "
859 "patterns with";
861 c = static_cast<codec_t>(static_cast<int>(c) + 1)) {
862 if (get_decoder_from_to(RG48, c) != NULL && get_bits_per_component(c) > 8) {
863 col() << " " << SBOLD(get_codec_name(c));
864 }
865 }
866 col() << "\n";
867 col() << "\t- pattern "
868 << SBOLD("'raw'") " generates repeating sequence of given "
869 "bytes without any color conversion\n";
870 col() << "\t- patterns marked with "
871 << SBOLD("'*'") " provide help as its option\n";
872 return nullptr;
873 }
874 assert(width > 0 && height > 0);
875 try {
876 string pattern = config;
877 string params;
878 if (string::size_type delim = pattern.find('='); delim != string::npos) {
879 params = pattern.substr(delim + 1);
880 pattern = pattern.substr(0, delim);
881 }
882 if (pattern == "gray" || pattern == "grey") {
883 return new gray_video_pattern_generator{width, height, color_spec, params};
884 }
885 if (pattern == "interlaced") {
886 return new interlaced_video_pattern_generator{width, height, color_spec};
887 }
888 return new still_image_video_pattern_generator{pattern, params, width, height, color_spec, offset};
889 } catch (exception const &e) {
890 LOG(LOG_LEVEL_ERROR) << MOD_NAME << e.what() << "\n";
891 return nullptr;
892 } catch (...) {
893 return nullptr;
894 }
895}
const char * get_codec_name(codec_t codec)
pattern
Definition testcard.c:94
#define SBOLD(x)
Definition color_out.h:80
static __device__ const float offset
Definition cuda_dxt.cu:139
#define LOG_LEVEL_ERROR
general errors
Definition debug.h:59
#define LOG(level)
Definition debug.h:313
static struct @19 params[100]
decoder_t get_decoder_from_to(codec_t in, codec_t out)
codec_t
Definition types.h:65
@ VIDEO_CODEC_FIRST
Definition types.h:68
@ RG48
16-bit RGB little-endian (RlRhGl...)
Definition types.h:95
@ VIDEO_CODEC_COUNT
count of known video codecs (including VIDEO_CODEC_NONE)
Definition types.h:108
int get_bits_per_component(codec_t codec)
#define BLANK_USAGE
#define MOD_NAME

References BLANK_USAGE, get_bits_per_component(), get_codec_name(), get_decoder_from_to(), LOG, LOG_LEVEL_ERROR, MOD_NAME, offset, params, RG48, SBOLD, VIDEO_CODEC_COUNT, and VIDEO_CODEC_FIRST.

Referenced by vidcap_testcard_init().

Here is the call graph for this function:

◆ video_pattern_generator_destroy()

void video_pattern_generator_destroy ( video_pattern_generator_t s)

Definition at line 909 of file video_pattern_generator.cpp.

910{
911 delete s;
912}

Referenced by vidcap_testcard_done().

◆ video_pattern_generator_fill_data()

void video_pattern_generator_fill_data ( video_pattern_generator_t s,
const char * data )

Definition at line 902 of file video_pattern_generator.cpp.

903{
904 auto &state = dynamic_cast<still_image_video_pattern_generator &>(*s);
905 memcpy(state.data.data(), data, state.data_len);
906 memcpy(state.data.data() + state.data_len, data, state.data_len);
907}
void ** state

References state.

Referenced by vidcap_testcard_init().

◆ video_pattern_generator_next_frame()

char * video_pattern_generator_next_frame ( video_pattern_generator_t s)

Definition at line 897 of file video_pattern_generator.cpp.

898{
899 return s->get_next();
900}
virtual char * get_next()=0

References video_pattern_generator::get_next().

Referenced by vidcap_testcard_grab().

Here is the call graph for this function:

Variable Documentation

◆ headroom

size_t headroom = 128
constexpr

Definition at line 77 of file video_pattern_generator.cpp.

Referenced by audio_testcard_read_wav(), and image_pattern::init().

◆ rg48_bpp

int rg48_bpp = 6
constexpr

Definition at line 78 of file video_pattern_generator.cpp.

Referenced by image_pattern::init().