3 * Copyright (C) 2005 the ffmpeg project
5 * This file is part of Libav.
7 * Libav is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * Libav is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with Libav; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 * Autodesk RLE Video Decoder by Konstantin Shishkov
35 typedef struct AascContext
{
36 AVCodecContext
*avctx
;
41 static av_cold
int aasc_decode_init(AVCodecContext
*avctx
)
43 AascContext
*s
= avctx
->priv_data
;
47 avctx
->pix_fmt
= AV_PIX_FMT_BGR24
;
49 s
->frame
= av_frame_alloc();
51 return AVERROR(ENOMEM
);
56 static int aasc_decode_frame(AVCodecContext
*avctx
,
57 void *data
, int *got_frame
,
60 const uint8_t *buf
= avpkt
->data
;
61 int buf_size
= avpkt
->size
;
62 AascContext
*s
= avctx
->priv_data
;
63 int compr
, i
, stride
, ret
;
65 if ((ret
= ff_reget_buffer(avctx
, s
->frame
)) < 0) {
66 av_log(avctx
, AV_LOG_ERROR
, "reget_buffer() failed\n");
75 stride
= (avctx
->width
* 3 + 3) & ~3;
76 for (i
= avctx
->height
- 1; i
>= 0; i
--) {
77 memcpy(s
->frame
->data
[0] + i
* s
->frame
->linesize
[0], buf
, avctx
->width
* 3);
82 bytestream2_init(&s
->gb
, buf
, buf_size
);
83 ff_msrle_decode(avctx
, (AVPicture
*)s
->frame
, 8, &s
->gb
);
86 av_log(avctx
, AV_LOG_ERROR
, "Unknown compression type %d\n", compr
);
87 return AVERROR_INVALIDDATA
;
91 if ((ret
= av_frame_ref(data
, s
->frame
)) < 0)
94 /* report that the buffer was completely consumed */
98 static av_cold
int aasc_decode_end(AVCodecContext
*avctx
)
100 AascContext
*s
= avctx
->priv_data
;
102 av_frame_free(&s
->frame
);
107 AVCodec ff_aasc_decoder
= {
109 .type
= AVMEDIA_TYPE_VIDEO
,
110 .id
= AV_CODEC_ID_AASC
,
111 .priv_data_size
= sizeof(AascContext
),
112 .init
= aasc_decode_init
,
113 .close
= aasc_decode_end
,
114 .decode
= aasc_decode_frame
,
115 .capabilities
= CODEC_CAP_DR1
,
116 .long_name
= NULL_IF_CONFIG_SMALL("Autodesk RLE"),