55 #define ADVANCE_BLOCK() \
58 if (pixel_ptr >= width) \
61 row_ptr += stride * 4; \
64 if (total_blocks < 0) \
66 av_log(s->avctx, AV_LOG_ERROR, "warning: block counter just went negative (this should not happen)\n"); \
75 int row_inc = stride - 4;
77 uint16_t colorA = 0, colorB;
80 uint16_t *pixels = (uint16_t *)s->
frame->
data[0];
89 if (bytestream2_peek_byte(&s->
gb) != 0xe1)
91 bytestream2_peek_byte(&s->
gb));
94 chunk_size = bytestream2_get_be32(&s->
gb) & 0x00FFFFFF;
105 uint8_t opcode = bytestream2_get_byte(&s->
gb);
107 int n_blocks = (opcode & 0x1f) + 1;
110 if ((opcode & 0x80) == 0) {
111 colorA = (opcode << 8) | bytestream2_get_byte(&s->
gb);
113 if ((bytestream2_peek_byte(&s->
gb) & 0x80) != 0) {
122 n_blocks =
FFMIN(n_blocks, total_blocks);
124 switch (opcode & 0xe0) {
135 colorA = bytestream2_get_be16(&s->
gb);
137 block_ptr = row_ptr + pixel_ptr;
138 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
139 for (pixel_x = 0; pixel_x < 4; pixel_x++){
140 pixels[block_ptr] = colorA;
143 block_ptr += row_inc;
151 colorA = bytestream2_get_be16(&s->
gb);
153 colorB = bytestream2_get_be16(&s->
gb);
162 ta = (colorA >> 10) & 0x1F;
163 tb = (colorB >> 10) & 0x1F;
164 color4[1] |= ((11 * ta + 21 * tb) >> 5) << 10;
165 color4[2] |= ((21 * ta + 11 * tb) >> 5) << 10;
168 ta = (colorA >> 5) & 0x1F;
169 tb = (colorB >> 5) & 0x1F;
170 color4[1] |= ((11 * ta + 21 * tb) >> 5) << 5;
171 color4[2] |= ((21 * ta + 11 * tb) >> 5) << 5;
176 color4[1] |= ((11 * ta + 21 * tb) >> 5);
177 color4[2] |= ((21 * ta + 11 * tb) >> 5);
182 block_ptr = row_ptr + pixel_ptr;
183 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
185 for (pixel_x = 0; pixel_x < 4; pixel_x++){
186 uint8_t idx = (index >> (2 * (3 - pixel_x))) & 0x03;
187 pixels[block_ptr] = color4[idx];
190 block_ptr += row_inc;
200 block_ptr = row_ptr + pixel_ptr;
201 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
202 for (pixel_x = 0; pixel_x < 4; pixel_x++){
204 if ((pixel_y != 0) || (pixel_x != 0))
205 colorA = bytestream2_get_be16u(&s->
gb);
206 pixels[block_ptr] = colorA;
209 block_ptr += row_inc;
217 " Skip remaining %d bytes of chunk data.\n", opcode,
239 void *
data,
int *got_frame,
static int rpza_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
This structure describes decoded (raw) audio or video data.
#define AV_LOG_WARNING
Something somehow does not look correct.
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.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
static void rpza_decode_stream(RpzaContext *s)
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
const char * name
Name of the codec implementation.
#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.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
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...
int width
picture width / height.
if(ac->has_optimized_func)
static av_cold int rpza_decode_init(AVCodecContext *avctx)
#define AV_PIX_FMT_RGB555
main external API structure.
static void close(AVCodecParserContext *s)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
common internal api header.
static av_cold int init(AVCodecParserContext *s)
This structure stores compressed data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.