Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***********************************************************************
- *
- * void MakeNest(HVQM2KeyFrame *header)
- *
- * Explanation
- *
- * Builds the DC nest. If not enough data is given to fill the
- * entire nest, the data is mirrored once horizontally and/or
- * vertically to attempt to fill the remaining space. If there is
- * still empty space after mirroring, it is filled with zeroes.
- *
- ***********************************************************************/
- static __inline__ void
- MakeNest( HVQM2KeyFrame *header )
- {
- u8 *rowP, *dstP;
- u8 *v_mirrorP;
- u16 nest_x, nest_y;
- s32 src_w, src_h;
- s32 h_mirror_size, v_mirror_size;
- s32 hzeroes, vzeroes;
- int i, j;
- /*
- * Get starting offset of source DC data
- */
- nest_x = header->nest_start_x;
- nest_y = header->nest_start_y;
- rowP = nest_x + ( nest_y * lum_hblocks ) + dcbufY;
- dstP = nest;
- /*
- * Calculate horizontal mirror size
- */
- if ( lum_hblocks < nest_w )
- {
- src_w = lum_hblocks;
- h_mirror_size = nest_w - src_w;
- if ( src_w < h_mirror_size )
- h_mirror_size = src_w; /* Clamp size of horizontal mirror */
- hzeroes = nest_w - ( src_w + h_mirror_size );
- } else
- {
- src_w = nest_w;
- h_mirror_size = 0;
- hzeroes = 0;
- }
- /*
- * Calculate vertical mirror size
- */
- if ( lum_vblocks < nest_h )
- {
- src_h = lum_vblocks;
- v_mirror_size = nest_h - src_h;
- if ( src_h < v_mirror_size )
- v_mirror_size = src_h; /* Clamp size of vertical mirror */
- vzeroes = nest_h - ( src_h + v_mirror_size );
- } else
- {
- src_h = nest_h;
- v_mirror_size = 0;
- vzeroes = 0;
- }
- /*
- * Copy source DC data into the nest and create horizontal mirror
- */
- for ( i = src_h; i > 0; i-- )
- {
- u8 *srcP = rowP;
- for ( j = src_w; j > 0; j-- ) *dstP++ = *srcP++;
- for ( j = h_mirror_size; j > 0; j-- ) *dstP++ = *--srcP;
- for ( j = hzeroes; j > 0; j-- ) *dstP++ = 0;
- rowP += lum_hblocks;
- }
- v_mirrorP = dstP - nest_w;
- /*
- * Create vertical mirror
- */
- for ( i = v_mirror_size; i > 0; i-- )
- {
- u8 *srcP = v_mirrorP;
- for ( j = nest_w; j > 0; j-- ) *dstP++ = *srcP++;
- v_mirrorP -= nest_w;
- }
- /*
- * Fill any remaining space with zeroes
- */
- for ( i = vzeroes; i > 0; i-- )
- for ( j = nest_w; j > 0; j-- ) *dstP++ = 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement