63 uint8_t *ptr, *last_row;
65 ptr =
s->image_buf +
s->image_linesize *
s->y;
67 last_row =
s->last_row;
69 last_row = ptr -
s->image_linesize;
72 last_row,
s->row_size, 3);
81 zstream->next_in =
s->gb.buffer;
89 while (zstream->avail_in > 0) {
90 ret =
inflate(zstream, Z_PARTIAL_FLUSH);
91 if (ret != Z_OK && ret != Z_STREAM_END) {
95 if (zstream->avail_out == 0) {
96 if (
s->y <
s->cur_h) {
99 zstream->avail_out =
s->crow_size;
100 zstream->next_out =
s->crow_buf;
102 if (ret == Z_STREAM_END && zstream->avail_in > 0) {
104 "%d undecompressed bytes left in buffer\n", zstream->avail_in);
117 int ret, nb_blocks,
offset = 0;
121 if (avpkt->
size == 2)
126 nb_blocks = bytestream2_get_le16(gb);
135 for (
int b = 0;
b < nb_blocks;
b++) {
136 z_stream *
const zstream = &
s->zstream.zstream;
137 int x, y, x2, y2,
w,
h,
left;
138 uint32_t csize,
size;
140 if (inflateReset(zstream) != Z_OK)
145 x = bytestream2_get_le16(gb);
146 y = bytestream2_get_le16(gb);
147 x2 = bytestream2_get_le16(gb);
148 y2 = bytestream2_get_le16(gb);
152 if (
w <= 0 || x < 0 || x >= avctx->
width ||
w + x > avctx->
width ||
156 size = bytestream2_get_le32(gb);
158 if ((nb_blocks == 1) &&
161 (x == 0) && (y == 0))
167 csize = bytestream2_get_be32(gb);
168 if (bytestream2_get_le32(gb) !=
MKTAG(
'I',
'D',
'A',
'T'))
185 s->crow_size =
w * 3 + 1;
186 s->crow_buf =
s->buffer + 15;
187 zstream->avail_out =
s->crow_size;
188 zstream->next_out =
s->crow_buf;
189 s->image_buf =
frame->data[0] + (avctx->
height - y - 1) *
frame->linesize[0] + x * 3;
190 s->image_linesize =-
frame->linesize[0];
199 csize = bytestream2_get_be32(gb);
200 if (bytestream2_get_le32(gb) !=
MKTAG(
'I',
'D',
'A',
'T'))
237 if (!
s->last_picture)
const FFCodec ff_lscr_decoder
static av_cold void close(AVCodecParserContext *s)
Libavcodec external API header.
static int BS_FUNC left(const BSCTX *bc)
Return the number of the bits left in a buffer.
static av_always_inline int bytestream2_get_bytes_left(const 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 FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
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.
#define FF_REGET_BUFFER_FLAG_READONLY
the returned buffer does not need to be writable
int(* init)(AVBSFContext *ctx)
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.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
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.
static int decode_frame_lscr(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
static av_cold int lscr_decode_init(AVCodecContext *avctx)
static int decode_idat(LSCRContext *s, z_stream *zstream, int length)
static av_cold int lscr_decode_close(AVCodecContext *avctx)
static av_cold void lscr_decode_flush(AVCodecContext *avctx)
static void handle_row(LSCRContext *s)
#define MKTAG(a, b, c, d)
Memory handling functions.
@ AVCOL_RANGE_JPEG
Full range content.
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
void ff_png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type, const uint8_t *src, const 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.
This structure describes decoded (raw) audio or video data.
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)
void ff_inflate_end(FFZStream *zstream)
Wrapper around inflateEnd().
int ff_inflate_init(FFZStream *zstream, void *logctx)
Wrapper around inflateInit().