ACodec: Video bringup for NuPlayer and other fixes

- Add tile color format
- Handle Flush command in intermediate states

Change-Id: Id60e6a47d7dba39ea6febbfa55f64b6480ac54fa

Process EBD and FBD messages in ERROR state

- OMXCodec::on_message() function drops all OMX messages if
  OMXCodec is in ERROR state
- This can cause EBD/FBD messages containing valid buffers to be
  dropped
- Avoid dropping EBD/FBD messages so that buffer book-keeping is still
  possible

Change-Id: Idc1174b3fa946b26458d49394b87fba1738b228e
Signed-off-by: Iliyan Malchev <malchev@google.com>

nuplayer: Fixes in nuplayer Renderer

- Fix to allow EOS to be queued & handled even before
  a single frame is rendered. This can occur for suspend
  resume scenarios, where seek fails after resume.
- Reset the mSyncQueues flag when an EOS is queued immediately
  after seek
- Fix in AV sync calculation for video only stream's pause
  scenario

Change-Id: I881b9d0584dddde5f20da54f0501258649c9c600

NuPlayer: Fixes in NuPlayer

- Do not scan for sources during pause
- Do not create Video Decoder if Surface is not set
- Do not create Audio Decoder if Audio Sink is not set
- Enable fetchFile & BW estimate logs in LiveSession
- Enable format changed, and EOS logs in NuPlayer

Change-Id: Ia829dd6bb11fd4d1305caaa1dbac7434ea33e02f

ACodec: Support for dynamic port reconfig

- On port settings changed first flush output port
- Move ACodec to new state called FlushingOutputState
- Flush all output buffers, wait till all decoded buffers
  are rendered
- Then disable output port, and allocate output buffers
  with new resolution, and reset native window

Change-Id: Iafa266371ed2a87b909fbcb4eeae6b64208df617

NuPlayer-HLS: Support for handling seek from NuPlayer

- Seek was handled by the source by queuing discontinuity events
  individually for each stream.With this approach renderer will
  continue till discontinuity events are handled for each stream
- With the new approach Seek will be handled by NuPlayer directly
  Flush & reset decoders & renderer, then scan for sources
- Update meta data in ATSParser & AnotherPacketSource after seek
- Add a new discontinity type for HLS seek, and set it for seek

Change-Id: Iaff05b33f9a8d244cddbc53ae55219fb8568e614

libstagefright: Thumbnail mode initial commit

- DIVX and WMV are commented out for now
- Fix thumbnails for videos with non multiple of 4 width
- Fix source start assertion failure on MPEG4Source

Change-Id: I0e8974e088fdcc468e27764861c128cfe291499f
CRs-Fixed: 346285, 331371, 326063, 325461, 323538

libvideoeditor: Initial commit for VideoEditor bringup

- Add the color conversion routines of TILE4x2 to Planar and Planar
  to Semi-Planar to libI420colorconvert.so
- Set the native window buffer count to 3 for image preview
- All Features are supported, Resolutions upto 1080P are supported
  (constrained by available memory) as we need to support two codec
  instances at a time
- High and main profile clips cannot be imported
- Export is in H264 always (Coming from the app)

- NativeWindowRenderer: Fixed the green tint issue when applying
  negative effect
- M4xVSS_API: Do not go through the M4MCS path if there is an
  effect in the clip(avoid double encoding)
- M4MCS_API: Remove the limitBitRate function as we set the bitrate
  in Encoder
- VideoEditorVideoEncoder: Add a function to calculate proper bitrate
  for different quality and resolutions

- Remove the check for effects present in the project to get original
  functionality. This check would encode all clips in the project if
  an effects existed via the _EDIT path. But it fails for HP clips.
  Hence reverting it.
- Only encode in M4MCS for input profile > output profile

- When parsing a clip, add support for level 6 for simple profile
  MPEG4 clips
- However map it to level 5, since OpenMax does not have support for
  level 6

- When creating transitions, the bitrate is copied from the input file,
  if this bitrate is > 20Mbps, it results in an error.Limit this bitrate
  to max of 20Mbps

- During preview, after calling start on mVideoSource if the component
  runs into an out of memory error, then first stop the mVideoSource
  before clearing it.
  Once the source is NULL(cleared), add a check to handle that case
  and propogate it upwards to the app.

- If there is clip with begin cut time and MPEG4, then let it encode
  via the M4MCS path first. Null encoding leads to corruption - because
  in null encoding, if we have a begin cut time then it will decode
  upto that time, encode the frame at the cut time and just copy the
  rest from the reader and write to the intermediate file, resulting
  in corruption. Instead now this change will make it encode from the
  cut time all the way to the end of clip.

