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++) {
86 for (i = 0; i <
w; i++) {
92 for (j = 0; j <
h; j++) {
94 for (x = 0; x <
w; x++) {
99 for (j = 0; j <
h; j++) {
101 for (i = 0; i <
w; i++) {
108 if (scale_h && scale_v) {
109 for (y = 0; y < h/2; y++) {
110 for (x = 0; x < w/2; x++) {
114 }
else if (scale_h) {
115 for (y = 0; y < h/2; y++) {
116 for (x = 0; x <
w; x++) {
120 }
else if (scale_v) {
121 for (y = 0; y <
h; y++) {
122 for (x = 0; x < w/2; x++) {
136 if (bits->
fill == 0) {
137 bits->
queue |= bytestream2_get_byte(gb);
140 res = bits->
queue >> 6;
149 bits->
queue = bytestream2_get_le32(gb);
155 int res = bits->
queue & ((1 << nbits) - 1);
157 bits->
queue >>= nbits;
159 if (bits->
fill <= 16) {
160 bits->
queue |= bytestream2_get_le16(gb) << bits->
fill;
175 c = bytestream2_get_byte(g2);
176 for (i = 0; i <
len; i++) {
177 bytestream2_put_byte(pb, c);
179 }
else if (offset < 0) {
183 for (i = 0; i <
len; i++) {
184 bytestream2_put_byte(pb, bytestream2_get_byte(g2));
190 for (i = 0; i <
len; i++) {
191 bytestream2_put_byte(pb, bytestream2_get_byte(g2));
208 for (c = 0; c < 256; c++) {
209 for (i = 0; i < 16; i++) {
210 gdv->
frame[c * 16 + i] =
c;
217 bytestream2_put_byte(pb, bytestream2_get_byte(gb));
218 }
else if (tag == 1) {
219 int b = bytestream2_get_byte(gb);
220 int len = (b & 0xF) + 3;
221 int top = (b >> 4) & 0xF;
222 int off = (bytestream2_get_byte(gb) << 4) + top - 4096;
224 }
else if (tag == 2) {
225 int len = (bytestream2_get_byte(gb)) + 2;
248 bytestream2_put_byte(pb, bytestream2_get_byte(gb));
249 }
else if (tag == 1) {
250 int b = bytestream2_get_byte(gb);
251 int len = (b & 0xF) + 3;
253 int off = (bytestream2_get_byte(gb) << 4) + top - 4096;
255 }
else if (tag == 2) {
257 int b = bytestream2_get_byte(gb);
264 len = bytestream2_get_le16(gb);
268 int b = bytestream2_get_byte(gb);
269 int len = (b & 0x3) + 2;
270 int off = -(b >> 2) - 1;
294 bytestream2_put_byte(pb, bytestream2_get_byte(gb));
304 if (val != ((1 << lbits) - 1)) {
309 for (i = 0; i <
len; i++) {
310 bytestream2_put_byte(pb, bytestream2_get_byte(gb));
313 }
else if (tag == 1) {
320 int bb = bytestream2_get_byte(gb);
321 if ((bb & 0x80) == 0) {
324 int top = (bb & 0x7F) << 8;
325 len = top + bytestream2_get_byte(gb) + 146;
329 }
else if (tag == 2) {
334 int offs = top + bytestream2_get_byte(gb);
335 if ((subtag != 0) || (offs <= 0xF80)) {
336 int len = (subtag) + 3;
337 lz_copy(pb, g2, (offs) - 4096, len);
345 real_off = ((offs >> 4) & 0x7) + 1;
346 len = ((offs & 0xF) + 2) * 2;
349 for (i = 0; i < len/2; i++) {
350 bytestream2_put_byte(pb, c1);
351 bytestream2_put_byte(pb, c2);
355 int b = bytestream2_get_byte(gb);
356 int off = ((b & 0x7F)) + 1;
357 int len = ((b & 0x80) == 0) ? 2 : 3;
365 int q,
b = bytestream2_get_byte(gb);
366 if ((b & 0xC0) == 0xC0) {
367 len = ((b & 0x3F)) + 8;
369 off = (q << 8) + (bytestream2_get_byte(gb)) + 1;
372 if ((b & 0x80) == 0) {
373 len = ((b >> 4)) + 6;
376 len = ((b & 0x3F)) + 14;
379 off = (ofs1 << 8) + (bytestream2_get_byte(gb)) - 4096;
382 int ofs1,
b = bytestream2_get_byte(gb);
384 if ((b >> 4) == 0xF) {
385 len = bytestream2_get_byte(gb) + 21;
390 off = (ofs1 << 8) + bytestream2_get_byte(gb) - 4096;
406 int ret, i, pal_size;
415 flags = bytestream2_get_le32(gb);
416 compression = flags & 0xF;
418 if (compression == 4 || compression == 7 || compression > 8)
427 !!(flags & 0x10), !!(flags & 0x20));
429 switch (compression) {
435 for (i = 0; i < 256; i++) {
436 unsigned r = bytestream2_get_byte(gb);
437 unsigned g = bytestream2_get_byte(gb);
438 unsigned b = bytestream2_get_byte(gb);
439 gdv->
pal[i] = 0xFF
U << 24 | r << 18 | g << 10 | b << 2;
461 dst = frame->
data[0];
467 for (y = 0; y < avctx->
height; y++) {
468 for (x = 0; x < avctx->
width; x++) {
469 dst[x+didx] = gdv->
frame[x+sidx];
471 sidx += avctx->
width;
478 for (y = 0; y < avctx->
height; y++) {
480 for (x = 0; x < avctx->
width; x++) {
481 dst[didx + x] = gdv->
frame[sidx + x];
484 for (x = 0; x < avctx->
width; x++) {
485 dst[didx + x] = gdv->
frame[sidx + x/2];
488 if (!gdv->
scale_h || ((y & 1) == 1)) {
497 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.
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)
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)