Added VDPAU multi decoder loop changes to VA-API code.

This commit is contained in:
Johns 2015-10-05 08:54:19 +02:00
parent 5dc5601576
commit 4fa4f6616a
3 changed files with 79 additions and 43 deletions

View File

@ -1,6 +1,9 @@
User johns User johns
Date: Date:
Added VDPAU multi decoder loop changes to VA-API code.
Reenabled VA-API auto detection.
Check and enforce USE_PIP is defined, for new code.
Fix comment spelling. Fix comment spelling.
Disabled old code before removement. Disabled old code before removement.
Handle change of audio ac3 downmix direct. Handle change of audio ac3 downmix direct.

View File

@ -18,9 +18,9 @@ OSS ?= 1
# support VDPAU video output module # support VDPAU video output module
VDPAU ?= $(shell pkg-config --exists vdpau && echo 1) VDPAU ?= $(shell pkg-config --exists vdpau && echo 1)
# support VA-API video output module (deprecated) # support VA-API video output module (deprecated)
#VAAPI ?= $(shell pkg-config --exists libva && echo 1) VAAPI ?= $(shell pkg-config --exists libva && echo 1)
# support glx output # support glx output
#OPENGL ?= $(shell pkg-config --exists gl glu && echo 1) OPENGL ?= $(shell pkg-config --exists gl glu && echo 1)
# screensaver disable/enable # screensaver disable/enable
SCREENSAVER ?= 1 SCREENSAVER ?= 1
# use ffmpeg libswresample # use ffmpeg libswresample

115
video.c
View File

