+static int handle_opts( crop_hnd_t *h, video_info_t *info, char **opts, const char * const *optlist )
+{
+ for( int i = 0; i < 4; i++ )
+ {
+ char *opt = x264_get_option( optlist[i], opts );
+ FAIL_IF_ERROR( !opt, "%s crop value not specified\n", optlist[i] )
+ h->dims[i] = x264_otoi( opt, -1 );
+ FAIL_IF_ERROR( h->dims[i] < 0, "%s crop value `%s' is less than 0\n", optlist[i], opt )
+ int dim_mod = i&1 ? (h->csp->mod_height << info->interlaced) : h->csp->mod_width;
+ FAIL_IF_ERROR( h->dims[i] % dim_mod, "%s crop value `%s' is not a multiple of %d\n", optlist[i], opt, dim_mod )
+ }
+ return 0;
+}
+