Skip to content

Commit

Permalink
Check in version of ffmpeg source code that is known to work, since t…
Browse files Browse the repository at this point in the history
…he released version do not.

Generalize loading of single volumes, not just movies.
Rearranged mutex locking in certain AnnotationWidget methods, in hope of avoiding sporadic hanging observed by Tanya.
Created stubs for manual loading of reference and neuron mask.  Not working yet.
  • Loading branch information
cmbruns committed Jun 7, 2012
1 parent 3846a30 commit cff4fa1
Show file tree
Hide file tree
Showing 11 changed files with 215 additions and 41 deletions.
2 changes: 1 addition & 1 deletion v3d.config
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// ADD PREDEFINED MACROS HERE!
#define ENABLE_FFMPEG
#define USE_FFMPEG
20 changes: 11 additions & 9 deletions v3d_main/neuron_annotator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ if(USE_FFMPEG)
)
set(av_dir "${CMAKE_CURRENT_BINARY_DIR}/libavcodec")
ExternalProject_Add(
LibAvcodec-0-11
LibAvcodec-0-10-2-head2012Apr25
DEPENDS Yasm-1-2-0
URL http://ffmpeg.org/releases/ffmpeg-0.11.tar.gz
# URL http://ffmpeg.org/releases/ffmpeg-0.10.3.tar.gz
# Use the exact distribution I developed against
URL ${CMAKE_CURRENT_SOURCE_DIR}/utility/ffmpeg-HEAD-cab15f9.tar.gz
SOURCE_DIR ${av_dir}/src
BINARY_DIR ${av_dir}/build
INSTALL_DIR ${av_dir}/install
Expand All @@ -113,20 +115,20 @@ if(USE_FFMPEG)
--extra-cflags="-D__STDC_CONSTANT_MACROS"
)
set(AVCODEC_INCLUDE_DIR "${av_dir}/install/include")
set(AVDEVICE_LIBRARY ${av_dir}/install/lib/libavdevice.a)
set(AVFORMAT_LIBRARY ${av_dir}/install/lib/libavformat.a)
set(AVFILTER_LIBRARY ${av_dir}/install/lib/libavfilter.a)
set(AVCODEC_LIBRARY ${av_dir}/install/lib/libavcodec.a)
set(SWSCALE_LIBRARY ${av_dir}/install/lib/libswscale.a)
set(AVUTIL_LIBRARY ${av_dir}/install/lib/libavutil.a)
set(AVDEVICE_LIBRARY ${av_dir}/install/lib/libavdevice.a CACHE INTERNAL "path to a library")
set(AVFORMAT_LIBRARY ${av_dir}/install/lib/libavformat.a CACHE INTERNAL "path to a library")
set(AVFILTER_LIBRARY ${av_dir}/install/lib/libavfilter.a CACHE INTERNAL "path to a library")
set(AVCODEC_LIBRARY ${av_dir}/install/lib/libavcodec.a CACHE INTERNAL "path to a library")
set(SWSCALE_LIBRARY ${av_dir}/install/lib/libswscale.a CACHE INTERNAL "path to a library")
set(AVUTIL_LIBRARY ${av_dir}/install/lib/libavutil.a CACHE INTERNAL "path to a library")

find_package(ZLIB)

include_directories(${AVCODEC_INCLUDE_DIR})
add_definitions(-DUSE_FFMPEG)
add_definitions(-D__STDC_CONSTANT_MACROS)

