52 #define PREAMBLE_SIZE 4096 65 for (i = 0; i < 2; i++) {
66 for (j = 0; j < 256; j++) {
67 for (k = 0; k < 8; k++) {
68 gdv->
frame[i * 2048 + j * 8 + k] = j;
79 for (x = 0; x < w - 7; x+=8) {
81 dst[x + 1] = src[(x>>1) + 0];
83 dst[x + 3] = src[(x>>1) + 1];
85 dst[x + 5] = src[(x>>1) + 2];
87 dst[x + 7] = src[(x>>1) + 3];
98 for (x = w - 1; (x+1) & 7; x--) {
101 for (x -= 7; x >= 0; x -= 8) {
103 dst[x + 7] = src[(x>>1) + 3];
105 dst[x + 5] = src[(x>>1) + 2];
107 dst[x + 3] = src[(x>>1) + 1];
109 dst[x + 1] = src[(x>>1) + 0];
116 for (x = 0; x < w - 7; x+=8) {
117 dst[x + 0] = src[2*x + 0];
118 dst[x + 1] = src[2*x + 2];
119 dst[x + 2] = src[2*x + 4];
120 dst[x + 3] = src[2*x + 6];
121 dst[x + 4] = src[2*x + 8];
122 dst[x + 5] = src[2*x +10];
123 dst[x + 6] = src[2*x +12];
124 dst[x + 7] = src[2*x +14];
140 for (j = 0; j <
h; j++) {
148 for (j = 0; j <
h; j++) {
152 memcpy(dst1, src1, w);
156 if (scale_h && scale_v) {
157 for (y = 0; y < (h>>1); y++) {
162 }
else if (scale_h) {
163 for (y = 0; y < (h>>1); y++) {
166 memcpy(dst1, src1, w);
168 }
else if (scale_v) {
169 for (y = 0; y <
h; y++) {
183 if (bits->
fill == 0) {
184 bits->
queue |= bytestream2_get_byte(gb);
187 res = bits->
queue >> 6;
196 bits->
queue = bytestream2_get_le32(gb);
202 int res = bits->
queue & ((1 << nbits) - 1);
204 bits->
queue >>= nbits;
206 if (bits->
fill <= 16) {
207 bits->
queue |= bytestream2_get_le16(gb) << bits->
fill;
222 c = bytestream2_get_byte(g2);
223 for (i = 0; i <
len; i++) {
224 bytestream2_put_byte(pb, c);
226 }
else if (offset < 0) {
230 for (i = 0; i <
len; i++) {
231 bytestream2_put_byte(pb, bytestream2_get_byte(g2));
237 for (i = 0; i <
len; i++) {
238 bytestream2_put_byte(pb, bytestream2_get_byte(g2));
255 for (c = 0; c < 256; c++) {
256 for (i = 0; i < 16; i++) {
264 bytestream2_put_byte(pb, bytestream2_get_byte(gb));
265 }
else if (tag == 1) {
266 int b = bytestream2_get_byte(gb);
267 int len = (b & 0xF) + 3;
268 int top = (b >> 4) & 0xF;
269 int off = (bytestream2_get_byte(gb) << 4) + top - 4096;
271 }
else if (tag == 2) {
272 int len = (bytestream2_get_byte(gb)) + 2;
301 bytestream2_put_byte(pb, bytestream2_get_byte(gb));
302 }
else if (tag == 1) {
303 int b = bytestream2_get_byte(gb);
304 int len = (b & 0xF) + 3;
306 int off = (bytestream2_get_byte(gb) << 4) + top - 4096;
308 }
else if (tag == 2) {
310 int b = bytestream2_get_byte(gb);
317 len = bytestream2_get_le16(gb);
321 int b = bytestream2_get_byte(gb);
322 int len = (b & 0x3) + 2;
323 int off = -(b >> 2) - 1;
349 bytestream2_put_byte(pb, bytestream2_get_byte(gb));
359 if (val != ((1 << lbits) - 1)) {
365 for (i = 0; i <
len; i++) {
366 bytestream2_put_byte(pb, bytestream2_get_byte(gb));
369 }
else if (tag == 1) {
376 int bb = bytestream2_get_byte(gb);
377 if ((bb & 0x80) == 0) {
380 int top = (bb & 0x7F) << 8;
381 len = top + bytestream2_get_byte(gb) + 146;
385 }
else if (tag == 2) {
390 int offs = top + bytestream2_get_byte(gb);
391 if ((subtag != 0) || (offs <= 0xF80)) {
392 int len = (subtag) + 3;
393 lz_copy(pb, g2, (offs) - 4096, len);
401 real_off = ((offs >> 4) & 0x7) + 1;
402 len = ((offs & 0xF) + 2) * 2;
405 for (i = 0; i < len/2; i++) {
406 bytestream2_put_byte(pb, c1);
407 bytestream2_put_byte(pb, c2);
411 int b = bytestream2_get_byte(gb);
412 int off = ((b & 0x7F)) + 1;
413 int len = ((b & 0x80) == 0) ? 2 : 3;
421 int q,
b = bytestream2_get_byte(gb);
422 if ((b & 0xC0) == 0xC0) {
423 len = ((b & 0x3F)) + 8;
425 off = (q << 8) + (bytestream2_get_byte(gb)) + 1;
428 if ((b & 0x80) == 0) {
429 len = ((b >> 4)) + 6;
432 len = ((b & 0x3F)) + 14;
435 off = (ofs1 << 8) + (bytestream2_get_byte(gb)) - 4096;
438 int ofs1,
b = bytestream2_get_byte(gb);
440 if ((b >> 4) == 0xF) {
441 len = bytestream2_get_byte(gb) + 21;
446 off = (ofs1 << 8) + bytestream2_get_byte(gb) - 4096;
473 flags = bytestream2_get_le32(gb);
474 compression = flags & 0xF;
476 if (compression == 4 || compression == 7 || compression > 8)
486 !!(flags & 0x10), !!(flags & 0x20));
488 switch (compression) {
492 for (i = 0; i < 256; i++) {
493 unsigned r = bytestream2_get_byte(gb);
494 unsigned g = bytestream2_get_byte(gb);
495 unsigned b = bytestream2_get_byte(gb);
496 gdv->
pal[
i] = 0xFF
U << 24 | r << 18 | g << 10 | b << 2;
520 dst = frame->
data[0];
526 for (y = 0; y < avctx->
height; y++) {
527 memcpy(dst + didx, gdv->
frame + sidx, avctx->
width);
528 sidx += avctx->
width;
535 for (y = 0; y < avctx->
height; y++) {
537 memcpy(dst + didx, gdv->
frame + sidx, avctx->
width);
544 if (!gdv->
scale_h || ((y & 1) == 1)) {
#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.
ptrdiff_t const GLvoid * data
int ff_copy_palette(void *dst, const AVPacket *src, void *logctx)
Check whether the side-data of src contains a palette of size AVPALETTE_SIZE; if so, copy it to dst and return 1; else return 0.
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
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static int gdv_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
static void scaleup_rev(uint8_t *dst, const uint8_t *src, int w)
static av_always_inline int bytestream2_get_bytes_left_p(PutByteContext *p)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
const char * name
Name of the codec implementation.
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)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
static double val(void *priv, double ch)
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators...
static int read_bits2(Bits8 *bits, GetByteContext *gb)