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;
78 for (x = 0; x < w - 7; x+=8) {
80 dst[x + 1] = src[(x>>1) + 0];
82 dst[x + 3] = src[(x>>1) + 1];
84 dst[x + 5] = src[(x>>1) + 2];
86 dst[x + 7] = src[(x>>1) + 3];
97 for (x = w - 1; (x+1) & 7; x--) {
100 for (x -= 7; x >= 0; x -= 8) {
102 dst[x + 7] = src[(x>>1) + 3];
104 dst[x + 5] = src[(x>>1) + 2];
106 dst[x + 3] = src[(x>>1) + 1];
108 dst[x + 1] = src[(x>>1) + 0];
115 for (x = 0; x < w - 7; x+=8) {
116 dst[x + 0] = src[2*x + 0];
117 dst[x + 1] = src[2*x + 2];
118 dst[x + 2] = src[2*x + 4];
119 dst[x + 3] = src[2*x + 6];
120 dst[x + 4] = src[2*x + 8];
121 dst[x + 5] = src[2*x +10];
122 dst[x + 6] = src[2*x +12];
123 dst[x + 7] = src[2*x +14];
139 for (j = 0; j <
h; j++) {
147 for (j = 0; j <
h; j++) {
151 memcpy(dst1, src1, w);
155 if (scale_h && scale_v) {
156 for (y = 0; y < (h>>1); y++) {
161 }
else if (scale_h) {
162 for (y = 0; y < (h>>1); y++) {
165 memcpy(dst1, src1, w);
167 }
else if (scale_v) {
168 for (y = 0; y <
h; y++) {
182 if (bits->
fill == 0) {
183 bits->
queue |= bytestream2_get_byte(gb);
186 res = bits->
queue >> 6;
195 bits->
queue = bytestream2_get_le32(gb);
201 int res = bits->
queue & ((1 << nbits) - 1);
203 bits->
queue >>= nbits;
205 if (bits->
fill <= 16) {
206 bits->
queue |= bytestream2_get_le16(gb) << bits->
fill;
221 c = bytestream2_get_byte(g2);
222 for (i = 0; i <
len; i++) {
223 bytestream2_put_byte(pb, c);
225 }
else if (offset < 0) {
229 for (i = 0; i <
len; i++) {
230 bytestream2_put_byte(pb, bytestream2_get_byte(g2));
236 for (i = 0; i <
len; i++) {
237 bytestream2_put_byte(pb, bytestream2_get_byte(g2));
254 for (c = 0; c < 256; c++) {
255 for (i = 0; i < 16; i++) {
263 bytestream2_put_byte(pb, bytestream2_get_byte(gb));
264 }
else if (tag == 1) {
265 int b = bytestream2_get_byte(gb);
266 int len = (b & 0xF) + 3;
267 int top = (b >> 4) & 0xF;
268 int off = (bytestream2_get_byte(gb) << 4) + top - 4096;
270 }
else if (tag == 2) {
271 int len = (bytestream2_get_byte(gb)) + 2;
300 bytestream2_put_byte(pb, bytestream2_get_byte(gb));
301 }
else if (tag == 1) {
302 int b = bytestream2_get_byte(gb);
303 int len = (b & 0xF) + 3;
305 int off = (bytestream2_get_byte(gb) << 4) + top - 4096;
307 }
else if (tag == 2) {
309 int b = bytestream2_get_byte(gb);
316 len = bytestream2_get_le16(gb);
320 int b = bytestream2_get_byte(gb);
321 int len = (b & 0x3) + 2;
322 int off = -(b >> 2) - 1;
346 bytestream2_put_byte(pb, bytestream2_get_byte(gb));
356 if (val != ((1 << lbits) - 1)) {
362 for (i = 0; i <
len; i++) {
363 bytestream2_put_byte(pb, bytestream2_get_byte(gb));
366 }
else if (tag == 1) {
373 int bb = bytestream2_get_byte(gb);
374 if ((bb & 0x80) == 0) {
377 int top = (bb & 0x7F) << 8;
378 len = top + bytestream2_get_byte(gb) + 146;
382 }
else if (tag == 2) {
387 int offs = top + bytestream2_get_byte(gb);
388 if ((subtag != 0) || (offs <= 0xF80)) {
389 int len = (subtag) + 3;
390 lz_copy(pb, g2, (offs) - 4096, len);
398 real_off = ((offs >> 4) & 0x7) + 1;
399 len = ((offs & 0xF) + 2) * 2;
402 for (i = 0; i < len/2; i++) {
403 bytestream2_put_byte(pb, c1);
404 bytestream2_put_byte(pb, c2);
408 int b = bytestream2_get_byte(gb);
409 int off = ((b & 0x7F)) + 1;
410 int len = ((b & 0x80) == 0) ? 2 : 3;
418 int q,
b = bytestream2_get_byte(gb);
419 if ((b & 0xC0) == 0xC0) {
420 len = ((b & 0x3F)) + 8;
422 off = (q << 8) + (bytestream2_get_byte(gb)) + 1;
425 if ((b & 0x80) == 0) {
426 len = ((b >> 4)) + 6;
429 len = ((b & 0x3F)) + 14;
432 off = (ofs1 << 8) + (bytestream2_get_byte(gb)) - 4096;
435 int ofs1,
b = bytestream2_get_byte(gb);
437 if ((b >> 4) == 0xF) {
438 len = bytestream2_get_byte(gb) + 21;
443 off = (ofs1 << 8) + bytestream2_get_byte(gb) - 4096;
459 int ret,
i, pal_size;
468 flags = bytestream2_get_le32(gb);
469 compression = flags & 0xF;
471 if (compression == 4 || compression == 7 || compression > 8)
482 !!(flags & 0x10), !!(flags & 0x20));
484 switch (compression) {
488 for (i = 0; i < 256; i++) {
489 unsigned r = bytestream2_get_byte(gb);
490 unsigned g = bytestream2_get_byte(gb);
491 unsigned b = bytestream2_get_byte(gb);
492 gdv->
pal[
i] = 0xFF
U << 24 | r << 18 | g << 10 | b << 2;
516 dst = frame->
data[0];
522 for (y = 0; y < avctx->
height; y++) {
523 for (x = 0; x < avctx->
width; x++) {
524 dst[x+didx] = gdv->
frame[x+sidx];
526 sidx += avctx->
width;
533 for (y = 0; y < avctx->
height; y++) {
535 memcpy(dst + didx, gdv->
frame + sidx, avctx->
width);
542 if (!gdv->
scale_h || ((y & 1) == 1)) {
551 return ret < 0 ? ret : avpkt->
size;
const char const char void * val
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static void scaledown(uint8_t *dst, const uint8_t *src, int w)
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)
#define i(width, name, range_min, range_max)
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)
static void scaleup_rev(uint8_t *dst, const uint8_t *src, int w)
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 void scaleup(uint8_t *dst, const uint8_t *src, int w)
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)