]> git.vomp.tv Git - vompclient.git/blob - src/omx/omximagedecode.h
Switch to cmake
[vompclient.git] / src / omx / omximagedecode.h
1 /*
2     Copyright 2021 Chris Tallon
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
18 */
19
20 #ifndef OMXIMAGEDECODE_H
21 #define OMXIMAGEDECODE_H
22
23 #include "omx.h"
24
25 class OMX_Image_Decode : public OMX
26 {
27   friend class OMX;
28
29   public:
30     OMX_Image_Decode();
31     virtual ~OMX_Image_Decode();
32
33     bool init();
34     void shutdown();
35
36     void prepareInputBuffers(int dataSize);  // throws
37     void setFormat();  // throws
38     void setSliceHeight(int sliceHeight);  // throws
39
40     void allocateInputBuffers(char* data);  // throws
41     void allocateOutputBuffer();
42
43     void deallocateInputBuffers();  // throws
44     void deallocateOutputBuffer();  // throws
45
46     void sendToInput();  // throws
47
48     void waitForOutputPortSettingsChange();  // throws
49     void receiveFromOutput(char** data, int* nFlags); // throws // caller frees data
50     void getImageInfo(int* width, int* height, int* stride, int* sliceHeight);
51
52     void enableInput(bool wait = true) { enablePort(inputPort, true, wait); }  // throws
53     void disableInput(bool wait = true) { enablePort(inputPort, false, wait); }  // throws
54     void enableOutput(bool wait = true) { enablePort(outputPort, true, wait); }  // throws
55     void disableOutput(bool wait = true) { enablePort(outputPort, false, wait); }  // throws
56     void flushInputCommands(bool wait = true) { flushCommands(inputPort, wait); }
57     void flushOutputCommands(bool wait = true) { flushCommands(outputPort, wait); }
58
59     // Buffers callback overrides
60
61     OMX_ERRORTYPE cb_FillBufferDone(
62       OMX_IN OMX_HANDLETYPE handle, OMX_IN OMX_PTR appdata, OMX_IN OMX_BUFFERHEADERTYPE* buffer) override;
63
64     OMX_ERRORTYPE cb_EmptyBufferDone(
65       OMX_IN OMX_HANDLETYPE handle, OMX_IN OMX_PTR appdata, OMX_IN OMX_BUFFERHEADERTYPE* buffer) override;
66
67   protected:
68
69     OMX_U32 inputPort;
70     OMX_U32 outputPort;
71     OMX_BUFFERHEADERTYPE* inBuffer1{};
72     OMX_BUFFERHEADERTYPE* inBuffer2{};
73
74     unsigned int dataSize{};
75
76     OMX_PARAM_PORTDEFINITIONTYPE outputPortSettings;
77
78     OMX_BUFFERHEADERTYPE* outputBufferHeader{};
79 };
80
81 #endif