OSDN Git Service

android-x86/external-stagefright-plugins.git
5 years agoEnable compilation on oreo-x86. android-x86-8.1-r1 android-x86-8.1-r2 android-x86-8.1-r3 android-x86-8.1-r4 android-x86-8.1-r5
Michael Goffioul [Mon, 16 Apr 2018 13:13:57 +0000 (09:13 -0400)]
Enable compilation on oreo-x86.

These changes are based on a simple port of frameworks/av port to
oreo-x86 containing only necessary changes. Notable differences from
nougat-x86:
- no support for non-PCM16 output

5 years agoomx: fix another memory leak android-x86-7.1-r2 android-x86-7.1-r3 android-x86-7.1-r4
Michael Goffioul [Sun, 29 Apr 2018 04:14:24 +0000 (12:14 +0800)]
omx: fix another memory leak

The 'strdup' call in createSoftOMXComponent() is never freed.

5 years agoomx: hwaccel: fix memory leak
Michael Goffioul [Fri, 27 Apr 2018 02:16:45 +0000 (10:16 +0800)]
omx: hwaccel: fix memory leak

It's missing some cleanup when uninitializing the decoder.

6 years agoRevert "Revert "Disable OMX.ffmpeg.vp9.decoder temporarily"" android-x86-7.1-r1
Chih-Wei Huang [Thu, 2 Nov 2017 08:44:10 +0000 (16:44 +0800)]
Revert "Revert "Disable OMX.ffmpeg.vp9.decoder temporarily""

Youtube in Chrome is still broken.

This reverts commit 37e65a1edbaea8e191f1d6cebdd58b776e9095b5.

6 years agoRevert "Disable adaptive-playback of vp9 decoder"
Chih-Wei Huang [Thu, 2 Nov 2017 08:43:59 +0000 (16:43 +0800)]
Revert "Disable adaptive-playback of vp9 decoder"

This reverts commit 3b7a4b8f090965c38283e6d882ceb5620ec275d7.

6 years agoSoftFFmpegVideo: fix adpative video scaling problem
Michael Goffioul [Sun, 3 Sep 2017 00:24:00 +0000 (08:24 +0800)]
SoftFFmpegVideo: fix adpative video scaling problem

The way I understand it is that the codec is not supposed to scale the
video frames to the buffer size. In case of adpative playback, the frames
may be smaller than the buffer, which corresponds to the max possible
frame size in the adaptive stream.

The patch also drops fiddling with the cropping attributes. I'm not sure
what was the purpose, but I couldn't find equivalent in other sw codecs
like avcdec or mpeg2dec, so I just dropped that and mimiced what the
other sw codecs are doing.

6 years agoDisable adaptive-playback of vp9 decoder
Chih-Wei Huang [Fri, 25 Aug 2017 04:16:27 +0000 (12:16 +0800)]
Disable adaptive-playback of vp9 decoder

To fix video messed up of Youtube in Chrome as suggested by Lambdadroid.

6 years agoRevert "Disable OMX.ffmpeg.vp9.decoder temporarily"
Chih-Wei Huang [Wed, 23 Aug 2017 16:19:46 +0000 (00:19 +0800)]
Revert "Disable OMX.ffmpeg.vp9.decoder temporarily"

Lambdadroid has fixed the green video issue so we can enable
the vp9 decoder now.

This reverts commit 70d2e61b95894d0608a5777b307bda6d49a2914f.

6 years agoFix green video when scaling video
lambdadroid [Tue, 4 Jul 2017 09:29:50 +0000 (11:29 +0200)]
Fix green video when scaling video

Not sure if this was changed in the newer FFMPEG version, but
sws_scale now takes the srcSliceY and srcSliceH. Currently, the
final height was given in instead of the source height, resulting
in an error.

6 years agoMerge remote-tracking branch 'los/cm-14.1' into nougat-x86
Chih-Wei Huang [Wed, 23 Aug 2017 16:03:28 +0000 (00:03 +0800)]
Merge remote-tracking branch 'los/cm-14.1' into nougat-x86

6 years agoAdd codec profile levels for h264
Chih-Wei Huang [Fri, 14 Jul 2017 07:39:12 +0000 (15:39 +0800)]
Add codec profile levels for h264

Not sure why VLC won't select the ffmpeg h264 decoder
without the codec profile levels.

6 years agoSoftFFmpegVideo: use AVDISCARD_DEFAULT in skip_loop_filter
Michael Goffioul [Fri, 11 Aug 2017 08:17:21 +0000 (16:17 +0800)]
SoftFFmpegVideo: use AVDISCARD_DEFAULT in skip_loop_filter

After a lot of trials and errors, it appears the rendering problem
has nothing to do with color depth. The problem is that the codec
is configured with skip_loop_filter = AVDISCARD_ALL. I'm not sure
what's the reason for that choice. By comparison, it was using
AVDISCARD_DEFAULT in kitkat-x86 branch. If I change the value to
AVDISCARD_DEFAULT instead, I get correct decoding.

Fixes: a5d3c4c2 "stagefright-plugins: Implement frame dropping and AV sync"

6 years agoDisable OMX.ffmpeg.vp9.decoder temporarily
Chih-Wei Huang [Sat, 3 Jun 2017 03:10:23 +0000 (11:10 +0800)]
Disable OMX.ffmpeg.vp9.decoder temporarily

Youtube in Chrome just shows green screen by using this codec.
But playing a local vp9 encoded video file is fine.

Disable it until we find a proper solution.

6 years agoFFmpegExtractor: Fix "supported" typo in logs
Michael Bestas [Mon, 26 Jun 2017 23:42:47 +0000 (02:42 +0300)]
FFmpegExtractor: Fix "supported" typo in logs

Change-Id: I016879f91371b149e9cdeaaba1d39282e146b3e4

6 years agoffmpeg-extractor: StageFright supports Opus files
Christopher R. Palmer [Fri, 2 Jun 2017 18:14:50 +0000 (14:14 -0400)]
ffmpeg-extractor: StageFright supports Opus files

