ronnie
2022-10-14 1504bb53e29d3d46222c0b3ea994fc494b48e153
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
 
#ifndef __HAL_V4L2_CAMERA_DEVICE_H__
#define __HAL_V4L2_CAMERA_DEVICE_H__
 
/*
 * Contains declaration of a class V4L2CameraDevice.
 */
 
#include <ui/Rect.h>
#include <fcntl.h>
#include <utils/Thread.h>
#include <hardware/camera.h>
#include <type_camera.h>
 
#include "CameraPlatform.h"
#include "OSAL_Queue.h"
#include "SceneFactory/SceneModeFactory.h"
#include <memory/memoryAdapter.h>
#include <memory/sc_interface.h>
#include "tvd_interface.h"
#ifdef USE_DEINTERLACE_HW
#include "DiProcess.h"
#endif
 
#ifdef USE_SUNXI_CAMERA_H
#include <sunxi_camera.h>
#endif
#ifdef USE_CSI_VIN_DRIVER
#include <sunxi_camera_v2.h>
#endif
 
#ifdef USE_ISP
#include "AWIspApi.h"
#endif
 
#include "Libve_Decoder2.h"
#define    MAX_YUV_SENSOR_PICTURE_SIZE (2592*1936*3>>1)    //just for yuv sensor
#define MAX_PICTURE_SIZE (4608*3456*3>>1)
#define MAX_HDR_PICTURE_SIZE (4608*3456*3>>1)
 
namespace android {
 
class CameraHardware;
class CallbackNotifier;
class PreviewWindow;
#ifdef USE_DEINTERLACE_HW
class DiProcess;
#endif
#ifdef USE_ISP
class AWIspApi;
#endif
 
/*
 *
 */
typedef struct HALCameraInfo {
    char    device_name[16];        // device node name, such as "/dev/video0"
    int     device_id;                // device id for camera share with the same CSI
    int     facing;                 // facing front or back
    int     orientation;            //
    bool    fast_picture_mode;        //
    bool    is_uvc;                    // usb camera
    bool    is_vfe;
}HALCameraInfo;
 
enum TAKE_PICTURE_STATE {
    TAKE_PICTURE_NULL,            // do not take picture
    TAKE_PICTURE_NORMAL,        // stream off -> stream on -> take picture -> stream off -> stream on
    TAKE_PICTURE_FAST,            // normal mode but do not need to stream off/on
    TAKE_PICTURE_RECORD,         // take picture in recording
    TAKE_PICTURE_CONTINUOUS,
    TAKE_PICTURE_CONTINUOUS_FAST,
    TAKE_PICTURE_SMART,            // take smart picture
    TAKE_PICTURE_SCENE_MODE,    // take scene mode picture
};
enum CAMERA_TYPE {
    CAMERA_TYPE_CSI,
    CAMERA_TYPE_UVC,
    CAMERA_TYPE_TVIN_NTSC,
    CAMERA_TYPE_TVIN_PAL,
    CAMERA_TYPE_TVIN_YPBPR,
    CAMERA_TYPE_VFE,
    CAMERA_TYPE_VIR,
};
 
/*
 * V4L2CameraDevice
 */
class V4L2CameraDevice {
public:
    /* Constructs V4L2CameraDevice instance. */
    V4L2CameraDevice(CameraHardware* camera_hal,
                     PreviewWindow * preview_window,
                     CallbackNotifier * cb);
 
    /* Destructs V4L2CameraDevice instance. */
    ~V4L2CameraDevice();
 
    /***************************************************************************
     * V4L2Camera device abstract interface implementation.
     * See declarations of these methods in V4L2Camera class for
     * information on each of these methods.
     **************************************************************************/
 
public:
    struct ScCamMemOpsS* mMemOpsS;
    /* Connects to the camera device.
     * Since there is no real device to connect to, this method does nothing,
     * but changes the state.
     */
    status_t connectDevice(HALCameraInfo * halInfo);
 
