diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2010-04-18 06:03:19 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2010-04-18 06:03:19 +0400 |
commit | dfe2f8dc03267e041102837e92f547fb04881510 (patch) | |
tree | d9582c4667ce5b9e39e2adce40832aa4f44b4fe7 /source/blender/imbuf/intern/anim.c | |
parent | d7e08f2d33207fdf76b1b597ef0de9dec26e3987 (diff) | |
parent | 00e46ef739cf2bfddb8805af056aa59fd3b3c71c (diff) |
Merged changes in the trunk up to revision 28247.
Diffstat (limited to 'source/blender/imbuf/intern/anim.c')
-rw-r--r-- | source/blender/imbuf/intern/anim.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/source/blender/imbuf/intern/anim.c b/source/blender/imbuf/intern/anim.c index 5a5b5ada4a1..a13f426e302 100644 --- a/source/blender/imbuf/intern/anim.c +++ b/source/blender/imbuf/intern/anim.c @@ -94,8 +94,13 @@ #define FFMPEG_CODEC_IS_POINTER 1 #endif +#if (LIBAVCODEC_VERSION_MAJOR >= 52) && (LIBAVCODEC_VERSION_MINOR >= 29) && \ + (LIBSWSCALE_VERSION_MAJOR >= 0) && (LIBSWSCALE_VERSION_MINOR >= 10) +#define FFMPEG_SWSCALE_COLOR_SPACE_SUPPORT #endif +#endif //WITH_FFMPEG + #ifdef WITH_REDCODE #ifdef _WIN32 /* on windows we use the ones in extern instead */ #include "libredcode/format.h" @@ -520,6 +525,13 @@ static int startffmpeg(struct anim * anim) { AVFormatContext *pFormatCtx; AVCodecContext *pCodecCtx; +#ifdef FFMPEG_SWSCALE_COLOR_SPACE_SUPPORT + /* The following for color space determination */ + int srcRange, dstRange, brightness, contrast, saturation; + int *table; + const int *inv_table; +#endif + if (anim == 0) return(-1); do_init_ffmpeg(); @@ -647,6 +659,25 @@ static int startffmpeg(struct anim * anim) { anim->pCodecCtx = NULL; return -1; } + +#ifdef FFMPEG_SWSCALE_COLOR_SPACE_SUPPORT + /* Try do detect if input has 0-255 YCbCR range (JFIF Jpeg MotionJpeg) */ + if (!sws_getColorspaceDetails(anim->img_convert_ctx, (int**)&inv_table, &srcRange, + &table, &dstRange, &brightness, &contrast, &saturation)) { + + srcRange = srcRange || anim->pCodecCtx->color_range == AVCOL_RANGE_JPEG; + inv_table = sws_getCoefficients(anim->pCodecCtx->colorspace); + + if(sws_setColorspaceDetails(anim->img_convert_ctx, (int *)inv_table, srcRange, + table, dstRange, brightness, contrast, saturation)) { + + printf("Warning: Could not set libswscale colorspace details.\n"); + } + } + else { + printf("Warning: Could not set libswscale colorspace details.\n"); + } +#endif return (0); } @@ -782,7 +813,7 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) { unsigned char* top; sws_scale(anim->img_convert_ctx, - input->data, + (const uint8_t * const *)input->data, input->linesize, 0, anim->pCodecCtx->height, @@ -841,7 +872,7 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) { unsigned char* r; sws_scale(anim->img_convert_ctx, - input->data, + (const uint8_t * const *)input->data, input->linesize, 0, anim->pCodecCtx->height, |