Squash all 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

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>

AudioFlinger: Add resampler using Speex library

In addition to earlier quality settings there is a new setting, which
uses libspeexresampler from external/speex directory. The output
quality with SPEEX_QUALITY is better than with HIGH_QUALITY
setting due to a proper anti-aliasing filter.
Cherry-pick from ICS.

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

AudioFlinger: Use AudioResampler::SPEEX_QUALITY by default

The bad audio resampling in AudioFlinger ruins the audio quality of
all media that does not have 44.1kHz sample-rate. Most video files
have 48kHz sample-rate audio track and this change improves playback
audio quality of those files.

Downside of this change is increased MPU usage when playing audio with
something else than 44.1kHz sample-rate. On OMAP 4430 the over all
load increase in comparison to linear interpolation resampler is
around 1-1.5 MHz of a single ARM A9 core, when playing 48 kHz
sample-rate stereo wav file.

Cherry-pick from ICS.

Change-Id: I7a54c281279e74b8f9e8615056c4a193d6e0f203
Signed-off-by: Jyri Sarha <jsarha@ti.com>
Signed-off-by: Daniel Levin <dendy@ti.com>

AudioFlinger: Move sample-rate conversion check to resampler class

This patch moves the resampling ratio checks to AudioResampler
class. With this patch it is possible to exploit Speex resampler's
flexibility of selecting any resampling ratio.
Porting from ICS to JB.

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

AudioFlinger: AudioResamplerSpeex: Do not overwrite output buffer

I had a fundamental misunderstanding about AudioResampler-class's role
in AudioFlinger's mixer implementation. The output buffer provided to
the resample-method is a shared final output buffer and should not be
overwritten. Instead the resampled audio should be mixed on top of the
output buffer.
Cherry-pick from ICS.

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

AudioFlinger: Prevent invalid free()'s in Speex resampler

AudioResamplerSpeex would sometimes call
provider->releaseBuffer(&mBuffer) if mBuffer.raw was not NULL.
However, this is an error because mBuffer.raw is never initialized.
If mBuffer.frameCount is zero, then mBuffer.raw is undefined and we
should NOT call releaseBuffer() on it.

Checking status of frameCount to resolve issue.

Change-Id: I5121f1358119336cb139d9692c4a1a135653cb00
Signed-off-by: Daniel Levin <dendy@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>

AACExtractor: Added support for APE tag

To support aac audio with APE tag we need parse
this tag. Otherwise AACExtractor stops reading of
audio file.

DR: OMAPS00267689

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

LiveSession: checking meta for playlist in live session.

This is necessary to check if mMeta is already exists in mPlaylist
before try to get any data from it in timeToRefreshPlaylist method.

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

Media: Stagefright: Interlaced video playback support

OMXCodec has been modified to handle an event from
Codec with new Index to detect the interlaced stream.
StagefrightMetadataRetriever is modified to configure
Video frame params appropriately for thumbnail generation.
A new color conversion routine has been added for handling
interlaced buffers.

Note# The Changes are done as per OMX1.2 spec, except the below:
According to omx, the interlaced buffer layout needs to be
communicated to IL as part of buffer payload (at the end of
video data).
Since this is a too much of overhead, the implementation is
done based on event handling mechanism between codec and IL client.

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

Initialize scaling values by reading from OMX Component.

Scaling values are lost if OMX_IndexConfigCommonOutputCrop/other event
is received after OMX_IndexConfigCommonScale.

So mOutputFormat is needs to be initialized in initOutputFormat()
by reading values from OMX component.

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

Recorder: Add APIs to set advanced encoder parameters

setParamInsertVideoIFramea()
setParamMaxNalSize()
setConfigVideoBitRate()
setConfigVideoFrameRate()

Ported from ICS

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

Stagefright: Use update TI OMX Headers

Since domx in omap4xxx tree is updated, use the definitions
in there instead of defining them in stagefright.

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

StageFright: Update frame rate information to codec

We need to update framerate information to codec by
parsing the mp4 file header so that codec can take
a better decision on operating to use on accelerator
size.

