mlt: image distortion using lossless codec - mlt

I have two 1920x1080 PNG files, center.png and right.png, which are identical except that the image in right.png is shifted horizontally by 325 pixels.
With mlt XML, I made a two-second long video using the lossless FFV1 format, showing one second of center.png, and then one second of right.png. Here's my file, foo.mlt:
<?xml version='1.0' encoding='utf-8'?>
<mlt>
<profile width="1920" height="1080"
display_aspect_num="1920" display_aspect_den="1080"
sample_aspect_num="1" sample_aspect_den="1"
colorspace="709" progressive="1"
frame_rate_num="30" frame_rate_den="1"/>
<consumer mlt_service="avformat" properties="lossless/FFV1" target="out.mkv"/>
<producer id="center" mlt_service="qimage" resource="center.png" length="30"/>
<producer id="right" mlt_service="qimage" resource="right.png" length="30"/>
<playlist>
<entry producer="center"/>
<entry producer="right"/>
</playlist>
</mlt>
Then I run melt foo.mlt at the terminal and check the output file out.mkv in my video viewer. However, on close inspection, when right.png appears in the video, it is slightly distorted (with some sort of halo-type artifact). Here is a magnified view:
Weirdly, only the right.png image is distorted; the center.png displays correctly, even though the two images are identical except for positioning.
Is this a bug? I wouldn't expect any image distortion with a lossless codec, but maybe I've done something wrong.
My specs:
Ubuntu 20.04.2 LTS, 64-bit
melt 6.25.0
ffmpeg version 4.2.4-1ubuntu0.1
Thanks

"Lossless" is not always lossless. In the case of "lossless/FFV1", the chroma format is 4:2:2 which will cut the chroma resolution in half:
https://github.com/mltframework/mlt/blob/master/presets/consumer/avformat/lossless/FFV1
This could be relevant because if format conversion is required, it could cause chroma bleeding on pixels that do not land directly on a chroma sample.
As an experiment, you could try shifting the image by 326 pixels instead of 325 to see if the bleeding still occurs.
There was another question a while back that related to bleeding due to chroma subsampling:
Melt composite transition is slightly blending

Related

Next JS Not loading svg from api

Versions:
React: 18.2.0
NextJS: 12.2.0
Simple image asset is just refusing to load when is used inside <img /> tag with src attribute set to data:image/svg+xml;utf-8,[svg data here]
When I paste this url data:image/svg+xml;utf-8,[svg data here] directly in the browser everything loads fine as expected the source image is there and all other things. The next.config has all the required image configuration and in the code for the image currently we use normal <img /> tag. The asset loads fine when its not called like svg, e.g. src="https://external-api/image.jpeg" In the network tab the response for the image is 200 all the time, but the preview shows only the svg styles with the default placeholder for missing image.
If I paste the image in THIS online encoder the image is NOT loading (behaves like in my problem), but if I copy the encoded url from the page and paste it in new chrome tab the image loads w/o any problem.
Examples:
Source image
Svg code that goes in to the src
data:image/svg+xml;utf-8,%3Csvg viewBox='0 0 1044 1054' fill='none' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Cg opacity='.7' filter='url(%23a)'%3E%3Cpath d='M309.796 414.322 190.497 535.433 467.98 803.76l119.299-121.111-277.483-268.327Z' fill='%23000'/%3E%3C/g%3E%3Cmask id='b' style='mask-type:alpha' maskUnits='userSpaceOnUse' x='116' y='91' width='837' height='837'%3E%3Crect width='440' height='1000' rx='220' transform='matrix(-.70604 .70817 .70746 .70675 335.664 0)' fill='%23000'/%3E%3C/mask%3E%3Cg mask='url(%23b)'%3E%3Cpath fill='url(%23c)' d='M109 84h850v850H109z'/%3E%3C/g%3E%3Crect width='294.223' height='822.461' rx='147.112' transform='matrix(-.70575 .70846 .70718 .70704 228.716 325)' fill='url(%23d)'/%3E%3Cdefs%3E%3Cpattern id='c' patternContentUnits='objectBoundingBox' width='1' height='1'%3E%3Cuse xlink:href='%23d'/%3E%3C/pattern%3E%3Cfilter id='a' x='.497' y='224.322' width='776.782' height='769.437' filterUnits='userSpaceOnUse' color-interpolation-filters='sRGB'%3E%3CfeFlood flood-opacity='0' result='BackgroundImageFix'/%3E%3CfeBlend in='SourceGraphic' in2='BackgroundImageFix' result='shape'/%3E%3CfeGaussianBlur stdDeviation='95' result='effect1_foregroundBlur_3332_33632'/%3E%3C/filter%3E%3Cimage id='d' width='1' height='1' xlink:href='https://fakeimg.pl/250x300/fff000/'/%3E%3C/defs%3E%3C/svg%3E
And how is renderd in the app
What was tried:
If the image is encoded in base64 works, but with huge performace drawbacks mainly on older IOS devices.
Next config option for dangerouslyAllowSVG doesn't change anything...

