Added transparency support in RGB565 bitmap outputs, for gif decoder.
[framework/osp/image-core.git] / src / FMedia_BmpDecoder.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file   FMedia_BmpDecoder.h
20  * @brief  This is header file for _BmpDecoder class.
21  *
22  */
23 #ifndef _FMEDIA_INTERNAL_BMP_DECODER_H_
24 #define _FMEDIA_INTERNAL_BMP_DECODER_H_
25
26 #include <unique_ptr.h>
27 #include "FMedia_IImageDecoder.h"
28
29 namespace Tizen { namespace Media
30 {
31
32 class _BmpDecoder
33         : public _IImageDecoder
34         , public Tizen::Base::Object
35 {
36 public:
37         static const int MAX_SIZE = 15000000;
38         static const int MAX_WIDTH = 3000;
39         static const int MAX_HEIGHT = 3000;
40         static const int BYTES_PER_PIXEL_RGB565 = 2;
41
42         _BmpDecoder(void);
43
44         virtual ~_BmpDecoder(void);
45
46         /**
47          * Constructs this instancce with given buffer and length.
48          *
49          * @return         An error code
50          * @param[in]   buffer                          The buffer that contains compressed data.
51          * @param[in]   length                          The length of buffer.
52          * @exception   E_SUCCESS                 The method is successful.
53          * @exception   E_INVALID_ARG     The input parameter is invalid.
54          */
55         virtual result Construct(const byte* buffer, int length, MediaPixelFormat pixelFormat);
56
57         /**
58          *  Decodes current frame and returns decoded data.
59          *
60          *  @return              A buffer pointer of decoded data
61          *  @param[out]   outLength                             The length of outBuf.
62          *  @exception    E_SUCCESS                      The method is successful.
63          *  @exception    E_OUT_OF_MEMORY          Memory is insufficient.
64          *  @exception    E_INVALID_DATA                The data is invalid.
65          */
66         virtual byte* DecodeN(int& outLength);
67
68         /**
69          *  Sets the decoding region. @n
70          *
71          *  @return                An error code
72          *  @param[in]     rect                                    The decoding region.
73          *  @exception     E_SUCCESS                              The method is successful.
74          *  @exception     E_INVALID_ARG                          The input parameter is invalid.
75          *  @exception     E_UNSUPPORTED_OPERATION      This method is unsupported.
76          */
77         virtual result SetDecodingRegion(int x, int y, int width, int height);
78
79         /**
80          * Gets current dimension of image.
81          *
82          * @return               An error code
83          * @param[out]   width          The width of image.
84          * @param[out]   height    The height of image.
85          */
86         virtual result GetDimension(int& width, int& height);
87
88         /**
89          * Gets the output pixel format.
90          *
91          * @return                 The output pixel format.
92          */
93         virtual MediaPixelFormat GetPixelFormat(void);
94
95 private:
96         /**
97          *  Initializes the ffmpeg codec and codec context.
98          *
99          *  @return      An error code
100          *  @exception  E_SUCCESS       The method is successful.
101          *  @exception  E_SYSTEM        Error occured when initializing FFMPEG resources.
102          */
103         result OpenCodec(void);
104
105         /**
106          *  Uninitializes the ffmpeg codec and codec context.
107          */
108         void CloseCodec(void);
109
110         AVCodecContext* __pCodecCtx;
111         AVCodec* __pCodec;
112         AVFrame* __pVideoFrame;
113         std::unique_ptr<byte[]> __pSrcBuf;
114         int __srcLength;
115         MediaPixelFormat __pixelFormat;
116
117         _BmpDecoder(const _BmpDecoder& rhs);
118         _BmpDecoder& operator =(const _BmpDecoder& rhs);
119
120 }; // class _BmpDecoder
121
122
123 } } // Tizen::Media
124
125 #endif