Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

Domains: forum.doom9.org / forum.doom9.net / forum.doom9.se

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 18th March 2011, 06:52   #1  |  Link
sub24ox7
Audiophile
 
sub24ox7's Avatar
 
Join Date: May 2009
Location: United States of America
Posts: 58
Need xyz > RGB conversion for MXFsource avisynth plugin

The only code left undone on this plugin https://code.google.com/p/dcinematools/
Is for xyz to RGB conversion code. Right now it uses openjpeg library if you don't don't own the mainconcept mjpeg2000 dll and that decoder clips blacks with its xyz to rgb conversion. The openjpeg implementation needs the xzy to RGB conversion code. I am sure for some of you this would be trivial to do since it mostly just involves some matrix math and many of you work with avisynth often and this area. This would be a valuable tool if it did this as there is no alternative. I would be VERY appreciative of any of you would be able to help out
__________________
never give up or at least die trying

Last edited by sub24ox7; 18th March 2011 at 09:47.
sub24ox7 is offline   Reply With Quote
Old 18th March 2011, 08:18   #2  |  Link
Snowknight26
Registered User
 
Join Date: Aug 2007
Posts: 1,432
Couldn't you use ffmpeg to encode it to RGB? It should be handle MXF files.
Snowknight26 is offline   Reply With Quote
Old 18th March 2011, 09:12   #3  |  Link
sub24ox7
Audiophile
 
sub24ox7's Avatar
 
Join Date: May 2009
Location: United States of America
Posts: 58
Unfortunately there is no support for xyz colorspace in ffmpeg :/ there is literally no option unless someone can work this out
__________________
never give up or at least die trying

Last edited by sub24ox7; 18th March 2011 at 09:47.
sub24ox7 is offline   Reply With Quote
Old 18th March 2011, 10:49   #4  |  Link
Yellow_
Registered User
 
Join Date: Sep 2009
Posts: 378
yCMS ?

If there was a Openjpeg plugin for Avisynth it would be easy to import video and use yCMS to do YCbCr to xyz to RGB 2.6 gamma in jpeg2000 DCi profiles, using full range levels in video source, where as ffmpeg does a 16 - 235 luma 240 chroma but can do full chroma with necessary swscale flags added.

Last edited by Yellow_; 18th March 2011 at 10:57.
Yellow_ is offline   Reply With Quote
Old 18th March 2011, 19:00   #5  |  Link
sub24ox7
Audiophile
 
sub24ox7's Avatar
 
Join Date: May 2009
Location: United States of America
Posts: 58
well right now MXFsource can use openjpeg library if mainconcept isn't present and It fakes the xzy as RGB I believe and that resulting picture isn't clipped its just that teh color is wrong faded looking. Avisynth doesn't support xzy natively:/ will try using ycms matrix on it. If you check in again on this thread post an example yCMS configuration would be great.

ALSO:

I have the correct matrix and Gamma right here to use with the code if someone is ever willing to take on the xyz to (Linear rgb) conversion within MXFSource.cpp

Code:
- <color_transformation>
- <transformation name="X'Y'Z' -> Linear RGB" comment="comment line">
  <source color_space="X'Y'Z'" primaries="XYZ" white_point="" gamma="0.3846154" white_projector_luminance="48.0" normalizing_constant="52.37" normalizing_bitrate="12" /> 
  <destination color_space="Linear RGB" primaries="RGB" white_point="" gamma="2.2" /> 
- <matrix>
  <row>3.24096989631653;-1.5373831987381;-0.498610764741898</row> 
  <row>-0.96924364566803;1.87596750259399;0.0415550582110882</row> 
  <row>0.0556300804018974;-0.203976958990097;1.05697154998779</row> 
  </matrix>
  </transformation>
  </color_transformation>
^these parameters are 100% correct
__________________
never give up or at least die trying

Last edited by sub24ox7; 18th March 2011 at 21:10.
sub24ox7 is offline   Reply With Quote
Old 19th March 2011, 22:16   #6  |  Link
sub24ox7
Audiophile
 
sub24ox7's Avatar
 
Join Date: May 2009
Location: United States of America
Posts: 58
Well I must admit at being surprised at the lack of response here :/ but I know for some of you here coding the color conversion would be trivial. This patch could be used for ffmpeg as well as it lacks the color conversion for mjpeg2000 output as well.
__________________
never give up or at least die trying
sub24ox7 is offline   Reply With Quote
Old 23rd March 2011, 10:32   #7  |  Link
sub24ox7
Audiophile
 
sub24ox7's Avatar
 
