3 * Copyright (C) 2005 the ffmpeg project
5 * This file is part of FFmpeg.
7 * FFmpeg 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 * FFmpeg 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 FFmpeg; 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;
40 #define FETCH_NEXT_STREAM_BYTE() \
41 if (stream_ptr >= buf_size) \
43 av_log(s->avctx, AV_LOG_ERROR, " AASC: stream ptr just went out of bounds (fetch)\n"); \
46 stream_byte = buf[stream_ptr++];
48 static av_cold int aasc_decode_init(AVCodecContext *avctx)
50 AascContext *s = avctx->priv_data;
54 avctx->pix_fmt = PIX_FMT_BGR24;
55 s->frame.data[0] = NULL;
60 static int aasc_decode_frame(AVCodecContext *avctx,
61 void *data, int *data_size,
62 const uint8_t *buf, int buf_size)
64 AascContext *s = avctx->priv_data;
66 s->frame.reference = 1;
67 s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
68 if (avctx->reget_buffer(avctx, &s->frame)) {
69 av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
73 ff_msrle_decode(avctx, &s->frame, 8, buf, buf_size);
75 *data_size = sizeof(AVFrame);
76 *(AVFrame*)data = s->frame;
78 /* report that the buffer was completely consumed */
82 static av_cold int aasc_decode_end(AVCodecContext *avctx)
84 AascContext *s = avctx->priv_data;
86 /* release the last frame */
88 avctx->release_buffer(avctx, &s->frame);
93 AVCodec aasc_decoder = {
103 .long_name = NULL_IF_CONFIG_SMALL("Autodesk RLE"),