Squash commits from omapzoom

Fix a typo that caused the high quality resampler to produce garbage

the problem is that if libaudio_resampler is present, it is those
coefficients that will always be selected, but the correct
meta-data.

Bug: 7385994
Change-Id: Ieebeb37b4dfb62a1a051bc29fae2ce056dbc6621

Squash commits from omapzoom

Media: Add codec quirks and extractor type

Rework partially reverted commit from JB MR0:
- 51b764e8fe060ecdec20cd8b4ed4fc0cc5d4f044
- 7b33c4564103afa81d70b175fb552e0f511a00cd

Change-Id: I6660461c244460a5764e23ae461b7210f058fdac
Signed-off-by: Daniel Levin <dendy@ti.com>

Stagefright: Add AVI support

Enable AVI support.

Change-Id: I35f2175b47942c51327409d22384f13470c21945
Signed-off-by: Daniel Levin <dendy@ti.com>

Stagefright: Add H263 support for AVI container

Add H263 support to avi files.

Change-Id: I1495cd90d19c4547c3003e6a68e5ddd934f6950b
Signed-off-by: Daniel Levin <dendy@ti.com>
Signed-off-by: Sergii Doroshenko <x0163979@ti.com>
Signed-off-by: Anviksha Khare <anviksha@ti.com>

SF: Added correct handling for malformed mpeg2ts stream

Modified CHECK_EQ/CHECK_GE comparison (that contain exit 1;) to return ERROR_MALFORMED status.
Corrected size for skipping bits for BitReader in parseAdaptationField
Added check for correct processing ERROR_MALFORMED status in MPEG2TSExtractor.
Increased counter for parsed packets (using 10000 we can't get succes for VideoStream detection)
Because there are a lot of broken data in a beginning of stream.

Change-Id: Icd74774003da420e5305896b8398aee97296157a
Signed-off-by: Daniel Levin <dendy@ti.com>

Adding MPEG2 Decoder support to Stagefright and media

Add MPEG2 to MediaProfile Decoder capabilities and mpeg2
codec details to MPEG4Extractor

Patch Set 2: rebase

Change-Id: Ifd2810aed37cf04f19c80959f7c90e8ce13641e7
Signed-off-by: Daniel Levin <dendy@ti.com>

MatroskaExtractor: Workaround for playback for mkv files with lacing.

Most mkv files having 'lacing' in their audio section to save space.
Android did not handle this properly, sending all frames in the block
with the same time code, which causes stuttery playback.

Ported from CyanogenMod. Change-Id: I4dc76e7c2a53126c7fbdd3628fe7d339d2e3364e
Original author: Pawit Pornkitprasan <p.pawit@gmail.com>

Change-Id: I090b412d94c07e92c00059a5110574dd08cffb96
Signed-off-by: Daniel Levin <dendy@ti.com>

StageFright: Skip zero size chunks in mp4 parser

Some mp4 clips were not playing with error ERROR_MALFORMED
returned from stagefright mp4 parser. These clips had zero
size chunks which the parser was not skipping. The patch
achieves this.

Change-Id: I5db18ae52dc96c8f7c90a5855724c1327ac2685a
Signed-off-by: Daniel Levin <dendy@ti.com>

TimeLapse recording with High Profile Encoder

When Timelapse recording is performed, Encoder is expected
to process each input buffer and provide a output buffer.
This wont work when we have B Frames enabled.
This patch disables B Frames when Encoder flag
kOnlySubmitOneInputBufferAtOneTime is set to allow
submission of 1 frame at a time.

Ported from ICS

Change-Id: I7dd17f8ce9185abe3c6749caa34c90500bd2f913
Signed-off-by: Daniel Levin <dendy@ti.com>

Workaround for Mpeg2TS grey thumbnail issue

Seek is not supported in Mpeg2TSExtractor. Thus during thumbnail
generation if the software decoder is failing the extractor is not
seeking to the I-frame and is providing the next available frame to
hardware decoder. Thus there is issue in thumbnail generation.
To resolve this, we directly use hardware decoder for all the
Mpeg2Ts Clips.
Now for Mpeg2TS, Mpeg2PS clips by default hardware codec is used
for thumbnail generation.

Change-Id: I526bd9079740a8fb7457fc92b6dce9f82206170d
Signed-off-by: Daniel Levin <dendy@ti.com>

Fix Race condition in Stagefright in thumbnail generation

Issue:
Video editor is not able to add CABAC encoded H264 files to project first time.

Observations:
When we add the cabac file to Video editor media server crashes. The crash is
seen in Stagefright library since software avc decoder is not able to decode
the clip.
2 signature of crashes are seen
   1. Buffer book-keeping is crashing in Idle to Loaded state.
   2. Random segmentation fault is happening while freeing the node.

Fix Description:
We have OMXCodec.cpp file containing on_message and stop, two functions which are involved in this race condition.
The variable which is having the race condition in mState.

Steps:
1. We receive error event since decoder is not able to decode the frames.
2. The mState is no in ERROR state
3. Stop function is invoked since the AsyncCompletion semaphore is triggered
4. FTBD and ETB calls are received in on_message while we have mState in ERROR
So we are ignoring the callback and doing nothing due to a condition check at
 the start of on_message function
5. Also we see every FTBD is followed by a ERROR event from codec
6. Now stop function will go ahead in parallel and change the mState to Executing_To_Idle
7. But as explained in step 3 & 4 this state is made ERROR again before the stop function reaches
a critical wait loop for checking transition to happen to LOADED conditon.
8. So we never wait for transition to happen to loaded state since we dont wait on AsynCompletion semaphore
So the component is still transitioning to idle state and we try to free the node. This is crash signature 2
as mentioned above.
9. If we have reached by chance the idle transition in onstatechange function then the buffer count will mismatch.
 the reason for that is explained in step 3. We dont change the ownership of the buffers and ignore them.

Observations with Fix:
1. Thumbnail generation is faster when we have lots of file pushed and one of them has CABAC in it.
2. We can add CABAC H264 file to video editor the first time itself.

Change-Id: I8b2e906261c5fa0c0a08622f9e9c038462f9cd0f
Signed-off-by: Daniel Levin <dendy@ti.com>

Initialize mDisplayWidth and mDisplayHeight.

Initialize mDisplayWidth and mDisplayHeight with kKeyWidth and kKeyHeight
values in case parser did not set kKeyDisplayWidth and kKeyDisplayHeight.
this will be use full for interlaced clips otherwise height calculated in
notifyVideoSize_l() will be based on cropped values.

Change-Id: I3b5ff3dbf5dd5286dc3c29b6231ebedce7ec1e42
Signed-off-by: Daniel Levin <dendy@ti.com>

Camera: Implementation for takePictureWithParameters()

1. Implemement initial ShotParameters class which inherits
   CameraParameters, extending it with extra keys.
2. Add takePictureWithParameters() to take in ShotParameters.
3. The ShotParameters is built as separate static library
   libcpcamcamera_client to avoid breaking ABI with regular
   Camera clients.

Change-Id: I80a359eda2bbd060c6ddd9958e2c3ef86f7e79b6
Signed-off-by: Daniel Levin <dendy@ti.com>