| 109 | } |
| 110 | |
| 111 | static int decode_frame_lscr(AVCodecContext *avctx, AVFrame *rframe, |
| 112 | int *got_frame, AVPacket *avpkt) |
| 113 | { |
| 114 | LSCRContext *const s = avctx->priv_data; |
| 115 | GetByteContext *gb = &s->gb; |
| 116 | AVFrame *frame = s->last_picture; |
| 117 | int ret, nb_blocks, offset = 0; |
| 118 | |
| 119 | if (avpkt->size < 2) |
| 120 | return AVERROR_INVALIDDATA; |
| 121 | if (avpkt->size == 2) |
| 122 | return 0; |
| 123 | |
| 124 | bytestream2_init(gb, avpkt->data, avpkt->size); |
| 125 | |
| 126 | nb_blocks = bytestream2_get_le16(gb); |
| 127 | if (bytestream2_get_bytes_left(gb) < 2 + nb_blocks * (12 + 8)) |
| 128 | return AVERROR_INVALIDDATA; |
| 129 | |
| 130 | ret = ff_reget_buffer(avctx, frame, |
| 131 | nb_blocks ? 0 : FF_REGET_BUFFER_FLAG_READONLY); |
| 132 | if (ret < 0) |
| 133 | return ret; |
| 134 | |
| 135 | for (int b = 0; b < nb_blocks; b++) { |
| 136 | z_stream *const zstream = &s->zstream.zstream; |
| 137 | int x, y, x2, y2, w, h, left; |
| 138 | uint32_t csize, size; |
| 139 | |
| 140 | if (inflateReset(zstream) != Z_OK) |
| 141 | return AVERROR_EXTERNAL; |
| 142 | |
| 143 | bytestream2_seek(gb, 2 + b * 12, SEEK_SET); |
| 144 | |
| 145 | x = bytestream2_get_le16(gb); |
| 146 | y = bytestream2_get_le16(gb); |
| 147 | x2 = bytestream2_get_le16(gb); |
| 148 | y2 = bytestream2_get_le16(gb); |
| 149 | w = x2-x; |
| 150 | s->cur_h = h = y2-y; |
| 151 | |
| 152 | if (w <= 0 || x < 0 || x >= avctx->width || w + x > avctx->width || |
| 153 | h <= 0 || y < 0 || y >= avctx->height || h + y > avctx->height) |
| 154 | return AVERROR_INVALIDDATA; |
| 155 | |
| 156 | size = bytestream2_get_le32(gb); |
| 157 | |
| 158 | if ((nb_blocks == 1) && |
| 159 | (w == avctx->width) && |
| 160 | (h == avctx->height) && |
| 161 | (x == 0) && (y == 0)) |
| 162 | frame->flags |= AV_FRAME_FLAG_KEY; |
| 163 | else |
| 164 | frame->flags &= ~AV_FRAME_FLAG_KEY; |
| 165 | |
| 166 | bytestream2_seek(gb, 2 + nb_blocks * 12 + offset, SEEK_SET); |
| 167 | csize = bytestream2_get_be32(gb); |
| 168 | if (bytestream2_get_le32(gb) != MKTAG('I', 'D', 'A', 'T')) |
nothing calls this directly
no test coverage detected