Join Date: May 2009
Location: United States of America
Posts: 58
okay code is finished with the help of a friend its perfect code could be used for ffmpeg output of mjpeg2000.
__________________
never give up or at least die trying
sub24ox7 is offline   Reply With Quote
Old 25th March 2011, 02:51   #8  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
this sounds really exciting actually.

i only just spotted the thread now, but unfortunately can't offer much to it... xyz is a freaky colour space and is not as useful in real life as it is on paper. projectors continue to be mis-calibrated the world over, and even a properly set up projector will change quite quickly as it's bulb(s) die and get dimmer.

adding to this that all film finishing is done in RGB...
__________________
sucking the life out of your videos since 2004
Mug Funky is offline   Reply With Quote
Old 13th May 2011, 03:36   #9  |  Link
sub24ox7
Audiophile
 
sub24ox7's Avatar
 
Join Date: May 2009
Location: United States of America
Posts: 58
Well the Xyz to sRGB is perfect but I have run into some problems I think are to do with the image pitch.
example. It occurs only with 1998 width video as there are only two image widths that are used 2048 and 1998. The 2048 video is displayed correctly, funnily enough avspmod had a bug in version 2.0.8 that looks similar to this bug with mod 2 video except its slanted in the opposite direction and when displayed in 2.0.8 it displays correctly lol. I could just use some hints as to what is causing this and in what direction to look.
<-- bug and the same video displayed correctly -->
__________________
never give up or at least die trying
sub24ox7 is offline   Reply With Quote
Old 13th May 2011, 09:00   #10  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,442
From mxfsource.cpp (function GetFrameOpenJPEG):
Code:
    int d_stride = pvf->GetPitch();

    for (int i = 0; i < w * h; i++) {
	unsigned char rc, gc, bc;
	int r, g, b;

	r = image->comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
	r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
	rc = (unsigned char) ((r >> adjustR)+((r >> (adjustR-1))%2));
	g = image->comps[1].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
	g += (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0);
	gc = (unsigned char) ((g >> adjustG)+((g >> (adjustG-1))%2));
	b = image->comps[2].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
	b += (image->comps[2].sgnd ? 1 << (image->comps[2].prec - 1) : 0);
	bc = (unsigned char) ((b >> adjustB)+((b >> (adjustB-1))%2));

	BYTE *pixel = ptr + i * 4;
	pixel[0] = bc;
	pixel[1] = gc;
	pixel[2] = rc;
It looks like it is just writing the pixels one after the other without taking the image pitch into account.
Note that the variable d_stride is not used.

It should be writing the data one row at a time and padding out to the pitch width.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 14th May 2011, 04:26   #11  |  Link
sub24ox7
Audiophile
 
sub24ox7's Avatar
 
Join Date: May 2009
Location: United States of America
Posts: 58
Thank you, this makes since and I have found some information on the subject and should be able to get it to work now
thank you again.
__________________
never give up or at least die trying
sub24ox7 is offline   Reply With Quote
Old 15th August 2011, 20:53   #12  |  Link
elmarikon
der Name sagt alles
 
elmarikon's Avatar
 
Join Date: Jul 2008
Location: Hamburg, Germany
Posts: 37
MXFSource

Hi guys!

Has anyone got the famous MXFSource to work?!
I found different versions of mxfsource.h & mxfsource.cpp here, but couldn't compile though....

Can anyone help me?
Or has anyone got a working dll=

All the best so long!

SwK
__________________
SwK
elmarikon is offline   Reply With Quote
Old 31st August 2011, 06:14   #13  |  Link
sub24ox7
Audiophile
 
sub24ox7's Avatar
 
Join Date: May 2009
Location: United States of America
Posts: 58
Haha well those were pastebins between my friend and I working on the code to covert the color from XYZ to RGB which is finished. We fixed the bug with non mod 4>= just had to use pitch.
for (int i = 0; i < d_stride/4 * h; i++)
{
if ( i%(d_stride/4) < w )
etc... blah blah.

I will be giving the original code writer the updated code so the page will be updated sometime soon hopefully.
And the source code up there now will not compile unless you comment out the include for the mainconcept jpeg2000 sdk
and all of the places its used. Its all open source now and uses the openjpeg lib.
__________________
never give up or at least die trying

Last edited by sub24ox7; 31st August 2011 at 07:07.
sub24ox7 is offline   Reply With Quote
Old 25th January 2013, 16:39   #14  |  Link
hanfrunz
Registered User
 
hanfrunz's Avatar
 
Join Date: Feb 2002
Location: Germany
Posts: 541
Hello sub24ox7,

where can i find the latest version of your mxfsource filter? The google code page seems to be outdated. Could you post a working .dll?

regards,
hanfrunz
hanfrunz is offline   Reply With Quote
Old 12th August 2013, 12:54   #15  |  Link
elmarikon
der Name sagt alles
 
elmarikon's Avatar
 
Join Date: Jul 2008
Location: Hamburg, Germany
Posts: 37
yes!

that would be so great!!



pleeeeease!
__________________
SwK
elmarikon is offline   Reply With Quote
Old 12th August 2013, 14:35   #16  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,406
Related thread here:
http://forum.doom9.org/showthread.ph...28#post1576128
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 12th August 2013 at 15:51. Reason: speeling
StainlessS is offline   Reply With Quote
Old 2nd October 2015, 08:48   #17  |  Link
Sparktank
47.952fps@71.928Hz
 
Sparktank's Avatar
 
Join Date: Mar 2011
Posts: 940
Really old bump:
But googling, you can see the mxfsource has been forked to GitHub recently:
https://github.com/trollcop/dcinematools

I forked just for archival purposes.

But, looking through some of the files,
it's for old AVS where it still uses YUY2 (no YV16/YV24).

I guess making an ffmpeg lossless intermediate (ffvhuff yuv444p##le) is still the most efficient way?
If I want YV24 output? Or even maybe YCgCo-matrixed output (limited MadVR; etc for things like DS_Kodi, etc etc).
The sacrifice of RGB I can live with.

But the appeal of using Dither_Package is the biggest reason for YV24 output (or YCgCo).

Oooor, would it not be more efficient to convert to RGB with ffmpeg then use Dither_package to get YCgCo.
With 10-bit option (Dither_quantize/Dither_out) ?

Outdated plugins for any type of MXF source (xyz12le, according to ffmpeg) seem deprecated when ffmpeg can do nicely ffvhuff for lossless intermediates.
With ffmpeg_ffvhuff, we also can work easily with ProRes/DVCpro, too.

If anyone were to update mxfsource() to be 2.6 compatible, would that even make a difference at all?
(time not included, given that making a lossless intermediate would, no doubt, take more time)
But, I mean, in terms of efficiency?
Cleaning out bugs to make sure it does what it needs to will take up a developer's time, so I don't want really want to ask anyone to make a proper port for avs2.6/vs.

tl;dr:
Are we happy with ffmpeg_ffvhuff-yv444p##le?

I am, absolutely, all for sharpening my axe twice before hitting that tree once.
__________________
Win10 (x64) build 19041
NVIDIA GeForce GTX 1060 3GB (GP106) 3071MB/GDDR5 | (r435_95-4)
NTSC | DVD: R1 | BD: A
AMD Ryzen 5 2600 @3.4GHz (6c/12th, I'm on AVX2 now!)
Sparktank is offline   Reply With Quote
Old 2nd October 2015, 13:08   #18  |  Link
foxyshadis
Angel of Night
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,567
Quote:
Originally Posted by Sparktank View Post
Really old bump:
But googling, you can see the mxfsource has been forked to GitHub recently:
https://github.com/trollcop/dcinematools
I took a look at that; unfortunately, the (custom?) jpeg2000 library the plugin uses was never open sourced, it was just abandoned half-assed and unbuildable.

I wouldn't mind a native plugin, but have you checked whether ffms or lav will work just as well? Assuming j2k, you would want a 16-bit workflow and they should be able to provide. If it's an mpeg2 mxf, it'll always be 8-bit.

Don't bother with YCgCo, unless you specifically need lossless. It's designed to be a high-speed lossless 9-bit colorspace (both chroma channels require one bit more than the RGB input), but true YUV should work better for almost any purpose with a 16-bit workflow. Likewise for using a lossless intermediate codec if you can output to MXF or realtime x264.
foxyshadis is offline   Reply With Quote
Old 3rd October 2015, 04:33   #19  |  Link
Sparktank
47.952fps@71.928Hz
 
Sparktank's Avatar
 
Join Date: Mar 2011
Posts: 940
That is, indeed, unfortunate news.

I haven't tested lates ffms2 builds.
I tried last known 10bit back, but no suitable colorspace can be found.

So far I don't see anything in ffms2 for anything xyz related.

Not much luck googling anything else.
__________________
Win10 (x64) build 19041
NVIDIA GeForce GTX 1060 3GB (GP106) 3071MB/GDDR5 | (r435_95-4)
NTSC | DVD: R1 | BD: A
AMD Ryzen 5 2600 @3.4GHz (6c/12th, I'm on AVX2 now!)
Sparktank is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:50.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.