1. 30 Jan, 2010 3 commits
  2. 14 Jan, 2010 1 commit
    • Fiona Glaser's avatar
      Periodic intra refresh · cde39046
      Fiona Glaser authored
      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.
      cde39046
  3. 15 Dec, 2009 1 commit
    • Fiona Glaser's avatar
      Fix two bugs in 2-pass ratecontrol · f30aed6d
      Fiona Glaser authored
      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.
      f30aed6d
  4. 11 Dec, 2009 1 commit
    • Steven Walters's avatar
      Fix zone parsing on mingw · e09a20eb
      Steven Walters authored
      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.
      e09a20eb
  5. 09 Dec, 2009 2 commits
    • Fiona Glaser's avatar
      Add support for MB-tree + B-pyramid · c186d2ac
      Fiona Glaser authored
      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.
      c186d2ac
    • Fiona Glaser's avatar
      Bring back slice-based threading support · 6f221210
      Fiona Glaser authored
      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.
      6f221210
  6. 22 Nov, 2009 1 commit
  7. 17 Nov, 2009 1 commit
    • Fiona Glaser's avatar
      Faster weightp analysis · 63f71477
      Fiona Glaser authored
      Modify pixel_var slightly to return the necessary information and use it for weight analysis instead of sad/ssd.
      Various minor cosmetics.
      63f71477
  8. 12 Nov, 2009 1 commit
    • Dylan Yudaken's avatar
      Various weightp fixes · 45b28315
      Dylan Yudaken authored
      Make weightp results match in threaded vs non-threaded mode.
      Fix two-pass with slow-firstpass.
      45b28315
  9. 09 Nov, 2009 4 commits
    • Steven Walters's avatar
      Fix weightp logfile parsing on MinGW · b3052970
      Steven Walters authored
      b3052970
    • Dylan Yudaken's avatar
      Weighted P-frame prediction · ccac8546
      Dylan Yudaken authored
      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!
      ccac8546
    • Steven Walters's avatar
    • Fiona Glaser's avatar
      Fix extremely rare infinite loop in 2-pass VBV · d2e7a5a6
      Fiona Glaser authored
      Implicit conversion from double->float lost enough precision to cause the loop termination condition to never trigger.
      Bug report by Tal Aloni.
      d2e7a5a6
  10. 29 Oct, 2009 1 commit
  11. 25 Oct, 2009 1 commit
  12. 19 Oct, 2009 3 commits
    • Steven Walters's avatar
      Fix assertion fail and incorrect costs with pyramid+VBV · ed903d90
      Steven Walters authored
      Deal properly with QPfile'd B-refs.  x264 should handle multiple B-refs per minigop now, though only via forced frametypes.
      ed903d90
    • Fiona Glaser's avatar
      Improve CRF initial QP selection, fix get_qscale bug · 318298e9
      Fiona Glaser authored
      If qcomp=1 (as in mb-tree), we don't need ABR_INIT_QP.
      get_qscale could give slightly weird results with still images
      318298e9
    • Lamont Alston's avatar
      Make B-pyramid spec-compliant · cf5ba813
      Lamont Alston authored
      The rules of the specification with regard to picture buffering for pyramid coding are widely ignored.
      x264's b-pyramid implementation, despite being practically identical to that proposed by the original paper, was technically not compliant.
      Now it is.
      Two modes are now available:
      1) strict b-pyramid, while worse for compression, follows the rule mandated by Blu-ray (no P-frames can reference B-frames)
      2) normal b-pyramid, which is like the old mode except fully compliant.
      This patch also adds MMCO support (necessary for compliant pyramid in some cases).
      MB-tree still doesn't support b-pyramid (but will soon).
      cf5ba813
  13. 12 Oct, 2009 3 commits
    • Fiona Glaser's avatar
      Reduce the aggressiveness of 2-pass VBV · 07cfdf84
      Fiona Glaser authored
      Now that B-frames are properly covered, we don't have to be as aggressive.
      This eliminates some issues with skyrocketing QPs in B-frames in 2-pass VBV.
      07cfdf84
    • Fiona Glaser's avatar
      Add row-based VBV for B-frames · 507c8342
      Fiona Glaser authored
      While B-frames still aren't explicitly covered by ratecontrol, this should resolve issues of VBV underflows due to larger-than-expected B-frames.
      507c8342
    • Fiona Glaser's avatar
      Improve VBV, fix bug in 2-pass VBV introduced in MB-tree · c51d00b7
      Fiona Glaser authored
      Bug caused AQ'd row/frame costs to not be calculated (and thus caused underflows).
      Also make VBV more aggressive with more threads in 2-pass mode.
      Finally, --ratetol now affects VBV aggressiveness (higher is less aggressive).
      c51d00b7
  14. 07 Oct, 2009 3 commits
    • Fiona Glaser's avatar
      Reorder reference frames optimally on second pass · c1322c31
      Fiona Glaser authored
      About +0.1-0.2% compression at normal bitrates, up to +1% at very low bitrates.
      Only works if the first pass uses the same number of refs as the second (i.e. not with fast first pass).
      Thus, only worthwhile at insanely slow speeds: as such, enable slow-firstpass by default with preset placebo.
      Note that this changes the stats file format!
      c1322c31
    • Fiona Glaser's avatar
      Fix typo in ratecontrol_summary · deae6910
      Fiona Glaser authored
      deae6910
    • Fiona Glaser's avatar
      Add support for single-frame VBV, improve compliance · 24ef8748
      Fiona Glaser authored
      This allows both constant-framesize and capped-framesize encoding.
      Literal constant framesize isn't actually supported yet due to the lack of
      filler support.
      Example with 30fps video: --vbv-bufsize 200 --vbv-maxrate 6000 will ensure that
      no frame is ever larger than 200 kilobits.
      
      One example use-case of this is for zero-delay streaming where bandwidth costs
      need to be minimized.  If every frame is smaller than 200 kilobits and the
      client has a 6 megabit connection, every single frame can be instantly sent
      to the client and handled without any decoder-side buffer.
      
      Fix a mistake in VBV calculation--this may have caused the VBV to be slightly
      non-compliant in some situations without x264 realizing it.
      Add primitive prediction handling for rows with quantizers lower than their
      reference.  This slightly improves VBV in CBR mode.
      Various other minor improvements to VBV, mostly to make single-frame VBV work.
      
      Commit sponsored by a media streaming company that wishes to remain anonymous.
      24ef8748
  15. 21 Sep, 2009 2 commits
    • Fiona Glaser's avatar
      Fix integer overflow in 2-pass VBV · 9e6650e9
      Fiona Glaser authored
      Bug caused slight undersizing in 2-pass mode in some cases.
      9e6650e9
    • Fiona Glaser's avatar
      Major API change: encapsulate NALs within libx264 · 7a0fbed7
      Fiona Glaser authored
      libx264 now returns NAL units instead of raw data.  x264_nal_encode is no longer a public function.
      See x264.h for full documentation of changes.
      New parameter: b_annexb, on by default.  If disabled, startcodes are replaced by sizes as in mp4.
      x264's VBV now works on a NAL level, taking into account escape codes.
      VBV will also take into account the bit cost of SPS/PPS, but only if b_repeat_headers is set.
      Add an overhead tracking system to VBV to better predict the constant overhead of frames (headers, NALU overhead, etc).
      7a0fbed7
  16. 14 Sep, 2009 2 commits
  17. 02 Sep, 2009 1 commit
    • Steven Walters's avatar
      Threaded lookahead · 6940dcae
      Steven Walters authored
      Move lookahead into a separate thread, set to higher priority than the other threads, for optimal performance.
      Reduces the amount that lookahead bottlenecks encoding, greatly increasing performance with lookahead-intensive settings (e.g. b-adapt 2) on many-core CPUs.
      Buffer size can be controlled with --sync-lookahead, which defaults to auto (threads+bframes buffer size).
      Note that this buffer is separate from the rc-lookahead value.
      Note also that this does not split lookahead itself into multiple threads yet; this may be added in the future.
      Additionally, split frames into "fdec" and "fenc" frame types and keep the two separate.
      This split greatly reduces memory usage, which helps compensate for the larger lookahead size.
      Extremely special thanks to Michael Kazmier and Alex Giladi of Avail Media, the original authors of this patch.
      6940dcae
  18. 31 Aug, 2009 1 commit
    • Fiona Glaser's avatar
      Multi-slice encoding support · 4ccbb199
      Fiona Glaser authored
      Slicing support is available through three methods (which can be mixed):
      --slices sets a number of slices per frame and ensures rectangular slices (required for Blu-ray).  Overridden by either of the following options:
      --slice-max-mbs sets a maximum number of macroblocks per slice.
      --slice-max-size sets a maximum slice size, in bytes (includes NAL overhead).
      Implement macroblock re-encoding support to allow highly accurate slice size limitation.  Might be useful for other things in the future, too.
      4ccbb199
  19. 27 Aug, 2009 1 commit
  20. 24 Aug, 2009 1 commit
    • Fiona Glaser's avatar
      2-pass VBV fixes · 918808f8
      Fiona Glaser authored
      Properly run slicetype frame cost with 2pass + MB-tree.
      Slash the VBV rate tolerance in 2-pass mode; increasing it made sense for the highly reactive 1-pass VBV algorithm, but not for 2-pass.
      2-pass's planned frame sizes are guaranteed to be reasonable, since they are based on a real first pass, while 1-pass's, based on lookahead SATD, cannot always be trusted.
      918808f8
  21. 19 Aug, 2009 1 commit
    • Fiona Glaser's avatar
      Add support for frame-accurate parameter changes · c83699f1
      Fiona Glaser authored
      Parameter structs can now be passed with individual frames.
      The previous method would only change the parameter of what was currently being encoded, which due to delay might be very far from an intended exact frame.
      Also add support for changing aspect ratio.  Only works in a stream with repeating headers and requires the caller to force an IDR to ensure instant effect.
      c83699f1
  22. 17 Aug, 2009 1 commit
    • Fiona Glaser's avatar
      Lookahead VBV · 30a82c75
      Fiona Glaser authored
      Use the large-scale lookahead capability introduced in MB-tree for ratecontrol purposes.
      (Does not require MB-tree, however.)
      Greatly improved quality and compliance in 1-pass VBV mode, especially in CBR; +2db OPSNR or more in some cases.
      Fix some other bugs in VBV, which should improve non-lookahead mode as well.
      Change the tolerance algorithm in row VBV to allow for more significant mispredictions when buffer is nearly full.
      Note that due to the fixing of an extremely long-standing bug (>1 year), bitrates may change by nontrivial amounts in CRF without MB-tree.
      30a82c75
  23. 14 Aug, 2009 1 commit
    • Fiona Glaser's avatar
      Fix a potential failure in VBV · e586d699
      Fiona Glaser authored
      If VBV does underflow, ratecontrol could be permanently broken for the rest of the clip.
      Revert part of the previous VBV changes to fix this.
      e586d699
  24. 08 Aug, 2009 1 commit
  25. 07 Aug, 2009 1 commit
    • Fiona Glaser's avatar
      Macroblock-tree ratecontrol · 835ccc3c
      Fiona Glaser authored
      On by default; can be turned off with --no-mbtree.
      Uses a large lookahead to track temporal propagation of data and weight quality accordingly.
      Requires a very large separate statsfile (2 bytes per macroblock) in multi-pass mode.
      Doesn't work with b-pyramid yet.
      Note that MB-tree inherently measures quality different from the standard qcomp method, so bitrates produced by CRF may change somewhat.
      This makes the "medium" preset a bit slower.  Accordingly, make "fast" slower as well, and introduce a new preset "faster" between "fast" and "veryfast".
      All presets "fast" and above will have MB-tree on.
      Add a new option, --rc-lookahead, to control the distance MB tree looks ahead to perform propagation analysis.
      Default is 40; larger values will be slower and require more memory but give more accurate results.
      This value will be used in the future to control ratecontrol lookahead (VBV).
      Add a new option, --no-psy, to disable all psy optimizations that don't improve PSNR or SSIM.
      This disables psy-RD/trellis, but also other more subtle internal psy optimizations that can't be controlled directly via external parameters.
      Quality improvement from MB-tree is about 2-70% depending on content.
      Strength of MB-tree adjustments can be tweaked using qcompress; higher values mean lower MB-tree strength.
      Note that MB-tree may perform slightly suboptimally on fades; this will be fixed by weighted prediction, which is coming soon.
      835ccc3c
  26. 05 Aug, 2009 1 commit
    • Fiona Glaser's avatar
      Various 1-pass VBV tweaks · 93cc2893
      Fiona Glaser authored
      Make predictors have an offset in addition to a multiplier.
      This primarily fixes issues in sources with lots of extremely static scenes, such as anime and CGI.
      We tried linear regressions, but they were very unreliable as predictors.
      Also allow VBV to be slightly more aggressive in raising QPs to avoid not having enough bits left in some situations.
      Up to 1db improvement on some clips.
      93cc2893