63#define MOD_NAME "[resize filter] "
81 printf(
"Scaling by scale factor:\n\n");
82 printf(
"resize usage:\n");
85 printf(
"\t" TBOLD(
TRED(
"resize")
":<width>x<height>[algo=<a>]")
"\n\n");
87 "\t" TBOLD(
"resize:1/2")
" | " TBOLD(
"resize:0.5")
88 " - downscale input frame size by scale factor of 2\n"
89 "\t" TBOLD(
"resize:1280x720")
90 " - scales input to 1280x720\n"
91 "\t" TBOLD(
"resize:720x576")
92 " - scales input to PAL\n");
96 "algo")
" - scaling algorithm to use (list with `algo:help`)\n");
103 char *save_ptr = NULL;
105 while ((
item = strtok_r(cfg,
":", &save_ptr))) {
109 if (
param->algo < 0) {
114 if (!isdigit(
item[0]) &&
item[0] !=
'.') {
116 "[RESIZE ERROR] Unrecognized part of config "
121 if (strchr(
item,
'x')) {
122 param->mode = USE_DIMENSIONS;
123 param->target_width = strtol(
item, NULL, 10);
124 param->target_height = strtol(strchr(
item,
'x') + 1, NULL, 10);
126 param->mode = USE_FRACTION;
128 if (strchr(
item,
'/')) {
129 const long den = strtol(strchr(
item,
'/') + 1, NULL, 10);
130 param->factor = den <= 0 ? .0 :
param->factor / den;
135 if (
param->mode == USE_DIMENSIONS &&
param->target_width > 0 &&
136 param->target_height > 0) {
139 if (
param->mode == USE_FRACTION &&
param->factor > 0) {
143 MSG(ERROR,
"No or incorrect resize size!\n");
152 if(strcasecmp(cfg,
"help") == 0) {
157 char *
fmt = strdup(cfg);
203 "Cannot decode %s to neither of supported input formats!\n",
210 MSG(INFO,
"Decoding through %s to output pixfmt %s.\n",
248 for (
unsigned int i = 0; i < out_frame->
tile_count; i++) {
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)
int vc_get_linesize(unsigned int width, codec_t codec)
struct video_frame * vf_alloc_desc(struct video_desc desc)
Allocates video frame accordig given desc.
struct video_frame * vf_alloc_desc_data(struct video_desc desc)
const char * get_codec_name(codec_t codec)
#define CAPTURE_FILTER_ABI_VERSION
#define ADD_VO_PP_CAPTURE_FILTER_WRAPPER(name, init, filter, done, set_out_buf, get_prop_callb)
int color_printf(const char *format,...)
void log_msg(int level, const char *format,...)
#define LOG_LEVEL_ERROR
general errors
@ LIBRARY_CLASS_CAPTURE_FILTER
#define REGISTER_MODULE(name, info, lclass, abi)
Registers module to global modules' registry.
#define IS_KEY_PREFIX(tok, key)
expands to true value if <k> from tok in format <k>=<v> is prefix of key
void parallel_pix_conv(int height, char *out, int out_linesize, const char *in, int in_linesize, decoder_t decode, int threads)
decoder_t get_best_decoder_from(codec_t in, const codec_t *out_candidates, codec_t *out)
decoder_func_t * decoder_t
decoder_func_t vc_memcpy
dummy conversion - ptr to it returned if no conversion needed
static const struct capture_filter_info capture_filter_resize
static struct video_frame * filter(void *state, struct video_frame *in)
static int parse_fmt(char *cfg, struct resize_param *param)
static void cleanup_common(struct state_resize *s)
static void vo_pp_set_out_buffer(void *state, char *buffer)
static bool reconfigure_if_needed(struct state_resize *s, const struct video_frame *in)
static void done(void *state)
static int init(struct module *parent, const char *cfg, void **state)
int resize_algo_from_string(const char *str)
void resize_frame(char *indata, codec_t in_color, char *outdata, int width, int height, struct resize_param *resize_spec)
#define RESIZE_ALGO_HELP_SHOWN
#define RESIZE_SUPPORTED_PIXFMT_INIT
enum resize_param::resize_mode mode
struct resize_param param
char * vo_pp_out_buffer
buffer to write to if we use vo_pp wrapper (otherwise unused)
struct video_frame * dec_frame
struct video_desc saved_desc
struct video_desc out_desc
char * data
Raw tile data. Pointer must be at least 4B aligned.
unsigned int data_len
length of the data
unsigned int width
width of every tile (!)
unsigned int height
height of every tile (!)
void(* data_deleter)(struct video_frame *)
void(* dispose)(struct video_frame *)
Struct video_frame represents a video frame and contains video description.
struct tile tiles[FLEXIBLE_ARRAY_MEMBER]
struct video_frame_callbacks callbacks
@ RGB
RGB 8-bit (packed into 24-bit word)
@ VIDEO_CODEC_NONE
dummy color spec
@ RG48
16-bit RGB little-endian (RlRhGl...)
This is an umbrella header for video functions.
bool codec_is_in_set(codec_t codec, const codec_t *set)
int get_bits_per_component(codec_t codec)
bool video_desc_eq(struct video_desc a, struct video_desc b)
Compares two video descriptions.
#define VIDEO_FRAME_DISPOSE(frame)