Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Ebb <matt@mke3.net>2010-04-08 07:26:49 +0400
committerMatt Ebb <matt@mke3.net>2010-04-08 07:26:49 +0400
commit7693bbf48434f92e6146be7d9549f2555da65adf (patch)
tree6c8349bcdeeb3d65becb2959386360144d2cad4a /source/blender/imbuf/intern
parentb2330d44d249acbdc2a9d01643b08deaadfcbfb1 (diff)
Fix [#21890] YUV->RGB: Color clamping 16-235 in all motion pictures (ffmpeg)
Patch by Troy James Sobotka - this uses options in newer FFMPEG versions to convert the full 0-255 YUV range of imported imagery to RGB, rather than clipping at 16-235. This functionality is not available yet in an official FFMPEG release (current precompiled version in /lib for osx at least is v0.5.1 from 2009) so this won't take effect in that situation, but if you've got a newer ffmpeg on your system it will work.
Diffstat (limited to 'source/blender/imbuf/intern')
-rw-r--r--source/blender/imbuf/intern/anim.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/imbuf/intern/anim.c b/source/blender/imbuf/intern/anim.c
index 5a5b5ada4a1..1a46e79470f 100644
--- a/source/blender/imbuf/intern/anim.c
+++ b/source/blender/imbuf/intern/anim.c
@@ -659,7 +659,25 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) {
int pos_found = 1;
int filter_y = 0;
+#if (LIBAVCODEC_VERSION_MAJOR >= 52) && (LIBAVCODEC_VERSION_MINOR >= 29)
+ /* The following for color space determination */
+ int srcRange, dstRange, brightness, contrast, saturation;
+ int *inv_table, *table;
+
+ if (anim == 0) return (0);
+
+ /* The magic to assert we get full range for YUV to RGB, instead of
+ mapping into 16-235 (only supported by newer ffmpeg versions) */
+ if (!sws_getColorspaceDetails(anim->img_convert_ctx, &inv_table, &srcRange,
+ &table, &dstRange, &brightness, &contrast, &saturation)) {
+ srcRange = srcRange || anim->pCodecCtx->color_range == AVCOL_RANGE_JPEG;
+ inv_table = sws_getCoefficients(anim->pCodecCtx->colorspace);
+ sws_setColorspaceDetails(anim->img_convert_ctx, inv_table, srcRange,
+ table, dstRange, brightness, contrast, saturation);
+ }
+#else
if (anim == 0) return (0);
+#endif
ibuf = IMB_allocImBuf(anim->x, anim->y, 32, IB_rect, 0);