int gavl_deinterlacer_init_scale(gavl_video_deinterlacer_t * d) { gavl_video_options_t * scaler_opt; gavl_video_format_t in_format; gavl_video_format_t out_format; if(!d->scaler) d->scaler = gavl_video_scaler_create(); scaler_opt = gavl_video_scaler_get_options(d->scaler); gavl_video_options_copy(scaler_opt, &d->opt); gavl_video_format_copy(&in_format, &d->format); gavl_video_format_copy(&out_format, &d->format); if(in_format.interlace_mode == GAVL_INTERLACE_NONE) in_format.interlace_mode = GAVL_INTERLACE_TOP_FIRST; out_format.interlace_mode = GAVL_INTERLACE_NONE; gavl_video_scaler_init(d->scaler, &in_format, &out_format); d->func = deinterlace_scale; return 1; }
static void * create_cropscale() { cropscale_priv_t * ret; ret = calloc(1, sizeof(*ret)); ret->scaler = gavl_video_scaler_create(); ret->opt = gavl_video_scaler_get_options(ret->scaler); ret->global_opt = gavl_video_options_create(); ret->border_color[3] = 1.0; return ret; }
static int add_context_scale(gavl_video_converter_t * cnv, const gavl_video_format_t * input_format, const gavl_video_format_t * output_format) { gavl_video_options_t * scaler_options; gavl_video_convert_context_t * ctx; ctx = add_context(cnv, input_format, output_format); ctx->scaler = gavl_video_scaler_create(); scaler_options = gavl_video_scaler_get_options(ctx->scaler); gavl_video_options_copy(scaler_options, &cnv->options); #if 0 fprintf(stderr, "gavl_video_scaler_init:\n"); fprintf(stderr, "src_format:\n"); gavl_video_format_dump(input_format); fprintf(stderr, "dst_format:\n"); gavl_video_format_dump(output_format); fprintf(stderr, "src_rectangle: "); gavl_rectangle_f_dump(&cnv->options.src_rect); fprintf(stderr, "\n"); fprintf(stderr, "dst_rectangle: "); gavl_rectangle_i_dump(&cnv->options.dst_rect); fprintf(stderr, "\n"); #endif if(!gavl_video_scaler_init(ctx->scaler, input_format, output_format)) { // fprintf(stderr, "Initializing scaler failed\n"); return 0; } ctx->func = scale_func; return 1; }
static void update_scaler( scale0tilt_instance_t* inst ) { float dst_x, dst_y, dst_w, dst_h; float src_x, src_y, src_w, src_h; inst->do_scale = 1; src_x = inst->w * inst->cl; src_y = inst->h * inst->ct; src_w = inst->w * (1.0 - inst->cl - inst->cr ); src_h = inst->h * (1.0 - inst->ct - inst->cb ); dst_x = inst->w * inst->cl * inst->sx + inst->tx * inst->w; dst_y = inst->h * inst->ct * inst->sy + inst->ty * inst->h; dst_w = inst->w * (1.0 - inst->cl - inst->cr) * inst->sx; dst_h = inst->h * (1.0 - inst->ct - inst->cb) * inst->sy; if((dst_w < EPSILON) || (dst_h < EPSILON) || (src_w < EPSILON) || (src_h < EPSILON)) { inst->do_scale = 0; return; } if ( dst_x + dst_w > inst->w ) { src_w = src_w * ( (inst->w-dst_x) / dst_w ); dst_w = inst->w - dst_x; } if ( dst_y + dst_h > inst->h ) { src_h = src_h * ( (inst->h-dst_y) / dst_h ); dst_h = inst->h - dst_y; } if ( dst_x < 0 ) { src_x = src_x - dst_x * ( src_w / dst_w ); src_w = src_w * ( (dst_w+dst_x) / dst_w ); dst_w = dst_w + dst_x; dst_x = 0; } if ( dst_y < 0 ) { src_y = src_y - dst_y * ( src_h / dst_h ); src_h = src_h * ( (dst_h+dst_y) / dst_h ); dst_h = dst_h + dst_y; dst_y = 0; } if((dst_w < EPSILON) || (dst_h < EPSILON) || (src_w < EPSILON) || (src_h < EPSILON)) { inst->do_scale = 0; return; } gavl_video_options_t* options = gavl_video_scaler_get_options( inst->video_scaler ); gavl_video_format_t format_dst; livido_memset(&format_dst, 0, sizeof(format_dst)); format_dst.frame_width = inst->w; format_dst.frame_height = inst->h; format_dst.image_width = inst->w; format_dst.image_height = inst->h; format_dst.pixel_width = 1; format_dst.pixel_height = 1; format_dst.pixelformat = GAVL_YUVJ_444_P; gavl_rectangle_f_t src_rect; gavl_rectangle_i_t dst_rect; src_rect.x = src_x; src_rect.y = src_y; src_rect.w = src_w; src_rect.h = src_h; dst_rect.x = lroundf(dst_x); dst_rect.y = lroundf(dst_y); dst_rect.w = lroundf(dst_w); dst_rect.h = lroundf(dst_h); gavl_video_options_set_rectangles( options, &src_rect, &dst_rect ); gavl_video_scaler_init( inst->video_scaler, &inst->format_src, &format_dst ); }