Mercurial > mplayer.hg
comparison libmpcodecs/vd_ffmpeg.c @ 28582:4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
author | reimar |
---|---|
date | Mon, 16 Feb 2009 20:58:13 +0000 |
parents | 67d2779b13ec |
children | 239a2ceda4ff |
comparison
equal
deleted
inserted
replaced
28581:0403c0f4c7e1 | 28582:4d64f83e2fac |
---|---|
230 if(vd_use_slices && (lavc_codec->capabilities&CODEC_CAP_DRAW_HORIZ_BAND) && !do_vis_debug) | 230 if(vd_use_slices && (lavc_codec->capabilities&CODEC_CAP_DRAW_HORIZ_BAND) && !do_vis_debug) |
231 ctx->do_slices=1; | 231 ctx->do_slices=1; |
232 | 232 |
233 if(lavc_codec->capabilities&CODEC_CAP_DR1 && !do_vis_debug && lavc_codec->id != CODEC_ID_H264 && lavc_codec->id != CODEC_ID_INTERPLAY_VIDEO && lavc_codec->id != CODEC_ID_ROQ) | 233 if(lavc_codec->capabilities&CODEC_CAP_DR1 && !do_vis_debug && lavc_codec->id != CODEC_ID_H264 && lavc_codec->id != CODEC_ID_INTERPLAY_VIDEO && lavc_codec->id != CODEC_ID_ROQ) |
234 ctx->do_dr1=1; | 234 ctx->do_dr1=1; |
235 if (lavc_codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) | |
236 ctx->do_dr1=1; | |
235 ctx->b_age= ctx->ip_age[0]= ctx->ip_age[1]= 256*256*256*64; | 237 ctx->b_age= ctx->ip_age[0]= ctx->ip_age[1]= 256*256*256*64; |
236 ctx->ip_count= ctx->b_count= 0; | 238 ctx->ip_count= ctx->b_count= 0; |
237 | 239 |
238 ctx->pic = avcodec_alloc_frame(); | 240 ctx->pic = avcodec_alloc_frame(); |
239 ctx->avctx = avcodec_alloc_context(); | 241 ctx->avctx = avcodec_alloc_context(); |
240 avctx = ctx->avctx; | 242 avctx = ctx->avctx; |
241 | 243 |
244 #if CONFIG_VDPAU | |
245 if(lavc_codec->capabilities & CODEC_CAP_HWACCEL_VDPAU){ | |
246 avctx->get_format = get_format; | |
247 avctx->draw_horiz_band = draw_slice; | |
248 avctx->slice_flags = SLICE_FLAG_CODED_ORDER|SLICE_FLAG_ALLOW_FIELD; | |
249 } | |
250 #endif /* CONFIG_VDPAU */ | |
242 #if CONFIG_XVMC | 251 #if CONFIG_XVMC |
243 | 252 |
244 if(lavc_codec->capabilities & CODEC_CAP_HWACCEL){ | 253 if(lavc_codec->capabilities & CODEC_CAP_HWACCEL){ |
245 mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_XVMCAcceleratedCodec); | 254 mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_XVMCAcceleratedCodec); |
246 assert(ctx->do_dr1);//these are must to! | 255 assert(ctx->do_dr1);//these are must to! |
543 avctx->release_buffer= avcodec_default_release_buffer; | 552 avctx->release_buffer= avcodec_default_release_buffer; |
544 avctx->get_buffer= avcodec_default_get_buffer; | 553 avctx->get_buffer= avcodec_default_get_buffer; |
545 return avctx->get_buffer(avctx, pic); | 554 return avctx->get_buffer(avctx, pic); |
546 } | 555 } |
547 | 556 |
548 if (IMGFMT_IS_XVMC(ctx->best_csp)) { | 557 if (IMGFMT_IS_XVMC(ctx->best_csp) || IMGFMT_IS_VDPAU(ctx->best_csp)) { |
549 type = MP_IMGTYPE_NUMBERED | (0xffff << 16); | 558 type = MP_IMGTYPE_NUMBERED | (0xffff << 16); |
550 } else | 559 } else |
551 if (!pic->buffer_hints) { | 560 if (!pic->buffer_hints) { |
552 if(ctx->b_count>1 || ctx->ip_count>2){ | 561 if(ctx->b_count>1 || ctx->ip_count>2){ |
553 mp_msg(MSGT_DECVIDEO, MSGL_WARN, MSGTR_MPCODECS_DRIFailure); | 562 mp_msg(MSGT_DECVIDEO, MSGL_WARN, MSGTR_MPCODECS_DRIFailure); |
573 !(mpi->flags&MP_IMGFLAG_DIRECT)){ | 582 !(mpi->flags&MP_IMGFLAG_DIRECT)){ |
574 // nice, filter/vo likes draw_callback :) | 583 // nice, filter/vo likes draw_callback :) |
575 avctx->draw_horiz_band= draw_slice; | 584 avctx->draw_horiz_band= draw_slice; |
576 } else | 585 } else |
577 avctx->draw_horiz_band= NULL; | 586 avctx->draw_horiz_band= NULL; |
587 if(IMGFMT_IS_VDPAU(mpi->imgfmt)) { | |
588 avctx->draw_horiz_band= draw_slice; | |
589 } | |
578 #if CONFIG_XVMC | 590 #if CONFIG_XVMC |
579 if(IMGFMT_IS_XVMC(mpi->imgfmt)) { | 591 if(IMGFMT_IS_XVMC(mpi->imgfmt)) { |
580 struct xvmc_pix_fmt *render = mpi->priv; //same as data[2] | 592 struct xvmc_pix_fmt *render = mpi->priv; //same as data[2] |
581 avctx->draw_horiz_band= draw_slice; | 593 avctx->draw_horiz_band= draw_slice; |
582 if(!avctx->xvmc_acceleration) { | 594 if(!avctx->xvmc_acceleration) { |
877 if(pic->repeat_pict == 1) mpi->fields |= MP_IMGFIELD_REPEAT_FIRST; | 889 if(pic->repeat_pict == 1) mpi->fields |= MP_IMGFIELD_REPEAT_FIRST; |
878 | 890 |
879 return mpi; | 891 return mpi; |
880 } | 892 } |
881 | 893 |
882 #if CONFIG_XVMC | 894 #if CONFIG_XVMC || CONFIG_VDPAU |
883 static enum PixelFormat get_format(struct AVCodecContext *avctx, | 895 static enum PixelFormat get_format(struct AVCodecContext *avctx, |
884 const enum PixelFormat *fmt){ | 896 const enum PixelFormat *fmt){ |
885 enum PixelFormat selected_format = fmt[0]; | 897 enum PixelFormat selected_format = fmt[0]; |
886 int imgfmt; | 898 int imgfmt; |
887 sh_video_t *sh = avctx->opaque; | 899 sh_video_t *sh = avctx->opaque; |
888 int i; | 900 int i; |
889 | 901 |
890 for(i=0;fmt[i]!=PIX_FMT_NONE;i++){ | 902 for(i=0;fmt[i]!=PIX_FMT_NONE;i++){ |
891 imgfmt = pixfmt2imgfmt(fmt[i]); | 903 imgfmt = pixfmt2imgfmt(fmt[i]); |
892 if(!IMGFMT_IS_XVMC(imgfmt)) continue; | 904 if(!IMGFMT_IS_XVMC(imgfmt) && !IMGFMT_IS_VDPAU(imgfmt)) continue; |
893 mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_TryingPixfmt, i); | 905 mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_TryingPixfmt, i); |
894 if(init_vo(sh, fmt[i]) >= 0) { | 906 if(init_vo(sh, fmt[i]) >= 0) { |
895 selected_format = fmt[i]; | 907 selected_format = fmt[i]; |
896 break; | 908 break; |
897 } | 909 } |
898 } | 910 } |
899 imgfmt = pixfmt2imgfmt(selected_format); | 911 imgfmt = pixfmt2imgfmt(selected_format); |
900 if(IMGFMT_IS_XVMC(imgfmt)) { | 912 if(IMGFMT_IS_XVMC(imgfmt) || IMGFMT_IS_VDPAU(imgfmt)) { |
901 vd_ffmpeg_ctx *ctx = sh->context; | 913 vd_ffmpeg_ctx *ctx = sh->context; |
902 avctx->get_buffer= get_buffer; | 914 avctx->get_buffer= get_buffer; |
903 avctx->release_buffer= release_buffer; | 915 avctx->release_buffer= release_buffer; |
904 avctx->draw_horiz_band = draw_slice; | 916 avctx->draw_horiz_band = draw_slice; |
905 mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_XVMCAcceleratedMPEG2); | 917 mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_XVMCAcceleratedMPEG2); |