Why does my kml description balloon have no tail when displayed online on Google Earth?

I am a kml "newbie" trying to attach a balloon to a placemark.
The default behavior of a balloon associated with a placemark is to display text in a box with a tail pointing to the placemark's location after you click on the placemark. I import my kml files into Google Earth online to test. My balloons appear when I click on the placemarks, but I never get the "tail". Instead, the balloons appear in the upper left corner of the screen.
I've been reading about BallonStyle in the kml reference doc:
https://developers.google.com/kml/documentation/kmlreference
I have copied and loaded examples from: https://developers.google.com/kml/documentation/extendeddata
among other places, and the tail never appears.
I wrote this simple kml file that I think SHOULD use the default balloon behavior, but doesn't. The placemark has valid coordinates. What am I missing?
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Style id="Piper">
<IconStyle>
<color>ff0000ff</color>
</IconStyle>
<BalloonStyle>
<text>$[description]</text>
</BalloonStyle>
</Style>
<Placemark>
<name>Piper 2018-08-01T16:45:16</name>
<description>Accuracy = 10m</description>
<styleUrl>#Piper</styleUrl>
<Timestamp>
<when>2018-08-01T16:45:16</when>
</Timestamp>
<Point>
<coordinates>-110.766531000,43.851320000</coordinates>
</Point>
</Placemark>
</Document>
</kml>
Thanks for any insights.

Prevent macOS generic keyboard driver from capturing usb-device

