73 if(*
len < (
int)
sizeof(supported)) {
74 fprintf(stderr,
"Scale postprocessor query little space.\n");
77 memcpy(
val, &supported,
sizeof(supported));
78 *
len =
sizeof(supported);
89 printf(
"Scale postprocessor settings:\n");
90 printf(
"\t-p scale:width:height\n");
94 char *save_ptr = NULL;
97 if (strcmp(config,
"help") == 0) {
102 char *tmp = strdup(config);
109 ptr = strtok_r(tmp,
":", &save_ptr);
113 ptr = strtok_r(NULL,
":", &save_ptr);
118 fprintf(stderr,
"Scale postprocessor incorrect usage.\n");
132 glEnable(GL_TEXTURE_2D);
135 glBindTexture(GL_TEXTURE_2D, s->
tex_input);
136 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
137 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
138 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
139 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
142 glBindTexture(GL_TEXTURE_2D, s->
tex_input);
143 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
144 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
145 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
146 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
148 glGenFramebuffers(1, &s->
fbo);
157 struct tile *in_tile;
191 glBindTexture(GL_TEXTURE_2D, s->
tex_input);
201 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
width,
height,
202 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
216 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
width,
height,
217 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
238 char *tmp_data = NULL;
240 if(req_pitch != src_linesize) {
241 tmp_data = malloc(src_linesize *
250 glBindTexture(GL_TEXTURE_2D, s->
tex_input);
260 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,
width,
height,
261 GL_RGBA, GL_UNSIGNED_BYTE, in_tile->
data);
263 glBindFramebuffer(GL_FRAMEBUFFER, s->
fbo);
264 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, s->
tex_output, 0);
276 glBindTexture(GL_TEXTURE_2D, s->
tex_input);
278 glClearColor(1,0,0,1);
279 glClear(GL_COLOR_BUFFER_BIT);
282 glTexCoord2f(0.0, 0.0); glVertex2f(-1.0, -1.0);
283 glTexCoord2f(1.0, 0.0); glVertex2f(1.0, -1.0);
284 glTexCoord2f(1.0, 1.0); glVertex2f(1.0, 1.0);
285 glTexCoord2f(0.0, 1.0); glVertex2f(-1.0, 1.0);
291 glReadPixels(0, 0,
width ,
height, GL_RGBA, GL_UNSIGNED_BYTE, tmp_data);
292 char *src = tmp_data;
294 for (y = 0; y < (int) out->
tiles[i].
height; y += 1) {
295 memcpy(dst, src, src_linesize);
315 glDeleteFramebuffers(1, &s->
fbo);
struct video_frame * vf_alloc(int count)
Allocates blank video frame.
void vf_free(struct video_frame *buf)
Frees video_frame structure.
int vc_get_linesize(unsigned int width, codec_t codec)
bool init_gl_context(struct gl_context *context, int which)
initializes specified OpenGL context
void destroy_gl_context(struct gl_context *context)
void gl_context_make_current(struct gl_context *context)
#define GL_CONTEXT_LEGACY
@ DISPLAY_PROPERTY_VIDEO_MERGED
monolithic framebuffer
@ LIBRARY_CLASS_VIDEO_POSTPROCESS
#define REGISTER_MODULE(name, info, lclass, abi)
Registers module to global modules' registry.
static bool scale_postprocess(void *state, struct video_frame *in, struct video_frame *out, int req_pitch)
static bool scale_get_property(void *state, int property, void *val, size_t *len)
static bool scale_reconfigure(void *state, struct video_desc desc)
static void * scale_init(const char *config)
static const struct vo_postprocess_info vo_pp_scale_info
static struct video_frame * scale_getf(void *state)
static void scale_done(void *state)
static void scale_get_out_desc(void *state, struct video_desc *out, int *in_display_mode, int *out_frames)
struct gl_context context
Struct tile is an area of video_frame.
char * data
Raw tile data. Pointer must be at least 4B aligned.
unsigned int data_len
length of the data
enum interlacing_t interlacing
unsigned int width
width of every tile (!)
unsigned int height
height of every tile (!)
Struct video_frame represents a video frame and contains video description.
enum interlacing_t interlacing
struct tile tiles[FLEXIBLE_ARRAY_MEMBER]
@ INTERLACED_MERGED
Columngs of both fields are interlaced together.
@ UYVY
YCbCr 422 8-bit - Cb Y0 Cr Y1.
@ RGBA
RGBA 8-bit, big-endian.
This is an umbrella header for video functions.
struct tile * vf_get_tile(struct video_frame *buf, int pos)
Returns pointer to n-th tile from video frame Equivalent to &video_frame::tiles[pos].
#define VO_PP_PROPERTY_CODECS
#define VO_PP_ABI_VERSION