Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksoid <aleksoid@users.sourceforge.net>2012-04-09 03:00:25 +0400
committerAleksoid <aleksoid@users.sourceforge.net>2012-04-09 03:00:25 +0400
commit4599560b05b03011a4d36867e2c43ce9f865da43 (patch)
treeed2adf9e0be6264a6ef1e8f3c08fc979a2733652
parentc9ad80de91ab6beb9da67fa5062201ea6faacf54 (diff)
Change : code refactoring - remove "goto" instruction;
Change : Add "DXVA" indicator on Pause state; ticket #2157; git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@4301 10f7b99b-c216-0410-bff0-8a66a9350fd8
-rw-r--r--src/apps/mplayerc/MainFrm.cpp2
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp110
2 files changed, 51 insertions, 61 deletions
diff --git a/src/apps/mplayerc/MainFrm.cpp b/src/apps/mplayerc/MainFrm.cpp
index d3bf66e21..b3267d321 100644
--- a/src/apps/mplayerc/MainFrm.cpp
+++ b/src/apps/mplayerc/MainFrm.cpp
@@ -3569,7 +3569,7 @@ void CMainFrame::OnUpdatePlayerStatus(CCmdUI* pCmdUI)
(fs == State_Paused || m_fFrameSteppingActive) ? ResStr(IDS_CONTROLS_PAUSED) :
fs == State_Running ? ResStr(IDS_CONTROLS_PLAYING) :
_T("");
- if ((!m_fAudioOnly) && (UI_Text == ResStr(IDS_CONTROLS_PLAYING))) {
+ if ((!m_fAudioOnly) && (UI_Text == ResStr(IDS_CONTROLS_PAUSED) || UI_Text == ResStr(IDS_CONTROLS_PLAYING))) {
CString DXVA_Text = GetDXVADecoderDescription();
if (!(_T("Not using DXVA")==DXVA_Text) || (_T("Unknown")==DXVA_Text)) {
UI_Text += _T(" [DXVA]");
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp b/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp
index 48eab64d4..39c4f6681 100644
--- a/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp
+++ b/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp
@@ -104,45 +104,40 @@ void CDXVADecoderH264::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSi
int slice_step = 1;
int nDxvaNalLength;
- Nalu.SetBuffer (pBuffer, nSize, m_nNALLength);
-
-slice_again:
- nSize = 0;
- while (Nalu.ReadNext()) {
- switch (Nalu.GetType()) {
- case NALU_TYPE_SLICE:
- case NALU_TYPE_IDR:
- // Skip the NALU if the data length is below 0
- if (Nalu.GetDataLength() < 0) {
- break;
- }
+ while (!nSlices && slice_step <= 2) {
+ Nalu.SetBuffer (pBuffer, m_nSize, slice_step == 1 ? m_nNALLength : 0);
+ nSize = 0;
+ while (Nalu.ReadNext()) {
+ switch (Nalu.GetType()) {
+ case NALU_TYPE_SLICE:
+ case NALU_TYPE_IDR:
+ // Skip the NALU if the data length is below 0
+ if (Nalu.GetDataLength() < 0) {
+ break;
+ }
- // For AVC1, put startcode 0x000001
- pDXVABuffer[0]=pDXVABuffer[1]=0; pDXVABuffer[2]=1;
- if (Nalu.GetDataLength() < 0)
- break;
+ // For AVC1, put startcode 0x000001
+ pDXVABuffer[0]=pDXVABuffer[1]=0; pDXVABuffer[2]=1;
+ if (Nalu.GetDataLength() < 0)
+ break;
- // Copy NALU
- __try {
- memcpy (pDXVABuffer+3, Nalu.GetDataBuffer(), Nalu.GetDataLength());
- } __except (EXCEPTION_EXECUTE_HANDLER) { break; }
+ // Copy NALU
+ __try {
+ memcpy (pDXVABuffer+3, Nalu.GetDataBuffer(), Nalu.GetDataLength());
+ } __except (EXCEPTION_EXECUTE_HANDLER) { break; }
- // Update slice control buffer
- nDxvaNalLength = Nalu.GetDataLength()+3;
- m_pSliceShort[nSlices].BSNALunitDataLocation = nSize;
- m_pSliceShort[nSlices].SliceBytesInBuffer = nDxvaNalLength;
+ // Update slice control buffer
+ nDxvaNalLength = Nalu.GetDataLength()+3;
+ m_pSliceShort[nSlices].BSNALunitDataLocation = nSize;
+ m_pSliceShort[nSlices].SliceBytesInBuffer = nDxvaNalLength;
- nSize += nDxvaNalLength;
- pDXVABuffer += nDxvaNalLength;
- nSlices++;
- break;
+ nSize += nDxvaNalLength;
+ pDXVABuffer += nDxvaNalLength;
+ nSlices++;
+ break;
+ }
}
- }
-
- if (!nSlices && slice_step == 1) {
slice_step++;
- Nalu.SetBuffer (pBuffer, m_nSize, 0);
- goto slice_again;
}
// Complete with zero padding (buffer size should be a multiple of 128)
@@ -184,39 +179,34 @@ HRESULT CDXVADecoderH264::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME
TRACE_H264 ("CDXVADecoderH264::DecodeFrame() : nFramePOC = %d, nOutPOC = %d[%d], rtOutStart = %I64d\n", nFramePOC, nOutPOC, m_nOutPOC, rtOutStart);
- Nalu.SetBuffer (pDataIn, nSize, m_nNALLength);
-
-slice_again:
- while (Nalu.ReadNext()) {
- switch (Nalu.GetType()) {
- case NALU_TYPE_SLICE:
- case NALU_TYPE_IDR:
- if (m_bUseLongSlice) {
- m_pSliceLong[nSlices].BSNALunitDataLocation = nNalOffset;
- m_pSliceLong[nSlices].SliceBytesInBuffer = Nalu.GetDataLength()+3; //.GetRoundedDataLength();
- m_pSliceLong[nSlices].slice_id = nSlices;
- FF264UpdateRefFrameSliceLong(&m_DXVAPicParams, &m_pSliceLong[nSlices], m_pFilter->GetAVCtx());
-
- if (nSlices>0) {
- m_pSliceLong[nSlices-1].NumMbsForSlice = m_pSliceLong[nSlices].NumMbsForSlice = m_pSliceLong[nSlices].first_mb_in_slice - m_pSliceLong[nSlices-1].first_mb_in_slice;
+ while (!nSlices && slice_step <= 2) {
+ Nalu.SetBuffer (pDataIn, nSize, slice_step == 1 ? m_nNALLength : 0);
+ while (Nalu.ReadNext()) {
+ switch (Nalu.GetType()) {
+ case NALU_TYPE_SLICE:
+ case NALU_TYPE_IDR:
+ if (m_bUseLongSlice) {
+ m_pSliceLong[nSlices].BSNALunitDataLocation = nNalOffset;
+ m_pSliceLong[nSlices].SliceBytesInBuffer = Nalu.GetDataLength()+3; //.GetRoundedDataLength();
+ m_pSliceLong[nSlices].slice_id = nSlices;
+ FF264UpdateRefFrameSliceLong(&m_DXVAPicParams, &m_pSliceLong[nSlices], m_pFilter->GetAVCtx());
+
+ if (nSlices>0) {
+ m_pSliceLong[nSlices-1].NumMbsForSlice = m_pSliceLong[nSlices].NumMbsForSlice = m_pSliceLong[nSlices].first_mb_in_slice - m_pSliceLong[nSlices-1].first_mb_in_slice;
+ }
+ }
+ nSlices++;
+ nNalOffset += (UINT)(Nalu.GetDataLength() + 3);
+ if (nSlices > MAX_SLICES) {
+ break;
}
- }
- nSlices++;
- nNalOffset += (UINT)(Nalu.GetDataLength() + 3);
- if (nSlices > MAX_SLICES) {
break;
- }
- break;
+ }
}
+ slice_step++;
}
if (!nSlices) {
- if(slice_step == 1) {
- slice_step++;
- Nalu.SetBuffer (pDataIn, nSize, 0);
- goto slice_again;
- }
-
return S_FALSE;
}