libstagefright: port to refcounted frames
authorPaul B Mahol <onemda@gmail.com>
Thu, 4 Jul 2013 20:17:38 +0000 (20:17 +0000)
committerPaul B Mahol <onemda@gmail.com>
Thu, 4 Jul 2013 20:17:38 +0000 (20:17 +0000)
Untested.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
libavcodec/libstagefright.cpp

index d02e6f3..bb49d8a 100644 (file)
@@ -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);
     }