UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
grayscale.c File Reference
#include "capture_filter.h"
#include "debug.h"
#include "lib_common.h"
#include "utils/color_out.h"
#include "video.h"
#include "video_codec.h"
#include "vo_postprocess/capture_filter_wrapper.h"
Include dependency graph for grayscale.c:

Go to the source code of this file.

Classes

struct  state_grayscale
 

Functions

static void done (void *state)
 
static struct video_frame * filter (void *state, struct video_frame *in)
 
static int init (struct module *parent, const char *cfg, void **state)
 
 REGISTER_MODULE (grayscale, &capture_filter_grayscale, LIBRARY_CLASS_CAPTURE_FILTER, CAPTURE_FILTER_ABI_VERSION)
 
static void vo_pp_set_out_buffer (void *state, char *buffer)
 

Variables

static const struct capture_filter_info capture_filter_grayscale
 

Detailed Description

Author
Martin Pulec pulec.nosp@m.@ces.nosp@m.net.c.nosp@m.z

Definition in file grayscale.c.

Function Documentation

◆ done()

static void done ( void * state)
static

Definition at line 71 of file grayscale.c.

72{
73 free(state);
74}
void ** state

References state.

◆ filter()

static struct video_frame * filter ( void * state,
struct video_frame * in )
static

Definition at line 76 of file grayscale.c.

77{
78 struct state_grayscale *s = state;
79
80 if (in->color_spec != UYVY) {
81 log_msg(LOG_LEVEL_WARNING, "Cannot create grayscale from other codec than UYVY!\n");
82 return in;
83 }
85 if (s->vo_pp_out_buffer) {
86 out->tiles[0].data = s->vo_pp_out_buffer;
87 } else {
88 out->tiles[0].data = (char *) malloc(out->tiles[0].data_len);
90 }
92
93 unsigned char *in_data = (unsigned char *) in->tiles[0].data;
94 unsigned char *out_data = (unsigned char *) out->tiles[0].data;
95
96 for (unsigned int i = 0; i < in->tiles[0].width * in->tiles[0].height; ++i) {
97 *out_data++ = 127;
98 in_data++;
99 *out_data++ = *in_data++;
100 }
101
103
104 return out;
105}
void vf_free(struct video_frame *buf)
Frees video_frame structure.
struct video_desc video_desc_from_frame(const struct video_frame *frame)
Returns struct video_desc from video frame.
void vf_data_deleter(struct video_frame *buf)
struct video_frame * vf_alloc_desc(struct video_desc desc)
Allocates video frame accordig given desc.
void log_msg(int level, const char *format,...)
Definition debug.cpp:130
#define LOG_LEVEL_WARNING
less severe errors
Definition debug.h:60
char * vo_pp_out_buffer
buffer to write to if we use vo_pp wrapper (otherwise unused)
Definition grayscale.c:57
unsigned int width
Definition types.h:280
char * data
Raw tile data. Pointer must be at least 4B aligned.
Definition types.h:287
unsigned int data_len
length of the data
Definition types.h:288
unsigned int height
Definition types.h:281
void(* data_deleter)(struct video_frame *)
Definition types.h:256
void(* dispose)(struct video_frame *)
Definition types.h:245
Struct video_frame represents a video frame and contains video description.
Definition types.h:305
struct tile tiles[FLEXIBLE_ARRAY_MEMBER]
Definition types.h:345
struct video_frame_callbacks callbacks
Definition types.h:324
codec_t color_spec
Definition types.h:306
@ UYVY
YCbCr 422 8-bit - Cb Y0 Cr Y1.
Definition types.h:71
#define VIDEO_FRAME_DISPOSE(frame)
Definition video_frame.h:76

References video_frame::callbacks, video_frame::color_spec, tile::data, video_frame_callbacks::data_deleter, tile::data_len, video_frame_callbacks::dispose, tile::height, LOG_LEVEL_WARNING, log_msg(), state, video_frame::tiles, UYVY, vf_alloc_desc(), vf_data_deleter(), vf_free(), video_desc_from_frame(), VIDEO_FRAME_DISPOSE, state_grayscale::vo_pp_out_buffer, and tile::width.

Here is the call graph for this function:

◆ init()

static int init ( struct module * parent,
const char * cfg,
void ** state )
static

Definition at line 60 of file grayscale.c.

61{
63 if (strlen(cfg) > 0) {
64 color_printf(TRED(TBOLD("grayscale")) " converts image to grayscale, takes no arguments\n");
65 return strcmp(cfg, "help") == 0 ? 1 : -1;
66 }
67 *state = calloc(1, sizeof(struct state_grayscale));
68 return 0;
69}
#define UNUSED(x)
int color_printf(const char *format,...)
#define TRED(x)
Definition color_out.h:75
#define TBOLD(x)
Definition color_out.h:70
const char * parent
Definition settings.cpp:198

References color_printf(), parent, state, TBOLD, TRED, and UNUSED.

Here is the call graph for this function:

◆ REGISTER_MODULE()

REGISTER_MODULE ( grayscale ,
& capture_filter_grayscale,
LIBRARY_CLASS_CAPTURE_FILTER ,
CAPTURE_FILTER_ABI_VERSION  )

◆ vo_pp_set_out_buffer()

static void vo_pp_set_out_buffer ( void * state,
char * buffer )
static

Definition at line 107 of file grayscale.c.

108{
109 struct state_grayscale *s = state;
110 s->vo_pp_out_buffer = buffer;
111}

References state, and state_grayscale::vo_pp_out_buffer.

Variable Documentation

◆ capture_filter_grayscale

const struct capture_filter_info capture_filter_grayscale
static
Initial value:
= {
.init = init,
.done = done,
.filter = filter,
}
static struct video_frame * filter(void *state, struct video_frame *in)
Definition grayscale.c:76
static void done(void *state)
Definition grayscale.c:71
static int init(struct module *parent, const char *cfg, void **state)
Definition grayscale.c:60

Definition at line 114 of file grayscale.c.

114 {
115 .init = init,
116 .done = done,
117 .filter = filter,
118};