A method of intra prediction of a block, comprising: obtaining two lines of reconstructed neighboring samples; deriving a set of reference samples based on the two lines of reconstructed neighboring samples; obtaining a set of matrix-based intra prediction, MIP, coefficients based on an intra prediction mode obtained from a bitstream, wherein an MIP coefficient C MIP of the set of MIP coefficients is obtained as follows: C MIP = ν sgn ⋅ q ≪ s, where q is a magnitude of the MIP coefficient; s is a left shift value; v sgn is a sign value of the MIP coefficient; obtaining a prediction block based on the set of reference samples and the set of MIP coefficients; wherein a reconstructed picture is obtained based on the prediction block; wherein obtaining the prediction block based on the set of reference samples and the set of MIP coefficients comprises a matrix multiplication of the reference samples and the set of MIP coefficients, wherein the multiplication operation in matrix multiplication is performed with reduced bit depth by repositioning shift operation after multiplication: p ⋅ C MIP = ν sgn ⋅ p ⋅ q ≪ s, where q is a magnitude of the MIP coefficient; s is a left shift value; v sgn is a sign value of the MIP coefficient; p is a reference sample, p = bdry red top i 0 ≤ i < W; or p = bdry red left i, 0 ≤ i < H; whereby input boundaries to the top and to the left of the block are reduced to smaller boundaries, where bdry top and bdry lett are input boundaries to the top and to the left of the block, where the reduced smaller boundaries are dbry red top of W reconstructed neighbouring boundary samples and bdry red left of H reconstructed neighbouring boundary samples, respectively. obtaining two lines of reconstructed neighboring samples; deriving a set of reference samples based on the two lines of reconstructed neighboring samples; obtaining a set of matrix-based intra prediction, MIP, coefficients based on an intra prediction mode obtained from a bitstream, wherein an MIP coefficient C MIP of the set of MIP coefficients is obtained as follows: C MIP = ν sgn ⋅ q ≪ s, where q is a magnitude of the MIP coefficient; s is a left shift value; v sgn is a sign value of the MIP coefficient; obtaining a prediction block based on the set of reference samples and the set of MIP coefficients; wherein a reconstructed picture is obtained based on the prediction block; wherein obtaining the prediction block based on the set of reference samples and the set of MIP coefficients comprises a matrix multiplication of the reference samples and the set of MIP coefficients, wherein the multiplication operation in matrix multiplication is performed with reduced bit depth by repositioning shift operation after multiplication: p ⋅ C MIP = ν sgn ⋅ p ⋅ q ≪ s, where q is a magnitude of the MIP coefficient; s is a left shift value; v sgn is a sign value of the MIP coefficient; p is a reference sample, p = bdry red top i 0 ≤ i < W; or p = bdry red left i, 0 ≤ i < H; whereby input boundaries to the top and to the left of the block are reduced to smaller boundaries, where bdry top and bdry lett are input boundaries to the top and to the left of the block, where the reduced smaller boundaries are dbry red top of W reconstructed neighbouring boundary samples and bdry red left of H reconstructed neighbouring boundary samples, respectively.