26 # define FUNC(n) AV_JOIN(n ## _simple_, BITS)
27 # define PIXEL_SHIFT (BITS >> 4)
29 # define FUNC(n) n ## _complex
30 # define PIXEL_SHIFT h->pixel_shift
43 const int mb_x = h->mb_x;
44 const int mb_y = h->mb_y;
45 const int mb_xy = h->mb_xy;
46 const int mb_type = h->cur_pic.mb_type[
mb_xy];
47 uint8_t *dest_y, *dest_cb, *dest_cr;
51 const int transform_bypass = !
SIMPLE && (h->qscale == 0 && h->sps.transform_bypass);
55 const int block_h = 16 >> h->chroma_y_shift;
58 dest_y = h->cur_pic.f.data[0] + ((mb_x <<
PIXEL_SHIFT) + mb_y * h->linesize) * 16;
59 dest_cb = h->cur_pic.f.data[1] + (mb_x <<
PIXEL_SHIFT) * 8 + mb_y * h->uvlinesize * block_h;
60 dest_cr = h->cur_pic.f.data[2] + (mb_x <<
PIXEL_SHIFT) * 8 + mb_y * h->uvlinesize * block_h;
62 h->vdsp.prefetch(dest_y + (h->mb_x & 3) * 4 * h->linesize + (64 <<
PIXEL_SHIFT), h->linesize, 4);
63 h->vdsp.prefetch(dest_cb + (h->mb_x & 7) * h->uvlinesize + (64 <<
PIXEL_SHIFT), dest_cr - dest_cb, 2);
65 h->list_counts[
mb_xy] = h->list_count;
68 linesize = h->mb_linesize = h->linesize * 2;
69 uvlinesize = h->mb_uvlinesize = h->uvlinesize * 2;
70 block_offset = &h->block_offset[48];
72 dest_y -= h->linesize * 15;
73 dest_cb -= h->uvlinesize * (block_h - 1);
74 dest_cr -= h->uvlinesize * (block_h - 1);
78 for (list = 0; list < h->list_count; list++) {
82 int8_t *ref = &h->ref_cache[list][
scan8[0]];
85 for (i = 0; i < 16; i += 4) {
86 int ref = h->ref_cache[list][
scan8[i]];
89 8, (16 + ref) ^ (h->mb_y & 1), 1);
95 linesize = h->mb_linesize = h->linesize;
96 uvlinesize = h->mb_uvlinesize = h->uvlinesize;
102 const int bit_depth = h->sps.bit_depth_luma;
108 for (i = 0; i < 16; i++) {
109 uint16_t *tmp_y = (uint16_t *)(dest_y + i * linesize);
110 for (j = 0; j < 16; j++)
111 tmp_y[j] =
get_bits(&gb, bit_depth);
114 if (!h->sps.chroma_format_idc) {
115 for (i = 0; i < block_h; i++) {
116 uint16_t *tmp_cb = (uint16_t *)(dest_cb + i * uvlinesize);
117 for (j = 0; j < 8; j++)
118 tmp_cb[j] = 1 << (bit_depth - 1);
120 for (i = 0; i < block_h; i++) {
121 uint16_t *tmp_cr = (uint16_t *)(dest_cr + i * uvlinesize);
122 for (j = 0; j < 8; j++)
123 tmp_cr[j] = 1 << (bit_depth - 1);
126 for (i = 0; i < block_h; i++) {
127 uint16_t *tmp_cb = (uint16_t *)(dest_cb + i * uvlinesize);
128 for (j = 0; j < 8; j++)
129 tmp_cb[j] =
get_bits(&gb, bit_depth);
131 for (i = 0; i < block_h; i++) {
132 uint16_t *tmp_cr = (uint16_t *)(dest_cr + i * uvlinesize);
133 for (j = 0; j < 8; j++)
134 tmp_cr[j] =
get_bits(&gb, bit_depth);
139 for (i = 0; i < 16; i++)
140 memcpy(dest_y + i * linesize, h->intra_pcm_ptr + i * 16, 16);
142 if (!h->sps.chroma_format_idc) {
143 for (i = 0; i < block_h; i++) {
144 memset(dest_cb + i * uvlinesize, 128, 8);
145 memset(dest_cr + i * uvlinesize, 128, 8);
148 const uint8_t *src_cb = h->intra_pcm_ptr + 256;
149 const uint8_t *src_cr = h->intra_pcm_ptr + 256 + block_h * 8;
150 for (i = 0; i < block_h; i++) {
151 memcpy(dest_cb + i * uvlinesize, src_cb + i * 8, 8);
152 memcpy(dest_cr + i * uvlinesize, src_cr + i * 8, 8);
159 if (h->deblocking_filter)
164 h->hpc.pred8x8[h->chroma_pred_mode](dest_cb,
uvlinesize);
165 h->hpc.pred8x8[h->chroma_pred_mode](dest_cr,
uvlinesize);
170 block_offset, linesize, dest_y, 0);
172 if (h->deblocking_filter)
175 }
else if (is_h264) {
177 FUNC(hl_motion_422)(h, dest_y, dest_cb, dest_cr,
178 h->me.qpel_put, h->h264chroma.put_h264_chroma_pixels_tab,
179 h->me.qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab,
180 h->h264dsp.weight_h264_pixels_tab,
181 h->h264dsp.biweight_h264_pixels_tab);
183 FUNC(hl_motion_420)(h, dest_y, dest_cb, dest_cr,
184 h->me.qpel_put, h->h264chroma.put_h264_chroma_pixels_tab,
185 h->me.qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab,
186 h->h264dsp.weight_h264_pixels_tab,
187 h->h264dsp.biweight_h264_pixels_tab);
196 uint8_t *dest[2] = { dest_cb, dest_cr };
197 if (transform_bypass) {
198 if (
IS_INTRA(mb_type) && h->sps.profile_idc == 244 &&
201 h->hpc.pred8x8_add[h->chroma_pred_mode](dest[0],
205 h->hpc.pred8x8_add[h->chroma_pred_mode](dest[1],
210 idct_add = h->h264dsp.h264_add_pixels4_clear;
211 for (j = 1; j < 3; j++) {
212 for (i = j * 16; i < j * 16 + 4; i++)
213 if (h->non_zero_count_cache[
scan8[i]] ||
215 idct_add(dest[j - 1] + block_offset[i],
219 for (i = j * 16 + 4; i < j * 16 + 8; i++)
220 if (h->non_zero_count_cache[
scan8[i + 4]] ||
222 idct_add(dest[j - 1] + block_offset[i + 4],
232 qp[0] = h->chroma_qp[0] + 3;
233 qp[1] = h->chroma_qp[1] + 3;
235 qp[0] = h->chroma_qp[0];
236 qp[1] = h->chroma_qp[1];
239 h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + (16 * 16 * 1 <<
PIXEL_SHIFT),
240 h->dequant4_coeff[
IS_INTRA(mb_type) ? 1 : 4][qp[0]][0]);
242 h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + (16 * 16 * 2 <<
PIXEL_SHIFT),
243 h->dequant4_coeff[
IS_INTRA(mb_type) ? 2 : 5][qp[1]][0]);
244 h->h264dsp.h264_idct_add8(dest, block_offset,
246 h->non_zero_count_cache);
248 h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + 16 * 16 * 1,
249 h->dequant4_coeff[
IS_INTRA(mb_type) ? 1 : 4][h->chroma_qp[0]][0]);
250 h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + 16 * 16 * 2,
251 h->dequant4_coeff[
IS_INTRA(mb_type) ? 2 : 5][h->chroma_qp[1]][0]);
252 for (j = 1; j < 3; j++) {
253 for (i = j * 16; i < j * 16 + 4; i++)
254 if (h->non_zero_count_cache[
scan8[i]] || h->mb[i * 16]) {
255 uint8_t *
const ptr = dest[j - 1] + block_offset[i];
267 #if !SIMPLE || BITS == 8
275 const int mb_x = h->mb_x;
276 const int mb_y = h->mb_y;
277 const int mb_xy = h->mb_xy;
278 const int mb_type = h->cur_pic.mb_type[
mb_xy];
283 const int transform_bypass = !
SIMPLE && (h->qscale == 0 && h->sps.transform_bypass);
286 for (p = 0; p < plane_count; p++) {
287 dest[p] = h->cur_pic.f.data[p] +
289 h->vdsp.prefetch(dest[p] + (h->mb_x & 3) * 4 * h->linesize + (64 <<
PIXEL_SHIFT),
293 h->list_counts[
mb_xy] = h->list_count;
296 linesize = h->mb_linesize = h->mb_uvlinesize = h->linesize * 2;
297 block_offset = &h->block_offset[48];
299 for (p = 0; p < 3; p++)
300 dest[p] -= h->linesize * 15;
303 for (list = 0; list < h->list_count; list++) {
307 int8_t *ref = &h->ref_cache[list][
scan8[0]];
310 for (i = 0; i < 16; i += 4) {
311 int ref = h->ref_cache[list][
scan8[i]];
314 8, (16 + ref) ^ (h->mb_y & 1), 1);
320 linesize = h->mb_linesize = h->mb_uvlinesize = h->linesize;
325 const int bit_depth = h->sps.bit_depth_luma;
329 for (p = 0; p < plane_count; p++)
330 for (i = 0; i < 16; i++) {
331 uint16_t *tmp = (uint16_t *)(dest[p] + i * linesize);
332 for (j = 0; j < 16; j++)
336 for (p = 0; p < plane_count; p++)
337 for (i = 0; i < 16; i++)
338 memcpy(dest[p] + i * linesize,
339 h->intra_pcm_ptr + p * 256 + i * 16, 16);
343 if (h->deblocking_filter)
347 for (p = 0; p < plane_count; p++)
350 block_offset, linesize, dest[p], p);
352 if (h->deblocking_filter)
356 FUNC(hl_motion_444)(h, dest[0], dest[1], dest[2],
357 h->me.qpel_put, h->h264chroma.put_h264_chroma_pixels_tab,
358 h->me.qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab,
359 h->h264dsp.weight_h264_pixels_tab,
360 h->h264dsp.biweight_h264_pixels_tab);
363 for (p = 0; p < plane_count; p++)
static av_always_inline void hl_decode_mb_predict_luma(H264Context *h, int mb_type, int is_h264, int simple, int transform_bypass, int pixel_shift, int *block_offset, int linesize, uint8_t *dest_y, int p)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define CONFIG_SVQ3_DECODER
#define USES_LIST(a, list)
does this mb use listX, note does not work if subMBs
static av_always_inline void hl_decode_mb_idct_luma(H264Context *h, int mb_type, int is_h264, int simple, int transform_bypass, int pixel_shift, int *block_offset, int linesize, uint8_t *dest_y, int p)
static av_noinline void FUNC() hl_decode_mb_444(H264Context *h)
const uint8_t ff_h264_chroma_qp[3][QP_MAX_NUM+1]
One chroma qp table for each supported bit depth (8, 9, 10).
#define CHROMA_DC_BLOCK_INDEX
static const uint8_t scan8[16 *3+3]
static av_always_inline void xchg_mb_border(H264Context *h, 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)
void ff_svq3_add_idct_c(uint8_t *dst, int16_t *block, int stride, int qp, int dc)
static av_always_inline int dctcoef_get(int16_t *mb, int high_bit_depth, int index)
static void fill_rectangle(SDL_Surface *screen, int x, int y, int w, int h, int color)
if(ac->has_optimized_func)
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
static void idct_add(uint8_t *dest, int line_size, int16_t *block)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
int block_offset[2 *(16 *3)]
block_offset[ 0..23] for frame macroblocks block_offset[24..47] for field macroblocks ...
static av_noinline void FUNC() hl_decode_mb(H264Context *h)
#define CODEC_FLAG_GRAY
Only decode/encode grayscale.
const uint16_t ff_h264_mb_sizes[4]