Skip to content

Commit

Permalink
check in the final stable code
Browse files Browse the repository at this point in the history
  • Loading branch information
jicheng committed Dec 5, 2012
1 parent efd43f2 commit 4f17cf1
Show file tree
Hide file tree
Showing 5,982 changed files with 1,676,113 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
30 changes: 30 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="feipeng.andzop.Main"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="6" />

<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:debuggable="true">
<activity android:name="VideoBrowser2"
android:label="@string/app_name"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="VideoPlayer"
android:label="@string/app_name"
android:screenOrientation="landscape" >
</activity>
<activity android:name=".ROIOptionsDialog"
android:label="Change ROI Size"
android:theme="@android:style/Theme.Dialog">
</activity>
</application>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
</manifest>
35 changes: 35 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
This player is part of the jiku project: http://www.jiku.org/

For a research paper about this player: http://www.comp.nus.edu.sg/~ooiwt/papers/pcm12-zoomable.pdf
For a more detailed description, please refer to my master thesis: http://www.roman10.net/src/thesis.pdf

I've stopped the development for this player. The master branch is the one that is stable and ready to use, while other branches contain code for experiments purposes only.

How to use the app?
1. connect your phone to a computer, "adb install jiku-player.apk" to install the app to your phone.

How to use the app?
1. Create a directory "/sdcard/multitest" and put all videos there.
2. Start the app, click a video, and a menu will pop up. Choose "Dump dependency" to generate the dependency files.
Use "adb logcat -v time" to see how the dependency file generation goes. It might take some time.
3. After dependency file generation is done, click the video again. Choose "View with Andzop" to watch the video.
4. Switch between "Full Mode" and "Auto Mode".
4.a Full mode demonstrates selective decoding; auto mode is more close to real usage.
4.b Press menu key, select "Change Mode", then select the mode you want.
4.c When you're at "Full Mode", you can adjust the ROI size by the "Update ROI size" menu.

How to build the app?
1. At jiku-player/jni/ffmpeg folder, update NDK variable path, and then execute the following command,
./build_android.sh
2. At jiku-player/jni folder, execute the following command,
ndk-build
3. At eclipse, build the project.

The desktop version
There's also an equivalent desktop version available under andzop/jni/andzop_desktop/ folder, it's for debugging purpose. Note that the code might be obsolete compared with the code for android.


TODOs:
1. migrate to latest ffmpeg
2. improve the zoomable interface

Binary file added jiku-player.apk
Binary file not shown.
43 changes: 43 additions & 0 deletions jni/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
LOCAL_PATH := $(call my-dir)

#declare the sqlite library
#include $(CLEAR_VARS)
#LOCAL_MODULE := sqlite-prebuilt
#LOCAL_SRC_FILES := sqlite/android/armv7-a/libsqlite_andzop.so
#LOCAL_EXPORT_C_INCLUDES := sqlite/android/armv7-a/include
#LOCAL_EXPORT_LDLIBS := sqlite/android/armv7-a/libsqlite_andzop.so
#LOCAL_PRELINK_MODULE := true
#include $(PREBUILT_SHARED_LIBRARY)

#declare the prebuilt library
include $(CLEAR_VARS)
LOCAL_MODULE := ffmpeg-prebuilt
LOCAL_SRC_FILES := ffmpeg/android/armv7-a/libffmpeg.so
LOCAL_EXPORT_C_INCLUDES := ffmpeg/android/armv7-a/include
LOCAL_EXPORT_LDLIBS := ffmpeg/android/armv7-a/libffmpeg.so
LOCAL_PRELINK_MODULE := true
include $(PREBUILT_SHARED_LIBRARY)

