| 1500 | } |
| 1501 | |
| 1502 | static int encode_float32_rgb_frame(FFV1Context *f, FFV1SliceContext *sc, |
| 1503 | const uint8_t *src[4], |
| 1504 | int w, int h, const int stride[4], int ac) |
| 1505 | { |
| 1506 | int x, y, p, i; |
| 1507 | const int ring_size = f->context_model ? 3 : 2; |
| 1508 | int32_t *sample[4][3]; |
| 1509 | const int pass1 = !!(f->avctx->flags & AV_CODEC_FLAG_PASS1); |
| 1510 | int bits[4], offset; |
| 1511 | int transparency = f->transparency; |
| 1512 | |
| 1513 | ff_ffv1_compute_bits_per_plane(f, sc, bits, &offset, NULL, f->bits_per_raw_sample); |
| 1514 | |
| 1515 | sc->run_index = 0; |
| 1516 | |
| 1517 | for (int p = 0; p < MAX_PLANES; ++p) |
| 1518 | sample[p][2] = sc->sample_buffer32; // dummy to avoid UB pointer arithmetic |
| 1519 | |
| 1520 | memset(RENAME(sc->sample_buffer), 0, ring_size * MAX_PLANES * |
| 1521 | (w + 6) * sizeof(*RENAME(sc->sample_buffer))); |
| 1522 | |
| 1523 | for (y = 0; y < h; y++) { |
| 1524 | for (i = 0; i < ring_size; i++) |
| 1525 | for (p = 0; p < MAX_PLANES; p++) |
| 1526 | sample[p][i]= RENAME(sc->sample_buffer) + p*ring_size*(w+6) + ((h+i-y)%ring_size)*(w+6) + 3; |
| 1527 | |
| 1528 | for (x = 0; x < w; x++) { |
| 1529 | int b, g, r, av_uninit(a); |
| 1530 | g = sc->bitmap[0][x + w*y]; |
| 1531 | b = sc->bitmap[1][x + w*y]; |
| 1532 | r = sc->bitmap[2][x + w*y]; |
| 1533 | if (transparency) |
| 1534 | a = sc->bitmap[3][x + w*y]; |
| 1535 | |
| 1536 | if (sc->slice_coding_mode != 1) { |
| 1537 | b -= g; |
| 1538 | r -= g; |
| 1539 | g += (b * sc->slice_rct_by_coef + r * sc->slice_rct_ry_coef) >> 2; |
| 1540 | b += offset; |
| 1541 | r += offset; |
| 1542 | } |
| 1543 | |
| 1544 | sample[0][0][x] = g; |
| 1545 | sample[1][0][x] = b; |
| 1546 | sample[2][0][x] = r; |
| 1547 | sample[3][0][x] = a; |
| 1548 | } |
| 1549 | for (p = 0; p < 3 + transparency; p++) { |
| 1550 | int ret; |
| 1551 | sample[p][0][-1] = sample[p][1][0 ]; |
| 1552 | sample[p][1][ w] = sample[p][1][w-1]; |
| 1553 | ret = encode_line32(f, sc, f->avctx, w, sample[p], (p + 1) / 2, |
| 1554 | bits[p], ac, pass1); |
| 1555 | if (ret < 0) |
| 1556 | return ret; |
| 1557 | } |
| 1558 | } |
| 1559 | return 0; |
no test coverage detected