add_dependencies(NeuronAnnotatorLib LibAvcodec-0-11)
add_dependencies(NeuronAnnotatorLib LibAvcodec-0-10-2-head2012Apr25)
find_package(Threads)
target_link_libraries(NeuronAnnotatorLib
${SWSCALE_LIBRARY}
Expand Down
11 changes: 8 additions & 3 deletions v3d_main/neuron_annotator/data_model/MipFragmentColors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,22 @@ void MipFragmentColors::update()
size_t data_size = 0;
// qDebug() << "MipFragmentColors::update()" << __FILE__ << __LINE__;
{
DataColorModel::Reader colorReader(dataColorModel); // readlock two of two
if (dataColorModel.readerIsStale(colorReader)) return;

MipFragmentData::Reader mipReader(mipFragmentData); // readlock one of two
if (! mipReader.hasReadLock()) return;
if (mipReader.getNumberOfDataChannels() == 0) return; // what's the use?
DataColorModel::Reader colorReader(dataColorModel); // readlock two of two
if (dataColorModel.readerIsStale(colorReader)) return;
const Image4DProxy<My4DImage> mipProxy = mipReader.getMipProxy();
if (mipProxy.nbytes == 0)
return; // upstream data is invalid

if (! (colorReader.getNumberOfDataChannels() == mipReader.getNumberOfDataChannels()) )
{
qDebug() << "Error: color model does not match data model";
return;
}
const Image4DProxy<My4DImage> mipProxy = mipReader.getMipProxy();

const Image4DProxy<My4DImage> intensityProxy = mipReader.getIntensityProxy();
int refIndex = intensityProxy.sz - 1; // relative to fragment indices

Expand Down
114 changes: 112 additions & 2 deletions v3d_main/neuron_annotator/data_model/NaVolumeData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,27 @@ void NaVolumeData::loadVolumeDataFromFiles()
emit dataChanged();
}

/* slot */
bool NaVolumeData::loadChannels(QString fileName) // includes loading general volumes
{
bool bSucceeded = false;
int channel_count = 0;
emit progressMessageChanged("Loading single volume file"); // emit outside of lock block
{
Writer writer(*this);
channel_count = writer.loadChannels(fileName);
if (channel_count > 0)
bSucceeded = true;
} // release lock before emitting
if (bSucceeded) {
emit channelsLoaded(channel_count);
emit dataChanged();
}
else
emit progressAborted("Data stack load failed");
return bSucceeded;
}

/* slot */
bool NaVolumeData::loadSingleImageMovieVolume(QString fileName)
{
Expand All @@ -270,6 +291,59 @@ bool NaVolumeData::loadSingleImageMovieVolume(QString fileName)
return bSucceeded;
}

/* slot */
bool NaVolumeData::loadReference(QString fileName)
{
bool bSucceeded = false;
emit progressMessageChanged("Loading reference channel"); // emit outside of lock block
{
Writer writer(*this);
if (writer.loadReference(fileName))
bSucceeded = true;
}

if (bSucceeded)
emit referenceLoaded();
else
emit progressAborted("Reference load failed");
return bSucceeded;
}

/* slot */
bool NaVolumeData::loadOneChannel(QString fileName, int channel_index) // includes loading general volumes
{
bool bSucceeded = false;
emit progressMessageChanged(QString("Loading data channel %1").arg(channel_index)); // emit outside of lock block
{
Writer writer(*this);
if (writer.loadOneChannel(fileName, channel_index))
bSucceeded = true;
}
if (bSucceeded)
emit channelLoaded(channel_index);
else
emit progressAborted("Channel load failed");
return bSucceeded;
}

/* slot */
bool NaVolumeData::loadNeuronMask(QString fileName)
{
bool bSucceeded = false;
emit progressMessageChanged("Loading neuron mask"); // emit outside of lock block
{
Writer writer(*this);
if (writer.loadNeuronMask(fileName))
bSucceeded = true;
}
if (bSucceeded)
emit neuronMaskLoaded();
else
emit progressAborted("Neuron mask load failed");
return bSucceeded;
}


//////////////////////////////////
// NaVolumeData::Writer methods //
//////////////////////////////////
Expand Down Expand Up @@ -323,9 +397,25 @@ bool NaVolumeData::Writer::loadSingleImageMovieVolume(QString fileName)
#endif
}

int NaVolumeData::Writer::loadChannels(QString fileName) // includes loading general volumes
{
qDebug() << "NaVolumeData::Writer::loadChannels()" << fileName;
My4DImage* img = new My4DImage();
ImageLoader loader;
if (! loader.loadImage(img, fileName) ) {
delete img;
return 0;
}
if (! setSingleImageVolume(img)) {
delete img;
return 0;
}
return img->getCDim();
}

bool NaVolumeData::Writer::setSingleImageVolume(My4DImage* img)
{
qDebug() << "NaVolumeData::Writer::loadSingleImageMovieVolume";
qDebug() << "NaVolumeData::Writer::setSingleImageVolume";
if (m_data->originalImageStack == img)
return false; // no change
if (NULL == img)
Expand All @@ -340,7 +430,8 @@ bool NaVolumeData::Writer::setSingleImageVolume(My4DImage* img)
img->updateminmaxvalues();
m_data->originalImageProxy = Image4DProxy<My4DImage>(m_data->originalImageStack);
m_data->originalImageProxy.set_minmax(m_data->originalImageStack->p_vmin, m_data->originalImageStack->p_vmax);
// Populate histgrams
// TODO - for speed, deprecate or move histogram computation
// Populate histograms
m_data->histograms.assign((size_t)(m_data->originalImageProxy.sc), IntensityHistogram());
for(int c = 0; c < m_data->originalImageProxy.sc; ++c)
m_data->histograms[c].populate(m_data->originalImageProxy, c);
Expand Down Expand Up @@ -475,6 +566,25 @@ bool NaVolumeData::Writer::loadStacks()
return true;
}

bool NaVolumeData::Writer::loadReference(QString fileName)
{
assert(false); // TODO
return false;
}

bool NaVolumeData::Writer::loadOneChannel(QString fileName, int channel_index) // includes loading general volumes
{
assert(false); // TODO
return false;
}

bool NaVolumeData::Writer::loadNeuronMask(QString fileName)
{
assert(false); // TODO
return false;
}


//////////////////////////////////
// NaVolumeData::Reader methods //
//////////////////////////////////
Expand Down
20 changes: 19 additions & 1 deletion v3d_main/neuron_annotator/data_model/NaVolumeData.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,25 @@ class NaVolumeData : public NaLockableData
explicit NaVolumeData();
virtual ~NaVolumeData();