Change-Id: I485394ca7e1d85f402cd77aa1d059c8bfeb8db1f
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>

[VidDec] Change the i/p buffer size if video clip contains bigger samples than WxH

Currently, the i/p buffer size ('nBufferSize') is always set to WxH by Ducati,
and cannot changed from Stagefright since it is a read-only paramter.
So, if video clip contains bigger samples than WxH, the video playback is failed.
This patch checks if the maximum sample size of the video clip is bigger than WxH (i.e.'nBufferSize'),
and allocate the i/p buffer with the maximum sample size if necessary.

Ref: OMAPS00259559

Change-Id: I69b4e7b17107a7a681a8083335317a182eb02e65
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>

Remove memcpy from mp4 parser to OMX input buffer

For AV playback, mem copy from MP4 parser to OMX is a costly operation.
This patch avoids the intermediate copy from MPEG4Source to OMX I/P
by supplying a buffer from the buffer pool in OMXCodec.

Patchset3:
 - fixed typo in macro
 - profile: mediaserver load reduced from 7% to 6% @700MHz for AV857

Signed-off-by: Yong Zhi <y-zhi@ti.com>
Signed-off-by: Devaraj Rangasamy <dev@ti.com>

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

OMXCodec: conditionalize memcpy optimization for DRM content

DRM content uses their own proprietary implementations, the
memcpy optimization patch will break these apps.

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

AVI extractor: Save fps information

Calculating fps (dwRate/dwScale) in .avi container and
saving it as kKeyVideoFPS for future reference.
This information was missing, hence VC1 60fps clips were
playing at 30fps, hence resulting in issues for 60fps.
Fix the same.

Change-Id: I3ab8135c77d83c14a5fbddf28e8e489aba2b343a
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>

Fix to play mp4 files with broken tracks

Sample table may miss some required subfields, such as 'stsc', 'stsz', 'stts', etc.
In such cases the error ERROR_MALFORMED was returned and the playback failed.
But if at least one track in file is correct, such incorrect tracks may be skipped
and the playback should run normally without them.

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

MKVExtractor: workaround, adjusting the negative time stamps

Some encoders may set negative shifting for the blocks with audio data,
we can just ignore this and set time stamp to 0 for such frames.

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

Change include path to OpenMAX headers

In case of build with OMAP_ENHANCEMENT we should use
OpenMAX from DOMX repository.

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

StageFright: Add TI-specific OMX headers

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

CameraService: Added CAMERA_CMD_PREVIEW_INITIALIZATION

To achieve the lowest latency during VTC, tunneling has
been implemented between the encoder and the camera. When 2
components are tunneled, as per OMX spec, those components
must transition to different states in lock step. These 2
additional commands give the application greater control
over the state transitions within the Camera HAL component.

When application sends the command
CAMERA_CMD_PREVIEW_INITIALIZATION, the Camera HAL component
moves from loaded to idle state and when the application
calls startPreview(), the component moves from idle to
executing state.

Similarly, when application sends the command
CAMERA_CMD_PREVIEW_DEINITIALIZATION, the Camera HAL
component moves from executing to idle state and when the
application calls stopPreview(), the component moves from
idle to loaded state.

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

CameraService: Setup extended callbacks

Pass camera_device_extended_ops_t instance to HAL to initialize
extended callbacks if any.

Change-Id: Ie1c700d2aed05bbd4c2a8ba4dc6118a83397f4d3
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>

Camera: Initial implmentation of BufferSource API

In this initial implementation of setBufferSource(), BufferSource is
nothing but an instance of the SurfaceTexture class and passed as a
preview_stream_ops to camera HAL module.

BufferSource will be the allocator interface for tap-in and tap-out
points to allow for zero-copy buffer passing between processes using
camera.

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

Camera: Add camera_metadata_t structure

- POD structure containing metadata for a given frame
- The ICS equivalent of this patch implements metadata as
  a String8 based object that will be passed around. Scrapping
  that approach due to latency and overhead of passing large data
  with a string.
- Used to pass metadata information to applications via BufferQueue

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