- For H263/MPEG4 encoding, bitrate is not reconfigured.We break out
 from the case to avoid getting into the default case.

Change-Id: I850edc1fcaad167250089644a4435bc549f1e31d

CRs-Fixed: 327213, 329321, 328501, 329324, 332373, 332959, 375291

libstagefright: Add support for mm-color-convertor

- Define structure and enums to be used by stagefright
  to interact with mm-color-convertor library
- Adds support of NV12 Tile to RGB565 color conversion
  using the qcom color convertor library.
- Use proper mangled name for color convertor API

Change-Id: Ifd87d0e56c5fe4c9f605321abdd39574415733f5
CRs-Fixed: 329591

libstagefright: Enable frame by frame mode

- Enable frame by frame for all formats - local playback & http
  streaming.
- Arbitrary mode is enabled only for specific formats by setting
  a new key (kKeyUseArbitraryMode) in extractor, for following
  formats :
  - H264 Interlaced clips
  - VC1 Advance profile clips
  - MPEG4 in AVI container
- If the arbitrary mode key is not set by the extractor, it will
  default to frame by frame mode for all video clips except
  interlaced clips.
- Adds SPS parsing functionality.

Change-Id: If8c47d0499720eead86b4c4fbe74696aba4423fb
CRs-Fixed: 322872

libstagefright: Fix to use correct HAL pixel format

Use correct HAL pixel format to update buffer geometry
using native window API for 7x27A/8x25.

Change-Id: I3602cf3e21d259a79f36db3103ab5f18ec2a1010

Conflicts:

	media/libstagefright/OMXCodec.cpp

libvideoeditor: remove header file added during bringup

This header file was added to this directory while merging
changes to JB.The header file exist in a different location.
Source code which need the header file is updated to include
correct path.

Change-Id: I95a8cb7dcc13ddb925d4e4f55fbeabbf54f9ca61

libstagefright: Ignore bad size error when parsing d263 atom.

Change-Id: Id71c6d55181d46671aba3e14bfbc4933687b180f
CRs-Fixed: 288020

libstagefright: Handle error on allocate buffer failure

Set state to error on allocate buffer failure at start(init)
of decoding.

Change-Id: Id16cb68aad95bf60aa520d1cc7378cfe0f88b65a
CRs-Fixed: 332373
Signed-off-by: Shalaj Jain <shalajj@codeaurora.org>

libstagefright: Add definitions for sync margins

- Added definitions for late and early margins in AwesomePlayer which
  are used to decide if frames should be delayed or dropped

CRs-Fixed: 276424, 297660

SampleTable: Add shortcut in getMaxSampleSize() to avoid ANR in corrupted clips

-for very large/corrupt values of mNumSampleSizes, getMaxSampleSize will
 run a very long forloop that will cause an ANR
-for cases where mDefaultSampleSize is zero, this ANR issue will not
 occur becase a check is in place for checking mNumSampleSizes corruption
-for cases where mDefaultSampleSize is non-zero, getMaxSampleSize will proceed
 to process each sample for finding max size.  But each run of
 SampleIterator::getSampleSizeDirect will return mDefaultSampleSize as the size
-a check for mDefaultSampleSize being non-zero is placed before the for loop,
 and will return mDefaultSampleSize if it is the case, skipping the entire for loop
 and avoids ANR

Change-Id: Ib2af5f18a2d15fb8efa6e1edaa2e5b46f6746fe8
CRs-Fixed: 316017

libstagefright - Squashed commits from CodeAurora

libstagefright - increase avcc atom size allowed

 - increases buffer allowed for parsing avcc atom to 1024

Change-Id: I2bd91be7f578978a6d00280f05beccfda19eea0b
CRs-Fixed: 344358, 331837

libstagefright: Release output buffer when file limit is reached in recording

There is a memory leak in video recording when the
file size or duration limits are reached. The output
buffer copy is not released before exiting the track
thread in the mpeg4 writer.

To avoid the memory leak, the buffer copy is released
when a limit condition is detected in the mpeg4 writer.

Change-Id: Idfde2083fdd9997b3025c7c12e00f3ae4665b8da
CRs-Fixed: 315255
Signed-off-by: Shalaj Jain <shalajj@codeaurora.org>

libstagefright: Remove warnings

- Treat warnings as errors
- Clean up existing warnings

Change-Id: I162e6f0586f27502c404dfcea87052a930c543ee

Check for status of OMX_UseBuffer before updating port buffer vector

- For output buffers, check if the call to OMX_UseBuffer
  was successful before updating the port buffer queue.

