CodeBlocks

Showing posts with label x264. Show all posts
Showing posts with label x264. Show all posts

Sunday, 12 May 2013

x264 Settings Comparison - Reference and BFrames

So its been a while since my last post, its quite difficult to find time for everything these days. So in this post im going to cover Reference frames, BFrames fast/optimal, since these don't influence quality and only compression, there is no need for screenshots.

Reference Frames
Default - 3
Controls the size of the DPB(Decoded Picture Buffer). Values range from 0-16. This is the number of previous frames each P-frame can use as a reference. 

Using more refernece frames increases memory usage and cpu load during playback, caused by having all the decoded reference frames in memory during playback. This can cause mobile devices or players to be unable to playback the video.

B-Frames
Default - 3 Fast
Sets the maximum number of consecutive B-Frames. B-Frames are capable of using motion prediction of future frames, this can lead to a significant compression gain.

Two different method to determine B-Frames, Fast and Optimal.

Reference Frames Compression

Futurama SD



Filesize Speed over reference frames
Performance compared to Medium

Reel Steel SD

Filesize speed over reference frames

Performance compared to Medium

Reel Steel HD

Filesize, Speed over reference frames

Performance compared to medium


It seems like animation benefits more from extra reference frames, than the live action, however the compression gained tapers off very quickly and appear to bottom out at around 8 reference frames. Interestingly the performance loss also tapers out.


B-Frames

Futurama SD


Fast Method
Optimal
Fast Method
Optimal
 

Reel Steel SD

Fast


Optimal
Fast
Optimal


Reel Steel HD

Fast
Optimal
Fast
Optimal

B-Fast method seems to have a near consistent speed regardless of the number of B-Frames and B-Optimal seems to slow down at a constant rate, however optimal performs much better at compression than fast with about 6% more compression, with only 5% speed impact.

Conclusion

Whilst the number of reference frames does improve performance it can cause other playback issues in memory and speed and the compression gained is not that significant. A safe value is 3, more than that and the compression gained for speed lost is large.

In BFrames we saw that optimal does a far better job at compression than Fast, but at a slower rate at around beyond 4 BFrames both start looses compression with some even doing worse at high values than lower ones. Also at 4 BFrames optimal is only marginally slower than Fast but provides about 6% extra compression

Recommended

Reference Frames : 3-5
B-Frames: Optimal : 3

Monday, 1 April 2013

X264 - ADM and Ab Frames- Comparison


x264 - ADM and Ab Frames - Comparison

Most of the next series of X264 related posts will be a lot lighter and smaller so I'm going to cover more settings. The settings I'll cover in thos post will be Adaptive Direct Mode(ADM) and Adaptive b-Frames(Ab-Frames)

Adaptive Direct Mode 
Also known as direct in the x264 settings, with 3 potential settings:
  1. None - Disabled direct motion vectors
  2. Spatial(default)
  3. Temporal
  4. Auto - x264 will swap between Spatial and Temporal.

Adaptive b-Frames 
Also known as b-adapt, this determine the placement of b-Frames and controls how x264 decides between adding a b-Frame of a P-frame. Since b-Frames are the most compressed out of all the frames having more b-frames should increase compression without having a image quality impact. b-adpt has 3 values to choose from and also uses the max bFrames setting to determine max consecutive beframes.
  1. Off/Disabled - Will always force the max number of consecutive bFrames after any p frame, not recommended with high consecutive b-frames as it will lead to some interesting stutter within the frame
  2. Fast - Fast attempt to determine bFrames and the quality and performance is not affective by the max number of consecutive bFrames.
  3. Optimal -  A slower but more accurate method, but performance will go down depending on the max number of consecutive bFrames. 

Since these don't really effect the quality of the video there is no reason to have any still frames.

Futurama  

Adaptive Direct Mode

So lets dive into it, these to graphs represents the file-size and performance of each method.


Filesize in KB
Performance FPS


Here we can see that auto performs almost identical to spatial suggesting that x264 uses spatial more often than temporal when left on auto, but since x264 has to do extra computations to determine which is better spatial out performs in performance. Interestingly none is the slowest of all the settings and the largest.

The next graph will show the relative differences in percentage between the settings when compared to spatial(default).

Percentage diff

As you can see none is 10.5% slower and yet 1.5% larger.
Temporal is 0.38 larger and 0.64 slower
Auto is 0.01 smaller but 1.13% slower

So during SD anime spatial is the best compression/performance wise
Note that it is said that auto is better suited for 2pass encodings.


Adaptive b-Frames

Filesize in KB

Performance FPS

Since bFrames are extremely small forcing bFrames at all time will lead to a smaller file size just like off does(max bFrames is 3), and since no additional decisions are made it is also faster, but not as fast as Fast. And with optimal having smaller filesize than fast.

 The next graph will show the relative differences in percentage between the settings when compared to Fast(default).

Percentage Diff



The first thing to note it that all of them are slower than Fast, however all of them have better compression than Fast. With optimal having a very good compression/performance ratio, with about 6% compression but only 4.3% slower.



