UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
every.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 dependency graph for every.c:

Go to the source code of this file.

Classes

struct  state_every
 

Functions

static void dispose_frame (struct video_frame *f)
 
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 (every, &capture_filter_every, LIBRARY_CLASS_CAPTURE_FILTER, CAPTURE_FILTER_ABI_VERSION)
 
static void usage ()
 

Variables

static const struct capture_filter_info capture_filter_every
 

Detailed Description

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

Definition in file every.c.

Function Documentation

◆ dispose_frame()

static void dispose_frame ( struct video_frame * f)
static

Definition at line 112 of file every.c.

112 {
114 vf_free(f);
115}
void vf_free(struct video_frame *buf)
Frees video_frame structure.
Struct video_frame represents a video frame and contains video description.
Definition types.h:305
struct video_frame_callbacks callbacks
Definition types.h:324
#define VIDEO_FRAME_DISPOSE(frame)
Definition video_frame.h:76

References video_frame::callbacks, video_frame_callbacks::dispose_udata, vf_free(), and VIDEO_FRAME_DISPOSE.

Referenced by filter().

Here is the call graph for this function:

◆ done()

static void done ( void * state)
static

Definition at line 107 of file every.c.

108{
109 free(state);
110}
void ** state

References state.

◆ filter()

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

Definition at line 117 of file every.c.

118{
119 struct state_every *s = state;
120
121 if (s->num == 0) {
123 return NULL;
124 }
125
126 s->current = (s->current + 1) % s->num;
127
128 if (s->current >= s->denom) {
130 return NULL;
131 }
132
134 memcpy(frame->tiles, in->tiles, in->tile_count * sizeof(struct tile));
135 frame->fps /= (double) s->num / s->denom;
136
139
140 return frame;
141}
struct video_frame * frame
struct video_desc video_desc_from_frame(const struct video_frame *frame)
Returns struct video_desc from video frame.
struct video_frame * vf_alloc_desc(struct video_desc desc)
Allocates video frame accordig given desc.
static void dispose_frame(struct video_frame *f)
Definition every.c:112
int num
Definition every.c:59
int current
Definition every.c:61
int denom
Definition every.c:60
Struct tile is an area of video_frame.
Definition types.h:279
void(* dispose)(struct video_frame *)
Definition types.h:245
struct tile tiles[FLEXIBLE_ARRAY_MEMBER]
Definition types.h:345
double fps
Definition types.h:308
unsigned int tile_count
Definition types.h:344

References video_frame::callbacks, state_every::current, state_every::denom, video_frame_callbacks::dispose, dispose_frame(), video_frame_callbacks::dispose_udata, video_frame::fps, frame, state_every::num, state, video_frame::tile_count, video_frame::tiles, vf_alloc_desc(), video_desc_from_frame(), and VIDEO_FRAME_DISPOSE.

Here is the call graph for this function:

◆ init()

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

Definition at line 73 of file every.c.

74{
76
77 int n;
78 int denom = 1;;
79 if (strlen(cfg) == 0) {
80 usage();
81 return -1;
82 }
83 if(strcasecmp(cfg, "help") == 0) {
84 usage();
85 return 1;
86 }
87 n = atoi(cfg);
88 if(strchr(cfg, '/')) {
89 denom = atoi(strchr(cfg, '/') + 1);
90 }
91 if (denom > n && n != 0) {
92 log_msg(LOG_LEVEL_ERROR, "Currently, numerator has to be greater "
93 "(or equal, which, however, has a little use) than denominator.\n");
94 return -1;
95 }
96
97 struct state_every *s = calloc(1, sizeof(struct state_every));
98 s->num = n;
99 s->denom = denom;
100
101 s->current = -1;
102
103 *state = s;
104 return 0;
105}
#define UNUSED(x)
void log_msg(int level, const char *format,...)
Definition debug.cpp:130
#define LOG_LEVEL_ERROR
general errors
Definition debug.h:59
static void usage()
Definition every.c:64
const char * parent
Definition settings.cpp:198

References state_every::current, state_every::denom, LOG_LEVEL_ERROR, log_msg(), state_every::num, parent, state, UNUSED, and usage().

Here is the call graph for this function:

◆ REGISTER_MODULE()

REGISTER_MODULE ( every ,
& capture_filter_every,
LIBRARY_CLASS_CAPTURE_FILTER ,
CAPTURE_FILTER_ABI_VERSION  )

◆ usage()

static void usage ( void )
static

Definition at line 64 of file every.c.

64 {
65 color_printf("Passes only every n-th frame.\n"
66 "See also capture filter " TBOLD("ratelimit") ".\n\n");
67 color_printf(TBOLD("every") " usage:\n");
68 printf("\tevery:numerator[/denominator]\n\n");
69 printf("Example: every:2 - every second frame will be dropped\n");
70 printf("The special case every:0 can be used to discard all frames\n");
71}
int color_printf(const char *format,...)
#define TBOLD(x)
Definition color_out.h:70

References color_printf(), and TBOLD.

Referenced by init().

Here is the call graph for this function:

Variable Documentation

◆ capture_filter_every

const struct capture_filter_info capture_filter_every
static
Initial value:
= {
.init = init,
.done = done,
.filter = filter,
}
static struct video_frame * filter(void *state, struct video_frame *in)
Definition every.c:117
static void done(void *state)
Definition every.c:107
static int init(struct module *parent, const char *cfg, void **state)
Definition every.c:73

Definition at line 143 of file every.c.

143 {
144 .init = init,
145 .done = done,
146 .filter = filter,
147};