[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25983 - Extractor/src/plugins
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25983 - Extractor/src/plugins |
Date: |
Fri, 1 Feb 2013 19:09:57 +0100 |
Author: LRN
Date: 2013-02-01 19:09:57 +0100 (Fri, 01 Feb 2013)
New Revision: 25983
Modified:
Extractor/src/plugins/thumbnailffmpeg_extractor.c
Log:
Fix ffmpeg thumbnailer
libav* requires input buffers to be padded, otherwise its data accessor
macros will read past the allocated size, resulting in access violation
Modified: Extractor/src/plugins/thumbnailffmpeg_extractor.c
===================================================================
--- Extractor/src/plugins/thumbnailffmpeg_extractor.c 2013-02-01 15:32:21 UTC
(rev 25982)
+++ Extractor/src/plugins/thumbnailffmpeg_extractor.c 2013-02-01 18:09:57 UTC
(rev 25983)
@@ -75,6 +75,16 @@
#define MAX_THUMB_BYTES (100*1024)
/**
+ * Number of bytes to feed to libav in one go.
+ */
+#define BUFFER_SIZE (32 * 1024)
+
+/**
+ * Number of bytes to feed to libav in one go, with padding (padding is
zeroed).
+ */
+#define PADDED_BUFFER_SIZE (BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE)
+
+/**
* Global handle to MAGIC data.
*/
static magic_t magic;
@@ -340,6 +350,7 @@
int frame_finished;
ssize_t iret;
void *data;
+ unsigned char padded_data[PADDED_BUFFER_SIZE];
if (NULL == (codec = avcodec_find_decoder (image_codec_id)))
{
@@ -384,10 +395,12 @@
{
if (0 >= (iret = ec->read (ec->cls,
&data,
- 32 * 1024)))
- break;
+ BUFFER_SIZE)))
+ break;
+ memcpy (padded_data, data, iret);
+ memset (&padded_data[iret], 0, PADDED_BUFFER_SIZE - iret);
av_init_packet (&avpkt);
- avpkt.data = data;
+ avpkt.data = padded_data;
avpkt.size = iret;
avcodec_decode_video2 (codec_ctx, frame, &frame_finished, &avpkt);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25983 - Extractor/src/plugins,
gnunet <=