Skip to content

Commit 8d24e9f

Browse files
committed
dcp changed to mmap based
1 parent 7801dfa commit 8d24e9f

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

dependency.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ void allocate_selected_decoding_fields(int p_videoFileIndex, int _mbHeight, int
163163
for (l_i = 0; l_i < _mbHeight; ++l_i) {
164164
gVideoCodecCtxList[p_videoFileIndex]->selected_mb_mask[l_i] = (unsigned char *) malloc(_mbWidth * sizeof(unsigned char));
165165
}
166-
gVideoCodecCtxList[p_videoFileIndex]->pred_dc_dir = (unsigned char **) malloc(_mbHeight * sizeof(unsigned char *));
166+
/*gVideoCodecCtxList[p_videoFileIndex]->pred_dc_dir = (unsigned char **) malloc(_mbHeight * sizeof(unsigned char *));
167167
for (l_i = 0; l_i < _mbHeight; ++l_i) {
168168
gVideoCodecCtxList[p_videoFileIndex]->pred_dc_dir[l_i] = (unsigned char *) malloc(_mbWidth * sizeof(unsigned char));
169-
}
169+
}*/
170170
LOGI(10, "allocate %d video selected decoding fields: %d, %d is done", p_videoFileIndex, _mbHeight, _mbWidth);
171171
}
172172

@@ -177,10 +177,10 @@ void free_selected_decoding_fields(int p_videoFileIndex, int _mbHeight) {
177177
free(gVideoCodecCtxList[p_videoFileIndex]->selected_mb_mask[l_i]);
178178
}
179179
free(gVideoCodecCtxList[p_videoFileIndex]->selected_mb_mask);
180-
for (l_i = 0; l_i < _mbHeight; ++l_i) {
180+
/*for (l_i = 0; l_i < _mbHeight; ++l_i) {
181181
free(gVideoCodecCtxList[p_videoFileIndex]->pred_dc_dir[l_i]);
182182
}
183-
free(gVideoCodecCtxList[p_videoFileIndex]->pred_dc_dir);
183+
free(gVideoCodecCtxList[p_videoFileIndex]->pred_dc_dir);*/
184184
}
185185

186186
int *mbStartPos;
@@ -441,18 +441,19 @@ static void load_gop_dc_pred_direction(int p_videoFileIndex) {
441441

442442

443443
static void load_frame_dc_pred_direction(int p_videoFileIndex, int _height, int _width) {
444-
FILE *testF;
444+
// FILE *testF;
445445
int i, j;
446446
LOGI(10, "load_frame_dc_pred_direction\n");
447-
memset(gVideoCodecCtxList[p_videoFileIndex]->pred_dc_dir, 0, _height*_width*sizeof(gVideoCodecCtxList[p_videoFileIndex]->pred_dc_dir[0][0]));
447+
//memset(gVideoCodecCtxList[p_videoFileIndex]->pred_dc_dir, 0, _height*_width*sizeof(gVideoCodecCtxList[p_videoFileIndex]->pred_dc_dir[0][0]));
448448
gVideoCodecCtxList[p_videoFileIndex]->pred_dc_dir = dcpPosMove;
449-
testF = fopen("test.txt", "a+");
449+
/*testF = fopen("test.txt", "a+");
450450
for (i = 0; i < _height; ++i) {
451451
for (j = 0; j < _width; ++j) {
452-
fprintf("%d:%d:%d\n", i, j, gVideoCodecCtxList[p_videoFileIndex]->pred_dc_dir[i][j]);
452+
//fprintf("%d:%d:%d\n", i, j, *(gVideoCodecCtxList[p_videoFileIndex]->pred_dc_dir + (i*_width) + j));
453+
fprintf(testF, "%d:%d:%d\n", i, j, gVideoCodecCtxList[p_videoFileIndex]->pred_dc_dir[(i*_width) + j]);
453454
}
454455
}
455-
fclose(testF);
456+
fclose(testF);*/
456457
dcpPosMove += _height*_width;
457458
LOGI(10, "load_frame_dc_pred_direction done\n");
458459
}
@@ -982,7 +983,7 @@ void decode_a_video_packet(int p_videoFileIndex, int _roiStH, int _roiStW, int _
982983
l_dcpF = fopen(l_dcpFName, "w");
983984
for (l_i = 0; l_i < l_mbHeight; ++l_i) {
984985
for (l_j = 0; l_j < l_mbWidth; ++l_j) {
985-
fprintf(l_dcpF, "%d:", gVideoCodecCtxList[p_videoFileIndex]->pred_dc_dir[l_i][l_j]);
986+
//fprintf(l_dcpF, "%d:", gVideoCodecCtxList[p_videoFileIndex]->pred_dc_dir[l_i][l_j]);
986987
}
987988
fprintf(l_dcpF, "\n");
988989
}

libavcodec/avcodec.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2915,7 +2915,8 @@ typedef struct AVCodecContext {
29152915
*/
29162916
int allow_selective_decoding;
29172917
unsigned char **selected_mb_mask;
2918-
unsigned char **pred_dc_dir;
2918+
//unsigned char **pred_dc_dir;
2919+
unsigned char *pred_dc_dir;
29192920
//int roi_start_mb_x, roi_start_mb_y, roi_end_mb_x, roi_end_mb_y;
29202921
int dump_dependency;
29212922
/*char *dep_gop_file_name;

libavcodec/mpeg4video.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ static inline int ff_mpeg4_pred_dc_internal(MpegEncContext * s, int n, int level
171171
updated to directly read the decisions from log files
172172
when selective encoding is on, but if we're dumping dependency, we don't read the prediction*/
173173
if ((s->avctx->allow_selective_decoding == 1) && (!dump_dep)) {
174-
*dir_ptr = (s->avctx->pred_dc_dir[s->mb_y][s->mb_x] & (1 << n));
174+
//*dir_ptr = (s->avctx->pred_dc_dir[s->mb_y][s->mb_x] & (1 << n));
175+
*dir_ptr = (*(s->avctx->pred_dc_dir + s->mb_y * s->mb_width + s->mb_x)) & (1 << n);
175176
if (*dir_ptr == 0) {
176177
pred = a;
177178
} else {

0 commit comments

Comments
 (0)