00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #undef MCFUNC
00023
00024 #if CHROMA_IDC == 1
00025 # define MCFUNC(n) FUNC(n ## _420)
00026 #elif CHROMA_IDC == 2
00027 # define MCFUNC(n) FUNC(n ## _422)
00028 #elif CHROMA_IDC == 3
00029 # define MCFUNC(n) FUNC(n ## _444)
00030 #endif
00031
00032 #undef mc_part
00033 #define mc_part MCFUNC(mc_part)
00034
00035 static void mc_part(H264Context *h, int n, int square,
00036 int height, int delta,
00037 uint8_t *dest_y, uint8_t *dest_cb,
00038 uint8_t *dest_cr,
00039 int x_offset, int y_offset,
00040 qpel_mc_func *qpix_put,
00041 h264_chroma_mc_func chroma_put,
00042 qpel_mc_func *qpix_avg,
00043 h264_chroma_mc_func chroma_avg,
00044 h264_weight_func *weight_op,
00045 h264_biweight_func *weight_avg,
00046 int list0, int list1)
00047 {
00048 if ((h->use_weight == 2 && list0 && list1 &&
00049 (h->implicit_weight[h->ref_cache[0][scan8[n]]][h->ref_cache[1][scan8[n]]][h->s.mb_y & 1] != 32)) ||
00050 h->use_weight == 1)
00051 mc_part_weighted(h, n, square, height, delta, dest_y, dest_cb, dest_cr,
00052 x_offset, y_offset, qpix_put, chroma_put,
00053 weight_op[0], weight_op[1], weight_avg[0],
00054 weight_avg[1], list0, list1, PIXEL_SHIFT, CHROMA_IDC);
00055 else
00056 mc_part_std(h, n, square, height, delta, dest_y, dest_cb, dest_cr,
00057 x_offset, y_offset, qpix_put, chroma_put, qpix_avg,
00058 chroma_avg, list0, list1, PIXEL_SHIFT, CHROMA_IDC);
00059 }
00060
00061 static void MCFUNC(hl_motion)(H264Context *h, uint8_t *dest_y,
00062 uint8_t *dest_cb, uint8_t *dest_cr,
00063 qpel_mc_func(*qpix_put)[16],
00064 h264_chroma_mc_func(*chroma_put),
00065 qpel_mc_func(*qpix_avg)[16],
00066 h264_chroma_mc_func(*chroma_avg),
00067 h264_weight_func *weight_op,
00068 h264_biweight_func *weight_avg)
00069 {
00070 MpegEncContext *const s = &h->s;
00071 const int mb_xy = h->mb_xy;
00072 const int mb_type = s->current_picture.f.mb_type[mb_xy];
00073
00074 av_assert2(IS_INTER(mb_type));
00075
00076 if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME))
00077 await_references(h);
00078 prefetch_motion(h, 0, PIXEL_SHIFT, CHROMA_IDC);
00079
00080 if (IS_16X16(mb_type)) {
00081 mc_part(h, 0, 1, 16, 0, dest_y, dest_cb, dest_cr, 0, 0,
00082 qpix_put[0], chroma_put[0], qpix_avg[0], chroma_avg[0],
00083 weight_op, weight_avg,
00084 IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1));
00085 } else if (IS_16X8(mb_type)) {
00086 mc_part(h, 0, 0, 8, 8 << PIXEL_SHIFT, dest_y, dest_cb, dest_cr, 0, 0,
00087 qpix_put[1], chroma_put[0], qpix_avg[1], chroma_avg[0],
00088 weight_op, weight_avg,
00089 IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1));
00090 mc_part(h, 8, 0, 8, 8 << PIXEL_SHIFT, dest_y, dest_cb, dest_cr, 0, 4,
00091 qpix_put[1], chroma_put[0], qpix_avg[1], chroma_avg[0],
00092 weight_op, weight_avg,
00093 IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1));
00094 } else if (IS_8X16(mb_type)) {
00095 mc_part(h, 0, 0, 16, 8 * h->mb_linesize, dest_y, dest_cb, dest_cr, 0, 0,
00096 qpix_put[1], chroma_put[1], qpix_avg[1], chroma_avg[1],
00097 &weight_op[1], &weight_avg[1],
00098 IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1));
00099 mc_part(h, 4, 0, 16, 8 * h->mb_linesize, dest_y, dest_cb, dest_cr, 4, 0,
00100 qpix_put[1], chroma_put[1], qpix_avg[1], chroma_avg[1],
00101 &weight_op[1], &weight_avg[1],
00102 IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1));
00103 } else {
00104 int i;
00105
00106 av_assert2(IS_8X8(mb_type));
00107
00108 for (i = 0; i < 4; i++) {
00109 const int sub_mb_type = h->sub_mb_type[i];
00110 const int n = 4 * i;
00111 int x_offset = (i & 1) << 2;
00112 int y_offset = (i & 2) << 1;
00113
00114 if (IS_SUB_8X8(sub_mb_type)) {
00115 mc_part(h, n, 1, 8, 0, dest_y, dest_cb, dest_cr,
00116 x_offset, y_offset,
00117 qpix_put[1], chroma_put[1], qpix_avg[1], chroma_avg[1],
00118 &weight_op[1], &weight_avg[1],
00119 IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1));
00120 } else if (IS_SUB_8X4(sub_mb_type)) {
00121 mc_part(h, n, 0, 4, 4 << PIXEL_SHIFT, dest_y, dest_cb, dest_cr,
00122 x_offset, y_offset,
00123 qpix_put[2], chroma_put[1], qpix_avg[2], chroma_avg[1],
00124 &weight_op[1], &weight_avg[1],
00125 IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1));
00126 mc_part(h, n + 2, 0, 4, 4 << PIXEL_SHIFT,
00127 dest_y, dest_cb, dest_cr, x_offset, y_offset + 2,
00128 qpix_put[2], chroma_put[1], qpix_avg[2], chroma_avg[1],
00129 &weight_op[1], &weight_avg[1],
00130 IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1));
00131 } else if (IS_SUB_4X8(sub_mb_type)) {
00132 mc_part(h, n, 0, 8, 4 * h->mb_linesize,
00133 dest_y, dest_cb, dest_cr, x_offset, y_offset,
00134 qpix_put[2], chroma_put[2], qpix_avg[2], chroma_avg[2],
00135 &weight_op[2], &weight_avg[2],
00136 IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1));
00137 mc_part(h, n + 1, 0, 8, 4 * h->mb_linesize,
00138 dest_y, dest_cb, dest_cr, x_offset + 2, y_offset,
00139 qpix_put[2], chroma_put[2], qpix_avg[2], chroma_avg[2],
00140 &weight_op[2], &weight_avg[2],
00141 IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1));
00142 } else {
00143 int j;
00144 av_assert2(IS_SUB_4X4(sub_mb_type));
00145 for (j = 0; j < 4; j++) {
00146 int sub_x_offset = x_offset + 2 * (j & 1);
00147 int sub_y_offset = y_offset + (j & 2);
00148 mc_part(h, n + j, 1, 4, 0,
00149 dest_y, dest_cb, dest_cr, sub_x_offset, sub_y_offset,
00150 qpix_put[2], chroma_put[2], qpix_avg[2], chroma_avg[2],
00151 &weight_op[2], &weight_avg[2],
00152 IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1));
00153 }
00154 }
00155 }
00156 }
00157
00158 prefetch_motion(h, 1, PIXEL_SHIFT, CHROMA_IDC);
00159 }
00160