]> git.vomp.tv Git - vompclient.git/blob - imageomx.h
Remove deprecated max() function
[vompclient.git] / imageomx.h
1 /*
2     Copyright 2004-2005 Chris Tallon, 2009,2012, 2014 Marten Richter
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 IMAGEOMX_H
21 #define IMAGEOMX_H
22
23 #include <stdio.h>
24 #include <unistd.h>
25 #include <fcntl.h>
26 #include <sys/ioctl.h>
27 #include <mutex>
28
29 #include <EGL/egl.h>
30 #include <EGL/eglext.h>
31
32 #include "defines.h"
33 #include "osdvector.h"
34 #include "videoomx.h"
35
36 #include "eglpicturecreator.h"
37
38
39
40 class ImageOMX : public OsdVector::PictureDecoder
41 {
42   friend class VideoOMX;
43   public:
44     ImageOMX(OsdVector::PictureReader * treader);
45     virtual ~ImageOMX();
46
47     void init();
48     void shutdown();
49
50     unsigned char* decodePicture(LoadIndex index, unsigned char * buffer, unsigned int length, bool freemem);
51     bool getDecodedPicture(struct OsdVector::PictureInfo& pict_inf);
52     void freeReference(void * ref);
53
54   private:
55
56     static OMX_ERRORTYPE EmptyBufferDone_OMX(OMX_IN OMX_HANDLETYPE hcomp,OMX_IN OMX_PTR appdata,OMX_IN OMX_BUFFERHEADERTYPE* bulibaver);
57     static OMX_ERRORTYPE FillBufferDone_OMX(OMX_IN OMX_HANDLETYPE hcomp, OMX_IN OMX_PTR appdata,OMX_IN OMX_BUFFERHEADERTYPE* bulibaver);
58
59
60     bool intDecodePicture(LoadIndex index, unsigned char * buffer, unsigned int length, EGLPictureCreator* egl_pict, VideoOMX *video);
61
62     void ReturnEmptyOMXBuffer(OMX_BUFFERHEADERTYPE* bulibaver);
63     void ReturnFillOMXBuffer(OMX_BUFFERHEADERTYPE* buffer);
64
65
66     OMX_HANDLETYPE omx_imag_decode;
67     OMX_HANDLETYPE omx_egl_render;
68
69     OMX_U32 omx_image_input_port;
70     OMX_U32 omx_image_output_port;
71
72     OMX_U32 omx_egl_input_port;
73     OMX_U32 omx_egl_output_port;
74
75
76     int AllocateCodecsOMX( unsigned char * buffer, unsigned int length);
77     int DeAllocateCodecsOMX();
78
79     int PrepareInputBufsOMX(bool setportdef, unsigned char * buffer, unsigned int length);
80     int DestroyInputBufsOMX();
81     int DestroyInputBufsOMXwhilePlaying();
82
83     enum ImageFormats {
84         Unsupported,
85         Jpeg,
86         PNG
87     };
88
89     enum ImageFormats curformat;
90
91
92
93     std::vector<OMX_BUFFERHEADERTYPE*> input_bufs_omx_all;
94     std::list<OMX_BUFFERHEADERTYPE*> input_bufs_omx_free;
95     //list<OMX_BUFFERHEADERTYPE*> output_bufs_omx_full;
96     std::mutex input_bufs_omx_mutex;
97
98     bool omx_running;
99     bool omx_first_frame;
100     bool omx_egl_filled;
101
102     OMX_BUFFERHEADERTYPE *buf_head_egl;
103
104     int initted;
105
106     char L_VPE_OMX_IMAGE_DECODER[128];
107     char L_VPE_OMX_EGL_REND[128];
108
109   protected:
110     OsdVector::PictureInfo pictInf;
111     bool pictInfValid;
112
113 };
114
115 #endif