A method comprising: selecting, by a computing device, a first reference block in a first reference frame and a second reference block in a second reference frame, the first reference block and the second reference block being used to predict a current block in a current frame; selecting, by the computing device, a first template in the first reference frame comprising decoded neighboring pixels of the first reference block, a second template in the second reference frame comprising decoded neighboring pixels of the second reference block, and a third template in the current frame comprising decoded neighboring pixels of the current block; comparing, by the computing device, a characteristic of the first template to a characteristic of the third template to generate a first difference value dis0; comparing a characteristic of the second template to the characteristic of the third template to generate a second difference value dist1; calculating, by the computing device, a first weight w 0 for the first reference block and a second weight w 1 for the second reference block based on the first difference value and the second difference value; adaptively, by the computing device, calculating a prediction block for the current block using the first weight and the second weight; and using, by the computing device, the prediction block as a prediction for the current block in a video transcoding process or a video decoding process associated with the current block, characterized in that the step of calculating, by the computing device, the first weight w0 and the second weight w1 comprises: calculating the weight w 0 using a contribution of the distance dist1 to the total distance of dist0 and dist1, and calculating the weight w 1 using a contribution of the distance dist0 to the total distance of dist0 and distance dist1. selecting, by a computing device, a first reference block in a first reference frame and a second reference block in a second reference frame, the first reference block and the second reference block being used to predict a current block in a current frame; selecting, by the computing device, a first template in the first reference frame comprising decoded neighboring pixels of the first reference block, a second template in the second reference frame comprising decoded neighboring pixels of the second reference block, and a third template in the current frame comprising decoded neighboring pixels of the current block; comparing, by the computing device, a characteristic of the first template to a characteristic of the third template to generate a first difference value dis0; comparing a characteristic of the second template to the characteristic of the third template to generate a second difference value dist1; calculating, by the computing device, a first weight w 0 for the first reference block and a second weight w 1 for the second reference block based on the first difference value and the second difference value; adaptively, by the computing device, calculating a prediction block for the current block using the first weight and the second weight; and using, by the computing device, the prediction block as a prediction for the current block in a video transcoding process or a video decoding process associated with the current block, characterized in that the step of calculating, by the computing device, the first weight w0 and the second weight w1 comprises: calculating the weight w 0 using a contribution of the distance dist1 to the total distance of dist0 and dist1, and calculating the weight w 1 using a contribution of the distance dist0 to the total distance of dist0 and distance dist1. calculating the weight w 0 using a contribution of the distance dist1 to the total distance of dist0 and dist1, and calculating the weight w 1 using a contribution of the distance dist0 to the total distance of dist0 and distance dist1.