Update the codecs supported by StageFright to include Opus (added
in Android 5.0 but not recognized here).

Change-Id: If4d011a8b3cf1df46126213f3d72887055b9a2a5

6 years agoRevert "FFmpegExtractor: Don't use our extractor when we agree with StageFright"
Christopher R. Palmer [Mon, 5 Jun 2017 10:24:43 +0000 (06:24 -0400)]
Revert "FFmpegExtractor: Don't use our extractor when we agree with StageFright"

This reverts commit 40898770dd66b011b0a7653e1cd5750f176be038.

Change-Id: Ic57879f0dc22f1495e4c42d008529396929abd3d

6 years agoFFmpegExtractor: Don't use our extractor when we agree with StageFright
Christopher R. Palmer [Sat, 27 May 2017 18:44:42 +0000 (14:44 -0400)]
FFmpegExtractor: Don't use our extractor when we agree with StageFright

Prior to this commit, if StageFright picks mimeType X with any
confidence <= .8 then it uses the StageFright extractors and otherwise
(if ffmpeg recognizes the file format) then it will use the ffmpeg
extractors.

This commit changes the logic to prefer the StageFright extractors
(keeping the behaviour closer to aosp and less dependent on ffmpeg's
implementation) whenever both agree on the same mime type.

Change-Id: I98b1b3c3e94756923106911783104ca42e916aed

6 years agoomx: hwaccel: decode in one thread
Chih-Wei Huang [Tue, 9 May 2017 05:49:43 +0000 (13:49 +0800)]
omx: hwaccel: decode in one thread

As FFmpeg asserts, hardware accelerated decoding with frame threading
is known to be unstable.

To make hardware codecs stable, just decode in one thread.

6 years agoAdd hardware accelerated codecs
Chih-Wei Huang [Tue, 9 May 2017 05:49:24 +0000 (13:49 +0800)]
Add hardware accelerated codecs

Inspired by the nice work from Michael Goffioul and Jaap Jan Meijer.

The patch adds hardware accelerated codecs via ffmpeg vaapi support.
It is still experimental and unstable so it's disabled by default.
To enable it, set the property media.sf.hwaccel=1.

6 years agoutils: simplify code
Chih-Wei Huang [Thu, 4 May 2017 02:13:10 +0000 (10:13 +0800)]
utils: simplify code

Use property_get_bool() instead of property_get().

6 years agoQuiet unnecessary warnings
Chih-Wei Huang [Thu, 4 May 2017 02:07:45 +0000 (10:07 +0800)]
Quiet unnecessary warnings

To avoid warnings, both values in CHECK_xx() must be the same type.

6 years agoomx: video: quiet log a little
Chih-Wei Huang [Wed, 3 May 2017 09:33:33 +0000 (17:33 +0800)]
omx: video: quiet log a little

Distinguish no frame and EOS cases.

No frame is normal. Make it less verbose.

6 years agoCleanup: remove C++ checking
Chih-Wei Huang [Fri, 28 Apr 2017 04:45:33 +0000 (12:45 +0800)]
Cleanup: remove C++ checking

These are C++ files. The checking is unnecessary.

6 years agocodecs: enable vp8 and vp9
Chih-Wei Huang [Thu, 27 Apr 2017 11:07:47 +0000 (19:07 +0800)]
codecs: enable vp8 and vp9

6 years agoMerge branch 'lollipop-x86' into multiwindow-hwaccel
Chih-Wei Huang [Fri, 28 Apr 2017 04:41:46 +0000 (12:41 +0800)]
Merge branch 'lollipop-x86' into multiwindow-hwaccel

6 years agoMerge branch 'jide_x86_lollipop' into lollipop-x86
Chih-Wei Huang [Tue, 25 Apr 2017 09:13:23 +0000 (17:13 +0800)]
Merge branch 'jide_x86_lollipop' into lollipop-x86

6 years agoRevert "codecs: Disable AC3/EAC3"
Jesse Chan [Sat, 22 Apr 2017 14:49:04 +0000 (22:49 +0800)]
Revert "codecs: Disable AC3/EAC3"

This reverts commit 40998aa023a37f1dc7d20c8963c294af4f09353b.

 * Patents of AC3 expired in March, 2017.

Change-Id: I16300796dbd43200ddfe5e465126aecfbab0127f

6 years agoextractor: avoid to initialize ffmpeg multiple times
Chih-Wei Huang [Fri, 21 Apr 2017 03:44:31 +0000 (11:44 +0800)]
extractor: avoid to initialize ffmpeg multiple times

I really don't see why we need to init and de-init ffmpeg each time
on sniffing. Just do it once.

6 years agoomx: don't do av_frame_unref
Chih-Wei Huang [Fri, 21 Apr 2017 02:29:51 +0000 (10:29 +0800)]
omx: don't do av_frame_unref

This is done in libav/ffmpeg internally.

6 years agoAllow to build with libav and ffmpeg
Chih-Wei Huang [Thu, 20 Apr 2017 09:35:12 +0000 (17:35 +0800)]
Allow to build with libav and ffmpeg

Change to use common macros of libav and ffmpeg.

Disable libswresample temporarily.

6 years agoClean up makefiles
Chih-Wei Huang [Wed, 19 Apr 2017 03:54:06 +0000 (11:54 +0800)]
Clean up makefiles

Move common rules to common.mk.

6 years agoomx: remove useless code
Chih-Wei Huang [Tue, 18 Apr 2017 08:39:34 +0000 (16:39 +0800)]
omx: remove useless code

The lowres field is not used anymore. Remove all related code.

6 years agoutils: simplify priv_data handling
Chih-Wei Huang [Tue, 18 Apr 2017 08:29:04 +0000 (16:29 +0800)]
utils: simplify priv_data handling

Let FFmpeg allocate and free priv_data.

