Skip to content

Commit

Permalink
S-ADM audio metadata browser, ADM preview, sample-wise audio resource…
Browse files Browse the repository at this point in the history
… editing
  • Loading branch information
IMFTool committed Mar 15, 2024
1 parent b9413d0 commit a38e14a
Show file tree
Hide file tree
Showing 36 changed files with 1,862 additions and 87 deletions.
Binary file not shown.
Binary file modified photon/build/libs-admsadm/Photon-4.9.0-SNAPSHOT.jar
Binary file not shown.
Binary file not shown.
Binary file modified resources/IMF-Tool_Users-Manual.pdf
Binary file not shown.
16 changes: 10 additions & 6 deletions src/CMakeLists.txt
Expand Up @@ -5,9 +5,11 @@ find_file(asdcplib_Targets_PATH NAMES asdcplibtargets.cmake PATHS "$ENV{CMAKE_HI
find_path(asdcplib_include_DIR NAMES AS_02.h PATHS "$ENV{CMAKE_HINT}/asdcplib" ENV CMAKE_HINT PATH_SUFFIXES "include")
find_library(XercescppLib_PATH NAMES xerces-c xerces-c_3 PATHS "${PROJECT_SOURCE_DIR}/../xercescpp" "${PROJECT_SOURCE_DIR}/../lib/xercescpp" "$ENV{CMAKE_HINT}/xercescpp" ENV CMAKE_HINT PATH_SUFFIXES "lib")
find_library(XercescppLib_Debug_PATH NAMES xerces-cD xerces-c_3D xerces-c PATHS "${PROJECT_SOURCE_DIR}/../xercescpp" "${PROJECT_SOURCE_DIR}/../lib/xercescpp" "$ENV{CMAKE_HINT}/xercescpp" ENV CMAKE_HINT PATH_SUFFIXES "lib")
find_path(XercescppLib_include_DIR NAMES xercesc/dom/DOM.hpp PATHS "${PROJECT_SOURCE_DIR}/../xercescpp" "${PROJECT_SOURCE_DIR}/../lib/xercescpp" "$ENV{CMAKE_HINT}/xercescpp" ENV CMAKE_HINT PATH_SUFFIXES "include")
find_path(libz_include_DIR NAMES zlib.h zconf.h ENV CMAKE_HINT PATH_SUFFIXES "include" "zlib/include")
find_file(libz_PATH NAMES libz.a zlib.lib ENV CMAKE_HINT PATH_SUFFIXES "lib" "zlib/lib")
find_package(OpenJPEG)
find_package(regxmllibc)
find_path(XercescppLib_include_DIR NAMES xercesc/dom/DOM.hpp PATHS "${PROJECT_SOURCE_DIR}/../xercescpp" "${PROJECT_SOURCE_DIR}/../lib/xercescpp" "$ENV{CMAKE_HINT}/xercescpp" ENV CMAKE_HINT PATH_SUFFIXES "include")

if(BUILD_APP5_SUPPORT)
find_package(Imath CONFIG)
Expand Down Expand Up @@ -61,11 +63,12 @@ set(tool_src main.cpp MainWindow.cpp KMQtLogSink.cpp QtWaitingSpinner.cpp Widget
ImfPackageCommands.cpp MetadataExtractor.cpp MetadataExtractorCommon.cpp WizardResourceGenerator.cpp DelegateComboBox.cpp DelegateMetadata.cpp
GraphicsWidgetTimeline.cpp GraphicsWidgetSegment.cpp CompositionPlaylistCommands.cpp ImfMimeData.cpp GraphicsCommon.cpp
CustomProxyStyle.cpp GraphicScenes.cpp GraphicsWidgetResources.cpp GraphicsViewScaleable.cpp WidgetTrackDedails.cpp GraphicsWidgetComposition.cpp
GraphicsWidgetSequence.cpp Events.cpp WidgetCentral.cpp
GraphicsWidgetSequence.cpp Events.cpp WidgetCentral.cpp
WidgetCompositionInfo.cpp UndoProxyModel.cpp JobQueue.cpp Jobs.cpp Error.cpp WizardPartialImpGenerator.cpp
WidgetVideoPreview.cpp WidgetImagePreview.cpp JP2K_Preview.cpp JP2K_Decoder.cpp TTMLParser.cpp WidgetTimedTextPreview.cpp TimelineParser.cpp # (k)
WidgetContentVersionList.cpp WidgetContentVersionListCommands.cpp WidgetLocaleList.cpp WidgetLocaleListCommands.cpp WizardEssenceDescriptor.cpp#WR
WizardSidecarCompositionMapGenerator.cpp WizardCompositionGenerator.cpp PreviewCommon.cpp Player.cpp WidgetXmlTree.cpp
WizardSidecarCompositionMapGenerator.cpp WizardCompositionGenerator.cpp PreviewCommon.cpp Player.cpp WidgetXmlTree.cpp WidgetSADMPreview.cpp XmlQSyntaxHighlighter.cpp
qcompressor.cpp
)
if(BUILD_APP5_SUPPORT)
set(tool_src ${tool_src} As02AcesIStream.cpp ACES_Preview.cpp ACES_Decoder.cpp
Expand All @@ -82,7 +85,8 @@ set(tool_src ${tool_src} global.h MainWindow.h KMQtLogSink.h QtWaitingSpinner.h
WidgetCompositionInfo.h UndoProxyModel.h SafeBool.h JobQueue.h Jobs.h Error.h WizardPartialImpGenerator.h
WidgetVideoPreview.h WidgetImagePreview.h JP2K_Preview.h JP2K_Decoder.h TTMLParser.h WidgetTimedTextPreview.h TimelineParser.h SMPTE_Labels.h # (k)
WidgetContentVersionList.h WidgetContentVersionListCommands.h WidgetLocaleList.h WidgetLocaleListCommands.h WizardEssenceDescriptor.h# WR
WizardSidecarCompositionMapGenerator.h WizardCompositionGenerator.h PreviewCommon.h Player.h WidgetXmlTree.h
WizardSidecarCompositionMapGenerator.h WizardCompositionGenerator.h PreviewCommon.h Player.h WidgetXmlTree.h WidgetSADMPreview.h XmlQSyntaxHighlighter.h
qcompressor.h
)
if(BUILD_APP5_SUPPORT)
set(tool_src ${tool_src} As02AcesIStream.h ACES_Preview.h ACES_Decoder.h
Expand All @@ -100,7 +104,7 @@ source_group("Synthesis Files" FILES ${synthesis_src})
qt5_add_resources(resSources ${qt_rcc_resources})

include_directories("${PROJECT_SOURCE_DIR}/src" "${PROJECT_SOURCE_DIR}/src/synthesis" "${XercescppLib_include_DIR}"
"${asdcplib_include_DIR}" "${OPENJPEG_INCLUDE_DIRS}" "${REGXMLLIBC_INCLUDE_DIRS}")
"${asdcplib_include_DIR}" "${OPENJPEG_INCLUDE_DIRS}" "${REGXMLLIBC_INCLUDE_DIRS}" "${libz_include_DIR}")

if(BUILD_APP5_SUPPORT)
include_directories("${OpenEXRLib_include_DIR}/OpenEXR" "${ImathLib_include_DIR}/Imath")
Expand All @@ -120,7 +124,7 @@ endif(BUILD_APP5_SUPPORT)
add_executable(${EXE_NAME} WIN32 ${tool_src} ${resSources} ${win_resources} ${synthesis_src})
target_link_libraries(${EXE_NAME} general Qt5::Widgets
general libas02 debug "${XercescppLib_Debug_PATH}" optimized "${XercescppLib_PATH}" debug "${OpenJPEGLib_Debug_Path}" optimized "${OpenJPEGLib_Path}"
regxmllibc debug openjp2 optimized openjp2
regxmllibc "${libz_PATH}" debug openjp2 optimized openjp2
)
if(BUILD_APP5_SUPPORT)
target_link_libraries(${EXE_NAME}
Expand Down
48 changes: 44 additions & 4 deletions src/CompositionPlaylistCommands.cpp
Expand Up @@ -39,6 +39,21 @@ void SetEntryPointCommand::redo() {
mpResource->SetEntryPoint(mNewEntryPoint);
}

SetEntryPointSamplesCommand::SetEntryPointSamplesCommand(GraphicsWidgetAudioResource *pResource, const Duration &rOldEntryPoint, const Duration &rNewEntryPoint, QUndoCommand *pParent /*= NULL*/) :
QUndoCommand(pParent), mpResource(pResource), mOldEntryPoint(rOldEntryPoint), mNewEntryPoint(rNewEntryPoint) {

}

void SetEntryPointSamplesCommand::undo() {

mpResource->SetEntryPointSamples(mOldEntryPoint);
}

void SetEntryPointSamplesCommand::redo() {

mpResource->SetEntryPointSamples(mNewEntryPoint);
}

SetSourceDurationCommand::SetSourceDurationCommand(AbstractGraphicsWidgetResource *pResource, const Duration &rOldSourceDuration, const Duration &rNewSourceDuration, QUndoCommand *pParent /*= NULL*/) :
QUndoCommand(pParent), mpResource(pResource), mOldSourceDuration(rOldSourceDuration), mNewSourceDuration(rNewSourceDuration) {

Expand All @@ -54,6 +69,21 @@ void SetSourceDurationCommand::redo() {
mpResource->SetSourceDuration(mNewSourceDuration);
}

SetSourceDurationSamplesCommand::SetSourceDurationSamplesCommand(GraphicsWidgetAudioResource *pResource, const Duration &rOldSourceDuration, const Duration &rNewSourceDuration, QUndoCommand *pParent /*= NULL*/) :
QUndoCommand(pParent), mpResource(pResource), mOldSourceDuration(rOldSourceDuration), mNewSourceDuration(rNewSourceDuration) {

}

void SetSourceDurationSamplesCommand::undo() {

mpResource->SetSourceDurationSamples(mOldSourceDuration);
}

void SetSourceDurationSamplesCommand::redo() {

mpResource->SetSourceDurationSamples(mNewSourceDuration);
}

SetIntrinsicDurationCommand::SetIntrinsicDurationCommand(GraphicsWidgetMarkerResource *pResource, const Duration &rOldIntrinsicDuration, const Duration &rNewIntrinsicDuration, QUndoCommand *pParent /*= NULL*/) :
QUndoCommand(pParent), mpResource(pResource), mOldIntrinsicDuration(rOldIntrinsicDuration), mNewIntrinsicDuration(rNewIntrinsicDuration) {

Expand Down Expand Up @@ -461,10 +491,20 @@ EditCommand::EditCommand(AbstractGraphicsWidgetResource *pOriginResource, const
QUndoCommand *pParent /*= NULL*/) :
QUndoCommand(pParent) {

SetSourceDurationCommand *p_set_source_dur = new SetSourceDurationCommand(pOriginResource, rOldOriginResourceSourceDuration, rNewOriginResourceSourceDuration, this);
SetEntryPointCommand *p_entry_command = new SetEntryPointCommand(pCloneResource, rOldCloneResourceEntryPoint, rNewCloneResourceEntryPoint, this);
SetSourceDurationCommand *p_set_source_dur_two = new SetSourceDurationCommand(pCloneResource, rOldCloneResourceSourceDuration, rNewCloneResourceSourceDuration, this);
AddResourceCommand *p_add_resource_command = new AddResourceCommand(pCloneResource, clonedResourceSourceIndex, pTargetSequence, this);
GraphicsWidgetAudioResource *p_origin_audio_resource = qobject_cast<GraphicsWidgetAudioResource *>(pOriginResource);
GraphicsWidgetAudioResource *p_clone_audio_resource = qobject_cast<GraphicsWidgetAudioResource *>(pCloneResource);
if (p_origin_audio_resource && p_clone_audio_resource && pOriginResource->GetCplEditRate().HasFractionalNumberOfAudioSamplesPerImageFrame()) {
SetSourceDurationSamplesCommand *p_set_source_dur = new SetSourceDurationSamplesCommand(p_origin_audio_resource, rOldOriginResourceSourceDuration, rNewOriginResourceSourceDuration, this);
SetEntryPointSamplesCommand *p_entry_command = new SetEntryPointSamplesCommand(p_clone_audio_resource, rOldCloneResourceEntryPoint, rNewCloneResourceEntryPoint, this);
SetSourceDurationSamplesCommand *p_set_source_dur_two = new SetSourceDurationSamplesCommand(p_clone_audio_resource, rOldCloneResourceSourceDuration, rNewCloneResourceSourceDuration, this);
//AbstractGraphicsWidgetResource *p_resource = qobject_cast<AbstractGraphicsWidgetResource *>(p_clone_audio_resource->Clone());
AddResourceCommand *p_add_resource_command = new AddResourceCommand(p_clone_audio_resource, clonedResourceSourceIndex, pTargetSequence, this);
} else {
SetSourceDurationCommand *p_set_source_dur = new SetSourceDurationCommand(pOriginResource, rOldOriginResourceSourceDuration, rNewOriginResourceSourceDuration, this);
SetEntryPointCommand *p_entry_command = new SetEntryPointCommand(pCloneResource, rOldCloneResourceEntryPoint, rNewCloneResourceEntryPoint, this);
SetSourceDurationCommand *p_set_source_dur_two = new SetSourceDurationCommand(pCloneResource, rOldCloneResourceSourceDuration, rNewCloneResourceSourceDuration, this);
AddResourceCommand *p_add_resource_command = new AddResourceCommand(pCloneResource, clonedResourceSourceIndex, pTargetSequence, this);
}
}

MoveResourceCommand::MoveResourceCommand(AbstractGraphicsWidgetResource *pResource, int newResourceIndex, GraphicsWidgetSequence *pNewSequence, GraphicsWidgetSequence *pOldSequence, QUndoCommand *pParent /*= NULL*/) :
Expand Down
37 changes: 36 additions & 1 deletion src/CompositionPlaylistCommands.h
Expand Up @@ -19,7 +19,8 @@
#include <QUndoCommand>


class AbstractGraphicsWidgetResource;
class AbstractGraphicsWidgetResource;
class GraphicsWidgetAudioResource;
class GraphicsWidgetMarkerResource;
class GraphicsObjectVerticalIndicator;
class GraphicsWidgetSegmentIndicator;
Expand Down Expand Up @@ -47,6 +48,23 @@ class SetEntryPointCommand : public QUndoCommand {
};


class SetEntryPointSamplesCommand : public QUndoCommand {

public:
SetEntryPointSamplesCommand(GraphicsWidgetAudioResource *pResource, const Duration &rOldEntryPoint, const Duration &rNewEntryPoint, QUndoCommand *pParent = NULL);
virtual ~SetEntryPointSamplesCommand() {}
virtual void undo();
//! Called once when pushed on Undo Stack.
virtual void redo();

private:
Q_DISABLE_COPY(SetEntryPointSamplesCommand);
GraphicsWidgetAudioResource *mpResource;
Duration mOldEntryPoint;
Duration mNewEntryPoint;
};


class SetSourceDurationCommand : public QUndoCommand {

public:
Expand All @@ -64,6 +82,23 @@ class SetSourceDurationCommand : public QUndoCommand {
};


class SetSourceDurationSamplesCommand : public QUndoCommand {

public:
SetSourceDurationSamplesCommand(GraphicsWidgetAudioResource *pResource, const Duration &rOldSourceDuration, const Duration &rNewSourceDuration, QUndoCommand *pParent = NULL);
virtual ~SetSourceDurationSamplesCommand() {}
virtual void undo();
//! Called once when pushed on Undo Stack.
virtual void redo();

private:
Q_DISABLE_COPY(SetSourceDurationSamplesCommand);
GraphicsWidgetAudioResource *mpResource;
Duration mOldSourceDuration;
Duration mNewSourceDuration;
};


class SetIntrinsicDurationCommand : public QUndoCommand {

public:
Expand Down
67 changes: 59 additions & 8 deletions src/GraphicScenes.cpp
Expand Up @@ -599,14 +599,49 @@ void GraphicsSceneComposition::ProcessDragMove(DragDropInfo &rInfo, const QPoint

else if(p_origin_resource->type() == GraphicsWidgetSADMResourceType) {
// Per 2067-203, The Edit Rate shall be an integer multiple of the Edit Rate of the Main Image Virtual Track
if(p_origin_resource->GetAsset() &&
( p_origin_resource->GetAsset()->GetEditRate().GetNumerator() % GetCplEditRate().GetNumerator() == 0)
&& (p_origin_resource->GetAsset()->GetEditRate().GetDenominator() == GetCplEditRate().GetDenominator())) {
rInfo.isDropable = true;
if(p_origin_resource->GetAsset().isNull()) {
error_text = tr("Asset is NULL");
} else if(GraphicsWidgetSequence *p_sequence = dynamic_cast<GraphicsWidgetSequence*>(grid_info_left.HorizontalOrigin)) {
if(p_sequence->GetType() == MGASADMSignalSequence) {
QUuid track_id = p_sequence->GetTrackId();
for(int i = 0; i < mpComposition->GetSegmentCount(); i++) {
GraphicsWidgetSegment *p_segment = mpComposition->GetSegment(i);
if(p_segment) {
GraphicsWidgetSequence *p_sequence = p_segment->GetSequenceWithTrackId(track_id);
if(p_sequence && p_sequence->IsEmpty() == false) {
GraphicsWidgetSADMResource *p_resource_other = NULL;
for (int i=0; i < p_sequence->GetResourceCount(); i++) {
p_resource_other = dynamic_cast<GraphicsWidgetSADMResource*>(p_sequence->GetResource(i));
if (p_resource_other && p_resource_other->GetAsset()) break;
}
if(p_resource_other && p_resource_other->GetAsset()) {
if (error_text.isEmpty() && (p_resource_other->GetAsset()->GetMetadata().audioSamplingRate != p_origin_resource->GetAsset()->GetMetadata().audioSamplingRate)) {
error_text = tr("Audio sampling rate mismatch: %1 but %2 expected.").arg(p_origin_resource->GetAsset()->GetMetadata().audioSamplingRate.GetQuotient()).arg(p_resource_other->GetAsset()->GetMetadata().audioSamplingRate.GetName());

}
if (error_text.isEmpty() && (p_resource_other->GetAsset()->GetMetadata().editRate != p_origin_resource->GetAsset()->GetMetadata().editRate)) {
error_text = tr("MGA Edit rate mismatch: %1 fps but %2 fps expected.").arg(p_origin_resource->GetAsset()->GetMetadata().editRate.GetQuotient()).arg(p_resource_other->GetAsset()->GetMetadata().editRate.GetName());

}
}
}
}
}
}
}
else {
if (((p_origin_resource->GetAsset()->GetEditRate().GetNumerator() % GetCplEditRate().GetNumerator()) != 0)
|| (p_origin_resource->GetAsset()->GetEditRate().GetDenominator() != GetCplEditRate().GetDenominator())) {
error_text = tr("S-ADM edit rate mismatch: %1 or a multiple expected.").arg(GetCplEditRate().GetQuotient(), 0, 'f', 2);
} else if ((p_origin_resource->GetAsset()->GetAudioSamplingRate().GetNumerator() != 48000)
&& (p_origin_resource->GetAsset()->GetAudioSamplingRate().GetNumerator() != 96000)) {
error_text = tr("MGA S-ADM sampling rate mismatch: %1 Hz, 48000 or 96000 is expected.").arg(p_origin_resource->GetAsset()->GetAudioSamplingRate().GetQuotient(), 0, 'f', 0);
}

if (error_text.isEmpty()) {
rInfo.isDropable = true;
} else {
get_main_window()->statusBar()->setStyleSheet("QStatusBar{color:red}");
get_main_window()->statusBar()->showMessage(tr("S-ADM sample rate mismatch: %1 expected.").arg(GetCplEditRate().GetQuotient(), 0, 'f', 2), 5000);
get_main_window()->statusBar()->showMessage(error_text, 5000);
}
}

Expand Down Expand Up @@ -901,8 +936,24 @@ bool GraphicsSceneComposition::AppendEditCommand(const Timecode &rCplTimecode, Q

if(pRootCommand) {
for(int i = 0; i < resources.size(); i++) {
AbstractGraphicsWidgetResource *p_resource = resources.at(i);
if(p_resource) {
AbstractGraphicsWidgetResource *p_resource = resources.at(i);
GraphicsWidgetAudioResource *p_audio_resource = qobject_cast<GraphicsWidgetAudioResource *>(p_resource);

if (p_audio_resource) {
GraphicsWidgetSequence *p_sequence = p_audio_resource->GetSequence();
Duration old_duration = p_audio_resource->GetSourceDuration();
Duration entry_point = p_audio_resource->GetEntryPoint();
Duration position_duration = rCplTimecode.GetOverallFrames() * p_audio_resource->GetEditRate().GetNumerator() / p_audio_resource->GetEditRate().GetDenominator() * p_audio_resource->GetCplEditRate().GetDenominator() / p_audio_resource->GetCplEditRate().GetNumerator() + .5;
//Duration position_duration = p_audio_resource->ResourceErPerCompositionEr(p_audio_resource->GetEditRate()) * rCplTimecode.GetOverallFrames();
Duration new_duration = (position_duration - entry_point).GetCount() % old_duration.GetCount();
if(new_duration == 0) continue;
GraphicsWidgetAudioResource *p_clone = p_audio_resource->Clone();
addItem(p_clone);
new EditCommand(p_audio_resource, p_audio_resource->GetSourceDuration(), new_duration,
p_clone, p_audio_resource->GetSourceDuration(), old_duration - new_duration,
p_clone->GetEntryPoint(), p_audio_resource->GetEntryPoint() + new_duration,
p_sequence->GetResourceIndex(p_audio_resource) + 1, p_sequence, pRootCommand);
} else if(p_resource) {
GraphicsWidgetSequence *p_sequence = p_resource->GetSequence();
Duration old_duration = p_resource->MapToCplTimeline(p_resource->GetSourceDuration());
Timecode current_frame(rCplTimecode);
Expand Down
2 changes: 1 addition & 1 deletion src/GraphicsCommon.h
Expand Up @@ -136,9 +136,9 @@ class GraphicsWidgetBase : public QGraphicsWidget, public AbstractGridExtension
GraphicsWidgetBase(QGraphicsItem *pParent = NULL);
virtual ~GraphicsWidgetBase() {}
virtual int type() const { return GraphicsWidgetBaseType; }
EditRate GetCplEditRate() const;

protected:
EditRate GetCplEditRate() const;
virtual void CplEditRateChanged() {}
virtual bool ExtendGrid(QPointF &rPoint, eGridPosition which) const { return false; }
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &rValue);
Expand Down

0 comments on commit a38e14a

Please sign in to comment.