Change-Id: I0cdef2200349ff6be4620d4f9fe4ae96e0c263cf

StagefrightRecorder: Set intra-period to 2 seconds for video recording

Sets the video encoder intra period value to 2 seconds in
StagefrightRecorder.

Change-Id: Ic9fa16e75baa9aa8e90876f0558b3f2bdcfaa2b3

libstagefright: Fix AV sync issues

- Add edit list support for video playback.

Change-Id: If50ecebc46d97b6da4164834c5aece0345b2aeea
CRs-Fixed: 362885

frameworks/base: Add rendering statistics to Stagefright

- this adds extra fps statistics

CRs-Fixed: 345331, 338656, 334379, 325195
Change-Id: I2637e1912169e44fc136377d385c95d836813b0c

AudioFlinger: Compile AudioParameter as shared library

Change-Id: I5115ef6ba370c251b1a28e3453a154a43ae3470b

libstagefright: Ignore port settings changed event in certain cases

Ignore port settings changed event if the client has already
requested the component to move to Idle state (or any other state)
from Executing state. This scenario happens when Stop is called
immediately after Stop on OMXCodec. Since, Stop is called
so we request the component to move into Idle state and set
the state variable accordingly. In this case we might receive
port settings changed event after we have requested the
component to move into Idle state.

Change-Id: I35cb15bb582381c86f327cd874999ac05c771ee2

libstagefright: enable extended extractor

- Enable extended extractor to support proprietary Audio\Video
  format.

Change-Id: Ia586a3048420ddf1515261f20035589447263b7b

libmediaplayerservices: Enable DASH on Nuplayer framework

Change-Id: Ie9b107881867686d5ee04f19bc043c926ba7427e

Conflicts:

	media/libmediaplayerservice/nuplayer/NuPlayer.cpp

libstagefright - Fix timestamp overflow

 - change time related variables to 64 bit to avoid overflow
 - composition time calculations were having overflow in
   SampleIterator and it propagates to the rest of the time
   related information for the frames

Change-Id: I8ba25cc2ef8ceeadc63d3aa123ed7716f8d1e209
Crs-Fixed: 350349, 360150

ligstagefright: New flag GRALLOC_USAGE_PRIVATE_CP_BUFFER used for securing buffers

GRALLOC_USAGE_PROTECTED is being used by Surface flinger for protecting screen
shot. For WV L3 secure buffers are not being used, so we need a different flag
to set use or not use secure buffers.

Change-Id: I17224a978a13a344786f81df555efbe68f71918a
CRs-fixed: 348454

Conflicts:

	include/media/stagefright/OMXCodec.h
	media/libstagefright/OMXCodec.cpp

libstagefright : Fix to support additional file types in MPEG4Extractor

-Add Support for AVC1, MSNV, mmp4, FACE, wmf and ftyp's k3g1, skm3, mp41
 file types in SniffMPEG4 function.
-Function returns true if the header contains one of these
 filetypes.

Change-Id: I569c9ab783b013401f095edf3959748b1e47d370
CRs-Fixed: 253907, 257978, 263296

libstagefright: Do not populate sync sample index if none present

- While an A/V clip in playback, seek fails to desired location
  and starts playback from zero position.
- The stss atom has zero entry count and sync sample index for Audio
  track. Due to this seek fails and starts playback from zero position.
- Do not return sync sample index as zero when no sample is present. Just
  return the original value back.

Change-Id: I1bd222006a9b61d58c3157773c540c7ab5327016
CRs-Fixed: 271385

libstagefright: Enable timestamp reordering for mpeg4 and vc1 clips

Enables timestamp reordering when decoding:
- All VC1 bitstreams
- Mpeg4 bitstreams contained in AVI file format

Timestamp reordering is enabled only for qcom codecs.

Change-Id: I8da7e7a6c0ccced1965cc5c2204879288b57cbe0
CRs-Fixed: 339035

libstagefright: Fix for CTS MediaRecorder test cases

The static keyword in a declaration of a local variable in an
mpeg4 writer function is causing the variable to be initialized
only the first time the function is called.

Because of this, the variable is not being re-initialized properly
when the function is called again on subsequent record attempts,
leading to a recording error.

This change removes the static keyword from the variable
declaration.

Change-Id: Ifb1348eb38377c844e2e024bface8c735271045c
CRs-Fixed: 346553

libstagefright : Fix to prevent CHECK failures for YAMATO format

-Fix to prevent CHECK failures for YAMATO format.
-Removes unused code related to YAMATO format.

Change-Id: Iadf972b1234dd3ea0caebc9678ec32d875db18a6

Conflicts:

	media/libstagefright/OMXCodec.cpp