From 1e12bb2502f1870923cf4fcbe260ca911c1fb1c3 Mon Sep 17 00:00:00 2001 From: roman10 Date: Mon, 5 Dec 2011 12:36:40 +0800 Subject: [PATCH] add project.properties --- jni/andzop.c | 3 ++ jni/dependency.c | 76 ++++++++++++++++++++++++++++++++++------------ jni/dependency.h | 5 ++- project.properties | 11 +++++++ 4 files changed, 74 insertions(+), 21 deletions(-) create mode 100644 project.properties diff --git a/jni/andzop.c b/jni/andzop.c index 72fadce..e6d0e5f 100644 --- a/jni/andzop.c +++ b/jni/andzop.c @@ -390,6 +390,9 @@ JNIEXPORT jint JNICALL Java_feipeng_andzop_render_RenderView_naRenderAFrame(JNIE sprintf(l_depGopRecFileName, "./%s_goprec_gop%d.txt", gVideoFileNameList[gCurrentDecodingVideoFileIndex], g_decode_gop_num); #endif gVideoCodecCtxList[gCurrentDecodingVideoFileIndex]->g_gopF = fopen(l_depGopRecFileName, "r"); + //unmap the files + unload_frame_mb_stindex(); + unload_frame_mb_edindex(); load_gop_info(gVideoCodecCtxList[gCurrentDecodingVideoFileIndex]->g_gopF, &gGopStart, &gGopEnd); } #endif /*end of ifndef SELECTIVE_DECODING*/ diff --git a/jni/dependency.c b/jni/dependency.c index ae9825c..8db52b0 100644 --- a/jni/dependency.c +++ b/jni/dependency.c @@ -185,11 +185,10 @@ void free_selected_decoding_fields(int p_videoFileIndex, int _mbHeight) { free(gVideoCodecCtxList[p_videoFileIndex]->pred_dc_dir); } -//unsigned int numOfFramesInGop; -//unsigned int mbHeight; -//unsigned int mbWidth; int *mbStartPos; +int mapStLen; int *mbEndPos; +int mapEdLen; struct MBIdx intraDep[MAX_FRAME_NUM_IN_GOP][MAX_MB_H][MAX_MB_W][MAX_DEP_MB]; struct MBIdx interDep[MAX_FRAME_NUM_IN_GOP][MAX_MB_H][MAX_MB_W][MAX_DEP_MB]; @@ -242,48 +241,81 @@ int interDepMask[MAX_FRAME_NUM_IN_GOP][MAX_MB_H][MAX_MB_W]; } LOGI(10, "+++++load_frame_mb_index finished, exit the function"); }*/ -static void load_frame_mb_stindex(int p_videoFileIndex) { +void unload_frame_mb_stindex(void) { + munmap(mbStartPos, mapStLen); +} + +void unload_frame_mb_edindex(void) { + munmap(mbEndPos, mapEdLen); +} + +void load_frame_mb_stindex(int p_videoFileIndex) { + char curDir[100]; int fd; struct stat sbuf; - LOGI(10, "+++++load_frame_mb_stindex\n"); - if (fd = open(gVideoCodecCtxList[p_videoFileIndex]->g_mbStPosF, O_RDONLY) == -1) { - LOGE(1, "file open error"); + char filename[100]; + char *data; + sprintf(filename, "./%s_mbstpos_gop%d.txt", "h1_1280_720_5m.mp4", 1); + LOGI(10, "+++++load_frame_mb_stindex: %s", gVideoCodecCtxList[p_videoFileIndex]->g_mbStPosFileName); + if (strcmp(gVideoCodecCtxList[p_videoFileIndex]->g_mbStPosFileName, filename) == 0) { + LOGI(10, "two strings are equal"); + } + getcwd(curDir, 100); + LOGI(10, "current dir: %s, file: %s = %s", curDir, filename, gVideoCodecCtxList[p_videoFileIndex]->g_mbStPosFileName); + //if (fd = open(gVideoCodecCtxList[p_videoFileIndex]->g_mbStPosFileName, O_RDONLY) == -1) { + if ((fd = open(gVideoCodecCtxList[p_videoFileIndex]->g_mbStPosFileName, O_RDONLY)) == -1) { + LOGE(1, "file open error: %s", gVideoCodecCtxList[p_videoFileIndex]->g_mbStPosFileName); + perror("file open error: "); exit(1); } - if (stat(gVideoCodecCtxList[p_videoFileIndex]->g_mbStPosF, &sbuf) == -1) { + //if (stat(gVideoCodecCtxList[p_videoFileIndex]->g_mbStPosFileName, &sbuf) == -1) { + if (stat(gVideoCodecCtxList[p_videoFileIndex]->g_mbStPosFileName, &sbuf) == -1) { LOGE(1, "stat error"); exit(1); } - mbStartPos = mmap((caddr_t)0, sbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + LOGI(10, "file size: %ld", sbuf.st_size); + //mbStartPos = mmap((caddr_t)0, sbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + //mbStartPos = mmap(0, sbuf.st_size, PROT_READ, MAP_SHARED, fd, 0); + //mbStartPos = mmap(0, sbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + mapStLen = sbuf.st_size; + mbStartPos = mmap(0, sbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0) ; + //mbStartPos = mmap(0, sbuf.st_size, PROT_READ, MAP_SHARED, fd, 0); if (mbStartPos == MAP_FAILED) { LOGE(1, "mmap error"); + perror("mmap error: "); exit(1); } //TODO: preload the data LOGI(10, "+++++load_frame_mb_stindex finished, exit the function"); } -static void load_frame_mb_edindex(int p_videoFileIndex) { +void load_frame_mb_edindex(int p_videoFileIndex) { int fd; struct stat sbuf; - LOGI(10, "+++++load_frame_mb_edindex\n"); - if (fd = open(gVideoCodecCtxList[p_videoFileIndex]->g_mbEdPosF, O_RDONLY) == -1) { + LOGI(10, "+++++load_frame_mb_edindex, file: %s", gVideoCodecCtxList[p_videoFileIndex]->g_mbEdPosFileName); + if ((fd = open(gVideoCodecCtxList[p_videoFileIndex]->g_mbEdPosFileName, O_RDONLY)) == -1) { LOGE(1, "file open error"); exit(1); } - if (stat(gVideoCodecCtxList[p_videoFileIndex]->g_mbEdPosF, &sbuf) == -1) { + if (stat(gVideoCodecCtxList[p_videoFileIndex]->g_mbEdPosFileName, &sbuf) == -1) { LOGE(1, "stat error"); exit(1); } - mbEndPos = mmap((caddr_t)0, sbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + LOGI(10, "file size: %ld", sbuf.st_size); + //mbEndPos = mmap((caddr_t)0, sbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + //mbEndPos = mmap(0, sbuf.st_size, PROT_READ, MAP_SHARED, fd, 0); + mbEndPos = sbuf.st_size; + mbEndPos = mmap(0, sbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); if (mbEndPos == MAP_FAILED) { LOGE(1, "mmap error"); + perror("mmap error: "); exit(1); } //TODO: preload the data LOGI(10, "+++++load_frame_mb_edindex finished, exit the function"); } + static void load_intra_frame_mb_dependency(int p_videoFileIndex, int _stFrame, int _edFrame) { char aLine[40], *aToken; int l_idxF, l_idxH, l_idxW, l_depH, l_depW, l_curDepIdx; @@ -867,7 +899,8 @@ int decode_a_video_packet(int p_videoFileIndex, int _roiStH, int _roiStW, int _r for (l_j = 0; l_j < l_mbWidth; ++l_j) { if (interDepMask[gVideoPacketNum - gStFrame][l_i][l_j] == 1) { gVideoCodecCtxList[p_videoFileIndex]->selected_mb_mask[l_i][l_j] = 1; - } + } else { + } } } #ifdef DUMP_SELECTIVE_DEP @@ -981,10 +1014,10 @@ int decode_a_video_packet(int p_videoFileIndex, int _roiStH, int _roiStW, int _r if (gVideoCodecCtxList[p_videoFileIndex]->selected_mb_mask[l_i][l_j] == 1) { //LOGI(10, "%d:%d", mbEndPos[gVideoPacketNum - gStFrame][l_i][l_j], mbStartPos[gVideoPacketNum - gStFrame][l_i][l_j]); //l_selectiveDecodingDataSize += (mbEndPos[gVideoPacketNum - gStFrame][l_i][l_j] - mbStartPos[gVideoPacketNum - gStFrame][l_i][l_j]); - l_selectiveDecodingDataSize += (*lMbEdPos - *lMbStPos); - ++lMbEdPos; - ++lMbStPos; - } + l_selectiveDecodingDataSize += (*lMbEdPos) - (*lMbStPos); + } + ++lMbEdPos; + ++lMbStPos; } } LOGI(10, "total number of bits: %d", l_selectiveDecodingDataSize); @@ -996,6 +1029,7 @@ int decode_a_video_packet(int p_videoFileIndex, int _roiStH, int _roiStW, int _r gVideoPacket2.size = l_selectiveDecodingDataSize; memset(gVideoPacket2.data, 0, gVideoPacket2.size + FF_INPUT_BUFFER_PADDING_SIZE); l_bufPos = 0; + lMbStPos = mbStartPos, lMbEdPos = mbEndPos; lMbStPos += (gVideoPacketNum - gStFrame)*l_mbHeight*l_mbWidth; lMbEdPos += (gVideoPacketNum - gStFrame)*l_mbHeight*l_mbWidth; //l_bufPos = copy_bits(gVideoPacket.data, gVideoPacket2.data, 0, mbStartPos[gVideoPacketNum - gStFrame][0][0], l_bufPos); @@ -1005,8 +1039,10 @@ int decode_a_video_packet(int p_videoFileIndex, int _roiStH, int _roiStW, int _r for (l_j = 0; l_j < l_mbWidth; ++l_j) { //put the data bits into the composed video packet if (gVideoCodecCtxList[p_videoFileIndex]->selected_mb_mask[l_i][l_j] == 1) { - l_bufPos = copy_bits(gVideoPacket.data, gVideoPacket2.data, *lMbStPos, *lMbEdPos - *lMbStPos, l_bufPos); + l_bufPos = copy_bits(gVideoPacket.data, gVideoPacket2.data, *lMbStPos, (*lMbEdPos) - (*lMbStPos), l_bufPos); } + ++lMbEdPos; + ++lMbStPos; } } //stuffing the last byte diff --git a/jni/dependency.h b/jni/dependency.h index b88b4f4..cbeded1 100644 --- a/jni/dependency.h +++ b/jni/dependency.h @@ -115,5 +115,8 @@ void dep_decode_a_video_packet(int p_videoFileIndex); int load_gop_info(FILE* p_gopRecFile, int *p_startF, int *p_endF); int if_dependency_complete(int p_videoFileIndex, int p_gopNum); void prepare_decode_of_gop(int p_videoFileIndex, int _stFrame, int _edFrame, int _roiSh, int _roiSw, int _roiEh, int _roiEw); - +void load_frame_mb_stindex(int p_videoFileIndex); +void load_frame_mb_edindex(int p_videoFileIndex); +void unload_frame_mb_stindex(void); +void unload_frame_mb_edindex(void); diff --git a/project.properties b/project.properties new file mode 100644 index 0000000..5a70945 --- /dev/null +++ b/project.properties @@ -0,0 +1,11 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "ant.properties", and override values to adapt the script to your +# project structure. + +# Project target. +target=android-7