MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / cdg_scroll

Function cdg_scroll

libavcodec/cdgraphics.c:206–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204}
205
206static void cdg_scroll(CDGraphicsContext *cc, uint8_t *data,
207 AVFrame *new_frame, int roll_over)
208{
209 int color;
210 int hscmd, h_off, hinc, vscmd, v_off, vinc;
211 int y;
212 int stride = cc->frame.linesize[0];
213 uint8_t *in = cc->frame.data[0];
214 uint8_t *out = new_frame->data[0];
215
216 color = data[0] & 0x0F;
217 hscmd = (data[1] & 0x30) >> 4;
218 vscmd = (data[2] & 0x30) >> 4;
219
220 h_off = FFMIN(data[1] & 0x07, CDG_BORDER_WIDTH - 1);
221 v_off = FFMIN(data[2] & 0x07, CDG_BORDER_HEIGHT - 1);
222
223 /// find the difference and save the offset for cdg_tile_block usage
224 hinc = h_off - cc->hscroll;
225 vinc = v_off - cc->vscroll;
226 cc->hscroll = h_off;
227 cc->vscroll = v_off;
228
229 if (vscmd == UP)
230 vinc -= 12;
231 if (vscmd == DOWN)
232 vinc += 12;
233 if (hscmd == LEFT)
234 hinc -= 6;
235 if (hscmd == RIGHT)
236 hinc += 6;
237
238 if (!hinc && !vinc)
239 return;
240
241 memcpy(new_frame->data[1], cc->frame.data[1], CDG_PALETTE_SIZE * 4);
242
243 for (y = FFMAX(0, vinc); y < FFMIN(CDG_FULL_HEIGHT + vinc, CDG_FULL_HEIGHT); y++)
244 memcpy(out + FFMAX(0, hinc) + stride * y,
245 in + FFMAX(0, hinc) - hinc + (y - vinc) * stride,
246 FFMIN(stride + hinc, stride));
247
248 if (vinc > 0)
249 cdg_fill_wrapper(0, 0, out,
250 0, CDG_FULL_HEIGHT - vinc, in, color,
251 stride, vinc, stride, roll_over);
252 else if (vinc < 0)
253 cdg_fill_wrapper(0, CDG_FULL_HEIGHT + vinc, out,
254 0, 0, in, color,
255 stride, -1 * vinc, stride, roll_over);
256
257 if (hinc > 0)
258 cdg_fill_wrapper(0, 0, out,
259 CDG_FULL_WIDTH - hinc, 0, in, color,
260 hinc, CDG_FULL_HEIGHT, stride, roll_over);
261 else if (hinc < 0)
262 cdg_fill_wrapper(CDG_FULL_WIDTH + hinc, 0, out,
263 0, 0, in, color,

Callers 1

cdg_decode_frameFunction · 0.85

Calls 1

cdg_fill_wrapperFunction · 0.85

Tested by

no test coverage detected