ReelSteel SD
Adaptive Direct Mode
Well lets see how things change with Live Action Video.


Filesize in KB


Performance FPS

Percentage Diff

Interestingly optimal is only 0.47% slower but has 4.75% more compression


ReelSteel HD
Adaptive Direct Mode
Although I don't think HD video will have much of an impact on the data, I'm curious to see if the trend continues where Spatial and Optimal are very good.

Filesize in KB
 
Performance FPS


Percentage Diff


 Again nothing special Spatial performs exceptional well against the other settings

Although I don't think HD video will have much of an impact on the data, I'm curious to see if the trend continues where Spatial and Optimal are very good.
 Adaptive Direct Mode 
 I assume there won't be  much of a difference between HD and SD


Filesize in KB
Perormance FPS
Percentage Diff

 And the only diffirence is that Off is faster by 2% with about the same compression, and optimal is slower by 4.4% than in SD. Other than that it the same.

Conclusion
Well as there isn't that much to say other than spatial consistently had the best compression/performance ratio in Adaptive Direct mode. And Optimal had better compression than fast with a minimal to negligible performance impact.

Recommended
Adaptive Direct Mode: Spatial. is the best setting.

Adaptive b-Frames: Optimal - In my opinion the small performance hit is well worth compression gained, for now at least. We should see how they perform with varying max consecutive bFrames, which we will look into next time.

 Navigation
  1. Introduction
  2. Presets
  3. Subme  
  4. Motion estimation method 
  5. ADM and b-adapt.

Saturday, 16 March 2013

X264 - Motion Estimation Method- Comparison

Last time we looked at the effects of the various subpixel estimation complexity, today we will be looking at how the motion estimation method(MeM) impacts the filesize(all measured in KB), quality and performance(average FPS) according to CRF18 of x264.

There are a total of 5 methods these are in order of complexity:
  • Diamond(dia) - The most simplest method, checking motion vectors at one pixel up, left, down and right and picking the best candidate, this process repeats until it can't find a better motion vector
  • Hexagon(Hex) - Work similarly like Diamond but consists of a range-2 and 6 surrounding points, more efficient than diamond with little performance impact.
  • Uneven multi-hexagon(Uhm) - While slower than Hex, it is able to avoid missing harder-to-find motion vectors. The Me-Range parameter controls its search radius.
  • Exhaustive(Esa) - An optimised intelligent search of the complete motion vector space within Me-Range. Mathematically equivalent to brute force but faster, but still slower than Uhm.
  • Transformed exhaustive(Tesa) - is an algorithm which attempts to approximate the effect of running a Hadamard transform comparison at each motion vector; like exhaustive.

So now that we are more familiar with MeM lets see how it performs.


Futurama SD


The top graph shows the FileSize(Graph area) in KB as well as the performance(line) of each of the different methods. As you can see the relationship between compression and performance takes a turn for the worst with Esa and Tesa.

The bottom graph represents the difference in percentage for speed and compression compared to the default(medium) setting. Here we can see that with Esa for 29.5% performance reduction we get a measly 2.56% extra compression and Tesa does even worse. Uhm compresses better with a slight performance hit of 6.71% slower. Of course will have to see if this translates into any visual artefacts

Still Frame
Diamond
Hexagon

Uhm

Esa

Tesa





















Even though I can see a VERY slight difference between the different methods, I cannot say that one looks better than the other. 


Smaller Motion Detail
Diamond
Hexagon
Uhm
Esa
Tesa

























Again I can notice a difference between the methods but cannot say which is actually higher quality than the rest.

Reel Steel SD
 


So moving onto live action video, we can see that the same trend repeats it self with esa and tesa performing very poorly when compared to dia, hex and uhm.


Still Frame
Diamond
Hexagon





Uhm
Esa






Tesa









As with Futurama its difficult to tell which is better quality.


Smaller Motion Detail
Diamond
Hexagon

Uhm

Esa
Tesa








  .

 

 







And yet again the frame quality is too consistent to say which is better. Maybe we'll see a bigger deference with HD videos

 

Reel Steel HD 

So looking at HD video we see that esa and tesa performs worse than Uhm and is significantly slower. Hexagon seems like a good default method.


Still Frame 
Diamond
Hexagon
Uhm
Esa
Tesa

 

 

 

 

 

 

 

 

 








Yet again with MeM and with HD I can hardly see any difference let alone which is higher quality   

Smaller Motion Detail
Diamond
Hexagon
Uhm
Esa
Tesa

 



















So yet a again its almost impossible to tell which is which and which is better than the other.

Conclusion

Well as you can see visually there isn`t much of a difference, in terms of compression Uhm did consistently better than hexagon or diamond, and esa, tesa also performed better except at HD videos. Regarding performance Esa and Tesa took a massive performance hit, with Uhm only being slightly slower.

Recommended
Hexagon - Performed consistently close to the others.
Uhm - A slight compression gain at a margin performance loss.


 Navigation

  1. Introduction
  2. Presets
  3. Subme  
  4. Motion estimation method