diff options
author | Torsten Jager <t.jager@gmx.de> | 2012-06-12 10:24:25 +0300 |
---|---|---|
committer | Torsten Jager <t.jager@gmx.de> | 2012-06-12 10:24:25 +0300 |
commit | ac96af99481bce26d747f0e642d62c7cd9d3e70d (patch) | |
tree | c82e62ab664332c3fbdf95482e2de927e147aaf4 /src | |
parent | 41118625efec6e4eca3221334b499a1a7f73fdc9 (diff) | |
download | xine-lib-ac96af99481bce26d747f0e642d62c7cd9d3e70d.tar.gz xine-lib-ac96af99481bce26d747f0e642d62c7cd9d3e70d.tar.bz2 |
Optimized memory allocation (image size is known)
Diffstat (limited to 'src')
-rw-r--r-- | src/video_dec/yuv.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/video_dec/yuv.c b/src/video_dec/yuv.c index b9f4b43f4..477365641 100644 --- a/src/video_dec/yuv.c +++ b/src/video_dec/yuv.c @@ -111,8 +111,7 @@ static void yuv_decode_data (video_decoder_t *this_gen, free (this->buf); this->buf = NULL; - this->bufsize = VIDEOBUFSIZE; - this->buf = malloc(this->bufsize); + this->bufsize = this->width = this->height; this->size = 0; this->decoder_ok = 1; @@ -122,18 +121,21 @@ static void yuv_decode_data (video_decoder_t *this_gen, case BUF_VIDEO_YUY2: this->width = (this->width + 1) & ~1; + this->bufsize = this->width * this->height * 2; _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "Raw YUY2"); break; case BUF_VIDEO_YV12: this->width = (this->width + 1) & ~1; this->height = (this->height + 1) & ~1; + this->bufsize = this->width * this->height * 3 / 2; _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "Raw YV12"); break; case BUF_VIDEO_YVU9: this->width = (this->width + 3) & ~3; this->height = (this->height + 3) & ~3; + this->bufsize = this->width * this->height * 9 / 8; _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "Raw YVU9"); break; @@ -144,11 +146,14 @@ static void yuv_decode_data (video_decoder_t *this_gen, case BUF_VIDEO_I420: this->width = (this->width + 1) & ~1; this->height = (this->height + 1) & ~1; + this->bufsize = this->width * this->height * 3 / 2; _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "Raw I420"); break; } + this->buf = malloc(this->bufsize); + _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_WIDTH, this->width); _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HEIGHT, this->height); _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_RATIO, this->ratio*10000); |