Exemple #1
0
ECode Movie::NativeDecodeStream(
    /* [in] */ IInputStream* istream,
    /* [out] */IMovie** movie)
{
    VALIDATE_NOT_NULL(movie);
    // NPE_CHECK_RETURN_ZERO(env, istream);
    if (istream == NULL) {
        *movie = NULL;
        return NOERROR;
    }

    AutoPtr<ArrayOf<Byte> > byteArray = ArrayOf<Byte>::Alloc(16*1024);
    // ScopedLocalRef<jbyteArray> scoper(env, byteArray);
    SkStream* strm = CreateInputStreamAdaptor(istream, byteArray);
    if (NULL == strm) {
        *movie = NULL;
        return NOERROR;
    }

    // Need to buffer enough input to be able to rewind as much as might be read by a decoder
    // trying to determine the stream's format. The only decoder for movies is GIF, which
    // will only read 6.
    // FIXME: Get this number from SkImageDecoder
    SkAutoTUnref<SkStreamRewindable> bufferedStream(SkFrontBufferedStream::Create(strm, 6));
    SkASSERT(bufferedStream.get() != NULL);

    SkMovie* moov = SkMovie::DecodeStream(bufferedStream);
    strm->unref();
    return CreateMovie(moov, movie);
}
Exemple #2
0
ECode Movie::DecodeByteArray(
    /* [in] */ ArrayOf<Byte>* data,
    /* [in] */ Int32 offset,
    /* [in] */ Int32 length,
    /* [out] */ IMovie** movie)
{
    VALIDATE_NOT_NULL(movie);

    Int32 totalLength = data->GetLength();
    if ((offset | length) < 0 || offset + length > totalLength) {
        // doThrow(env, "java/lang/ArrayIndexOutOfBoundsException");
        return E_ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION;
    }

    SkMovie* moov = SkMovie::DecodeMemory(data->GetPayload() + offset, length);
    return CreateMovie(moov, movie);
}
Exemple #3
0
ECode Movie::NativeDecodeAsset(
    /* [in] */ Int64 native_asset,
    /* [out] */IMovie** movie)
{
    VALIDATE_NOT_NULL(movie);
    android::Asset* asset = reinterpret_cast<android::Asset*>(native_asset);
    if (asset == NULL) {
        *movie = NULL;
        return NOERROR;
    }
    SkAutoTUnref<SkStreamRewindable> stream (new AssetStreamAdaptor(asset,
            AssetStreamAdaptor::kNo_OwnAsset,
            AssetStreamAdaptor::kNo_HasMemoryBase));
    SkMovie* moov = SkMovie::DecodeStream(stream.get());

    return CreateMovie(moov, movie);
}
Exemple #4
0
int main(int argc, char *argv[])
{
	int x = 0;
	int bw = 0, vf = 0, hm = 0, e = 0, p = 0, m = 0;
	int c = 0, rv = 0, rs = 0, ff = 0;
	char *fin = NULL, *fout = NULL;
	int W = 0, H = 0, numFrames = 0;
	int sFrame = 0, eFrame = 0, res = 0, fFrame = 0;
	MOVIE *movie;

 /*entering while loop to check options entered*/
	while(x < argc)
	{
		/*specify input video*/
		if(0 == strcmp(&argv[x][0], "-i")) 
		{
			if(x < argc - 1)
			{
				fin = (char *)malloc(sizeof(char) * (strlen(&argv[x + 1][0]) + strlen(".yuv") + 1));
				strcpy(fin, argv[x + 1]);
				strcat( fin, ".yuv");
			}/*fi*/
			else
			{
				printf("Missing argument for input name!");
				free(fin);
				free(fout);
				return 5;
			}/*esle*/
			x += 2;
			continue;
		}/*fi*/

		/*specify output video*/
		if(0 == strcmp(&argv[x][0], "-o")) 
		{
			if(x < argc - 1)
			{
				fout = (char *)malloc(sizeof(char) * (strlen(&argv[x + 1][0]) + strlen(".yuv") + 1));
				strcpy(fout, argv[x + 1]);
				strcat( fout, ".yuv");
			}/*fi*/
			else
			{
				printf("Missing argument for output name!");
				free(fin);
				free(fout);
				return 5;
			}/*esle*/
			x += 2;
			continue;
		}/*fi*/
		
		/*set resolution of input stream */
		if(0 == strcmp(&argv[x][0], "-s"))
		{
			if (x < argc - 1)
			{
				if(sscanf(argv[x + 1], "%dx%d", &W, &H) == 2)
				{
					assert(W);
					assert(H);
				}
				
				else
				{
					printf("not.\nResolution information provided by -s parameter is incorrect.\n");
					PrintUsage();
					free(fin);
					free(fout);
					return 5;
				}
			}
			else
			{
				printf("t.\nResolution information provided by -s parameter is incorrect.\n");
				PrintUsage();
				free(fin);
				free(fout);
				return 5;
			}
			x += 2;
			continue;
		} /*fi */
		
		if(0 == strcmp(&argv[x][0], "-f"))
		{
			if (x < argc - 1)
			{
				if(sscanf(argv[x + 1], "%d", &numFrames) == 1)
				{
					assert(numFrames);
				}
				else
				{
					printf("Number of frames information provided by -f parameter is incorrect.\n");
					PrintUsage();
					free(fin);
					free(fout);
					return 5;
				}
			}
			else
			{
				printf("Number of frames information provided by -f parameter is incorrect.\n");
				PrintUsage();
				free(fin);
				free(fout);
				return 5;
			}
			x += 2;
			continue;
		} /* fi */
		
		if ( 0 == strcmp(&argv[x][0], "-m"))
		{
			m = 1;
			x++;
			continue;
		}
		
		if( 0 == strcmp(&argv[x][0], "-bw"))
		{
			bw = 1;
			x++;
			continue;
		} /* fi */
		
		if( 0 == strcmp(&argv[x][0], "-vflip"))
		{
			vf = 1;
			x++;
			continue;
		} /* fi */
		
		if( 0 == strcmp(&argv[x][0], "-hmirror"))
		{
			hm = 1;
			x++;
			continue;
		} /* fi */

		if( 0 == strcmp(&argv[x][0], "-edge"))
		{
			e = 1;
			x++;
			continue;
		} /* fi */

		if( 0 == strcmp(&argv[x][0], "-poster"))
		{
			p = 1;
			x++;
			continue;
		} /* fi */
		
		if ( 0 == strcmp(&argv[x][0], "-rvs"))
		{
			rv = 1;
			x++;
			continue;
		}

		if( 0 == strcmp(&argv[x][0], "-cut"))
		{
			if (x < argc -1)
			{
				if(sscanf(argv[x + 1], "%d-%d", &sFrame, &eFrame) == 2)
				{
					assert(sFrame);
					assert(eFrame);
				}
				else
				{
					printf("Frames information given by -cut parameter is incorrect.\n");
					PrintUsage();
					free(fin);
					free(fout);
					return 5;
				}
			}
			else
			{
				printf("Frames information given by -cut parameter is incorrect. \n");
				PrintUsage();
				free(fin);
				free(fout);
				return 5;
			}
			c = 1;
			x += 2;
			continue;
		} /* fi */
		
		if( 0 == strcmp(&argv[x][0], "-resize"))
		{
			if (x < argc - 1)
			{
				if (sscanf(argv[x + 1], "%d", &res) == 1)
				{
					assert(res);
				}
				else
				{
					printf("Resolution information given by -resize parameter is incorrect.\n");
					PrintUsage();
					free(fin);
					free(fout);
					return 5;
				}
			}
			else
			{
				printf("Resolution information given by -resize parameter is incorrect.\n");
				PrintUsage();
				free(fin);
				free(fout);
				return 5;
			}
			rs = 1;
			x += 2;
			continue;
		} /* fi */
		
		if ( 0 == strcmp(&argv[x][0], "-fast"))
		{
			if (x < argc - 1)
			{
				if (sscanf(argv[x + 1], "%d", &fFrame) == 1)
				{
					assert(fFrame);
				}
				else
				{
					printf("Frames information given by -fast parameter is incorrect.\n");
					PrintUsage();
					free(fin);
					free(fout);
					return 5;
				}
			}
			else
			{
				printf("Frames information given by -fast parameter is incorrect.\n");
				PrintUsage();
				free(fin);
				free(fout);
				return 5;
			}
			ff = 1;
			x += 2;
			continue;
		} /* fi */
		
		/*help option*/
		if(0 == strcmp(&argv[x][0], "-h")) 
		{ 
			PrintUsage();
			free(fin);
			free(fout);
			return 0;
		}/*fi*/
		x++;
	}/*elihw*/

	if(!fin && !m){
		printf("Missing argument for input name!\n");
		PrintUsage();
		free(fin);
		free(fout);
		return 5;
	}

	if(!fout){
		printf("Missing argument for output name!\n");
		PrintUsage();
		free(fin);
		free(fout);
		return 5;
	}
	
	if(W == 0 || H == 0)
	{
		printf("Test.\nNo resolution information provided by -s parameter.\n");
		PrintUsage();
		free(fin);
		free(fout);
		return 5;
	}
	
	if(numFrames == 0)
	{
		printf("Test.\nNumber of frames information provided by -f parameter is incorrect.\n");
		PrintUsage();
		free(fin);
		free(fout);
		return 5;
	}
	
	movie = CreateMovie(numFrames, W, H);
	if (m == 1)
	{
		MandelbrotMovie(numFrames, W, H, movie);
		printf("Operation Mandelbrot is done!\n");
	}
	else{
		
		ReadMovie(fin, numFrames, W, H, movie);
		if(bw == 1)
		{
			Movie_DIP_Operation(movie, BlackNWhite);
			printf("Operation BlackNWhite is done!\n");
		}

		if(vf == 1)
		{
			Movie_DIP_Operation(movie, VFlip);
			printf("Operation VFlip is done!\n");
		}	
		
		if(hm == 1)
		{
			Movie_DIP_Operation(movie, HMirror);
			printf("Operation HMirror is done!\n");
		}
		
		if(e == 1)
		{
			Movie_DIP_Operation(movie, Edge);
			printf("Operation Edge is done!\n");
		}
		
		if(p == 1)
		{
			Movie_DIP_Operation(movie, Posterize);
			printf("Operation Posterize is done!\n");
		}	
		
		if(rv == 1)
		{
			ReverseImageList(movie->Frames);
			printf("Operation VFlip is done!\n");
		}
		
		
		if(rs == 1)
		{
			ResizeImageList(movie->Frames,res);
			printf("Operation Resize is done! New Width/Height = %dx%d\n", (W*res/100), (H*res/100));
			movie->Width = (W*res/100);
			movie->Height = (H*res/100);
		}
		
		if(c == 1)
		{
			CropImageList(movie->Frames, sFrame, eFrame);
			printf("Operation Frame Cropping is done!\n");
			movie->NumFrames = movie->Frames->Length;
		}	
		
		if(ff == 1)
		{
			
			printf("Operation Fast Forward is done! Number of frames = %u.\n", FastImageList(movie->Frames, fFrame));
			movie->NumFrames = movie->Frames->Length;
		}
	}
	
	/*printf("%d", movie->Frames->Length);*/
	SaveMovie(fout, movie);
	
	DeleteMovie(movie);
	movie = NULL;
	
	
	free(fin);
	free(fout);
	fin = NULL;
	fout = NULL;

	return 0;
}