53#include <libswscale/swscale.h>
79 double vals_relative[4];
80 unsigned int counter = 0;
85 if (strchr(cfg,
'%')) {
91 char *
item, *save_ptr = NULL;
92 while ((
item = strtok_r(cfg,
":", &save_ptr))) {
94 vals_relative[counter] = atof(
item) / 100.0;
95 if (vals_relative[counter] < 0.0)
96 vals_relative[counter] = 0.0;
98 vals[counter] = atoi(
item);
99 if (vals[counter] < 0)
105 if (counter ==
sizeof(vals) /
sizeof(
int))
108 while ((
item = strtok_r(cfg,
":", &save_ptr))) {
109 if (strcmp(
item,
"black") == 0) {
112 fprintf(stderr,
"[Blank] Unknown config value: %s\n",
118 if(counter !=
sizeof(vals) /
sizeof(
int)) {
119 fprintf(stderr,
"[Blank] Few config values.\n");
141 if (cfg && strcasecmp(cfg,
"help") == 0) {
142 printf(
"Blanks specified rectangular area:\n\n");
143 printf(
"blank usage:\n");
144 printf(
"\tblank:x:y:widht:height[:black]\n");
146 printf(
"\tblank:x%%:y%%:widht%%:height%%[:black]\n");
147 printf(
"\t(all values in pixels)\n");
155 char *tmp = strdup(cfg);
156 bool ret =
parse(s, tmp);
201 enum AVPixelFormat
av_pixfmt = AV_PIX_FMT_NONE;
220 x = (
x + bpp - 1) / bpp * bpp;
242 fprintf(stderr,
"Unable to find suitable pixfmt!\n");
255 fprintf(stderr,
"Unable to initialize scaling context!");
268 if (width <= 0 || height <= 0)
272 char *orig = in->
tiles[0].
data + x * bpp + y * orig_stride;
274 size_t tmp_len = tmp_stride * (height /
FACTOR);
275 uint8_t *tmp = (uint8_t *) malloc(tmp_len);
278 unsigned char pattern[] = { 127, 0 };
284 memset(tmp, 0, tmp_len);
287 sws_scale(s->
ctx_downscale, (
const uint8_t *
const *) &orig, &orig_stride, 0, height, &tmp, &tmp_stride);
289 sws_scale(s->
ctx_upscale, (
const uint8_t *
const *) &tmp, &tmp_stride, 0, height /
FACTOR, (uint8_t **) &orig, &orig_stride);
struct video_desc video_desc_from_frame(const struct video_frame *frame)
Returns struct video_desc from video frame.
int vc_get_linesize(unsigned int width, codec_t codec)
static struct video_frame * filter(void *state, struct video_frame *in)
static struct response * process_message(struct state_blank *s, struct msg_universal *msg)
static const struct capture_filter_info capture_filter_blank
static bool parse(struct state_blank *s, char *cfg)
static void done(void *state)
static int init(struct module *parent, const char *cfg, void **state)
#define CAPTURE_FILTER_ABI_VERSION
void module_init_default(struct module *module_data)
void module_register(struct module *module_data, struct module *parent)
void module_done(struct module *module_data)
enum AVPixelFormat av_pixfmt
@ LIBRARY_CLASS_CAPTURE_FILTER
#define REGISTER_MODULE(name, info, lclass, abi)
Registers module to global modules' registry.
void free_message(struct message *msg, struct response *r)
struct response * new_response(int status, const char *text)
struct message * check_message(struct module *mod)
#define RESPONSE_BAD_REQUEST
struct SwsContext * ctx_downscale
struct video_desc saved_desc
struct SwsContext * ctx_upscale
char * data
Raw tile data. Pointer must be at least 4B aligned.
Struct video_frame represents a video frame and contains video description.
struct tile tiles[FLEXIBLE_ARRAY_MEMBER]
@ UYVY
YCbCr 422 8-bit - Cb Y0 Cr Y1.
enum AVPixelFormat get_ug_to_av_pixfmt(codec_t ug_codec)
This is an umbrella header for video functions.
double get_bpp(codec_t codec)
bool video_desc_eq(struct video_desc a, struct video_desc b)
Compares two video descriptions.