6 years agoutils: fix build for FFmpeg 3.1
Chih-Wei Huang [Tue, 18 Apr 2017 08:28:06 +0000 (16:28 +0800)]
utils: fix build for FFmpeg 3.1

7 years agoMerge remote-tracking branch 'cm/cm-14.0' into cm-14.0-x86
Jaap Jan Meijer [Thu, 6 Oct 2016 16:41:07 +0000 (18:41 +0200)]
Merge remote-tracking branch 'cm/cm-14.0' into cm-14.0-x86

Conflicts:
data/media_codecs_ffmpeg.xml

7 years agocodecs: make codec list complete again.
Jaap Jan Meijer [Thu, 28 Jul 2016 11:20:40 +0000 (13:20 +0200)]
codecs: make codec list complete again.

This reverts commit 40998aa023a37f1dc7d20c8963c294af4f09353b and
68d9c451a448a44c59e81791e11a62988ff2bf2a.

7 years agostagefright-plugins: Avoid QCOM-specific identifier
Steve Kondik [Tue, 27 Sep 2016 23:47:08 +0000 (16:47 -0700)]
stagefright-plugins: Avoid QCOM-specific identifier

Change-Id: I63568dc6ade25197bfb6940b3f7f7e1aa547ebd1

7 years agostagefright-plugins: Improvements and updates for CM14
Steve Kondik [Tue, 6 Sep 2016 06:06:04 +0000 (23:06 -0700)]
stagefright-plugins: Improvements and updates for CM14

 * Use a simple dlsym mechanism for loading the plugin. This
   eliminates some odd coupling and framework code footprint.
 * Use IMediaSource to follow new API.
 * Switch to supplying a PCM format instead of
   just the bits per sample as we're using the new AOSP
   support for non-PCM16 formats.

Change-Id: Ibf13362b3b1ae89eae2adccf32da0a3d3530aee6

7 years agoclear omx struct when initializing
WuZhen [Tue, 9 Aug 2016 09:16:42 +0000 (17:16 +0800)]
clear omx struct when initializing

NO_REF_TASK
tested: local run

Change-Id: I52473e941c19d22ece05e4cd654559229c803148

7 years agostagefright-plugins: Add a new component for ALAC
Steve Kondik [Fri, 1 Jul 2016 19:30:46 +0000 (12:30 -0700)]
stagefright-plugins: Add a new component for ALAC

 * ALAC (Apple Lossless) files were previously handled by the
   catch-all path. New QCOM DSPs have the ability to offload
   these files, so we need to identify them correctly.

Change-Id: Ie83f965aa7ecdc614f308664fc33b0e6e597f7b2

7 years agoMerge remote-tracking branch 'cm/cm-13.0' into jide_x86_lollipop
WuZhen [Wed, 6 Jul 2016 12:16:00 +0000 (20:16 +0800)]
Merge remote-tracking branch 'cm/cm-13.0' into jide_x86_lollipop

NO_REF_TASK
tested: local run

Change-Id: If6523ccd94baeec109b4cbe477760aef479571f0

7 years agostagefright-plugins: Clean up warnings for invalid format strings
Steve Kondik [Fri, 1 Jul 2016 19:50:01 +0000 (12:50 -0700)]
stagefright-plugins: Clean up warnings for invalid format strings

Change-Id: I68c326af5d4a0b8c793c9334050e9c39debafcdc

7 years agostagefright-plugins: Stop using AVPicture
Steve Kondik [Fri, 1 Jul 2016 19:57:08 +0000 (12:57 -0700)]
stagefright-plugins: Stop using AVPicture

 * It's been deprecated in FFMPEG.

Change-Id: I3ccd9a74c09988c8f09e56e98f5c0bdf1bdead31

7 years agoenable ffmpeg hevc decoder.
WuZhen [Wed, 22 Jun 2016 03:58:07 +0000 (11:58 +0800)]
enable ffmpeg hevc decoder.

google's hevc decoder does not support MAIN10 profile.
use ffmpeg's in this case

NO_REF_TASK
tested: local run

Change-Id: I6028cfa43145ba5e17b377a989bd85da30118533

7 years agostagefright-plugins: call packet_queue_init earier
Keith Mok [Mon, 20 Jun 2016 17:19:56 +0000 (10:19 -0700)]
stagefright-plugins: call packet_queue_init earier

On FFmpegExtractor destructor it always call
packet_queue_destroy. However packet_queue_init
may not be called if there is an error inside
initStreams. Causing packet_queue_destroy trying
to free some random data in mVideoQ and mAudioQ and
leading to crash.

OPO-775

Change-Id: Idded5f886a680f135d6e004977c85135e40d02f1

7 years agohandle audio/vnd.dts with ffmpeg
WuZhen [Fri, 10 Jun 2016 11:26:30 +0000 (19:26 +0800)]
handle audio/vnd.dts with ffmpeg

NO_REF_TASK
tested: local run

Change-Id: I286ad9522489f931082b41551c2fa9acb724e1ff

7 years agostagefright-plugins: flac does not playback
Keith Mok [Fri, 3 Jun 2016 16:20:54 +0000 (09:20 -0700)]
stagefright-plugins: flac does not playback

The previous patch reverse the logic for null
pointer checking. Fixes it.

NIGHTLIES-3061

Change-Id: I337eef9ed29546d00e5b232f7074251566cd3366

7 years agostagefright-plugins: check if input queue is empty
Keith Mok [Tue, 31 May 2016 23:08:48 +0000 (16:08 -0700)]
stagefright-plugins: check if input queue is empty

input queue may be empty when calling decodeAudio.
Add a guard for it.

DOGEDUMP-4184

Change-Id: I261e8d36fb4560fdcc04702b4e09a00c4b10cc47

7 years agostagefright-plugins: Fix crash with invalid FLAC file
Steve Kondik [Tue, 10 May 2016 04:59:44 +0000 (21:59 -0700)]
stagefright-plugins: Fix crash with invalid FLAC file

 * Check size of the extradata before groping it's bits.
 * Also fix a trivial compilation warning on 64-bit.

