1 /*****************************************************************************
2 * opencl.h: OpenCL structures and defines
3 *****************************************************************************
4 * Copyright (C) 2012-2013 x264 project
6 * Authors: Steve Borho <sborho@multicorewareinc.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
22 * This program is also available under a commercial proprietary license.
23 * For more information, contact us at licensing@x264.com.
24 *****************************************************************************/
30 #include "common/common.h"
34 /* Number of downscale resolutions to use for motion search */
35 #define NUM_IMAGE_SCALES 4
37 /* Number of PCIe copies that can be queued before requiring a flush */
38 #define MAX_FINISH_COPIES 1024
40 /* Size (in bytes) of the page-locked buffer used for PCIe xfers */
41 #define PAGE_LOCKED_BUF_SIZE 32 * 1024 * 1024
47 cl_command_queue queue;
49 cl_program lookahead_program;
52 cl_mem page_locked_buffer;
53 char *page_locked_ptr;
61 } copies[MAX_FINISH_COPIES];
66 int lookahead_thread_pri;
67 int opencl_thread_pri;
69 /* downscale lowres luma */
70 cl_kernel downscale_hpel_kernel;
71 cl_kernel downscale_kernel1;
72 cl_kernel downscale_kernel2;
73 cl_mem luma_16x16_image[2];
75 /* weightp filtering */
76 cl_kernel weightp_hpel_kernel;
77 cl_kernel weightp_scaled_images_kernel;
78 cl_mem weighted_scaled_images[NUM_IMAGE_SCALES];
79 cl_mem weighted_luma_hpel;
82 cl_kernel memset_kernel;
83 cl_kernel intra_kernel;
84 cl_kernel rowsum_intra_kernel;
87 /* hierarchical motion estimation */
89 cl_kernel subpel_refine_kernel;
91 cl_mem lowres_mv_costs;
95 cl_kernel mode_select_kernel;
96 cl_kernel rowsum_inter_kernel;
97 cl_mem lowres_costs[2];
98 cl_mem frame_stats[2]; /* cost_est, cost_est_aq, intra_mbs */
103 cl_mem scaled_image2Ds[NUM_IMAGE_SCALES];
105 cl_mem inv_qscale_factor;
109 cl_mem lowres_mv_costs0;
110 cl_mem lowres_mv_costs1;
111 } x264_frame_opencl_t;
113 typedef struct x264_frame x264_frame;
115 int x264_opencl_init( x264_t *h );
116 int x264_opencl_init_lookahead( x264_t *h );
117 void x264_opencl_free( x264_t *h );
118 void x264_opencl_frame_delete( x264_frame *frame );