1
0
mirror of https://github.com/jojo61/vdr-plugin-softhdcuvid.git synced 2023-10-10 13:37:41 +02:00

fixed SD video

This commit is contained in:
jojo61 2018-08-31 10:19:34 +02:00
parent 64ae9a368e
commit 137e85a412
3 changed files with 149 additions and 152 deletions

14
codec.c
View File

@ -307,17 +307,21 @@ void CodecVideoOpen(VideoDecoder * decoder, int codec_id)
decoder->VideoCtx->pkt_timebase.num = 1; decoder->VideoCtx->pkt_timebase.num = 1;
decoder->VideoCtx->pkt_timebase.den = 90000; decoder->VideoCtx->pkt_timebase.den = 90000;
decoder->VideoCtx->framerate.num = 25; decoder->VideoCtx->framerate.num = 50;
decoder->VideoCtx->framerate.den = 1; decoder->VideoCtx->framerate.den = 1;
pthread_mutex_lock(&CodecLockMutex); pthread_mutex_lock(&CodecLockMutex);
// open codec // open codec
if (name && strcmp(name,"mpeg2_cuvid") == 0) { // deinterlace for mpeg2 is somehow broken 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 if (av_opt_set_int(decoder->VideoCtx->priv_data, "deint", 2 ,0) < 0) { // weave
pthread_mutex_unlock(&CodecLockMutex); pthread_mutex_unlock(&CodecLockMutex);
Fatal(_("codec: can't set option deint to video codec!\n")); Fatal(_("codec: can't set option deint to video codec!\n"));
} }
if (av_opt_set_int(decoder->VideoCtx->priv_data, "surfaces", 15 ,0) < 0) {
pthread_mutex_unlock(&CodecLockMutex);
Fatal(_("codec: can't set option surfces to video codec!\n"));
}
if (av_opt_set(decoder->VideoCtx->priv_data, "drop_second_field", "false" ,0) < 0) { if (av_opt_set(decoder->VideoCtx->priv_data, "drop_second_field", "false" ,0) < 0) {
pthread_mutex_unlock(&CodecLockMutex); pthread_mutex_unlock(&CodecLockMutex);
Fatal(_("codec: can't set option drop 2.field to video codec!\n")); Fatal(_("codec: can't set option drop 2.field to video codec!\n"));
@ -456,12 +460,12 @@ void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
int consumed = 0; int consumed = 0;
AVPacket *pkt; AVPacket *pkt;
static uint64_t last_time = 0; static uint64_t last_time = 0;
static uint64_t lastpts = 0;
next_part: next_part:
video_ctx = decoder->VideoCtx; video_ctx = decoder->VideoCtx;
frame = decoder->Frame; frame = decoder->Frame;
pkt = avpkt; // use copy pkt = avpkt; // use copy
got_frame = 0; got_frame = 0;
ret1 = avcodec_send_packet(video_ctx, pkt); ret1 = avcodec_send_packet(video_ctx, pkt);
@ -475,8 +479,6 @@ next_part:
ret = avcodec_receive_frame(video_ctx, frame); // get new frame ret = avcodec_receive_frame(video_ctx, frame); // get new frame
if (ret >= 0) { // one is avail. if (ret >= 0) { // one is avail.
got_frame = 1; got_frame = 1;
// printf("got frame nach %ld ms\n",(GetusTicks() - last_time)/1000);
last_time = GetusTicks();
} }
else else
got_frame = 0; got_frame = 0;
@ -485,7 +487,7 @@ next_part:
#ifdef FFMPEG_WORKAROUND_ARTIFACTS #ifdef FFMPEG_WORKAROUND_ARTIFACTS
if (!CodecUsePossibleDefectFrames && decoder->FirstKeyFrame) { if (!CodecUsePossibleDefectFrames && decoder->FirstKeyFrame) {
decoder->FirstKeyFrame++; decoder->FirstKeyFrame++;
if (frame->key_frame || (decoder->FirstKeyFrame > 2)) { // key frame is not reliable if (frame->key_frame || (decoder->FirstKeyFrame > 3)) { // key frame is not reliable
Debug(3, "codec: key frame after %d frames\n",decoder->FirstKeyFrame); Debug(3, "codec: key frame after %d frames\n",decoder->FirstKeyFrame);
decoder->FirstKeyFrame = 0; decoder->FirstKeyFrame = 0;
VideoRenderFrame(decoder->HwDecoder, video_ctx, frame); VideoRenderFrame(decoder->HwDecoder, video_ctx, frame);

View File

@ -798,8 +798,8 @@ static void PesParse(PesDemux * pesdx, const uint8_t * data, int size,
(int64_t) (data[9] & 0x0E) << 29 | data[10] << 22 | (int64_t) (data[9] & 0x0E) << 29 | data[10] << 22 |
(data[11] & 0xFE) << 14 | data[12] << 7 | (data[13] (data[11] & 0xFE) << 14 | data[12] << 7 | (data[13]
& 0xFE) >> 1; & 0xFE) >> 1;
Debug(4, "pesdemux: pts %#012" PRIx64 "\n", pts);
pesdx->PTS = pts; pesdx->PTS = pts;
pesdx->DTS = AV_NOPTS_VALUE;
} else if ((pesdx->Header[7] & 0xC0) == 0xC0) { } else if ((pesdx->Header[7] & 0xC0) == 0xC0) {
pts = pts =
(int64_t) (data[9] & 0x0E) << 29 | data[10] << 22 | (int64_t) (data[9] & 0x0E) << 29 | data[10] << 22 |
@ -811,11 +811,8 @@ static void PesParse(PesDemux * pesdx, const uint8_t * data, int size,
| (data[16] & 0xFE) << 14 | data[17] << 7 | | (data[16] & 0xFE) << 14 | data[17] << 7 |
(data[18] & 0xFE) >> 1; (data[18] & 0xFE) >> 1;
pesdx->DTS = dts; pesdx->DTS = dts;
Debug(4, Debug(4,"pesdemux: pts %#012" PRIx64 " %#012" PRIx64 "\n", pts, dts);
"pesdemux: pts %#012" PRIx64 " %#012" PRIx64 "\n",
pts, dts);
} }
empty_header: empty_header:
pesdx->State = PES_INIT; pesdx->State = PES_INIT;
if (pesdx->StartCode == PES_PRIVATE_STREAM1) { if (pesdx->StartCode == PES_PRIVATE_STREAM1) {
@ -1669,7 +1666,7 @@ static void VideoMpegEnqueue(VideoStream * stream, int64_t pts, int64_t dts,
VideoEnqueue(stream, pts, dts, data, size); VideoEnqueue(stream, pts, dts, data, size);
} }
#else #endif
/** /**
** Fix packet for FFMpeg. ** Fix packet for FFMpeg.
@ -1746,7 +1743,7 @@ static void FixPacketForFFMpeg(VideoDecoder * vdecoder, AVPacket * avpkt)
CodecVideoDecode(vdecoder, tmp); CodecVideoDecode(vdecoder, tmp);
} }
#endif
/** /**
** Open video stream. ** Open video stream.
@ -2251,8 +2248,7 @@ int PlayVideo3(VideoStream * stream, const uint8_t * data, int size)
// H264 NAL AUD Access Unit Delimiter (0x00) 0x00 0x00 0x01 0x09 // H264 NAL AUD Access Unit Delimiter (0x00) 0x00 0x00 0x01 0x09
// and next start code // and next start code
if ((data[6] & 0xC0) == 0x80 && z >= 2 && check[0] == 0x01 if ((data[6] & 0xC0) == 0x80 && z >= 2 && check[0] == 0x01 && check[1] == 0x09 && !check[3] && !check[4]) {
&& check[1] == 0x09 && !check[3] && !check[4]) {
// old PES HDTV recording z == 2 -> stronger check! // old PES HDTV recording z == 2 -> stronger check!
if (stream->CodecID == AV_CODEC_ID_H264) { if (stream->CodecID == AV_CODEC_ID_H264) {
#ifdef DUMP_TRICKSPEED #ifdef DUMP_TRICKSPEED
@ -2298,8 +2294,7 @@ int PlayVideo3(VideoStream * stream, const uint8_t * data, int size)
return size; return size;
} }
// HEVC Codec // HEVC Codec
if ((data[6] & 0xC0) == 0x80 && z >= 2 && check[0] == 0x01 if ((data[6] & 0xC0) == 0x80 && z >= 2 && check[0] == 0x01 && check[1] == 0x46) {
&& check[1] == 0x46) {
// old PES HDTV recording z == 2 -> stronger check! // old PES HDTV recording z == 2 -> stronger check!
if (stream->CodecID == AV_CODEC_ID_HEVC) { if (stream->CodecID == AV_CODEC_ID_HEVC) {
VideoNextPacket(stream, AV_CODEC_ID_HEVC); VideoNextPacket(stream, AV_CODEC_ID_HEVC);
@ -2320,11 +2315,7 @@ int PlayVideo3(VideoStream * stream, const uint8_t * data, int size)
Debug(3, "video: mpeg2 detected ID %02x\n", check[3]); Debug(3, "video: mpeg2 detected ID %02x\n", check[3]);
stream->CodecID = AV_CODEC_ID_MPEG2VIDEO; stream->CodecID = AV_CODEC_ID_MPEG2VIDEO;
} }
#ifdef noDEBUG // pip pes packet has no lenght
if (ValidateMpeg(data, size)) {
Debug(3, "softhddev/video: invalid mpeg2 video packet\n");
}
#endif
// SKIP PES header, begin of start code // SKIP PES header, begin of start code
#ifdef USE_PIP #ifdef USE_PIP
VideoMpegEnqueue(stream, pts, dts, check - 2, l + 2); VideoMpegEnqueue(stream, pts, dts, check - 2, l + 2);
@ -2338,6 +2329,7 @@ int PlayVideo3(VideoStream * stream, const uint8_t * data, int size)
Debug(3, "video: not detected\n"); Debug(3, "video: not detected\n");
return size; return size;
} }
#ifdef USE_PIP #ifdef USE_PIP
if (stream->CodecID == AV_CODEC_ID_MPEG2VIDEO) { if (stream->CodecID == AV_CODEC_ID_MPEG2VIDEO) {
// SKIP PES header // SKIP PES header
@ -2357,6 +2349,7 @@ int PlayVideo3(VideoStream * stream, const uint8_t * data, int size)
VideoEnqueue(stream, pts, dts, data + 9 + n, size - 9 - n); VideoEnqueue(stream, pts, dts, data + 9 + n, size - 9 - n);
} }
#else #else
// SKIP PES header // SKIP PES header
VideoEnqueue(stream, pts, dts, data + 9 + n, size - 9 - n); VideoEnqueue(stream, pts, dts, data + 9 + n, size - 9 - n);

View File

@ -634,8 +634,10 @@ static void VideoUpdateOutput(AVRational input_aspect_ratio, int input_width,
*output_width = (video_height * display_aspect_ratio.num + display_aspect_ratio.den ) / display_aspect_ratio.den; *output_width = (video_height * display_aspect_ratio.num + display_aspect_ratio.den ) / display_aspect_ratio.den;
*output_height = (video_width * display_aspect_ratio.den + display_aspect_ratio.num ) / display_aspect_ratio.num; *output_height = (video_width * display_aspect_ratio.den + display_aspect_ratio.num ) / display_aspect_ratio.num;
// JOJO hier stimmt was nicht // JOJO hier stimmt was nicht
// *output_width = video_width; #if DEBUG
// *output_height = video_height; *output_width = video_width;
*output_height = video_height;
#endif
if (*output_width > video_width) { if (*output_width > video_width) {
*output_width = video_width; *output_width = video_width;