Commit d2a847c2 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge remote-tracking branch 'hexene/scratchpad'

* hexene/scratchpad:
  libstagefright: Explicitly free smart pointer objects
  Changelog: Explain why C++ support is added, and that its optional
  tools/build_libstagefright: rename build/libav to something neutral

Conflicts:
	Changelog
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 9fa47cb7 e7f9aa6f
...@@ -51,7 +51,7 @@ easier to use. The changes are: ...@@ -51,7 +51,7 @@ easier to use. The changes are:
- Speex encoder via libspeex - Speex encoder via libspeex
- JSON output in ffprobe - JSON output in ffprobe
- WTV muxer - WTV muxer
- C++ Support - Optional C++ Support (needed for libstagefright)
- H.264 Decoding on Android via Stagefright - H.264 Decoding on Android via Stagefright
......
...@@ -58,7 +58,7 @@ struct StagefrightContext { ...@@ -58,7 +58,7 @@ struct StagefrightContext {
AVBitStreamFilterContext *bsfc; AVBitStreamFilterContext *bsfc;
uint8_t* orig_extradata; uint8_t* orig_extradata;
int orig_extradata_size; int orig_extradata_size;
sp<MediaSource> source; sp<MediaSource> *source;
List<Frame*> *in_queue, *out_queue; List<Frame*> *in_queue, *out_queue;
pthread_mutex_t in_mutex, out_mutex; pthread_mutex_t in_mutex, out_mutex;
pthread_cond_t condition; pthread_cond_t condition;
...@@ -74,7 +74,7 @@ struct StagefrightContext { ...@@ -74,7 +74,7 @@ struct StagefrightContext {
int dummy_bufsize; int dummy_bufsize;
OMXClient *client; OMXClient *client;
sp<MediaSource> decoder; sp<MediaSource> *decoder;
const char *decoder_component; const char *decoder_component;
}; };
...@@ -156,9 +156,9 @@ void* decode_thread(void *arg) ...@@ -156,9 +156,9 @@ void* decode_thread(void *arg)
decode_done = 1; decode_done = 1;
s->end_frame = NULL; s->end_frame = NULL;
} else { } else {
frame->status = s->decoder->read(&buffer); frame->status = (*s->decoder)->read(&buffer);
if (frame->status == OK) { if (frame->status == OK) {
sp<MetaData> outFormat = s->decoder->getFormat(); sp<MetaData> outFormat = (*s->decoder)->getFormat();
outFormat->findInt32(kKeyWidth , &frame->w); outFormat->findInt32(kKeyWidth , &frame->w);
outFormat->findInt32(kKeyHeight, &frame->h); outFormat->findInt32(kKeyHeight, &frame->h);
frame->size = buffer->range_length(); frame->size = buffer->range_length();
...@@ -220,7 +220,8 @@ static av_cold int Stagefright_init(AVCodecContext *avctx) ...@@ -220,7 +220,8 @@ static av_cold int Stagefright_init(AVCodecContext *avctx)
android::ProcessState::self()->startThreadPool(); android::ProcessState::self()->startThreadPool();
s->source = new CustomSource(avctx, meta); s->source = new sp<MediaSource>();
*s->source = new CustomSource(avctx, meta);
s->in_queue = new List<Frame*>; s->in_queue = new List<Frame*>;
s->out_queue = new List<Frame*>; s->out_queue = new List<Frame*>;
s->client = new OMXClient; s->client = new OMXClient;
...@@ -237,17 +238,18 @@ static av_cold int Stagefright_init(AVCodecContext *avctx) ...@@ -237,17 +238,18 @@ static av_cold int Stagefright_init(AVCodecContext *avctx)
goto fail; goto fail;
} }
s->decoder = OMXCodec::Create(s->client->interface(), meta, s->decoder = new sp<MediaSource>();
false, s->source, NULL, *s->decoder = OMXCodec::Create(s->client->interface(), meta,
false, *s->source, NULL,
OMXCodec::kClientNeedsFramebuffer); OMXCodec::kClientNeedsFramebuffer);
if (s->decoder->start() != OK) { if ((*s->decoder)->start() != OK) {
av_log(avctx, AV_LOG_ERROR, "Cannot start decoder\n"); av_log(avctx, AV_LOG_ERROR, "Cannot start decoder\n");
ret = -1; ret = -1;
s->client->disconnect(); s->client->disconnect();
goto fail; goto fail;
} }
outFormat = s->decoder->getFormat(); outFormat = (*s->decoder)->getFormat();
outFormat->findInt32(kKeyColorFormat, &colorFormat); outFormat->findInt32(kKeyColorFormat, &colorFormat);
if (colorFormat == OMX_QCOM_COLOR_FormatYVU420SemiPlanar || if (colorFormat == OMX_QCOM_COLOR_FormatYVU420SemiPlanar ||
colorFormat == OMX_COLOR_FormatYUV420SemiPlanar) colorFormat == OMX_COLOR_FormatYUV420SemiPlanar)
...@@ -472,7 +474,7 @@ static av_cold int Stagefright_close(AVCodecContext *avctx) ...@@ -472,7 +474,7 @@ static av_cold int Stagefright_close(AVCodecContext *avctx)
av_freep(&frame); av_freep(&frame);
} }
s->decoder->stop(); (*s->decoder)->stop();
s->client->disconnect(); s->client->disconnect();
if (s->decoder_component) if (s->decoder_component)
...@@ -490,6 +492,8 @@ static av_cold int Stagefright_close(AVCodecContext *avctx) ...@@ -490,6 +492,8 @@ static av_cold int Stagefright_close(AVCodecContext *avctx)
delete s->in_queue; delete s->in_queue;
delete s->out_queue; delete s->out_queue;
delete s->client; delete s->client;
delete s->decoder;
delete s->source;
pthread_mutex_destroy(&s->in_mutex); pthread_mutex_destroy(&s->in_mutex);
pthread_mutex_destroy(&s->out_mutex); pthread_mutex_destroy(&s->out_mutex);
......
...@@ -12,10 +12,10 @@ export PATH=$TOOLCHAIN/bin:$PATH ...@@ -12,10 +12,10 @@ export PATH=$TOOLCHAIN/bin:$PATH
ANDROID_SOURCE=$HOME/android ANDROID_SOURCE=$HOME/android
ANDROID_LIBS=$HOME/glib ANDROID_LIBS=$HOME/glib
rm -rf ../build/libav rm -rf ../build/stagefright
mkdir -p ../build/libav 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="--target-os=linux --cross-prefix=arm-linux-androideabi- --arch=arm --cpu=armv7-a"
FLAGS="$FLAGS --sysroot=$SYSROOT" FLAGS="$FLAGS --sysroot=$SYSROOT"
FLAGS="$FLAGS --disable-avdevice --disable-decoder=h264 --disable-decoder=h264_vdpau --enable-libstagefright-h264" FLAGS="$FLAGS --disable-avdevice --disable-decoder=h264 --disable-decoder=h264_vdpau --enable-libstagefright-h264"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment