UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
M4Image.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "vdecmpeg4.h"
5#include "M4Decoder.h"
6
7namespace vdecmpeg4
8{
9
12#define EDGE_SIZE 32
13
15#define EDGE_SIZE2 (EDGE_SIZE/2)
16
18#define ALIGNMENT_TRASH (64)
19
20
22{
23public:
27
30
31private:
32 M4Image()
33 {
34 }
35
36public:
37 //
38 //--- Public Interface
39 //
40
42 static M4Image* create(M4Decoder* decoder, int16 width, int16 height, bool poolMem = true);
43
45 static void destroy(M4Image*& pImage, M4Decoder* decoder);
46
48 void Black();
49
51 void RefAdd()
52 {
53 ++mRefCount;
54 }
55
57 void RefRemove()
58 {
59 if (--mRefCount == 0)
60 {
61 // Actually, we need to get a copy of the member variable, because the destructor call
62 // in the next line frees the instance possibily overwriting the mDecoder member.
63 M4Decoder* pDecoder = mDecoder;
64 this->~M4Image();
65 pDecoder->mMemSys.free(this);
66 }
67 }
68
70 int32 RefGet() const
71 {
72 return mRefCount;
73 }
74
77 {
78 return *mDecoder;
79 }
80
82 static void poolMemCb(void* memPtr, uint32 size, uint32 poolFlags, void* userData);
83
84 void* operator new(size_t sz, M4MemHandler& memSys)
85 {
86 void* pAddr = memSys.malloc(sz, 16);
87 if (pAddr)
88 {
90 }
91 return pAddr;
92 }
93
94 void operator delete(void* ptr)
95 {
96 ((M4Image*)ptr)->mDecoder->mMemSys.free(ptr);
97 }
98
99private:
101 uint8* mBaseMem;
102
104 M4Decoder* mDecoder;
105
107 volatile int32 mRefCount;
108
109
111 ~M4Image();
112
114 void setup(uint8* ptr, uint32 flags);
115
117 M4Image(const M4Image& pObj);
118
120 const M4Image &operator=(const M4Image& pObj);
121
124
125 friend class M4Decoder;
126 friend struct VIDImage;
127
128
129#ifdef _M4_ENABLE_BMP_OUT
131 void saveBMP(const char* pBaseName, uint32 frameCounter);
132
133private:
136
138 void initImageSave();
139
140 static int32 mTabRgbY[256];
141 static int32 mTabBU[256];
142 static int32 mTabGU[256];
143 static int32 mTabGV[256];
144 static int32 mTabRV[256];
145 static bool mInitImageSave;
146#endif
147};
148
149/******************************************************************************
150 * INLINE FUNCTIONS
151 ******************************************************************************/
152
154{
155 M4Image* tmp = img1;
156 img1 = img2;
157 img2 = tmp;
158}
159
160}
161
FPlatformTypes::int16 int16
A 16-bit signed integer.
Definition Platform.h:1123
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define M4_MEMORY_HANDLER
Definition M4Memory.h:14
char * dst
Definition lz4.h:735
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition M4Decoder.h:30
Definition M4Image.h:22
void RefAdd()
Reference increase.
Definition M4Image.h:51
VIDImageInfo mImageInfo
Image information.
Definition M4Image.h:29
static M4Image * create(M4Decoder *decoder, int16 width, int16 height, bool poolMem=true)
Construction and allocation of image helper.
Definition M4Image.cpp:80
VIDImage mImage
Definition M4Image.h:26
void Black()
Clear buffer.
Definition M4Image.cpp:152
void RefRemove()
Reference decrease and free mem if drops to 0 references.
Definition M4Image.h:57
static void destroy(M4Image *&pImage, M4Decoder *decoder)
Destruction.
Definition M4Image.cpp:124
static void poolMemCb(void *memPtr, uint32 size, uint32 poolFlags, void *userData)
Pool mem allocation callback.
Definition M4Image.cpp:171
int32 RefGet() const
Return current reference value.
Definition M4Image.h:70
M4Decoder & getDecoder() const
Return reference to our decoder.
Definition M4Image.h:76
Definition M4Memory.h:34
Definition M4Bitstream.h:9
void swapM4Image(M4Image *&img1, M4Image *&img2)
Definition M4Image.h:153
static UE_FORCEINLINE_HINT void * Memzero(void *Dest, SIZE_T Count)
Definition UnrealMemory.h:131
Statistical information about decoded frame. This struct is returned via a call to VIDGetFrameInfo.
Definition vdecmpeg4.h:54
Definition vdecmpeg4_Image.h:32