예제 #1
0
파일: minghsp.c 프로젝트: tkhaga/MingHSP
EXPORT BOOL WINAPI mhsp_SWFBitmap_buf(HSPEXINFO *hei, int p2, int p3, int p4)
{
	unsigned char *buf, *buf2;
	int size, size2;
	SWFInput input;
	SWFBitmap *p1;
	lstrcpy(funcname, "SWFBitmap_buf");
	p1 = (SWFBitmap *)hei->HspFunc_prm_getv();
	buf = (unsigned char *)hei->HspFunc_prm_getv();
	size = hei->HspFunc_prm_geti();
	buf2 = (unsigned char *)hei->HspFunc_prm_getv();
	size2 = hei->HspFunc_prm_getdi(0);
	input = newSWFInput_allocedBuffer(buf, size);
	if (size2 && isJPEG(input)) {
		SWFInput_seek(input, 0, SEEK_SET);
		*p1 = (SWFBitmap)newSWFJpegWithAlpha_fromInput(input,
			 newSWFInput_allocedBuffer(buf2, size2));
	}
#ifdef JAMING
	else if (isDBL(input) || isJPEG(input))
#else
	else if (isDBL(input) || isJPEG(input) || isGIF(input) || isPNG(input) || isBMP(input))
#endif
	{
		SWFInput_seek(input, 0, SEEK_SET);
		*p1 = newSWFBitmap_fromInput(newSWFInput_allocedBuffer(buf, size));
	}
	else {
		return -1;
	}
	if (!mhsp_bitmap) {
		mhsp_bitmap = *p1;
	}
	return 0;
}
예제 #2
0
파일: soundstream.c 프로젝트: cran/R2SWF
SWFSoundStream
newSWFSoundStream_fromInput(SWFInput input)
{
	FLVStream *flvStream;
	SWFSoundStream stream = (SWFSoundStream)malloc(sizeof(struct SWFSoundStream_s));

	/* test if input stream is a FLV file first. */
	flvStream = FLVStream_fromInput(input);
	/* if input is not a valid FLV file a MP3 file is assumed. */
	if(flvStream == NULL)
	{
		SWFInput_seek(input, 0, SEEK_SET);
		stream->streamSource = STREAM_MP3;
		stream->source.mp3.input = input;
		stream->source.mp3.start = 0;
	}
	else
	{
		stream->streamSource = STREAM_FLV;
		stream->source.flv.stream = flvStream;
		stream->source.flv.tagOffset = -1;
	}

	stream->initialDelay = SWFSOUND_INITIAL_DELAY;
	stream->delay = 0;
	stream->isFinished = FALSE;
	stream->samplesPerFrame = 0;
	stream->sampleRate = 0;
	stream->freeInput = FALSE;
	stream->flags = -1;
	return stream;
}
예제 #3
0
파일: soundstream.c 프로젝트: cran/R2SWF
/* XXX - kill this somehow.. */
void
SWFSoundStream_rewind(SWFSoundStream stream)
{
	if(stream->streamSource == STREAM_MP3)
		SWFInput_seek(stream->source.mp3.input, stream->source.mp3.start, SEEK_SET);
	else if(stream->streamSource == STREAM_FLV)
		stream->source.flv.tagOffset = -1;
}
예제 #4
0
파일: minghsp.c 프로젝트: tkhaga/MingHSP
EXPORT BOOL WINAPI mhsp_SWFBitmap(HSPEXINFO *hei, int p2, int p3, int p4)
{
	FILE *fp1, *fp2;
	char filename[MHSP_STRMAX], alpha[MHSP_STRMAX];
	SWFInput input;
	SWFBitmap *p1;
	lstrcpy(funcname, "SWFBitmap");
	p1 = (SWFBitmap *)hei->HspFunc_prm_getv();
	lstrcpyn(filename, hei->HspFunc_prm_gets(), MHSP_STRMAX);
	lstrcpyn(alpha, hei->HspFunc_prm_getds(""), MHSP_STRMAX);
	fp1 = fopen(filename, "rb");
	if (!fp1) {
		return 1;
	}
	input = newSWFInput_file(fp1);
	fp2 = fopen(alpha, "rb");
	if (fp2 && isJPEG(input)) {
		SWFInput_seek(input, 0, SEEK_SET);
		*p1 = (SWFBitmap)newSWFJpegWithAlpha_fromInput(input, newSWFInput_file(fp2));
	}
#ifdef JAMING
	else if (isDBL(input) || isJPEG(input))
#else
	else if (isDBL(input) || isJPEG(input) || isGIF(input) || isPNG(input) || isBMP(input))
#endif
	{
		SWFInput_seek(input, 0, SEEK_SET);
		*p1 = newSWFBitmap_fromInput(input);
	}
	else {
		return -1;	/* 非対応フォーマット */
	}
	if (!mhsp_bitmap) {
		mhsp_bitmap = *p1;
	}
	return 0;
}
예제 #5
0
파일: soundstream.c 프로젝트: cran/R2SWF
static void 
write_flv(SWFSoundStreamBlock streamblock, SWFByteOutputMethod method, void *data)
{
	SWFInput input; 
	FLVStream *flv = streamblock->stream->source.flv.stream;
        FLVTag *tag = &streamblock->stream->source.flv.tag;
        int tagOffset = streamblock->stream->source.flv.tagOffset;
	int l = streamblock->length;
	int ret;
	
	if(tagOffset < 0)
	{
		ret = FLVStream_nextTagType(flv, tag, NULL, FLV_AUDIOTAG);
	
		if(ret < 0)
			return;
	}
	
	input = FLVTag_getPayloadInput(tag);
	if(input == NULL)
		return;

	if(tagOffset > 0)
		SWFInput_seek(input, tagOffset, SEEK_SET);

	while( l>0 )
	{
		int ichar = SWFInput_getChar(input);
		if(ichar != EOF)
		{
			method(ichar, data);
			l--;
			continue;
		}

		ret = FLVStream_nextTagType(flv, tag, tag, FLV_AUDIOTAG);
		if(ret < 0)
                	return;

		input = FLVTag_getPayloadInput(tag);
	 	if(input == NULL)
			return;
	}

	streamblock->stream->source.flv.tag = *tag;
	streamblock->stream->source.flv.tagOffset = SWFInput_tell(input);
}
예제 #6
0
SWFDBLBitmap
newSWFDBLBitmap_fromInput(SWFInput input)
{
	SWFDBLBitmap dbl;
	int version;
	int width, height;

	dbl = (SWFDBLBitmap)malloc(sizeof(struct SWFDBLBitmap_s));

	SWFCharacterInit((SWFCharacter)dbl);

	CHARACTERID(dbl) = ++SWF_gNumCharacters;

	BLOCK(dbl)->writeBlock = writeSWFDBLBitmapToMethod;
	BLOCK(dbl)->complete = completeSWFDBLBitmap;
	BLOCK(dbl)->dtor = (destroySWFBlockMethod) destroySWFCharacter;

	dbl->input = input;

	if ( SWFInput_getChar(input) != 'D' ||
			 SWFInput_getChar(input) != 'B' )
	{
		SWF_error("File is not a DBL file!");
	}

	version = SWFInput_getChar(input);

	if ( version != 'L' && version != 'l' )
		SWF_error("File is not a DBL file!");

	switch ( SWFInput_getChar(input) )
	{
		case 1:
			BLOCK(dbl)->type = SWF_DEFINELOSSLESS;
			break;
		case 2:
			BLOCK(dbl)->type = SWF_DEFINELOSSLESS2;
			break;
		default:
			SWF_error("Unexpected DBL type byte!");
	}

	if ( version == 'l' )
	{
		BLOCK(dbl)->length = SWFInput_getUInt32_BE(input);
		BLOCK(dbl)->length += 2; /* character id */
	}
	else
	{
		/* first version used a 2-byte file length..	brilliant, eh? */

		BLOCK(dbl)->length = SWFInput_getUInt16_BE(input);
		BLOCK(dbl)->length += 2; /* character id */
	}

	SWFInput_getChar(input); /* format */

	width = SWFInput_getUInt16(input);
	height = SWFInput_getUInt16(input);

	/* roll back to beginning of dbl data */
	SWFInput_seek(input, -5, SEEK_CUR);

	CHARACTER(dbl)->bounds = newSWFRect(0, width, 0, height);

	return dbl;
}
예제 #7
0
파일: soundstream.c 프로젝트: cran/R2SWF
static int
fillBlock_flv_mp3(SWFSoundStream stream, SWFSoundStreamBlock block)
{
	FLVStream *flv = stream->source.flv.stream;
	FLVTag *tag = &stream->source.flv.tag; 
	int tagOffset = stream->source.flv.tagOffset;
	int delay, length, frameSize, ret;
	SWFInput input;
	static const int maxSC = 65535;

	block->delay = stream->delay;
	delay = stream->delay + stream->samplesPerFrame;

	if(tagOffset < 0)
	{
		ret = FLVStream_nextTagType(flv, tag, NULL, FLV_AUDIOTAG);
		if(ret < 0)
		{
			SWF_warn("fillStreamBlock_flv: not a valid flv audio stream\n");
			return -1;
		}
	}
	
	input = FLVTag_getPayloadInput(tag);
	if(input == NULL)
		return -1;
		
	if(tagOffset > 0)
		SWFInput_seek(input, tagOffset, SEEK_SET);

	if ( stream->sampleRate > 32000 )
		frameSize = 1152;
	else
		frameSize = 576;

	while ( delay > frameSize)
	{
		length = nextMP3Frame(input);	
		if (length < 0)
		{
			SWF_warn("parse error: not a valid mp3 frame\n");
			return -1;
		}
		else if(length == 0) /* eof */
		{
			ret = FLVStream_nextTagType(flv, tag, tag, FLV_AUDIOTAG);
			if(ret < 0)
				return -1;
			
			input = FLVTag_getPayloadInput(tag);
			if(input == NULL)
				return -1;
		}
		else 
		{
			block->numSamples += frameSize;
			block->length += length;
			delay -= frameSize;
		}
	}
	if ( block->numSamples > maxSC ) {
		SWF_warn("fillBlock_flv_mp3: number of samples in block (%d) exceed max allowed value of %d\n", block->numSamples, maxSC);
	}
	stream->source.flv.tag = *tag;
	stream->source.flv.tagOffset = SWFInput_tell(input);
	stream->delay = delay;
	return 0;
}