@ -2452,7 +2452,6 @@ static int VaapiInit(const char *display_name)
&entrypoint_n)) { &entrypoint_n)) {
for (i = 0; i < entrypoint_n; i++) { for (i = 0; i < entrypoint_n; i++) {
fprintf(stderr, "oops %d\n", i);
if (entrypoints[i] == VAEntrypointVideoProc) { if (entrypoints[i] == VAEntrypointVideoProc) {
Info("video/vaapi: supports video processing\n"); Info("video/vaapi: supports video processing\n");
VaapiVideoProcessing = 1; VaapiVideoProcessing = 1;
@ -5255,8 +5254,9 @@ static void VaapiSyncDecoder(VaapiDecoder * decoder)
8888 ? ((video_clock - audio_clock) / 90) : 8888, 8888 ? ((video_clock - audio_clock) / 90) : 8888,
AudioGetDelay() / 90, (int)VideoDeltaPTS / 90, AudioGetDelay() / 90, (int)VideoDeltaPTS / 90,
VideoGetBuffers(decoder->Stream), VideoGetBuffers(decoder->Stream),
(1 + decoder->Interlaced) * atomic_read(&decoder->SurfacesFilled) decoder->Interlaced ? (2 * atomic_read(&decoder->SurfacesFilled)
- decoder->SurfaceField); - decoder->SurfaceField)
: atomic_read(&decoder->SurfacesFilled));
if (!(decoder->FramesDisplayed % (5 * 60 * 60))) { if (!(decoder->FramesDisplayed % (5 * 60 * 60))) {
VaapiPrintFrames(decoder); VaapiPrintFrames(decoder);
} }
@ -5305,8 +5305,22 @@ static void VaapiSyncRenderFrame(VaapiDecoder * decoder,
} }
#endif #endif
#if 1
#ifndef USE_PIP
#error "-DUSE_PIP or #define USE_PIP is needed,"
#endif
// if video output buffer is full, wait and display surface. // if video output buffer is full, wait and display surface.
// loop for interlace // loop for interlace
if (atomic_read(&decoder->SurfacesFilled) >= VIDEO_SURFACES_MAX) {
#ifdef DEBUG
Fatal("video/vdpau: this code part shouldn't be used\n");
#else
Info("video/vdpau: this code part shouldn't be used\n");
#endif
return;
}
#else
// FIXME: this part code should be no longer be needed with new mpeg fix
while (atomic_read(&decoder->SurfacesFilled) >= VIDEO_SURFACES_MAX - 1) { while (atomic_read(&decoder->SurfacesFilled) >= VIDEO_SURFACES_MAX - 1) {
struct timespec abstime; struct timespec abstime;
@ -5335,6 +5349,7 @@ static void VaapiSyncRenderFrame(VaapiDecoder * decoder,
VaapiSyncDisplayFrame(); VaapiSyncDisplayFrame();
} }
#endif
if (!decoder->Closing) { if (!decoder->Closing) {
VideoSetPts(&decoder->PTS, decoder->Interlaced, video_ctx, frame); VideoSetPts(&decoder->PTS, decoder->Interlaced, video_ctx, frame);
@ -5377,49 +5392,66 @@ static void VaapiSetVideoMode(void)
/// ///
/// Handle a va-api display. /// Handle a va-api display.
/// ///
/// @todo FIXME: only a single decoder supported.
///
static void VaapiDisplayHandlerThread(void) static void VaapiDisplayHandlerThread(void)
{ {
int i;
int err; int err;
int filled; int allfull;
int decoded;
struct timespec nowtime; struct timespec nowtime;
VaapiDecoder *decoder; VaapiDecoder *decoder;
if (!(decoder = VaapiDecoders[0])) { // no stream available allfull = 1;
return; decoded = 0;
} pthread_mutex_lock(&VideoLockMutex);
// for (i = 0; i < VaapiDecoderN; ++i) {
// fill frame output ring buffer int filled;
//
filled = atomic_read(&decoder->SurfacesFilled);
if (filled < VIDEO_SURFACES_MAX - 1) {
// FIXME: hot polling
pthread_mutex_lock(&VideoLockMutex);
// fetch+decode or reopen
err = VideoDecodeInput(decoder->Stream);
pthread_mutex_unlock(&VideoLockMutex);
} else {
err = VideoPollInput(decoder->Stream);
}
if (err) {
// FIXME: sleep on wakeup
usleep(5 * 1000); // nothing buffered
if (err == -1 && decoder->Closing) {
decoder->Closing--;
if (!decoder->Closing) {
Debug(3, "video/vaapi: closing eof\n");
decoder->Closing = -1;
}
}
}
clock_gettime(CLOCK_MONOTONIC, &nowtime); decoder = VaapiDecoders[i];
// time for one frame over?
if ((nowtime.tv_sec - decoder->FrameTime.tv_sec) //
* 1000 * 1000 * 1000 + (nowtime.tv_nsec - decoder->FrameTime.tv_nsec) < // fill frame output ring buffer
15 * 1000 * 1000) { //
return; filled = atomic_read(&decoder->SurfacesFilled);
if (filled < VIDEO_SURFACES_MAX) {
// FIXME: hot polling
// fetch+decode or reopen
allfull = 0;
err = VideoDecodeInput(decoder->Stream);
} else {
err = VideoPollInput(decoder->Stream);
}
// decoder can be invalid here
if (err) {
// nothing buffered?
if (err == -1 && decoder->Closing) {
decoder->Closing--;
if (!decoder->Closing) {
Debug(3, "video/vdpau: closing eof\n");
decoder->Closing = -1;
}
}
continue;
}
decoded = 1;
}
pthread_mutex_unlock(&VideoLockMutex);
if (!decoded) { // nothing decoded, sleep
// FIXME: sleep on wakeup
usleep(1 * 1000);
}
// all decoder buffers are full
// speed up filling display queue, wait on display queue empty
if (!allfull) {
clock_gettime(CLOCK_MONOTONIC, &nowtime);
// time for one frame over?
if ((nowtime.tv_sec -
VaapiDecoders[0]->FrameTime.tv_sec) * 1000 * 1000 * 1000 +
(nowtime.tv_nsec - VaapiDecoders[0]->FrameTime.tv_nsec) <
15 * 1000 * 1000) {
return;
}
} }
pthread_mutex_lock(&VideoLockMutex); pthread_mutex_lock(&VideoLockMutex);
@ -9004,6 +9036,9 @@ static void VdpauSyncRenderFrame(VdpauDecoder * decoder,
return; return;
} }
#if 1 #if 1
#ifndef USE_PIP
#error "-DUSE_PIP or #define USE_PIP is needed,"
#endif
// if video output buffer is full, wait and display surface. // if video output buffer is full, wait and display surface.
// loop for interlace // loop for interlace
if (atomic_read(&decoder->SurfacesFilled) >= VIDEO_SURFACES_MAX) { if (atomic_read(&decoder->SurfacesFilled) >= VIDEO_SURFACES_MAX) {
@ -9151,8 +9186,6 @@ static void VdpauSetVideoMode(void)
/// ///
/// Handle a VDPAU display. /// Handle a VDPAU display.
/// ///
/// @todo FIXME: only a single decoder supported.
///
static void VdpauDisplayHandlerThread(void) static void VdpauDisplayHandlerThread(void)
{ {
int i; int i;