From 64ae9a368e12b9f428287c0b38e3cd5d1798c27e Mon Sep 17 00:00:00 2001 From: jojo61 Date: Mon, 27 Aug 2018 16:54:44 +0200 Subject: [PATCH] deinterlace fpr mpeg2 is broken --- codec.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/codec.c b/codec.c index 2cc826e..932cf72 100644 --- a/codec.c +++ b/codec.c @@ -313,16 +313,26 @@ void CodecVideoOpen(VideoDecoder * decoder, int codec_id) pthread_mutex_lock(&CodecLockMutex); // open codec - - if (av_opt_set_int(decoder->VideoCtx->priv_data, "deint", 2 ,0) < 0) { - pthread_mutex_unlock(&CodecLockMutex); - Fatal(_("codec: can't set option deint to video codec!\n")); - } - - if (av_opt_set(decoder->VideoCtx->priv_data, "drop_second_field", "false" ,0) < 0) { - pthread_mutex_unlock(&CodecLockMutex); - Fatal(_("codec: can't set option drop 2.field to video codec!\n")); - } + if (name && strcmp(name,"mpeg2_cuvid") == 0) { // deinterlace for mpeg2 is somehow broken + if (av_opt_set_int(decoder->VideoCtx->priv_data, "deint", 0 ,0) < 0) { // weave + pthread_mutex_unlock(&CodecLockMutex); + Fatal(_("codec: can't set option deint to video codec!\n")); + } + if (av_opt_set(decoder->VideoCtx->priv_data, "drop_second_field", "false" ,0) < 0) { + pthread_mutex_unlock(&CodecLockMutex); + Fatal(_("codec: can't set option drop 2.field to video codec!\n")); + } + } + else { + if (av_opt_set_int(decoder->VideoCtx->priv_data, "deint", 2 ,0) < 0) { // adaptive + pthread_mutex_unlock(&CodecLockMutex); + Fatal(_("codec: can't set option deint to video codec!\n")); + } + if (av_opt_set(decoder->VideoCtx->priv_data, "drop_second_field", "false" ,0) < 0) { + pthread_mutex_unlock(&CodecLockMutex); + Fatal(_("codec: can't set option drop 2.field to video codec!\n")); + } + } if ((ret = avcodec_open2(decoder->VideoCtx, video_codec, NULL)) < 0) {