51 #define PREAMBLE_SIZE 4096
64 for (i = 0; i < 2; i++) {
65 for (j = 0; j < 256; j++) {
66 for (k = 0; k < 8; k++) {
67 gdv->
frame[i * 2048 + j * 8 + k] = j;
84 for (j = 0; j <
h; j++) {
89 for (x = w - 1; x >= 0 && !(x&1); x--) {
90 dst1[x] = src1[(x>>1)];
93 for (x--; x >= 0; x-=2) {
95 dst1[x+1] = src1[(x>>1)];
99 for (j = 0; j <
h; j++) {
103 memcpy(dst1, src1, w);
107 if (scale_h && scale_v) {
108 for (y = 0; y < (h>>1); y++) {
111 for (x = 0; x < (w>>1); x++) {
115 }
else if (scale_h) {
116 for (y = 0; y < (h>>1); y++) {
119 memcpy(dst1, src1, w);
121 }
else if (scale_v) {
122 for (y = 0; y <
h; y++) {
124 for (x = 0; x < (w>>1); x++) {
138 if (bits->
fill == 0) {
139 bits->
queue |= bytestream2_get_byte(gb);
142 res = bits->
queue >> 6;
151 bits->
queue = bytestream2_get_le32(gb);
157 int res = bits->
queue & ((1 << nbits) - 1);
159 bits->
queue >>= nbits;
161 if (bits->
fill <= 16) {
162 bits->
queue |= bytestream2_get_le16(gb) << bits->
fill;
177 c = bytestream2_get_byte(g2);
178 for (i = 0; i <
len; i++) {
179 bytestream2_put_byte(pb, c);
181 }
else if (offset < 0) {
185 for (i = 0; i <
len; i++) {
186 bytestream2_put_byte(pb, bytestream2_get_byte(g2));
192 for (i = 0; i <
len; i++) {
193 bytestream2_put_byte(pb, bytestream2_get_byte(g2));
210 for (c = 0; c < 256; c++) {
211 for (i = 0; i < 16; i++) {
212 gdv->
frame[c * 16 + i] =
c;
219 bytestream2_put_byte(pb, bytestream2_get_byte(gb));
220 }
else if (tag == 1) {
221 int b = bytestream2_get_byte(gb);
222 int len = (b & 0xF) + 3;
223 int top = (b >> 4) & 0xF;
224 int off = (bytestream2_get_byte(gb) << 4) + top - 4096;
226 }
else if (tag == 2) {
227 int len = (bytestream2_get_byte(gb)) + 2;
254 bytestream2_put_byte(pb, bytestream2_get_byte(gb));
255 }
else if (tag == 1) {
256 int b = bytestream2_get_byte(gb);
257 int len = (b & 0xF) + 3;
259 int off = (bytestream2_get_byte(gb) << 4) + top - 4096;
261 }
else if (tag == 2) {
263 int b = bytestream2_get_byte(gb);
270 len = bytestream2_get_le16(gb);
274 int b = bytestream2_get_byte(gb);
275 int len = (b & 0x3) + 2;
276 int off = -(b >> 2) - 1;
300 bytestream2_put_byte(pb, bytestream2_get_byte(gb));
310 if (val != ((1 << lbits) - 1)) {
315 for (i = 0; i <
len; i++) {
316 bytestream2_put_byte(pb, bytestream2_get_byte(gb));
319 }
else if (tag == 1) {
326 int bb = bytestream2_get_byte(gb);
327 if ((bb & 0x80) == 0) {
330 int top = (bb & 0x7F) << 8;
331 len = top + bytestream2_get_byte(gb) + 146;
335 }
else if (tag == 2) {
340 int offs = top + bytestream2_get_byte(gb);
341 if ((subtag != 0) || (offs <= 0xF80)) {
342 int len = (subtag) + 3;
343 lz_copy(pb, g2, (offs) - 4096, len);
351 real_off = ((offs >> 4) & 0x7) + 1;
352 len = ((offs & 0xF) + 2) * 2;
355 for (i = 0; i < len/2; i++) {
356 bytestream2_put_byte(pb, c1);
357 bytestream2_put_byte(pb, c2);
361 int b = bytestream2_get_byte(gb);
362 int off = ((b & 0x7F)) + 1;
363 int len = ((b & 0x80) == 0) ? 2 : 3;
371 int q,
b = bytestream2_get_byte(gb);
372 if ((b & 0xC0) == 0xC0) {
373 len = ((b & 0x3F)) + 8;
375 off = (q << 8) + (bytestream2_get_byte(gb)) + 1;
378 if ((b & 0x80) == 0) {
379 len = ((b >> 4)) + 6;
382 len = ((b & 0x3F)) + 14;
385 off = (ofs1 << 8) + (bytestream2_get_byte(gb)) - 4096;
388 int ofs1,
b = bytestream2_get_byte(gb);
390 if ((b >> 4) == 0xF) {
391 len = bytestream2_get_byte(gb) + 21;
396 off = (ofs1 << 8) + bytestream2_get_byte(gb) - 4096;
412 int ret, i, pal_size;
421 flags = bytestream2_get_le32(gb);
422 compression = flags & 0xF;
424 if (compression == 4 || compression == 7 || compression > 8)
433 !!(flags & 0x10), !!(flags & 0x20));
435 switch (compression) {
441 for (i = 0; i < 256; i++) {
442 unsigned r = bytestream2_get_byte(gb);
443 unsigned g = bytestream2_get_byte(gb);
444 unsigned b = bytestream2_get_byte(gb);
445 gdv->
pal[i] = 0xFF
U << 24 | r << 18 | g << 10 | b << 2;
469 dst = frame->
data[0];
475 for (y = 0; y < avctx->
height; y++) {
476 for (x = 0; x < avctx->
width; x++) {
477 dst[x+didx] = gdv->
frame[x+sidx];
479 sidx += avctx->
width;
486 for (y = 0; y < avctx->
height; y++) {
488 memcpy(dst + didx, gdv->
frame + sidx, avctx->
width);
490 for (x = 0; x < avctx->
width - 1; x+=2) {
492 dst[didx + x + 1] = gdv->
frame[sidx + (x>>1)];
494 for (; x < avctx->
width; x++) {
495 dst[didx + x] = gdv->
frame[sidx + (x>>1)];
498 if (!gdv->
scale_h || ((y & 1) == 1)) {
507 return ret < 0 ? ret : avpkt->
size;
const char const char void * val
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
static av_cold int init(AVCodecContext *avctx)
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
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)
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
8 bits with AV_PIX_FMT_RGB32 palette
static int gdv_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette...
static av_always_inline unsigned int bytestream2_get_bytes_left_p(PutByteContext *p)
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
#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.
static const uint8_t offset[127][2]
static av_always_inline int bytestream2_tell_p(PutByteContext *p)
static av_always_inline void bytestream2_skip_p(PutByteContext *p, unsigned int size)
static void rescale(GDVContext *gdv, uint8_t *dst, int w, int h, int scale_v, int scale_h)
int width
picture width / height.
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static av_cold int gdv_decode_close(AVCodecContext *avctx)
static void fill_bits32(Bits32 *bits, GetByteContext *gb)
static int decompress_68(AVCodecContext *avctx, unsigned skip, unsigned use8)
static int read_bits32(Bits32 *bits, GetByteContext *gb, int nbits)
static av_cold int gdv_decode_init(AVCodecContext *avctx)
static int decompress_5(AVCodecContext *avctx, unsigned skip)
#define flags(name, subs,...)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static void lz_copy(PutByteContext *pb, GetByteContext *g2, int offset, unsigned len)
static int decompress_2(AVCodecContext *avctx)
common internal api header.
common internal and external API header
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static int read_bits2(Bits8 *bits, GetByteContext *gb)