diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-04-02 23:30:17 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-04-02 23:30:17 +0000 |
commit | 61146b7b17e16ea3308b0eb9ce031f4004fa6355 (patch) | |
tree | 00651c3dce17251ca2de9c70803894523ff4c365 | |
parent | ac125f1b1949603e7e11fe09a0af73e8418a7463 (diff) | |
download | libextractor-61146b7b17e16ea3308b0eb9ce031f4004fa6355.tar.gz libextractor-61146b7b17e16ea3308b0eb9ce031f4004fa6355.zip |
fixing #4167 (untested)
-rw-r--r-- | src/plugins/thumbnailffmpeg_extractor.c | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/src/plugins/thumbnailffmpeg_extractor.c b/src/plugins/thumbnailffmpeg_extractor.c index 1355586..0619efd 100644 --- a/src/plugins/thumbnailffmpeg_extractor.c +++ b/src/plugins/thumbnailffmpeg_extractor.c | |||
@@ -59,6 +59,20 @@ | |||
59 | #include <ffmpeg/swscale.h> | 59 | #include <ffmpeg/swscale.h> |
60 | #endif | 60 | #endif |
61 | 61 | ||
62 | #if USE_JPEG | ||
63 | #ifdef PIX_FMT_YUVJ420P | ||
64 | #define PIX_OUTPUT_FORMAT PIX_FMT_YUVJ420P | ||
65 | #else | ||
66 | #define PIX_OUTPUT_FORMAT AV_PIX_FMT_YUVJ420P | ||
67 | #endif | ||
68 | #else | ||
69 | #ifdef PIX_FMT_RGB24 | ||
70 | #define PIX_OUTPUT_FORMAT PIX_FMT_RGB24 | ||
71 | #else | ||
72 | #define PIX_OUTPUT_FORMAT AV_PIX_FMT_RGB24 | ||
73 | #endif | ||
74 | #endif | ||
75 | |||
62 | /** | 76 | /** |
63 | * Set to 1 to use JPEG, PNG otherwise | 77 | * Set to 1 to use JPEG, PNG otherwise |
64 | */ | 78 | */ |
@@ -164,7 +178,7 @@ seek_cb (void *opaque, | |||
164 | static size_t | 178 | static size_t |
165 | create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height, | 179 | create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height, |
166 | int src_stride[], | 180 | int src_stride[], |
167 | enum PixelFormat src_pixfmt, | 181 | enum AVPixelFormat src_pixfmt, |
168 | const uint8_t * const src_data[], | 182 | const uint8_t * const src_data[], |
169 | int dst_width, int dst_height, | 183 | int dst_width, int dst_height, |
170 | uint8_t **output_data, | 184 | uint8_t **output_data, |
@@ -208,12 +222,8 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height, | |||
208 | (scaler_ctx = | 222 | (scaler_ctx = |
209 | sws_getContext (src_width, src_height, src_pixfmt, | 223 | sws_getContext (src_width, src_height, src_pixfmt, |
210 | dst_width, dst_height, | 224 | dst_width, dst_height, |
211 | #if USE_JPEG | 225 | PIX_OUTPUT_FORMAT, |
212 | PIX_FMT_YUVJ420P | 226 | SWS_BILINEAR, NULL, NULL, NULL))) |
213 | #else | ||
214 | PIX_FMT_RGB24 | ||
215 | #endif | ||
216 | ,SWS_BILINEAR, NULL, NULL, NULL))) | ||
217 | { | 227 | { |
218 | #if DEBUG | 228 | #if DEBUG |
219 | fprintf (stderr, | 229 | fprintf (stderr, |
@@ -237,13 +247,8 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height, | |||
237 | return 0; | 247 | return 0; |
238 | } | 248 | } |
239 | if (NULL == (dst_buffer = | 249 | if (NULL == (dst_buffer = |
240 | av_malloc (avpicture_get_size ( | 250 | av_malloc (avpicture_get_size (PIX_OUTPUT_FORMAT, |
241 | #if USE_JPEG | 251 | dst_width, dst_height)))) |
242 | PIX_FMT_YUVJ420P | ||
243 | #else | ||
244 | PIX_FMT_RGB24 | ||
245 | #endif | ||
246 | ,dst_width, dst_height)))) | ||
247 | { | 252 | { |
248 | #if DEBUG | 253 | #if DEBUG |
249 | fprintf (stderr, | 254 | fprintf (stderr, |
@@ -258,12 +263,8 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height, | |||
258 | return 0; | 263 | return 0; |
259 | } | 264 | } |
260 | avpicture_fill ((AVPicture *) dst_frame, dst_buffer, | 265 | avpicture_fill ((AVPicture *) dst_frame, dst_buffer, |
261 | #if USE_JPEG | 266 | PIX_OUTPUT_FORMAT, |
262 | PIX_FMT_YUVJ420P | 267 | dst_width, dst_height); |
263 | #else | ||
264 | PIX_FMT_RGB24 | ||
265 | #endif | ||
266 | , dst_width, dst_height); | ||
267 | sws_scale (scaler_ctx, | 268 | sws_scale (scaler_ctx, |
268 | src_data, | 269 | src_data, |
269 | src_stride, | 270 | src_stride, |
@@ -320,9 +321,9 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height, | |||
320 | #endif | 321 | #endif |
321 | encoder_codec_ctx->time_base.num = pCodecCtx->time_base.num; | 322 | encoder_codec_ctx->time_base.num = pCodecCtx->time_base.num; |
322 | encoder_codec_ctx->time_base.den = pCodecCtx->time_base.den; | 323 | encoder_codec_ctx->time_base.den = pCodecCtx->time_base.den; |
323 | encoder_codec_ctx->pix_fmt = PIX_FMT_YUVJ420P; | 324 | encoder_codec_ctx->pix_fmt = PIX_OUTPUT_FORMAT; |
324 | #else | 325 | #else |
325 | encoder_codec_ctx->pix_fmt = PIX_FMT_RGB24; | 326 | encoder_codec_ctx->pix_fmt = PIX_OUTPUT_FORMAT; |
326 | #endif | 327 | #endif |
327 | 328 | ||
328 | opts = NULL; | 329 | opts = NULL; |
@@ -347,8 +348,13 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height, | |||
347 | 348 | ||
348 | 349 | ||
349 | #ifdef USE_JPEG | 350 | #ifdef USE_JPEG |
351 | #if FF_API_MPV_OPT | ||
350 | encoder_codec_ctx->mb_lmin = encoder_codec_ctx->lmin = encoder_codec_ctx->qmin * FF_QP2LAMBDA; | 352 | encoder_codec_ctx->mb_lmin = encoder_codec_ctx->lmin = encoder_codec_ctx->qmin * FF_QP2LAMBDA; |
351 | encoder_codec_ctx->mb_lmax = encoder_codec_ctx->lmax = encoder_codec_ctx->qmax * FF_QP2LAMBDA; | 353 | encoder_codec_ctx->mb_lmax = encoder_codec_ctx->lmax = encoder_codec_ctx->qmax * FF_QP2LAMBDA; |
354 | #else | ||
355 | encoder_codec_ctx->mb_lmin = encoder_codec_ctx->qmin * FF_QP2LAMBDA; | ||
356 | encoder_codec_ctx->mb_lmax = encoder_codec_ctx->qmax * FF_QP2LAMBDA; | ||
357 | #endif | ||
352 | encoder_codec_ctx->flags = CODEC_FLAG_QSCALE; | 358 | encoder_codec_ctx->flags = CODEC_FLAG_QSCALE; |
353 | encoder_codec_ctx->global_quality = encoder_codec_ctx->qmin * FF_QP2LAMBDA; | 359 | encoder_codec_ctx->global_quality = encoder_codec_ctx->qmin * FF_QP2LAMBDA; |
354 | 360 | ||