    /* Disconnects from the camera device.
     * Since there is no real device to disconnect from, this method does
     * nothing, but changes the state.
     */
    status_t disconnectDevice();
 
    /* Starts the camera device. */
    status_t startDevice(int width, int height, uint32_t pix_fmt, bool video_hint);
 
    /* Stops the camera device. */
    status_t stopDevice();
 
    /* Gets current preview fame into provided buffer. */
    status_t getPreviewFrame(void* buffer);
 
    /* Starts delivering frames captured from the camera device.
     * This method will start the worker thread that would be pulling frames from
     * the camera device, and will deliver the pulled frames back to the emulated
     * camera via onNextFrameAvailable callback. This method must be called on a
     * connected instance of this class with a started camera device. If it is
     * called on a disconnected instance, or camera device has not been started,
     * this method must return a failure.
     * Param:
     *  one_burst - Controls how many frames should be delivered. If this
     *      parameter is 'true', only one captured frame will be delivered to the
     *      V4L2Camera. If this parameter is 'false', frames will keep
     *      coming until stopDeliveringFrames method is called. Typically, this
     *      parameter is set to 'true' only in order to obtain a single frame
     *      that will be used as a "picture" in takePicture method of the
     *      V4L2Camera.
     * Return:
     *  NO_ERROR on success, or an appropriate error status.
     */
    status_t startDeliveringFrames();
 
    /* Stops delivering frames captured from the camera device.
     * This method will stop the worker thread started by startDeliveringFrames.
     * Return:
     *  NO_ERROR on success, or an appropriate error status.
     */
    status_t stopDeliveringFrames();
 
    /***************************************************************************
     * Worker thread management overrides.
     * See declarations of these methods in V4L2Camera class for
     * information on each of these methods.
     **************************************************************************/
 
protected:
 
    // -------------------------------------------------------------------------
    // extended interfaces here <***** star *****>
    // -------------------------------------------------------------------------
 
    class DoCaptureThread : public Thread {
        V4L2CameraDevice*    mV4l2CameraDevice;
        bool                mRequestExit;
    public:
        DoCaptureThread(V4L2CameraDevice* dev) :
            Thread(false),
            mV4l2CameraDevice(dev),
            mRequestExit(false) {
        }
        void startThread() {
            run("CameraCaptureThread", PRIORITY_URGENT_DISPLAY);
        }
        void stopThread() {
            mRequestExit = true;
        }
        virtual bool threadLoop() {
            if (mRequestExit) {
                return false;
            }
            return mV4l2CameraDevice->captureThread();
        }
    };
 
    class DoPreviewThread : public Thread {
        V4L2CameraDevice*    mV4l2CameraDevice;
        bool                mRequestExit;
    public:
        DoPreviewThread(V4L2CameraDevice* dev) :
            Thread(false),
            mV4l2CameraDevice(dev),
            mRequestExit(false) {
        }
        void startThread() {
            run("CameraPreviewThread", PRIORITY_URGENT_DISPLAY);
        }
        void stopThread() {
            mRequestExit = true;
        }
        virtual bool threadLoop() {
            if (mRequestExit) {
                return false;
            }
            return mV4l2CameraDevice->previewThread();
        }
    };
 
    class DoPictureThread : public Thread {
        V4L2CameraDevice*    mV4l2CameraDevice;
        bool                mRequestExit;
    public:
        DoPictureThread(V4L2CameraDevice* dev) :
            Thread(false),
            mV4l2CameraDevice(dev),
            mRequestExit(false) {
        }
        void startThread() {
            run("CameraPictrueThread", PRIORITY_URGENT_DISPLAY);
        }
        void stopThread() {
            mRequestExit = true;
        }
        virtual bool threadLoop() {
            if (mRequestExit) {
                return false;
            }
            return mV4l2CameraDevice->pictureThread();
        }
    };
 
