42 #include "libavutil/intreadwrite.h"
51 const unsigned char *
buf;
56 #define ADVANCE_BLOCK() \
59 if (pixel_ptr >= width) \
62 row_ptr += stride * 4; \
65 if (total_blocks < 0) \
67 av_log(s->avctx, AV_LOG_ERROR, "warning: block counter just went negative (this should not happen)\n"); \
76 int row_inc = stride - 4;
81 unsigned short colorA = 0, colorB;
82 unsigned short color4[4];
83 unsigned char index, idx;
84 unsigned short ta,
tb;
85 unsigned short *pixels = (
unsigned short *)s->
frame.
data[0];
94 if (s->
buf[stream_ptr] != 0xe1)
99 chunk_size =
AV_RB32(&s->
buf[stream_ptr]) & 0x00FFFFFF;
103 if (chunk_size != s->
size)
106 chunk_size = s->
size;
112 while (stream_ptr < chunk_size) {
113 opcode = s->
buf[stream_ptr++];
115 n_blocks = (opcode & 0x1f) + 1;
118 if ((opcode & 0x80) == 0) {
119 colorA = (opcode << 8) | (s->
buf[stream_ptr++]);
121 if ((s->
buf[stream_ptr] & 0x80) != 0) {
130 switch (opcode & 0xe0) {
145 block_ptr = row_ptr + pixel_ptr;
146 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
147 for (pixel_x = 0; pixel_x < 4; pixel_x++){
148 pixels[block_ptr] = colorA;
151 block_ptr += row_inc;
171 ta = (colorA >> 10) & 0x1F;
172 tb = (colorB >> 10) & 0x1F;
173 color4[1] |= ((11 * ta + 21 *
tb) >> 5) << 10;
174 color4[2] |= ((21 * ta + 11 *
tb) >> 5) << 10;
177 ta = (colorA >> 5) & 0x1F;
178 tb = (colorB >> 5) & 0x1F;
179 color4[1] |= ((11 * ta + 21 *
tb) >> 5) << 5;
180 color4[2] |= ((21 * ta + 11 *
tb) >> 5) << 5;
185 color4[1] |= ((11 * ta + 21 *
tb) >> 5);
186 color4[2] |= ((21 * ta + 11 *
tb) >> 5);
188 if (s->
size - stream_ptr < n_blocks * 4)
192 block_ptr = row_ptr + pixel_ptr;
193 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
194 index = s->
buf[stream_ptr++];
195 for (pixel_x = 0; pixel_x < 4; pixel_x++){
196 idx = (index >> (2 * (3 - pixel_x))) & 0x03;
197 pixels[block_ptr] = color4[idx];
200 block_ptr += row_inc;
207 if (s->
size - stream_ptr < 30)
210 block_ptr = row_ptr + pixel_ptr;
211 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
212 for (pixel_x = 0; pixel_x < 4; pixel_x++){
214 if ((pixel_y != 0) || (pixel_x !=0)) {
218 pixels[block_ptr] = colorA;
221 block_ptr += row_inc;
228 " Skip remaining %d bytes of chunk data.\n", opcode,
229 chunk_size - stream_ptr);
248 void *
data,
int *got_frame,
252 int buf_size = avpkt->
size;
static int rpza_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
This structure describes decoded (raw) audio or video data.
static av_cold int init(AVCodecContext *avctx)
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
if((e=av_dict_get(options,"", NULL, AV_DICT_IGNORE_SUFFIX)))
static void rpza_decode_stream(RpzaContext *s)
#define AV_PIX_FMT_RGB555
const char * name
Name of the codec implementation.
int av_frame_ref(AVFrame *dst, AVFrame *src)
Setup a new reference to the data described by a given frame.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static av_cold int rpza_decode_end(AVCodecContext *avctx)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Libavcodec external API header.
common internal API header
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
Identical in function to av_frame_make_writable(), except it uses ff_get_buffer() to allocate the buf...
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
int width
picture width / height.
static av_cold int rpza_decode_init(AVCodecContext *avctx)
main external API structure.
static void close(AVCodecParserContext *s)
void avcodec_get_frame_defaults(AVFrame *frame)
Set the fields of the given AVFrame to default values.
const unsigned char * buf
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
common internal api header.
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
This structure stores compressed data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.