[FFmpeg-cvslog] vdpau: factor out common end-of-frame handling

Rémi Denis-Courmont git at videolan.org
Mon Oct 6 12:20:46 CEST 2014


ffmpeg | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Oct  4 16:55:03 2014 +0300| [fcc1022611f79c2f3aa2f392a5ce14c74be9c1d7] | committer: Anton Khirnov

vdpau: factor out common end-of-frame handling

Also add error handling.

Signed-off-by: Anton Khirnov <anton at khirnov.net>

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

 libavcodec/vdpau.c          |   25 +++++++++++++++++++------
 libavcodec/vdpau_h264.c     |   10 ++++------
 libavcodec/vdpau_internal.h |    2 ++
 3 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c
index 581eada..0a4b796 100644
--- a/libavcodec/vdpau.c
+++ b/libavcodec/vdpau.c
@@ -72,23 +72,36 @@ int ff_vdpau_common_start_frame(struct vdpau_picture_context *pic_ctx,
     return 0;
 }
 
+int ff_vdpau_common_end_frame(AVCodecContext *avctx, AVFrame *frame,
+                              struct vdpau_picture_context *pic_ctx)
+{
+    AVVDPAUContext *hwctx = avctx->hwaccel_context;
+    VdpVideoSurface surf = ff_vdpau_get_surface_id(frame);
+    VdpStatus status;
+
+    status = hwctx->render(hwctx->decoder, surf, (void *)&pic_ctx->info,
+                           pic_ctx->bitstream_buffers_used,
+                           pic_ctx->bitstream_buffers);
+
+    av_freep(&pic_ctx->bitstream_buffers);
+    return vdpau_error(status);
+}
+
 #if CONFIG_H263_VDPAU_HWACCEL  || CONFIG_MPEG1_VDPAU_HWACCEL || \
     CONFIG_MPEG2_VDPAU_HWACCEL || CONFIG_MPEG4_VDPAU_HWACCEL || \
     CONFIG_VC1_VDPAU_HWACCEL   || CONFIG_WMV3_VDPAU_HWACCEL
 int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx)
 {
-    AVVDPAUContext *hwctx = avctx->hwaccel_context;
     MpegEncContext *s = avctx->priv_data;
     Picture *pic = s->current_picture_ptr;
     struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
-    VdpVideoSurface surf = ff_vdpau_get_surface_id(pic->f);
+    int val;
 
-    hwctx->render(hwctx->decoder, surf, (void *)&pic_ctx->info,
-                  pic_ctx->bitstream_buffers_used, pic_ctx->bitstream_buffers);
+    val = ff_vdpau_common_end_frame(avctx, pic->f, pic_ctx);
+    if (val < 0)
+        return val;
 
     ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
-    av_freep(&pic_ctx->bitstream_buffers);
-
     return 0;
 }
 #endif
diff --git a/libavcodec/vdpau_h264.c b/libavcodec/vdpau_h264.c
index 32e9c28..838a670 100644
--- a/libavcodec/vdpau_h264.c
+++ b/libavcodec/vdpau_h264.c
@@ -189,18 +189,16 @@ static int vdpau_h264_decode_slice(AVCodecContext *avctx,
 
 static int vdpau_h264_end_frame(AVCodecContext *avctx)
 {
-    AVVDPAUContext *hwctx = avctx->hwaccel_context;
     H264Context *h = avctx->priv_data;
     H264Picture *pic = h->cur_pic_ptr;
     struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
-    VdpVideoSurface surf = ff_vdpau_get_surface_id(&pic->f);
+    int val;
 
-    hwctx->render(hwctx->decoder, surf, (void *)&pic_ctx->info,
-                  pic_ctx->bitstream_buffers_used, pic_ctx->bitstream_buffers);
+    val = ff_vdpau_common_end_frame(avctx, &pic->f, pic_ctx);
+    if (val < 0)
+        return val;
 
     ff_h264_draw_horiz_band(h, 0, h->avctx->height);
-    av_freep(&pic_ctx->bitstream_buffers);
-
     return 0;
 }
 
diff --git a/libavcodec/vdpau_internal.h b/libavcodec/vdpau_internal.h
index 2443e0a..3f55ee7 100644
--- a/libavcodec/vdpau_internal.h
+++ b/libavcodec/vdpau_internal.h
@@ -72,6 +72,8 @@ struct vdpau_picture_context {
 
 int ff_vdpau_common_start_frame(struct vdpau_picture_context *pic,
                                 const uint8_t *buffer, uint32_t size);
+int ff_vdpau_common_end_frame(AVCodecContext *avctx, AVFrame *frame,
+                              struct vdpau_picture_context *pic);
 int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx);
 int ff_vdpau_add_buffer(struct vdpau_picture_context *pic, const uint8_t *buf,
                         uint32_t buf_size);



More information about the ffmpeg-cvslog mailing list