    class DoContinuousPictureThread : public Thread {
        V4L2CameraDevice*    mV4l2CameraDevice;
        bool                mRequestExit;
    public:
        DoContinuousPictureThread(V4L2CameraDevice* dev) :
            Thread(false),
            mV4l2CameraDevice(dev),
            mRequestExit(false) {
        }
        void startThread() {
            run("CameraContinuousPictrueThread", PRIORITY_URGENT_DISPLAY);
        }
        void stopThread() {
            mRequestExit = true;
        }
        virtual bool threadLoop() {
            if (mRequestExit) {
                return false;
            }
            return mV4l2CameraDevice->continuousPictureThread();
        }
    };
 
    class DoSmartPictureThread : public Thread {
        V4L2CameraDevice*    mV4l2CameraDevice;
        bool                mRequestExit;
    public:
        DoSmartPictureThread(V4L2CameraDevice* dev) :
            Thread(false),
            mV4l2CameraDevice(dev),
            mRequestExit(false) {
        }
        void startThread() {
            run("CameraSmartPictrueThread", PRIORITY_URGENT_DISPLAY);
        }
        void stopThread() {
            mRequestExit = true;
        }
        virtual bool threadLoop() {
            if (mRequestExit) {
                return false;
            }
            return mV4l2CameraDevice->smartPictureThread();
        }
    };
public:
 
    bool captureThread();
    bool previewThread();
    bool pictureThread();
    bool continuousPictureThread();
    bool smartPictureThread();
 
    int tryFmt(int format);                            // check if driver support this format
    int tryFmtSize(int * width, int * height);        // check if driver support this size
    int setFrameRate(int rate);                        // set frame rate from camera.cfg
    int getFrameRate();                                // get v4l2 device current frame rate
    int testFrameRate();
 
    int enumSize(char * pSize, int len);
    void getThumbSize(int* sub_w, int* sub_h);
    int getFullSize(int * full_w, int * full_h);
    int getSuitableThumbScale(int full_w, int full_h);
 
    int setImageEffect(int effect);
    int setWhiteBalance(int wb);
 
    int setTakePictureCtrl(enum v4l2_take_picture value);
 
    // exposure
    int setExposureMode(int mode);
    int setExposureCompensation(int val);
    int setExposureWind(int num, void *areas);
 
    int setFlashMode(int mode);
 
    // af
    int setAutoFocusInit();
    int setAutoFocusRelease();
    int setAutoFocusRange(int range);
    int setAutoFocusWind(int num, void *areas);
    int setAutoFocusStart();
    int setAutoFocusStop();
    int getAutoFocusStatus();
 
    int getGainValue();
    int getExpValue();
    int setGainValue(int Gain);
    int setExpValue(int Exp);
    int setHDRMode(void *hdr_setting);
    int getAeStat(struct isp_stat_buf *AeBuf);
    int getGammaStat(struct isp_stat_buf *GammaBuf);
    int getHistStat(struct isp_stat_buf *HistBuf);
    int getSnrValue();
    int set3ALock(int lock);
    void releasePreviewFrame(native_handle_t *handle); //release buffer handle
    void releasePreviewFrame(int index);            // Q buffer for encoder
 
    int getCurrentFaceFrame(void* frame, int* width, int* height);
    int getSensorType();        //get sensor type: raw or yuv
    int getExifInfo(struct isp_exif_attribute *exif_attri);
    int getHDRFrameCnt()
    {
        return mTakePictureFlag.bits.hdr_cnt;
    }
    int getTVINSystemType(int fd);
    int getCameraType();
    void setThumbUsedForVideo(bool isThumbUsedForVideo)
    {
        mIsThumbUsedForVideo = isThumbUsedForVideo;
    }
 
    void setVideoSize(int w, int h)
    {
        mVideoWidth = w;
        mVideoHeight = h;
    }
 
    inline void setCrop(int new_zoom, int max_zoom)
    {
        mNewZoom = new_zoom;
        mMaxZoom = max_zoom;
    }
 
    inline int getCaptureFormat()
    {
        return mCaptureFormat;
    }
 
    inline void setHwEncoder(bool hw)
    {
        mUseHwEncoder = hw;
    }
 