#the andzop library
include $(CLEAR_VARS)
LOCAL_ALLOW_UNDEFINED_SYMBOLS=false
LOCAL_MODULE := andzop
LOCAL_SRC_FILES := andutils.c cpu_id.c scale.c yuv2rgb.neon.S utility.c queue.c packetqueue.c dependency.c andzop.c
#LOCAL_SRC_FILES := andutils.c scale.c yuv2rgb16tab.c yuv420rgb8888c.c yuv420rgb8888.S utility.c queue.c packetqueue.c dependency.c andzop.c
#LOCAL_SRC_FILES := yuv2rgb.neon.S utility.c queue.c packetqueue.c dependency.c andzop.c
LOCAL_ARM_NEON := true
#ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
#if the cpu supports neon, we use neon
LOCAL_CFLAGS := -DHAVE_NEON=1
LOCAL_ARM_NEON := true
#else
#otherwise, use the arm assembly to scale and do color conversion
# LOCAL_SRC_FILES += scale.c yuv2rgb16tab.c yuv420rgb8888.S
#endif
LOCAL_C_INCLUDES := $(LOCAL_PATH)/ffmpeg/android/armv7-a/include
LOCAL_SHARED_LIBRARY := ffmpeg-prebuilt
LOCAL_STATIC_LIBRARIES := cpufeatures
LOCAL_LDLIBS := -llog -ljnigraphics -lz -lm $(LOCAL_PATH)/ffmpeg/android/armv7-a/libffmpeg.so
#LOCAL_CFLAGS := -g
include $(BUILD_SHARED_LIBRARY)
$(call import-module,cpufeatures)
4 changes: 4 additions & 0 deletions jni/Application.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# The ARMv7 is significanly faster due to the use of the hardware FPU
APP_OPTIM := debug
APP_ABI := armeabi-v7a
APP_PLATFORM := android-8
117 changes: 117 additions & 0 deletions jni/android_specific.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
JNIEXPORT void JNICALL Java_feipeng_andzop_render_RenderView_naClose(JNIEnv *pEnv, jobject pObj) {
andzop_finish();
}

JNIEXPORT void JNICALL Java_feipeng_andzop_render_RenderView_naInit(JNIEnv *pEnv, jobject pObj, int pDumpDep) {
int l_mbH, l_mbW;
int l_i;
//char* l_videoFileNameList[10];
jobjectArray l_videoFileNameObjList;
jfieldID l_fid;
jstring l_videoFileNameStr;
/*get the video file name*/
//l_videoFileName = (char *)(*pEnv)->GetStringUTFChars(pEnv, pFileName, NULL);
if (pObj == NULL) {
LOGE(1, "pObj is NULL");
}
jclass cls = (*pEnv)->GetObjectClass(pEnv, pObj);
l_fid = (*pEnv)->GetFieldID(pEnv, cls, "fileNameList", "[Ljava/lang/String;");
l_videoFileNameObjList = (*pEnv)->GetObjectField(pEnv, pObj, l_fid);
gNumOfVideoFiles = (*pEnv)->GetArrayLength(pEnv, l_videoFileNameObjList);
LOGI(10, "number of video files: %d", gNumOfVideoFiles);
gVideoFileNameList = (char **)malloc(gNumOfVideoFiles*sizeof(char*));
for (l_i = 0; l_i < gNumOfVideoFiles; ++l_i) {
l_videoFileNameStr = (*pEnv)->GetObjectArrayElement(pEnv, l_videoFileNameObjList, l_i);
gVideoFileNameList[l_i] = (char *)(*pEnv)->GetStringUTFChars(pEnv, l_videoFileNameStr, NULL);
LOGI(10, "%d video file name is %s", l_i, gVideoFileNameList[l_i]);
}
gDumpDep = pDumpDep;
andzop_init(0);
}

JNIEXPORT jstring JNICALL Java_feipeng_andzop_render_RenderView_naGetVideoCodecName(JNIEnv *pEnv, jobject pObj) {
char* lCodecName = (char*)gVideoCodecCtxList[gCurrentDecodingVideoFileIndex]->codec->name;
return (*pEnv)->NewStringUTF(pEnv, lCodecName);
}

JNIEXPORT jstring JNICALL Java_feipeng_andzop_render_RenderView_naGetVideoFormatName(JNIEnv *pEnv, jobject pObj) {
char* lFormatName = (char*)gFormatCtxList[gCurrentDecodingVideoFileIndex]->iformat->name;
return (*pEnv)->NewStringUTF(pEnv, lFormatName);
}

JNIEXPORT jintArray JNICALL Java_feipeng_andzop_render_RenderView_naGetVideoResolution(JNIEnv *pEnv, jobject pObj) {
jintArray lRes;
LOGI(2, "start of get video resolution for %d", gCurrentDecodingVideoFileIndex);
lRes = (*pEnv)->NewIntArray(pEnv, 2);
if (lRes == NULL) {
LOGI(1, "cannot allocate memory for video size");
return NULL;
}
jint lVideoRes[2];
lVideoRes[0] = gVideoCodecCtxList[gCurrentDecodingVideoFileIndex]->width;
lVideoRes[1] = gVideoCodecCtxList[gCurrentDecodingVideoFileIndex]->height;
LOGI(2, "end of get video resolution for %d (%d, %d)", gCurrentDecodingVideoFileIndex, lVideoRes[0], lVideoRes[1]);
(*pEnv)->SetIntArrayRegion(pEnv, lRes, 0, 2, lVideoRes);
return lRes;
}

