nal: refactor nal code, marshall packets directly into output buffer

This removes two malloc/free for every NAL unit and removes yet another set of
memcopies at the end of the each frame encode. We're now writing the escaped
NAL packets directly into the buffer handed back to the user.

We preserve the max size of this output buffer to prevent having to do any
reallocations once the encoder is running.
encoder: remove useless comment
api: introduce param variables for two-pass encodes
rc: define default setting and validations for 2 pass states
rc: add 2 pass states in RateControl
param: log rc states of m_param in x265_param2string
rc: initialize the 2 pass states in rc
remove reduce code since trHeight always equal to trWidth
static m_bLFCrossTileBoundary since all of LCU use same value
move m_blockingStrength to local
cu: nits
TComDataCU: refactor structure for better data locality

--HG--
extra : rebase_source : 3cdf2d2f2fe240bc1a31ea2a7736ef32cf644e9e
rc: disable MSVC warnings about using POSIX function names like unlink()
lambda: [CHANGES OUTPUT] Change the distortion weights applied to chroma.

Inside R-D, a single lambda is applied for both luma and chroma. To account for the different QPs,
(as defined by the standard) the chroma distortion was weighted by a factor proportional to the
difference in QPs. This patch eliminates the extra weighting given to the chroma distortion
(since it is visually less perceptible).
x265_encoder_encode: don't return 0 while flushing.

--HG--
extra : rebase_source : 49e9af56c29b5bbca65dc527d738d35f380b9f1c
encoder: cleanup obsolete NAL data fields

--HG--
extra : rebase_source : 344428137d9c88558b24404fd13e78b439f3d079
encoder: remove redundant flush argument

--HG--
extra : rebase_source : 50cd3876db1ff1089d9cb3a0ad1c458c9ce170b4