    inline void setTakePictureState(TAKE_PICTURE_STATE state)
    {
        pthread_mutex_lock(&mCaptureMutex);
        LOGD("setTakePictureState %d", state);
        mTakePictureState = state;
        pthread_mutex_unlock(&mCaptureMutex);
    }
 
    void startContinuousPicture();
    void stopContinuousPicture();
    void setContinuousPictureCnt(int cnt);
    void startSmartPicture();
    void stopSmartPicture();
 
    void startSceneModePicture(int scenemode);
    void stopSceneModePicture();
    status_t openSceneMode(const char* scenemode);
    void closeSceneMode();
    void stopPreviewThread();
    /*
     * State checkers.
     */
    inline bool isConnected() const {
        /* Instance is connected when its status is either"connected", or
         * "started". */
        return mCameraDeviceState == STATE_CONNECTED || mCameraDeviceState == STATE_STARTED;
    }
    inline bool isStarted() const {
        return mCameraDeviceState == STATE_STARTED;
    }
 
private:
    int openCameraDev(HALCameraInfo * halInfo);
    void closeCameraDev();
    int v4l2SetVideoParams(int width, int height, uint32_t pix_fmt);
    int v4l2setCaptureParams();
    int v4l2ReqBufs(int * buf_cnt);
    int v4l2QueryBuf();
    int v4l2StartStreaming();
    int v4l2StopStreaming();
    int v4l2UnmapBuf();
 
    int v4l2WaitCameraReady();
    int getPreviewFrame(v4l2_buffer *buf);
 
    void dealWithVideoFrameSW(V4L2BUF_t * pBuf);
    void dealWithVideoFrameHW(V4L2BUF_t * pBuf);
    void dealWithVideoFrameTest(V4L2BUF_t * pBuf);
 
    /* Checks if it's the time to push new frame to continuous picture.
     * Note that this method must be called while object is locked. */
    bool isContinuousPictureTime();
 
    bool isPreviewTime();
    void waitFaceDectectTime();
 
    void singalDisconnect();
public:
#ifdef USE_MP_CONVERT
    // use for YUYV to YUV420C
    void YUYVToYUV420C(const void* yuyv, void *yuv420, int width, int height);
    void NV21ToYV12(const void* nv21, void *yv12, int width, int height);
 
#endif
    void showformat(int format,char *str);
    void recoveryPreviewFrame();
    int mPreviewIsNull = -1;
 
    // be usb camera or not
    int                             mCameraType;
 
private:
    // -------------------------------------------------------------------------
    // private data
    // -------------------------------------------------------------------------
 
    /* Locks this instance for parameters, state, etc. change. */
    Mutex                           mObjectLock;
 
    // instance of CameraHardware
    CameraHardware *                 mCameraHardware;
 
    // instance of PreviewWindow
    PreviewWindow *                    mPreviewWindow;
 
    // instance of CallbackNotifier
    CallbackNotifier *                mCallbackNotifier;
 
    HALCameraInfo                    mHalCameraInfo;
 
    /* Defines possible states of the V4L2Camera device object.
     */
    enum CameraDeviceState {
        /* Object has been constructed. */
        STATE_CONSTRUCTED,
        /* Object has been connected to the physical device. */
        STATE_CONNECTED,
        /* Camera device has been started. */
        STATE_STARTED,
    };
 
    /* Object state. */
    CameraDeviceState               mCameraDeviceState;
 
    /* Defines possible states of the V4L2CameraDevice capture thread.
     */
    enum CaptureThreadState {
        /* Do not capture frame. */
        CAPTURE_STATE_NULL,
        /* Do not capture frame. */
        CAPTURE_STATE_PAUSED,
        /* Start capture frame. */
        CAPTURE_STATE_STARTED,
        /* exit thread*/
        CAPTURE_STATE_EXIT,
    };
 
