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

Function ipvideo_decode_block_opcode_0x9

libavcodec/interplayvideo.c:330–398  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

328}
329
330static int ipvideo_decode_block_opcode_0x9(IpvideoContext *s, AVFrame *frame)
331{
332 int x, y;
333 unsigned char P[4];
334
335 if (bytestream2_get_bytes_left(&s->stream_ptr) < 8) {
336 av_log(s->avctx, AV_LOG_ERROR, "too little data for opcode 0x9\n");
337 return AVERROR_INVALIDDATA;
338 }
339
340 /* 4-color encoding */
341 bytestream2_get_buffer(&s->stream_ptr, P, 4);
342
343 if (P[0] <= P[1]) {
344 if (P[2] <= P[3]) {
345
346 /* 1 of 4 colors for each pixel, need 16 more bytes */
347 for (y = 0; y < 8; y++) {
348 /* get the next set of 8 2-bit flags */
349 int flags = bytestream2_get_le16(&s->stream_ptr);
350 for (x = 0; x < 8; x++, flags >>= 2)
351 *s->pixel_ptr++ = P[flags & 0x03];
352 s->pixel_ptr += s->line_inc;
353 }
354
355 } else {
356 uint32_t flags;
357
358 /* 1 of 4 colors for each 2x2 block, need 4 more bytes */
359 flags = bytestream2_get_le32(&s->stream_ptr);
360
361 for (y = 0; y < 8; y += 2) {
362 for (x = 0; x < 8; x += 2, flags >>= 2) {
363 s->pixel_ptr[x ] =
364 s->pixel_ptr[x + 1 ] =
365 s->pixel_ptr[x + s->stride] =
366 s->pixel_ptr[x + 1 + s->stride] = P[flags & 0x03];
367 }
368 s->pixel_ptr += s->stride * 2;
369 }
370
371 }
372 } else {
373 uint64_t flags;
374
375 /* 1 of 4 colors for each 2x1 or 1x2 block, need 8 more bytes */
376 flags = bytestream2_get_le64(&s->stream_ptr);
377 if (P[2] <= P[3]) {
378 for (y = 0; y < 8; y++) {
379 for (x = 0; x < 8; x += 2, flags >>= 2) {
380 s->pixel_ptr[x ] =
381 s->pixel_ptr[x + 1] = P[flags & 0x03];
382 }
383 s->pixel_ptr += s->stride;
384 }
385 } else {
386 for (y = 0; y < 8; y += 2) {
387 for (x = 0; x < 8; x++, flags >>= 2) {

Callers

nothing calls this directly

Calls 3

av_logFunction · 0.85
bytestream2_get_bufferFunction · 0.85

Tested by

no test coverage detected