Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Commit

Permalink
Fixed custom matrix coefficient bug + misc comments
Browse files Browse the repository at this point in the history
The additive part of the matrix was not properly taken into account, causing the coefficients to be canceled at some point.
  • Loading branch information
EleonoreMizo committed May 20, 2015
1 parent 12e1cdc commit a1c3169
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build/unix/configure.ac
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AC_INIT([fmtconv], [r11], [http://forum.doom9.org/showthread.php?t=166504], [fmtconv], [http://forum.doom9.org/showthread.php?t=166504])
AC_INIT([fmtconv], [r14], [http://forum.doom9.org/showthread.php?t=166504], [fmtconv], [http://forum.doom9.org/showthread.php?t=166504])

: ${CXXFLAGS=""}

Expand Down
4 changes: 2 additions & 2 deletions doc/fmtconv.html
Original file line number Diff line number Diff line change
Expand Up @@ -1340,9 +1340,9 @@ <h2><a id="troubleshooting"></a>IV) Troubleshooting</h2>

<h2><a id="changelog"></a>V) Changelog</h2>

<p><b>r14, 20xx.xx.xx</b></p>
<p><b>r14, 2015.05.20</b></p>
<ul>
<li></li>
<li><code>matrix</code>: fixed a bug introducing wrong offsets in custom matrix coefficients, thanks to mawen1250 for the report.</li>
</ul>

<p><b>r13, 2015.05.18</b></p>
Expand Down
17 changes: 8 additions & 9 deletions src/fmtc/Matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@ Matrix::Matrix (const ::VSMap &in, ::VSMap &out, void * /*user_data_ptr*/, ::VSC
{
for (int x = 0; x < NBR_PLANES + 1; ++x)
{
_mat_main [y] [x] = (x == y && x < NBR_PLANES) ? 1 : 0;
_mat_main [y] [x] = (x == y) ? 1 : 0;

if ( x < fmt_src.numPlanes
&& y < fmt_dst.numPlanes)
if ( (x < fmt_src.numPlanes || x == NBR_PLANES)
&& y < fmt_dst.numPlanes)
{
int err = 0;
const int index = y * (fmt_src.numPlanes + 1) + x;
Expand All @@ -257,7 +257,6 @@ Matrix::Matrix (const ::VSMap &in, ::VSMap &out, void * /*user_data_ptr*/, ::VSC
}
}


mat_init_flag = true;
}

Expand Down Expand Up @@ -1268,7 +1267,7 @@ void Matrix::prepare_coef_flt (const ::VSFormat &fmt_dst, const ::VSFormat &fmt_
{ 1, 0, 0, 0 },
{ 0, 1, 0, 0 },
{ 0, 0, 1, 0 },
{ 0, 0, 0, 0 }
{ 0, 0, 0, 1 }
};

::VSFormat fmt_dst2 = fmt_dst;
Expand Down Expand Up @@ -1524,11 +1523,11 @@ Y = R * Kr + G * Kg + B * Kb
U = (B-Y)/(1-Kb) = - R * Kr/(1-Kb) - G * Kg/(1-Kb) + B
V = (R-Y)/(1-Kr) = R - G * Kg/(1-Kr) - B * Kb/(1-Kr)
R, G, B, Y range : [0 ; 1]
U, V range : [-0.5 ; 0.5]
The given equations work for R, G, B in range [0 ; 1] and U and V in range
[-1 ; 1]. Scaling must be applied to match the required range for U and V.
R, G, B, Y range : [0 ; 1]
U, V range : [-0.5 ; 0.5]
*/

void Matrix::make_mat_yuv (Mat4 &m, double kr, double kg, double kb, bool to_rgb_flag)
Expand Down Expand Up @@ -1574,7 +1573,7 @@ R, G, B, Y range : [0 ; 1]
Cg, Co range : [-0.5 ; 0.5]
Note: this implementation is not exactly the same as specified because the
standard specifies specific steps to apply the RGB to YCgCo matrix, leading
standard specifies specific steps to apply the RGB-to-YCgCo matrix, leading
to different roundings.
*/

Expand Down
2 changes: 1 addition & 1 deletion src/fmtc/version.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once

#define fmtc_VERSION "r13"
#define fmtc_VERSION "r14"
#define fmtc_PLUGIN_NAME "fmtconv"
#define fmtc_NAMESPACE "fmtc"

0 comments on commit a1c3169

Please sign in to comment.