static gavl_source_status_t read_func(void * priv, gavl_video_frame_t ** f) { gavl_video_frame_t * in_frame = NULL; cropscale_priv_t * vp; gavl_source_status_t st; vp = priv; if((st = gavl_video_source_read_frame(vp->in_src, &in_frame)) != GAVL_SOURCE_OK) return st; if(vp->need_reinit) init_scaler(vp); if(vp->maintain_aspect) gavl_video_frame_fill(*f, &vp->out_format, vp->border_color); gavl_video_scaler_scale(vp->scaler, in_frame, *f); gavl_video_frame_copy_metadata(*f, in_frame); return GAVL_SOURCE_OK; }
static void scale_func(gavl_video_convert_context_t * ctx) { gavl_video_scaler_scale(ctx->scaler, ctx->input_frame, ctx->output_frame); }
static void deinterlace_scale(gavl_video_deinterlacer_t * d, const gavl_video_frame_t * in, gavl_video_frame_t * out) { gavl_video_scaler_scale(d->scaler, in, out); }
int process_instance( livido_port_t *my_instance, double timecode ) { uint8_t *A[4] = {NULL,NULL,NULL,NULL}; uint8_t *B[4] = {NULL,NULL,NULL,NULL}; uint8_t *O[4] = {NULL,NULL,NULL,NULL}; int palette; int w; int h; scale0tilt_instance_t *inst = NULL; livido_property_get( my_instance, "PLUGIN_private", 0, &inst ); if( inst == NULL ) return LIVIDO_ERROR_INTERNAL; int error = lvd_extract_channel_values( my_instance, "out_channels", 0, &w,&h, O,&palette ); if( error != LIVIDO_NO_ERROR ) return LIVIDO_ERROR_NO_OUTPUT_CHANNELS; error = lvd_extract_channel_values( my_instance, "in_channels" , 0, &w, &h, A, &palette ); if( error != LIVIDO_NO_ERROR ) return LIVIDO_ERROR_NO_INPUT_CHANNELS; error = lvd_extract_channel_values( my_instance, "in_channels" , 1, &w, &h, B, &palette ); if( error != LIVIDO_NO_ERROR ) return LIVIDO_ERROR_NO_INPUT_CHANNELS; double width = (double)w; double height= (double)h; inst->cl = lvd_extract_param_index( my_instance,"in_parameters", 0 ) / width; inst->cr = ((double) lvd_extract_param_index( my_instance,"in_parameters", 1 )) / width; inst->ct = ((double) lvd_extract_param_index( my_instance, "in_parameters", 2 )) / height; inst->cb = ((double) lvd_extract_param_index( my_instance, "in_parameters", 3)) / height; inst->sx = ( (double) lvd_extract_param_index( my_instance,"in_parameters", 4 ) / width) * 2.0; inst->sy = ( (double) lvd_extract_param_index( my_instance,"in_parameters", 5 ) / height) * 2.0; inst->tx = ( (double) lvd_extract_param_index( my_instance, "in_parameters", 6 ) / width) * 2.0 - 1.0; inst->ty = ( (double) lvd_extract_param_index( my_instance, "in_parameters", 7) / height) * 2.0 - 1.0; int alpha = lvd_extract_param_index( my_instance, "in_parameters", 8 ); inst->frame_src->strides[0] = width; inst->frame_src->strides[1] = width; inst->frame_src->strides[2] = width; inst->frame_dst->strides[0] = width; inst->frame_dst->strides[1] = width; inst->frame_dst->strides[2] = width; update_scaler( inst ); gavl_video_frame_t* frame_src = inst->frame_src; inst->frame_src->planes[0] = B[0]; inst->frame_src->planes[1] = B[1]; inst->frame_src->planes[2] = B[2]; inst->frame_dst->planes[0] = O[0]; inst->frame_dst->planes[1] = O[1]; inst->frame_dst->planes[2] = O[2]; if ( inst->do_scale ) { int len = w * h; int i; livido_memset( inst->temp_alpha->planes[0],0,len); /* scale alpha channel first */ inst->frame_src->strides[0] = width; inst->frame_src->strides[1] = 0; inst->frame_src->strides[2] = 0; inst->frame_src->planes[0] = B[3]; inst->temp_alpha->strides[0] = width; inst->temp_alpha->strides[1] = 0; inst->temp_alpha->strides[2] = 0; gavl_video_scaler_scale( inst->video_scaler, frame_src, inst->temp_alpha ); /* setup pointers for frames */ inst->frame_src->strides[1] = width; inst->frame_src->strides[2] = width; inst->frame_src->planes[0] = B[0]; inst->frame_src->planes[1] = B[1]; inst->frame_src->planes[2] = B[2]; inst->frame_dst->strides[0] = width; inst->frame_dst->strides[1] = width; inst->frame_dst->strides[2] = width; inst->frame_dst->planes[0] = O[0]; inst->frame_dst->planes[1] = O[1]; inst->frame_dst->planes[2] = O[2]; if(alpha) { livido_memset( inst->temp->planes[0], 0, len ); livido_memset( inst->temp->planes[1],128,len ); livido_memset( inst->temp->planes[2],128,len ); gavl_video_scaler_scale( inst->video_scaler, frame_src, inst->temp ); const uint8_t *t0 = inst->temp->planes[0]; const uint8_t *t1 = inst->temp->planes[1]; const uint8_t *t2 = inst->temp->planes[2]; const uint8_t *tA = inst->temp_alpha->planes[0]; for( i = 0; i < len; i ++ ) { if( tA[i] > 0 ) { unsigned int op1 = tA[i]; unsigned int op0 = 0xff - tA[i]; O[0][i] = (op0 * O[0][i] + op1 * t0[i]) >> 8; O[1][i] = (op0 * O[1][i] + op1 * t1[i]) >> 8; O[2][i] = (op0 * O[2][i] + op1 * t2[i]) >> 8; O[3][i] = op1; } } }