/*get the actual roi*/
/*the actual roi may differ from the user requested roi, as the roi can only change at the beginning of gop*/
JNIEXPORT jfloatArray JNICALL Java_feipeng_andzop_render_RenderView_naGetActualRoi(JNIEnv *pEnv, jobject pObj) {
jfloatArray lRes;
LOGI(2, "start of naGetActualRoi");
lRes = (*pEnv)->NewFloatArray(pEnv, 4);
if (lRes == NULL) {
LOGI(1, "cannot allocate memory for video size");
return NULL;
}
jfloat lVideoRes[4];
//enlarge or shrink the roi size according to the ratio of current video
LOGI(2, "(%d, %d) to (%d, %d)", gRoiSh, gRoiSw, gRoiEh, gRoiEw);
lVideoRes[0] = gRoiSh*16*gVideoPicture.height/gVideoCodecCtxList[gCurrentDecodingVideoFileIndex]->height;
lVideoRes[1] = gRoiSw*16*gVideoPicture.width/gVideoCodecCtxList[gCurrentDecodingVideoFileIndex]->width;
lVideoRes[2] = gRoiEh*16*gVideoPicture.height/gVideoCodecCtxList[gCurrentDecodingVideoFileIndex]->height;
lVideoRes[3] = gRoiEw*16*gVideoPicture.width/gVideoCodecCtxList[gCurrentDecodingVideoFileIndex]->width;
LOGI(2, "(%.2f, %.2f) to (%.2f, %.2f)", lVideoRes[0], lVideoRes[1], lVideoRes[2], lVideoRes[3]);
(*pEnv)->SetFloatArrayRegion(pEnv, lRes, 0, 4, lVideoRes);
LOGI(2, "end of naGetActualRoi");
return lRes;
}

JNIEXPORT void JNICALL Java_feipeng_andzop_render_RenderView_naUpdateZoomLevel(JNIEnv * pEnv, jobject pObj, int _zoomLevelUpdate) {
gZoomLevelUpdate = _zoomLevelUpdate;
}

/*fill in data for a bitmap, 0 on success*/
JNIEXPORT jint JNICALL Java_feipeng_andzop_render_RenderView_naRenderAFrame(JNIEnv * pEnv, jobject pObj, int pMode, jobject pBitmap,
int _width, int _height,
float _roiSh, float _roiSw, float _roiEh, float _roiEw,
int _displaySh, int _displaySw, int _displayEh, int _displayEw) {
AndroidBitmapInfo lInfo;
//void* lPixels;
int lRet;
int li, lj, lk;
int lPos;
unsigned char* ltmp;
LOGI(3, "start of render_a_frame: %d:%d", _width, _height);
//1. retrieve information about the bitmap
if ((lRet = AndroidBitmap_getInfo(pEnv, pBitmap, &lInfo)) < 0) {
LOGE(1, "AndroidBitmap_getInfo failed! error = %d", lRet);
return 1;
}
if (lInfo.format != ANDROID_BITMAP_FORMAT_RGBA_8888) {
LOGE(1, "Bitmap format is not RGBA_8888!");
return 1;
}
//2. lock the pixel buffer and retrieve a pointer to it
if ((lRet = AndroidBitmap_lockPixels(pEnv, pBitmap, &gBitmap)) < 0) {
LOGE(1, "AndroidBitmap_lockPixels() failed! error = %d", lRet);
return 1;
}
//3. modify the pixel buffer
//decode a video frame: the pBitmap will be filled with decoded pixels
lRet = decode_a_frame(pMode, _width, _height, _roiSh, _roiSw, _roiEh, _roiEw, _displaySh, _displaySw, _displayEh, _displayEw);
AndroidBitmap_unlockPixels(pEnv, pBitmap);
LOGI(3, "~~~~~~~~~~end of rendering a frame : %d~~~~~~~~~~~~~~~~~", lRet);
return lRet;
}
14 changes: 14 additions & 0 deletions jni/andutils.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "andutils.h"

int get_file_size(char *fName) {
FILE *f;
int lSize;
f = fopen(fName, "r");
if (f == NULL) {
return -1;
}
fseek(f, 0L, SEEK_END);
lSize = ftell(f);
fclose(f);
return lSize;
}
9 changes: 9 additions & 0 deletions jni/andutils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef ANDUTILS_H
#define ANDUTILS_H

#include <stdio.h>
#include <stdlib.h>

int get_file_size(char *fName);

#endif
Loading

0 comments on commit 4f17cf1

Please sign in to comment.