aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2009-05-31 08:49:27 +0000
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2009-05-31 08:49:27 +0000
commite786d3cf8023414babcc9f1d3a8fdd5a29c3fd70 (patch)
tree90b62532b1e55252d1f3cf431c58fa8ee182280a
parent4a01b3c714fed6475e70084f2b59e0f061a827c5 (diff)
downloadffmpeg-e786d3cf8023414babcc9f1d3a8fdd5a29c3fd70.tar.gz
lclenc.c: compress directly into output buffer instead of using a pointless
temporary buffer and then using put_bits to copy the data over. Originally committed as revision 19030 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavcodec/lclenc.c18
1 files changed, 2 insertions, 16 deletions
diff --git a/libavcodec/lclenc.c b/libavcodec/lclenc.c
index 762b83e1b4..5385a84e8a 100644
--- a/libavcodec/lclenc.c
+++ b/libavcodec/lclenc.c
@@ -83,8 +83,6 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
int i;
int zret; // Zlib return code
- init_put_bits(&c->pb, buf, buf_size);
-
*p = *pict;
p->pict_type= FF_I_TYPE;
p->key_frame= 1;
@@ -99,8 +97,8 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
av_log(avctx, AV_LOG_ERROR, "Deflate reset error: %d\n", zret);
return -1;
}
- c->zstream.next_out = c->comp_buf;
- c->zstream.avail_out = c->max_comp_size;
+ c->zstream.next_out = buf;
+ c->zstream.avail_out = buf_size;
for(i = avctx->height - 1; i >= 0; i--) {
c->zstream.next_in = p->data[0]+p->linesize[0]*i;
@@ -117,10 +115,6 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
return -1;
}
- for (i = 0; i < c->zstream.total_out; i++)
- put_bits(&c->pb, 8, c->comp_buf[i]);
- flush_put_bits(&c->pb);
-
return c->zstream.total_out;
}
@@ -175,14 +169,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
return 1;
}
- /* Conservative upper bound taken from zlib v1.2.1 source */
- c->max_comp_size = c->decomp_size + ((c->decomp_size + 7) >> 3) +
- ((c->decomp_size + 63) >> 6) + 11;
- if ((c->comp_buf = av_malloc(c->max_comp_size)) == NULL) {
- av_log(avctx, AV_LOG_ERROR, "Can't allocate compression buffer.\n");
- return 1;
- }
-
return 0;
}