A method of encoding a picture, the method comprising generating a bitstream for reconstructing the picture, wherein the method comprises: generating a list of candidate intra prediction modes for a current coding block of the picture, wherein the list of candidate intra prediction modes comprises at least one bidirectional intra prediction, BIP, mode; determining whether a BIP flag is to be signaled in the bitstream according to prediction related information, wherein the BIP flag indicates a BIP mode selected for the current coding block, and wherein the prediction related information comprises at least numbers and positions of available primary reference samples; and when the BIP flag is to be signaled in the bitstream, deriving a probability model for encoding from the prediction related information, coding a value of the BIP flag to the bitstream using the probability model; and when the BIP flag is not to be signaled in the bitstream, not coding a value of the BIP flag to the bitstream, wherein the determining whether the BIP flag is to be signaled according to numbers and positions of available primary reference samples comprises: determining that the BIP is disabled and the BIP flag is not to be signaled in the bitstream when primary reference samples at a top side of the current coding block are not available, or determining that the BIP is disabled and the BIP flag is not to be signaled in the bitstream when primary reference samples at left and right sides of the current coding block are not available. generating a list of candidate intra prediction modes for a current coding block of the picture, wherein the list of candidate intra prediction modes comprises at least one bidirectional intra prediction, BIP, mode; determining whether a BIP flag is to be signaled in the bitstream according to prediction related information, wherein the BIP flag indicates a BIP mode selected for the current coding block, and wherein the prediction related information comprises at least numbers and positions of available primary reference samples; and when the BIP flag is to be signaled in the bitstream, deriving a probability model for encoding from the prediction related information, coding a value of the BIP flag to the bitstream using the probability model; and when the BIP flag is not to be signaled in the bitstream, not coding a value of the BIP flag to the bitstream, wherein the determining whether the BIP flag is to be signaled according to numbers and positions of available primary reference samples comprises: determining that the BIP is disabled and the BIP flag is not to be signaled in the bitstream when primary reference samples at a top side of the current coding block are not available, or determining that the BIP is disabled and the BIP flag is not to be signaled in the bitstream when primary reference samples at left and right sides of the current coding block are not available. determining that the BIP is disabled and the BIP flag is not to be signaled in the bitstream when primary reference samples at a top side of the current coding block are not available, or determining that the BIP is disabled and the BIP flag is not to be signaled in the bitstream when primary reference samples at left and right sides of the current coding block are not available.