I'm trying to write a macOS user-level driver in C for a usb-device (a pentablet with buttons).
Currently this tablet gets recognized as generic mouse and generic keyboard from the system. Since the shortcuts applied to the buttons of the pentablet are not customizeable, I'd like to write my own driver for that.
What's working:
I am able to read the raw-data with hidapi (http://www.signal11.us/oss/hidapi/) from the device, which looks something like this:
A B C D E F G H
10 192 228 50 157 43 0 0
I figured out, that when I use the pen the values of the columns B-H change according to the pens position, pressure and click.
My problem:
However, I cannot figure out how to access the buttons of the device. Each time I press one of them, their hardcoded key-combination gets triggered. Since the values of column A never change, I assume that the device is still captured as a generic keyboard by the system, and so this column never shows me the currently pressed button and triggers it's key-combination.
Each time I press one of these buttons they all trigger a holding ALT/Option + Shift, additionally some of them trigger a character, and one of them triggers the volume up.
So, my approach was to use a codeless kext for preventing the system from capturing the device. But this doesn't work either - the device still gets captured by the system as a generic keyboard.
I disabled csrutil and with kextload, having my kext located in /Library/Extensions, I get a successfull message, that the kext is loaded:
Warnings:
Personality CFBundleIdentifier differs from containing kext's (not necessarily a mistake, but rarely done):
Tablet
Code Signing Failure: code signature is invalid
Warnings:
Personality CFBundleIdentifier differs from containing kext's (not necessarily a mistake, but rarely done):
Tablet
/Library/Extensions/foobartablet.kext appears to be loadable (not including linkage for on-disk libraries).
kext-dev-mode allowing invalid signature -67050 0xFFFFFFFFFFFEFA16 for kext "/Library/Extensions/foobartablet.kext"
kext signature failure override allowing invalid signature -67050 0xFFFFFFFFFFFEFA16 for kext "/Library/Extensions/foobartablet.kext"
Loading /Library/Extensions/foobartablet.kext.
Here's my info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>13C64</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleGetInfoString</key>
<string>1.0 Copyright © Adis Durakovic</string>
<key>CFBundleIdentifier</key>
<string>com.adisdurakovic.huitablet</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>KEXT</string>
<key>CFBundleShortVersionString</key>
<string>Huion Tablet 1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>5A2053</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>13A595</string>
<key>DTSDKName</key>
<string>macosx10.9</string>
<key>DTXcode</key>
<string>0501</string>
<key>DTXcodeBuild</key>
<string>5A2053</string>
<key>IOKitPersonalities</key>
<dict>
<key>Tablet</key>
<dict>
<key>CFBundleIdentifier</key>
<string>com.apple.kpi.iokit</string>
<key>IOClass</key>
<string>IOService</string>
<key>IOProviderClass</key>
<string>IOUSBDevice</string>
<key>idVendor</key>
<string>9580</string>
<key>idProduct</key>
<string>110</string>
<key>bcdDevice</key>
<string>12288</string>
<key>IOProbeScore</key>
<integer>200000</integer>
</dict>
<key>TabletNew</key>
<dict>
<key>CFBundleIdentifier</key>
<string>com.apple.kpi.iokit</string>
<key>IOClass</key>
<string>IOService</string>
<key>IOProviderClass</key>
<string>IOUSBHostDevice</string>
<key>idVendor</key>
<string>9580</string>
<key>idProduct</key>
<string>110</string>
<key>bcdDevice</key>
<string>12288</string>
<key>IOProbeScore</key>
<integer>300000</integer>
</dict>
</dict>
<key>OSBundleLibraries</key>
<dict/>
</dict>
</plist>
And here's also my ioreg -i -w 0 -l -n "PenTablet" output which I used for device matching:
https://adisdurakovic.com/pentablet.txt
What am I doing wrong here?
Since you mention SIP, I assume you're testing this on 10.11 or newer. Your IOProviderClass is set to IOUSBDevice - this will only work for 10.10 and older. 10.11 introduced a completely new USB stack, the new class name is IOUSBHostDevice. I know that's not what IORegistryExplorer/ioreg say: there's a translation going on somewhere to keep old userspace apps ticking over. In the kernel, drivers matching IOUSBHostDevice will take precedence over those matching IOUSBDevice. If you want to support both, you can just add an extra personality to your codeless kext. For kexts with code, you'll need to create two versions of your kext if the legacy support doesn't work in your case.
Another thing that could affect it is probe score, although in theory your idVendor + idProduct + bcdDevice rule should already have a very high score.

How can I resolve the "Invalid Resx file...Cannot find valid "resheader" tags for the ResX reader and writer type names." compiler error?

I'm getting a dozen "Invalid Resx file. ResX input is not valid. Cannot find valid "resheader" tags for the ResX reader and writer type names." err msgs on trying to compile.
I had this problem before, as can be seen here.
This time, though, it manifests itself a little differently.
First, here is what I did: I selected the context menu item "Undo Pending Changes" on several files in a project. For each of them, their related *.resx file apparently got corrupted.
2-clicking the first err msg in the Error List takes me here in the .resx file:
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
2-clicking the next err takes me here in the .resx file:
<resheader name="resmimetype">text/microsoft-resx</resheader>
This is a commented out explanatory section; in a little bit of context:
<!--
Microsoft ResX Schema
Version 1.3
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>
. . .
All 10 other 2-clickings takes me right to the first line in the .resx file, namely:
<?xml version="1.0" encoding="utf-8"?>
Hans Passant's answer to the same question by a different cat here indicates superfluous white space needs to be removed; I see no such extra white space in my .resx files, though...
What need I do to fix these mangled .resx files?
UPDATE
It may be that those first two locations where the err msg seems to point are bogus/misleading; they may be simply places in the files where I had previously put my cursor (odd that the err msg would go there instead of to the supposed location of the problem, though...)
UPDATE 2
According to the err msg, the failing *.resx files are missing valid resheader reader/writer tags. Yet those tags/declarations do exist there in the failing *.resx files. These look like this:
<resheader name="reader">
<value>System.Windows.Forms.Design.CFResXResourceReader, System.CF.Design,
Version=7.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</resheader>
<resheader name="writer">
<value>System.Windows.Forms.Design.CFResXResourceWriter, System.CF.Design,
Version=7.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</resheader>
....but, interestingly enough (if you're an uebergeek, anyway) those do differ from the RESX readers and writer declarations in other (compiling) forms, which look like this:
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0,
Culture=neutral,PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0,
Culture=neutral,PublicKeyToken=b77a5c561934e089</value>
</resheader>
If I replace the RESX reader/writer declarations in the non-compiling forms with the other format (IOW I replace "System.Windows.Forms.Design.CFResXResourceReader, System.CF.Design, Version=7.0.5000.0" with "System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0" (and use the differing public key tokens), it compiles!
BUT (and this is a big but[t] (think Bertha)), the machine on which this project is being compiled is a PC (of course), but the target machine on which the .exe will run is a Compact Framework (handheld) device. So, will replacing the "CF" with the more generic RESX verbiage prove problematic once the .exe is moved from point PC to point Handheld Windows CE device?

Can solr produce highlight position info for Adobe XML highlighting spec?

There is a PDF highlighting spec from Adobe that allows one to provide an XML file describing highlight locations to a PDF viewer API. Can Solr produce the highlighting info necessary to produce such a file? Mandatory info would be: page, position, and length. If the answer is yes, any tips on configuring the Solr highlighting component?
Sample XML higlighting file:
<XML>
<Body units='characters' color='#ff00ff' mode='active' version='2'>
<Highlight>
<loc pg='0' pos='0' len='6' />
<loc pg='2' pos='1' len='10' />
</Highlight>
</Body>
</XML>

Resources