    enum PreviewThreadState {
        /* Do not capture frame. */
        PREVIEW_STATE_NULL,
        /* Do not capture frame. */
        PREVIEW_STATE_PAUSED,
        /* Start capture frame. */
        PREVIEW_STATE_STARTED,
        /* exit thread*/
        PREVIEW_STATE_EXIT,
    };
    /* capture thread state. */
    CaptureThreadState                mCaptureThreadState;
    PreviewThreadState                mPreviewThreadState;
 
    // v4l2 device handle
    int                                mCameraFd;
 
    v4l2_sensor_type                mSensor_Type;
 
    int                                mFrameRate;
 
    TAKE_PICTURE_STATE                mTakePictureState;
    V4L2BUF_t                        mPicBuffer;
    bool                            mIsPicCopy;
 
    /* Frame width */
    int                             mFrameWidth;
 
    /* Frame height */
    int                             mFrameHeight;
 
    /* thumb Frame width */
    int                             mThumbWidth;
 
    /* thumb Frame height */
    int                             mThumbHeight;
 
    /* Timestamp of the current frame. */
    nsecs_t                         mCurFrameTimestamp;
 
    typedef struct v4l2_mem_map_t{
        void *    mem[NB_BUFFER];
        int     length;
        int             nShareBufFd[NB_BUFFER];
        int             nDmaBufFd[NB_BUFFER];
    }v4l2_mem_map_t;
    v4l2_mem_map_t                    mMapMem;
 
    /* the number of pictrue-addr we can get from V4L2,the value rely on the
    * macro we set to V4L2,in v4l2SetVideoParams Parameter pix_fmt
    * 1.nplanes = 1:we get yuv addr buf.m.planes[0]
    * 2.nplanes = 2:we get y addr from buf.m.planes[0] ,get uv addr from buf.m.planes[1]...
    * 3.nplanes = 3:we get y addr from buf.m.planes[0] ,get u addr from buf.m.planes[1],get v addr from buf.m.planes[2]...
    */
    unsigned int nplanes;
 
    // actually buffer counts
    int                                mBufferCnt;
 
    bool                            mUseHwEncoder;
 
    Rect                            mRectCrop;
    Rect                            mThumbRectCrop;
    int                                mNewZoom;
    int                                mLastZoom;
    int                                mMaxZoom;
    int                             mZoomRatio;
 
    int                                mCaptureFormat;        // the driver capture format
    int                                mVideoFormat;        // the user request format, it should convert video buffer format
                                                        // if mVideoFormat is different from mCaptureFormat.
    int                               mExposureBias;
//TOOLS FOR CAPTURE BITSTREAM
#if DBG_CAPTURE_STREAM_FROM_V4L2DEVICE_TAKEPICTURE||DBG_CAPTURE_STREAM_FROM_V4L2DEVICE_FORNV21||DBG_CAPTURE_STREAM_FROM_V4L2DEVICE_FORYUYV||DBG_CAPTURE_STREAM_FROM_V4L2DEVICE_FORMJPEG||DBG_CAPTURE_STREAM_FROM_V4L2DEVICE_FORH264
    FILE *fp_stream_from_v4l2device = NULL;
    int v4l2device_tail_num= 0;
    int frame_num0 = 0;
#endif
#if DBG_CAPTURE_STREAM_AFTER_TRANSFORMATION
    FILE *fp_stream_after_transformation = NULL;
    int afterTransformation_tail_num = 0;
    int frame_num1 = 0;
#endif
    typedef struct bufferManagerQ_t
    {
        unsigned long            buf_vir_addr[NB_BUFFER];
        unsigned long            buf_phy_addr[NB_BUFFER];
        int            write_id;
        int            read_id;
        int            buf_unused;
        int            nShareBufFd[NB_BUFFER];
        int            nDmaBufFd[NB_BUFFER];
    }bufferManagerQ_t;
 
    typedef struct bufferManagerQD_t {
        unsigned long            buf_vir_addr[NB_BUFFER * 2];
        unsigned long            buf_phy_addr[NB_BUFFER * 2];
        int            write_id;
        int            read_id;
        int            buf_unused;
        int            nShareBufFd[NB_BUFFER * 2];
        int            nDmaBufFd[NB_BUFFER * 2];
    } bufferManagerQD_t;
 