Camera: Add flush config and EV compensation

Added support to set EV compensation array and flush shot config
in ShotParameters.

Application can set EV compensation vector as:
-200,-100,0,+100,0,-100,-200

If Application has set flush shot config option, the internal shot
config queue could be cleared before to set the new values.

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

StageFright: Add a 'TimeInterpolator' class

The TimeInterpolator is a mechanism to transform the discreet flow of
media via buffer transfers into a monotonic clock that can be used for
precise scheduling and latency compensation.  While intended to be
used as an "Audio Clock," it can be used in any situation where
discreet data flow can be quantified in terms of time.

Suppose that a thread is reading audio data from a buffer in chunks of
N bytes (which corresponds to T seconds of music).  It is known that
the thread is directly feeding the hardware and that (on average) the
data flow rate is a constant (e.g. because there is a known sample
rate).  However, the time span between reads is random.  If the
time-stamp of the most recent read is used as a "clock," then the
clock will be jumpy and irregular.

The TimeInterpolator can take this jumpy data and convert it to a
smooth and nearly straight line.

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

CameraService: Pass preview_stream_extended_ops_t to HAL

If HAL supports set_extended_preview_ops callback use it to pass
extended preview stream callbacks.

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

Camera: Add get current buffer to preview_stream_extended_ops_t

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

Camera: Add interface for reprocess

Add reprocessing interface for user to inject a frame to HAL via a
tap-in point.

Call sequence:
- setBufferSource()
- setParameters()
- reprocess()

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

Camera: Add reprocess msg type to reprocess()

CAMERA_MSG_COMPRESSED_BURST_IMAGE needs to included for
reprocess() similar to how it is already included for
takePicture()

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

CameraService: Add metadata passing through SurfaceTexture

This patch adds camera hardware interface for HAL
to pass BufferQueue metadata

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

CameraService: Ensure other picture types are disabled

Ensure picture types not specified by the application are disabled.
If application is switching msg types for different captures, HAL
needs to be informed.

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

Camera: Support exp/gain preview metadata

Add support for sending exposure_time and analoag_gain metadata
through binder in ICameraClient.

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

Camera: Add face detection metadata

Extended camera_metadata_t to handle face detection metadata.

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

MPEG4Extractor: enable decoding order if no ctts atom found.

Enabling decoding order if no ctts atom found in container.

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

MPEG4Extractor: Handle the haveDeltaTable() function via sub-classing

Change I8924293f14eccf28ad399a156f2f819320aa2541 added a virtual
function to MediaSource which breaks binary compatibility with 3rd
party binaries. For example, this broke WMV playback because the
vtables didn't match.

This is corrected creating a subclass of MediaSource called
MediaSourceHaveDeltaTable and deriving MPEG4Source from the new
subclass. In AwesomePlayer, if the container is MPEG4 then we
statically cast to MediaSourceHaveDeltaTable to use the new function.

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

[AwesomePlayer] Fix for S3D video playback.

S3d mode is not turned on when videos are not played
from the start. That is because the s3d frame layout
information is in the beginning of the video stream.
That is easily visible when you start a s3d movie in
the Gallery, pause it, go to home screen and then
reopen the Gallery again. The paused movie is not in
s3d mode any longer.

A workaround for this situation is to do an extra read
when the first read is from offset different from the
start of the stream. This makes the decoder return
the extra data containing s3d layout information.

Fixes bug OMAPS00270286

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

[Stagefright] Do not terminate the playback due to the malformed data.

Added corret handling for malfromed mepg2ts stream.
Even if the malformed data was detected while parsing PES in MPEG-TS,
this patch just skips it and continues the playback.

This patch implemented by Nanako Baba for ICS. Its original change-id
is I60508498cc3d19fd8c4d220970e4679128b596fa.

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

StageFright: Detect read-pointer mismatch between media TimeInterpolator

When the media content and the TimeInterpolator disagree about where
the read pointer of the audio is then it causes A/V to be out of
sync. This is most likely to happen with a rare media file where the
beginning of the clip is not '0'.