Change-Id: I60a5a075e4718317901144d991b116039d45d8ec

7 years agostagefright-plugins: Fix crash if nal size is not 3/4
Keith Mok [Mon, 2 May 2016 22:23:19 +0000 (15:23 -0700)]
stagefright-plugins: Fix crash if nal size is not 3/4

IF a media file reported a nal size length not
equals to 3/4. It will asserts.
Change it to report error on that media instead
of asserts.

FEIJ-335

Change-Id: Id46a423102407388eff2b7f3b069cb7c4354df32

7 years agostagefright-plugins: Fix port reset problem
Keith Mok [Fri, 22 Apr 2016 23:21:44 +0000 (16:21 -0700)]
stagefright-plugins: Fix port reset problem

onReset does not clean the ffmpeg status
causing left-over to the next stream decoded.
Fix CTS testCodecResetsMpeg4WithSurface and
testCodecResetsMpeg4WithoutSurface under
package android.media.cts.DecoderTest

FEIJ-88

Change-Id: Ic185852948a946d42feed464b7f690a6b809dc58

7 years agostagefright-plugins: Fix eos flush problem.
Keith Mok [Fri, 22 Apr 2016 21:55:11 +0000 (14:55 -0700)]
stagefright-plugins: Fix eos flush problem.

When input stream eos encounter, the output
buffer are not flushed correctly. a null data
must be passed to the ffmpeg decodebr
(avcodec_decode_video2) when the codec is
with flag CODEC_CAP_DELAY.

This fix cts testEOSBehaviorMpeg4 and testCodecEarlyEOSMpeg4
under package android.media.cts.DecoderTest.

This can be simulate on other devices by disable the h/w
mpeg4 omx component.

FEIJ-88

Change-Id: I84ffd7c2a1e4844afe4c891f0440ed4e3c7effe3

8 years agostagefright-plugin: Allow playback video with negative timestamp
Keith Mok [Mon, 22 Feb 2016 20:18:10 +0000 (12:18 -0800)]
stagefright-plugin: Allow playback video with negative timestamp

Try to skip negative timestamp packets up to
a certain limit before we report video is MALFORMED.
This allows some video starts with a few video packets containing
timestamp before the reported video started time
to be played correctly.

CYNGNOS-2120

Change-Id: Id91aae916eb7e1071534c1948109e1bdbe2af26d

8 years agoRevert "stagefright-plugins: Fix timestamp calculation"
Keith Mok [Tue, 5 Apr 2016 21:44:05 +0000 (14:44 -0700)]
Revert "stagefright-plugins: Fix timestamp calculation"

This reverts commit a54c041a1755b46843b8dab736eccee5d27602d9.

Change-Id: I044330eb11c981eb5be0e865f4e8bc083b40fd78

8 years agostagefright-plugins: Fix timestamp calculation
Steve Kondik [Sat, 2 Apr 2016 02:52:04 +0000 (19:52 -0700)]
stagefright-plugins: Fix timestamp calculation

 * The start time should be added to the calculated PTS or we end up
   with a negative timestamp. Derp?

Change-Id: Id24834ff3e7268dacdcd1d44d6335ece3a62b410

8 years agostagefright-plugins: Convert calls to av_free_packet to av_packet_unref
Ethan Chen [Tue, 15 Mar 2016 00:15:58 +0000 (17:15 -0700)]
stagefright-plugins: Convert calls to av_free_packet to av_packet_unref

* av_free_packet is marked as deprecated in avcodec 57.8.0 2015-10-29
  and should be replaced by av_packet_unref instead.

Change-Id: I2f06c4292e9f417e329768f6ff184bf511b4678e

8 years agoRevert "stagefright-plugins: Protect against crash"
Keith Mok [Mon, 14 Mar 2016 17:53:33 +0000 (10:53 -0700)]
Revert "stagefright-plugins: Protect against crash"

This causes severe memory leak.
In packet_queue_destroy, it called packet_queue_abort
first, then abort_request is set to 1 in that funnction.
Then packet_queue_destroy calls packet_queue_flush to
free the memory, but abort_request is set to 1 and return
immediately.

CYNGNOS-2239

This reverts commit 4924fcb3bee37d7c6a8b447abb4eb0ffdd06173b.

Change-Id: Ibc5795a4518c9c84a408713cd8fa8401b7f58c88

8 years agostagefright-plugins: Fix memory leak
Keith Mok [Mon, 14 Mar 2016 19:12:27 +0000 (12:12 -0700)]
stagefright-plugins: Fix memory leak

Should use av_frame_free to free AVFrame
instead of av_freep

CYNGNOS-2239

Change-Id: If441761f55d92f3de94ede36a1ec7cfa5b63dfd4

8 years agostagefright-plugins: Fix memory leak
Keith Mok [Mon, 14 Mar 2016 18:20:03 +0000 (11:20 -0700)]
stagefright-plugins: Fix memory leak

AVPacket needs to be unreference after
calling avcodec_decode_video2.
Reference: "ffmpeg/tests/api/api-band-test.c"

CYNGNOS-2239

Change-Id: I0ffb7c95addc32cb49c070d95a8d7cc950646360

8 years agostagefright-plugins: Fix memory leak
Keith Mok [Mon, 14 Mar 2016 15:59:00 +0000 (08:59 -0700)]
stagefright-plugins: Fix memory leak

During deinitDecoder mCtx may not be free due to
codec have not be opened.

CYNGNOS-2239

