Mercurial > libavcodec.hg
comparison h264pred.c @ 8349:920ded20b469 libavcodec
Horizontal and vertical prediction functions needed for new lossless mode
of H.264.
author | michael |
---|---|
date | Tue, 16 Dec 2008 19:39:01 +0000 |
parents | 585572f14e2c |
children | 5961d2deb35f |
comparison
equal
deleted
inserted
replaced
8348:64ab53a5aef4 | 8349:920ded20b469 |
---|---|
984 #undef PREDICT_8x8_DC | 984 #undef PREDICT_8x8_DC |
985 #undef PTR | 985 #undef PTR |
986 #undef PT | 986 #undef PT |
987 #undef PL | 987 #undef PL |
988 #undef SRC | 988 #undef SRC |
989 | |
990 static void pred4x4_vertical_add_c(uint8_t *pix, const DCTELEM *block, int stride){ | |
991 int i; | |
992 for(i=0; i<4; i++){ | |
993 pix[0]= pix[0-stride] + block[0]; | |
994 pix[1]= pix[1-stride] + block[1]; | |
995 pix[2]= pix[2-stride] + block[2]; | |
996 pix[3]= pix[3-stride] + block[3]; | |
997 pix+= stride; | |
998 block+= 4; | |
999 } | |
1000 } | |
1001 | |
1002 static void pred4x4_horizontal_add_c(uint8_t *pix, const DCTELEM *block, int stride){ | |
1003 int i; | |
1004 for(i=0; i<4; i++){ | |
1005 pix[0]= pix[-1] + block[0]; | |
1006 pix[1]= pix[ 0] + block[1]; | |
1007 pix[2]= pix[ 1] + block[2]; | |
1008 pix[3]= pix[ 2] + block[3]; | |
1009 pix+= stride; | |
1010 block+= 4; | |
1011 } | |
1012 } | |
1013 | |
1014 static void pred8x8l_vertical_add_c(uint8_t *pix, const DCTELEM *block, int stride){ | |
1015 int i; | |
1016 for(i=0; i<8; i++){ | |
1017 pix[0]= pix[0-stride] + block[0]; | |
1018 pix[1]= pix[1-stride] + block[1]; | |
1019 pix[2]= pix[2-stride] + block[2]; | |
1020 pix[3]= pix[3-stride] + block[3]; | |
1021 pix[4]= pix[4-stride] + block[4]; | |
1022 pix[5]= pix[5-stride] + block[5]; | |
1023 pix[6]= pix[6-stride] + block[6]; | |
1024 pix[7]= pix[7-stride] + block[7]; | |
1025 pix+= stride; | |
1026 block+= 8; | |
1027 } | |
1028 } | |
1029 | |
1030 static void pred8x8l_horizontal_add_c(uint8_t *pix, const DCTELEM *block, int stride){ | |
1031 int i; | |
1032 for(i=0; i<8; i++){ | |
1033 pix[0]= pix[-1] + block[0]; | |
1034 pix[1]= pix[ 0] + block[1]; | |
1035 pix[2]= pix[ 1] + block[2]; | |
1036 pix[3]= pix[ 2] + block[3]; | |
1037 pix[4]= pix[ 3] + block[4]; | |
1038 pix[5]= pix[ 4] + block[5]; | |
1039 pix[6]= pix[ 5] + block[6]; | |
1040 pix[7]= pix[ 6] + block[7]; | |
1041 pix+= stride; | |
1042 block+= 8; | |
1043 } | |
1044 } | |
1045 | |
1046 static void pred16x16_vertical_add_c(uint8_t *pix, const int *block_offset, const DCTELEM *block, int stride){ | |
1047 int i; | |
1048 for(i=0; i<16; i++) | |
1049 pred4x4_vertical_add_c(pix + block_offset[i], block + i*16, stride); | |
1050 } | |
1051 | |
1052 static void pred16x16_horizontal_add_c(uint8_t *pix, const int *block_offset, const DCTELEM *block, int stride){ | |
1053 int i; | |
1054 for(i=0; i<16; i++) | |
1055 pred4x4_horizontal_add_c(pix + block_offset[i], block + i*16, stride); | |
1056 } | |
1057 | |
1058 static void pred8x8_vertical_add_c(uint8_t *pix, const int *block_offset, const DCTELEM *block, int stride){ | |
1059 int i; | |
1060 for(i=0; i<4; i++) | |
1061 pred4x4_vertical_add_c(pix + block_offset[i], block + i*16, stride); | |
1062 } | |
1063 | |
1064 static void pred8x8_horizontal_add_c(uint8_t *pix, const int *block_offset, const DCTELEM *block, int stride){ | |
1065 int i; | |
1066 for(i=0; i<4; i++) | |
1067 pred4x4_horizontal_add_c(pix + block_offset[i], block + i*16, stride); | |
1068 } | |
1069 | |
989 | 1070 |
990 /** | 1071 /** |
991 * Sets the intra prediction function pointers. | 1072 * Sets the intra prediction function pointers. |
992 */ | 1073 */ |
993 void ff_h264_pred_init(H264PredContext *h, int codec_id){ | 1074 void ff_h264_pred_init(H264PredContext *h, int codec_id){ |
1073 h->pred16x16[PLANE_PRED8x8 ]= pred16x16_plane_c; | 1154 h->pred16x16[PLANE_PRED8x8 ]= pred16x16_plane_c; |
1074 } | 1155 } |
1075 h->pred16x16[LEFT_DC_PRED8x8]= pred16x16_left_dc_c; | 1156 h->pred16x16[LEFT_DC_PRED8x8]= pred16x16_left_dc_c; |
1076 h->pred16x16[TOP_DC_PRED8x8 ]= pred16x16_top_dc_c; | 1157 h->pred16x16[TOP_DC_PRED8x8 ]= pred16x16_top_dc_c; |
1077 h->pred16x16[DC_128_PRED8x8 ]= pred16x16_128_dc_c; | 1158 h->pred16x16[DC_128_PRED8x8 ]= pred16x16_128_dc_c; |
1078 } | 1159 |
1160 //special lossless h/v prediction for h264 | |
1161 h->pred4x4_add [VERT_PRED ]= pred4x4_vertical_add_c; | |
1162 h->pred4x4_add [ HOR_PRED ]= pred4x4_horizontal_add_c; | |
1163 h->pred8x8l_add [VERT_PRED ]= pred8x8l_vertical_add_c; | |
1164 h->pred8x8l_add [ HOR_PRED ]= pred8x8l_horizontal_add_c; | |
1165 h->pred8x8_add [VERT_PRED8x8]= pred8x8_vertical_add_c; | |
1166 h->pred8x8_add [ HOR_PRED8x8]= pred8x8_horizontal_add_c; | |
1167 h->pred16x16_add[VERT_PRED8x8]= pred16x16_vertical_add_c; | |
1168 h->pred16x16_add[ HOR_PRED8x8]= pred16x16_horizontal_add_c; | |
1169 } |