From b5824233fbf9fdc8eb85ea214451b7552cc31f00 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 14 Sep 2011 02:33:50 +0200 Subject: [PATCH 1/3] tools/build_libstagefright: rename build/libav to something neutral Signed-off-by: Michael Niedermayer --- tools/build_libstagefright | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/build_libstagefright b/tools/build_libstagefright index 583c801a56..a228487fb5 100755 --- a/tools/build_libstagefright +++ b/tools/build_libstagefright @@ -12,10 +12,10 @@ export PATH=$TOOLCHAIN/bin:$PATH ANDROID_SOURCE=$HOME/android ANDROID_LIBS=$HOME/glib -rm -rf ../build/libav -mkdir -p ../build/libav +rm -rf ../build/stagefright +mkdir -p ../build/stagefright -DEST=../build/libav +DEST=../build/stagefright FLAGS="--target-os=linux --cross-prefix=arm-linux-androideabi- --arch=arm --cpu=armv7-a" FLAGS="$FLAGS --sysroot=$SYSROOT" FLAGS="$FLAGS --disable-avdevice --disable-decoder=h264 --disable-decoder=h264_vdpau --enable-libstagefright-h264" From 1a2d8c8b355a58153045e2416c30b404f3e7e9ed Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 14 Sep 2011 02:35:28 +0200 Subject: [PATCH 2/3] Changelog: Explain why C++ support is added, and that its optional Signed-off-by: Michael Niedermayer --- Changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog b/Changelog index c3b37484c1..aa08ebbab8 100644 --- a/Changelog +++ b/Changelog @@ -42,7 +42,7 @@ easier to use. The changes are: * -intra option was removed, it's equivalent to -g 0. - XMV demuxer - Windows Media Image decoder -- C++ Support +- Optional C++ Support (needed for libstagefright) - H.264 Decoding on Android via Stagefright From e7f9aa6ff5c850df173784d88ef8c79b22513d96 Mon Sep 17 00:00:00 2001 From: Mohamed Naufal Date: Wed, 14 Sep 2011 21:01:07 +0530 Subject: [PATCH 3/3] libstagefright: Explicitly free smart pointer objects --- libavcodec/libstagefright.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/libavcodec/libstagefright.cpp b/libavcodec/libstagefright.cpp index e31a2ec7b3..2022bab37e 100644 --- a/libavcodec/libstagefright.cpp +++ b/libavcodec/libstagefright.cpp @@ -58,7 +58,7 @@ struct StagefrightContext { AVBitStreamFilterContext *bsfc; uint8_t* orig_extradata; int orig_extradata_size; - sp source; + sp *source; List *in_queue, *out_queue; pthread_mutex_t in_mutex, out_mutex; pthread_cond_t condition; @@ -74,7 +74,7 @@ struct StagefrightContext { int dummy_bufsize; OMXClient *client; - sp decoder; + sp *decoder; const char *decoder_component; }; @@ -156,9 +156,9 @@ void* decode_thread(void *arg) decode_done = 1; s->end_frame = NULL; } else { - frame->status = s->decoder->read(&buffer); + frame->status = (*s->decoder)->read(&buffer); if (frame->status == OK) { - sp outFormat = s->decoder->getFormat(); + sp outFormat = (*s->decoder)->getFormat(); outFormat->findInt32(kKeyWidth , &frame->w); outFormat->findInt32(kKeyHeight, &frame->h); frame->size = buffer->range_length(); @@ -220,7 +220,8 @@ static av_cold int Stagefright_init(AVCodecContext *avctx) android::ProcessState::self()->startThreadPool(); - s->source = new CustomSource(avctx, meta); + s->source = new sp(); + *s->source = new CustomSource(avctx, meta); s->in_queue = new List; s->out_queue = new List; s->client = new OMXClient; @@ -237,17 +238,18 @@ static av_cold int Stagefright_init(AVCodecContext *avctx) goto fail; } - s->decoder = OMXCodec::Create(s->client->interface(), meta, - false, s->source, NULL, + s->decoder = new sp(); + *s->decoder = OMXCodec::Create(s->client->interface(), meta, + false, *s->source, NULL, OMXCodec::kClientNeedsFramebuffer); - if (s->decoder->start() != OK) { + if ((*s->decoder)->start() != OK) { av_log(avctx, AV_LOG_ERROR, "Cannot start decoder\n"); ret = -1; s->client->disconnect(); goto fail; } - outFormat = s->decoder->getFormat(); + outFormat = (*s->decoder)->getFormat(); outFormat->findInt32(kKeyColorFormat, &colorFormat); if (colorFormat == OMX_QCOM_COLOR_FormatYVU420SemiPlanar || colorFormat == OMX_COLOR_FormatYUV420SemiPlanar) @@ -472,7 +474,7 @@ static av_cold int Stagefright_close(AVCodecContext *avctx) av_freep(&frame); } - s->decoder->stop(); + (*s->decoder)->stop(); s->client->disconnect(); if (s->decoder_component) @@ -490,6 +492,8 @@ static av_cold int Stagefright_close(AVCodecContext *avctx) delete s->in_queue; delete s->out_queue; delete s->client; + delete s->decoder; + delete s->source; pthread_mutex_destroy(&s->in_mutex); pthread_mutex_destroy(&s->out_mutex);