signals:
void referenceLoaded();
void channelLoaded(int channel_index);
void channelsLoaded(int channel_count);
void neuronMaskLoaded();

public slots:
bool loadChannels(QString fileName); // includes loading general volumes
bool loadSingleImageMovieVolume(QString fileName);

protected slots:
void loadVolumeDataFromFiles(); // Assumes file name paths have already been set
void setProgressValue(int progressValue);
void setProgressMessage(QString message) {emit progressMessageChanged(message);}
void setStackLoadProgress(int progressValue, int stackIndex);
bool loadSingleImageMovieVolume(QString fileName);

bool loadReference(QString fileName);
bool loadOneChannel(QString fileName, int channel_index = 0);
bool loadNeuronMask(QString fileName);

private:
QString originalImageStackFilePath;
Expand Down Expand Up @@ -134,6 +147,11 @@ public slots:
bool loadSingleImageMovieVolume(QString fileName);
bool setSingleImageVolume(My4DImage* img);

bool loadReference(QString fileName);
bool loadOneChannel(QString fileName, int channel_index = 0);
int loadChannels(QString fileName); // includes loading general volumes
bool loadNeuronMask(QString fileName);

private:
NaVolumeData * m_data;
};
Expand Down
46 changes: 27 additions & 19 deletions v3d_main/neuron_annotator/gui/AnnotationWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,26 +679,32 @@ void AnnotationWidget::selectEntity(const Entity *entity)

void AnnotationWidget::selectEntity(const Entity *entity, const bool external)
{
QMutexLocker locker(&mutex);
qDebug() << "AnnotationWidget::selectEntity"<<(entity==0?"None":*entity->name)<<"external?"<<external;

if ((selectedEntity==entity) || (selectedEntity!=0 && entity!=0 && *selectedEntity->id==*entity->id)) return;
selectedEntity = entity;
ui->annotatedBranchTreeView->clearSelection();
if (entity!=0) ui->annotatedBranchTreeView->selectEntity(*entity->id);
{
QMutexLocker locker(&mutex);

if ((selectedEntity==entity) || (selectedEntity!=0 && entity!=0 && *selectedEntity->id==*entity->id)) return;
selectedEntity = entity;
ui->annotatedBranchTreeView->clearSelection();
if (entity!=0) ui->annotatedBranchTreeView->selectEntity(*entity->id);
} // release lock before emit
emit entitySelected(selectedEntity);

if (!external)
{
if (entity!=0)
QMutexLocker locker(&mutex);
if (!external)
{
qDebug() << "AnnotationWidget::selectEntity (notifying console)"<<*entity->id;
selectEntityThread = new SelectEntityThread(*entity->id);
selectEntityThread->start(QThread::NormalPriority);
}
else
{
// TODO: deselectEntity event?
if (entity!=0)
{
qDebug() << "AnnotationWidget::selectEntity (notifying console)"<<*entity->id;
selectEntityThread = new SelectEntityThread(*entity->id);
selectEntityThread->start(QThread::NormalPriority);
}
else
{
// TODO: deselectEntity event?
}
}
}
}
Expand Down Expand Up @@ -726,18 +732,20 @@ void AnnotationWidget::selectEntityById(const qint64 & entityId)

void AnnotationWidget::selectEntityById(const qint64 & entityId, const bool external)
{
QMutexLocker locker(&mutex);
qDebug() << "AnnotationWidget::selectEntityById"<<entityId<<"external?"<<external;
{
QMutexLocker locker(&mutex);

if (annotatedBranch==0) return;
Entity *entity = annotatedBranch->getEntityById(entityId);
if (entity!=0) selectEntity(entity, external);
if (annotatedBranch==0) return;
Entity *entity = annotatedBranch->getEntityById(entityId);
if (entity!=0) selectEntity(entity, external);
}
}

void AnnotationWidget::selectNeuron(int index)
{
QMutexLocker locker(&mutex);
qDebug() << "AnnotationWidget::selectNeuron"<<index;
QMutexLocker locker(&mutex);

if (!annotatedBranch) return;

Expand Down
9 changes: 7 additions & 2 deletions v3d_main/neuron_annotator/gui/NaMainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,12 +490,17 @@ void NaMainWindow::on_actionOpen_Single_Movie_Stack_triggered()
/* slot */
bool NaMainWindow::loadSingleVolumeMovieFile(QString fileName)
{
bool bSucceeded = false; // start pessimistic
onDataLoadStarted();
DataFlowModel* dfm = new DataFlowModel();
setDataFlowModel(*dfm);
bool result = dataFlowModel->getVolumeData().loadSingleImageMovieVolume(fileName);

int num_channels = dataFlowModel->getVolumeData().loadChannels(fileName);
if (num_channels > 0)
bSucceeded = true;

onDataLoadFinished();
return result;
return bSucceeded;
}

/* slot */
Expand Down
Loading

0 comments on commit cff4fa1

Please sign in to comment.