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 = h->mb_x;
46 const int mb_y = h->mb_y;
47 const int mb_xy = h->mb_xy;
48 const int mb_type = h->cur_pic.mb_type[
mb_xy];
49 uint8_t *dest_y, *dest_cb, *dest_cr;
53 const int transform_bypass = !
SIMPLE && (h->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 * h->linesize) * 16;
61 dest_cb = h->cur_pic.f.data[1] + (mb_x <<
PIXEL_SHIFT) * 8 + mb_y * h->uvlinesize * block_h;
62 dest_cr = h->cur_pic.f.data[2] + (mb_x <<
PIXEL_SHIFT) * 8 + mb_y * h->uvlinesize * block_h;
64 h->vdsp.prefetch(dest_y + (h->mb_x & 3) * 4 * h->linesize + (64 <<
PIXEL_SHIFT), h->linesize, 4);
65 h->vdsp.prefetch(dest_cb + (h->mb_x & 7) * h->uvlinesize + (64 <<
PIXEL_SHIFT), dest_cr - dest_cb, 2);
67 h->list_counts[
mb_xy] = h->list_count;
70 linesize = h->mb_linesize = h->linesize * 2;
71 uvlinesize = h->mb_uvlinesize = h->uvlinesize * 2;
72 block_offset = &h->block_offset[48];
74 dest_y -= h->linesize * 15;
75 dest_cb -= h->uvlinesize * (block_h - 1);
76 dest_cr -= h->uvlinesize * (block_h - 1);
80 for (list = 0; list < h->list_count; list++) {
84 int8_t *ref = &h->ref_cache[list][
scan8[0]];
87 for (i = 0; i < 16; i += 4) {
88 int ref = h->ref_cache[list][
scan8[i]];
91 8, (16 + ref) ^ (h->mb_y & 1), 1);
97 linesize = h->mb_linesize = h->linesize;
98 uvlinesize = h->mb_uvlinesize = h->uvlinesize;
104 const int bit_depth = h->sps.bit_depth_luma;
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 for (j = 0; j < 8; j++)
120 tmp_cb[j] = 1 << (bit_depth - 1);
122 for (i = 0; i < block_h; i++) {
123 uint16_t *tmp_cr = (uint16_t *)(dest_cr + i * uvlinesize);
124 for (j = 0; j < 8; j++)
125 tmp_cr[j] = 1 << (bit_depth - 1);
128 for (i = 0; i < block_h; i++) {
129 uint16_t *tmp_cb = (uint16_t *)(dest_cb + i * uvlinesize);
130 for (j = 0; j < 8; j++)
131 tmp_cb[j] =
get_bits(&gb, bit_depth);
133 for (i = 0; i < block_h; i++) {
134 uint16_t *tmp_cr = (uint16_t *)(dest_cr + i * uvlinesize);
135 for (j = 0; j < 8; j++)
136 tmp_cr[j] =
get_bits(&gb, bit_depth);
141 for (i = 0; i < 16; i++)
142 memcpy(dest_y + i * linesize, h->intra_pcm_ptr + i * 16, 16);
144 if (!h->sps.chroma_format_idc) {
145 for (i = 0; i < block_h; i++) {
146 memset(dest_cb + i * uvlinesize, 128, 8);
147 memset(dest_cr + i * uvlinesize, 128, 8);
150 const uint8_t *src_cb = h->intra_pcm_ptr + 256;
151 const uint8_t *src_cr = h->intra_pcm_ptr + 256 + block_h * 8;
152 for (i = 0; i < block_h; i++) {
153 memcpy(dest_cb + i * uvlinesize, src_cb + i * 8, 8);
154 memcpy(dest_cr + i * uvlinesize, src_cr + i * 8, 8);
161 if (h->deblocking_filter)
166 h->hpc.pred8x8[h->chroma_pred_mode](dest_cb,
uvlinesize);
167 h->hpc.pred8x8[h->chroma_pred_mode](dest_cr,
uvlinesize);
172 block_offset, linesize, dest_y, 0);
174 if (h->deblocking_filter)
177 }
else if (is_h264) {
179 FUNC(hl_motion_422)(h, dest_y, dest_cb, dest_cr,
180 h->qpel_put, h->h264chroma.put_h264_chroma_pixels_tab,
181 h->qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab,
182 h->h264dsp.weight_h264_pixels_tab,
183 h->h264dsp.biweight_h264_pixels_tab);
185 FUNC(hl_motion_420)(h, dest_y, dest_cb, dest_cr,
186 h->qpel_put, h->h264chroma.put_h264_chroma_pixels_tab,
187 h->qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab,
188 h->h264dsp.weight_h264_pixels_tab,
189 h->h264dsp.biweight_h264_pixels_tab);
198 uint8_t *dest[2] = { dest_cb, dest_cr };
199 if (transform_bypass) {
200 if (
IS_INTRA(mb_type) && h->sps.profile_idc == 244 &&
203 h->hpc.pred8x8_add[h->chroma_pred_mode](dest[0],
207 h->hpc.pred8x8_add[h->chroma_pred_mode](dest[1],
212 idct_add = h->h264dsp.h264_add_pixels4_clear;
213 for (j = 1; j < 3; j++) {
214 for (i = j * 16; i < j * 16 + 4; i++)
215 if (h->non_zero_count_cache[
scan8[i]] ||
217 idct_add(dest[j - 1] + block_offset[i],
221 for (i = j * 16 + 4; i < j * 16 + 8; i++)
222 if (h->non_zero_count_cache[
scan8[i + 4]] ||
224 idct_add(dest[j - 1] + block_offset[i + 4],
234 qp[0] = h->chroma_qp[0] + 3;
235 qp[1] = h->chroma_qp[1] + 3;
237 qp[0] = h->chroma_qp[0];
238 qp[1] = h->chroma_qp[1];
241 h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + (16 * 16 * 1 <<
PIXEL_SHIFT),
242 h->dequant4_coeff[
IS_INTRA(mb_type) ? 1 : 4][qp[0]][0]);
244 h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + (16 * 16 * 2 <<
PIXEL_SHIFT),
245 h->dequant4_coeff[
IS_INTRA(mb_type) ? 2 : 5][qp[1]][0]);
246 h->h264dsp.h264_idct_add8(dest, block_offset,
248 h->non_zero_count_cache);
250 h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + 16 * 16 * 1,
251 h->dequant4_coeff[
IS_INTRA(mb_type) ? 1 : 4][h->chroma_qp[0]][0]);
252 h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + 16 * 16 * 2,
253 h->dequant4_coeff[
IS_INTRA(mb_type) ? 2 : 5][h->chroma_qp[1]][0]);
254 for (j = 1; j < 3; j++) {
255 for (i = j * 16; i < j * 16 + 4; i++)
256 if (h->non_zero_count_cache[
scan8[i]] || h->mb[i * 16]) {
257 uint8_t *
const ptr = dest[j - 1] + block_offset[i];
269 #if !SIMPLE || BITS == 8
277 const int mb_x = h->mb_x;
278 const int mb_y = h->mb_y;
279 const int mb_xy = h->mb_xy;
280 const int mb_type = h->cur_pic.mb_type[
mb_xy];
285 const int transform_bypass = !
SIMPLE && (h->qscale == 0 && h->sps.transform_bypass);
288 for (p = 0; p < plane_count; p++) {
289 dest[p] = h->cur_pic.f.data[p] +
291 h->vdsp.prefetch(dest[p] + (h->mb_x & 3) * 4 * h->linesize + (64 <<
PIXEL_SHIFT),
295 h->list_counts[
mb_xy] = h->list_count;
298 linesize = h->mb_linesize = h->mb_uvlinesize = h->linesize * 2;
299 block_offset = &h->block_offset[48];
301 for (p = 0; p < 3; p++)
302 dest[p] -= h->linesize * 15;
305 for (list = 0; list < h->list_count; list++) {
309 int8_t *ref = &h->ref_cache[list][
scan8[0]];
312 for (i = 0; i < 16; i += 4) {
313 int ref = h->ref_cache[list][
scan8[i]];
316 8, (16 + ref) ^ (h->mb_y & 1), 1);
322 linesize = h->mb_linesize = h->mb_uvlinesize = h->linesize;
327 const int bit_depth = h->sps.bit_depth_luma;
331 for (p = 0; p < plane_count; p++)
332 for (i = 0; i < 16; i++) {
333 uint16_t *tmp = (uint16_t *)(dest[p] + i * linesize);
334 for (j = 0; j < 16; j++)
338 for (p = 0; p < plane_count; p++)
339 for (i = 0; i < 16; i++)
340 memcpy(dest[p] + i * linesize,
341 h->intra_pcm_ptr + p * 256 + i * 16, 16);
345 if (h->deblocking_filter)
349 for (p = 0; p < plane_count; p++)
352 block_offset, linesize, dest[p], p);
354 if (h->deblocking_filter)
358 FUNC(hl_motion_444)(h, dest[0], dest[1], dest[2],
359 h->qpel_put, h->h264chroma.put_h264_chroma_pixels_tab,
360 h->qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab,
361 h->h264dsp.weight_h264_pixels_tab,
362 h->h264dsp.biweight_h264_pixels_tab);
365 for (p = 0; p < plane_count; p++)
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)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define CONFIG_SVQ3_DECODER
#define USES_LIST(a, list)
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 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 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)
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 av_always_inline int dctcoef_get(int16_t *mb, int high_bit_depth, int index)
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 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]