How to add color space information in mp4 header using Media Foundation? - ms-media-foundation

Trying to add color space information (primary/transfer matrix/transform function) in MediaFoundation transcoding.
To set the color related attributes on
MFCreateSinkWriterFromURL(..,..,pAttributes,..)
or the IMFSample* to IMFSinkWriter::WriteSample()
Only the Nvidia has color tag on output mp4 header, but AMD and Intel do not have.
How do I add the color tag for these two vendor?

Intercept the buffer and insert the vui parameter with color tag into sps header.
Create a file sink wrapper, which internally create actual file sink by MFCreateMPEG4MediaSink.
Set the attribute MF_MPEG4SINK_SPSPPS_PASSTHROUGH with TRUE to the actual media sink.
Implement IMFMediaSink and IMFStreamSink to hook all APIs.
The IMFStreamSink ::ProcessSample(__RPC__in_opt IMFSample *pSample) will get the encoder output sample.
Create SinkWriter using MFCreateSinkWriterFromMediaSink() with the wrapper.
When running, extract the raw buffer from IMFSample*/IMFMediaBuffer*/BYTE*. Follow the h264 or h265 spec to insert a sps header with
Colour Description Present, 1
Colour Primaries
Transfer Characteristics
Matrix Coefficients

Related

Can VNImageRequestHandler accepts MLMultiArray as an input? (Without converting to UIImage)

I have two MLModels in my app. The first one is generating an MLMultiArray output which is meant to be used as the second model input.
As I'm trying to make things as performance-best as possible. I was thinking about using VNImageRequestHandler to feed it with the first model output (MLMultiArray) and use Vision resize and rectOfIntersent to avoid converting the first input to an image, crop features, to avoid the need to convert the first output to image, do everything manually and use the regular image initializer.
Something like that:
let request = VNCoreMLRequest(model: mlModel) { (request, error) in
// handle logic?
}
request.regionOfInterest = // my region
let handler = VNImageRequestHandler(multiArray: myFirstModelOutputMultiArray)
Or I have to go through back and forth conversions? Trying to reduce processing delays.
Vision uses images (hence the name ;-) ). If you don't want to use images, you need to use the Core ML API directly.
If the output from the first model really is an image, it's easiest to change that model's output type to an image so that you get a CVPixelBuffer instead of an MLMultiArray. Then you can directly pass this CVPixelBuffer into the next model using Vision.

Open-Atrium Toolbar

I have two blue prints for the space content type in OA. On the toolbar dropdown i want to show only the spaces created using the default blue print. AO uses the oa_core_get_groups_by_user_access(found in OA core module in the oa_core.util.inc file) to pull all spaces a use subscribed to. I want to alter this function to show only spaces created using the default blue print by altering the query used in this function.
All my attempts to do so have failed probably because i don't understand the drupal database abstraction queries. Can someone help me with the piece of code i can add to this function to achieve this functionality.
Finally got it. To show only the default spaces in the dropdown, you have to make changes to the oa_core_get_titles function in the oa_core_util.inc file of oa_core.
Add the following line below line 641 of that particular file.
$query->leftJoin('field_data_field_oa_space_type','t','n.nid=t.entity_id');
$query->condition('t.field_oa_space_type_tid',1);
This filters out only spaces created using the default space.

Enhanced SR SOP Class"1.2.840.10008.5.1.4.1.1.88.22" Is useful to draw Region of Interest

SOP Class UID :- "1.2.840.10008.5.1.4.1.1.88.22" of Enhanced SR SOP Class Name
In this SR Modality having various dicom tags from these various tag I want to draw the "Region of Interest"(ROI) on the MR Modality.
this is my SR Dicom file SR DICOM
So help me to know which SR Modality Tag I use to draw the marker on MR Modality or which referential tag I use to get ROI and MR reference SOP Instance UID with respect to SR Modality
I have been doing a large amount of work with mammography SR recently. I found David Clunie's book to be excellent. You can find more info on his site and a link to the book.
I tried to have a look at your file but I can't access it so I will tell you about my experience of SR in mammography.
To tackle the SR in mammography I wrote a tool that is now part of PyDICOM to understand the structure of the SR files. I'm sure there are similar tools in other languages. Below is a screen capture of an example.
The information about the ROI is stored in the SCOORD content item. Change this to change the ROI. I have found different types of SCOORD items such as centre and outline so you would need to be consistent in changing them. The one I have highlighted is an outline of a ROI.
If you notice the reference content identifier on the SCOORD has the value [1,2,1]. This means you go to the root (1) go to the second item (2) and then the first item in the referenced Series Sequence (1). The ReferencedSOPInstanceUID in there is the image on which the SCOORD is drawn.
EDIT 1
I had a look at your file but I can't find and SCOORD content items. Also there are no ReferencedSOPInstances.

