50 #if CONFIG_ZLIB_DECODER 68 #if CONFIG_ZLIB_DECODER 78 static unsigned int mszh_decomp(
const unsigned char * srcptr,
int srclen,
unsigned char * destptr,
unsigned int destsize)
80 unsigned char *destptr_bak = destptr;
81 unsigned char *destptr_end = destptr + destsize;
82 const unsigned char *srcptr_end = srcptr + srclen;
83 unsigned mask = *srcptr++;
84 unsigned maskbit = 0x80;
86 while (srcptr < srcptr_end && destptr < destptr_end) {
87 if (!(mask & maskbit)) {
88 memcpy(destptr, srcptr, 4);
92 unsigned ofs = bytestream_get_le16(&srcptr);
93 unsigned cnt = (ofs >> 11) + 1;
95 ofs =
FFMIN(ofs, destptr - destptr_bak);
97 cnt =
FFMIN(cnt, destptr_end - destptr);
103 memset(destptr, 0, cnt);
111 if (destptr_end - destptr < 32 || srcptr_end - srcptr < 32)
break;
112 memcpy(destptr, srcptr, 32);
121 return destptr - destptr_bak;
125 #if CONFIG_ZLIB_DECODER 136 int zret = inflateReset(&c->zstream);
142 c->zstream.avail_in = src_len;
145 zret = inflate(&c->zstream, Z_FINISH);
146 if (zret != Z_OK && zret != Z_STREAM_END) {
150 if (expected != (
unsigned int)c->zstream.total_out) {
152 expected, c->zstream.total_out);
155 return c->zstream.total_out;
169 int buf_size = avpkt->
size;
171 unsigned char *encoded = (
unsigned char *)buf;
172 unsigned int pixel_ptr;
174 unsigned char *outptr;
175 uint8_t *y_out, *u_out, *v_out;
178 unsigned int mszh_dlen;
179 unsigned char yq, y1q, uq, vq;
181 unsigned int mthread_inlen, mthread_outlen;
182 unsigned int len = buf_size;
187 outptr = frame->
data[0];
197 mthread_inlen =
AV_RL32(encoded);
202 mthread_inlen =
FFMIN(mthread_inlen, len - 8);
203 mthread_outlen =
AV_RL32(encoded+4);
206 if (mthread_outlen != mszh_dlen) {
208 mthread_outlen, mszh_dlen);
211 mszh_dlen =
mszh_decomp(encoded + 8 + mthread_inlen, len - 8 - mthread_inlen,
213 if (mthread_outlen != mszh_dlen) {
215 mthread_outlen, mszh_dlen);
250 if (len < ((width * height * bppx2) >> 1))
259 #if CONFIG_ZLIB_DECODER 265 len == width * height * 3) {
273 mthread_inlen =
AV_RL32(encoded);
274 mthread_inlen =
FFMIN(mthread_inlen, len - 8);
275 mthread_outlen =
AV_RL32(encoded+4);
277 ret = zlib_decomp(avctx, encoded + 8, mthread_inlen, 0, mthread_outlen);
278 if (ret < 0)
return ret;
279 ret = zlib_decomp(avctx, encoded + 8 + mthread_inlen, len - 8 - mthread_inlen,
280 mthread_outlen, mthread_outlen);
281 if (ret < 0)
return ret;
283 int ret = zlib_decomp(avctx, encoded, len, 0, c->
decomp_size);
284 if (ret < 0)
return ret;
291 av_log(avctx,
AV_LOG_ERROR,
"BUG! Unknown codec in frame decoder compression switch.\n");
301 for (row = 0; row <
height; row++) {
302 pixel_ptr = row * width * 3;
303 yq = encoded[pixel_ptr++];
304 uqvq =
AV_RL16(encoded+pixel_ptr);
306 for (col = 1; col <
width; col++) {
307 encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
308 uqvq -=
AV_RL16(encoded+pixel_ptr+1);
309 AV_WL16(encoded+pixel_ptr+1, uqvq);
315 for (row = 0; row <
height; row++) {
316 pixel_ptr = row * width * 2;
318 for (col = 0; col < width/4; col++) {
319 encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
320 encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];
321 encoded[pixel_ptr+2] = yq -= encoded[pixel_ptr+2];
322 encoded[pixel_ptr+3] = yq -= encoded[pixel_ptr+3];
323 encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4];
324 encoded[pixel_ptr+5] = uq -= encoded[pixel_ptr+5];
325 encoded[pixel_ptr+6] = vq -= encoded[pixel_ptr+6];
326 encoded[pixel_ptr+7] = vq -= encoded[pixel_ptr+7];
332 for (row = 0; row <
height; row++) {
333 pixel_ptr = row * width / 2 * 3;
335 for (col = 0; col < width/4; col++) {
336 encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
337 encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];
338 encoded[pixel_ptr+2] = yq -= encoded[pixel_ptr+2];
339 encoded[pixel_ptr+3] = yq -= encoded[pixel_ptr+3];
340 encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4];
341 encoded[pixel_ptr+5] = vq -= encoded[pixel_ptr+5];
347 for (row = 0; row <
height; row++) {
348 pixel_ptr = row * width * 2;
350 for (col = 0; col < width/2; col++) {
351 encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
352 encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];
353 encoded[pixel_ptr+2] = uq -= encoded[pixel_ptr+2];
354 encoded[pixel_ptr+3] = vq -= encoded[pixel_ptr+3];
360 for (row = 0; row < height/2; row++) {
361 pixel_ptr = row * width * 3;
362 yq = y1q = uq = vq =0;
363 for (col = 0; col < width/2; col++) {
364 encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
365 encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];
366 encoded[pixel_ptr+2] = y1q -= encoded[pixel_ptr+2];
367 encoded[pixel_ptr+3] = y1q -= encoded[pixel_ptr+3];
368 encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4];
369 encoded[pixel_ptr+5] = vq -= encoded[pixel_ptr+5];
381 y_out = frame->
data[0] + (height - 1) * frame->
linesize[0];
382 u_out = frame->
data[1] + (height - 1) * frame->
linesize[1];
383 v_out = frame->
data[2] + (height - 1) * frame->
linesize[2];
386 for (row = 0; row <
height; row++) {
387 for (col = 0; col <
width; col++) {
388 y_out[col] = *encoded++;
389 u_out[col] = *encoded++ + 128;
390 v_out[col] = *encoded++ + 128;
398 for (row = 0; row <
height; row++) {
399 for (col = 0; col < width - 3; col += 4) {
400 memcpy(y_out + col, encoded, 4);
402 u_out[ col >> 1 ] = *encoded++ + 128;
403 u_out[(col >> 1) + 1] = *encoded++ + 128;
404 v_out[ col >> 1 ] = *encoded++ + 128;
405 v_out[(col >> 1) + 1] = *encoded++ + 128;
413 for (row = height - 1; row >= 0; row--) {
414 pixel_ptr = row * frame->
linesize[0];
415 memcpy(outptr + pixel_ptr, encoded, 3 * width);
416 encoded += 3 *
width;
420 for (row = 0; row <
height; row++) {
421 for (col = 0; col < width - 3; col += 4) {
422 memcpy(y_out + col, encoded, 4);
424 u_out[col >> 2] = *encoded++ + 128;
425 v_out[col >> 2] = *encoded++ + 128;
433 for (row = 0; row <
height; row++) {
434 for (col = 0; col < width - 1; col += 2) {
435 memcpy(y_out + col, encoded, 2);
437 u_out[col >> 1] = *encoded++ + 128;
438 v_out[col >> 1] = *encoded++ + 128;
446 u_out = frame->
data[1] + ((height >> 1) - 1) * frame->
linesize[1];
447 v_out = frame->
data[2] + ((height >> 1) - 1) * frame->
linesize[2];
448 for (row = 0; row < height - 1; row += 2) {
449 for (col = 0; col < width - 1; col += 2) {
450 memcpy(y_out + col, encoded, 2);
452 memcpy(y_out + col - frame->
linesize[0], encoded, 2);
454 u_out[col >> 1] = *encoded++ + 128;
455 v_out[col >> 1] = *encoded++ + 128;
481 unsigned int basesize = avctx->
width * avctx->
height;
484 unsigned int max_decomp_size;
494 av_log(avctx,
AV_LOG_ERROR,
"Codec id and codec type mismatch. This should not happen.\n");
501 max_decomp_size = max_basesize * 3;
507 max_decomp_size = max_basesize * 2;
513 max_decomp_size = max_basesize * 3;
519 max_decomp_size = max_basesize / 2 * 3;
525 max_decomp_size = max_basesize * 2;
531 max_decomp_size = max_basesize / 2 * 3;
557 #if CONFIG_ZLIB_DECODER 603 #if CONFIG_ZLIB_DECODER 606 c->zstream.zalloc = Z_NULL;
607 c->zstream.zfree = Z_NULL;
608 c->zstream.opaque = Z_NULL;
609 zret = inflateInit(&c->zstream);
631 #if CONFIG_ZLIB_DECODER 633 inflateEnd(&c->zstream);
639 #if CONFIG_MSZH_DECODER 653 #if CONFIG_ZLIB_DECODER #define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
memory handling functions
static av_cold int init(AVCodecContext *avctx)
#define COMP_ZLIB_HISPEED
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
struct LclDecContext LclDecContext
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static const uint16_t mask[17]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
static const uint8_t offset[127][2]
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int width
picture width / height.
packed RGB 8:8:8, 24bpp, BGRBGR...
unsigned char * decomp_buf
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
static void close(AVCodecParserContext *s)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
BYTE int const BYTE int int int height
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static av_cold int decode_end(AVCodecContext *avctx)
static unsigned int mszh_decomp(const unsigned char *srcptr, int srclen, unsigned char *destptr, unsigned int destsize)
static av_cold int decode_init(AVCodecContext *avctx)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFilterBuffer 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.Buffer references ownership and permissions
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal api header.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
void av_memcpy_backptr(uint8_t *dst, int back, int cnt)
deliberately overlapping memcpy implementation
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
This structure stores compressed data.