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) {
144 block_ptr = row_ptr + pixel_ptr;
145 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
146 for (pixel_x = 0; pixel_x < 4; pixel_x++){
147 pixels[block_ptr] = colorA;
150 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)
191 block_ptr = row_ptr + pixel_ptr;
192 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
193 index = s->
buf[stream_ptr++];
194 for (pixel_x = 0; pixel_x < 4; pixel_x++){
195 idx = (index >> (2 * (3 - pixel_x))) & 0x03;
196 pixels[block_ptr] = color4[idx];
199 block_ptr += row_inc;
207 if (s->
size - stream_ptr < 16)
209 block_ptr = row_ptr + pixel_ptr;
210 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
211 for (pixel_x = 0; pixel_x < 4; pixel_x++){
213 if ((pixel_y != 0) || (pixel_x !=0)) {
217 pixels[block_ptr] = colorA;
220 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.
struct RpzaContext RpzaContext
static av_cold int init(AVCodecContext *avctx)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static void rpza_decode_stream(RpzaContext *s)
#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 NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
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...
int width
picture width / height.
static av_cold int rpza_decode_init(AVCodecContext *avctx)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
static void close(AVCodecParserContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void avcodec_get_frame_defaults(AVFrame *frame)
Set the fields of the given AVFrame to default values.
const unsigned char * buf
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
int av_frame_ref(AVFrame *dst, AVFrame *src)
Setup a new reference to the data described by an given frame.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal api header.
#define AV_PIX_FMT_RGB555
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
This structure stores compressed data.