28 # define FUNC(n) AV_JOIN(n ## _simple_, BITS)
29 # define PIXEL_SHIFT (BITS >> 4)
31 # define FUNC(n) n ## _complex
32 # define PIXEL_SHIFT h->pixel_shift
45 const int mb_x = sl->mb_x;
46 const int mb_y = sl->mb_y;
47 const int mb_xy = sl->mb_xy;
48 const int mb_type =
h->cur_pic.mb_type[mb_xy];
49 uint8_t *dest_y, *dest_cb, *dest_cr;
50 int linesize, uvlinesize ;
52 const int *block_offset = &
h->block_offset[0];
53 const int transform_bypass = !
SIMPLE && (sl->qscale == 0 &&
h->sps.transform_bypass);
57 const int block_h = 16 >>
h->chroma_y_shift;
60 dest_y =
h->cur_pic.f->data[0] + ((mb_x <<
PIXEL_SHIFT) + mb_y * sl->linesize) * 16;
61 dest_cb =
h->cur_pic.f->data[1] + (mb_x <<
PIXEL_SHIFT) * 8 + mb_y * sl->uvlinesize * block_h;
62 dest_cr =
h->cur_pic.f->data[2] + (mb_x <<
PIXEL_SHIFT) * 8 + mb_y * sl->uvlinesize * block_h;
64 h->vdsp.prefetch(dest_y + (sl->mb_x & 3) * 4 * sl->linesize + (64 <<
PIXEL_SHIFT), sl->linesize, 4);
65 h->vdsp.prefetch(dest_cb + (sl->mb_x & 7) * sl->uvlinesize + (64 <<
PIXEL_SHIFT), dest_cr - dest_cb, 2);
67 h->list_counts[mb_xy] = sl->list_count;
70 linesize = sl->mb_linesize = sl->linesize * 2;
71 uvlinesize = sl->mb_uvlinesize = sl->uvlinesize * 2;
72 block_offset = &
h->block_offset[48];
74 dest_y -= sl->linesize * 15;
75 dest_cb -= sl->uvlinesize * (block_h - 1);
76 dest_cr -= sl->uvlinesize * (block_h - 1);
80 for (list = 0; list < sl->list_count; list++) {
84 int8_t *ref = &sl->ref_cache[list][
scan8[0]];
87 for (i = 0; i < 16; i += 4) {
88 int ref = sl->ref_cache[list][
scan8[i]];
91 8, (16 + ref) ^ (sl->mb_y & 1), 1);
97 linesize = sl->mb_linesize = sl->linesize;
98 uvlinesize = sl->mb_uvlinesize = sl->uvlinesize;
110 for (i = 0; i < 16; i++) {
111 uint16_t *tmp_y = (uint16_t *)(dest_y + i * linesize);
112 for (j = 0; j < 16; j++)
113 tmp_y[j] =
get_bits(&gb, bit_depth);
116 if (!
h->sps.chroma_format_idc) {
117 for (i = 0; i < block_h; i++) {
118 uint16_t *tmp_cb = (uint16_t *)(dest_cb + i * uvlinesize);
119 uint16_t *tmp_cr = (uint16_t *)(dest_cr + i * uvlinesize);
120 for (j = 0; j < 8; j++) {
121 tmp_cb[j] = tmp_cr[j] = 1 << (bit_depth - 1);
125 for (i = 0; i < block_h; i++) {
126 uint16_t *tmp_cb = (uint16_t *)(dest_cb + i * uvlinesize);
127 for (j = 0; j < 8; j++)
128 tmp_cb[j] =
get_bits(&gb, bit_depth);
130 for (i = 0; i < block_h; i++) {
131 uint16_t *tmp_cr = (uint16_t *)(dest_cr + i * uvlinesize);
132 for (j = 0; j < 8; j++)
133 tmp_cr[j] =
get_bits(&gb, bit_depth);
138 for (i = 0; i < 16; i++)
139 memcpy(dest_y + i * linesize, sl->intra_pcm_ptr + i * 16, 16);
141 if (!
h->sps.chroma_format_idc) {
142 for (i = 0; i < 8; i++) {
143 memset(dest_cb + i * uvlinesize, 1 << (bit_depth - 1), 8);
144 memset(dest_cr + i * uvlinesize, 1 << (bit_depth - 1), 8);
147 const uint8_t *src_cb = sl->intra_pcm_ptr + 256;
148 const uint8_t *src_cr = sl->intra_pcm_ptr + 256 + block_h * 8;
149 for (i = 0; i < block_h; i++) {
150 memcpy(dest_cb + i * uvlinesize, src_cb + i * 8, 8);
151 memcpy(dest_cr + i * uvlinesize, src_cr + i * 8, 8);
158 if (sl->deblocking_filter)
163 h->hpc.pred8x8[sl->chroma_pred_mode](dest_cb, uvlinesize);
164 h->hpc.pred8x8[sl->chroma_pred_mode](dest_cr, uvlinesize);
169 block_offset, linesize, dest_y, 0);
171 if (sl->deblocking_filter)
174 }
else if (is_h264) {
176 FUNC(hl_motion_422)(
h, sl, dest_y, dest_cb, dest_cr,
177 h->qpel_put,
h->h264chroma.put_h264_chroma_pixels_tab,
178 h->qpel_avg,
h->h264chroma.avg_h264_chroma_pixels_tab,
179 h->h264dsp.weight_h264_pixels_tab,
180 h->h264dsp.biweight_h264_pixels_tab);
182 FUNC(hl_motion_420)(
h, sl, dest_y, dest_cb, dest_cr,
183 h->qpel_put,
h->h264chroma.put_h264_chroma_pixels_tab,
184 h->qpel_avg,
h->h264chroma.avg_h264_chroma_pixels_tab,
185 h->h264dsp.weight_h264_pixels_tab,
186 h->h264dsp.biweight_h264_pixels_tab);
195 uint8_t *dest[2] = { dest_cb, dest_cr };
196 if (transform_bypass) {
197 if (
IS_INTRA(mb_type) &&
h->sps.profile_idc == 244 &&
200 h->hpc.pred8x8_add[sl->chroma_pred_mode](dest[0],
204 h->hpc.pred8x8_add[sl->chroma_pred_mode](dest[1],
209 idct_add =
h->h264dsp.h264_add_pixels4_clear;
210 for (j = 1; j < 3; j++) {
211 for (i = j * 16; i < j * 16 + 4; i++)
212 if (sl->non_zero_count_cache[
scan8[i]] ||
214 idct_add(dest[j - 1] + block_offset[i],
218 for (i = j * 16 + 4; i < j * 16 + 8; i++)
219 if (sl->non_zero_count_cache[
scan8[i + 4]] ||
221 idct_add(dest[j - 1] + block_offset[i + 4],
231 qp[0] = sl->chroma_qp[0] + 3;
232 qp[1] = sl->chroma_qp[1] + 3;
234 qp[0] = sl->chroma_qp[0];
235 qp[1] = sl->chroma_qp[1];
238 h->h264dsp.h264_chroma_dc_dequant_idct(sl->mb + (16 * 16 * 1 <<
PIXEL_SHIFT),
239 h->dequant4_coeff[
IS_INTRA(mb_type) ? 1 : 4][qp[0]][0]);
241 h->h264dsp.h264_chroma_dc_dequant_idct(sl->mb + (16 * 16 * 2 <<
PIXEL_SHIFT),
242 h->dequant4_coeff[
IS_INTRA(mb_type) ? 2 : 5][qp[1]][0]);
243 h->h264dsp.h264_idct_add8(dest, block_offset,
245 sl->non_zero_count_cache);
246 }
else if (CONFIG_SVQ3_DECODER) {
247 h->h264dsp.h264_chroma_dc_dequant_idct(sl->mb + 16 * 16 * 1,
248 h->dequant4_coeff[
IS_INTRA(mb_type) ? 1 : 4][sl->chroma_qp[0]][0]);
249 h->h264dsp.h264_chroma_dc_dequant_idct(sl->mb + 16 * 16 * 2,
250 h->dequant4_coeff[
IS_INTRA(mb_type) ? 2 : 5][sl->chroma_qp[1]][0]);
251 for (j = 1; j < 3; j++) {
252 for (i = j * 16; i < j * 16 + 4; i++)
253 if (sl->non_zero_count_cache[
scan8[i]] || sl->mb[i * 16]) {
254 uint8_t *
const ptr = dest[j - 1] + block_offset[i];
266 #if !SIMPLE || BITS == 8
274 const int mb_x = sl->mb_x;
275 const int mb_y = sl->mb_y;
276 const int mb_xy = sl->mb_xy;
277 const int mb_type =
h->cur_pic.mb_type[mb_xy];
281 const int *block_offset = &
h->block_offset[0];
282 const int transform_bypass = !
SIMPLE && (sl->qscale == 0 &&
h->sps.transform_bypass);
285 for (p = 0; p < plane_count; p++) {
286 dest[p] =
h->cur_pic.f->data[p] +
287 ((mb_x <<
PIXEL_SHIFT) + mb_y * sl->linesize) * 16;
288 h->vdsp.prefetch(dest[p] + (sl->mb_x & 3) * 4 * sl->linesize + (64 <<
PIXEL_SHIFT),
292 h->list_counts[mb_xy] = sl->list_count;
295 linesize = sl->mb_linesize = sl->mb_uvlinesize = sl->linesize * 2;
296 block_offset = &
h->block_offset[48];
298 for (p = 0; p < 3; p++)
299 dest[p] -= sl->linesize * 15;
302 for (list = 0; list < sl->list_count; list++) {
306 int8_t *ref = &sl->ref_cache[list][
scan8[0]];
309 for (i = 0; i < 16; i += 4) {
310 int ref = sl->ref_cache[list][
scan8[i]];
313 8, (16 + ref) ^ (sl->mb_y & 1), 1);
319 linesize = sl->mb_linesize = sl->mb_uvlinesize = sl->linesize;
328 for (p = 0; p < plane_count; p++)
329 for (i = 0; i < 16; i++) {
330 uint16_t *tmp = (uint16_t *)(dest[p] + i * linesize);
331 for (j = 0; j < 16; j++)
335 for (p = 0; p < plane_count; p++)
336 for (i = 0; i < 16; i++)
337 memcpy(dest[p] + i * linesize,
338 sl->intra_pcm_ptr + p * 256 + i * 16, 16);
342 if (sl->deblocking_filter)
346 for (p = 0; p < plane_count; p++)
349 block_offset, linesize, dest[p], p);
351 if (sl->deblocking_filter)
355 FUNC(hl_motion_444)(
h, sl, dest[0], dest[1], dest[2],
356 h->qpel_put,
h->h264chroma.put_h264_chroma_pixels_tab,
357 h->qpel_avg,
h->h264chroma.avg_h264_chroma_pixels_tab,
358 h->h264dsp.weight_h264_pixels_tab,
359 h->h264dsp.biweight_h264_pixels_tab);
362 for (p = 0; p < plane_count; p++)
static av_always_inline void hl_decode_mb_idct_luma(const H264Context *h, H264SliceContext *sl, int mb_type, int is_h264, int simple, int transform_bypass, int pixel_shift, const int *block_offset, int linesize, uint8_t *dest_y, int p)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static av_always_inline void hl_decode_mb_predict_luma(const H264Context *h, H264SliceContext *sl, int mb_type, int is_h264, int simple, int transform_bypass, int pixel_shift, const int *block_offset, int linesize, uint8_t *dest_y, int p)
#define USES_LIST(a, list)
static void fill_rectangle(SDL_Surface *screen, int x, int y, int w, int h, int color, int update)
#define AV_CODEC_FLAG_GRAY
Only decode/encode grayscale.
const uint8_t ff_h264_chroma_qp[7][QP_MAX_NUM+1]
One chroma qp table for each possible bit depth (8-14).
#define CHROMA_DC_BLOCK_INDEX
static const uint8_t scan8[16 *3+3]
void ff_svq3_add_idct_c(uint8_t *dst, int16_t *block, int stride, int qp, int dc)
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
static av_always_inline int dctcoef_get(int16_t *mb, int high_bit_depth, int index)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static av_always_inline void xchg_mb_border(const H264Context *h, H264SliceContext *sl, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr, int linesize, int uvlinesize, int xchg, int chroma444, int simple, int pixel_shift)
static unsigned bit_depth(uint64_t mask)
static av_noinline void FUNC() hl_decode_mb(const H264Context *h, H264SliceContext *sl)
const uint16_t ff_h264_mb_sizes[4]
static av_noinline void FUNC() hl_decode_mb_444(const H264Context *h, H264SliceContext *sl)