This fixes:
984 bytes in 1 blocks are definitely lost in loss record 1,174 of 1,286
   at 0x486B8AC: memalign (in /system/lib/valgrind/vgpreload_memcheck-arm-linux.so)
   by 0x486B9C7: posix_memalign (in /system/lib/valgrind/vgpreload_memcheck-arm-linux.so)
   by 0xC1165BB: av_malloc (in /system/vendor/lib/libavutil.so)
   by 0xE0914A7: avcodec_alloc_context3 (in /system/vendor/lib/libavcodec.so)
   by 0xBF2DD2B: android::SoftFFmpegVideo::initDecoder(AVCodecID) (in /system/vendor/lib/libffmpeg_omx.so)
   by 0xBF2DC9B: android::SoftFFmpegVideo::SoftFFmpegVideo(char const*, char const*, OMX_VIDEO_CODINGTYPE, android::CodecProfileLevel const*, unsigned int, OMX_CALLBACKTYPE const*, void*, OMX_COMPONENTTYPE**, AVCodecID) (in /system/vendor/lib/libffmpeg_omx.so)
   by 0xBF2EAC5: android::SoftFFmpegVideo::createSoftOMXComponent(char const*, OMX_CALLBACKTYPE const*, void*, OMX_COMPONENTTYPE**) (in /system/vendor/lib/libffmpeg_omx.so)
   by 0xBF2B651: android::FFmpegOMXPlugin::makeComponentInstance(char const*, OMX_CALLBACKTYPE const*, void*, OMX_COMPONENTTYPE**) (in /system/vendor/lib/libffmpeg_omx.so)
   by 0x53D8DA3: android::OMXMaster::makeComponentInstance(char const*, OMX_CALLBACKTYPE const*, void*, OMX_COMPONENTTYPE**) (in /system/lib/libstagefright_omx.so)
   by 0x53D7331: android::OMX::allocateNode(char const*, android::sp<android::IOMXObserver> const&, unsigned int*) (in /system/lib/libstagefright_omx.so)
   by 0x50271DB: android::QueryCodec(android::sp<android::IOMX> const&, char const*, char const*, bool, android::CodecCapabilities*) (in /system/lib/libstagefright.so)
   by 0x5010EF7: android::MediaCodecList::initializeCapabilities(char const*) (in /system/lib/libstagefright.so)

3,936 bytes in 4 blocks are definitely lost in loss record 1,223 of 1,286
   at 0x486B8AC: memalign (in /system/lib/valgrind/vgpreload_memcheck-arm-linux.so)
   by 0x486B9C7: posix_memalign (in /system/lib/valgrind/vgpreload_memcheck-arm-linux.so)
   by 0xC1165BB: av_malloc (in /system/vendor/lib/libavutil.so)
   by 0xE0914A7: avcodec_alloc_context3 (in /system/vendor/lib/libavcodec.so)
   by 0xBF2BAC9: android::SoftFFmpegAudio::initDecoder(AVCodecID) (in /system/vendor/lib/libffmpeg_omx.so)
   by 0xBF2B92B: android::SoftFFmpegAudio::SoftFFmpegAudio(char const*, char const*, OMX_AUDIO_CODINGTYPE, AVCodecID, OMX_CALLBACKTYPE const*, void*, OMX_COMPONENTTYPE**) (in /system/vendor/lib/libffmpeg_omx.so)
   by 0xBF2D723: android::SoftFFmpegAudio::createSoftOMXComponent(char const*, OMX_CALLBACKTYPE const*, void*, OMX_COMPONENTTYPE**) (in /system/vendor/lib/libffmpeg_omx.so)
   by 0xBF2B619: android::FFmpegOMXPlugin::makeComponentInstance(char const*, OMX_CALLBACKTYPE const*, void*, OMX_COMPONENTTYPE**) (in /system/vendor/lib/libffmpeg_omx.so)
   by 0x53D8DA3: android::OMXMaster::makeComponentInstance(char const*, OMX_CALLBACKTYPE const*, void*, OMX_COMPONENTTYPE**) (in /system/lib/libstagefright_omx.so)
   by 0x53D7331: android::OMX::allocateNode(char const*, android::sp<android::IOMXObserver> const&, unsigned int*) (in /system/lib/libstagefright_omx.so)
   by 0x50271DB: android::QueryCodec(android::sp<android::IOMX> const&, char const*, char const*, bool, android::CodecCapabilities*) (in /system/lib/libstagefright.so)
   by 0x5010EF7: android::MediaCodecList::initializeCapabilities(char const*) (in /system/lib/libstagefright.so)

Change-Id: I623860502bc692663c80bf0f26305270e161df2c

8 years agostagefright-plugins: Skip 2nd parsing for ogg
Keith Mok [Mon, 22 Feb 2016 18:02:38 +0000 (10:02 -0800)]
stagefright-plugins: Skip 2nd parsing for ogg

Currently only drm extractor from stagefright
provides confidence > 0.8f.
This makes almosts all media files to be parsed a 2nd time
in ffmpeg.

Skip parsing file that is determined by stagefright as ogg
file. The stagefright ogg extractor handles it well enough.

Change-Id: Ic6ab86c8cef38dbbac337f1bf5f4ec2a8bbcd862

8 years agostagefright-plugins: enlarge audio/video queue
Keith Mok [Wed, 17 Feb 2016 00:58:42 +0000 (16:58 -0800)]
stagefright-plugins: enlarge audio/video queue

Some video file have large offset between video and
audio data, we need to enlarge the buffer size
in order to be able to play back those files.

CYNGNOS-2061

Change-Id: Ia44f27e64733186750c058a5cb67985e812ee6c7

8 years agostagefright-plugins: prevent deadlock
Keith Mok [Wed, 17 Feb 2016 00:50:34 +0000 (16:50 -0800)]
stagefright-plugins: prevent deadlock

If video/audio data offset too large,
it will create a deadlock, since there is only one
thread in consuming the video/audio data.
The video can be full, but with all audio data
consumed, causing read function to wait foreve for
new audio data.

CYNGNOS-2061

Change-Id: I0d366311463d5ae25c1d18a584d51d1deae7dfea

