Mercurial > libavcodec.hg
comparison zmbv.c @ 5349:6a4286208743 libavcodec
remove useless #ifdef CONFIG_ZLIB from zmbv decoder
author | mru |
---|---|
date | Mon, 16 Jul 2007 21:05:16 +0000 |
parents | 4372aeade5dc |
children | 9c5eed7cd0ae |
comparison
equal
deleted
inserted
replaced
5348:8627a229d2d2 | 5349:6a4286208743 |
---|---|
27 #include <stdio.h> | 27 #include <stdio.h> |
28 #include <stdlib.h> | 28 #include <stdlib.h> |
29 | 29 |
30 #include "avcodec.h" | 30 #include "avcodec.h" |
31 | 31 |
32 #ifdef CONFIG_ZLIB | |
33 #include <zlib.h> | 32 #include <zlib.h> |
34 #endif | |
35 | 33 |
36 #define ZMBV_KEYFRAME 1 | 34 #define ZMBV_KEYFRAME 1 |
37 #define ZMBV_DELTAPAL 2 | 35 #define ZMBV_DELTAPAL 2 |
38 | 36 |
39 enum ZmbvFormat { | 37 enum ZmbvFormat { |
64 int fmt; | 62 int fmt; |
65 int comp; | 63 int comp; |
66 int flags; | 64 int flags; |
67 int bw, bh, bx, by; | 65 int bw, bh, bx, by; |
68 int decomp_len; | 66 int decomp_len; |
69 #ifdef CONFIG_ZLIB | |
70 z_stream zstream; | 67 z_stream zstream; |
71 #endif | |
72 int (*decode_intra)(struct ZmbvContext *c); | 68 int (*decode_intra)(struct ZmbvContext *c); |
73 int (*decode_xor)(struct ZmbvContext *c); | 69 int (*decode_xor)(struct ZmbvContext *c); |
74 } ZmbvContext; | 70 } ZmbvContext; |
75 | 71 |
76 /** | 72 /** |
397 | 393 |
398 static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) | 394 static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) |
399 { | 395 { |
400 ZmbvContext * const c = avctx->priv_data; | 396 ZmbvContext * const c = avctx->priv_data; |
401 uint8_t *outptr; | 397 uint8_t *outptr; |
402 #ifdef CONFIG_ZLIB | |
403 int zret = Z_OK; // Zlib return code | 398 int zret = Z_OK; // Zlib return code |
404 #endif | |
405 int len = buf_size; | 399 int len = buf_size; |
406 int hi_ver, lo_ver; | 400 int hi_ver, lo_ver; |
407 | 401 |
408 if(c->pic.data[0]) | 402 if(c->pic.data[0]) |
409 avctx->release_buffer(avctx, &c->pic); | 403 avctx->release_buffer(avctx, &c->pic); |
471 c->decode_intra = NULL; | 465 c->decode_intra = NULL; |
472 c->decode_xor = NULL; | 466 c->decode_xor = NULL; |
473 av_log(avctx, AV_LOG_ERROR, "Unsupported (for now) format %i\n", c->fmt); | 467 av_log(avctx, AV_LOG_ERROR, "Unsupported (for now) format %i\n", c->fmt); |
474 return -1; | 468 return -1; |
475 } | 469 } |
476 #ifdef CONFIG_ZLIB | 470 |
477 zret = inflateReset(&c->zstream); | 471 zret = inflateReset(&c->zstream); |
478 if (zret != Z_OK) { | 472 if (zret != Z_OK) { |
479 av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret); | 473 av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret); |
480 return -1; | 474 return -1; |
481 } | 475 } |
482 #else | 476 |
483 av_log(avctx, AV_LOG_ERROR, "BUG! Zlib support not compiled in frame decoder.\n"); | |
484 return -1; | |
485 #endif /* CONFIG_ZLIB */ | |
486 c->cur = av_realloc(c->cur, avctx->width * avctx->height * (c->bpp / 8)); | 477 c->cur = av_realloc(c->cur, avctx->width * avctx->height * (c->bpp / 8)); |
487 c->prev = av_realloc(c->prev, avctx->width * avctx->height * (c->bpp / 8)); | 478 c->prev = av_realloc(c->prev, avctx->width * avctx->height * (c->bpp / 8)); |
488 c->bx = (c->width + c->bw - 1) / c->bw; | 479 c->bx = (c->width + c->bw - 1) / c->bw; |
489 c->by = (c->height+ c->bh - 1) / c->bh; | 480 c->by = (c->height+ c->bh - 1) / c->bh; |
490 } | 481 } |
496 | 487 |
497 if(c->comp == 0) { //Uncompressed data | 488 if(c->comp == 0) { //Uncompressed data |
498 memcpy(c->decomp_buf, buf, len); | 489 memcpy(c->decomp_buf, buf, len); |
499 c->decomp_size = 1; | 490 c->decomp_size = 1; |
500 } else { // ZLIB-compressed data | 491 } else { // ZLIB-compressed data |
501 #ifdef CONFIG_ZLIB | |
502 c->zstream.total_in = c->zstream.total_out = 0; | 492 c->zstream.total_in = c->zstream.total_out = 0; |
503 c->zstream.next_in = buf; | 493 c->zstream.next_in = buf; |
504 c->zstream.avail_in = len; | 494 c->zstream.avail_in = len; |
505 c->zstream.next_out = c->decomp_buf; | 495 c->zstream.next_out = c->decomp_buf; |
506 c->zstream.avail_out = c->decomp_size; | 496 c->zstream.avail_out = c->decomp_size; |
507 inflate(&c->zstream, Z_FINISH); | 497 inflate(&c->zstream, Z_FINISH); |
508 c->decomp_len = c->zstream.total_out; | 498 c->decomp_len = c->zstream.total_out; |
509 #else | |
510 av_log(avctx, AV_LOG_ERROR, "BUG! Zlib support not compiled in frame decoder.\n"); | |
511 return -1; | |
512 #endif | |
513 } | 499 } |
514 if(c->flags & ZMBV_KEYFRAME) { | 500 if(c->flags & ZMBV_KEYFRAME) { |
515 c->pic.key_frame = 1; | 501 c->pic.key_frame = 1; |
516 c->pic.pict_type = FF_I_TYPE; | 502 c->pic.pict_type = FF_I_TYPE; |
517 c->decode_intra(c); | 503 c->decode_intra(c); |
616 if (avcodec_check_dimensions(avctx, avctx->width, avctx->height) < 0) { | 602 if (avcodec_check_dimensions(avctx, avctx->width, avctx->height) < 0) { |
617 return 1; | 603 return 1; |
618 } | 604 } |
619 c->bpp = avctx->bits_per_sample; | 605 c->bpp = avctx->bits_per_sample; |
620 | 606 |
621 #ifdef CONFIG_ZLIB | |
622 // Needed if zlib unused or init aborted before inflateInit | 607 // Needed if zlib unused or init aborted before inflateInit |
623 memset(&(c->zstream), 0, sizeof(z_stream)); | 608 memset(&(c->zstream), 0, sizeof(z_stream)); |
624 #else | 609 |
625 av_log(avctx, AV_LOG_ERROR, "Zlib support not compiled.\n"); | |
626 return 1; | |
627 #endif | |
628 avctx->pix_fmt = PIX_FMT_RGB24; | 610 avctx->pix_fmt = PIX_FMT_RGB24; |
629 c->decomp_size = (avctx->width + 255) * 4 * (avctx->height + 64); | 611 c->decomp_size = (avctx->width + 255) * 4 * (avctx->height + 64); |
630 | 612 |
631 /* Allocate decompression buffer */ | 613 /* Allocate decompression buffer */ |
632 if (c->decomp_size) { | 614 if (c->decomp_size) { |
634 av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n"); | 616 av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n"); |
635 return 1; | 617 return 1; |
636 } | 618 } |
637 } | 619 } |
638 | 620 |
639 #ifdef CONFIG_ZLIB | |
640 c->zstream.zalloc = Z_NULL; | 621 c->zstream.zalloc = Z_NULL; |
641 c->zstream.zfree = Z_NULL; | 622 c->zstream.zfree = Z_NULL; |
642 c->zstream.opaque = Z_NULL; | 623 c->zstream.opaque = Z_NULL; |
643 zret = inflateInit(&(c->zstream)); | 624 zret = inflateInit(&(c->zstream)); |
644 if (zret != Z_OK) { | 625 if (zret != Z_OK) { |
645 av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret); | 626 av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret); |
646 return 1; | 627 return 1; |
647 } | 628 } |
648 #endif | |
649 | 629 |
650 return 0; | 630 return 0; |
651 } | 631 } |
652 | 632 |
653 | 633 |
663 | 643 |
664 av_freep(&c->decomp_buf); | 644 av_freep(&c->decomp_buf); |
665 | 645 |
666 if (c->pic.data[0]) | 646 if (c->pic.data[0]) |
667 avctx->release_buffer(avctx, &c->pic); | 647 avctx->release_buffer(avctx, &c->pic); |
668 #ifdef CONFIG_ZLIB | |
669 inflateEnd(&(c->zstream)); | 648 inflateEnd(&(c->zstream)); |
670 #endif | |
671 av_freep(&c->cur); | 649 av_freep(&c->cur); |
672 av_freep(&c->prev); | 650 av_freep(&c->prev); |
673 | 651 |
674 return 0; | 652 return 0; |
675 } | 653 } |