From d1c96b28d7b6c9db9a6c5d19d33b41311bbe2ca6 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Thu, 4 Jul 2013 20:17:38 +0000 Subject: [PATCH] libstagefright: port to refcounted frames Untested. Signed-off-by: Paul B Mahol --- libavcodec/libstagefright.cpp | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/libavcodec/libstagefright.cpp b/libavcodec/libstagefright.cpp index d02e6f32ac..bb49d8a625 100644 --- a/libavcodec/libstagefright.cpp +++ b/libavcodec/libstagefright.cpp @@ -186,7 +186,7 @@ void* decode_thread(void *arg) buffer->release(); goto push_frame; } - ret = ff_get_buffer(avctx, frame->vframe, 0); + ret = ff_get_buffer(avctx, frame->vframe, AV_GET_BUFFER_FLAG_REF); if (ret < 0) { frame->status = ret; decode_done = 1; @@ -457,10 +457,8 @@ static int Stagefright_decode_frame(AVCodecContext *avctx, void *data, return -1; } - if (s->prev_frame) { - avctx->release_buffer(avctx, s->prev_frame); - av_freep(&s->prev_frame); - } + if (s->prev_frame) + av_frame_free(&s->prev_frame); s->prev_frame = ret_frame; *got_frame = 1; @@ -482,10 +480,8 @@ static av_cold int Stagefright_close(AVCodecContext *avctx) while (!s->out_queue->empty()) { frame = *s->out_queue->begin(); s->out_queue->erase(s->out_queue->begin()); - if (frame->vframe) { - avctx->release_buffer(avctx, frame->vframe); - av_freep(&frame->vframe); - } + if (frame->vframe) + av_frame_free(&frame->vframe); av_freep(&frame); } pthread_mutex_unlock(&s->out_mutex); @@ -515,10 +511,8 @@ static av_cold int Stagefright_close(AVCodecContext *avctx) pthread_join(s->decode_thread_id, NULL); - if (s->prev_frame) { - avctx->release_buffer(avctx, s->prev_frame); - av_freep(&s->prev_frame); - } + if (s->prev_frame) + av_frame_free(&s->prev_frame); s->thread_started = false; } @@ -534,10 +528,8 @@ static av_cold int Stagefright_close(AVCodecContext *avctx) while (!s->out_queue->empty()) { frame = *s->out_queue->begin(); s->out_queue->erase(s->out_queue->begin()); - if (frame->vframe) { - avctx->release_buffer(avctx, frame->vframe); - av_freep(&frame->vframe); - } + if (frame->vframe) + av_frame_free(&frame->vframe); av_freep(&frame); }