Filemaker GetAs...How to display Container Field on webpage?

I have an ASP.Net application that needs to display an image that is stored in a Filemaker Container field. My query statement looks like:
SELECT GetAs(Image, 'JPG') FROM UA_Item_Pictures WHERE "Stock Number" = 33989 AND ImageOrder = 1
According to the documentation:
The possible file types (case sensitive) you can retrieve from a container field in a FileMaker database file are:
'EMBO'
OLE container data
'PDF '
Portable Document Format
'EMF+'
Windows Enhanced Metafile Plus
'PICT'
Mac OS (does not have 512-byte file-based header)
'EPS '
Embedded PostScript
'PNGf'
Bitmap image format
'FILE'
Result of an Insert File command
'PNTG'
MacPaint
'FPix'
Flash (FPX)
'qtif'
QuickTime image file
'FORK'
Resource fork (Mac OS)
'.SGI'
Generic bitmap format
'GIFf'
Graphics Interchange Format
'snd '
Standard sound (Mac OS raw format)
'JPEG'
Photographic images
'TIFF'
Raster file format for digital images
'JP2 '
JPEG 2000
'TPIC'
Targa
'META'
Windows Metafile (enhanced)
'XMLO'
Layout objects
'METO'
Windows Metafile (original)
'8BPS'
PhotoShop (PSD)
'moov'
Old QuickTime format (Mac OS)
So with this information, my questions are:
How do I retrieve contents with multiple formats?
How do I render the BLOG into an image on the page?
Any suggestions would be much appreciated!
Thanks, but I think I found out what was going on. If I did an inner join between an image table and another table, the image wasn't being returned (or being returned properly...not sure which). As soon as I ran a query against the image table directly, images were returned.
So this did not work:
select * from biography_table b inner join image_table i on b.stocknumber = i.stocknumber
where b.stocknumber = 12345
But this does:
select * from image_table where stocknumber = 12345
This means I have to run 2 separate queries, but at least I'm seeing data!!
If you cannot predict what the file type will be, AND/OR you need to use other extensions (such as docx, xlsx, etc), then you can exclusively use 'FILE' for all of your storage and retrieval scripts.
However doing it this way means that FileMaker does not know natively how to handle and open the file. In other words, when using FileMaker you will need to manually export the contents of the field to edit/view it, instead of being able to simply double click the field and it opens the file. So either the setup is advantageous to FileMaker, or advantageous to your external application.
If you do it this way, all files in container fields will be called 'Untitled.dat' and their internal name will be '?', so you will also need to store in another field the actual file name or its extension so you can open it later.
It is because you are using JPG instead of JPEG, in fact, your question answers itself. You can read it this way
SELECT GetAs(Image, 'JPEG') ...
And then, if you are using ado.net read it this way
var bytesLength = reader.GetBytes(0, 0, null, 0, 0);
var buffer = new Byte[bytesLength];
var bytes = reader.GetBytes(0, 0, buffer, 0, (int)bytesLength);
using (var fileStream = new FileStream(String.Format("{0}.jpg", Guid.NewGuid().ToString()), FileMode.Create, FileAccess.Write)) {
fileStream.Write(buffer, 0, buffer.Length);
}
Where 0 at the beggining of the the GetBytes function is the index of the photo field.
Buy a license of SuperContainer (shameless plug alert: I'm one of the authors) and a Mac Mini to host it on. Move the files out of your container fields and into SuperContainer, and let SuperContainer render image versions of your files by tapping into OS X's CoreImage libs.

how to change OutPut Pin Size & ColorSpace/Compression in DirectShow

how to change OutPut Pin Size & ColorSpace/Compression of a Video Source Filter in DirectShow
I want to Know whre the Output Pin PropertyPage Datas are stored and how can I Change those Datas By My Code
You would have to write your own transformation filter. Or you can use a filter like FFDShow that supports image resizing among other video modifications and enhancements.
You can use IPin::EnumMediaTypes on your filter's output pin to get a list of supported media types / video formats.
Afterwards, call IAMStreamConfig::GetFormat to get the current format in an AM_MEDIA_TYPE structure. Modify this structure as you wish (make sure your format is supported by the device), and call IAMStreamConfig::SetFormat with the same structure.

Resources