Lines Matching defs:avctx
69 static void clear_plane(AVCodecContext *avctx, AVFrame *frame)
71 RASCContext *s = avctx->priv_data;
77 for (int y = 0; y < avctx->height; y++) {
78 memset(dst, 0, avctx->width * s->bpp);
83 static void copy_plane(AVCodecContext *avctx, AVFrame *src, AVFrame *dst)
85 RASCContext *s = avctx->priv_data;
89 for (int y = 0; y < avctx->height; y++) {
96 static int init_frames(AVCodecContext *avctx)
98 RASCContext *s = avctx->priv_data;
103 if ((ret = ff_get_buffer(avctx, s->frame1, 0)) < 0)
106 if ((ret = ff_get_buffer(avctx, s->frame2, 0)) < 0)
109 clear_plane(avctx, s->frame2);
110 clear_plane(avctx, s->frame1);
115 static int decode_fint(AVCodecContext *avctx,
118 RASCContext *s = avctx->priv_data;
127 clear_plane(avctx, s->frame2);
128 clear_plane(avctx, s->frame1);
154 ret = ff_set_dimensions(avctx, w, h);
157 avctx->width = w;
158 avctx->height = h;
159 avctx->pix_fmt = fmt;
161 ret = init_frames(avctx);
165 if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
175 static int decode_zlib(AVCodecContext *avctx, const AVPacket *avpkt,
178 RASCContext *s = avctx->priv_data;
185 av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret);
201 av_log(avctx, AV_LOG_ERROR,
209 static int decode_move(AVCodecContext *avctx,
212 RASCContext *s = avctx->priv_data;
225 if (nb_moves > INT32_MAX / 16 || nb_moves > avctx->width * avctx->height)
231 ret = decode_zlib(avctx, avpkt,
241 avpriv_request_sample(avctx, "compression %d", compression);
264 if (start_x >= avctx->width || start_y >= avctx->height ||
265 end_x >= avctx->width || end_y >= avctx->height ||
266 mov_x >= avctx->width || mov_y >= avctx->height) {
276 if (mov_x + w > avctx->width || mov_y + h > avctx->height)
333 static int decode_dlta(AVCodecContext *avctx,
336 RASCContext *s = avctx->priv_data;
352 if (x >= avctx->width || y >= avctx->height ||
353 w > avctx->width || h > avctx->height)
356 if (x + w > avctx->width || y + h > avctx->height)
365 ret = decode_zlib(avctx, avpkt, size, uncompressed_size);
375 avpriv_request_sample(avctx, "compression %d", compression);
465 avpriv_request_sample(avctx, "runlen %d", type);
475 static int decode_kfrm(AVCodecContext *avctx,
478 RASCContext *s = avctx->priv_data;
487 ret = decode_fint(avctx, avpkt, size);
497 av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret);
504 dst = s->frame2->data[0] + (avctx->height - 1) * s->frame2->linesize[0];
505 for (int i = 0; i < avctx->height; i++) {
511 av_log(avctx, AV_LOG_ERROR,
519 dst = s->frame1->data[0] + (avctx->height - 1) * s->frame1->linesize[0];
520 for (int i = 0; i < avctx->height; i++) {
526 av_log(avctx, AV_LOG_ERROR,
539 static int decode_mous(AVCodecContext *avctx,
542 RASCContext *s = avctx->priv_data;
554 if (w > avctx->width || h > avctx->height)
564 ret = decode_zlib(avctx, avpkt,
579 static int decode_mpos(AVCodecContext *avctx,
582 RASCContext *s = avctx->priv_data;
596 static void draw_cursor(AVCodecContext *avctx)
598 RASCContext *s = avctx->priv_data;
604 if (s->cursor_x >= avctx->width || s->cursor_y >= avctx->height)
607 if (s->cursor_x + s->cursor_w > avctx->width ||
608 s->cursor_y + s->cursor_h > avctx->height)
611 if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
640 } else if (avctx->pix_fmt == AV_PIX_FMT_RGB555LE) {
655 } else if (avctx->pix_fmt == AV_PIX_FMT_BGR0) {
674 static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
677 RASCContext *s = avctx->priv_data;
707 ret = decode_fint(avctx, avpkt, size);
710 ret = decode_kfrm(avctx, avpkt, size);
713 ret = decode_dlta(avctx, avpkt, size);
716 ret = decode_move(avctx, avpkt, size);
719 ret = decode_mous(avctx, avpkt, size);
722 ret = decode_mpos(avctx, avpkt, size);
736 if ((ret = ff_get_buffer(avctx, s->frame, 0)) < 0)
739 copy_plane(avctx, s->frame2, s->frame);
740 if (avctx->pix_fmt == AV_PIX_FMT_PAL8)
743 draw_cursor(avctx);
753 static av_cold int decode_init(AVCodecContext *avctx)
755 RASCContext *s = avctx->priv_data;
762 return ff_inflate_init(&s->zstream, avctx);
765 static av_cold int decode_close(AVCodecContext *avctx)
767 RASCContext *s = avctx->priv_data;
780 static void decode_flush(AVCodecContext *avctx)
782 RASCContext *s = avctx->priv_data;
784 clear_plane(avctx, s->frame1);
785 clear_plane(avctx, s->frame2);