On 2016-03-28 20:35:49 +0200, Vittorio Giovara wrote: > On Mon, Mar 28, 2016 at 5:36 PM, Janne Grunau <[email protected]> wrote: > > On 2016-03-28 13:24:59 +0200, Vittorio Giovara wrote: > >> Signed-off-by: Vittorio Giovara <[email protected]> > >> --- > >> libavcodec/screenpresso.c | 45 > >> ++++++++++++++++++++++++++++++--------------- > >> 1 file changed, 30 insertions(+), 15 deletions(-) > >> > >> diff --git a/libavcodec/screenpresso.c b/libavcodec/screenpresso.c > >> index 88a927b..af678cd 100644 > >> --- a/libavcodec/screenpresso.c > >> +++ b/libavcodec/screenpresso.c > >> @@ -30,7 +30,7 @@ > >> * rebuilt frame (not the reference), and since there is no coordinate > >> system > >> * they contain exactly as many pixel as the keyframe. > >> * > >> - * Supports: BGR24 > >> + * Supports: BGRA, BGR24, RGB555 > >> */ > >> > >> #include <stdint.h> > >> @@ -79,10 +79,8 @@ static av_cold int screenpresso_init(AVCodecContext > >> *avctx) > >> if (!ctx->current) > >> return AVERROR(ENOMEM); > >> > >> - avctx->pix_fmt = AV_PIX_FMT_BGR24; > >> - > >> - /* Allocate maximum size possible, a full frame */ > >> - ctx->inflated_size = avctx->width * avctx->height * 3; > >> + /* Allocate maximum size possible, a full RGBA frame */ > >> + ctx->inflated_size = avctx->width * avctx->height * 4; > >> ctx->inflated_buf = av_malloc(ctx->inflated_size); > >> if (!ctx->inflated_buf) > >> return AVERROR(ENOMEM); > >> @@ -108,7 +106,7 @@ static int screenpresso_decode_frame(AVCodecContext > >> *avctx, void *data, > >> ScreenpressoContext *ctx = avctx->priv_data; > >> AVFrame *frame = data; > >> uLongf length = ctx->inflated_size; > > > > length should be component_size * avctx->width * avctx->height > > Yes, but since we don't know what size is the component until we start > decoding, I simplified a bit the code and initialized the buffer to > the max size available ( ctx->inflated_size = avctx->width * > avctx->height * 4) in _init. > I'd use the container value but I'm not sure it's trustworthy.
Allocating the buffer to the maximal possible size is fine. I misinterpreted zlib documentation that it required the exact size of uncompressed data in the destLen parameter. So ignore this comment and the same comment for rscc.. Janne _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
