mirror of
https://github.com/mpv-player/mpv
synced 2025-05-08 11:10:15 +00:00
Allow to use vdpau temporal deinterlacers with hardware accelerated decoding.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28991 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
ad95e046c2
commit
115bfb9762
@ -3464,15 +3464,14 @@ No deinterlacing.
|
|||||||
.IPs 1
|
.IPs 1
|
||||||
Show only first field, similar to \-vf field.
|
Show only first field, similar to \-vf field.
|
||||||
.IPs 2
|
.IPs 2
|
||||||
Bob deinterlacing
|
Bob deinterlacing, similar to \-vf tfields=1.
|
||||||
(current fallback for advanced deinterlacers and hardware decoding).
|
|
||||||
.IPs 3
|
.IPs 3
|
||||||
Motion adaptive temporal deinterlacing
|
Motion adaptive temporal deinterlacing.
|
||||||
(currently only working with software-decoded video).
|
May lead to A/V desync with slow video hardware and/or high resolution.
|
||||||
This is the default if "D" is used to enable deinterlacing.
|
This is the default if "D" is used to enable deinterlacing.
|
||||||
.IPs 4
|
.IPs 4
|
||||||
Motion adaptive temporal deinterlacing with edge-guided spatial interpolation
|
Motion adaptive temporal deinterlacing with edge-guided spatial interpolation.
|
||||||
(currently only working with software-decoded video).
|
Needs fast video hardware.
|
||||||
.RE
|
.RE
|
||||||
.IPs chroma\-deint
|
.IPs chroma\-deint
|
||||||
Makes temporal deinterlacers operate both on luma and chroma (default).
|
Makes temporal deinterlacers operate both on luma and chroma (default).
|
||||||
|
@ -54,8 +54,6 @@
|
|||||||
|
|
||||||
// buffer type was printed (do NOT set this flag - it's for INTERNAL USE!!!)
|
// buffer type was printed (do NOT set this flag - it's for INTERNAL USE!!!)
|
||||||
#define MP_IMGFLAG_TYPE_DISPLAYED 0x8000
|
#define MP_IMGFLAG_TYPE_DISPLAYED 0x8000
|
||||||
// set if it can not be reused yet (for MP_IMGTYPE_NUMBERED)
|
|
||||||
#define MP_IMGFLAG_IN_USE 0x10000
|
|
||||||
|
|
||||||
// codec doesn't support any form of direct rendering - it has own buffer
|
// codec doesn't support any form of direct rendering - it has own buffer
|
||||||
// allocation. so we just export its buffer pointers:
|
// allocation. so we just export its buffer pointers:
|
||||||
@ -101,6 +99,7 @@ typedef struct mp_image_s {
|
|||||||
int chroma_height;
|
int chroma_height;
|
||||||
int chroma_x_shift; // horizontal
|
int chroma_x_shift; // horizontal
|
||||||
int chroma_y_shift; // vertical
|
int chroma_y_shift; // vertical
|
||||||
|
int usage_count;
|
||||||
/* for private use by filter or vo driver (to store buffer id or dmpi) */
|
/* for private use by filter or vo driver (to store buffer id or dmpi) */
|
||||||
void* priv;
|
void* priv;
|
||||||
} mp_image_t;
|
} mp_image_t;
|
||||||
|
@ -719,7 +719,7 @@ static void release_buffer(struct AVCodecContext *avctx, AVFrame *pic){
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// release mpi (in case MPI_IMGTYPE_NUMBERED is used, e.g. for VDPAU)
|
// release mpi (in case MPI_IMGTYPE_NUMBERED is used, e.g. for VDPAU)
|
||||||
mpi->flags &= ~MP_IMGFLAG_IN_USE;
|
mpi->usage_count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pic->type!=FF_BUFFER_TYPE_USER){
|
if(pic->type!=FF_BUFFER_TYPE_USER){
|
||||||
|
@ -304,7 +304,7 @@ mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype,
|
|||||||
if (number == -1) {
|
if (number == -1) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < NUM_NUMBERED_MPI; i++)
|
for (i = 0; i < NUM_NUMBERED_MPI; i++)
|
||||||
if (!vf->imgctx.numbered_images[i] || !(vf->imgctx.numbered_images[i]->flags & MP_IMGFLAG_IN_USE))
|
if (!vf->imgctx.numbered_images[i] || !vf->imgctx.numbered_images[i]->usage_count)
|
||||||
break;
|
break;
|
||||||
number = i;
|
number = i;
|
||||||
}
|
}
|
||||||
@ -431,7 +431,7 @@ mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype,
|
|||||||
|
|
||||||
mpi->qscale = NULL;
|
mpi->qscale = NULL;
|
||||||
}
|
}
|
||||||
mpi->flags |= MP_IMGFLAG_IN_USE;
|
mpi->usage_count++;
|
||||||
// printf("\rVF_MPI: %p %p %p %d %d %d \n",
|
// printf("\rVF_MPI: %p %p %p %d %d %d \n",
|
||||||
// mpi->planes[0],mpi->planes[1],mpi->planes[2],
|
// mpi->planes[0],mpi->planes[1],mpi->planes[2],
|
||||||
// mpi->stride[0],mpi->stride[1],mpi->stride[2]);
|
// mpi->stride[0],mpi->stride[1],mpi->stride[2]);
|
||||||
|
@ -148,12 +148,14 @@ static void *vdpau_lib_handle;
|
|||||||
#define osd_surface output_surfaces[NUM_OUTPUT_SURFACES]
|
#define osd_surface output_surfaces[NUM_OUTPUT_SURFACES]
|
||||||
static VdpOutputSurface output_surfaces[NUM_OUTPUT_SURFACES + 1];
|
static VdpOutputSurface output_surfaces[NUM_OUTPUT_SURFACES + 1];
|
||||||
static VdpVideoSurface deint_surfaces[3];
|
static VdpVideoSurface deint_surfaces[3];
|
||||||
|
static mp_image_t *deint_mpi[3];
|
||||||
static int output_surface_width, output_surface_height;
|
static int output_surface_width, output_surface_height;
|
||||||
|
|
||||||
static VdpVideoMixer video_mixer;
|
static VdpVideoMixer video_mixer;
|
||||||
static int deint;
|
static int deint;
|
||||||
static int deint_type;
|
static int deint_type;
|
||||||
static int deint_counter;
|
static int deint_counter;
|
||||||
|
static int deint_buffer_past_frames;
|
||||||
static int pullup;
|
static int pullup;
|
||||||
static float denoise;
|
static float denoise;
|
||||||
static float sharpen;
|
static float sharpen;
|
||||||
@ -456,6 +458,12 @@ static void free_video_specific(void) {
|
|||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
deint_surfaces[i] = VDP_INVALID_HANDLE;
|
deint_surfaces[i] = VDP_INVALID_HANDLE;
|
||||||
|
|
||||||
|
for (i = 0; i < 3; i++)
|
||||||
|
if (deint_mpi[i]) {
|
||||||
|
deint_mpi[i]->usage_count--;
|
||||||
|
deint_mpi[i] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < MAX_VIDEO_SURFACES; i++) {
|
for (i = 0; i < MAX_VIDEO_SURFACES; i++) {
|
||||||
if (surface_render[i].surface != VDP_INVALID_HANDLE) {
|
if (surface_render[i].surface != VDP_INVALID_HANDLE) {
|
||||||
vdp_st = vdp_video_surface_destroy(surface_render[i].surface);
|
vdp_st = vdp_video_surface_destroy(surface_render[i].surface);
|
||||||
@ -848,7 +856,14 @@ static uint32_t draw_image(mp_image_t *mpi)
|
|||||||
if (IMGFMT_IS_VDPAU(image_format)) {
|
if (IMGFMT_IS_VDPAU(image_format)) {
|
||||||
struct vdpau_render_state *rndr = mpi->priv;
|
struct vdpau_render_state *rndr = mpi->priv;
|
||||||
vid_surface_num = rndr - surface_render;
|
vid_surface_num = rndr - surface_render;
|
||||||
deint = FFMIN(deint, 2);
|
if (deint_buffer_past_frames) {
|
||||||
|
mpi->usage_count++;
|
||||||
|
if (deint_mpi[2])
|
||||||
|
deint_mpi[2]->usage_count--;
|
||||||
|
deint_mpi[2] = deint_mpi[1];
|
||||||
|
deint_mpi[1] = deint_mpi[0];
|
||||||
|
deint_mpi[0] = mpi;
|
||||||
|
}
|
||||||
} else if (!(mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)) {
|
} else if (!(mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)) {
|
||||||
VdpStatus vdp_st;
|
VdpStatus vdp_st;
|
||||||
void *destdata[3] = {mpi->planes[0], mpi->planes[2], mpi->planes[1]};
|
void *destdata[3] = {mpi->planes[0], mpi->planes[2], mpi->planes[1]};
|
||||||
@ -984,9 +999,9 @@ static const char help_msg[] =
|
|||||||
" deint (all modes > 0 respect -field-dominance)\n"
|
" deint (all modes > 0 respect -field-dominance)\n"
|
||||||
" 0: no deinterlacing\n"
|
" 0: no deinterlacing\n"
|
||||||
" 1: only show first field\n"
|
" 1: only show first field\n"
|
||||||
" 2: bob deinterlacing (current fallback for hardware decoding)\n"
|
" 2: bob deinterlacing\n"
|
||||||
" 3: temporal deinterlacing (only works with software codecs)\n"
|
" 3: temporal deinterlacing (resource-hungry)\n"
|
||||||
" 4: temporal-spatial deinterlacing (only works with software codecs)\n"
|
" 4: temporal-spatial deinterlacing (very resource-hungry)\n"
|
||||||
" chroma-deint\n"
|
" chroma-deint\n"
|
||||||
" Operate on luma and chroma when using temporal deinterlacing (default)\n"
|
" Operate on luma and chroma when using temporal deinterlacing (default)\n"
|
||||||
" Use nochroma-deint to speed up temporal deinterlacing\n"
|
" Use nochroma-deint to speed up temporal deinterlacing\n"
|
||||||
@ -1007,6 +1022,8 @@ static int preinit(const char *arg)
|
|||||||
deint = 0;
|
deint = 0;
|
||||||
deint_type = 3;
|
deint_type = 3;
|
||||||
deint_counter = 0;
|
deint_counter = 0;
|
||||||
|
deint_buffer_past_frames = 0;
|
||||||
|
deint_mpi[0] = deint_mpi[1] = deint_mpi[2] = NULL;
|
||||||
chroma_deint = 1;
|
chroma_deint = 1;
|
||||||
pullup = 0;
|
pullup = 0;
|
||||||
denoise = 0;
|
denoise = 0;
|
||||||
@ -1017,6 +1034,8 @@ static int preinit(const char *arg)
|
|||||||
}
|
}
|
||||||
if (deint)
|
if (deint)
|
||||||
deint_type = deint;
|
deint_type = deint;
|
||||||
|
if (deint > 2)
|
||||||
|
deint_buffer_past_frames = 1;
|
||||||
|
|
||||||
vdpau_lib_handle = dlopen(vdpaulibrary, RTLD_LAZY);
|
vdpau_lib_handle = dlopen(vdpaulibrary, RTLD_LAZY);
|
||||||
if (!vdpau_lib_handle) {
|
if (!vdpau_lib_handle) {
|
||||||
@ -1122,6 +1141,7 @@ static int control(uint32_t request, void *data, ...)
|
|||||||
features,
|
features,
|
||||||
feature_enables);
|
feature_enables);
|
||||||
CHECK_ST_WARNING("Error changing deinterlacing settings")
|
CHECK_ST_WARNING("Error changing deinterlacing settings")
|
||||||
|
deint_buffer_past_frames = 1;
|
||||||
}
|
}
|
||||||
return VO_TRUE;
|
return VO_TRUE;
|
||||||
case VOCTRL_PAUSE:
|
case VOCTRL_PAUSE:
|
||||||
|
Loading…
Reference in New Issue
Block a user