62 ptr =
s->image_buf +
s->image_linesize *
s->y;
64 last_row =
s->last_row;
66 last_row = ptr -
s->image_linesize;
69 last_row,
s->row_size, 3);
78 s->zstream.next_in =
s->gb.buffer;
86 while (
s->zstream.avail_in > 0) {
87 ret =
inflate(&
s->zstream, Z_PARTIAL_FLUSH);
88 if (ret != Z_OK && ret != Z_STREAM_END) {
92 if (
s->zstream.avail_out == 0) {
93 if (
s->y <
s->cur_h) {
96 s->zstream.avail_out =
s->crow_size;
97 s->zstream.next_out =
s->crow_buf;
99 if (ret == Z_STREAM_END &&
s->zstream.avail_in > 0) {
101 "%d undecompressed bytes left in buffer\n",
s->zstream.avail_in);
109 void *
data,
int *got_frame,
115 int ret, nb_blocks,
offset = 0;
119 if (avpkt->
size == 2)
124 nb_blocks = bytestream2_get_le16(gb);
133 for (
int b = 0;
b < nb_blocks;
b++) {
134 int x, y, x2, y2,
w,
h, left;
135 uint32_t csize,
size;
139 s->zstream.opaque =
NULL;
141 if ((ret = inflateInit(&
s->zstream)) != Z_OK) {
149 x = bytestream2_get_le16(gb);
150 y = bytestream2_get_le16(gb);
151 x2 = bytestream2_get_le16(gb);
152 y2 = bytestream2_get_le16(gb);
156 if (
w <= 0 || x < 0 || x >= avctx->
width ||
w + x > avctx->
width ||
162 size = bytestream2_get_le32(gb);
167 (x == 0) && (y == 0);
170 csize = bytestream2_get_be32(gb);
171 if (bytestream2_get_le32(gb) !=
MKTAG(
'I',
'D',
'A',
'T')) {
194 s->crow_size =
w * 3 + 1;
195 s->crow_buf =
s->buffer + 15;
196 s->zstream.avail_out =
s->crow_size;
197 s->zstream.next_out =
s->crow_buf;
208 csize = bytestream2_get_be32(gb);
209 if (bytestream2_get_le32(gb) !=
MKTAG(
'I',
'D',
'A',
'T')) {
216 inflateEnd(&
s->zstream);
226 inflateEnd(&
s->zstream);
253 if (!
s->last_picture)
static void flush(AVCodecContext *avctx)
Libavcodec external API header.
static av_cold int init(AVCodecContext *avctx)
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
#define MKTAG(a, b, c, d)
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Identical in function to ff_get_buffer(), except it reuses the existing buffer if available.
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
reference-counted frame API
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end w...
#define AVERROR_EXTERNAL
Generic error in an external library.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PICTURE_TYPE_P
Predicted.
#define FF_REGET_BUFFER_FLAG_READONLY
the returned buffer does not need to be writable
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static int lscr_decode_close(AVCodecContext *avctx)
static void lscr_decode_flush(AVCodecContext *avctx)
static int decode_frame_lscr(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static int decode_idat(LSCRContext *s, int length)
static void handle_row(LSCRContext *s)
static int lscr_decode_init(AVCodecContext *avctx)
@ AVCOL_RANGE_JPEG
Full range content.
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
void * ff_png_zalloc(void *opaque, unsigned int items, unsigned int size)
void ff_png_zfree(void *opaque, void *ptr)
void ff_png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type, uint8_t *src, uint8_t *last, int size, int bpp)
av_cold void ff_pngdsp_init(PNGDSPContext *dsp)
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
const char * name
Name of the codec implementation.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int key_frame
1 -> keyframe, 0-> not
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
enum AVPictureType pict_type
Picture type of the frame.
This structure stores compressed data.
unsigned int last_row_size
static void inflate(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord, int maxc)
static const uint8_t offset[127][2]