NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
decompress.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  libvideo: a library for SDI video processing.
4 
5  Copyright (c) University College London (UCL). All rights reserved.
6 
7  This software is distributed WITHOUT ANY WARRANTY; without even
8  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  PURPOSE.
10 
11  See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 
15 #pragma once
16 #ifndef LIBVIDEO_DECOMPRESS_H_924E20500947462F889F5AB92DA2C0FF
17 #define LIBVIDEO_DECOMPRESS_H_924E20500947462F889F5AB92DA2C0FF
18 
19 #include <video/dllexport.h>
20 #include <video/compress.h>
21 #include <string>
22 
23 
24 namespace video
25 {
26 
27 
28 #pragma warning(push)
29 #pragma warning(disable: 4275) // non dll-interface class '...' used as base for dll-interface class '...'
30 
31 class LIBVIDEO_DLL_EXPORTS DecompressorFailedException : public std::runtime_error
32 {
33 public:
34  DecompressorFailedException(const std::string& msg, int errorcode = 1);
35 };
36 
37 #pragma warning(pop)
38 
39 
40 // forward-decl
41 class DecompressorImpl;
42 
47 class LIBVIDEO_DLL_EXPORTS Decompressor
48 {
49 private:
50  // avoid header pollution
51  DecompressorImpl* pimpl;
52 
53 
54 #pragma warning(push)
55 #pragma warning(disable: 4251) // class ... needs to have dll-interface to be used by clients of class ...
56 
57  std::string filename;
58 
59 #pragma warning(pop)
60 
61 
62 public:
63  Decompressor(const std::string& filename);
64  ~Decompressor();
65 
66 
67 private:
68  // not implemented
69  Decompressor(const Decompressor& copyme);
70  Decompressor& operator=(const Decompressor& assignme);
71 
72 
73 public:
74  // to be able to seek, or decompress an arbitrary frame, we need to know
75  // where in the file the relevant data has been written to.
76  void update_index(unsigned int frameno, unsigned __int64 offset, FrameType::FT type);
77 
78  // retrieve what is already in the index, or was recovered.
79  bool get_index(unsigned int frameno, unsigned __int64* offset, FrameType::FT* type);
80 
81  // try to rebuild index by scanning the input file for start codes.
82  bool recover_index();
83 
84  // decompresses the requested frame into the targettexture.
85  // this is a blocking call: it will return once decompression has finished.
86 // bool decompress(unsigned int frameno, GLuint targettexture);
87 
88  // buffer is RGBA (4 bytes per pixel).
89  // buffersize is in bytes, pitch is bytes as well.
90  // returns true if successfully decoded.
91  // throws if the decoder barfs.
92  bool decompress(unsigned int frameno, void* buffer, std::size_t buffersize, unsigned int bufferpitch);
93 
94  // FIXME: coded dimensions are different from display dimensions! which one to return?
95  // i would go for display dimension because that is what compressor takes as input.
96  int get_width() const;
97  int get_height() const;
98 };
99 
100 
101 } // namespace
102 
103 #endif // LIBVIDEO_DECOMPRESS_H_924E20500947462F889F5AB92DA2C0FF
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1237
Definition: decompress.h:31
Definition: decompress.cxx:41
Definition: decompress.h:47
GLintptr offset
Definition: glew.h:1666
GLuint buffer
Definition: glew.h:1664
FT
Definition: compress.h:56
Definition: compress.cxx:30
GLsizei const GLcharARB ** string
Definition: glew.h:5194