comparison lcl.c @ 2250:902caf560c43 libavcodec

Zlib encoder: fix image orientation (was flipped), 100l in deflate error check, put right codec type in extradata
author rtognimp
date Thu, 23 Sep 2004 22:20:17 +0000
parents e4e1b4f31db6
children 582e635cfa08
comparison
equal deleted inserted replaced
2249:2b1a5e1fd449 2250:902caf560c43
565 zret = deflateReset(&(c->zstream)); 565 zret = deflateReset(&(c->zstream));
566 if (zret != Z_OK) { 566 if (zret != Z_OK) {
567 av_log(avctx, AV_LOG_ERROR, "Deflate reset error: %d\n", zret); 567 av_log(avctx, AV_LOG_ERROR, "Deflate reset error: %d\n", zret);
568 return -1; 568 return -1;
569 } 569 }
570 c->zstream.next_in = p->data[0];
571 c->zstream.avail_in = c->decomp_size;
572 c->zstream.next_out = c->comp_buf; 570 c->zstream.next_out = c->comp_buf;
573 c->zstream.avail_out = c->max_comp_size; 571 c->zstream.avail_out = c->max_comp_size;
574 572
573 for(i = avctx->height - 1; i >= 0; i--) {
574 c->zstream.next_in = p->data[0]+p->linesize[0]*i;
575 c->zstream.avail_in = avctx->width*3;
576 zret = deflate(&(c->zstream), Z_NO_FLUSH);
577 if (zret != Z_OK) {
578 av_log(avctx, AV_LOG_ERROR, "Deflate error: %d\n", zret);
579 return -1;
580 }
581 }
575 zret = deflate(&(c->zstream), Z_FINISH); 582 zret = deflate(&(c->zstream), Z_FINISH);
576 if ((zret != Z_OK) && (zret != Z_STREAM_END)) { 583 if (zret != Z_STREAM_END) {
577 av_log(avctx, AV_LOG_ERROR, "Deflate error: %d\n", zret); 584 av_log(avctx, AV_LOG_ERROR, "Deflate error: %d\n", zret);
578 return -1; 585 return -1;
579 } 586 }
580 587
581 for (i = 0; i < c->zstream.total_out; i++) 588 for (i = 0; i < c->zstream.total_out; i++)
783 ((uint8_t*)avctx->extradata)[2]= 0; 790 ((uint8_t*)avctx->extradata)[2]= 0;
784 ((uint8_t*)avctx->extradata)[3]= 0; 791 ((uint8_t*)avctx->extradata)[3]= 0;
785 ((uint8_t*)avctx->extradata)[4]= c->imgtype; 792 ((uint8_t*)avctx->extradata)[4]= c->imgtype;
786 ((uint8_t*)avctx->extradata)[5]= c->compression; 793 ((uint8_t*)avctx->extradata)[5]= c->compression;
787 ((uint8_t*)avctx->extradata)[6]= c->flags; 794 ((uint8_t*)avctx->extradata)[6]= c->flags;
788 ((uint8_t*)avctx->extradata)[7]= 0; 795 ((uint8_t*)avctx->extradata)[7]= CODEC_ZLIB;
789 c->avctx->extradata_size= 8; 796 c->avctx->extradata_size= 8;
790 797
791 c->zstream.zalloc = Z_NULL; 798 c->zstream.zalloc = Z_NULL;
792 c->zstream.zfree = Z_NULL; 799 c->zstream.zfree = Z_NULL;
793 c->zstream.opaque = Z_NULL; 800 c->zstream.opaque = Z_NULL;