diff options
author | Heikki Lindholm <holin@iki.fi> | 2009-12-25 19:57:42 +0000 |
---|---|---|
committer | Heikki Lindholm <holin@iki.fi> | 2009-12-25 19:57:42 +0000 |
commit | 1ce874e4b3a9cc9e364b1f806f545444e51129e3 (patch) | |
tree | a69ae7cd116a4094061255bda09f1248dd4c169b /src/plugins/thumbnailffmpeg_extractor.c | |
parent | acd2b65e96603a6334e161c11d1635fd4620517b (diff) | |
download | libextractor-1ce874e4b3a9cc9e364b1f806f545444e51129e3.tar.gz libextractor-1ce874e4b3a9cc9e364b1f806f545444e51129e3.zip |
leak, cosmetics
Diffstat (limited to 'src/plugins/thumbnailffmpeg_extractor.c')
-rw-r--r-- | src/plugins/thumbnailffmpeg_extractor.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/plugins/thumbnailffmpeg_extractor.c b/src/plugins/thumbnailffmpeg_extractor.c index 3313c0d..c3b00cb 100644 --- a/src/plugins/thumbnailffmpeg_extractor.c +++ b/src/plugins/thumbnailffmpeg_extractor.c | |||
@@ -42,7 +42,7 @@ | |||
42 | #include <libavcodec/avcodec.h> | 42 | #include <libavcodec/avcodec.h> |
43 | #include <libswscale/swscale.h> | 43 | #include <libswscale/swscale.h> |
44 | 44 | ||
45 | #include "mime_extractor.c" | 45 | #include "mime_extractor.c" /* TODO: do this cleaner */ |
46 | 46 | ||
47 | #define DEBUG 0 | 47 | #define DEBUG 0 |
48 | 48 | ||
@@ -62,11 +62,11 @@ void __attribute__ ((constructor)) ffmpeg_lib_init (void) | |||
62 | av_register_all (); | 62 | av_register_all (); |
63 | } | 63 | } |
64 | 64 | ||
65 | #define THUMBSIZE 128 /* max dimension in pixels */ | 65 | #define MAX_THUMB_DIMENSION 128 /* max dimension in pixels */ |
66 | #define MAX_THUMB_SIZE (100*1024) /* in bytes */ | 66 | #define MAX_THUMB_BYTES (100*1024) |
67 | 67 | ||
68 | /* | 68 | /* |
69 | * Rescale and encode a png thumbnail | 69 | * Rescale and encode a PNG thumbnail |
70 | * on success, fills in output_data and returns the number of bytes used | 70 | * on success, fills in output_data and returns the number of bytes used |
71 | */ | 71 | */ |
72 | static size_t create_thumbnail( | 72 | static size_t create_thumbnail( |
@@ -255,13 +255,13 @@ static void calculate_thumbnail_dimensions(int src_width, | |||
255 | } | 255 | } |
256 | if ((src_width * src_sar_num) / src_sar_den > src_height) | 256 | if ((src_width * src_sar_num) / src_sar_den > src_height) |
257 | { | 257 | { |
258 | *dst_width = THUMBSIZE; | 258 | *dst_width = MAX_THUMB_DIMENSION; |
259 | *dst_height = (*dst_width * src_height) / | 259 | *dst_height = (*dst_width * src_height) / |
260 | ((src_width * src_sar_num) / src_sar_den); | 260 | ((src_width * src_sar_num) / src_sar_den); |
261 | } | 261 | } |
262 | else | 262 | else |
263 | { | 263 | { |
264 | *dst_height = THUMBSIZE; | 264 | *dst_height = MAX_THUMB_DIMENSION; |
265 | *dst_width = (*dst_height * | 265 | *dst_width = (*dst_height * |
266 | ((src_width * src_sar_num) / src_sar_den)) / | 266 | ((src_width * src_sar_num) / src_sar_den)) / |
267 | src_height; | 267 | src_height; |
@@ -360,7 +360,7 @@ extract_image (enum CodecID image_codec_id, | |||
360 | err = create_thumbnail (codec_ctx->width, codec_ctx->height, | 360 | err = create_thumbnail (codec_ctx->width, codec_ctx->height, |
361 | frame->linesize, codec_ctx->pix_fmt, frame->data, | 361 | frame->linesize, codec_ctx->pix_fmt, frame->data, |
362 | thumb_width, thumb_height, | 362 | thumb_width, thumb_height, |
363 | &encoded_thumbnail, MAX_THUMB_SIZE); | 363 | &encoded_thumbnail, MAX_THUMB_BYTES); |
364 | 364 | ||
365 | if (err > 0) | 365 | if (err > 0) |
366 | { | 366 | { |
@@ -376,6 +376,7 @@ extract_image (enum CodecID image_codec_id, | |||
376 | 376 | ||
377 | av_free (frame); | 377 | av_free (frame); |
378 | avcodec_close (codec_ctx); | 378 | avcodec_close (codec_ctx); |
379 | av_free (codec_ctx); | ||
379 | return ret; | 380 | return ret; |
380 | } | 381 | } |
381 | 382 | ||
@@ -564,7 +565,7 @@ RETRY_PROBE: | |||
564 | err = create_thumbnail (codec_ctx->width, codec_ctx->height, | 565 | err = create_thumbnail (codec_ctx->width, codec_ctx->height, |
565 | frame->linesize, codec_ctx->pix_fmt, frame->data, | 566 | frame->linesize, codec_ctx->pix_fmt, frame->data, |
566 | thumb_width, thumb_height, | 567 | thumb_width, thumb_height, |
567 | &encoded_thumbnail, MAX_THUMB_SIZE); | 568 | &encoded_thumbnail, MAX_THUMB_BYTES); |
568 | 569 | ||
569 | if (err > 0) | 570 | if (err > 0) |
570 | { | 571 | { |