Log in

View Full Version : Fevh264 - simple baseline h.264 encoder


imcold
24th July 2010, 20:49
Fevh264 is a very simple baseline h.264 encoder. I'm releasing it in hope that somebody finds it useful if he decides to learn about h.264 encoding process and as a base for experiments; it's not a serious competition to "real" h.264 encoders. It's written in Pascal (Freepascal) with some hand-written assembly and shouldn't be hard to understand.

It uses the command line interface (see fevh264_cli -h for switches). Input is restricted to raw YUV 4:2:0 (width and height requied), yuv4mpeg or Avisynth scripts; output is raw .264 (AnnexB) file.

Update:
-added simple ratecontrol for 2 pass avg. bitrate encoding
-added multiref support
-GUI frontend with visualization support, on-the-fly QP change support. Screenshot (windows, linux):
http://i266.photobucket.com/albums/ii260/imcoldz/prog/983027c1.png http://i266.photobucket.com/albums/ii260/imcoldz/prog/th_236842f5.png (http://s266.photobucket.com/albums/ii260/imcoldz/prog/236842f5.png)

Limitations:
-won't work on cpu without sse2 support, also the asm is 32bit only
-can't be build as a library currently
-all files set to 25 fps

Missing useful baseline stuff, to be added later:
-inter mb partitions
-deblock

Sample (parkjoy, using older version of encoder): http://www.mediafire.com/?cyk53kqx88tcc10

Source, binaries: https://sourceforge.net/projects/fevh264/

Compilation:
Win32 and Linux 32bit are supported. You'll need Yasm and Freepascal 2.x + Lazarus IDE.
1. go to frontend subdirectory, run build_asm.bat/.sh to compile asm files
2. open fevh264_cli.lpi / fevh264_gui.lpi through Lazarus IDE and build

If you find any bugs (crashes, unplayable output files), let me know.

Terranigma
24th July 2010, 22:03
Not bad. Not bad at all. I just wish it could handle non mod-16 resolutions.

lnatan25
25th July 2010, 04:10
Haha, Pascal. But it's commendable, good stuff!

imcold
29th July 2010, 17:53
Support for non-mod16 resolution added.
Haha, Pascal.
Yes, still alive and well, though fallen out of favor.

TheImperial2004
1st August 2010, 01:56
Great stuff indeed . ;)

Why don't you write this encoder for GPU (e.g. CUDA) from the very begining ? It will be great and easier than adding it later when you have a big source tree :)

All the best ...

imcold
2nd August 2010, 07:52
1. there won't be a big source tree, that's one of the goals - any gpgpu efforts should be aimed on x264
2. from what I've seen so far, usefulness of gpgpu in video encoding is very limited
3. I don't have gpgpu capable graphic card (5+ years old)

TheImperial2004
5th August 2010, 11:10
1. there won't be a big source tree, that's one of the goals - any gpgpu efforts should be aimed on x264
2. from what I've seen so far, usefulness of gpgpu in video encoding is very limited
3. I don't have gpgpu capable graphic card (5+ years old)

Neverthless , I'll keep my eye on this project . I might even develop a simple GUI for it if I had enough time , And I'll consult you on the matter ;)
Good luck :)

imcold
10th February 2011, 20:03
I had some time recently so I made some improvements to the encoder and made a new encoding GUI, so you can observe the encoder in action: it displays macroblock types, motion vectors and some statistics about currently encoded frame and it allows you to change QP on the fly. Some settings are non-functional/not available at the moment, though: 2pass, chroma qp changing. Have fun.

benwaggoner
18th February 2011, 19:03
Yes, still alive and well, though fallen out of favor.
Pascal was the last commonly-used programming language I felt adequately good at :). Got a 5 on my AP CS test... in Pascal... in 1988...

Did you pick Pascal because you liked it, or for another reason?

Also, can you give some background on the origin and goals of this project?

imcold
27th February 2011, 10:51
I generally prefer using (Free)pascal instead of C/C++. Origin - I got interested in data compression, especially video compr. way back and started making progs using different compression algos. Things evolved over the years and voila. Goal - learn about h.264 standard specifics and how encoders work in general, and I guess learning by implementing it is a very good way to do this.