2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FMedia_BmpDecoder.h
20 * @brief This is header file for _BmpDecoder class.
23 #ifndef _FMEDIA_INTERNAL_BMP_DECODER_H_
24 #define _FMEDIA_INTERNAL_BMP_DECODER_H_
26 #include <unique_ptr.h>
27 #include "FMedia_IImageDecoder.h"
29 namespace Tizen { namespace Media
33 : public _IImageDecoder
34 , public Tizen::Base::Object
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;
44 virtual ~_BmpDecoder(void);
47 * Constructs this instancce with given buffer and length.
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.
55 virtual result Construct(const byte* buffer, int length, MediaPixelFormat pixelFormat);
58 * Decodes current frame and returns decoded data.
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.
66 virtual byte* DecodeN(int& outLength);
69 * Sets the decoding region. @n
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.
77 virtual result SetDecodingRegion(int x, int y, int width, int height);
80 * Gets current dimension of image.
82 * @return An error code
83 * @param[out] width The width of image.
84 * @param[out] height The height of image.
86 virtual result GetDimension(int& width, int& height);
89 * Gets the output pixel format.
91 * @return The output pixel format.
93 virtual MediaPixelFormat GetPixelFormat(void);
97 * Initializes the ffmpeg codec and codec context.
99 * @return An error code
100 * @exception E_SUCCESS The method is successful.
101 * @exception E_SYSTEM Error occured when initializing FFMPEG resources.
103 result OpenCodec(void);
106 * Uninitializes the ffmpeg codec and codec context.
108 void CloseCodec(void);
110 AVCodecContext* __pCodecCtx;
112 AVFrame* __pVideoFrame;
113 std::unique_ptr<byte[]> __pSrcBuf;
115 MediaPixelFormat __pixelFormat;
117 _BmpDecoder(const _BmpDecoder& rhs);
118 _BmpDecoder& operator =(const _BmpDecoder& rhs);
120 }; // class _BmpDecoder