Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.
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
31 changes: 24 additions & 7 deletions decoder/vaapidecoder_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ VaapiDecoderBase::~VaapiDecoderBase()

Decode_Status VaapiDecoderBase::start(VideoConfigBuffer * buffer)
{
Decode_Status status;

INFO("base: start()");

if (buffer == NULL) {
Expand All @@ -81,7 +83,9 @@ Decode_Status VaapiDecoderBase::start(VideoConfigBuffer * buffer)
m_lowDelay = buffer->flag & WANT_LOW_DELAY;
m_rawOutput = buffer->flag & WANT_RAW_OUTPUT;

setupVA(buffer->surfaceNumber, buffer->profile);
status = setupVA(buffer->surfaceNumber, buffer->profile);
if (status != DECODE_SUCCESS)
return status;

DEBUG
("m_videoFormatInfo video size: %d x %d, m_videoFormatInfo surface size: %d x %d",
Expand All @@ -92,14 +96,22 @@ Decode_Status VaapiDecoderBase::start(VideoConfigBuffer * buffer)

Decode_Status VaapiDecoderBase::reset(VideoConfigBuffer * buffer)
{
Decode_Status status;

INFO("base: reset()");
if (buffer == NULL) {
return DECODE_INVALID_DATA;
}

flush();
terminateVA();
start(buffer);

status = terminateVA();
if (status != DECODE_SUCCESS)
return status;

status = start(buffer);
if (status != DECODE_SUCCESS)
return status;

return DECODE_SUCCESS;
}
Expand Down Expand Up @@ -272,12 +284,13 @@ Decode_Status
m_VADisplay = vaGetDisplay(m_display);
if (m_VADisplay == NULL) {
ERROR("vaGetDisplay failed.");
return DECODE_DRIVER_FAIL;
return DECODE_FAIL;
}

int majorVersion, minorVersion;
vaStatus = vaInitialize(m_VADisplay, &majorVersion, &minorVersion);
checkVaapiStatus(vaStatus, "vaInitialize");
if (!checkVaapiStatus(vaStatus, "vaInitialize"))
return DECODE_FAIL;

VAConfigAttrib attrib;
attrib.type = VAConfigAttribRTFormat;
Expand All @@ -297,7 +310,8 @@ Decode_Status
VAEntrypointVLD, &attrib, 1,
&m_VAConfig);

checkVaapiStatus(vaStatus, "vaCreateConfig");
if (!checkVaapiStatus(vaStatus, "vaCreateConfig"))
return DECODE_FAIL;

m_configBuffer.surfaceNumber = numSurface;
m_bufPool = new VaapiSurfaceBufferPool(m_VADisplay, &m_configBuffer);
Expand All @@ -315,7 +329,8 @@ Decode_Status
m_videoFormatInfo.width,
m_videoFormatInfo.height,
0, surfaces, numSurface, &m_VAContext);
checkVaapiStatus(vaStatus, "vaCreateContext");
if (!checkVaapiStatus(vaStatus, "vaCreateContext"))
return DECODE_FAIL;

VADisplayAttribute rotate;
rotate.type = VADisplayAttribRotation;
Expand All @@ -330,6 +345,8 @@ Decode_Status
rotate.value = VA_ROTATION_270;

vaStatus = vaSetDisplayAttributes(m_VADisplay, &rotate, 1);
if (!checkVaapiStatus(vaStatus, "vaSetDisplayAttributes"))
return DECODE_FAIL;

m_videoFormatInfo.surfaceNumber = numSurface;
m_videoFormatInfo.ctxSurfaces = surfaces;
Expand Down
19 changes: 16 additions & 3 deletions decoder/vaapidecoder_h264.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,7 @@ Decode_Status VaapiDecoderH264::ensureContext(H264PPS * pps)
uint32_t mbWidth, mbHeight;
bool resetContext = false;
uint32_t DPBSize = 0;
Decode_Status status;

m_progressiveSequence = sps->frame_mbs_only_flag;

Expand All @@ -1004,6 +1005,7 @@ Decode_Status VaapiDecoderH264::ensureContext(H264PPS * pps)
DEBUG("H264: profile changed: old = %d, new = %d, \n",
m_configBuffer.profile, parsedProfile);
m_configBuffer.profile = parsedProfile;
m_configBuffer.flag |= HAS_VA_PROFILE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here are exist code. why we not set the flag before your commit .

resetContext = true;
}

Expand Down Expand Up @@ -1038,11 +1040,19 @@ Decode_Status VaapiDecoderH264::ensureContext(H264PPS * pps)
if (!m_hasContext) {
DPBSize = getMaxDecFrameBuffering(sps, 1);
m_configBuffer.surfaceNumber = DPBSize + H264_EXTRA_SURFACE_NUMBER;
VaapiDecoderBase::start(&m_configBuffer);
m_configBuffer.flag |= HAS_SURFACE_NUMBER;
status = VaapiDecoderBase::start(&m_configBuffer);
if (status != DECODE_SUCCESS)
return status;

DEBUG("First time to Start VA context");
m_resetContext = true;
} else if (resetContext) {
VaapiDecoderBase::reset(&m_configBuffer);
m_hasContext = false;
status = VaapiDecoderBase::reset(&m_configBuffer);
if (status != DECODE_SUCCESS)
return status;

if (m_DPBManager)
m_DPBManager->resetDPB(sps);

Expand Down Expand Up @@ -1487,7 +1497,10 @@ Decode_Status VaapiDecoderH264::start(VideoConfigBuffer * buffer)
}

if (gotConfig) {
VaapiDecoderBase::start(buffer);
status = VaapiDecoderBase::start(buffer);
if (status != DECODE_SUCCESS)
return status;

m_hasContext = true;
}

Expand Down