From 41116224c88162e2fa8d6c9e7631a7e31a68f138 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Stadler?= Date: Sun, 16 Oct 2011 20:30:25 +0200 Subject: [PATCH] pngenc: increase arbitrary resolution limits Apparently libpng can technically do up to 2^31-1 rows and columns. However it imposes an (arbitrary) default limit of 1 million (that could theoretically be lifted by using some additional API). Moved array allocation to the heap now. --- ext/libpng/gstpngenc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ext/libpng/gstpngenc.c b/ext/libpng/gstpngenc.c index 8ccb804ce6..578d568db6 100644 --- a/ext/libpng/gstpngenc.c +++ b/ext/libpng/gstpngenc.c @@ -57,8 +57,8 @@ GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS ("image/png, " - "width = (int) [ 16, 4096 ], " - "height = (int) [ 16, 4096 ], " "framerate = " GST_VIDEO_FPS_RANGE) + "width = (int) [ 16, 1000000 ], " + "height = (int) [ 16, 1000000 ], " "framerate = " GST_VIDEO_FPS_RANGE) ); static GstStaticPadTemplate pngenc_sink_template = @@ -174,8 +174,8 @@ gst_pngenc_setcaps (GstPad * pad, GstCaps * caps) goto done; } - if (G_UNLIKELY (pngenc->width < 16 || pngenc->width > 4096 || - pngenc->height < 16 || pngenc->height > 4096)) { + if (G_UNLIKELY (pngenc->width < 16 || pngenc->width > 1000000 || + pngenc->height < 16 || pngenc->height > 1000000)) { ret = FALSE; goto done; } @@ -329,7 +329,7 @@ gst_pngenc_chain (GstPad * pad, GstBuffer * buf) png_set_write_fn (pngenc->png_struct_ptr, pngenc, (png_rw_ptr) user_write_data, user_flush_data); - row_pointers = g_newa (png_byte *, pngenc->height); + row_pointers = g_new (png_byte *, pngenc->height); for (row_index = 0; row_index < pngenc->height; row_index++) { row_pointers[row_index] = GST_BUFFER_DATA (buf) + @@ -345,6 +345,8 @@ gst_pngenc_chain (GstPad * pad, GstBuffer * buf) png_write_image (pngenc->png_struct_ptr, row_pointers); png_write_end (pngenc->png_struct_ptr, NULL); + g_free (row_pointers); + encoded_buf = gst_buffer_create_sub (pngenc->buffer_out, 0, pngenc->written); png_destroy_info_struct (pngenc->png_struct_ptr, &pngenc->png_info_ptr);