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_JpegDecoder.h
20 * @brief This is header file for _JpegDecoder.
22 #ifndef _FMEDIA_INTERNAL_JPEG_DECODER_H_
23 #define _FMEDIA_INTERNAL_JPEG_DECODER_H_
25 #include "FMedia_IImageDecoder.h"
27 namespace Tizen { namespace Media
31 : public _IImageDecoder
32 , public Tizen::Base::Object
35 static const int MAX_WIDTH = 5000;
36 static const int MAX_HEIGHT = 5000;
37 static const int MAX_SIZE = 4096000; // 4Mbyte
40 * This is the default constructor for this class.
47 * This is the destructor for this class.
51 virtual ~_JpegDecoder(void);
54 * Constructs this instancce with given buffer and length.
56 * @return An error code
57 * @param[in] buffer The buffer that contains compressed data.
58 * @param[in] length The length of buffer.
59 * @exception E_SUCCESS The method is successful.
60 * @exception E_INVALID_ARG The input parameter is invalid.
62 virtual result Construct(const byte* buffer, int length, MediaPixelFormat pixelFormat);
65 * Decodes current frame and returns decoded data.
67 * @return An error code
68 * @param[out] outBuf The decoded frame buffer.
69 * @param[out] length The length of outBuf.
70 * @exception E_SUCCESS The method is successful.
71 * @exception E_OUT_OF_MEMORY Memory is insufficient.
72 * @exception E_INVALID_DATA The data is invalid.
74 virtual byte* DecodeN(int& length);
77 * Sets the decoding region. @n
79 * @return An error code
80 * @param[in] rect The decoding region.
81 * @exception E_SUCCESS The method is successful.
82 * @exception E_INVALID_ARG The input parameter is invalid.
83 * @exception E_UNSUPPORTED_OPERATION This method is unsupported.
85 virtual result SetDecodingRegion(int x, int y, int width, int height);
88 * Gets current dimension of image.
90 * @return An error code
91 * @param[out] width The width of image.
92 * @param[out] height The height of image.
93 * @param[out] pitch The pitch of image in bytes.
95 virtual result GetDimension(int& width, int& height);
98 * Gets the output pixel format.
100 * @return The output pixel format.
102 virtual MediaPixelFormat GetPixelFormat(void);
105 * Sets scale down degree.
107 * @return An error code
108 * @param[in] scaleDown The level of scale down.
109 * @exception E_SUCCESS The method is successful.
110 * @exception E_INVALID_ARG The input parameter is invalid.
111 * @exception E_UNSUPPORTED_OPERATION This method is unsupported.
113 virtual result SetScaleDown(int scaleDown);
116 * Gets the value of given key.
118 * @return An error code
119 * @param[in] key The key of the value.
120 * @param[out] value The output value.
121 * @exception E_SUCCESS The method is successful.
122 * @exception E_INVALID_ARG The input parameter is invalid.
123 * @exception E_UNSUPPORTED_OPERATION This method is unsupported.
125 virtual result GetValue(const Tizen::Base::String& key, Tizen::Base::Object &value);
128 _JpegDecoder(const _JpegDecoder&);
129 _JpegDecoder& operator =(const _JpegDecoder & __jpegDecoder);
132 static void JpegErrorExitStatic(struct jpeg_common_struct * decInfo);
133 void JpegErrorExit(void);
142 int __decodingRectWidth;
143 int __decodingRectHeight;
144 bool __isDecodeRegionEnabled;
145 struct jpeg_decompress_struct* __pDec;
146 struct jpeg_error_mgr* __pErr;
147 struct __jmp_buf_tag* __pJmp;
148 }; // class _JpegDecoder