<commit_before>#include <assert.h>
#include "MpegVideoState.h"
#include "VideoStream_ReadDct.h"
#include "MPEG2/DctCoefficientTable0.h"
#include "MPEG2/DctCoefficientTable1.h"

using namespace VideoStream;

ReadDct::ReadDct()
: m_coeffTable(NULL)
, m_block(NULL)
{

}

ReadDct::~ReadDct()
{

}

void ReadDct::Reset()
{
	m_programState = STATE_INIT;
	m_coeffTable = NULL;
	m_blockIndex = 0;
}

void ReadDct::SetBlockInfo(int16* block, unsigned int channel)
{
	m_channel = channel;
	m_block = block;
}

void ReadDct::Execute(void* context, Framework::CBitStream& stream)
{
	MPEG_VIDEO_STATE* state(reinterpret_cast<MPEG_VIDEO_STATE*>(context));
	PICTURE_HEADER& pictureHeader(state->pictureHeader);
	PICTURE_CODING_EXTENSION& pictureCodingExtension(state->pictureCodingExtension);
	BLOCK_DECODER_STATE& decoderState(state->blockDecoderState);
	SEQUENCE_HEADER& sequenceHeader(state->sequenceHeader);
	bool isMpeg2 = sequenceHeader.isMpeg2;

	while(1)
	{
		switch(m_programState)
		{
		case STATE_INIT:					goto Label_Init;
		case STATE_READDCDIFFERENTIAL:		goto Label_ReadDcDifferential;
		case STATE_CHECKEOB:				goto Label_CheckEob;
		case STATE_READCOEFF:				goto Label_ReadCoeff;
		case STATE_SKIPEOB:					goto Label_SkipEob;
		default:							assert(0);
		}

Label_Init:
		{
			bool isIntra = (pictureHeader.pictureCodingType == PICTURE_TYPE_I || decoderState.macroblockType & MACROBLOCK_MODE_INTRA);

			m_dcDiffReader.Reset();
			if(pictureCodingExtension.intraVlcFormat && isIntra)
			{
				m_coeffTable = MPEG2::CDctCoefficientTable1::GetInstance();
			}
			else
			{
				m_coeffTable = MPEG2::CDctCoefficientTable0::GetInstance();
			}

			if(isIntra)
			{
				m_programState = STATE_READDCDIFFERENTIAL;
			}
			else
			{
				m_programState = STATE_CHECKEOB;
			}
		}
		continue;

Label_ReadDcDifferential:
		m_dcDiffReader.SetChannel(m_channel);
		m_dcDiffReader.Execute(context, stream);
		m_block[0] = static_cast<int16>(decoderState.dcPredictor[m_channel] + decoderState.dcDifferential);
		decoderState.dcPredictor[m_channel] = m_block[0];
		m_blockIndex++;
		m_programState = STATE_CHECKEOB;
		continue;

Label_CheckEob:
		if((m_blockIndex != 0) && m_coeffTable->IsEndOfBlock(&stream))
		{
			m_programState = STATE_SKIPEOB;
		}
		else
		{
			m_programState = STATE_READCOEFF;
		}
		continue;

Label_ReadCoeff:
		{
			MPEG2::RUNLEVELPAIR runLevelPair;
			if(m_blockIndex == 0)
			{
				m_coeffTable->GetRunLevelPairDc(&stream, &runLevelPair, isMpeg2);
			}
			else
			{
				m_coeffTable->GetRunLevelPair(&stream, &runLevelPair, isMpeg2);
			}
			m_blockIndex += runLevelPair.nRun;
		
			if(m_blockIndex < 0x40)
			{
				m_block[m_blockIndex] = static_cast<int16>(runLevelPair.nLevel);
#ifdef _DECODE_LOGGING
	            CLog::GetInstance().Print(LOG_NAME, "[%i]:%i ", index, runLevelPair.nLevel);
#endif
			}
			else
			{
				assert(0);
				break;<commit_msg>Compilation fixes.<commit_after>#include <assert.h>
#include "MpegVideoState.h"
#include "VideoStream_ReadDct.h"
#include "MPEG2/DctCoefficientTable0.h"
#include "MPEG2/DctCoefficientTable1.h"

using namespace VideoStream;

ReadDct::ReadDct()
: m_coeffTable(NULL)
, m_block(NULL)
{

}

ReadDct::~ReadDct()
{

}

void ReadDct::Reset()
{
	m_programState = STATE_INIT;
	m_coeffTable = NULL;
	m_blockIndex = 0;
}

void ReadDct::SetBlockInfo(int16* block, unsigned int channel)
{
	m_channel = channel;
	m_block = block;
}

void ReadDct::Execute(void* context, Framework::CBitStream& stream)
{
	MPEG_VIDEO_STATE* state(reinterpret_cast<MPEG_VIDEO_STATE*>(context));
	PICTURE_HEADER& pictureHeader(state->pictureHeader);
	PICTURE_CODING_EXTENSION& pictureCodingExtension(state->pictureCodingExtension);
	BLOCK_DECODER_STATE& decoderState(state->blockDecoderState);
	SEQUENCE_HEADER& sequenceHeader(state->sequenceHeader);
	bool isMpeg2 = sequenceHeader.isMpeg2;

	while(1)
	{
		switch(m_programState)
		{
		case STATE_INIT:					goto Label_Init;
		case STATE_READDCDIFFERENTIAL:		goto Label_ReadDcDifferential;
		case STATE_CHECKEOB:				goto Label_CheckEob;
		case STATE_READCOEFF:				goto Label_ReadCoeff;
		case STATE_SKIPEOB:					goto Label_SkipEob;
		default:							assert(0);
		}

Label_Init:
		{
			bool isIntra = (pictureHeader.pictureCodingType == PICTURE_TYPE_I || decoderState.macroblockType & MACROBLOCK_MODE_INTRA);

			m_dcDiffReader.Reset();
			if(pictureCodingExtension.intraVlcFormat && isIntra)
			{
				m_coeffTable = &MPEG2::CDctCoefficientTable1::GetInstance();
			}
			else
			{
				m_coeffTable = &MPEG2::CDctCoefficientTable0::GetInstance();
			}

			if(isIntra)
			{
				m_programState = STATE_READDCDIFFERENTIAL;
			}
			else
			{
				m_programState = STATE_CHECKEOB;
			}
		}
		continue;

Label_ReadDcDifferential:
		m_dcDiffReader.SetChannel(m_channel);
		m_dcDiffReader.Execute(context, stream);
		m_block[0] = static_cast<int16>(decoderState.dcPredictor[m_channel] + decoderState.dcDifferential);
		decoderState.dcPredictor[m_channel] = m_block[0];
		m_blockIndex++;
		m_programState = STATE_CHECKEOB;
		continue;

Label_CheckEob:
		if((m_blockIndex != 0) && m_coeffTable->IsEndOfBlock(&stream))
		{
			m_programState = STATE_SKIPEOB;
		}
		else
		{
			m_programState = STATE_READCOEFF;
		}
		continue;

Label_ReadCoeff:
		{
			MPEG2::RUNLEVELPAIR runLevelPair;
			if(m_blockIndex == 0)
			{
				m_coeffTable->GetRunLevelPairDc(&stream, &runLevelPair, isMpeg2);
			}
			else
			{
				m_coeffTable->GetRunLevelPair(&stream, &runLevelPair, isMpeg2);
			}
			m_blockIndex += runLevelPair.run;
		
			if(m_blockIndex < 0x40)
			{
				m_block[m_blockIndex] = static_cast<int16>(runLevelPair.level);
#ifdef _DECODE_LOGGING
	            CLog::GetInstance().Print(LOG_NAME, "[%i]:%i ", index, runLevelPair.nLevel);
#endif
			}
			else
			{
				assert(0);
				break;
{'fraction_non_alphanumeric': 0.11323708471038442, 'fraction_numerical': 0.010436597669159853, 'mean_word_length': 4.933952528379773, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6953550', 'n_tokens_mistral': 2532, 'n_tokens_neox': 2207, 'n_words': 300}