55 #define CHECK_BLOCK() \ 56 if (total_blocks < 1) { \ 57 av_log(s->avctx, AV_LOG_ERROR, \ 58 "Block counter just went negative (this should not happen)\n"); \ 59 return AVERROR_INVALIDDATA; \ 62 #define ADVANCE_BLOCK() \ 65 if (pixel_ptr >= width) \ 68 row_ptr += stride * 4; \ 77 int row_inc = stride - 4;
79 uint16_t colorA = 0, colorB;
91 if (bytestream2_peek_byte(&s->
gb) != 0xe1)
93 bytestream2_peek_byte(&s->
gb));
96 chunk_size = bytestream2_get_be32(&s->
gb) & 0x00FFFFFF;
101 "MOV chunk size %d != encoded chunk size %d\n",
111 uint8_t opcode = bytestream2_get_byte(&s->
gb);
113 int n_blocks = (opcode & 0x1f) + 1;
116 if ((opcode & 0x80) == 0) {
117 colorA = (opcode << 8) | bytestream2_get_byte(&s->
gb);
119 if ((bytestream2_peek_byte(&s->
gb) & 0x80) != 0) {
128 n_blocks =
FFMIN(n_blocks, total_blocks);
130 switch (opcode & 0xe0) {
142 colorA = bytestream2_get_be16(&s->
gb);
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;
159 colorA = bytestream2_get_be16(&s->
gb);
161 colorB = bytestream2_get_be16(&s->
gb);
170 ta = (colorA >> 10) & 0x1F;
171 tb = (colorB >> 10) & 0x1F;
172 color4[1] |= ((11 * ta + 21 *
tb) >> 5) << 10;
173 color4[2] |= ((21 * ta + 11 *
tb) >> 5) << 10;
176 ta = (colorA >> 5) & 0x1F;
177 tb = (colorB >> 5) & 0x1F;
178 color4[1] |= ((11 * ta + 21 *
tb) >> 5) << 5;
179 color4[2] |= ((21 * ta + 11 *
tb) >> 5) << 5;
184 color4[1] |= ((11 * ta + 21 *
tb) >> 5);
185 color4[2] |= ((21 * ta + 11 *
tb) >> 5);
191 block_ptr = row_ptr + pixel_ptr;
192 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
194 for (pixel_x = 0; pixel_x < 4; pixel_x++){
195 uint8_t idx = (index >> (2 * (3 - pixel_x))) & 0x03;
196 pixels[block_ptr] = color4[idx];
199 block_ptr += row_inc;
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))
215 colorA = bytestream2_get_be16u(&s->
gb);
216 pixels[block_ptr] = colorA;
219 block_ptr += row_inc;
227 " Skip remaining %d bytes of chunk data.\n", opcode,
251 void *
data,
int *got_frame,
static int rpza_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
#define AV_LOG_WARNING
Something somehow does not look correct.
static av_cold int init(AVCodecContext *avctx)
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)
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
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...
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
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)
const char * name
Name of the codec implementation.
common internal API header
int width
picture width / height.
static int rpza_decode_stream(RpzaContext *s)
static av_cold int rpza_decode_init(AVCodecContext *avctx)
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal api header.
#define AV_PIX_FMT_RGB555
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.