+ // default to 8bit 4:2:0 if nothing is specified
+ if( colorspace == X264_CSP_NONE )
+ {
+ colorspace = X264_CSP_I420;
+ h->bit_depth = 8;
+ }
+
+ FAIL_IF_ERROR( colorspace <= X264_CSP_NONE || colorspace >= X264_CSP_MAX, "colorspace unhandled\n" )
+ FAIL_IF_ERROR( h->bit_depth < 8 || h->bit_depth > 16, "unsupported bit depth `%d'\n", h->bit_depth );
+
+ info->thread_safe = 1;
+ info->num_frames = 0;
+ info->csp = colorspace;
+
+ if( h->bit_depth > 8 )
+ info->csp |= X264_CSP_HIGH_DEPTH;
+
+ const x264_cli_csp_t *csp = x264_cli_get_csp( info->csp );
+
+ for( i = 0; i < csp->planes; i++ )
+ {
+ h->plane_size[i] = x264_cli_pic_plane_size( info->csp, info->width, info->height, i );
+ h->frame_size += h->plane_size[i];
+ /* x264_cli_pic_plane_size returns the size in bytes, we need the value in pixels from here on */
+ h->plane_size[i] /= x264_cli_csp_depth_factor( info->csp );
+ }