A method for encoding an intra-frame prediction mode, comprising: obtaining an intra-frame prediction mode of a current intra-frame encoding block from a preset prediction mode set, wherein the intra-frame prediction mode is a prediction mode adopted when the current intra-frame encoding block is pixel-encoded, wherein current intra-frame encoding blocks of different sizes all use the same preset prediction mode set, and the different sizes includes 4x4, 8x8, 16x16, 32x32 and 64x64; obtaining a predetermined number of distinct reference prediction modes of the current intra-frame encoding block, wherein the reference prediction modes are intra-frame prediction modes of available adjacent blocks of the current intra-frame encoding block and, if there are insufficient distinct intra frame prediction modes of said available adjacent blocks, prediction modes in a preset backup reference mode set, wherein all prediction modes in the preset backup reference mode set belong to the preset prediction mode set; writing a first flag bit into a code stream according to the reference prediction modes and the intra-frame prediction mode, wherein the first flag bit is used to indicate whether the intra-frame prediction mode is the same as one of the reference prediction modes; and when the intra-frame prediction mode of the encoding block is different from all the reference prediction modes, obtaining a prediction mode encoding value by subtracting from the value of the intra-frame prediction mode the number of reference prediction modes with value less than said value of the intra-frame prediction mode, and encoding the obtained prediction mode encoding value with a fixed number of bits. obtaining an intra-frame prediction mode of a current intra-frame encoding block from a preset prediction mode set, wherein the intra-frame prediction mode is a prediction mode adopted when the current intra-frame encoding block is pixel-encoded, wherein current intra-frame encoding blocks of different sizes all use the same preset prediction mode set, and the different sizes includes 4x4, 8x8, 16x16, 32x32 and 64x64; obtaining a predetermined number of distinct reference prediction modes of the current intra-frame encoding block, wherein the reference prediction modes are intra-frame prediction modes of available adjacent blocks of the current intra-frame encoding block and, if there are insufficient distinct intra frame prediction modes of said available adjacent blocks, prediction modes in a preset backup reference mode set, wherein all prediction modes in the preset backup reference mode set belong to the preset prediction mode set; writing a first flag bit into a code stream according to the reference prediction modes and the intra-frame prediction mode, wherein the first flag bit is used to indicate whether the intra-frame prediction mode is the same as one of the reference prediction modes; and when the intra-frame prediction mode of the encoding block is different from all the reference prediction modes, obtaining a prediction mode encoding value by subtracting from the value of the intra-frame prediction mode the number of reference prediction modes with value less than said value of the intra-frame prediction mode, and encoding the obtained prediction mode encoding value with a fixed number of bits.