8 years agostagefright-plugins: workaround negative timestamp
Keith Mok [Fri, 29 Jan 2016 19:14:11 +0000 (11:14 -0800)]
stagefright-plugins: workaround negative timestamp

libstagefright does not like negative timestamp,
and is causing crash if extractor reports that.
Add a checking for that, and return media malformed
if negative timestamp is encountered.

Change-Id: I8478b49d280735600b0f6290deb3dee7ed6521f5

8 years agostagefright-plugins: Fix mov file streaming
Keith Mok [Sat, 23 Jan 2016 00:36:07 +0000 (16:36 -0800)]
stagefright-plugins: Fix mov file streaming

mov file is consider as MEDIA_MIMETYPE_CONTAINER_MPEG4.
But if we are streaming, the following code will force
to use aosp extractor instead:
    if (!strcasecmp(container, MEDIA_MIMETYPE_CONTAINER_MPEG4)
            && (source->flags() & DataSource::kIsCachingDataSource)) {
        ALOGI("support container: %s, but it is caching data source, "
                "Don't use ffmpegextractor", container);
        (*meta)->clear();
        *meta = NULL;
        return false;
    }

However aosp does not support mov file container, which results
playback fails.

This patch fixes it.

Change-Id: Ie2ae8a177c7df92987b6a955e6450cb69ee9f93e

8 years agostagefright-plugins: Fix video orientation
Keith Mok [Fri, 22 Jan 2016 00:40:55 +0000 (16:40 -0800)]
stagefright-plugins: Fix video orientation

* Some videos are encoded rotated, but it also records the rotation in a
  rotation matrix. During playback, the player should apply the
  rotation matrix for display purpose.
  Right now, ffmpeg does decode the rotation matrix stored on the video file.
  But stagefright-plugins does not parse that meta data to stagefright.
  Added code to pass kKeyRotation to stagefright.
* Fixes CYNGNOS-1692

Change-Id: I718fd80c4695407fb214bab359d5cc255044725e

8 years agostagefright-plugins: Update pixfmt
Keith Mok [Wed, 20 Jan 2016 00:22:10 +0000 (16:22 -0800)]
stagefright-plugins: Update pixfmt

PIX_FMT_YUV420P is going to be deprecated.
Use AV_PIX_FMT_YUV420P instead.

Change-Id: Ia6d119367bc2763da8206b1e6c61f3183830fe2b

8 years agostagefright-plugins: Skip stream with jpeg tag
Keith Mok [Mon, 18 Jan 2016 23:39:01 +0000 (15:39 -0800)]
stagefright-plugins: Skip stream with jpeg tag

 * MJPEG is used internally by FFMPEG to represent embedded art as
   stream of images. Normally, AV_DISPOSITION_ATTACHED_PIC will be set
   on these streams to denote it should be handled as such. We are
   seeing certain streams in the wild for which this isn't happening
   which causes a hang during decode.
 * Fixes NIGHTLIES-2346

Change-Id: Ie86d3ffb5b7b676a77dc0ae5e7d10a828c8532cf

8 years agostagefright-plugins: Fix certain HEVC file cannot playback
Keith Mok [Wed, 6 Jan 2016 19:57:38 +0000 (11:57 -0800)]
stagefright-plugins: Fix certain HEVC file cannot playback

Add checking for HEVC streaming is in hvcC format or not,
before we decided to do convertion to annex-b format.

Change-Id: If268bbf2631ef51694298d04a3ec89e5e68f37a9

8 years agostagefright-plugins: Parse file metadata tags
Steve Kondik [Mon, 4 Jan 2016 09:56:36 +0000 (01:56 -0800)]
stagefright-plugins: Parse file metadata tags

 * Convert from AVFormat tags into the corresponding Android
   tags when file metadata is requested.
 * Also extract embedded album art.

Change-Id: I49aec64dc30c9afd6510a25f8c2261029d8bdadf

8 years agostagefright-plugins: Protect against crash
Steve Kondik [Sat, 2 Jan 2016 16:40:06 +0000 (08:40 -0800)]
stagefright-plugins: Protect against crash

 * If the queue has been aborted, don't derefernce NULL pointers.

Change-Id: I1a04216da11cf71cbe78a315d7aef3224bb11162

8 years agostagefright-plugins: Increase max video buffer size + count
Steve Kondik [Sat, 2 Jan 2016 09:32:52 +0000 (01:32 -0800)]
stagefright-plugins: Increase max video buffer size + count

 * Fixes testOtherMpeg4SurfArbitraryW and testOtherMpeg4FlexArbitraryW

Change-Id: I1af56a5b5d950b61778c59c7d097755c9a4b902e

8 years agostagefright-plugins: Refactor packet queue locking
Steve Kondik [Wed, 30 Dec 2015 23:20:26 +0000 (15:20 -0800)]
stagefright-plugins: Refactor packet queue locking

 * Use Mutex/Condition like a sane Android developer
 * Introduce a timeout in the blocking get call to avoid deadlocks
 * This ensure that error cases get handled gracefully and that
   android.media.cts.MediaScannerNotificationTest passes too.

Change-Id: Icd106699dd65af07f7afbbdd02e927ff0122eace

8 years agostagefright-plugins: Fix shutdown deadlock
Steve Kondik [Wed, 30 Dec 2015 05:02:20 +0000 (21:02 -0800)]
stagefright-plugins: Fix shutdown deadlock

 * No need to hold the lock to shut down the extractor. We can also
   deadlock here during heavy mediascanner activity (seen during CTS).

Change-Id: I7fdd540891651c489b524cb4634f933e5bb4746d

