Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vpp merge #13

Merged
merged 4 commits into from
Oct 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
User johns
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.
Disabled old code before removement.
Handle change of audio ac3 downmix direct.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ AVFILTER ?= $(shell pkg-config --exists libavfilter && echo 1)
#CONFIG += -DSTILL_DEBUG=2 # still picture debug verbose level

CONFIG += -DAV_INFO -DAV_INFO_TIME=3000 # info/debug a/v sync
#CONFIG += -DUSE_PIP # PIP support
CONFIG += -DUSE_PIP # PIP support
CONFIG += -DHAVE_PTHREAD_NAME # supports new pthread_setname_np
#CONFIG += -DNO_TS_AUDIO # disable ts audio parser
#CONFIG += -DUSE_TS_VIDEO # build new ts video parser
Expand Down
58 changes: 0 additions & 58 deletions libva-intel-driver-9999-r1.ebuild

This file was deleted.

113 changes: 73 additions & 40 deletions video.c
Original file line number Diff line number Diff line change
Expand Up @@ -3042,7 +3042,6 @@ static int VaapiInit(const char *display_name)
&entrypoint_n)) {

for (i = 0; i < entrypoint_n; i++) {
fprintf(stderr, "oops %d\n", i);
if (entrypoints[i] == VAEntrypointVideoProc) {
Info("video/vaapi: supports video processing\n");
VaapiVideoProcessing = 1;
Expand Down Expand Up @@ -5097,7 +5096,7 @@ static void VaapiQueueSurface(VaapiDecoder * decoder, VASurfaceID surface,
++decoder->FrameCounter;

if (1) { // can't wait for output queue empty
if (atomic_read(&decoder->SurfacesFilled) >= VIDEO_SURFACES_MAX) {
if (atomic_read(&decoder->SurfacesFilled) >= VIDEO_SURFACES_MAX - 1) {
++decoder->FramesDropped;
Warning(_("video: output buffer full, dropping frame (%d/%d)\n"),
decoder->FramesDropped, decoder->FrameCounter);
Expand All @@ -5111,7 +5110,7 @@ static void VaapiQueueSurface(VaapiDecoder * decoder, VASurfaceID surface,
}
#if 0
} else { // wait for output queue empty
while (atomic_read(&decoder->SurfacesFilled) >= VIDEO_SURFACES_MAX) {
while (atomic_read(&decoder->SurfacesFilled) >= VIDEO_SURFACES_MAX - 1) {
VideoDisplayHandler();
}
#endif
Expand Down Expand Up @@ -6918,8 +6917,9 @@ static void VaapiSyncDecoder(VaapiDecoder * decoder)
8888 ? ((video_clock - audio_clock) / 90) : 8888,
AudioGetDelay() / 90, (int)VideoDeltaPTS / 90,
VideoGetBuffers(decoder->Stream),
(1 + decoder->Interlaced) * atomic_read(&decoder->SurfacesFilled)
- decoder->SurfaceField);
decoder->Interlaced ? (2 * atomic_read(&decoder->SurfacesFilled)
- decoder->SurfaceField)
: atomic_read(&decoder->SurfacesFilled));
if (!(decoder->FramesDisplayed % (5 * 60 * 60))) {
VaapiPrintFrames(decoder);
}
Expand Down Expand Up @@ -6968,8 +6968,22 @@ static void VaapiSyncRenderFrame(VaapiDecoder * decoder,
}
#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.
// loop for interlace
if (atomic_read(&decoder->SurfacesFilled) >= VIDEO_SURFACES_MAX - 1) {
#ifdef DEBUG
Fatal("video/vaapi: this code part shouldn't be used\n");
#else
Info("video/vaapi: 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) {
struct timespec abstime;

Expand Down Expand Up @@ -6998,6 +7012,7 @@ static void VaapiSyncRenderFrame(VaapiDecoder * decoder,

VaapiSyncDisplayFrame();
}
#endif

if (!decoder->Closing) {
VideoSetPts(&decoder->PTS, decoder->Interlaced, video_ctx, frame);
Expand Down Expand Up @@ -7060,49 +7075,66 @@ static void VaapiSetOutputPosition(VaapiDecoder * decoder, int x, int y,
///
/// Handle a va-api display.
///
/// @todo FIXME: only a single decoder supported.
///
static void VaapiDisplayHandlerThread(void)
{
int i;
int err;
int filled;
int allfull;
int decoded;
struct timespec nowtime;
VaapiDecoder *decoder;

if (!(decoder = VaapiDecoders[0])) { // no stream available
return;
}
//
// fill frame output ring buffer
//
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;
allfull = 1;
decoded = 0;
pthread_mutex_lock(&VideoLockMutex);
for (i = 0; i < VaapiDecoderN; ++i) {
int filled;

decoder = VaapiDecoders[i];

//
// fill frame output ring buffer
//
filled = atomic_read(&decoder->SurfacesFilled);
if (filled < VIDEO_SURFACES_MAX - 1) {
// 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);

clock_gettime(CLOCK_MONOTONIC, &nowtime);
// time for one frame over?
if ((nowtime.tv_sec - decoder->FrameTime.tv_sec)
* 1000 * 1000 * 1000 + (nowtime.tv_nsec - decoder->FrameTime.tv_nsec) <
15 * 1000 * 1000) {
return;
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);
Expand Down Expand Up @@ -10714,6 +10746,9 @@ static void VdpauSyncRenderFrame(VdpauDecoder * decoder,
return;
}
#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.
// loop for interlace
if (atomic_read(&decoder->SurfacesFilled) >= VIDEO_SURFACES_MAX) {
Expand Down Expand Up @@ -10861,8 +10896,6 @@ static void VdpauSetVideoMode(void)
///
/// Handle a VDPAU display.
///
/// @todo FIXME: only a single decoder supported.
///
static void VdpauDisplayHandlerThread(void)
{
int i;
Expand Down