    bufferManagerQ_t                mVideoBuffer;        // for usb camera
 
#ifdef USE_MP_CONVERT
    int                             mG2DHandle;
#endif
 
    OSAL_QUEUE                        mQueueBufferPreview;
    OSAL_QUEUE                        mQueueBufferPicture;
    V4L2BUF_t                        mV4l2buf[NB_BUFFER];
 
    sp<DoCaptureThread>                mCaptureThread;
    pthread_mutex_t                 mCaptureMutex;
    pthread_cond_t                    mCaptureCond;
 
    sp<DoPreviewThread>                mPreviewThread;
    pthread_mutex_t                 mPreviewMutex;
    pthread_cond_t                    mPreviewCond;
    pthread_mutex_t                    mPreviewSyncMutex;
    pthread_cond_t                    mPreviewSyncCond;
 
    sp<DoPictureThread>                mPictureThread;
    pthread_mutex_t                 mPictureMutex;
    pthread_cond_t                    mPictureCond;
 
    pthread_mutex_t                 mConnectMutex;
    pthread_cond_t                    mConnectCond;
    bool                            mCanBeDisconnected;
 
    sp<DoContinuousPictureThread>    mContinuousPictureThread;
    pthread_mutex_t                 mContinuousPictureMutex;
    pthread_cond_t                    mContinuousPictureCond;
    bool                            mContinuousPictureStarted;
    int                                mContinuousPictureCnt;
    int                                mContinuousPictureMax;
    nsecs_t                         mContinuousPictureStartTime;
 
    sp<DoSmartPictureThread>        mSmartPictureThread;
    pthread_mutex_t                 mSmartPictureMutex;
    pthread_cond_t                    mSmartPictureCond;
    bool                            mSmartPictureDone;
    int64_t                         mStartSmartTimeMs;
    bool                            mStartSmartTimeout;
    /* Timestamp (abs. microseconds) when last frame has been pushed to the
     * preview window. */
    uint64_t                        mContinuousPictureLast;
 
    /* Preview frequency in microseconds. */
    uint32_t                        mContinuousPictureAfter;
 
    uint64_t                        mFaceDectectLast;
    uint32_t                        mFaceDectectAfter;
 
    uint64_t                        mPreviewLast;
    uint32_t                        mPreviewAfter;
    V4L2BUF_t *                        mCurrentV4l2buf;
 
    bool                            mVideoHint;
    VideoDecoder *                    mDecoder;
    VConfig                            mVideoConf;
    VideoStreamInfo                    mVideoInfo;
    VideoStreamDataInfo                mDataInfo;
#define STATISICS_CNT    60
    int                                mCurAvailBufferCnt;
    int                                mStatisicsIndex;
    bool                            mNeedHalfFrameRate;
    bool                            mShouldPreview;
    bool                            mIsThumbUsedForVideo;
    int                                mVideoWidth;            // for cts
    int                                mVideoHeight;
 
    int                             mDiscardFrameNum;
    IMAGE_FLAG_t                    mTakePictureFlag;
    int                                mFlashMode;
 
    ISceneMode*                        mSceneMode;
    SceneModeFactory                mSceneModeFactory;
    int releaseIndex; //handle index for encoder callback to release
#ifdef USE_DEINTERLACE_HW
    DiProcess                       *mDiProcess;
    int                             mPreFrameIndex;
    int                             mPrePreFrameIndex;
    bufferManagerQD_t               mDiOutPutBuffer;
 
public:
    int                             mEnableYUV422;
 
    private:
    V4L2BUF_t                       mV4l2DiBuf[NB_BUFFER];
#endif
 
#ifdef USE_ISP
    AWIspApi                          *mAWIspApi;
    int                               mIspId;
#endif
    int                             mPicCnt;
    uint64_t                        mOrgTime;
    int                             mDebugLogCnt;
};
 
}; /* namespace android */
 
#endif  /* __HAL_V4L2_CAMERA_DEVICE_H__ */