changeset 28553:81931c7c0cf3

Make the default release_buffer work for XvMC, use it and remove mc_release_buffer
author reimar
date Sun, 15 Feb 2009 13:14:17 +0000
parents d7e1fd202d85
children 36fbf025f4da
files libmpcodecs/vd_ffmpeg.c
diffstat 1 files changed, 14 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vd_ffmpeg.c	Sun Feb 15 13:04:57 2009 +0000
+++ b/libmpcodecs/vd_ffmpeg.c	Sun Feb 15 13:14:17 2009 +0000
@@ -62,7 +62,6 @@
 static enum PixelFormat get_format(struct AVCodecContext *avctx,
                                    const enum PixelFormat *pix_fmt);
 static int mc_get_buffer(AVCodecContext *avctx, AVFrame *pic);
-static void mc_release_buffer(AVCodecContext *avctx, AVFrame *pic);
 #endif
 
 static int lavc_param_workaround_bugs= FF_BUG_AUTODETECT;
@@ -252,7 +251,7 @@
         avctx->flags|= CODEC_FLAG_EMU_EDGE;//do i need that??!!
         avctx->get_format= get_format;//for now only this decoder will use it
         avctx->get_buffer= mc_get_buffer;
-        avctx->release_buffer= mc_release_buffer;
+        avctx->release_buffer= release_buffer;
         avctx->draw_horiz_band = draw_slice;
         avctx->slice_flags=SLICE_FLAG_CODED_ORDER|SLICE_FLAG_ALLOW_FIELD;
     }else
@@ -657,6 +656,18 @@
     // Palette support: free palette buffer allocated in get_buffer
     if (mpi && (mpi->bpp == 8))
         av_freep(&mpi->planes[1]);
+#if CONFIG_XVMC
+    if (mpi) {
+        if (IMGFMT_IS_XVMC(mpi->imgfmt)) {
+            struct xvmc_pixfmt_render *render = (struct xvmc_pixfmt_render *)pic->data[2];//same as mpi->priv
+            if(mp_msg_test(MSGT_DECVIDEO, MSGL_DBG5))
+                mp_msg(MSGT_DECVIDEO, MSGL_DBG5, "vd_ffmpeg::release_buffer (xvmc render=%p)\n", render);
+            assert(render!=NULL);
+            assert(render->magic_id==AV_XVMC_RENDER_MAGIC);
+            render->state&=~AV_XVMC_STATE_PREDICTION;
+        }
+    }
+#endif
 
     if(pic->type!=FF_BUFFER_TYPE_USER){
         avcodec_default_release_buffer(avctx, pic);
@@ -855,7 +866,7 @@
     if(avctx->xvmc_acceleration){
         vd_ffmpeg_ctx *ctx = sh->context;
         avctx->get_buffer= mc_get_buffer;
-        avctx->release_buffer= mc_release_buffer;
+        avctx->release_buffer= release_buffer;
         avctx->draw_horiz_band = draw_slice;
         mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_XVMCAcceleratedMPEG2);
         assert(ctx->do_dr1);//these are must to!
@@ -886,7 +897,6 @@
         exit(1);
 //        return -1;//!!fixme check error conditions
     }
-    assert(avctx->release_buffer == mc_release_buffer);
     if(mp_msg_test(MSGT_DECVIDEO, MSGL_DBG5))
         mp_msg(MSGT_DECVIDEO, MSGL_DBG5, "vd_ffmpeg::mc_get_buffer\n");
 
@@ -962,33 +972,4 @@
     return 0;
 }
 
-
-static void mc_release_buffer(AVCodecContext *avctx, AVFrame *pic){
-    mp_image_t *mpi= pic->opaque;
-    sh_video_t *sh = avctx->opaque;
-    vd_ffmpeg_ctx *ctx = sh->context;
-    struct xvmc_pixfmt_render *render;
-    int i;
-
-
-    if(ctx->ip_count <= 2 && ctx->b_count<=1){
-        if(mpi->flags&MP_IMGFLAG_PRESERVE)
-            ctx->ip_count--;
-        else
-            ctx->b_count--;
-    }
-
-//printf("R%X %X\n", pic->linesize[0], pic->data[0]);
-//mark the surface as not requared for prediction
-    render=(struct xvmc_pixfmt_render *)pic->data[2];//same as mpi->priv
-    if(mp_msg_test(MSGT_DECVIDEO, MSGL_DBG5))
-        mp_msg(MSGT_DECVIDEO, MSGL_DBG5, "vd_ffmpeg::mc_release_buffer (render=%p)\n", render);
-    assert(render!=NULL);
-    assert(render->magic_id==AV_XVMC_RENDER_MAGIC);
-    render->state&=~AV_XVMC_STATE_PREDICTION;
-    for(i=0; i<4; i++){
-        pic->data[i]= NULL;
-    }
-}
-
 #endif /* CONFIG_XVMC */