QCamera3PostProc.h revision c8d1059ae679132e7654708fdfca6ee221775187
1/* Copyright (c) 2012-2013, The Linux Foundataion. All rights reserved. 2 * 3 * Redistribution and use in source and binary forms, with or without 4 * modification, are permitted provided that the following conditions are 5 * met: 6 * * Redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer. 8 * * Redistributions in binary form must reproduce the above 9 * copyright notice, this list of conditions and the following 10 * disclaimer in the documentation and/or other materials provided 11 * with the distribution. 12 * * Neither the name of The Linux Foundation nor the names of its 13 * contributors may be used to endorse or promote products derived 14 * from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 */ 29 30#ifndef __QCamera3_POSTPROC_H__ 31#define __QCamera3_POSTPROC_H__ 32 33extern "C" { 34#include <mm_camera_interface.h> 35#include <mm_jpeg_interface.h> 36} 37//#include "QCamera3HWI.h" 38#include "QCameraQueue.h" 39#include "QCameraCmdThread.h" 40 41namespace qcamera { 42 43class QCamera3Exif; 44class QCamera3Channel; 45class QCamera3PicChannel; 46class QCamera3Stream; 47class QCamera3Memory; 48 49typedef struct { 50 uint32_t jobId; // job ID 51 uint32_t client_hdl; // handle of jpeg client (obtained when open jpeg) 52 mm_camera_super_buf_t *src_frame;// source frame (need to be returned back to kernel after done) 53 mm_camera_super_buf_t *src_reproc_frame; // original source frame for reproc if not NULL 54 mm_camera_super_buf_t *aux_frame;// source frame but from different stream 55 QCamera3Channel *aux_channel; 56} qcamera_jpeg_data_t; 57 58typedef struct { 59 uint32_t jobId; // job ID 60 mm_camera_super_buf_t *src_frame;// source frame (need to be returned back to kernel after done) 61} qcamera_pp_data_t; 62 63typedef struct { 64 mm_camera_super_buf_t *frame; // source frame that needs post process 65} qcamera_pp_request_t; 66 67typedef struct { 68 uint32_t jobId; // job ID (obtained when start_jpeg_job) 69 jpeg_job_status_t status; // jpeg encoding status 70 mm_jpeg_output_t out_data; // ptr to jpeg output buf 71} qcamera_jpeg_evt_payload_t; 72 73#define MAX_EXIF_TABLE_ENTRIES 14 74class QCamera3Exif 75{ 76public: 77 QCamera3Exif(); 78 virtual ~QCamera3Exif(); 79 80 int32_t addEntry(exif_tag_id_t tagid, 81 exif_tag_type_t type, 82 uint32_t count, 83 void *data); 84 uint32_t getNumOfEntries() {return m_nNumEntries;}; 85 QEXIF_INFO_DATA *getEntries() {return m_Entries;}; 86 87private: 88 QEXIF_INFO_DATA m_Entries[MAX_EXIF_TABLE_ENTRIES]; // exif tags for JPEG encoder 89 uint32_t m_nNumEntries; // number of valid entries 90}; 91 92class QCamera3PostProcessor 93{ 94public: 95 QCamera3PostProcessor(QCamera3PicChannel *ch_ctrl); 96 virtual ~QCamera3PostProcessor(); 97 98 int32_t init(jpeg_encode_callback_t jpeg_cb, void *user_data); 99 int32_t deinit(); 100 int32_t start(QCamera3Memory *mMemory, int index); 101 int32_t stop(); 102 int32_t processData(mm_camera_super_buf_t *frame); 103 int32_t processRawData(mm_camera_super_buf_t *frame); 104 int32_t processPPData(mm_camera_super_buf_t *frame); 105 int32_t processAuxiliaryData(mm_camera_buf_def_t *frame, 106 QCamera3Channel* pAuxiliaryChannel); 107 int32_t processJpegEvt(qcamera_jpeg_evt_payload_t *evt); 108 qcamera_jpeg_data_t *findJpegJobByJobId(uint32_t jobId); 109 void releaseJpegJobData(qcamera_jpeg_data_t *job); 110 111private: 112 int32_t sendEvtNotify(int32_t msg_type, int32_t ext1, int32_t ext2); 113 mm_jpeg_color_format getColorfmtFromImgFmt(cam_format_t img_fmt); 114 mm_jpeg_format_t getJpegImgTypeFromImgFmt(cam_format_t img_fmt); 115 int32_t getJpegEncodingConfig(mm_jpeg_encode_params_t& encode_parm, 116 QCamera3Stream *main_stream, 117 QCamera3Stream *thumb_stream); 118 int32_t encodeData(qcamera_jpeg_data_t *jpeg_job_data, 119 uint8_t &needNewSess); 120 void releaseSuperBuf(mm_camera_super_buf_t *super_buf); 121 static void releaseNotifyData(void *user_data, void *cookie); 122 int32_t processRawImageImpl(mm_camera_super_buf_t *recvd_frame); 123 124 static void releaseJpegData(void *data, void *user_data); 125 static void releasePPInputData(void *data, void *user_data); 126 static void releaseOngoingPPData(void *data, void *user_data); 127 128 static void *dataProcessRoutine(void *data); 129 130private: 131 QCamera3PicChannel *m_parent; 132 jpeg_encode_callback_t mJpegCB; 133 void * mJpegUserData; 134 mm_jpeg_ops_t mJpegHandle; 135 uint32_t mJpegClientHandle; 136 uint32_t mJpegSessionId; 137 138 QCamera3Exif * m_pJpegExifObj; 139 int8_t m_bThumbnailNeeded; 140 QCamera3Memory *mJpegMem; 141 int mJpegMemIndex; 142 143 QCameraQueue m_inputPPQ; // input queue for postproc 144 QCameraQueue m_ongoingPPQ; // ongoing postproc queue 145 QCameraQueue m_inputJpegQ; // input jpeg job queue 146 QCameraQueue m_ongoingJpegQ; // ongoing jpeg job queue 147 QCameraQueue m_inputRawQ; // input raw job queue 148 QCameraCmdThread m_dataProcTh; // thread for data processing 149}; 150 151}; // namespace qcamera 152 153#endif /* __QCamera3_POSTPROC_H__ */ 154