1
0

mp4def.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975
  1. /* ///////////////////////////////////////////////////////////////////////
  2. //
  3. // INTEL CORPORATION PROPRIETARY INFORMATION
  4. // This software is supplied under the terms of a license agreement or
  5. // nondisclosure agreement with Intel Corporation and may not be copied
  6. // or disclosed except in accordance with the terms of that agreement.
  7. // Copyright (c) 2001-2008 Intel Corporation. All Rights Reserved.
  8. //
  9. // Description: MPEG-4 header.
  10. //
  11. */
  12. #pragma once
  13. #include <bfc/platform/types.h>
  14. #include <stdlib.h>
  15. #include <stdio.h>
  16. #include <string.h>
  17. #include "../tools/staticlib/ipp_px.h"
  18. #include "ippdefs.h"
  19. #include "ippcore.h"
  20. #include "ipps.h"
  21. #include "ippi.h"
  22. #include "ippvc.h"
  23. //#include "vm_debug.h"
  24. //#include "vm_thread.h"
  25. #pragma warning(disable : 4710) // function not inlined
  26. #pragma warning(disable : 4514) // unreferenced inline function has been removed CL
  27. #pragma warning(disable : 4100) // unreferenced formal parameter CL
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. //#define USE_INLINE_BITS_FUNC
  32. #define USE_NOTCODED_STATE
  33. #if defined(__INTEL_COMPILER) || defined(_MSC_VER)
  34. #define __INLINE static __inline
  35. #elif defined( __GNUC__ )
  36. #define __INLINE static __inline__
  37. #else
  38. #define __INLINE static
  39. #endif
  40. #if defined(__INTEL_COMPILER) && !defined(_WIN32_WCE)
  41. #define __ALIGN16(type, name, size) \
  42. __declspec (align(16)) type name[size]
  43. #else
  44. #if defined(_WIN64) || defined(WIN64) || defined(LINUX64)
  45. #define __ALIGN16(type, name, size) \
  46. uint8_t _a16_##name[(size)*sizeof(type)+15]; type *name = (type*)(((int64_t)(_a16_##name) + 15) & ~15)
  47. #else
  48. #define __ALIGN16(type, name, size) \
  49. uint8_t _a16_##name[(size)*sizeof(type)+15]; type *name = (type*)(((int32_t)(_a16_##name) + 15) & ~15)
  50. #endif
  51. #endif
  52. #define mp4_CLIP(x, min, max) if ((x) < (min)) (x) = (min); else if ((x) > (max)) (x) = (max)
  53. #define mp4_CLIPR(x, max) if ((x) > (max)) (x) = (max)
  54. #define mp4_SWAP(type, x, y) {mp4_Frame *t = (x); (x) = (y); (y) = t;}
  55. #define mp4_ABS(a) ((a) >= 0 ? (a) : -(a))
  56. /* Timer Info */
  57. #if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64)
  58. #include <windows.h>
  59. typedef struct _mp4_Timer {
  60. LARGE_INTEGER count;
  61. LARGE_INTEGER start;
  62. LARGE_INTEGER stop;
  63. int32_t calls;
  64. } mp4_Timer;
  65. __INLINE void mp4_TimerStart(mp4_Timer *t)
  66. {
  67. QueryPerformanceCounter(&t->start);
  68. }
  69. __INLINE void mp4_TimerStop(mp4_Timer *t)
  70. {
  71. QueryPerformanceCounter(&t->stop);
  72. t->count.QuadPart += t->stop.QuadPart - t->start.QuadPart;
  73. t->calls ++;
  74. }
  75. #define TIMER_FREQ_TYPE LARGE_INTEGER
  76. __INLINE void mp4_GetTimerFreq(TIMER_FREQ_TYPE *f)
  77. {
  78. QueryPerformanceFrequency(f);
  79. }
  80. __INLINE double mp4_GetTimerSec(mp4_Timer *t, TIMER_FREQ_TYPE f)
  81. {
  82. return (double)t->count.QuadPart / (double)f.QuadPart;
  83. }
  84. #else // LINUX
  85. #include <time.h>
  86. typedef struct _mp4_Timer {
  87. clock_t count;
  88. clock_t start;
  89. clock_t stop;
  90. int32_t calls;
  91. } mp4_Timer;
  92. __INLINE void mp4_TimerStart(mp4_Timer *t)
  93. {
  94. t->start = clock();
  95. }
  96. __INLINE void mp4_TimerStop(mp4_Timer *t)
  97. {
  98. t->stop = clock();
  99. t->count += t->stop - t->start;
  100. t->calls ++;
  101. }
  102. #define TIMER_FREQ_TYPE int32_t
  103. __INLINE void mp4_GetTimerFreq(TIMER_FREQ_TYPE *f)
  104. {
  105. *f = CLOCKS_PER_SEC;
  106. }
  107. __INLINE double mp4_GetTimerSec(mp4_Timer *t, TIMER_FREQ_TYPE f)
  108. {
  109. return (double)t->count / (double)f;
  110. }
  111. #endif
  112. /* number of exterior MB */
  113. #define MP4_NUM_EXT_MB 1
  114. /* Statistic Info */
  115. typedef struct _mp4_Statistic {
  116. // VideoObjectLayer Info
  117. int32_t nVOP;
  118. int32_t nVOP_I;
  119. int32_t nVOP_P;
  120. int32_t nVOP_B;
  121. int32_t nVOP_S;
  122. int32_t nMB;
  123. int32_t nMB_INTER;
  124. int32_t nMB_INTER_Q;
  125. int32_t nMB_INTRA;
  126. int32_t nMB_INTRA_Q;
  127. int32_t nMB_INTER4V;
  128. int32_t nMB_DIRECT;
  129. int32_t nMB_INTERPOLATE;
  130. int32_t nMB_BACKWARD;
  131. int32_t nMB_FORWARD;
  132. int32_t nMB_NOTCODED;
  133. int32_t nB_INTRA_DC;
  134. int32_t nB_INTRA_AC;
  135. int32_t nB_INTER_C;
  136. int32_t nB_INTER_NC;
  137. // app Timing Info
  138. mp4_Timer time_DecodeShow; // decode + draw + file reading
  139. mp4_Timer time_Decode; // decode + file reading
  140. mp4_Timer time_DecodeOnly; // decode only
  141. } mp4_Statistic;
  142. __INLINE void mp4_StatisticInc(int32_t *s)
  143. {
  144. *s = (*s) + 1;
  145. }
  146. // when using Full Statistic, FPS is less
  147. #ifdef MP4_FULL_STAT
  148. #define mp4_StatisticInc_(s) mp4_StatisticInc(s)
  149. #define mp4_TimerStart_(t) mp4_TimerStart(t)
  150. #define mp4_TimerStop_(t) mp4_TimerStop(t)
  151. #else
  152. #define mp4_StatisticInc_(s)
  153. #define mp4_TimerStart_(t)
  154. #define mp4_TimerStop_(t)
  155. #endif
  156. /* status codes */
  157. typedef enum {
  158. MP4_STATUS_OK = 0, // no error
  159. MP4_STATUS_NO_MEM = -1, // out of memory
  160. MP4_STATUS_FILE_ERROR = -2, // file error
  161. MP4_STATUS_NOTSUPPORT = -3, // not supported mode
  162. MP4_STATUS_PARSE_ERROR = -4, // fail in parse MPEG-4 stream
  163. MP4_STATUS_ERROR = -5 // unknown/unspecified error
  164. } mp4_Status;
  165. /* MPEG-4 start code values */
  166. // ISO/IEC 14496-2: table 6-3
  167. enum {
  168. MP4_VIDEO_OBJECT_MIN_SC = 0x00,
  169. MP4_VIDEO_OBJECT_MAX_SC = 0x1F,
  170. MP4_VIDEO_OBJECT_LAYER_MIN_SC = 0x20,
  171. MP4_VIDEO_OBJECT_LAYER_MAX_SC = 0x2F,
  172. MP4_FGS_BP_MIN_SC = 0x40,
  173. MP4_FGS_BP_MAX_SC = 0x5F,
  174. MP4_VISUAL_OBJECT_SEQUENCE_SC = 0xB0,
  175. MP4_VISUAL_OBJECT_SEQUENCE_EC = 0xB1,
  176. MP4_USER_DATA_SC = 0xB2,
  177. MP4_GROUP_OF_VOP_SC = 0xB3,
  178. MP4_VIDEO_SESSION_ERROR_SC = 0xB4,
  179. MP4_VISUAL_OBJECT_SC = 0xB5,
  180. MP4_VIDEO_OBJECT_PLANE_SC = 0xB6,
  181. MP4_SLICE_SC = 0xB7,
  182. MP4_EXTENSION_SC = 0xB8,
  183. MP4_FGS_VOP_SC = 0xB9,
  184. MP4_FBA_OBJECT_SC = 0xBA,
  185. MP4_FBA_OBJECT_PLANE_SC = 0xBB,
  186. MP4_MESH_OBJECT_SC = 0xBC,
  187. MP4_MESH_OBJECT_PLANE_SC = 0xBD,
  188. MP4_STILL_TEXTURE_OBJECT_SC = 0xBE,
  189. MP4_TEXTURE_SPATIAL_LAYER_SC = 0xBF,
  190. MP4_TEXTURE_SNR_LAYER_SC = 0xC0,
  191. MP4_TEXTURE_TILE_SC = 0xC1,
  192. MP4_TEXTURE_SHAPE_LAYER_SC = 0xC2,
  193. MP4_STUFFING_SC = 0xC3
  194. };
  195. /* MPEG-4 code values */
  196. // ISO/IEC 14496-2:2004 table 6-6
  197. enum {
  198. MP4_VISUAL_OBJECT_TYPE_VIDEO = 1,
  199. MP4_VISUAL_OBJECT_TYPE_TEXTURE = 2,
  200. MP4_VISUAL_OBJECT_TYPE_MESH = 3,
  201. MP4_VISUAL_OBJECT_TYPE_FBA = 4,
  202. MP4_VISUAL_OBJECT_TYPE_3DMESH = 5
  203. };
  204. // ISO/IEC 14496-2:2004 table 6-7
  205. enum {
  206. MP4_VIDEO_FORMAT_COMPONENT = 0,
  207. MP4_VIDEO_FORMAT_PAL = 1,
  208. MP4_VIDEO_FORMAT_NTSC = 2,
  209. MP4_VIDEO_FORMAT_SECAM = 3,
  210. MP4_VIDEO_FORMAT_MAC = 4,
  211. MP4_VIDEO_FORMAT_UNSPECIFIED = 5
  212. };
  213. // ISO/IEC 14496-2:2004 table 6-8..10
  214. enum {
  215. MP4_VIDEO_COLORS_FORBIDDEN = 0,
  216. MP4_VIDEO_COLORS_ITU_R_BT_709 = 1,
  217. MP4_VIDEO_COLORS_UNSPECIFIED = 2,
  218. MP4_VIDEO_COLORS_RESERVED = 3,
  219. MP4_VIDEO_COLORS_ITU_R_BT_470_2_M = 4,
  220. MP4_VIDEO_COLORS_ITU_R_BT_470_2_BG = 5,
  221. MP4_VIDEO_COLORS_SMPTE_170M = 6,
  222. MP4_VIDEO_COLORS_SMPTE_240M = 7,
  223. MP4_VIDEO_COLORS_GENERIC_FILM = 8
  224. };
  225. // ISO/IEC 14496-2:2004 table 6-11
  226. enum {
  227. MP4_VIDEO_OBJECT_TYPE_SIMPLE = 1,
  228. MP4_VIDEO_OBJECT_TYPE_SIMPLE_SCALABLE = 2,
  229. MP4_VIDEO_OBJECT_TYPE_CORE = 3,
  230. MP4_VIDEO_OBJECT_TYPE_MAIN = 4,
  231. MP4_VIDEO_OBJECT_TYPE_NBIT = 5,
  232. MP4_VIDEO_OBJECT_TYPE_2DTEXTURE = 6,
  233. MP4_VIDEO_OBJECT_TYPE_2DMESH = 7,
  234. MP4_VIDEO_OBJECT_TYPE_SIMPLE_FACE = 8,
  235. MP4_VIDEO_OBJECT_TYPE_STILL_SCALABLE_TEXTURE = 9,
  236. MP4_VIDEO_OBJECT_TYPE_ADVANCED_REAL_TIME_SIMPLE = 10,
  237. MP4_VIDEO_OBJECT_TYPE_CORE_SCALABLE = 11,
  238. MP4_VIDEO_OBJECT_TYPE_ADVANCED_CODING_EFFICIENCY = 12,
  239. MP4_VIDEO_OBJECT_TYPE_ADVANCED_SCALABLE_TEXTURE = 13,
  240. MP4_VIDEO_OBJECT_TYPE_SIMPLE_FBA = 14,
  241. MP4_VIDEO_OBJECT_TYPE_SIMPLE_STUDIO = 15,
  242. MP4_VIDEO_OBJECT_TYPE_CORE_STUDIO = 16,
  243. MP4_VIDEO_OBJECT_TYPE_ADVANCED_SIMPLE = 17,
  244. MP4_VIDEO_OBJECT_TYPE_FINE_GRANULARITY_SCALABLE = 18
  245. };
  246. // ISO/IEC 14496-2:2004 table 6.17 (maximum defined video_object_layer_shape_extension)
  247. #define MP4_SHAPE_EXT_NUM 13
  248. // ISO/IEC 14496-2:2004 table 6-14
  249. enum {
  250. MP4_ASPECT_RATIO_FORBIDDEN = 0,
  251. MP4_ASPECT_RATIO_1_1 = 1,
  252. MP4_ASPECT_RATIO_12_11 = 2,
  253. MP4_ASPECT_RATIO_10_11 = 3,
  254. MP4_ASPECT_RATIO_16_11 = 4,
  255. MP4_ASPECT_RATIO_40_33 = 5,
  256. MP4_ASPECT_RATIO_EXTPAR = 15
  257. };
  258. // ISO/IEC 14496-2:2004 table 6-15
  259. #define MP4_CHROMA_FORMAT_420 1
  260. // ISO/IEC 14496-2:2004 table 6-16
  261. enum {
  262. MP4_SHAPE_TYPE_RECTANGULAR = 0,
  263. MP4_SHAPE_TYPE_BINARY = 1,
  264. MP4_SHAPE_TYPE_BINARYONLY = 2,
  265. MP4_SHAPE_TYPE_GRAYSCALE = 3
  266. };
  267. // ISO/IEC 14496-2:2004 table 6-19
  268. #define MP4_SPRITE_STATIC 1
  269. #define MP4_SPRITE_GMC 2
  270. // ISO/IEC 14496-2:2004 table 6-24
  271. enum {
  272. MP4_VOP_TYPE_I = 0,
  273. MP4_VOP_TYPE_P = 1,
  274. MP4_VOP_TYPE_B = 2,
  275. MP4_VOP_TYPE_S = 3
  276. };
  277. // ISO/IEC 14496-2:2004 table 6-26
  278. enum {
  279. MP4_SPRITE_TRANSMIT_MODE_STOP = 0,
  280. MP4_SPRITE_TRANSMIT_MODE_PIECE = 1,
  281. MP4_SPRITE_TRANSMIT_MODE_UPDATE = 2,
  282. MP4_SPRITE_TRANSMIT_MODE_PAUSE = 3
  283. };
  284. // ISO/IEC 14496-2:2004 table 7-3
  285. enum {
  286. MP4_BAB_TYPE_MVDSZ_NOUPDATE = 0,
  287. MP4_BAB_TYPE_MVDSNZ_NOUPDATE = 1,
  288. MP4_BAB_TYPE_TRANSPARENT = 2,
  289. MP4_BAB_TYPE_OPAQUE = 3,
  290. MP4_BAB_TYPE_INTRACAE = 4,
  291. MP4_BAB_TYPE_MVDSZ_INTERCAE = 5,
  292. MP4_BAB_TYPE_MVDSNZ_INTERCAE = 6
  293. };
  294. #define MP4_DC_MARKER 0x6B001 // 110 1011 0000 0000 0001
  295. #define MP4_MV_MARKER 0x1F001 // 1 1111 0000 0000 0001
  296. // ISO/IEC 14496-2:2004 table G.1
  297. enum {
  298. MP4_SIMPLE_PROFILE_LEVEL_1 = 0x01,
  299. MP4_SIMPLE_PROFILE_LEVEL_2 = 0x02,
  300. MP4_SIMPLE_PROFILE_LEVEL_3 = 0x03,
  301. MP4_SIMPLE_PROFILE_LEVEL_0 = 0x08,
  302. MP4_SIMPLE_SCALABLE_PROFILE_LEVEL_0 = 0x10,
  303. MP4_SIMPLE_SCALABLE_PROFILE_LEVEL_1 = 0x11,
  304. MP4_SIMPLE_SCALABLE_PROFILE_LEVEL_2 = 0x12,
  305. MP4_CORE_PROFILE_LEVEL_1 = 0x21,
  306. MP4_CORE_PROFILE_LEVEL_2 = 0x22,
  307. MP4_MAIN_PROFILE_LEVEL_2 = 0x32,
  308. MP4_MAIN_PROFILE_LEVEL_3 = 0x33,
  309. MP4_MAIN_PROFILE_LEVEL_4 = 0x34,
  310. MP4_NBIT_PROFILE_LEVEL_2 = 0x42,
  311. MP4_SCALABLE_TEXTURE_PROFILE_LEVEL_1 = 0x51,
  312. MP4_SIMPLE_FACE_ANIMATION_PROFILE_LEVEL_1 = 0x61,
  313. MP4_SIMPLE_FACE_ANIMATION_PROFILE_LEVEL_2 = 0x62,
  314. MP4_SIMPLE_FBA_PROFILE_LEVEL_1 = 0x63,
  315. MP4_SIMPLE_FBA_PROFILE_LEVEL_2 = 0x64,
  316. MP4_BASIC_ANIMATED_TEXTURE_PROFILE_LEVEL_1 = 0x71,
  317. MP4_BASIC_ANIMATED_TEXTURE_PROFILE_LEVEL_2 = 0x72,
  318. MP4_HYBRID_PROFILE_LEVEL_1 = 0x81,
  319. MP4_HYBRID_PROFILE_LEVEL_2 = 0x82,
  320. MP4_ADVANCED_REAL_TIME_SIMPLE_PROFILE_LEVEL_1 = 0x91,
  321. MP4_ADVANCED_REAL_TIME_SIMPLE_PROFILE_LEVEL_2 = 0x92,
  322. MP4_ADVANCED_REAL_TIME_SIMPLE_PROFILE_LEVEL_3 = 0x93,
  323. MP4_ADVANCED_REAL_TIME_SIMPLE_PROFILE_LEVEL_4 = 0x94,
  324. MP4_CORE_SCALABLE_PROFILE_LEVEL_1 = 0xA1,
  325. MP4_CORE_SCALABLE_PROFILE_LEVEL_2 = 0xA2,
  326. MP4_CORE_SCALABLE_PROFILE_LEVEL_3 = 0xA3,
  327. MP4_ADVANCED_CODING_EFFICIENCY_PROFILE_LEVEL_1 = 0xB1,
  328. MP4_ADVANCED_CODING_EFFICIENCY_PROFILE_LEVEL_2 = 0xB2,
  329. MP4_ADVANCED_CODING_EFFICIENCY_PROFILE_LEVEL_3 = 0xB3,
  330. MP4_ADVANCED_CODING_EFFICIENCY_PROFILE_LEVEL_4 = 0xB4,
  331. MP4_ADVANCED_CORE_PROFILE_LEVEL_1 = 0xC1,
  332. MP4_ADVANCED_CORE_PROFILE_LEVEL_2 = 0xC2,
  333. MP4_ADVANCED_SCALABLE_TEXTURE_PROFILE_LEVEL_1 = 0xD1,
  334. MP4_ADVANCED_SCALABLE_TEXTURE_PROFILE_LEVEL_2 = 0xD2,
  335. MP4_ADVANCED_SCALABLE_TEXTURE_PROFILE_LEVEL_3 = 0xD3,
  336. MP4_SIMPLE_STUDIO_PROFILE_LEVEL_1 = 0xE1,
  337. MP4_SIMPLE_STUDIO_PROFILE_LEVEL_2 = 0xE2,
  338. MP4_SIMPLE_STUDIO_PROFILE_LEVEL_3 = 0xE3,
  339. MP4_SIMPLE_STUDIO_PROFILE_LEVEL_4 = 0xE4,
  340. MP4_CORE_STUDIO_PROFILE_LEVEL_1 = 0xE5,
  341. MP4_CORE_STUDIO_PROFILE_LEVEL_2 = 0xE6,
  342. MP4_CORE_STUDIO_PROFILE_LEVEL_3 = 0xE7,
  343. MP4_CORE_STUDIO_PROFILE_LEVEL_4 = 0xE8,
  344. MP4_ADVANCED_SIMPLE_PROFILE_LEVEL_0 = 0xF0,
  345. MP4_ADVANCED_SIMPLE_PROFILE_LEVEL_1 = 0xF1,
  346. MP4_ADVANCED_SIMPLE_PROFILE_LEVEL_2 = 0xF2,
  347. MP4_ADVANCED_SIMPLE_PROFILE_LEVEL_3 = 0xF3,
  348. MP4_ADVANCED_SIMPLE_PROFILE_LEVEL_4 = 0xF4,
  349. MP4_ADVANCED_SIMPLE_PROFILE_LEVEL_5 = 0xF5,
  350. MP4_ADVANCED_SIMPLE_PROFILE_LEVEL_3B = 0xF7,
  351. MP4_FGS_PROFILE_LEVEL_0 = 0xF8,
  352. MP4_FGS_PROFILE_LEVEL_1 = 0xF9,
  353. MP4_FGS_PROFILE_LEVEL_2 = 0xFA,
  354. MP4_FGS_PROFILE_LEVEL_3 = 0xFB,
  355. MP4_FGS_PROFILE_LEVEL_4 = 0xFC,
  356. MP4_FGS_PROFILE_LEVEL_5 = 0xFD
  357. };
  358. /* Frame Info */
  359. typedef struct _mp4_Frame {
  360. uint8_t* apY; // allocated with border
  361. uint8_t* apCb; // allocated with border
  362. uint8_t* apCr; // allocated with border
  363. int32_t stepY;
  364. int32_t stepCr;
  365. int32_t stepCb;
  366. uint8_t* pY; // real pointer
  367. uint8_t* pCb; // real pointer
  368. uint8_t* pCr; // real pointer
  369. int32_t type;
  370. int64_t time;
  371. int32_t mbPerRow; // info for realloc VOP with Shape
  372. int32_t mbPerCol;
  373. uint8_t* apB; // for binary mask
  374. uint8_t* pB;
  375. uint8_t* apA[3]; // for aux components
  376. uint8_t* pA[3];
  377. uint8_t* mid;
  378. uint64_t timestamp; // user-provided timestamp
  379. int QP;
  380. unsigned int reference_count;
  381. int outputted; // for debugging purposes
  382. int sprite; // 0 - frame, 1 - sprite
  383. struct _mp4_Frame *next; // benski> for linked list of display & free frames
  384. } mp4_Frame;
  385. /* Block Info for Intra Prediction */
  386. typedef struct _mp4_IntraPredBlock {
  387. struct _mp4_IntraPredBlock *predA;
  388. struct _mp4_IntraPredBlock *predB;
  389. struct _mp4_IntraPredBlock *predC;
  390. int16_t dct_acA[8];
  391. int16_t dct_acC[8];
  392. int16_t dct_dc;
  393. } mp4_IntraPredBlock;
  394. /* Buffer for Intra Prediction */
  395. typedef struct _mp4_IntraPredBuff {
  396. uint8_t *quant; // quant buffer;
  397. mp4_IntraPredBlock dcB[6]; // blocks for Left-Top DC only
  398. mp4_IntraPredBlock *block;
  399. } mp4_IntraPredBuff;
  400. /* MacroBlock Info Data Partitioned mode */
  401. typedef struct _mp4_DataPartMacroBlock {
  402. int16_t dct_dc[6];
  403. uint8_t type;
  404. uint8_t not_coded;
  405. uint8_t mcsel;
  406. uint8_t ac_pred_flag;
  407. uint8_t pat;
  408. uint8_t quant;
  409. } mp4_DataPartMacroBlock;
  410. /* MacroBlock Info for Motion */
  411. typedef struct _mp4_MacroBlock {
  412. IppMotionVector mv[4];
  413. uint8_t validPred; // for MV pred, OBMC
  414. uint8_t type; // for OBMC, BVOP
  415. uint8_t not_coded; // for OBMC, BVOP
  416. uint8_t field_info; // for Interlaced BVOP Direct mode
  417. } mp4_MacroBlock;
  418. /* Group Of Video Object Plane Info */
  419. typedef struct _mp4_GroupOfVideoObjectPlane {
  420. int64_t time_code;
  421. int32_t closed_gov;
  422. int32_t broken_link;
  423. } mp4_GroupOfVideoObjectPlane;
  424. /* Video Object Plane Info */
  425. typedef struct _mp4_VideoObjectPlane {
  426. int32_t coding_type;
  427. int32_t modulo_time_base;
  428. int32_t time_increment;
  429. int32_t coded;
  430. int32_t id; // verid != 1 (newpred)
  431. int32_t id_for_prediction_indication; // verid != 1 (newpred)
  432. int32_t id_for_prediction; // verid != 1 (newpred)
  433. int32_t rounding_type;
  434. int32_t reduced_resolution; // verid != 1
  435. int32_t vop_width;
  436. int32_t vop_height;
  437. int32_t vop_horizontal_mc_spatial_ref;
  438. int32_t vop_vertical_mc_spatial_ref;
  439. int32_t background_composition;
  440. int32_t change_conv_ratio_disable;
  441. int32_t vop_constant_alpha;
  442. int32_t vop_constant_alpha_value;
  443. int32_t intra_dc_vlc_thr;
  444. int32_t top_field_first;
  445. int32_t alternate_vertical_scan_flag;
  446. int32_t sprite_transmit_mode;
  447. int32_t warping_mv_code_du[4];
  448. int32_t warping_mv_code_dv[4];
  449. int32_t brightness_change_factor;
  450. int32_t quant;
  451. int32_t alpha_quant[3];
  452. int32_t fcode_forward;
  453. int32_t fcode_backward;
  454. int32_t shape_coding_type;
  455. int32_t load_backward_shape;
  456. int32_t ref_select_code;
  457. int32_t dx;
  458. int32_t dy;
  459. int32_t quant_scale;
  460. int32_t macroblock_num;
  461. int32_t vop_id;
  462. int32_t vop_id_for_prediction_indication;
  463. int32_t vop_id_for_prediction;
  464. } mp4_VideoObjectPlane;
  465. /* mp4_ComplexityEstimation Info */
  466. typedef struct _mp4_ComplexityEstimation {
  467. int32_t estimation_method;
  468. int32_t shape_complexity_estimation_disable;
  469. int32_t opaque;
  470. int32_t transparent;
  471. int32_t intra_cae;
  472. int32_t inter_cae;
  473. int32_t no_update;
  474. int32_t upsampling;
  475. int32_t texture_complexity_estimation_set_1_disable;
  476. int32_t intra_blocks;
  477. int32_t inter_blocks;
  478. int32_t inter4v_blocks;
  479. int32_t not_coded_blocks;
  480. int32_t texture_complexity_estimation_set_2_disable;
  481. int32_t dct_coefs;
  482. int32_t dct_lines;
  483. int32_t vlc_symbols;
  484. int32_t vlc_bits;
  485. int32_t motion_compensation_complexity_disable;
  486. int32_t apm;
  487. int32_t npm;
  488. int32_t interpolate_mc_q;
  489. int32_t forw_back_mc_q;
  490. int32_t halfpel2;
  491. int32_t halfpel4;
  492. int32_t version2_complexity_estimation_disable; // verid != 1
  493. int32_t sadct; // verid != 1
  494. int32_t quarterpel; // verid != 1
  495. int32_t dcecs_opaque;
  496. int32_t dcecs_transparent;
  497. int32_t dcecs_intra_cae;
  498. int32_t dcecs_inter_cae;
  499. int32_t dcecs_no_update;
  500. int32_t dcecs_upsampling;
  501. int32_t dcecs_intra_blocks;
  502. int32_t dcecs_inter_blocks;
  503. int32_t dcecs_inter4v_blocks;
  504. int32_t dcecs_not_coded_blocks;
  505. int32_t dcecs_dct_coefs;
  506. int32_t dcecs_dct_lines;
  507. int32_t dcecs_vlc_symbols;
  508. int32_t dcecs_vlc_bits;
  509. int32_t dcecs_apm;
  510. int32_t dcecs_npm;
  511. int32_t dcecs_interpolate_mc_q;
  512. int32_t dcecs_forw_back_mc_q;
  513. int32_t dcecs_halfpel2;
  514. int32_t dcecs_halfpel4;
  515. int32_t dcecs_sadct; // verid != 1
  516. int32_t dcecs_quarterpel; // verid != 1
  517. } mp4_ComplexityEstimation;
  518. /* mp4_Scalability Info */
  519. typedef struct _mp4_ScalabilityParameters {
  520. int32_t dummy;
  521. } mp4_ScalabilityParameters;
  522. /* VOLControlParameters Info */
  523. typedef struct _mp4_VOLControlParameters {
  524. int32_t chroma_format;
  525. int32_t low_delay;
  526. int32_t vbv_parameters;
  527. int32_t bit_rate;
  528. int32_t vbv_buffer_size;
  529. int32_t vbv_occupancy;
  530. } mp4_VOLControlParameters;
  531. /* Video Object Plane with int16_t header Info */
  532. typedef struct _mp4_VideoObjectPlaneH263 {
  533. int32_t temporal_reference;
  534. int32_t split_screen_indicator;
  535. int32_t document_camera_indicator;
  536. int32_t full_picture_freeze_release;
  537. int32_t source_format;
  538. int32_t picture_coding_type;
  539. int32_t vop_quant;
  540. int32_t gob_number;
  541. int32_t num_gobs_in_vop;
  542. int32_t num_macroblocks_in_gob;
  543. int32_t gob_header_empty;
  544. int32_t gob_frame_id;
  545. int32_t quant_scale;
  546. int32_t num_rows_in_gob;
  547. } mp4_VideoObjectPlaneH263;
  548. /* Video Object Info */
  549. typedef struct _mp4_VideoObject {
  550. // iso part
  551. int32_t id;
  552. int32_t short_video_header;
  553. int32_t random_accessible_vol;
  554. int32_t type_indication;
  555. int32_t is_identifier;
  556. int32_t verid;
  557. int32_t priority;
  558. int32_t aspect_ratio_info;
  559. int32_t aspect_ratio_info_par_width;
  560. int32_t aspect_ratio_info_par_height;
  561. int32_t is_vol_control_parameters;
  562. mp4_VOLControlParameters VOLControlParameters;
  563. int32_t shape;
  564. int32_t shape_extension; // verid != 1
  565. int32_t vop_time_increment_resolution;
  566. int32_t vop_time_increment_resolution_bits;
  567. int32_t fixed_vop_rate;
  568. int32_t fixed_vop_time_increment;
  569. int32_t width;
  570. int32_t height;
  571. int32_t interlaced;
  572. int32_t obmc_disable;
  573. int32_t sprite_enable; // if verid != 1 (2 bit GMC is added)
  574. int32_t sprite_width;
  575. int32_t sprite_height;
  576. int32_t sprite_left_coordinate;
  577. int32_t sprite_top_coordinate;
  578. int32_t sprite_warping_points;
  579. int32_t sprite_warping_accuracy;
  580. int32_t sprite_brightness_change;
  581. int32_t low_latency_sprite_enable;
  582. int32_t sadct_disable; // verid != 1
  583. int32_t not_8_bit;
  584. int32_t quant_precision;
  585. int32_t bits_per_pixel;
  586. int32_t no_gray_quant_update;
  587. int32_t composition_method;
  588. int32_t linear_composition;
  589. int32_t quant_type;
  590. int32_t load_intra_quant_mat;
  591. uint8_t intra_quant_mat[64];
  592. int32_t load_nonintra_quant_mat;
  593. uint8_t nonintra_quant_mat[64];
  594. int32_t load_intra_quant_mat_grayscale[3];
  595. uint8_t intra_quant_mat_grayscale[3][64];
  596. int32_t load_nonintra_quant_mat_grayscale[3];
  597. uint8_t nonintra_quant_mat_grayscale[3][64];
  598. int32_t quarter_sample; // verid != 1
  599. int32_t complexity_estimation_disable;
  600. mp4_ComplexityEstimation ComplexityEstimation;
  601. int32_t resync_marker_disable;
  602. int32_t data_partitioned;
  603. int32_t reversible_vlc;
  604. int32_t newpred_enable; // verid != 1
  605. int32_t requested_upstream_message_type;// verid != 1
  606. int32_t newpred_segment_type; // verid != 1
  607. int32_t reduced_resolution_vop_enable; // verid != 1
  608. int32_t scalability;
  609. mp4_ScalabilityParameters ScalabilityParameters;
  610. mp4_GroupOfVideoObjectPlane GroupOfVideoObjectPlane;
  611. mp4_VideoObjectPlane VideoObjectPlane;
  612. mp4_VideoObjectPlaneH263 VideoObjectPlaneH263;
  613. // app part
  614. int32_t VOPindex;
  615. int32_t MacroBlockPerRow;
  616. int32_t MacroBlockPerCol;
  617. int32_t MacroBlockPerVOP;
  618. int32_t mbns; // num bits for MacroBlockPerVOP
  619. mp4_MacroBlock* MBinfo;
  620. mp4_IntraPredBuff IntraPredBuff;
  621. mp4_DataPartMacroBlock* DataPartBuff;
  622. IppiQuantInvIntraSpec_MPEG4* QuantInvIntraSpec;
  623. IppiQuantInvInterSpec_MPEG4* QuantInvInterSpec;
  624. IppiWarpSpec_MPEG4* WarpSpec;
  625. // for B-VOP
  626. int32_t prevPlaneIsB;
  627. // for interlaced B-VOP direct mode
  628. int32_t Tframe;
  629. IppMotionVector* FieldMV;
  630. // for B-VOP direct mode
  631. int32_t TRB, TRD;
  632. // time increment of past and future VOP for B-VOP
  633. int64_t rTime, nTime;
  634. // VOP global time
  635. int64_t vop_sync_time, vop_sync_time_b;
  636. #ifdef USE_NOTCODED_STATE
  637. // not_coded MB state
  638. uint8_t* ncState;
  639. int32_t ncStateCleared;
  640. #endif
  641. } mp4_VideoObject;
  642. /* StillTexture Object Info */
  643. typedef struct _mp4_StillTextureObject {
  644. int32_t dummy;
  645. } mp4_StillTextureObject;
  646. /* Mesh Object Info */
  647. typedef struct _mp4_MeshObject {
  648. int32_t dummy;
  649. } mp4_MeshObject;
  650. /* Face Object Info */
  651. typedef struct _mp4_FaceObject {
  652. int32_t dummy;
  653. } mp4_FaceObject;
  654. /* video_signal_type Info */
  655. typedef struct _mp4_VideoSignalType {
  656. int32_t is_video_signal_type;
  657. int32_t video_format;
  658. int32_t video_range;
  659. int32_t is_colour_description;
  660. int32_t colour_primaries;
  661. int32_t transfer_characteristics;
  662. int32_t matrix_coefficients;
  663. } mp4_VideoSignalType;
  664. /* Visual Object Info */
  665. typedef struct _mp4_VisualObject {
  666. int32_t is_identifier;
  667. int32_t verid;
  668. int32_t priority;
  669. int32_t type;
  670. mp4_VideoSignalType VideoSignalType;
  671. mp4_VideoObject VideoObject;
  672. mp4_StillTextureObject StillTextureObject;
  673. mp4_MeshObject MeshObject;
  674. mp4_FaceObject FaceObject;
  675. mp4_Frame *sFrame; // static sprite
  676. mp4_Frame *cFrame; // current TODO make pointer
  677. mp4_Frame *rFrame; // reference in past TODO make pointer
  678. mp4_Frame *nFrame; // reference in future TODO make pointer
  679. int32_t frameCount;
  680. int32_t frameInterval;
  681. int32_t frameScale;
  682. mp4_Statistic Statistic;
  683. mp4_Frame *frame_cache; // linked list of available frames (malloc cache)
  684. mp4_Frame *sprite_cache; // linked list of available sprite (malloc cache)
  685. mp4_Frame *display_frames; // linked list of display frames
  686. } mp4_VisualObject;
  687. /* Full Info */
  688. typedef struct _mp4_Info {
  689. int32_t ftype; // 0 - raw, 1 - mp4, 2 - avi
  690. int32_t ftype_f; // ftype == 1 (0 - QuickTime(tm)), ftype == 2 (0 - DivX(tm) v. < 5, XVID, 1 - DivX(tm) v. >= 5)
  691. uint8_t* buffer; /* buffer header for saving MPEG-4 stream */
  692. size_t buflen; /* total buffer length */
  693. size_t len; /* valid data in buffer */
  694. uint8_t* bufptr; /* current frame, point to header or data */
  695. int32_t bitoff; /* mostly point to next frame header or PSC */
  696. int32_t profile_and_level_indication;
  697. mp4_VisualObject VisualObject;
  698. int32_t stopOnErr;
  699. int strictSyntaxCheck;
  700. int noPVOPs;
  701. int noBVOPs;
  702. } mp4_Info;
  703. /* bitstream functions */
  704. extern uint8_t* mp4_FindStartCodePtr(mp4_Info* pInfo);
  705. extern uint8_t* mp4_FindStartCodeOrShortPtr(mp4_Info* pInfo);
  706. extern int32_t mp4_SeekStartCodePtr(mp4_Info* pInfo);
  707. extern int32_t mp4_SeekStartCodeOrShortPtr(mp4_Info* pInfo);
  708. extern int32_t mp4_SeekStartCodeValue(mp4_Info* pInfo, uint8_t code);
  709. extern uint8_t* mp4_FindShortVideoStartMarkerPtr(mp4_Info* pInfo);
  710. extern int32_t mp4_SeekShortVideoStartMarker(mp4_Info* pInfo);
  711. extern int32_t mp4_SeekGOBMarker(mp4_Info* pInfo);
  712. extern int32_t mp4_SeekResyncMarker(mp4_Info* pInfo);
  713. extern int32_t mp4_FindResyncMarker(mp4_Info* pInfo);
  714. extern int mp4_IsStartCodeOrShort(mp4_Info* pInfo);
  715. extern int mp4_IsStartCodeValue(mp4_Info* pInfo, int min, int max);
  716. extern int mp4_IsShortCode(mp4_Info* pInfo);
  717. /* tables */
  718. typedef struct _mp4_VLC1 {
  719. uint8_t code;
  720. uint8_t len;
  721. } mp4_VLC1;
  722. extern const uint8_t mp4_DefaultIntraQuantMatrix[];
  723. extern const uint8_t mp4_DefaultNonIntraQuantMatrix[];
  724. extern const uint8_t mp4_ClassicalZigzag[];
  725. extern const uint8_t mp4_DCScalerLuma[];
  726. extern const uint8_t mp4_DCScalerChroma[];
  727. extern const uint8_t mp4_cCbCrMvRound16[];
  728. extern const uint8_t mp4_cCbCrMvRound12[];
  729. extern const uint8_t mp4_cCbCrMvRound8[];
  730. extern const uint8_t mp4_cCbCrMvRound4[];
  731. extern const Ipp8s mp4_dquant[];
  732. extern const mp4_VLC1 mp4_cbpy1[];
  733. extern const mp4_VLC1 mp4_cbpy2[];
  734. extern const mp4_VLC1 mp4_cbpy3[];
  735. extern const mp4_VLC1 mp4_cbpy4[];
  736. extern const mp4_VLC1* mp4_cbpy_t[];
  737. extern const uint8_t mp4_cbpy_b[];
  738. extern const int32_t mp4_DC_vlc_Threshold[];
  739. extern const uint8_t mp4_PVOPmb_type[];
  740. extern const uint8_t mp4_PVOPmb_cbpc[];
  741. extern const uint8_t mp4_PVOPmb_bits[];
  742. extern const mp4_VLC1 mp4_BVOPmb_type[];
  743. extern const mp4_VLC1 mp4_MVD_B12_1[];
  744. extern const mp4_VLC1 mp4_MVD_B12_2[];
  745. extern const int32_t mp4_H263_width[];
  746. extern const int32_t mp4_H263_height[];
  747. extern const int32_t mp4_H263_mbgob[];
  748. extern const int32_t mp4_H263_gobvop[];
  749. extern const int32_t mp4_H263_rowgob[];
  750. extern const uint8_t mp4_aux_comp_count[];
  751. extern const uint8_t mp4_aux_comp_is_alpha[];
  752. extern const uint8_t mp4_BABtypeIntra[][3];
  753. extern const int32_t mp4_DivIntraDivisor[];
  754. // project functions
  755. extern void mp4_Error(const char *str);
  756. //#define mp4_Error(str) puts(str)
  757. extern mp4_Status mp4_InitVOL(mp4_Info *pInfo);
  758. extern mp4_Status mp4_FreeVOL(mp4_Info *pInfo);
  759. extern void mp4_ResetVOL(mp4_Info *pInfo);
  760. //extern void mp4_ShowFrame(mp4_Frame *frame);
  761. #define mp4_ShowFrame(frame)
  762. extern mp4_Status mp4_Parse_VisualObjectSequence(mp4_Info* pInfo);
  763. extern mp4_Status mp4_Parse_VisualObject(mp4_Info* pInfo);
  764. extern mp4_Status mp4_Parse_VideoObject(mp4_Info* pInfo);
  765. extern mp4_Status mp4_Parse_GroupOfVideoObjectPlane(mp4_Info* pInfo);
  766. extern mp4_Status mp4_Parse_VideoObjectPlane(mp4_Info* pInfo);
  767. extern mp4_Status mp4_DecodeVideoObjectPlane(mp4_Info* pInfo);
  768. #ifndef USE_INLINE_BITS_FUNC
  769. extern uint32_t mp4_ShowBits(mp4_Info* pInfo, int32_t n);
  770. extern uint32_t mp4_ShowBit(mp4_Info* pInfo);
  771. extern uint32_t mp4_ShowBits9(mp4_Info* pInfo, int32_t n);
  772. extern void mp4_FlushBits(mp4_Info* pInfo, int32_t n);
  773. extern uint32_t mp4_GetBits(mp4_Info* pInfo, int32_t n);
  774. //extern uint32_t mp4_GetBit(mp4_Info* pInfo);
  775. extern uint32_t mp4_GetBits9(mp4_Info* pInfo, int32_t n);
  776. extern void mp4_AlignBits(mp4_Info* pInfo);
  777. extern void mp4_AlignBits7F(mp4_Info* pInfo);
  778. extern uint32_t mp4_ShowBitsAlign(mp4_Info* pInfo, int32_t n);
  779. extern uint32_t mp4_ShowBitsAlign7F(mp4_Info* pInfo, int32_t n);
  780. #else
  781. __INLINE uint32_t mp4_ShowBits(mp4_Info* pInfo, int32_t n)
  782. {
  783. uint8_t* ptr = pInfo->bufptr;
  784. uint32_t tmp = (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | (ptr[3]);
  785. tmp <<= pInfo->bitoff;
  786. tmp >>= 32 - n;
  787. return tmp;
  788. }
  789. __INLINE uint32_t mp4_ShowBit(mp4_Info* pInfo)
  790. {
  791. uint32_t tmp = pInfo->bufptr[0];
  792. tmp >>= 7 - pInfo->bitoff;
  793. return (tmp & 1);
  794. }
  795. __INLINE uint32_t mp4_ShowBits9(mp4_Info* pInfo, int32_t n)
  796. {
  797. uint8_t* ptr = pInfo->bufptr;
  798. uint32_t tmp = (ptr[0] << 8) | ptr[1];
  799. tmp <<= (pInfo->bitoff + 16);
  800. tmp >>= 32 - n;
  801. return tmp;
  802. }
  803. __INLINE void mp4_FlushBits(mp4_Info* pInfo, int32_t n)
  804. {
  805. n = n + pInfo->bitoff;
  806. pInfo->bufptr += n >> 3;
  807. pInfo->bitoff = n & 7;
  808. }
  809. __INLINE uint32_t mp4_GetBits(mp4_Info* pInfo, int32_t n)
  810. {
  811. uint8_t* ptr = pInfo->bufptr;
  812. uint32_t tmp = (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | (ptr[3]);
  813. tmp <<= pInfo->bitoff;
  814. tmp >>= 32 - n;
  815. n = n + pInfo->bitoff;
  816. pInfo->bufptr += n >> 3;
  817. pInfo->bitoff = n & 7;
  818. return tmp;
  819. }
  820. __INLINE uint32_t mp4_GetBits9(mp4_Info* pInfo, int32_t n)
  821. {
  822. uint8_t* ptr = pInfo->bufptr;
  823. uint32_t tmp = (ptr[0] << 8) | ptr[1];
  824. tmp <<= (pInfo->bitoff + 16);
  825. tmp >>= 32 - n;
  826. n = n + pInfo->bitoff;
  827. pInfo->bufptr += n >> 3;
  828. pInfo->bitoff = n & 7;
  829. return tmp;
  830. }
  831. __INLINE void mp4_AlignBits(mp4_Info* pInfo)
  832. {
  833. if (pInfo->bitoff > 0) {
  834. pInfo->bitoff = 0;
  835. (pInfo->bufptr)++;
  836. }
  837. }
  838. __INLINE void mp4_AlignBits7F(mp4_Info* pInfo)
  839. {
  840. if (pInfo->bitoff > 0) {
  841. pInfo->bitoff = 0;
  842. (pInfo->bufptr)++;
  843. } else {
  844. if (*pInfo->bufptr == 0x7F)
  845. (pInfo->bufptr)++;
  846. }
  847. }
  848. __INLINE uint32_t mp4_ShowBitsAlign(mp4_Info* pInfo, int32_t n)
  849. {
  850. uint8_t* ptr = pInfo->bitoff ? (pInfo->bufptr + 1) : pInfo->bufptr;
  851. uint32_t tmp = (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | (ptr[3]);
  852. tmp >>= 32 - n;
  853. return tmp;
  854. }
  855. __INLINE uint32_t mp4_ShowBitsAlign7F(mp4_Info* pInfo, int32_t n)
  856. {
  857. uint8_t* ptr = pInfo->bitoff ? (pInfo->bufptr + 1) : pInfo->bufptr;
  858. uint32_t tmp;
  859. if (!pInfo->bitoff) {
  860. if (*ptr == 0x7F)
  861. ptr ++;
  862. }
  863. tmp = (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | (ptr[3]);
  864. tmp >>= 32 - n;
  865. return tmp;
  866. }
  867. #endif // USE_INLINE_BITS_FUNC
  868. __INLINE uint32_t mp4_GetBit(mp4_Info* pInfo)
  869. {
  870. uint32_t tmp = pInfo->bufptr[0];
  871. if (pInfo->bitoff != 7) {
  872. tmp >>= 7 - pInfo->bitoff;
  873. pInfo->bitoff ++;
  874. } else {
  875. pInfo->bitoff = 0;
  876. pInfo->bufptr ++;
  877. }
  878. return (tmp & 1);
  879. }
  880. __INLINE int32_t mp4_GetMarkerBit(mp4_Info* pInfo) {
  881. if (!mp4_GetBit(pInfo)) {
  882. mp4_Error("Error: wrong marker bit");
  883. return 0;
  884. }
  885. return 1;
  886. }
  887. // added by benski
  888. extern mp4_Frame *CreateFrame(mp4_VisualObject *object);
  889. extern void ReleaseFrame(mp4_VisualObject *object, mp4_Frame *frame);
  890. extern mp4_Frame *GetDisplayFrame(mp4_VisualObject *object);
  891. extern void DisplayFrame(mp4_VisualObject *object, mp4_Frame *frame);
  892. extern void FreeCache(mp4_VisualObject *object);
  893. #ifdef __cplusplus
  894. }
  895. #endif