comparison libmpcodecs/vd_ffmpeg.c @ 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
comparison
equal deleted inserted replaced
28552:d7e1fd202d85 28553:81931c7c0cf3
60 60
61 #if CONFIG_XVMC 61 #if CONFIG_XVMC
62 static enum PixelFormat get_format(struct AVCodecContext *avctx, 62 static enum PixelFormat get_format(struct AVCodecContext *avctx,
63 const enum PixelFormat *pix_fmt); 63 const enum PixelFormat *pix_fmt);
64 static int mc_get_buffer(AVCodecContext *avctx, AVFrame *pic); 64 static int mc_get_buffer(AVCodecContext *avctx, AVFrame *pic);
65 static void mc_release_buffer(AVCodecContext *avctx, AVFrame *pic);
66 #endif 65 #endif
67 66
68 static int lavc_param_workaround_bugs= FF_BUG_AUTODETECT; 67 static int lavc_param_workaround_bugs= FF_BUG_AUTODETECT;
69 static int lavc_param_error_resilience=2; 68 static int lavc_param_error_resilience=2;
70 static int lavc_param_error_concealment=3; 69 static int lavc_param_error_concealment=3;
250 assert(ctx->do_dr1);//these are must to! 249 assert(ctx->do_dr1);//these are must to!
251 assert(ctx->do_slices); //it is (vo_)ffmpeg bug if this fails 250 assert(ctx->do_slices); //it is (vo_)ffmpeg bug if this fails
252 avctx->flags|= CODEC_FLAG_EMU_EDGE;//do i need that??!! 251 avctx->flags|= CODEC_FLAG_EMU_EDGE;//do i need that??!!
253 avctx->get_format= get_format;//for now only this decoder will use it 252 avctx->get_format= get_format;//for now only this decoder will use it
254 avctx->get_buffer= mc_get_buffer; 253 avctx->get_buffer= mc_get_buffer;
255 avctx->release_buffer= mc_release_buffer; 254 avctx->release_buffer= release_buffer;
256 avctx->draw_horiz_band = draw_slice; 255 avctx->draw_horiz_band = draw_slice;
257 avctx->slice_flags=SLICE_FLAG_CODED_ORDER|SLICE_FLAG_ALLOW_FIELD; 256 avctx->slice_flags=SLICE_FLAG_CODED_ORDER|SLICE_FLAG_ALLOW_FIELD;
258 }else 257 }else
259 #endif /* CONFIG_XVMC */ 258 #endif /* CONFIG_XVMC */
260 if(ctx->do_dr1){ 259 if(ctx->do_dr1){
655 } 654 }
656 655
657 // Palette support: free palette buffer allocated in get_buffer 656 // Palette support: free palette buffer allocated in get_buffer
658 if (mpi && (mpi->bpp == 8)) 657 if (mpi && (mpi->bpp == 8))
659 av_freep(&mpi->planes[1]); 658 av_freep(&mpi->planes[1]);
659 #if CONFIG_XVMC
660 if (mpi) {
661 if (IMGFMT_IS_XVMC(mpi->imgfmt)) {
662 struct xvmc_pixfmt_render *render = (struct xvmc_pixfmt_render *)pic->data[2];//same as mpi->priv
663 if(mp_msg_test(MSGT_DECVIDEO, MSGL_DBG5))
664 mp_msg(MSGT_DECVIDEO, MSGL_DBG5, "vd_ffmpeg::release_buffer (xvmc render=%p)\n", render);
665 assert(render!=NULL);
666 assert(render->magic_id==AV_XVMC_RENDER_MAGIC);
667 render->state&=~AV_XVMC_STATE_PREDICTION;
668 }
669 }
670 #endif
660 671
661 if(pic->type!=FF_BUFFER_TYPE_USER){ 672 if(pic->type!=FF_BUFFER_TYPE_USER){
662 avcodec_default_release_buffer(avctx, pic); 673 avcodec_default_release_buffer(avctx, pic);
663 return; 674 return;
664 } 675 }
853 int i; 864 int i;
854 865
855 if(avctx->xvmc_acceleration){ 866 if(avctx->xvmc_acceleration){
856 vd_ffmpeg_ctx *ctx = sh->context; 867 vd_ffmpeg_ctx *ctx = sh->context;
857 avctx->get_buffer= mc_get_buffer; 868 avctx->get_buffer= mc_get_buffer;
858 avctx->release_buffer= mc_release_buffer; 869 avctx->release_buffer= release_buffer;
859 avctx->draw_horiz_band = draw_slice; 870 avctx->draw_horiz_band = draw_slice;
860 mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_XVMCAcceleratedMPEG2); 871 mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_XVMCAcceleratedMPEG2);
861 assert(ctx->do_dr1);//these are must to! 872 assert(ctx->do_dr1);//these are must to!
862 assert(ctx->do_slices); //it is (vo_)ffmpeg bug if this fails 873 assert(ctx->do_slices); //it is (vo_)ffmpeg bug if this fails
863 avctx->flags|= CODEC_FLAG_EMU_EDGE;//do i need that??!! 874 avctx->flags|= CODEC_FLAG_EMU_EDGE;//do i need that??!!
884 mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_McGetBufferShouldWorkOnlyWithXVMC); 895 mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_McGetBufferShouldWorkOnlyWithXVMC);
885 assert(0); 896 assert(0);
886 exit(1); 897 exit(1);
887 // return -1;//!!fixme check error conditions 898 // return -1;//!!fixme check error conditions
888 } 899 }
889 assert(avctx->release_buffer == mc_release_buffer);
890 if(mp_msg_test(MSGT_DECVIDEO, MSGL_DBG5)) 900 if(mp_msg_test(MSGT_DECVIDEO, MSGL_DBG5))
891 mp_msg(MSGT_DECVIDEO, MSGL_DBG5, "vd_ffmpeg::mc_get_buffer\n"); 901 mp_msg(MSGT_DECVIDEO, MSGL_DBG5, "vd_ffmpeg::mc_get_buffer\n");
892 902
893 if(init_vo(sh, avctx->pix_fmt) < 0){ 903 if(init_vo(sh, avctx->pix_fmt) < 0){
894 mp_msg(MSGT_DECVIDEO, MSGL_WARN, MSGTR_MPCODECS_UnexpectedInitVoError); 904 mp_msg(MSGT_DECVIDEO, MSGL_WARN, MSGTR_MPCODECS_UnexpectedInitVoError);
960 assert(render->magic_id == AV_XVMC_RENDER_MAGIC); 970 assert(render->magic_id == AV_XVMC_RENDER_MAGIC);
961 render->state |= AV_XVMC_STATE_PREDICTION; 971 render->state |= AV_XVMC_STATE_PREDICTION;
962 return 0; 972 return 0;
963 } 973 }
964 974
965
966 static void mc_release_buffer(AVCodecContext *avctx, AVFrame *pic){
967 mp_image_t *mpi= pic->opaque;
968 sh_video_t *sh = avctx->opaque;
969 vd_ffmpeg_ctx *ctx = sh->context;
970 struct xvmc_pixfmt_render *render;
971 int i;
972
973
974 if(ctx->ip_count <= 2 && ctx->b_count<=1){
975 if(mpi->flags&MP_IMGFLAG_PRESERVE)
976 ctx->ip_count--;
977 else
978 ctx->b_count--;
979 }
980
981 //printf("R%X %X\n", pic->linesize[0], pic->data[0]);
982 //mark the surface as not requared for prediction
983 render=(struct xvmc_pixfmt_render *)pic->data[2];//same as mpi->priv
984 if(mp_msg_test(MSGT_DECVIDEO, MSGL_DBG5))
985 mp_msg(MSGT_DECVIDEO, MSGL_DBG5, "vd_ffmpeg::mc_release_buffer (render=%p)\n", render);
986 assert(render!=NULL);
987 assert(render->magic_id==AV_XVMC_RENDER_MAGIC);
988 render->state&=~AV_XVMC_STATE_PREDICTION;
989 for(i=0; i<4; i++){
990 pic->data[i]= NULL;
991 }
992 }
993
994 #endif /* CONFIG_XVMC */ 975 #endif /* CONFIG_XVMC */