[vlc-commits] avcodec: provide default implementation for HW picture release callback

Rémi Denis-Courmont git at videolan.org
Tue Apr 21 23:43:07 CEST 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Apr 22 00:42:12 2015 +0300| [bf445475b7a0d1e5ac959968854661455177525c] | committer: Rémi Denis-Courmont

avcodec: provide default implementation for HW picture release callback

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bf445475b7a0d1e5ac959968854661455177525c
---

 modules/codec/avcodec/vda.c   |   24 ++----------------------
 modules/codec/avcodec/video.c |   28 ++++++++++++++++------------
 modules/hw/vdpau/avcodec.c    |    8 +-------
 3 files changed, 19 insertions(+), 41 deletions(-)

diff --git a/modules/codec/avcodec/vda.c b/modules/codec/avcodec/vda.c
index d842038..f2f742f 100644
--- a/modules/codec/avcodec/vda.c
+++ b/modules/codec/avcodec/vda.c
@@ -49,7 +49,6 @@ static void Close( vlc_va_t * , AVCodecContext *);
 static int Setup( vlc_va_t *, AVCodecContext *, vlc_fourcc_t *);
 static int Get( vlc_va_t *, picture_t *, uint8_t ** );
 static int Extract( vlc_va_t *, picture_t *, uint8_t * );
-static void Release( void *, uint8_t * );
 
 static void vda_Copy422YpCbCr8( picture_t *p_pic,
                                 CVPixelBufferRef buffer )
@@ -144,7 +143,7 @@ static int Open( vlc_va_t *va, AVCodecContext *ctx,
     va->pix_fmt = PIX_FMT_VDA_VLD;
     va->setup = Setup;
     va->get = Get;
-    va->release = Release;
+    va->release = NULL;
     va->extract = Extract;
 
     return VLC_SUCCESS;
@@ -299,18 +298,6 @@ static int Extract( vlc_va_t *va, picture_t *p_picture, uint8_t *data )
     return VLC_SUCCESS;
 }
 
-static void Release( void *opaque, uint8_t *data )
-{
-#if 0
-    CVPixelBufferRef cv_buffer = ( CVPixelBufferRef )p_ff->data[3];
-
-    if ( cv_buffer )
-        CVPixelBufferRelease( cv_buffer );
-#endif
-    picture_Release(opaque);
-    (void) data;
-}
-
 #else
 
 vlc_module_begin ()
@@ -329,7 +316,7 @@ static int Open( vlc_va_t *va, AVCodecContext *avctx, const es_format_t *fmt )
     va->pix_fmt = AV_PIX_FMT_VDA;
     va->setup = Setup;
     va->get = Get;
-    va->release = Release;
+    va->release = NULL;
     va->extract = Extract;
     msg_Dbg( va, "VDA decoder Open success!");
 
@@ -383,11 +370,4 @@ static int Extract( vlc_va_t *va, picture_t *p_picture, uint8_t *data )
 
     return VLC_SUCCESS;
 }
-
-static void Release( void *opaque, uint8_t *data )
-{
-    picture_Release(opaque);
-    (void) data;
-}
-
 #endif
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index a015e31..5ca424b 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -945,6 +945,14 @@ static void ffmpeg_InitCodec( decoder_t *p_dec )
     }
 }
 
+static void lavc_ReleaseFrame(void *opaque, uint8_t *data)
+{
+    picture_t *picture = opaque;
+
+    picture_Release(picture);
+    (void) data;
+}
+
 static int lavc_va_GetFrame(struct AVCodecContext *ctx, AVFrame *frame,
                             int flags)
 {
@@ -971,10 +979,14 @@ static int lavc_va_GetFrame(struct AVCodecContext *ctx, AVFrame *frame,
      * data[3] actually contains the format-specific surface handle. */
     frame->data[3] = frame->data[0];
 
-    frame->buf[0] = av_buffer_create(frame->data[0], 0, va->release, pic, 0);
+    void (*release)(void *, uint8_t *) = va->release;
+    if (va->release == NULL)
+        release = lavc_ReleaseFrame;
+
+    frame->buf[0] = av_buffer_create(frame->data[0], 0, release, pic, 0);
     if (unlikely(frame->buf[0] == NULL))
     {
-        vlc_va_Release(va, pic, frame->data[0]);
+        release(pic, frame->data[0]);
         return -1;
     }
 
@@ -984,14 +996,6 @@ static int lavc_va_GetFrame(struct AVCodecContext *ctx, AVFrame *frame,
     return 0;
 }
 
-static void lavc_dr_ReleaseFrame(void *opaque, uint8_t *data)
-{
-    picture_t *picture = opaque;
-
-    picture_Release(picture);
-    (void) data;
-}
-
 static picture_t *lavc_dr_GetFrame(struct AVCodecContext *ctx,
                                    AVFrame *frame, int flags)
 {
@@ -1054,11 +1058,11 @@ static picture_t *lavc_dr_GetFrame(struct AVCodecContext *ctx,
         uint8_t *data = pic->p[i].p_pixels;
         int size = pic->p[i].i_pitch * pic->p[i].i_lines;
 
-        frame->buf[i] = av_buffer_create(data, size, lavc_dr_ReleaseFrame,
+        frame->buf[i] = av_buffer_create(data, size, lavc_ReleaseFrame,
                                          picture_Hold(pic), 0);
         if (unlikely(frame->buf[i] == NULL))
         {
-            lavc_dr_ReleaseFrame(pic, data);
+            lavc_ReleaseFrame(pic, data);
             goto error;
         }
     }
diff --git a/modules/hw/vdpau/avcodec.c b/modules/hw/vdpau/avcodec.c
index b8b31c2..8022122 100644
--- a/modules/hw/vdpau/avcodec.c
+++ b/modules/hw/vdpau/avcodec.c
@@ -146,12 +146,6 @@ static int Lock(vlc_va_t *va, picture_t *pic, uint8_t **data)
     return VLC_SUCCESS;
 }
 
-static void Unlock(void *opaque, uint8_t *data)
-{
-    picture_Release(opaque);
-    (void) data;
-}
-
 static int Copy(vlc_va_t *va, picture_t *pic, uint8_t *data)
 {
     (void) va; (void) pic; (void) data;
@@ -389,7 +383,7 @@ static int Open(vlc_va_t *va, AVCodecContext *avctx, const es_format_t *fmt)
     va->pix_fmt = AV_PIX_FMT_VDPAU;
     va->setup = Setup;
     va->get = Lock;
-    va->release = Unlock;
+    va->release = NULL;
     va->extract = Copy;
     return VLC_SUCCESS;
 



More information about the vlc-commits mailing list