8 years agostagefright-plugins: Fix crash during testDecodeWithEOSOnLastBuffer
Steve Kondik [Wed, 30 Dec 2015 02:28:26 +0000 (18:28 -0800)]
stagefright-plugins: Fix crash during testDecodeWithEOSOnLastBuffer

 * Don't blindly dequeue a buffer, it could be garbage in which case
   we just crash and fail CTS :(

Change-Id: I6541b75890da8d9e55d5bf0b2126cea2688febba

8 years agostagefright-plugins: Wait for reader shutdown on EOS
Steve Kondik [Wed, 30 Dec 2015 02:08:01 +0000 (18:08 -0800)]
stagefright-plugins: Wait for reader shutdown on EOS

 * Source will flag EOS but we need to stick around during gapless
   playback, otherwise the extractor aborts early and can confuse
   apps.
 * Fixes gapless transitions during FLAC playback with Tidal.

Change-Id: Icbdaa180d39d626b163089f5686b7a1e4afcfbc2

8 years agostagefright-plugins: Only do as much sniffing as necessary
Steve Kondik [Mon, 28 Dec 2015 21:13:48 +0000 (13:13 -0800)]
stagefright-plugins: Only do as much sniffing as necessary

 * Stagefright will now pass on the current knowledge of the stream
   instead of zeros/nulls, let's take advantage of it.
 * Don't bother sniffing if the confidence is already high.
 * Check how much info avformat_open_input found before we continue.
   For formats with headers, this is all we need and our latency is
   reduced to 10s of milliseconds vs. potentially seconds.
 * Add timing metrics in the debug prints.

Change-Id: I476fc6723c070e03a77c6aaa0f8198064a15af2c

8 years agostagefright-plugins: Increase confidence on HEVC mp2p files
Keith Mok [Mon, 21 Dec 2015 23:44:43 +0000 (15:44 -0800)]
stagefright-plugins: Increase confidence on HEVC mp2p files

AOSP does not handle HEVC video codec in mp2p file.
Add more confidence in FFmpegExtractor to use ffmpeg
to decode this type of file.

Change-Id: I34f19e8d1e05c02e92a42386cb8d039f3e2a680d

8 years agostagefright-plugins: Fix audio trimmed when reaching eos
Keith Mok [Wed, 23 Dec 2015 20:54:37 +0000 (12:54 -0800)]
stagefright-plugins: Fix audio trimmed when reaching eos

When received eos, SoftFFmpegAudio will drop that buffer
without decoding it. This makes the following cts test case failed:
android.media.cts.DecoderTest/testDecodeWithEOSOnLastBuffer

Change-Id: I51e670ac4348dc5bfb8bae267a1801209e509fd7

8 years agostagefright-plugins: Fix crash
Keith Mok [Wed, 23 Dec 2015 19:24:18 +0000 (11:24 -0800)]
stagefright-plugins: Fix crash

When openmax reset the audio codec, it does not
clean up the mCodecAlreadyOpened flag which
leaving mCtx->codec equals to null and causing
crash.

Change-Id: Ib5c0240a308d8b85d8ce51e9309ead06addc903f

8 years agostagefright-plugins: Fix thumbnail issues
Steve Kondik [Sun, 27 Dec 2015 06:50:39 +0000 (22:50 -0800)]
stagefright-plugins: Fix thumbnail issues

 * Grab the thumbnail time from the overall duration.
 * Don't seek for negative values, this unbalances the code
   used by FFMPEG for seeking within a range and biases towards
   the first frame in short clips, usually resulting in a black
   thumbnail.

Change-Id: I7021f19560808dc58dce9892dadcbaf5927e1c14

8 years agostagefright-plugins: Pass the container format in the metadata
Steve Kondik [Sun, 27 Dec 2015 06:10:07 +0000 (22:10 -0800)]
stagefright-plugins: Pass the container format in the metadata

 * This is needed by Stagefright to enable certain features of
   the hardware decoders.

Change-Id: I694429c88501dfc5de6128d0eff28ef9b08c472f

8 years agostagefright-plugins: Remove voodoo from sniff logic
Steve Kondik [Sun, 27 Dec 2015 00:49:51 +0000 (16:49 -0800)]
stagefright-plugins: Remove voodoo from sniff logic

 * We always run last, so if our confidence is high then add the
   necessary metadata.
 * Remove magic numbers.

Change-Id: I34ccffff7836495055610346dc8b99e36d855d5b

8 years agostagefright-plugins: Add special case for DivX containers
Steve Kondik [Sun, 27 Dec 2015 00:48:03 +0000 (16:48 -0800)]
stagefright-plugins: Add special case for DivX containers

 * MPEG4Extractor cannot handle this and we need to do it. Boost
   confidence level accordingly.

Change-Id: I8ade1c576c0cc81bded1b00c4a0df33ef998a897

8 years agostagefright-plugins: Fix HEVC extradata handling
Steve Kondik [Sun, 27 Dec 2015 00:46:15 +0000 (16:46 -0800)]
stagefright-plugins: Fix HEVC extradata handling

 * Check the correct positions in the extradata for conversion.

Change-Id: I1c909c2f9f8b8dce30c180bca08496b15df928d6

8 years agostagefright-plugins: Always use FFMPEG for FLAC audio
Steve Kondik [Sun, 27 Dec 2015 00:42:29 +0000 (16:42 -0800)]
stagefright-plugins: Always use FFMPEG for FLAC audio

 * The decoder in AOSP is not very good and due to the use of libFLAC
   it cannot work in the case where the DSP can offload compressed
   FLAC (AOSP's codec can only output decoded PCM). Prefer ours instead.

Change-Id: Id5665e4bcff0206c9ce2bd5e3d2ab7bfb81a1663

8 years agostagefright-plugins: Correctly check if audio codec is open
Steve Kondik [Sun, 27 Dec 2015 00:40:26 +0000 (16:40 -0800)]
stagefright-plugins: Correctly check if audio codec is open

 * Same as we're doing for video.

Change-Id: I424cdd197cae73d0647738fc9c97e87c2692181b

8 years agostagefright-plugins: remove global dictionaries
Scott Mertz [Wed, 23 Dec 2015 00:19:59 +0000 (16:19 -0800)]
stagefright-plugins: remove global dictionaries

The global dictionaries are only accessed from the ffmpeg extractor.
There is no use for them to be declared in one shared library and
accessed in another.

This has the benefit of fixing an issue where format_opts is not
initialized to NULL in some cases.

Change-Id: I57b39c82e29aa48fc852a9fbe8a2434885d407e6

8 years agostagefright-plugins: Seek to beginning of file on seek error
Steve Kondik [Mon, 21 Dec 2015 11:44:06 +0000 (06:44 -0500)]
stagefright-plugins: Seek to beginning of file on seek error

 * Prevent a deadlock on seek error

Change-Id: Ic7dfe1849298f6166154c319e618048720d1ea61

8 years agostagefright-plugins: Fix AAC profile selection
Steve Kondik [Mon, 21 Dec 2015 04:21:54 +0000 (23:21 -0500)]
stagefright-plugins: Fix AAC profile selection

 * Just re-use the information FFMPEG has already gathered for us
   to avoid inconsistency.
 * Also set the right type for HVCC

Change-Id: I341e008cb0b51fffa83122db8103afed3212ec8b

8 years agostagefright-plugins: Return supported profiles for MPEG4
Steve Kondik [Thu, 17 Dec 2015 22:08:06 +0000 (17:08 -0500)]
stagefright-plugins: Return supported profiles for MPEG4

 * All codecs understood by MediaCodec must return supported
   profiles/levels and additional metadata.

Change-Id: If07a268a0791729b8db00d549f27d581760fa972

8 years agostagefright-plugins: Parse additional FLAC metadata
Steve Kondik [Mon, 14 Dec 2015 09:03:13 +0000 (01:03 -0800)]
stagefright-plugins: Parse additional FLAC metadata

  * Parse the min/max frame and block sizes from the streaminfo and
    report it in the metadata
  * This is needed for FLAC offload support on new Qualcomm DSPs.

Change-Id: Ib37891a5766066306adf18a6c23af9c9ac7dcdb1

8 years agostagefright-plugins: Really ignore album art "streams"
Steve Kondik [Mon, 14 Dec 2015 04:20:08 +0000 (20:20 -0800)]
stagefright-plugins: Really ignore album art "streams"

 * We need an extra check for the attached pic disposition if we want
   to use the source to extract raw data without a decoder. This
   is necessary for audio offload.

Change-Id: Ibb60987462a95a4d80d614870077ecf39c18fd52

8 years agostagefright-plugins: Init port with larger audio buffer size
Steve Kondik [Sun, 13 Dec 2015 05:23:59 +0000 (21:23 -0800)]
stagefright-plugins: Init port with larger audio buffer size

 * Allocate enough to handle 32 bits of data.

Change-Id: Ieac10aa1c1ac78b679c57a1957c3d6699612a262

8 years agostagefright-plugins: Fix video of resolution 320x240
Keith Mok [Wed, 9 Dec 2015 22:32:20 +0000 (14:32 -0800)]
stagefright-plugins: Fix video of resolution 320x240

Video of resoltuion 320x240 cannot be played correctly.
Since the width and height of mCtx are not set and eqauls to zero.
The width and height of mCts are supposed to be set by
OMX_IndexParamPortDefinition, but the default size is
320x240. So in function internalSetParameter,
case OMX_IndexParamPortDefinition,
(newWidth != oldWidth || newHeight != oldHeight)
is always false and skipped setting mCts->width and height.
This results avcodec_open2 fails and an error is printed out
"Picture size 0x0 is invalid".

Setting mCtx->width and height to mWidth and mHeight solves
the problem.

Change-Id: I5dec4e4af66afded27dc4e6d2835249262f90528

8 years agoffmpeg-extractor: Fix sample aspect ratioa issue
Keith Mok [Wed, 9 Dec 2015 19:26:20 +0000 (11:26 -0800)]
ffmpeg-extractor: Fix sample aspect ratioa issue

Some movies are diplayed incorrectly due to wrong aspect
ratio. The ffmpeg-extractor does not pass the sample aspect ratio
to the upper layer. This fixes it.

Change-Id: I6da6ffe355e1bc3802b2fbd7da0aa2946b88b1a6

8 years agoffmpeg: Fix crash when avio_check is called
Keith Mok [Wed, 7 Oct 2015 23:13:00 +0000 (16:13 -0700)]
ffmpeg: Fix crash when avio_check is called

url_check does not guarantee url_open will be called before
(and actually it is not designed to do so)
If url_open is not called before url_check called, ffs
will be null causing the crash.

Change-Id: I0176c619eeb931ede0061003e396ee7e1407b860
(cherry picked from commit 832d93744cccf1f056f7ecdad6041e91148e9260)

8 years agoffmpeg: video: Check if the codec is still open before flushing
Diogo Ferreira [Fri, 27 Nov 2015 10:37:47 +0000 (10:37 +0000)]
ffmpeg: video: Check if the codec is still open before flushing

This might be called whilst the codec has already finished decoding
and is not available for flushing.

Fixes the adaptative HEVC CTS tests.

Change-Id: I80ad95b23a4ba230256ffb7c6df6af4d99ef65a6

8 years agostagefright-plugins: Relax component role check
Steve Kondik [Thu, 26 Nov 2015 00:58:55 +0000 (16:58 -0800)]
stagefright-plugins: Relax component role check

 * Our extractor might be used to handle both thumbnails
   (in software) as well as playback (with hardware codec support).
   In at least one case, the vendor OMX roles don't match anything
   sane, so relax the check to support this case.

Change-Id: I8925229156cc0e33ff83d4b9ce933087b75b12ef

8 years agocodecs: Disable AC3/EAC3
Ricardo Cerqueira [Wed, 28 Oct 2015 14:56:41 +0000 (14:56 +0000)]
codecs: Disable AC3/EAC3

Because of reasons. And licenses. But mostly reasons. Maybe licenses.

Change-Id: Idd33afae0c55e428fd76961f54ae95f3cb9c6cc0