-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdependency.h
120 lines (99 loc) · 4.01 KB
/
dependency.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <errno.h>
/*ffmpeg headers*/
#include <libavutil/avstring.h>
//#include <libavutil/colorspace.h>
#include <libavutil/pixdesc.h>
#include <libavutil/imgutils.h>
#include <libavutil/samplefmt.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#include <libavcodec/avcodec.h>
#include <libavcodec/opt.h>
#include <libavcodec/avfft.h>
/*our header files*/
#include "queue.h"
#include "utility.h"
#include "packetqueue.h"
/*for logs*/
//#define ANDROID_BUILD
#define LOG_LEVEL 20
#ifdef ANDROID_BUILD
/*for android logs*/
/*android specific headers*/
#include <android/log.h>
#define LOG_TAG "libandzop"
#define LOGI(level, ...) if (level <= LOG_LEVEL) {__android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__);}
#define LOGE(level, ...) if (level <= LOG_LEVEL) {__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__);}
#else
/*for normal desktop app logs*/
#define LOGI(level, ...) if (level <= LOG_LEVEL) {printf(__VA_ARGS__); printf("\n");}
#define LOGE(level, ...) if (level <= LOG_LEVEL) {printf(__VA_ARGS__); printf("\n");}
#endif
#define SELECTIVE_DECODING //commented: run as normal decoding mode; uncommented: run as selective decoding mode
//#define NORM_DECODE_DEBUG //uncommented: dump dependency for normal decoding mode; should be commented at //selective decoding mode
//#define DUMP_SELECTED_MB_MASK //enabled: dump the mask for the mb needed;
//#define DUMP_VIDEO_FRAME_BYTES //enabled: dump the bytes to a binary file
//#define DUMP_SELECTIVE_DEP //enabled: dump the relationship in memory to files
#define MAX_FRAME_NUM_IN_GOP 50
#define MAX_MB_H 100
#define MAX_MB_W 100
#define MAX_INTER_DEP_MB 4
#define MAX_INTRA_DEP_MB 3
#define DUMP_PACKET
//#define CLEAR_DEP_BEFORE_START
/*structure for decoded video frame*/
typedef struct VideoPicture {
double pts;
double delay;
int width, height; //the requested size/the bitmap resolution
AVPicture data;
} VideoPicture;
AVCodecContext **gVideoCodecCtxDepList;
AVCodecContext **gVideoCodecCtxList;
VideoPicture gVideoPicture;
struct SwsContext *gImgConvertCtx; //[TODO]: check out why declear as global, probably for caching reason
AVFormatContext **gFormatCtxList;
AVFormatContext **gFormatCtxDepList;
int gNumOfVideoFiles;
int gCurrentDecodingVideoFileIndex;
char **gVideoFileNameList; //the list of video file names
int *gVideoStreamIndexList; //video stream index
int gStFrame;
int gVideoPacketNum; //the current frame number
//int g_dep_videoPacketNum; //the current frame number when dumping dependency
AVPacket *gVideoPacketDepList; //the video packet for dumping dependency
AVPacket gVideoPacket; //the original video packet
AVPacket gVideoPacket2; //the composed video packet
int gRoiSh, gRoiSw, gRoiEh, gRoiEw;
/*the file names for the dependency relationship*/
/*FILE *g_mbPosF;
FILE *g_intraDepF;
FILE *g_interDepF;
FILE *g_dcPredF;
FILE *g_gopF;*/
int gGopStart;
int gGopEnd;
int *gZoomLevelToVideoIndex;
void get_video_info(int p_debug);
void allocate_selected_decoding_fields(int p_videoFileIndex, int _mbHeight, int _mbWidth);
void free_selected_decoding_fields(int p_videoFileIndex, int _mbHeight);
void dump_frame_to_file(int _frameNum);
void decode_a_video_packet(int p_videoFileIndex, int _roiStH, int _roiStW, int _roiEdH, int _roiEdW);
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);
void unload_frame_dc_pred_direction(void);
void unload_inter_frame_mb_dependency(void);
void unload_intra_frame_mb_dependency(void);