Fiona Glaser [Tue, 19 Jan 2010 04:29:33 +0000 (20:29 -0800)]
Various performance optimizations
Simplify and compact storage of direct motion vectors, faster --direct auto.
Shrink various arrays to save a bit of cache.
Simplify and reorganize B macroblock type writing in CABAC.
Add some missing ALIGNED macros.
Fiona Glaser [Sun, 17 Jan 2010 01:11:29 +0000 (20:11 -0500)]
Add support for multiple --tune options
Tunes apply in the order they are listed in the case of conflicts.
Psy tunings, i.e. film/animation/grain/psnr/ssim, cannot be combined.
Also clarify --profile, which forces the limits of a profile, not the profile itself.
Fiona Glaser [Sat, 16 Jan 2010 07:50:15 +0000 (02:50 -0500)]
Various bugfixes and tweaks in analysis
Fix the oldest-ever bug in x264: b16x8 analysis used the wrong width for predict_mv.
Fix cache_ref calls for slightly better MV prediction in bsub16x16 analysis.
Make B-partition analysis consider reference frame costs.
Various other minor changes.
Overall very slightly improved mode decision and motion search in B-frames.
Fiona Glaser [Sun, 10 Jan 2010 20:14:02 +0000 (15:14 -0500)]
Fix free callback, add x264_encoder_parameters function
x264 would try to use the passed param struct after freeing if the param_free callback was set.
Probably didn't cause any issues, as probably no programs used the callback in this location yet.
A new x264_encoder_parameters function is now available in the API.
This function lets the calling application grab the current state of the encoder's parameters.
Use this in x264cli to ensure that the param struct used for set_param is updated with whatever changes x264_encoder_open has made to it.
Patch partially by Anton Mitrofanov <BugMaster@narod.ru>.
Fiona Glaser [Sat, 2 Jan 2010 08:27:46 +0000 (03:27 -0500)]
Faster weightp motion search
For blind-weight dupes, copy the motion vector from the main search and qpel-refine instead of doing a full search.
Fix the p8x8 early termination, which had unexpected results when combined with blind weighting.
Overall, marginally reduces compression but should potentially improve speed by over 5%.
Fiona Glaser [Thu, 31 Dec 2009 18:45:27 +0000 (13:45 -0500)]
More correct padding constants for lowres planes
Since lowres analysis isn't interlace-aware, we don't need to double the vertical padding for interlaced video.
Fiona Glaser [Tue, 22 Dec 2009 23:59:29 +0000 (18:59 -0500)]
Periodic intra refresh
Uses SEI recovery points, a moving vertical "bar" of intra blocks, and motion vector restrictions to eliminate keyframes.
Attempt to hide the visual appearance of the intra bar when --no-psy isn't set.
Enabled with --intra-refresh.
The refresh interval is controlled using keyint, but won't exceed the number of macroblock columns in the frame.
Greatly benefits low-latency streaming by making it possible to achieve constant framesize without intra-only encoding.
Combined with slice-max size for one slice per packet, tests suggest effective resiliance against packet loss as high as 25%.
x264 is now the best free software low-latency video encoder in the world.
Accordingly, change the API to add b_keyframe to the parameters present in output pictures.
Calling applications should check this to see if a frame is seekable, not the frame type.
Also make x264's motion estimation strictly abide by horizontal MV range limits in order for PIR to work.
Also fix a major bug in sliced-threads VBV handling.
Also change "auto" threads for sliced threads to "cores" instead of "1.5*cores" after performance testing.
Also simplify ratecontrol's checking of first pass options.
Also some minor tweaks to row-based VBV that should improve VBV accuracy on small frames.
Kieran Kunhya [Mon, 28 Dec 2009 15:42:17 +0000 (10:42 -0500)]
LAVF/FFMS input support, native VFR timestamp handling
libx264 now takes three new API parameters.
b_vfr_input tells x264 whether or not the input is VFR, and is 1 by default.
i_timebase_num and i_timebase_den pass the timebase to x264.
x264_picture_t now returns the DTS of each frame: the calling app need not calculate it anymore.
Add libavformat and FFMS2 input support: requires libav* and ffms2 libraries respectively.
FFMS2 is _STRONGLY_ preferred over libavformat: we encourage all distributions to compile with FFMS2 support if at all possible.
FFMS2 can be found at http://code.google.com/p/ffmpegsource/.
--index, a new x264cli option, allows the user to store (or load) an FFMS2 index file for future use, to avoid re-indexing in the future.
Overhaul the muxers to pass through timestamps instead of assuming CFR.
Also overhaul muxers to correctly use b_annexb and b_repeat_headers to simplify the code.
Remove VFW input support, since it's now pretty much redundant with native AVS support and LAVF support.
Finally, overhaul a large part of the x264cli internals.
--force-cfr, a new x264cli option, allows the user to force the old method of timestamp handling. May be useful in case of a source with broken timestamps.
Avisynth, YUV, and Y4M input are all still CFR. LAVF or FFMS2 must be used for VFR support.
Do note that this patch does *not* add VFR ratecontrol yet.
Support for telecined input is also somewhat dubious at the moment.
Large parts of this patch by Mike Gurlitz <mike.gurlitz@gmail.com>, Steven Walters <kemuri9@gmail.com>, and Yusuke Nakamura <muken.the.vfrmaniac@gmail.com>.
Fiona Glaser [Sat, 12 Dec 2009 01:22:18 +0000 (17:22 -0800)]
Fix two bugs in 2-pass ratecontrol
last_qscale_for wasn't set during the 2pass init code.
abr_buffer was way too small in the case of multiple threads, so accordingly increase its buffer size based on the number of threads.
May significantly increase quality with many threads in 2-pass mode, especially in cases with extremely large I-frames, such as anime.
Steven Walters [Fri, 11 Dec 2009 03:48:51 +0000 (19:48 -0800)]
Avisynth-MT and 2.6 compatibility fixes
Explain to the user why YV12 conversion is forced with Avisynth 2.6.
Fix encoding with Avisynth-MT scripts by inserting the necessary Distributor() call; speeds such scripts back up to expected levels.
Steven Walters [Thu, 10 Dec 2009 00:03:19 +0000 (16:03 -0800)]
Fix zone parsing on mingw
Due to MinGW evidently being in the hands of a pack of phenomenal idiots, MinGW does not have strtok_r, a basic string function.
As such, remove the dependency on strtok_r in zone parsing.
Previously, using zones for anything other than ratecontrol failed.
Fiona Glaser [Wed, 9 Dec 2009 23:03:44 +0000 (15:03 -0800)]
More lookahead optimizations
Under subme 1, don't do any qpel search at all and round temporal MVs accordingly.
Drop internal subme with subme 1 to do fullpel predictor checks only.
Other minor optimizations.
Fiona Glaser [Wed, 9 Dec 2009 13:56:35 +0000 (05:56 -0800)]
Various minor missing changes from previous commits
Boolify sliced threads too
Remove unused constants from dct-a.asm
Fix a few typos/minor errors in preset documentation
Fiona Glaser [Fri, 11 Dec 2009 00:52:39 +0000 (16:52 -0800)]
Fix regression in direct=auto/temporal in r1364
Bug caused rare race condition in frame reference handling.
This resulted in invalid bitstreams in some B-frames and, very rarely, crashes.
Fiona Glaser [Tue, 8 Dec 2009 11:08:17 +0000 (03:08 -0800)]
Add support for MB-tree + B-pyramid
Modify B-adapt 2 to consider pyramid in its calculations.
Generally results in many more B-frames being used when pyramid is on.
Modify MB-tree statsfile reading to handle the reordering necessary.
Make differing keyint or pyramid between passes into a fatal error.
Fiona Glaser [Mon, 7 Dec 2009 08:49:41 +0000 (00:49 -0800)]
Bring back slice-based threading support
Enabled with --sliced-threads
Unlike normal threading, adds no encoding latency.
Less efficient than normal threading, both performance and compression-wise.
Useful for low-latency encoding environments where performance is still important, such as HD videoconferencing.
Add --tune zerolatency, which eliminates all x264 encoder-side latency (no delayed frames at all).
Some tweaks to VBV ratecontrol and lookahead (in addition to those required by sliced threading).
Commit sponsored by a media streaming company that wishes to remain anonymous.
Fiona Glaser [Wed, 2 Dec 2009 00:15:15 +0000 (16:15 -0800)]
Significantly faster qpel-RD
Cache the results of MC, like in bidir-RD.
Slightly changes output due to the necessary reordering of satd/RD calls.
5-10% faster qpel-RD.
Steven Walters [Fri, 27 Nov 2009 06:37:18 +0000 (22:37 -0800)]
Enhanced Avisynth input support
Requires avisynth_c.h from the Avisynth API headers.
Reports errors properly from Avisynth script input.
Automatically construct input scripts for almost any input file.
Tries ffmpegsource2, DSS2, directshowsource, and many other sourcing methods, based on the input file extension.
Automatically converts to YV12.
Fiona Glaser [Wed, 25 Nov 2009 18:40:08 +0000 (10:40 -0800)]
Much faster weightp
Move sum/ssd calculation out of lookahead and do it only once per frame.
Also various minor optimizations, cosmetics, and cleanups.
Fiona Glaser [Wed, 25 Nov 2009 00:21:07 +0000 (16:21 -0800)]
Fix weightb with delta_poc_bottom
Has no effect yet, but will be required once we add TFF/BFF signalling support in interlaced mode.
Gives 0.5-0.7% better compression with proper TFF/BFF signalling.
Fiona Glaser [Wed, 18 Nov 2009 21:47:04 +0000 (13:47 -0800)]
Faster lookahead with subme=1
If it hasn't been clear already, don't use subme=1 as a "fast first pass" option.
Use subme=2 instead; 1 and below now enable a fast (lower quality) lookahead mode.
Fiona Glaser [Mon, 16 Nov 2009 23:23:58 +0000 (15:23 -0800)]
Faster weightp analysis
Modify pixel_var slightly to return the necessary information and use it for weight analysis instead of sad/ssd.
Various minor cosmetics.
Dylan Yudaken [Mon, 16 Nov 2009 00:14:50 +0000 (16:14 -0800)]
Fix two issues in weightp
If analysis decided on an offset of -128, x264 would create non-compliant streams.
Fix some cases with nearly all intra blocks where analysis could pick very weird weights.
Also add some asserts to check compliancy.
Use __attribute__((may_alias)) for type-punning
GCC thinks pointer casts to unions aren't valid with strict aliasing.
See http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Optimize-Options.html#Type_002dpunning.
Also use M32() in y4m.c.
Enable -Wstrict-aliasing again since all such warnings are fixed.
Fiona Glaser [Thu, 12 Nov 2009 13:25:32 +0000 (05:25 -0800)]
Fix all aliasing violations
New type-punning macros perform write/read-combining without aliasing violations per the second-to-last part of 6.5.7 in the C99 specification.
GCC 4.4, however, doesn't seem to have read this part of the spec and still warns about the violations.
Regardless, it seems to fix all known aliasing miscompilations, so perhaps the GCC warning generator is just broken.
As such, add -Wno-strict-aliasing to CFLAGS.
Fiona Glaser [Tue, 10 Nov 2009 05:22:41 +0000 (21:22 -0800)]
Fix one (of possibly many) miscompilations in weightp
Use NOINLINE and some emms calls to fix emms reordering issues.
This issue occurred with some GCC versions if threads > 1 and the phase of the moon was right.
Also a cosmetic in x264.c.
Dylan Yudaken [Mon, 9 Nov 2009 01:59:08 +0000 (17:59 -0800)]
Weighted P-frame prediction
Merge Dylan's Google Summer of Code 2009 tree.
Detect fades and use weighted prediction to improve compression and quality.
"Blind" mode provides a small overall quality increase by using a -1 offset without doing any analysis, as described in JVT-AB033.
"Smart", the default mode, also performs fade detection and decides weights accordingly.
MB-tree takes into account the effects of "smart" analysis in lookahead, even further improving quality in fades.
If psy is on, mbtree is on, interlaced is off, and weightp is off, fade detection will still be performed.
However, it will be used to adjust quality instead of create actual weights.
This will improve quality in fades when encoding in Baseline profile.
Doesn't add support for interlaced encoding with weightp yet.
Only adds support for luma weights, not chroma weights.
Internal code for chroma weights is in, but there's no analysis yet.
Baseline profile requires that weightp be off.
All weightp modes may cause minor breakage in non-compliant decoders that take shortcuts in deblocking reference frame checks.
"Smart" may cause serious breakage in non-compliant decoders that take shortcuts in handling of duplicate reference frames.
Thanks to Google for sponsoring our most successful Summer of Code yet!
Steven Walters [Sun, 8 Nov 2009 19:53:48 +0000 (11:53 -0800)]
Fix assert failure in the case of forced i-frames
Note that this applies to non-IDR i-frames, not IDR-frames.
This fix is also required for future open-gop.
David Conrad [Sat, 7 Nov 2009 17:25:18 +0000 (09:25 -0800)]
Various ARM-related fixes
Fix comment for mc_copy_neon.
Fix memzero_aligned_neon prototype.
Update NEON (i)dct_dc prototypes.
Duplicate x86 behavior for global+hidden functions.
Fiona Glaser [Wed, 4 Nov 2009 08:03:14 +0000 (00:03 -0800)]
Fix miscompilation with gcc 4.3 on ARM
Aliasing violation in spatial prediction caused nasty artifacts.
Shut up two other GCC warnings while we're at it.
Fiona Glaser [Wed, 4 Nov 2009 07:15:35 +0000 (23:15 -0800)]
Fix extremely rare infinite loop in 2-pass VBV
Implicit conversion from double->float lost enough precision to cause the loop termination condition to never trigger.
Bug report by Tal Aloni.
Anton Mitrofanov [Tue, 27 Oct 2009 19:28:07 +0000 (12:28 -0700)]
Fix cases in which b-adapt 1 could result in AUTO-type frames.
This didn't actually cause any issues, but it removes the need for the fixing-up code that prevented said issues.
Fiona Glaser [Mon, 26 Oct 2009 19:53:07 +0000 (12:53 -0700)]
Motion compensation optimizations
Turning off inlining saves a whole boatload of code size for near-zero speed cost.
Simplify offset calculation.
Various other optimizations.
Fiona Glaser [Sun, 25 Oct 2009 16:14:27 +0000 (09:14 -0700)]
ISC-license x86inc.asm
As the assembly abstraction layer is very useful in non-x264 projects, it is now ISC (simplified BSD) so that others, even in commercial projects, can use it as well.