Program: gdcm
Module: $RCSfile: gdcmDocument.cxx,v $
Language: C++
- Date: $Date: 2007/07/27 21:21:48 $
- Version: $Revision: 1.366 $
+ Date: $Date: 2007/08/21 12:51:09 $
+ Version: $Revision: 1.367 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// attributes have to be LO (Long String) and the VM shall be equal to 1
realVR = "LO";
- // Seems not to be true
- // Still in gdcmtk, David Clunnie disagrees, Marco Eichelberg says it's OK ...
- // We let it for a while?
- //(We should check length==4, for more security, but we don't have it yet !)
+ // Seems not to be true
+ // Still in gdcmtk, David Clunnie disagrees, Marco Eichelberg says it's OK ...
+ // We let it for a while?
+ //(We should check length==4, for more security, but we don't have it yet !)
else if ( CurrentElem == 0x0001)
realVR = "UL"; // Private Group Length To End
}
Module: $RCSfile: gdcmFileHelper.cxx,v $
Language: C++
- Date: $Date: 2007/07/26 08:36:49 $
- Version: $Revision: 1.119 $
+ Date: $Date: 2007/08/21 12:51:09 $
+ Version: $Revision: 1.120 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
{
if (e->GetVR() == " ")
{
-
SetWriteTypeToDcmImplVR();
SetWriteFileTypeToImplicitVR();
flag = true;
}
bool check = CheckWriteIntegrity(); // verifies length
- if (WriteType == JPEG || WriteType == JPEG2000)
+ if (WriteType == JPEG || WriteType == JPEG2000)
check = true;
if (check)
photInt->SetString("PALETTE COLOR ");
}
else
- {
+ {
if (GetPhotometricInterpretation() == 2)
photInt->SetString("MONOCHROME2 "); // 0 = Black
else
photInt->SetString("MONOCHROME1 "); // 0 = White !
}
-
+
PixelWriteConverter->SetReadData(PixelReadConverter->GetRaw(),
PixelReadConverter->GetRawSize());
{
vr = "OW";
}
-
+
DataEntry *pixel =
CopyDataEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel(),vr);
pixel->SetFlag(DataEntry::FLAG_PIXELDATA);
pixel->SetBinArea(PixelWriteConverter->GetData(),false);
- pixel->SetLength(PixelWriteConverter->GetDataSize());
-
+ pixel->SetLength(
+ static_cast< uint32_t >(PixelWriteConverter->GetDataSize()) );
+
if (!FileInternal->HasLUT() && GetPhotometricInterpretation() == 1)
{
ConvertFixGreyLevels( pixel->GetBinArea(), pixel->GetLength() );
- }
+ }
Archive->Push(photInt);
Archive->Push(pixel);
if ( oldRow && oldCol )
{
std::string rows, columns;
-
+
DataEntry *newRow=DataEntry::New(0x0028, 0x0010, "US");
DataEntry *newCol=DataEntry::New(0x0028, 0x0011, "US");
-
+
newRow->Copy(oldCol);
newCol->Copy(oldRow);
CREATED_IMAGE
-4) user modified/added some tags *without processing* the pixels (anonymization...)
UNMODIFIED_PIXELS_IMAGE
--Probabely some more to be added.
+-Probabely some more to be added.
gdcm::FileHelper::CheckMandatoryElements() deals automatically with these cases.
// 'Media Storage SOP Class UID' --> [Secondary Capture Image Storage]
CopyMandatoryEntry(0x0002,0x0002,"1.2.840.10008.5.1.4.1.1.7","UI");
}
-
- // 'Media Storage SOP Instance UID'
+
+ // 'Media Storage SOP Instance UID'
CopyMandatoryEntry(0x0002,0x0003,sop,"UI");
-
+
// 'Implementation Class UID'
// FIXME : in all examples we have, 0x0002,0x0012 is not so long :
// seems to be Root UID + 4 digits (?)
if ( ContentType != USER_OWN_IMAGE) // when it's not a user made image
{
-
+
gdcmDebugMacro( "USER_OWN_IMAGE (1)");
- // If 'SOP Class UID' exists ('true DICOM' image)
+ // If 'SOP Class UID' exists ('true DICOM' image)
// we create the 'Source Image Sequence' SeqEntry
// to hold informations about the Source Image
Archive->Push(0x0028,0x0017);
Archive->Push(0x0028,0x0198); // very old versions
Archive->Push(0x0028,0x0199);
-
+
// Replace deprecated 0028 0012 US Planes
// by new 0028 0008 IS Number of Frames
-
+
///\todo : find if there is a rule!
DataEntry *e_0028_0012 = FileInternal->GetDataEntry(0x0028, 0x0012);
if ( e_0028_0012 )
std::ostringstream s;
// check 'Bits Allocated' vs decent values
int nbBitsAllocated = FileInternal->GetBitsAllocated();
- if ( nbBitsAllocated == 0 || nbBitsAllocated > 32
- || ( nbBitsAllocated > 8 && nbBitsAllocated <16) )
+ if ( (nbBitsAllocated == 0 || nbBitsAllocated > 32)
+ || ( nbBitsAllocated > 8 && nbBitsAllocated <16) )
{
CopyMandatoryEntry(0x0028,0x0100,"16","US");
gdcmWarningMacro("(0028,0100) changed from "
}
// check Pixel Representation (default it as 0 -unsigned-)
-
+
DataEntry *e_0028_0103 = FileInternal->GetDataEntry(0x0028, 0x0103);
if ( !e_0028_0103 )
{
// --> This one is the *legal* one !
if ( ContentType != USER_OWN_IMAGE)
// we write it only when we are *sure* the image comes from
- // an imager (see also 0008,0x0064)
+ // an imager (see also 0008,0x0064)
CheckMandatoryEntry(0x0018,0x1164,pixelSpacing,"DS");
/*
// See page 73 of ACR-NEMA_300-1988.pdf !
-// 0020,0020 : Patient Orientation :
+// 0020,0020 : Patient Orientation :
Patient direction of the first row and
column of the images. The first entry id the direction of the raws, given by the
direction of the last pixel in the first row from the first pixel in tha row.
the image system with respect to the same axes
//0020,0050 Location
-An image location reference, standard for the modality (such as CT bed
-position), used to indicate position. Calculation of position for other purposes
+An image location reference, standard for the modality (such as CT bed position),
+used to indicate position. Calculation of position for other purposes
is only from (0020,0030) and (0020,0035)
*/
-
+
/*
// if imagePositionPatient not found, default it with imagePositionRet, if any
// if imageOrientationPatient not found, default it with imageOrientationRet, if any
std::string imageOrientationRet = FileInternal->GetEntryString(0x0020,0x0035);
std::string imagePositionPatient = FileInternal->GetEntryString(0x0020,0x0032);
std::string imageOrientationPatient = FileInternal->GetEntryString(0x0020,0x0037);
-
+
if( imagePositionPatient == GDCM_UNFOUND && imageOrientationPatient == GDCM_UNFOUND
&& imagePositionRet != GDCM_UNFOUND && imageOrientationRet != GDCM_UNFOUND)
{
}
*/
- // Samples Per Pixel (type 1) : default to grayscale
+ // Samples Per Pixel (type 1) : default to grayscale
CheckMandatoryEntry(0x0028,0x0002,"1","US");
// --- Check UID-related Entries ---
if ( ContentType == USER_OWN_IMAGE)
{
- gdcmDebugMacro( "USER_OWN_IMAGE (2)");
+ gdcmDebugMacro( "USER_OWN_IMAGE (2)");
// Conversion Type.
// Other possible values are :
// See PS 3.3, Page 408
-
+
// DV = Digitized Video
// DI = Digital Interface
// DF = Digitized Film
// SI = Scanned Image
// DRW = Drawing
// SYN = Synthetic Image
-
+
CheckMandatoryEntry(0x0008,0x0064,"SYN","CS"); // Why not?
}
/*
}
*/
-
+
// ---- The user will never have to take any action on the following ----
// new value for 'SOP Instance UID'
/*
// Deal with element 0x0000 (group length) of each group.
// First stage : get all the different Groups
-
+
GroupHT grHT;
DocEntry *d = FileInternal->GetFirstEntry();
while(d)
}
}
-/// \todo : what is it used for ? (FileHelper::SetMandatoryEntry)
+/// \todo : what is it used for ? (FileHelper::SetMandatoryEntry)
void FileHelper::SetMandatoryEntry(uint16_t group,uint16_t elem,std::string value,const VRKey &vr)
{
//DataEntry *entry = DataEntry::New(Global::GetDicts()->GetDefaultPubDict()->GetEntry(group,elem));
Program: gdcm
Module: $RCSfile: gdcmFileHelper.h,v $
Language: C++
- Date: $Date: 2007/07/27 21:21:48 $
- Version: $Revision: 1.50 $
+ Date: $Date: 2007/08/21 12:51:09 $
+ Version: $Revision: 1.51 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
static FileHelper *New() {return new FileHelper();}
/// \brief Constructs a FileHelper with a RefCounter from a fileHelper
static FileHelper *New(File *header) {return new FileHelper(header);}
-
+
void Print(std::ostream &os = std::cout, std::string const &indent = "");
/// Accessor to \ref File
/// (as opposed to 'Grey pixels + Palettes color')
void SetWriteModeToRGB() { SetWriteMode(WMODE_RGB); }
/// \brief Sets the Write Mode ( )
- void SetWriteMode(FileMode mode) { WriteMode = mode; }
+ void SetWriteMode(FileMode mode) { WriteMode = mode; }
/// \brief Gets the Write Mode ( )
FileMode GetWriteMode() { return WriteMode; }
void SetWriteTypeToAcr() { SetWriteType(ACR); }
/// \brief Tells the writer we want to write as LibIDO
void SetWriteTypeToAcrLibido() { SetWriteType(ACR_LIBIDO); }
- /// \brief Tells the writer we want to write as JPEG
+ /// \brief Tells the writer we want to write as JPEG
void SetWriteTypeToJPEG() { SetWriteType(JPEG); }
/// \brief Tells the writer we want to write as JPEG2000
- void SetWriteTypeToJPEG2000() { SetWriteType(JPEG2000); }
+ void SetWriteTypeToJPEG2000() { SetWriteType(JPEG2000); }
/// \brief Tells the writer which format we want to write
/// (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO)
void SetWriteType(FileType format) { WriteType = format; }
/// \brief Gets the format we talled the write we wanted to write
/// (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO)
FileType GetWriteType() { return WriteType; }
- /// \brief 1 : white=0, black=high value
+ /// \brief 1 : white=0, black=high value
void SetPhotometricInterpretationToMonochrome1() {
PhotometricInterpretation = 1;}
- /// \brief 2 : black=0, white=high value (default)
+ /// \brief 2 : black=0, white=high value (default)
void SetPhotometricInterpretationToMonochrome2() {
PhotometricInterpretation = 2;}
- /// \brief 1 : white=0, black=high value
+ /// \brief 1 : white=0, black=high value
int GetPhotometricInterpretation() {
- return PhotometricInterpretation; }
-
+ return PhotometricInterpretation; }
+
// Write pixels of ONE image on hard drive
// No test is made on processor "endianness"
// The user must call his reader correctly
FileHelper( File *header );
~FileHelper();
- /// \todo move all those 'protected' methods to 'privete'
+ /// \todo move all those 'protected' methods to 'private'
/// since FileHelper is not derived in anything!
bool CheckWriteIntegrity();
void SetWriteFileTypeToACR();
void SetWriteFileTypeToJPEG();
- void SetWriteFileTypeToJPEG2000();
+ void SetWriteFileTypeToJPEG2000();
void SetWriteFileTypeToExplicitVR();
void SetWriteFileTypeToImplicitVR();
void RestoreWriteFileType();
void RestoreWriteOfLibido();
DataEntry *CopyDataEntry(uint16_t group, uint16_t elem,
- const VRKey &vr = GDCM_VRUNKNOWN);
+ const VRKey &vr = GDCM_VRUNKNOWN);
void CheckMandatoryElements();
void CheckMandatoryEntry(uint16_t group, uint16_t elem, std::string value,
- const VRKey &vr = GDCM_VRUNKNOWN);
+ const VRKey &vr = GDCM_VRUNKNOWN);
void SetMandatoryEntry(uint16_t group, uint16_t elem, std::string value,
- const VRKey &vr = GDCM_VRUNKNOWN);
+ const VRKey &vr = GDCM_VRUNKNOWN);
void CopyMandatoryEntry(uint16_t group, uint16_t elem, std::string value,
- const VRKey &vr = GDCM_VRUNKNOWN);
+ const VRKey &vr = GDCM_VRUNKNOWN);
void RestoreWriteMandatory();
private:
/// \brief (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO)
FileType WriteType;
-
+
/// \brief Pointer to a user supplied function to allow modification
/// of pixel order (e.g. : Mirror, UpsideDown, 90°Rotation, ...)
/// use as : void userSuppliedFunction(uint8_t *im, gdcm::File *f)
/// - he anonymized and image (*no* modif on the pixels)
ImageContentType ContentType;
- /// \brief 1 : white=0, black=high value
- /// 2 : black=0, white=high value (default)
+ /// \brief 1 : white=0, black=high value
+ /// 2 : black=0, white=high value (default)
int PhotometricInterpretation;
};
Program: gdcm
Module: $RCSfile: gdcmJpeg.cxx,v $
Language: C++
- Date: $Date: 2007/07/13 08:17:21 $
- Version: $Revision: 1.57 $
+ Date: $Date: 2007/08/21 12:51:09 $
+ Version: $Revision: 1.58 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
int image_width, int image_height, int numZ,
int sample_pixel, int bitsallocated, int quality)
{
-
(void)bitsallocated;
struct jpeg_compress_struct cinfo;
int row_stride; /* physical row width in image buffer */
/* Step 2: specify data destination (eg, a file) */
/* Note: steps 2 and 3 can be done in either order. */
- int fragment_size = inputlength;
+ int fragment_size = static_cast< int >( inputlength );
jpeg_stdio_dest(&cinfo, fp, fragment_size, 1);
/* Step 3: set parameters for compression */
Program: gdcm
Module: $RCSfile: gdcmMpeg.cxx,v $
Language: C++
- Date: $Date: 2007/05/23 14:18:10 $
- Version: $Revision: 1.11 $
+ Date: $Date: 2007/08/21 12:51:09 $
+ Version: $Revision: 1.12 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmDebug.h"
#include <fstream>
-
-
-typedef struct
-{
- std::ifstream *InFd;
-} istream;
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <fcntl.h>
extern "C" {
#define GLOBAL
#include "config.h"
#include "global.h"
-}
+/* private prototypes */
+static int video_sequence _ANSI_ARGS_((int *framenum));
+static int Decode_Bitstream _ANSI_ARGS_((void));
+static int Headers _ANSI_ARGS_((void));
+static void Initialize_Sequence _ANSI_ARGS_((void));
+static void Initialize_Decoder _ANSI_ARGS_((void));
+static void Deinitialize_Sequence _ANSI_ARGS_((void));
+//static void Process_Options _ANSI_ARGS_((int argc, char *argv[]));
-off_t my_seek(istream *infile, off_t offset, int whence)
-{
- //return fseek(infile->InFd,offset, whence);
- switch(whence)
- {
- case SEEK_SET:
- infile->InFd->seekg(offset, std::ios::beg);
- break;
- case SEEK_END:
- infile->InFd->seekg(offset, std::ios::end);
- break;
- case SEEK_CUR:
- infile->InFd->seekg(offset, std::ios::cur);
- break;
- }
- return infile->InFd->tellg();
-}
-ssize_t my_read(istream *infile, void *buf, size_t count)
-{
- //return fread(buf,1,count, infile->InFd);
- infile->InFd->read((char*)buf, count);
- return infile->InFd->gcount();
-}
-
-int my_close(istream *infile)
-{
- //return fclose(infile->InFd);
- infile->InFd->close();
- return 0;
-}
-
-namespace GDCM_NAME_SPACE
-{
-
-static int Headers();
-static void DeInitialize_Decoder()
-{
- free(Clip-384); /* I love magic number */
-}
-static void Deinitialize_Sequence()
+/* IMPLEMENTATION specific routines */
+static void Initialize_Decoder()
{
int i;
- /* First cleanup the static buffer in store.c */
- FreeStaticBuffer();
-
- /* clear flags */
- base.MPEG2_Flag=0;
+ /* Clip table */
+ if ( !(Clip=(unsigned char *)malloc(1024)) )
+ Error("Clip[] malloc failed\n");
- for(i=0;i<3;i++)
- {
- free(backward_reference_frame[i]);
- free(forward_reference_frame[i]);
- free(auxframe[i]);
+ Clip += 384;
- if (base.scalable_mode==SC_SPAT)
- {
- free(llframe0[i]);
- free(llframe1[i]);
- }
- }
+ for (i=-384; i<640; i++)
+ Clip[i] = (i<0) ? 0 : ((i>255) ? 255 : i);
- if (base.scalable_mode==SC_SPAT)
- free(lltmp);
+ /* IDCT */
+ if ( Reference_IDCT_Flag )
+ Initialize_Reference_IDCT();
+ else
+ Initialize_Fast_IDCT();
-#ifdef DISPLAY
- if (Output_Type==T_X11)
- Terminate_Display_Process();
-#endif
}
-/* mostly IMPLEMENTAION specific routines */
+/* mostly IMPLEMENTATION specific routines */
static void Initialize_Sequence()
{
int cc, size;
static int Table_6_20[3] = {6,8,12};
/* check scalability mode of enhancement layer */
- if (Two_Streams && (enhan.scalable_mode!=SC_SNR) && (base.scalable_mode!=SC_DP))
- Error("unsupported scalability mode\n");
-
+ if ( Two_Streams && (enhan.scalable_mode!=SC_SNR)
+ &&
+ (base.scalable_mode!=SC_DP) )
+ {
+ Error("unsupported scalability mode\n");
+ }
/* force MPEG-1 parameters for proper decoder behavior */
/* see ISO/IEC 13818-2 section D.9.14 */
- if (!base.MPEG2_Flag)
+ if ( !base.MPEG2_Flag )
{
progressive_sequence = 1;
progressive_frame = 1;
for (cc=0; cc<3; cc++)
{
- if (cc==0)
+ if ( cc==0 )
size = Coded_Picture_Width*Coded_Picture_Height;
else
size = Chroma_Width*Chroma_Height;
- if (!(backward_reference_frame[cc] = (unsigned char *)malloc(size)))
+ if ( !(backward_reference_frame[cc] = (unsigned char *)malloc(size)) )
Error("backward_reference_frame[] malloc failed\n");
- if (!(forward_reference_frame[cc] = (unsigned char *)malloc(size)))
+ if ( !(forward_reference_frame[cc] = (unsigned char *)malloc(size)) )
Error("forward_reference_frame[] malloc failed\n");
- if (!(auxframe[cc] = (unsigned char *)malloc(size)))
+ if ( !(auxframe[cc] = (unsigned char *)malloc(size)) )
Error("auxframe[] malloc failed\n");
- if(Ersatz_Flag)
- if (!(substitute_frame[cc] = (unsigned char *)malloc(size)))
+ if ( Ersatz_Flag )
+ if ( !(substitute_frame[cc] = (unsigned char *)malloc(size)) )
Error("substitute_frame[] malloc failed\n");
- if (base.scalable_mode==SC_SPAT)
+ if ( base.scalable_mode==SC_SPAT )
{
/* this assumes lower layer is 4:2:0 */
- if (!(llframe0[cc] = (unsigned char *)malloc((lower_layer_prediction_horizontal_size*lower_layer_prediction_vertical_size)/(cc?4:1))))
+ if ( !(llframe0[cc] = (unsigned char *)malloc((lower_layer_prediction_horizontal_size*lower_layer_prediction_vertical_size)/(cc?4:1))))
Error("llframe0 malloc failed\n");
- if (!(llframe1[cc] = (unsigned char *)malloc((lower_layer_prediction_horizontal_size*lower_layer_prediction_vertical_size)/(cc?4:1))))
+ if ( !(llframe1[cc] = (unsigned char *)malloc((lower_layer_prediction_horizontal_size*lower_layer_prediction_vertical_size)/(cc?4:1))))
Error("llframe1 malloc failed\n");
}
}
/* SCALABILITY: Spatial */
- if (base.scalable_mode==SC_SPAT)
+ if ( base.scalable_mode==SC_SPAT )
{
- if (!(lltmp = (short *)malloc(lower_layer_prediction_horizontal_size*((lower_layer_prediction_vertical_size*vertical_subsampling_factor_n)/vertical_subsampling_factor_m)*sizeof(short))))
+ if ( !(lltmp = (short *)malloc(lower_layer_prediction_horizontal_size*((lower_layer_prediction_vertical_size*vertical_subsampling_factor_n)/vertical_subsampling_factor_m)*sizeof(short))))
Error("lltmp malloc failed\n");
}
#endif /* DISPLAY */
}
-static int video_sequence(int *Bitstream_Framenumber)
-//int *Bitstream_Framenumber;
-{
- int Bitstream_Framenum;
- int Sequence_Framenum;
- int Return_Value;
-
- Bitstream_Framenum = *Bitstream_Framenumber;
- Sequence_Framenum=0;
-
- Initialize_Sequence();
-
- /* decode picture whose header has already been parsed in
- Decode_Bitstream() */
-
-
- Decode_Picture(Bitstream_Framenum, Sequence_Framenum);
-
- /* update picture numbers */
- if (!Second_Field)
- {
- Bitstream_Framenum++;
- Sequence_Framenum++;
- }
-
- /* loop through the rest of the pictures in the sequence */
- while ((Return_Value=Headers()))
- {
- Decode_Picture(Bitstream_Framenum, Sequence_Framenum);
-
- if (!Second_Field)
- {
- Bitstream_Framenum++;
- Sequence_Framenum++;
- }
- }
-
- /* put last frame */
- if (Sequence_Framenum!=0)
- {
- Output_Last_Frame_of_Sequence(Bitstream_Framenum);
- }
- Deinitialize_Sequence();
-
-#ifdef VERIFY
- Clear_Verify_Headers();
-#endif /* VERIFY */
+extern void Error(char *text)
+{
+ fprintf(stderr,text);
+ exit(1);
+}
- *Bitstream_Framenumber = Bitstream_Framenum;
- return(Return_Value);
+/* Trace_Flag output */
+void Print_Bits(int code, int bits, int len)
+{
+ int i;
+ for (i=0; i<len; i++)
+ printf("%d",(code>>(bits-1-i))&1);
}
static int Headers()
int ret;
ld = &base;
-
-
+
/* return when end of sequence (0) or picture
header has been parsed (1) */
ret = Headers();
- if(ret==1)
+ if ( ret==1 )
{
ret = video_sequence(&Bitstream_Framenum);
}
}
-/* IMPLEMENTATION specific routines */
-static void Initialize_Decoder()
+static void Deinitialize_Sequence()
{
int i;
- /* Clip table */
- if (!(Clip=(unsigned char *)malloc(1024)))
- Error("Clip[] malloc failed\n");
+ /* clear flags */
+ base.MPEG2_Flag=0;
- Clip += 384;
+ for(i=0;i<3;i++)
+ {
+ free(backward_reference_frame[i]);
+ free(forward_reference_frame[i]);
+ free(auxframe[i]);
- for (i=-384; i<640; i++)
- Clip[i] = (i<0) ? 0 : ((i>255) ? 255 : i);
+ if ( base.scalable_mode==SC_SPAT )
+ {
+ free(llframe0[i]);
+ free(llframe1[i]);
+ }
+ }
- /* IDCT */
- if (Reference_IDCT_Flag)
- Initialize_Reference_IDCT();
- else
- Initialize_Fast_IDCT();
+ if ( base.scalable_mode==SC_SPAT )
+ free(lltmp);
+#ifdef DISPLAY
+ if ( Output_Type==T_X11 )
+ Terminate_Display_Process();
+#endif
}
+static int video_sequence(int *Bitstream_Framenumber)
+{
+ int Bitstream_Framenum;
+ int Sequence_Framenum;
+ int Return_Value;
+
+ Bitstream_Framenum = *Bitstream_Framenumber;
+ Sequence_Framenum=0;
+
+ Initialize_Sequence();
+
+ /* decode picture whose header has already been parsed in
+ Decode_Bitstream() */
+
+
+ Decode_Picture(Bitstream_Framenum, Sequence_Framenum);
+
+ /* update picture numbers */
+ if ( !Second_Field )
+ {
+ Bitstream_Framenum++;
+ Sequence_Framenum++;
+ }
+
+ /* loop through the rest of the pictures in the sequence */
+ while ((Return_Value=Headers()))
+ {
+ Decode_Picture(Bitstream_Framenum, Sequence_Framenum);
+
+ if ( !Second_Field )
+ {
+ Bitstream_Framenum++;
+ Sequence_Framenum++;
+ }
+ }
+
+ /* put last frame */
+ if (Sequence_Framenum!=0)
+ {
+ Output_Last_Frame_of_Sequence(Bitstream_Framenum);
+ }
+
+ Deinitialize_Sequence();
+
+#ifdef VERIFY
+ Clear_Verify_Headers();
+#endif /* VERIFY */
+
+ *Bitstream_Framenumber = Bitstream_Framenum;
+ return(Return_Value);
+}
+} // End "C" extern
+
+namespace gdcm
+{
/**
* \brief routine for MPEG decompression
* @param fp pointer to an already open file descriptor
* @param length length
* @return 1 on success, 0 on error
*/
-bool ReadMPEGFile (std::ifstream *fp, char *image_buffer, size_t length)
+bool ReadMPEGFile (std::ifstream *fp, void *image_buffer, size_t length)
{
- std::streampos mpeg_start = fp->tellg(); // the MPEG stream in our case does not start at 0
+ int ret, code;
+
#if 0
fp->read((char*)image_buffer, length);
- std::ofstream out("/tmp/etiam.mpeg");
+ ofstream out("/tmp/etiam.mpeg");
out.write((char*)image_buffer, length);
out.close();
-#else
- (void)length;
#endif
- int ret, code;
- istream bos,eos;
- /*base.open_stream = my_open;*/
- base.seek_stream = my_seek;
- base.read_stream = my_read;
- base.close_stream = my_close;
-
- Verbose_Flag = 0;
- Output_Type = T_MEM; //store in mem
- Output_Picture_Filename = "/tmp/rec%d";
- hiQdither = 0;
- Frame_Store_Flag = 1;
- Spatial_Flag = 0;
- Lower_Layer_Picture_Filename = "";
- Reference_IDCT_Flag = 1;
- Trace_Flag = 0;
- Quiet_Flag = 0;
- Ersatz_Flag = 0;
- Substitute_Picture_Filename = "";
- Two_Streams = 0;
- Enhancement_Layer_Bitstream_Filename = "";
- Big_Picture_Flag = 0;
- Main_Bitstream_Flag = 1;
- Main_Bitstream_Filename = "/tmp/etiam.mpeg";
- Main_Bitstream_Filename = "/tmp/ts.mpg";
- Verify_Flag = 0;
- Stats_Flag = 0;
- User_Data_Flag = 0;
- OUTMEM = (char*)image_buffer;
+// Clear_Options();
+ /* decode command line arguments */
+// Process_Options(argc,argv);
+
+#ifdef DEBUG
+ Print_Options();
+#endif
ld = &base; /* select base layer context */
/* open MPEG base layer bitstream file(s) */
/* NOTE: this is either a base layer stream or a spatial enhancement stream */
-/* if ((base.Infile=open(Main_Bitstream_Filename,O_RDONLY|O_BINARY))<0) */
- /*base.Infile = ld->open_stream(Main_Bitstream_Filename);*/
- base.Infile = &bos;
-#ifdef FILESTAR
- //base.Infile->InFd = fopen(Main_Bitstream_Filename, "rb");
- //base.Infile->InFd.open(Main_Bitstream_Filename, std::ios::binary | std::ios::in);
- base.Infile->InFd = fp;
-#else
- base.Infile->InFd = open(Main_Bitstream_Filename,O_RDONLY|O_BINARY );
-#endif
- if( !base.Infile->InFd)
+#if 0
+ if ((base.Infile=open(Main_Bitstream_Filename,O_RDONLY|O_BINARY))<0)
{
fprintf(stderr,"Base layer input file %s not found\n", Main_Bitstream_Filename);
exit(1);
}
+#else
+ base.Infile = -1; //DEBUG
+#endif
- if(base.Infile != 0)
+ if ( base.Infile != 0 )
{
- Initialize_Buffer();
-
- if(Show_Bits(8)==0x47)
+ Initialize_Buffer();
+
+ if ( Show_Bits(8)==0x47 )
{
sprintf(Error_Text,"Decoder currently does not parse transport streams\n");
Error(Error_Text);
break;
}
- /*lseek(base.Infile, 0l, SEEK_SET);*/
- ld->seek_stream(base.Infile,mpeg_start,SEEK_SET);
+ //lseek(base.Infile, 0l, SEEK_SET);
+ //fp->seekg(mpeg_start, ios_base::beg);
Initialize_Buffer();
}
- if(base.Infile!=0)
+ if ( base.Infile!=0 )
{
- /*lseek(base.Infile, 0l, SEEK_SET);*/
- ld->seek_stream(base.Infile,mpeg_start,SEEK_SET);
+ //lseek(base.Infile, 0l, SEEK_SET);
+ //fp->seekg(mpeg_start, ios_base::beg);
}
Initialize_Buffer();
- if(Two_Streams)
+ if ( Two_Streams )
{
+ abort();
ld = &enhan; /* select enhancement layer context */
- /*if ((enhan.Infile = open(Enhancement_Layer_Bitstream_Filename,O_RDONLY|O_BINARY))<0)*/
- /*enhan.Infile = ld->open_stream(Enhancement_Layer_Bitstream_Filename);*/
- enhan.Infile = &eos;
-#ifdef FILESTAR
- //enhan.Infile->InFd = fopen(Main_Bitstream_Filename, "rb");
- enhan.Infile->InFd->open(Main_Bitstream_Filename, std::ios::binary|std::ios::in);
- abort();
-#else
- enhan.Infile->InFd = open(Enhancement_Layer_Bitstream_Filename,O_RDONLY|O_BINARY);
-#endif
- if (enhan.Infile->InFd)
+ if ( (enhan.Infile = open(Enhancement_Layer_Bitstream_Filename,O_RDONLY|O_BINARY))<0)
{
sprintf(Error_Text,"enhancment layer bitstream file %s not found\n",
Enhancement_Layer_Bitstream_Filename);
ret = Decode_Bitstream();
- /*close(base.Infile);*/
- ld->close_stream(base.Infile);
-
- if (Two_Streams)
- /*close(enhan.Infile);*/
- ld->close_stream(enhan.Infile);
+ //close(base.Infile);
- DeInitialize_Decoder();
-
-#if 0
- std::ofstream out2("/tmp/etiam.raw");
- out2.write((char*)image_buffer, 352*240*3*10);
- out2.close();
-#endif
+ if ( Two_Streams )
+ {
+ abort();
+ close(enhan.Infile);
+ }
return ret;
}
Program: gdcm
Module: $RCSfile: gdcmPixelWriteConvert.cxx,v $
Language: C++
- Date: $Date: 2007/07/13 08:17:21 $
- Version: $Revision: 1.14 $
+ Date: $Date: 2007/08/21 12:51:10 $
+ Version: $Revision: 1.15 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
{
const JpegPair &jp = *i;
if(i == v.begin() ){ assert( jp.first - first.first == 0); }
- uint32_t offset = jp.first - first.first;
- GDCM_NAME_SPACE::binary_write(*fp, offset);
+ uint32_t offset = (uint32_t)(jp.first - first.first);
+ gdcm::binary_write(*fp, offset);
//std::cerr << "Updating Table:" << jp.first - first.first << std::endl;
}
}
size_t end = of->tellp();
//static int i = 0;
JpegPair &jp = JpegFragmentSize[i];
- jp.second = end-beg;
+ jp.second = (uint32_t)(end-beg);
if( ((end-beg) % 2) )
{
of->put( '\0' );
UserData = new uint8_t[of_size];
memcpy(UserData, of->str().c_str(), of_size);
UserDataSize = of_size;
-
+ delete of;
}
bool gdcm_write_JPEG_file8 (std::ostream *fp, char *inputdata, size_t inputlength,
size_t end = of->tellp();
//static int i = 0;
JpegPair &jp = JpegFragmentSize[i];
- jp.second = end-beg;
+ jp.second = (uint32_t)(end-beg);
if( ((end-beg) % 2) )
{
of->put( '\0' );
UserData = new uint8_t[of_size];
memcpy(UserData, of->str().c_str(), of_size);
UserDataSize = of_size;
-
- std::cerr << "Sortie ds PixelWriteConvert::SetCompressJPEGUserData" << std::endl;
+ delete of;
}
Program: gdcm
Module: $RCSfile: gdcmValidator.cxx,v $
Language: C++
- Date: $Date: 2007/05/23 14:18:12 $
- Version: $Revision: 1.15 $
+ Date: $Date: 2007/08/21 12:51:10 $
+ Version: $Revision: 1.16 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
grHT[d->GetGroup()] = 0;
d=input->GetNextEntry();
}
- for (GroupHT::iterator it = grHT.begin(); it != grHT.end(); ++it)
+ for (GroupHT::iterator it = grHT.begin(); it != grHT.end(); ++it)
{
std::cout << std::hex << it->first << std::endl;
- }
+ }
*/
// berk for now SetInput do two things at the same time
while(d)
{
if ( DataEntry *v = dynamic_cast<DataEntry *>(d) )
- {
+ {
if ( v->GetVM() != GDCM_NAME_SPACE::GDCM_UNKNOWN )
if ( !CheckVM(v) )
{
if (v->GetVM() == "FIXME" )
std::cout << "For Tag " << v->GetKey() << " VM = ["
<< v->GetVM() << "]" << std::endl;
-
+
std::cout << "Tag (" << v->GetKey()
- << ")-> [" << v->GetName() << "] VR :" << v->GetVR()
+ << ")-> [" << v->GetName() << "] VR :" << v->GetVR()
<< " contains an illegal VM. Expected VM :["
- << v->GetVM() << "], value [" << v->GetString() << "]"
+ << v->GetVM() << "], value [" << v->GetString() << "]"
<< std::endl;
}
-
+
if ( v->GetReadLength() % 2 )
{
- std::cout << "Tag (" << v->GetKey()
+ std::cout << "Tag (" << v->GetKey()
<< ")-> [" << v->GetName() << "] has an uneven length :"
<< v->GetReadLength()
- << " [" << v->GetString() << "] "
- << std::endl;
+ << " [" << v->GetString() << "] "
+ << std::endl;
}
}
else