AwesomePlayer now checks for this condition, and if it happens it
will forcibly update the TimeInterpolator's read pointer.

Change-Id: I4c6046c6aa66a521ff59066eed2551176dac2d01
Signed-off-by: Gabriel M. Beddingfield <gabrbedd@ti.com>
Signed-off-by: Barry Woodward <a0270655@ti.com>
Signed-off-by: Dmytro Dubovyk <dmytro.dubovyk@ti.com>

Libstagefright: Add reading of extended frame rates

Inorder to support 60fps and beyond, camera source
has to read the extended supported frame rates from
camerahal to validate against the app passed fps

Ported from ICS
Patch set#2: Re base

Change-Id: Ib7d14bcf941ab1a3ac861b29ae7befdcca7198d1
Signed-off-by: Sathya Prakash M R <a0393677@ti.com>
Signed-off-by: Andriy Chepurnyy <x0155536@ti.com>
Signed-off-by: Sundar Raman <sunds@ti.com>
Signed-off-by: Dmytro Dubovyk <dmytro.dubovyk@ti.com>

Camera: Add keys for tap-out and tap-in surfaces

- Add shot parameter keys so user can specify which
  tap-out and tap-in surfaces to be used by camera hardware
  for a particular shot config.

Change-Id: I7c8c17cfb16289874fb3772e14e4a6a9d8466197
Signed-off-by: Vladimir Petrov <vppetrov@mm-sol.com>
Signed-off-by: Tyler Luu <tluu@ti.com>

CameraService: Allow for multiple tap in/outs

- Add support for setting multiple tap in and tap out points.
  Moving all tap-in and tap-out point management to
  CameraHardwareInterface.h to remove duplicate code.

- Currently maximum tap in slots and maximum tap out slots
  are limited to 10.

- Patch for releasing the tap in and tap out points to follow.

Change-Id: Ia21c4a261cf54b4e83cdd570642a362df740efb0
Signed-off-by: Vladimir Petrov <vppetrov@mm-sol.com>
Signed-off-by: Tyler Luu <tluu@ti.com>

CameraService: Implement get_id preview stream OPS

- Implement get_id for preview stream OPS which returns the
  ANW ID.

Depends on hardware/libhardware change I859c6e87:
http://review.omapzoom.org/#/c/28141/

Change-Id: Id4acd7baf72735ce25c20f8a19fe1280bc0ffcda
Signed-off-by: Vladimir Petrov <vppetrov@mm-sol.com>
Signed-off-by: Tyler Luu <tluu@ti.com>

Camera: Add support to release tap in/outs

- Providing a way to camera client to tell camera hardware
  that tap in/outs previously set are not longer valid.

Depends on hardware/libhardware change I8f6c377a:
http://review.omapzoom.org/#/c/28984/

Change-Id: I68f613039702d0b5755ff66a38cf955410e66339
Signed-off-by: Vladimir Petrov <vppetrov@mm-sol.com>

Support for playback of WMV9,VC1 inside AVI file

This reverts commit f04390db9827827472477d0946136d5d3b8a75db.

Change-Id: I4e8df7032a082c59a66ed032f06790f1cadb2d65

CameraService: Window OP to get buffer count

Implement window op to get buffer count. this call allows hals
query the current buffer count that the window is set to.

Depends on hardware/libhardware change I01831e05:
http://review.omapzoom.org/#/c/28152/

Depends on system/core change Ia0ee3186:
http://review.omapzoom.org/#/c/28377/

Change-Id: I0dad41274c14b5f4f7e24e6f836128e008dd471e
Signed-off-by: Tyler Luu <tluu@ti.com>
Signed-off-by: Vladimir Petrov <vppetrov@mm-sol.com>

CameraHardwareInterface: Extends tap-in API

- Additional API for querying current crop
  and buffer size.

Depends on hardware/libhardware change Ie37ab311:
http://review.omapzoom.org/#/c/29676/

Depends on system/core change Ib0561bbe:
http://review.omapzoom.org/#/c/29667/

