Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
mracer
Feb 23, 2004
The M racer
Inside Intel's ipp mpeg2 decoder... nothing wrong with a 40+ line macro to do motion. (to add more fun they put ##stuff)
code:
#define FUNC_MC_MBLOCK_420(DIR, METH, FLG)                                               \
  Ipp8u *refY = frame_buffer.frame_p_c_n[frame_buffer.buff##DIR].Y_comp_data;            \
  Ipp8u *refU = frame_buffer.frame_p_c_n[frame_buffer.buff##DIR].U_comp_data;            \
  Ipp8u *refV = frame_buffer.frame_p_c_n[frame_buffer.buff##DIR].V_comp_data;            \
  Ipp8u *curY = video->blkCurrYUV[0];                                                    \
  Ipp8u *curU = video->blkCurrYUV[1];                                                    \
  Ipp8u *curV = video->blkCurrYUV[2];                                                    \
  Ipp32s pitch_l = frame_buffer.Y_comp_pitch;                                            \
  Ipp32s pitch_c = frame_buffer.U_comp_pitch;                                            \
  Ipp32s flag_l, flag_c;                                                                 \
  Ipp32s offs_l, offs_c;                                                                 \
  Ipp16s vec_x, vec_y;                                                                   \
                                                                                         \
  if(video->prediction_type == IPPVC_MC_FRAME)                                           \
  {                                                                                      \
    DECODE_MV(video->bs, index##DIR, index##DIR, vec_x, vec_y);                          \
    video->PMV[index##DIR + 4] = video->PMV[index##DIR];                                 \
    video->PMV[index##DIR + 5] = video->PMV[index##DIR + 1];                             \
	video->trans_output->g_transmb[sequenceHeader.mb_width*video->mb_row+video->mb_col].mvfx=vec_x; \
	video->trans_output->g_transmb[sequenceHeader.mb_width*video->mb_row+video->mb_col].mvfy=vec_y; \
                                                                                         \
    CALC_OFFSETS_FRAME_420(offs_l, offs_c, flag_l, flag_c, vec_x, vec_y, HP_FLAG_##FLG)  \
    CHECK_OFFSET_L(offs_l+(vec_x&1), pitch_l, 16+(vec_y&1))                              \
                                                                                         \
    FUNC_##METH##_HP(16, 16, refY + offs_l, pitch_l, curY, pitch_l, flag_l, 0);          \
    FUNC_##METH##_HP(8,  8,  refU + offs_c, pitch_c, curU, pitch_c, flag_c, 0);          \
    FUNC_##METH##_HP(8,  8,  refV + offs_c, pitch_c, curV, pitch_c, flag_c, 0);          \
  }                                                                                      \
  else                                                                                   \
  {                                                                                      \
    Ipp32s pitch_l2 = pitch_l + pitch_l;                                                 \
    Ipp32s pitch_c2 = pitch_c + pitch_c;                                                 \
    Ipp32s field_sel0, field_sel1;                                                       \
    Ipp16s vec1_x, vec1_y;                                                               \
                                                                                         \
    GET_1BIT(video->bs, field_sel0);                                                     \
    DECODE_MV_FIELD(video->bs, index##DIR, index##DIR, vec_x, vec_y);                    \
    GET_1BIT(video->bs, field_sel1);                                                     \
    DECODE_MV_FIELD(video->bs, index##DIR + 4, index##DIR, vec1_x, vec1_y);              \
	video->trans_output->g_transmb[sequenceHeader.mb_width*video->mb_row+video->mb_col].mvfx=vec_x; \
	video->trans_output->g_transmb[sequenceHeader.mb_width*video->mb_row+video->mb_col].mvfy=vec_y; \
                                                                                                  \
    CALC_OFFSETS_FIELD_420(offs_l, offs_c, flag_l, flag_c, vec_x, vec_y, field_sel0, HP_FLAG_##FLG)   \
    CHECK_OFFSET_L(offs_l+(vec_x&1), pitch_l2, 8+(vec_y&1))                                       \
                                                                                                  \
    FUNC_##METH##_HP(16, 8, refY + offs_l, pitch_l2, curY, pitch_l2, flag_l, 0);                  \
    FUNC_##METH##_HP(8,  4, refU + offs_c, pitch_c2, curU, pitch_c2, flag_c, 0);                  \
    FUNC_##METH##_HP(8,  4, refV + offs_c, pitch_c2, curV, pitch_c2, flag_c, 0);                  \
                                                                                                  \
    CALC_OFFSETS_FIELD_420(offs_l, offs_c, flag_l, flag_c, vec1_x, vec1_y, field_sel1, HP_FLAG_##FLG) \
    CHECK_OFFSET_L(offs_l+(vec1_x&1), pitch_l2, 8+(vec1_y&1))                                     \
                                                                                                  \
    FUNC_##METH##_HP(16, 8, refY + offs_l, pitch_l2, curY + pitch_l, pitch_l2, flag_l, 0);        \
    FUNC_##METH##_HP(8,  4, refU + offs_c, pitch_c2, curU + pitch_c, pitch_c2, flag_c, 0);        \
    FUNC_##METH##_HP(8,  4, refV + offs_c, pitch_c2, curV + pitch_c, pitch_c2, flag_c, 0);        \
}                                                                                               \
  return UMC_OK

mracer fucked around with this message at 13:55 on Apr 3, 2008

Adbot
ADBOT LOVES YOU

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply