An intra-frame predictive coding method based on template matching, comprising: determining (S201) N predicted pixel values of a to-be-predicted unit, wherein N is an integer greater than or equal to 3, wherein the determining comprises determining an i th predicted pixel value by using a template of an i th shape, i=1, 2, ..., N, wherein the to-be-predicted unit is adjacent to the template of the i th shape; and selecting (S201) a predicted pixel value from among the N predicted pixel values of the to-be-predicted unit which meets a preset condition as an optimal predicted pixel value of the to-be-predicted unit, wherein the optimal predicted pixel value of the to-be-predicted unit is used for coding, wherein the determining an i th predicted pixel value of a to-be-predicted unit by using a template of an i th shape comprises: determining a predicted pixel value of a subunit sj in the to-be-predicted unit by using a template ix of the i th shape, wherein the subunit sj is a region that is in the to-be-predicted unit, characterized in that the region has a same shape as the template ix and is adjacent to the template ix; j=1, 2, ..., M; x=1, 2, ..., M; M is an integer greater than or equal to 2; s1∪s2∪...∪sM is equal to the to-be-predicted unit; the subunits s 1 , s 2 , ..., sM are successively away from an adjacent reconstructed region; and each template ix has a different size, wherein templates of at least three shapes are separately used to calculate a predicted pixel value of a to-be-predicted unit, and wherein the template of each shape represents a neighborhood texture direction of the to-be-predicted unit. determining (S201) N predicted pixel values of a to-be-predicted unit, wherein N is an integer greater than or equal to 3, wherein the determining comprises determining an i th predicted pixel value by using a template of an i th shape, i=1, 2, ..., N, wherein the to-be-predicted unit is adjacent to the template of the i th shape; and selecting (S201) a predicted pixel value from among the N predicted pixel values of the to-be-predicted unit which meets a preset condition as an optimal predicted pixel value of the to-be-predicted unit, wherein the optimal predicted pixel value of the to-be-predicted unit is used for coding, wherein the determining an i th predicted pixel value of a to-be-predicted unit by using a template of an i th shape comprises: determining a predicted pixel value of a subunit sj in the to-be-predicted unit by using a template ix of the i th shape, wherein the subunit sj is a region that is in the to-be-predicted unit, characterized in that the region has a same shape as the template ix and is adjacent to the template ix; j=1, 2, ..., M; x=1, 2, ..., M; M is an integer greater than or equal to 2; s1∪s2∪...∪sM is equal to the to-be-predicted unit; the subunits s 1 , s 2 , ..., sM are successively away from an adjacent reconstructed region; and each template ix has a different size, wherein templates of at least three shapes are separately used to calculate a predicted pixel value of a to-be-predicted unit, and wherein the template of each shape represents a neighborhood texture direction of the to-be-predicted unit. <EOS>