summaryrefslogtreecommitdiff
path: root/src/gen9_encoder_vp8.c
blob: 2ac5efa8bf0b43eb2a60dd4837d1199a50c7230f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
 * Copyright © 2017 Intel Corporation
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sub license, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice (including the
 * next paragraph) shall be included in all copies or substantial portions
 * of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Authors:
 *    Xiang, Haihao <haihao.xiang@intel.com>
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <assert.h>

#include "intel_batchbuffer.h"
#include "intel_driver.h"

#include "i965_defines.h"
#include "i965_drv_video.h"
#include "i965_encoder.h"
#include "i965_encoder_vp8.h"

extern struct i965_kernel vp8_kernels_brc_init_reset[NUM_VP8_BRC_RESET];
extern struct i965_kernel vp8_kernels_scaling[NUM_VP8_SCALING];
extern struct i965_kernel vp8_kernels_me[NUM_VP8_ME];
extern struct i965_kernel vp8_kernels_mbenc[NUM_VP8_MBENC];
extern struct i965_kernel vp8_kernels_mpu[NUM_VP8_MPU];
extern struct i965_kernel vp8_kernels_tpu[NUM_VP8_TPU];
extern struct i965_kernel vp8_kernels_brc_update[NUM_VP8_BRC_UPDATE];

static const uint32_t gen9_brc_init_bin_vp8[][4] = {
#include "shaders/brc/skl/vp8_brc_init_genx_0.g9b"
};

static const uint32_t gen9_brc_reset_bin_vp8[][4] = {
#include "shaders/brc/skl/vp8_brc_reset_genx_0.g9b"
};

static const uint32_t gen9_scaling_bin_vp8[][4] = {
#include "shaders/brc/skl/hme_downscale_genx_0.g9b"
};

static const uint32_t gen9_me_bin_vp8[][4] = {
#include "shaders/brc/skl/hme_genx_0.g9b"
};

static const uint32_t gen9_mbenc_i_frame_dist_bin_vp8[][4] = {
#include "shaders/brc/skl/vp8_intra_distortion_genx_0.g9b"
};

static const uint32_t gen9_mbenc_i_frame_luma_bin_vp8[][4] = {
#include "shaders/brc/skl/vp8_enc_genx_0.g9b"
};

static const uint32_t gen9_mbenc_i_frame_chroma_bin_vp8[][4] = {
#include "shaders/brc/skl/vp8_enc_genx_1.g9b"
};

static const uint32_t gen9_mbenc_p_frame_bin_vp8[][4] = {
#include "shaders/brc/skl/vp8_enc_genx_2.g9b"
};

static const uint32_t gen9_mpu_bin_vp8[][4] = {
#include "shaders/brc/skl/vp8_mpu_genx_0.g9b"
};

static const uint32_t gen9_tpu_bin_vp8[][4] = {
#include "shaders/brc/skl/vp8_tpu_genx_0.g9b"
};

static const uint32_t gen9_brc_update_bin_vp8[][4] = {
#include "shaders/brc/skl/vp8_brc_update_genx_0.g9b"
};

Bool
gen9_encoder_vp8_context_init(VADriverContextP ctx,
                              struct intel_encoder_context *encoder_context,
                              struct i965_encoder_vp8_context *vp8_context)
{
    vp8_kernels_brc_init_reset[VP8_BRC_INIT].bin = gen9_brc_init_bin_vp8;
    vp8_kernels_brc_init_reset[VP8_BRC_INIT].size = sizeof(gen9_brc_init_bin_vp8);
    vp8_kernels_brc_init_reset[VP8_BRC_RESET].bin = gen9_brc_reset_bin_vp8;
    vp8_kernels_brc_init_reset[VP8_BRC_RESET].size = sizeof(gen9_brc_reset_bin_vp8);

    /* scaling 4x and 16x use the same kernel */
    vp8_kernels_scaling[VP8_SCALING_4X].bin = gen9_scaling_bin_vp8;
    vp8_kernels_scaling[VP8_SCALING_4X].size = sizeof(gen9_scaling_bin_vp8);
    vp8_kernels_scaling[VP8_SCALING_16X].bin = gen9_scaling_bin_vp8;
    vp8_kernels_scaling[VP8_SCALING_16X].size = sizeof(gen9_scaling_bin_vp8);

    /* me 4x and 16x use the same kernel */
    vp8_kernels_me[VP8_ME_4X].bin = gen9_me_bin_vp8;
    vp8_kernels_me[VP8_ME_4X].size = sizeof(gen9_me_bin_vp8);
    vp8_kernels_me[VP8_ME_16X].bin = gen9_me_bin_vp8;
    vp8_kernels_me[VP8_ME_16X].size = sizeof(gen9_me_bin_vp8);

    vp8_kernels_mbenc[VP8_MBENC_I_FRAME_DIST].bin = gen9_mbenc_i_frame_dist_bin_vp8;
    vp8_kernels_mbenc[VP8_MBENC_I_FRAME_DIST].size = sizeof(gen9_mbenc_i_frame_dist_bin_vp8);
    vp8_kernels_mbenc[VP8_MBENC_I_FRAME_LUMA].bin = gen9_mbenc_i_frame_luma_bin_vp8;
    vp8_kernels_mbenc[VP8_MBENC_I_FRAME_LUMA].size = sizeof(gen9_mbenc_i_frame_luma_bin_vp8);
    vp8_kernels_mbenc[VP8_MBENC_I_FRAME_CHROMA].bin = gen9_mbenc_i_frame_chroma_bin_vp8;
    vp8_kernels_mbenc[VP8_MBENC_I_FRAME_CHROMA].size = sizeof(gen9_mbenc_i_frame_chroma_bin_vp8);
    vp8_kernels_mbenc[VP8_MBENC_P_FRAME].bin = gen9_mbenc_p_frame_bin_vp8;
    vp8_kernels_mbenc[VP8_MBENC_P_FRAME].size = sizeof(gen9_mbenc_p_frame_bin_vp8);

    vp8_kernels_mpu[VP8_MPU].bin = gen9_mpu_bin_vp8;
    vp8_kernels_mpu[VP8_MPU].size = sizeof(gen9_mpu_bin_vp8);

    vp8_kernels_brc_update[VP8_BRC_UPDATE].bin = gen9_brc_update_bin_vp8;
    vp8_kernels_brc_update[VP8_BRC_UPDATE].size = sizeof(gen9_brc_update_bin_vp8);

    vp8_kernels_tpu[VP8_TPU].bin = gen9_tpu_bin_vp8;
    vp8_kernels_tpu[VP8_TPU].size = sizeof(gen9_tpu_bin_vp8);

    vp8_context->idrt_entry_size = ALIGN(sizeof(struct gen8_interface_descriptor_data), 64);

    return True;
}