diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2008-12-16 19:39:01 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2008-12-16 19:39:01 +0000 |
commit | d358caed7e56b30af9fc93f420372fd46a89b3d4 (patch) | |
tree | 031e72e2ff4d60487c2b0aa4e851f95692ef7154 /libavcodec | |
parent | ca5b528ea187974555fef5836629409ce63b5b74 (diff) | |
download | ffmpeg-d358caed7e56b30af9fc93f420372fd46a89b3d4.tar.gz |
Horizontal and vertical prediction functions needed for new lossless mode
of H.264.
Originally committed as revision 16168 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/h264pred.c | 91 | ||||
-rw-r--r-- | libavcodec/h264pred.h | 5 |
2 files changed, 96 insertions, 0 deletions
diff --git a/libavcodec/h264pred.c b/libavcodec/h264pred.c index 95b83f4964..8980d9d2c8 100644 --- a/libavcodec/h264pred.c +++ b/libavcodec/h264pred.c @@ -987,6 +987,87 @@ static void pred8x8l_horizontal_up_c(uint8_t *src, int has_topleft, int has_topr #undef PL #undef SRC +static void pred4x4_vertical_add_c(uint8_t *pix, const DCTELEM *block, int stride){ + int i; + for(i=0; i<4; i++){ + pix[0]= pix[0-stride] + block[0]; + pix[1]= pix[1-stride] + block[1]; + pix[2]= pix[2-stride] + block[2]; + pix[3]= pix[3-stride] + block[3]; + pix+= stride; + block+= 4; + } +} + +static void pred4x4_horizontal_add_c(uint8_t *pix, const DCTELEM *block, int stride){ + int i; + for(i=0; i<4; i++){ + pix[0]= pix[-1] + block[0]; + pix[1]= pix[ 0] + block[1]; + pix[2]= pix[ 1] + block[2]; + pix[3]= pix[ 2] + block[3]; + pix+= stride; + block+= 4; + } +} + +static void pred8x8l_vertical_add_c(uint8_t *pix, const DCTELEM *block, int stride){ + int i; + for(i=0; i<8; i++){ + pix[0]= pix[0-stride] + block[0]; + pix[1]= pix[1-stride] + block[1]; + pix[2]= pix[2-stride] + block[2]; + pix[3]= pix[3-stride] + block[3]; + pix[4]= pix[4-stride] + block[4]; + pix[5]= pix[5-stride] + block[5]; + pix[6]= pix[6-stride] + block[6]; + pix[7]= pix[7-stride] + block[7]; + pix+= stride; + block+= 8; + } +} + +static void pred8x8l_horizontal_add_c(uint8_t *pix, const DCTELEM *block, int stride){ + int i; + for(i=0; i<8; i++){ + pix[0]= pix[-1] + block[0]; + pix[1]= pix[ 0] + block[1]; + pix[2]= pix[ 1] + block[2]; + pix[3]= pix[ 2] + block[3]; + pix[4]= pix[ 3] + block[4]; + pix[5]= pix[ 4] + block[5]; + pix[6]= pix[ 5] + block[6]; + pix[7]= pix[ 6] + block[7]; + pix+= stride; + block+= 8; + } +} + +static void pred16x16_vertical_add_c(uint8_t *pix, const int *block_offset, const DCTELEM *block, int stride){ + int i; + for(i=0; i<16; i++) + pred4x4_vertical_add_c(pix + block_offset[i], block + i*16, stride); +} + +static void pred16x16_horizontal_add_c(uint8_t *pix, const int *block_offset, const DCTELEM *block, int stride){ + int i; + for(i=0; i<16; i++) + pred4x4_horizontal_add_c(pix + block_offset[i], block + i*16, stride); +} + +static void pred8x8_vertical_add_c(uint8_t *pix, const int *block_offset, const DCTELEM *block, int stride){ + int i; + for(i=0; i<4; i++) + pred4x4_vertical_add_c(pix + block_offset[i], block + i*16, stride); +} + +static void pred8x8_horizontal_add_c(uint8_t *pix, const int *block_offset, const DCTELEM *block, int stride){ + int i; + for(i=0; i<4; i++) + pred4x4_horizontal_add_c(pix + block_offset[i], block + i*16, stride); +} + + /** * Sets the intra prediction function pointers. */ @@ -1075,4 +1156,14 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id){ h->pred16x16[LEFT_DC_PRED8x8]= pred16x16_left_dc_c; h->pred16x16[TOP_DC_PRED8x8 ]= pred16x16_top_dc_c; h->pred16x16[DC_128_PRED8x8 ]= pred16x16_128_dc_c; + + //special lossless h/v prediction for h264 + h->pred4x4_add [VERT_PRED ]= pred4x4_vertical_add_c; + h->pred4x4_add [ HOR_PRED ]= pred4x4_horizontal_add_c; + h->pred8x8l_add [VERT_PRED ]= pred8x8l_vertical_add_c; + h->pred8x8l_add [ HOR_PRED ]= pred8x8l_horizontal_add_c; + h->pred8x8_add [VERT_PRED8x8]= pred8x8_vertical_add_c; + h->pred8x8_add [ HOR_PRED8x8]= pred8x8_horizontal_add_c; + h->pred16x16_add[VERT_PRED8x8]= pred16x16_vertical_add_c; + h->pred16x16_add[ HOR_PRED8x8]= pred16x16_horizontal_add_c; } diff --git a/libavcodec/h264pred.h b/libavcodec/h264pred.h index 150567d294..a8146ca0de 100644 --- a/libavcodec/h264pred.h +++ b/libavcodec/h264pred.h @@ -75,6 +75,11 @@ typedef struct H264PredContext{ void (*pred8x8l [9+3])(uint8_t *src, int topleft, int topright, int stride); void (*pred8x8 [4+3+4])(uint8_t *src, int stride); void (*pred16x16[4+3])(uint8_t *src, int stride); + + void (*pred4x4_add [2])(uint8_t *pix/*align 4*/, const DCTELEM *block/*align 16*/, int stride); + void (*pred8x8l_add [2])(uint8_t *pix/*align 8*/, const DCTELEM *block/*align 16*/, int stride); + void (*pred8x8_add [3])(uint8_t *pix/*align 8*/, const int *block_offset, const DCTELEM *block/*align 16*/, int stride); + void (*pred16x16_add[3])(uint8_t *pix/*align 16*/, const int *block_offset, const DCTELEM *block/*align 16*/, int stride); }H264PredContext; void ff_h264_pred_init(H264PredContext *h, int codec_id); |