Lines Matching refs:ctx

74     RsccContext *ctx = avctx->priv_data;
85 ctx->reference = av_frame_alloc();
86 if (!ctx->reference)
94 ctx->component_size = 4;
97 ctx->component_size = 3;
101 ctx->component_size = 4;
104 ctx->component_size = avctx->bits_per_coded_sample / 8;
125 ctx->component_size = 4;
130 ctx->inflated_size = avctx->width * avctx->height * ctx->component_size;
133 ctx->inflated_buf = av_malloc(ctx->inflated_size);
134 if (!ctx->inflated_buf)
142 RsccContext *ctx = avctx->priv_data;
144 av_freep(&ctx->tiles);
145 av_freep(&ctx->inflated_buf);
146 av_frame_free(&ctx->reference);
154 RsccContext *ctx = avctx->priv_data;
155 GetByteContext *gbc = &ctx->gbc;
178 av_fast_malloc(&ctx->tiles, &ctx->tiles_size,
179 tiles_nb * sizeof(*ctx->tiles));
180 if (!ctx->tiles) {
233 ctx->tiles[i].x = bytestream2_get_le16(gbc);
234 ctx->tiles[i].w = bytestream2_get_le16(gbc);
235 ctx->tiles[i].y = bytestream2_get_le16(gbc);
236 ctx->tiles[i].h = bytestream2_get_le16(gbc);
238 if (pixel_size + ctx->tiles[i].w * (int64_t)ctx->tiles[i].h * ctx->component_size > INT_MAX) {
244 pixel_size += ctx->tiles[i].w * ctx->tiles[i].h * ctx->component_size;
247 ctx->tiles[i].x, ctx->tiles[i].y,
248 ctx->tiles[i].w, ctx->tiles[i].h);
250 if (ctx->tiles[i].w == 0 || ctx->tiles[i].h == 0) {
253 ctx->tiles[i].x, ctx->tiles[i].y,
254 ctx->tiles[i].w, ctx->tiles[i].h);
257 } else if (ctx->tiles[i].x + ctx->tiles[i].w > avctx->width ||
258 ctx->tiles[i].y + ctx->tiles[i].h > avctx->height) {
261 ctx->tiles[i].x, ctx->tiles[i].y,
262 ctx->tiles[i].w, ctx->tiles[i].h);
269 gbc = &ctx->gbc;
298 uLongf len = ctx->inflated_size;
304 if (ctx->inflated_size < pixel_size) {
308 ret = uncompress(ctx->inflated_buf, &len, gbc->buffer, packed_size);
314 pixels = ctx->inflated_buf;
318 ret = ff_reget_buffer(avctx, ctx->reference, 0);
325 uint8_t *dst = ctx->reference->data[0] + ctx->reference->linesize[0] *
326 (avctx->height - ctx->tiles[i].y - 1) +
327 ctx->tiles[i].x * ctx->component_size;
328 av_image_copy_plane(dst, -1 * ctx->reference->linesize[0],
329 raw, ctx->tiles[i].w * ctx->component_size,
330 ctx->tiles[i].w * ctx->component_size,
331 ctx->tiles[i].h);
332 raw += ctx->tiles[i].w * ctx->component_size * ctx->tiles[i].h;
336 ret = av_frame_ref(frame, ctx->reference);
341 if (pixel_size == ctx->inflated_size) {
350 frame->palette_has_changed = ff_copy_palette(ctx->palette, avpkt, avctx);
351 memcpy(frame->data[1], ctx->palette, AVPALETTE_SIZE);
354 if (ctx->valid_pixels < ctx->inflated_size)
355 ctx->valid_pixels += pixel_size;
356 if (ctx->valid_pixels >= ctx->inflated_size * (100 - avctx->discard_damaged_percentage) / 100)