示例#1
0
static void testGetInfoTwice(Atrac3File &src) {
	checkpointNext("With second buffer:");

	Atrac3File looped((size_t)0);
	CreateLoopedAtracFrom(src, looped, 2048, 200000);

	u8 *buffer = new u8[looped.Size() / 2];
	memcpy(buffer, looped.Data(), looped.Size() / 2);

	int atracID = sceAtracSetDataAndGetID(buffer, looped.Size() / 2);

	u32 secondOff = 0, secondSize = 0;
	sceAtracGetSecondBufferInfo(atracID, &secondOff, &secondSize);
	u8 *secondBuffer = new u8[secondSize];
	memcpy(secondBuffer, looped.Data() + secondOff, secondSize);

	int result = sceAtracSetSecondBuffer(atracID, secondBuffer, secondSize);
	checkpoint("  Set buffer: %08x", result);

	testGetInfo("  With second buffer", atracID);
	sceAtracReleaseAtracID(atracID);

	delete [] buffer;
	delete [] secondBuffer;
}
/*
Identify whether there is a loop or not. If there is a loop, then
follow the below instructions.
- find a node inside a loop - say N
- find the length of the loop - from N to N - say L
- Now, from start, go ahead of L elements in the list - say T1
- Now, take another pointer, say T2 which points to head
- Now, move T2 and T1 one node at a time, if T1 = T2 then you're in 
  the starting of the loop
- Now, take T1 or T2 and move L nodes, and thats the tail node
- set tail nodes next to NULL

O(n) - time 
O(1) - space

*/
void fixloop()
{
	printf("%s: \n", __FUNCTION__);
	NODE *N = looped();
	int L = 1, t, s;
	NODE *T1 = head, *T2 = head;
	NODE *temp = N->next;


	// Find the length of the loop	
	// Start from N and stop at N
	while (temp != N) {
		L++;
		temp = temp->next;
	} 
	
	s = t = L;
	// Now, move T1 L times
	while (L--)
		T1 = T1->next;

	// move T1 and T2 one node at a time 
	// When they meet, they meet at the start of the loop
	while (T2 != T1) {
		T2 = T2->next;
		T1 = T1->next;
	}
	
	// move len-1 times, that will point to the tail node
	while (--t)
		T2 = T2->next;

	T2->next = NULL;
	tail = T2;	
	return;
}
示例#3
0
static void testGetInfoWithLooped(const char *title, Atrac3File &src, int loopStart, int loopEnd) {
	Atrac3File looped((size_t)0);
	CreateLoopedAtracFrom(src, looped, loopStart, loopEnd);

	testGetInfo(title, looped);
}