MCPcopy Create free account
hub / github.com/ARM-software/AVH / frame_copy

Function frame_copy

example/FVP_Video/project/frame_copy.c:136–169  ·  view source on GitHub ↗

Copy a video frame from input to output with automatic centering and/or cropping. This function adapts and copies input video frame to the output frame. The behavior depends on the relative sizes of input and output frames: - If dimensions are equal: Direct memory copy - If input is smaller (in one or both dimensions): Centers the input within the output - If input is larger (in one or

Source from the content-addressed store, hash-verified

134 \return int32_t 0 on success, -1 if configuration is unsupported.
135*/
136int32_t frame_copy(const void *in_frame, void *out_frame) {
137#if (VIDEO_IN_FRAME_WIDTH == VIDEO_OUT_FRAME_WIDTH) && (VIDEO_IN_FRAME_HEIGHT == VIDEO_OUT_FRAME_HEIGHT)
138 /* Input and output dimensions are the same, perform a direct copy */
139 memcpy(out_frame, in_frame, VIDEO_OUT_BUF_BLOCK_SIZE);
140 return 0;
141#elif ((VIDEO_IN_FRAME_WIDTH < VIDEO_OUT_FRAME_WIDTH) && (VIDEO_IN_FRAME_HEIGHT <= VIDEO_OUT_FRAME_HEIGHT)) || \
142 ((VIDEO_IN_FRAME_WIDTH <= VIDEO_OUT_FRAME_WIDTH) && (VIDEO_IN_FRAME_HEIGHT < VIDEO_OUT_FRAME_HEIGHT))
143 /* Input frame is smaller than output frame, copy input to the output center */
144 copy_RGB888((const uint8_t *)in_frame,
145 VIDEO_IN_FRAME_WIDTH,
146 VIDEO_IN_FRAME_HEIGHT,
147 (uint8_t *)out_frame,
148 VIDEO_OUT_FRAME_WIDTH,
149 VIDEO_OUT_FRAME_HEIGHT,
150 (VIDEO_OUT_FRAME_WIDTH - VIDEO_IN_FRAME_WIDTH) / 2,
151 (VIDEO_OUT_FRAME_HEIGHT - VIDEO_IN_FRAME_HEIGHT) / 2);
152 return 0;
153#elif ((VIDEO_IN_FRAME_WIDTH > VIDEO_OUT_FRAME_WIDTH) && (VIDEO_IN_FRAME_HEIGHT >= VIDEO_OUT_FRAME_HEIGHT)) || \
154 ((VIDEO_IN_FRAME_WIDTH >= VIDEO_OUT_FRAME_WIDTH) && (VIDEO_IN_FRAME_HEIGHT > VIDEO_OUT_FRAME_HEIGHT))
155 /* Input frame is larger than output frame, crop center of input image and copy to output */
156 crop_rgb888((const uint8_t *)in_frame,
157 VIDEO_IN_FRAME_WIDTH,
158 VIDEO_IN_FRAME_HEIGHT,
159 (uint8_t *)out_frame,
160 (VIDEO_IN_FRAME_WIDTH - VIDEO_OUT_FRAME_WIDTH) / 2,
161 (VIDEO_IN_FRAME_HEIGHT - VIDEO_OUT_FRAME_HEIGHT) / 2,
162 VIDEO_OUT_FRAME_WIDTH,
163 VIDEO_OUT_FRAME_HEIGHT);
164 return 0;
165#else
166 /* Unsupported configuration */
167 return -1;
168#endif
169}

Callers 1

app_main_threadFunction · 0.85

Calls 2

copy_RGB888Function · 0.85
crop_rgb888Function · 0.85

Tested by

no test coverage detected