mirror of
https://projects.vdr-developer.org/git/vdr-plugin-softhddevice.git
synced 2023-10-10 19:16:51 +02:00
Use video stream frame rate for A/V sync.
Use the video stream frame rate and not the fixed 50Hz for A/V sync.
This commit is contained in:
parent
9f134c1b6d
commit
4f4d304479
24
video.c
24
video.c
@ -446,13 +446,27 @@ static void VideoThreadExit(void); ///< exit/kill video thread
|
|||||||
///
|
///
|
||||||
/// @note frame->interlaced_frame can't be used for interlace detection
|
/// @note frame->interlaced_frame can't be used for interlace detection
|
||||||
///
|
///
|
||||||
static void VideoSetPts(int64_t * pts_p, int interlaced, const AVFrame * frame)
|
static void VideoSetPts(int64_t * pts_p, int interlaced,
|
||||||
|
const AVCodecContext * video_ctx, const AVFrame * frame)
|
||||||
{
|
{
|
||||||
int64_t pts;
|
int64_t pts;
|
||||||
|
int duration;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Get duration for this frame.
|
||||||
|
// FIXME: using framerate as workaround for av_frame_get_pkt_duration
|
||||||
|
//
|
||||||
|
if (video_ctx->framerate.num != 0 && video_ctx->framerate.den != 0) {
|
||||||
|
duration = 1000 * video_ctx->framerate.den / video_ctx->framerate.num;
|
||||||
|
} else {
|
||||||
|
duration = interlaced ? 40 : 20; // 50Hz -> 20ms default
|
||||||
|
}
|
||||||
|
Debug(4, "video: %d/%d %" PRIx64 " -> %d\n", video_ctx->framerate.den,
|
||||||
|
video_ctx->framerate.num, av_frame_get_pkt_duration(frame), duration);
|
||||||
|
|
||||||
// update video clock
|
// update video clock
|
||||||
if (*pts_p != (int64_t) AV_NOPTS_VALUE) {
|
if (*pts_p != (int64_t) AV_NOPTS_VALUE) {
|
||||||
*pts_p += interlaced ? 40 * 90 : 20 * 90;
|
*pts_p += duration * 90;
|
||||||
//Info("video: %s +pts\n", Timestamp2String(*pts_p));
|
//Info("video: %s +pts\n", Timestamp2String(*pts_p));
|
||||||
}
|
}
|
||||||
//av_opt_ptr(avcodec_get_frame_class(), frame, "best_effort_timestamp");
|
//av_opt_ptr(avcodec_get_frame_class(), frame, "best_effort_timestamp");
|
||||||
@ -5257,7 +5271,7 @@ static void VaapiSyncRenderFrame(VaapiDecoder * decoder,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!decoder->Closing) {
|
if (!decoder->Closing) {
|
||||||
VideoSetPts(&decoder->PTS, decoder->Interlaced, frame);
|
VideoSetPts(&decoder->PTS, decoder->Interlaced, video_ctx, frame);
|
||||||
}
|
}
|
||||||
VaapiRenderFrame(decoder, video_ctx, frame);
|
VaapiRenderFrame(decoder, video_ctx, frame);
|
||||||
#ifdef USE_AUTOCROP
|
#ifdef USE_AUTOCROP
|
||||||
@ -8879,7 +8893,7 @@ static void VdpauSyncRenderFrame(VdpauDecoder * decoder,
|
|||||||
|
|
||||||
if (VdpauPreemption) { // display preempted
|
if (VdpauPreemption) { // display preempted
|
||||||
if (!decoder->Closing) {
|
if (!decoder->Closing) {
|
||||||
VideoSetPts(&decoder->PTS, decoder->Interlaced, frame);
|
VideoSetPts(&decoder->PTS, decoder->Interlaced, video_ctx, frame);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -8929,7 +8943,7 @@ static void VdpauSyncRenderFrame(VdpauDecoder * decoder,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!decoder->Closing) {
|
if (!decoder->Closing) {
|
||||||
VideoSetPts(&decoder->PTS, decoder->Interlaced, frame);
|
VideoSetPts(&decoder->PTS, decoder->Interlaced, video_ctx, frame);
|
||||||
}
|
}
|
||||||
VdpauRenderFrame(decoder, video_ctx, frame);
|
VdpauRenderFrame(decoder, video_ctx, frame);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user