Change-Id: I788dd7384928a3fbd545208069346b3d16cd7205
Signed-off-by: Emilian Peev <epeev@mm-sol.com>
Signed-off-by: Vladimir Petrov <vppetrov@mm-sol.com>

CameraService: Add support for releasing acquired buffers

- Additionally also return the acquired buffer slot when
  doing 'update_and_get_current()'.

Depends on:
system/core change I8e4c1162:
http://review.omapzoom.org/#/c/30195/

frameworks/native Ic356b4b2:
http://review.omapzoom.org/#/c/30196/

hardware/libhardware I19514596:
http://review.omapzoom.org/#/c/30197/

Change-Id: I050800fa20b0dc87b7580cc02cd39df02bacc8a0
Signed-off-by: Emilian Peev <epeev@mm-sol.com>

Fixed incorrect behavior of AVI parser

Current patch includes following fixes:
- Fixed incorrect parsing of rate/scale values;
These values incorrectly read from AVI stream header.
- Fixed incorrect behavior of parser in cases with MPEG4;
AVI parser tries to read MPEG4 codec specific data.
If these data is not present in container,
parser continued parsing of invalid data
and this comes to error (AVI file malformed).
Correction prevents reporting about malformed AVI file
and continues correctly read stream data.
- This enhancement allows to start playback of
partially damaged AVI file.
For example, file was not fully downloaded
and some indexes were lost.
Logic will build index table from existing values.

Change-Id: I1ba1c9591f47565737e2970a67da1d7704307f46
Signed-off-by: Oleksii Gulchenko <oleksii.gulchenko@ti.com>

Skipping unsupported mpeg audio tracks

This is workaround to skip all unsupported mpeg audio tracks or mpeg
audio tracks with incorrect encoding and allow to play supported video
track alone without aborting the playback.

Change-Id: If8cfee8930a2b98c992076036d0bc392008c5c6a
Signed-off-by: Vitalii Kostiuk <Vitalii.Kostiuk@ti.com>
Revert "Squash all commits from omapzoom"

This reverts commit 123d011f0f789345725a89e5f2a5b57a9a9555c7.
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
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>
Remove memcpy from mp4 parser to OMX input buffer

For AV playback, mem copy from MP4 parser to OMX is a costly operation.
This patch avoids the intermediate copy from MPEG4Source to OMX I/P
by supplying a buffer from the buffer pool in OMXCodec.

Patchset3:
 - fixed typo in macro
 - profile: mediaserver load reduced from 7% to 6% @700MHz for AV857

Signed-off-by: Yong Zhi <y-zhi@ti.com>
Signed-off-by: Devaraj Rangasamy <dev@ti.com>

Change-Id: I6a16d4671bf84736992d1e5669331ee2416f2ce2
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>
StageFright: Add TI-specific OMX headers

Change-Id: Ia6dfcce0dfba5240a8f8b576b0a6977187a83167
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>
StageFright: Add a 'TimeInterpolator' class

The TimeInterpolator is a mechanism to transform the discreet flow of
media via buffer transfers into a monotonic clock that can be used for
precise scheduling and latency compensation.  While intended to be
used as an "Audio Clock," it can be used in any situation where
discreet data flow can be quantified in terms of time.

Suppose that a thread is reading audio data from a buffer in chunks of
N bytes (which corresponds to T seconds of music).  It is known that
the thread is directly feeding the hardware and that (on average) the
data flow rate is a constant (e.g. because there is a known sample
rate).  However, the time span between reads is random.  If the
time-stamp of the most recent read is used as a "clock," then the
clock will be jumpy and irregular.

The TimeInterpolator can take this jumpy data and convert it to a
smooth and nearly straight line.

Change-Id: Ic86d3534ab7202ae4a5a2fb98607942c550f4ffa
Signed-off-by: Daniel Levin <dendy@ti.com>
Support for playback of WMV9,VC1 inside AVI file

This reverts commit f04390db9827827472477d0946136d5d3b8a75db.

Change-Id: I4e8df7032a082c59a66ed032f06790f1cadb2d65