Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HEVC (h.265) intra-prediction

I am working on a project in implementing HEVC intra-prediction with MATLAB. I have read so many articles to write the codes in MATLAB and finally I have done that. (one of the most useful one was this article: Intra Coding of the HEVC Standard)

The main purpose of the project is a comparison between HEVC and AVC intra-prediction to show HEVC will give better quality for the reconstructed image than AVC does and for this reason the final SAE (sum of absolute errors) which HEVC gives should be less than the one with AVC. Unlike a HEVC decoder/encoder with a dynamic block division with respect to the amount of details in each area of an image, according to my supervisor, I have to have a specific block size at a time for each intra-prediction implementation on an image, i.e. once with 64x64, once with 32x32 and so on to 4x4.

Now I have a big problem in my work which is the SAE of HEVC is by far larger than AVC. I don't know why is it so?

If it's needed let me know to post my codes later.

Also I have some doubts and questions in implementing HEVC intra-prediction:

1- Does anything in the below linear interpolation function and its related parameters (according to the cited article) change with the block size or it is always the same for different block sizes?

Px,y = ((32 − wy )· Ri,0 + wy · Ri+1,0 + 16 ) >> 5
cy = (y · d) >> 5
wy = (y · d) &31

2- (>>) the shift operator, is like a normal division (for example >> 5 is equal to division of a signed number by 32) or is a binary shift of a signed number? (I said signed number due to the negative displacement related to some angular modes. also it's noticeable that bit-wise shift of an unsigned number gives totally different result than a signed one)

3- For computing the cost of each mode, I used SAE (Sum of Absolute Errors) as a replace for the full cost function for the simplification.

C = DHad + λ · Rmode (HEVC cost function)

Do you think using SAE instead of HEVC cost function will affect the process of choosing best mode for each block? If it's so, do you have any other more accurate method than SAE as a replacement for HEVC cost function to choose the best mode of prediction for each pixel?

4- For comparison purposes between h.265 (HEVC) and h.264 (AVC) intra-prediction, the total SAE of a reconstructed picture by HEVC should be less than AVC. However, it is not the case in my results and the SAE of AVC is less than HEVC. I cannot find the reason which caused this problem. may some one help me?

like image 584
manpmanp Avatar asked Jul 14 '14 15:07

manpmanp


Video Answer


1 Answers

1 - Actually, the formula for the linear interpolation mentioned in this publication is not quite right. According to Setion 8.4.4.2.3 "Filtering process of neighbouring samples" of the H.265 standard, it should be:

Px,y = ((63 − wy )· Ri,0 + wy · Ri+1,0 + 32 ) >> 6

Look at the standard for more information. Regarding your question about adapting some of the numbers depending on the block size: This so-called "strong filtering" should only be applied for reference pixels of 32x32 intra blocks. For smaller blocks, only the "Reference Sample Smoothing" from your article can be used. again, check the same section in the standard if you want to know details.

2 - The shift operator denotes a bitshift of the absolute value in these cases. Be aware with bitshifting signed numbers in matlab, some functions shift the absolute value, some shift the K2 complement with considering the sign.

3 - Since your "project is a comparison between HEVC and AVC intra-prediction to show HEVC will give better quality", i guess it makes sense to just use SAE or the sum of squared errors (SSE). If you do some kind of quality/bitrate evaluation like in the HEVC cost function, you'd need to add a lot more than just intra prediction to you project in order to compare both standarts adequately, in my opinion.

4 - You are right, the result should be the other way round. Check your calculation of the SAE. Also check with the stated section in the standard whether you do the reference sample filtering correctly.

Other stuff: 1 - While you can have 64x64 inter prediction blocks in HEVC, you can only have up to 32x32 intra blocks. 2 - Take care when using integers in matlab, this also once screwed up all of my computations. Think about whether the number of bits of the integers you use are sufficient, or switch to doubles. When you load an image, the values are by default 8 bit unsigned integers, you have to typecast them for some computations.

like image 73
Bastian35022 Avatar answered Sep 29 '22 20:09

Bastian35022