liyujie
2025-08-28 b3810562527858a3b3d98ffa6e9c9c5b0f4a9a8e
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
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
/*
* Copyright (c) 2008-2016 Allwinner Technology Co. Ltd.
* All rights reserved.
*
* File : vencoder.h
* Description :
* History :
*   Author  : fangning <fangning@allwinnertech.com>
*   Date    : 2016/04/13
*   Comment :
*
*
*/
 
/*
 *this software is based in part on the work
 * of the Independent JPEG Group
 */
#include "sc_interface.h"
#include "veInterface.h"
 
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
 
#ifndef _VENCODER_H_
#define _VENCODER_H_
 
#define  DATA_TIME_LENGTH           24
#define  INFO_LENGTH                64
#define  GPS_PROCESS_METHOD_LENGTH  100
#define  DESCRIPTOR_INFO            128
#define  PROC_BUF_LEN               1024
#define  MAX_CHANNEL_NUM            16
 
#define MAX_FRM_NUM                       5
#define MAX_GOP_SIZE                      63
#define MAX_OVERLAY_SIZE                  64
 
 
#define VENC_BUFFERFLAG_KEYFRAME 0x00000001
#define VENC_BUFFERFLAG_EOS 0x00000002
#define H264_VERSION2_USE64 0
 
typedef enum {
    PSKIP               = 0,
    BSKIP_DIRECT        = 0,
    P16x16              = 1,
    P16x8               = 2,
    P8x16               = 3,
    SMB8x8              = 4,
    SMB8x4              = 5,
    SMB4x8              = 6,
    SMB4x4              = 7,
    P8x8                = 8,
    I4MB                = 9,
    I16MB               = 10,
    IBLOCK              = 11,
    SI4MB               = 12,
    I8MB                = 13,
    IPCM                = 14,
    MAXMODE             = 15
}MB_TYPE;
 
typedef struct {
    short         mv_x;
    short         mv_y;
    int           mode;
    unsigned char lt_flag;
    unsigned short depth;
} VencMotionVector;
 
typedef struct {
    MB_TYPE mb_type;
    VencMotionVector mb_mv;
}MbMvList;
 
typedef struct rational_t {
    unsigned int num;
    unsigned int den;
}rational_t;
 
typedef struct srational_t {
    int num;
    int den;
}srational_t;
 
typedef enum ExifMeteringModeType {
    UNKNOWN_AW_EXIF,
    AVERAGE_AW_EXIF,
    CENTER_AW_EXIF,
    SPOT_AW_EXIF,
    MULTISPOT_AW_EXIF,
    PATTERN_AW_EXIF,
    PARTIAL_AW_EXIF,
    OTHER_AW_EXIF     = 255,
} ExifMeteringModeType;
 
typedef enum ExifExposureModeType {
    EXPOSURE_AUTO_AW_EXIF,
    EXPOSURE_MANUAL_AW_EXIF,
    EXPOSURE_AUTO_BRACKET_AW_EXIF,
}ExifExposureModeType;
 
typedef enum {
    UNKNOWN = 0,
    SUNLIGHT = 1,
    TUNGSTEN_LAMP = 2,
    FILAMENT_LAMP = 3,
    FLASH_LAMP = 4,
    OVERCAST = 9,
    CLOUDY = 10,
    SHADOW = 11,
    INCANDESCENT_LAMP = 12,
    WHITE_DAY_FLUORESCENT_LAMP = 13,
    COOL_COLOUR_FLUORESCENT_LAMP = 14,
    WHITE_FLUORESCENT_LAMP = 15,
    STANDARD_LAMP_A = 17,
    STANDARD_LAMP_B = 18,
    STANDARD_lAMP_C = 19,
    D55 = 20,
    D65 = 21,
    D75 = 22,
    D50= 23,
    PROJECTION_ROOM_LAMP = 24,
    OTHERS = 255
}ExifLightSource;
 
typedef struct EXIFInfo {
    unsigned char  CameraMake[INFO_LENGTH];
    unsigned char  CameraModel[INFO_LENGTH];
    unsigned char  DateTime[DATA_TIME_LENGTH];
 
    unsigned int   ThumbWidth;
    unsigned int   ThumbHeight;
    unsigned char* ThumbAddrVir;
    unsigned int   ThumbLen;
 
    int              Orientation;  //value can be 0,90,180,270 degree
    rational_t       ExposureTime; //tag 0x829A
    rational_t       FNumber; //tag 0x829D
    short           ISOSpeed;//tag 0x8827
 
    srational_t    ShutterSpeedValue; //tag 0x9201
    rational_t       Aperture; //tag 0x9202
    //srational_t    BrightnessValue;   //tag 0x9203
    srational_t    ExposureBiasValue; //tag 0x9204
 
    rational_t       MaxAperture; //tag 0x9205
 
    short           MeteringMode; //tag 0x9207
    short           LightSource; //tag 0x9208
    short           FlashUsed;     //tag 0x9209
    rational_t       FocalLength; //tag 0x920A
 
    rational_t       DigitalZoomRatio; // tag 0xA404
    short           WhiteBalance; //tag 0xA403
    short           ExposureMode; //tag 0xA402
 
    unsigned char   subSecTime[8];
    unsigned char   subSecTimeOrig[8];
    unsigned char   subSecTimeDig[8];
 
    // gps info
    int            enableGpsInfo;
    double         gps_latitude;
    double           gps_longitude;
    double         gps_altitude;
    long           gps_timestamp;
    unsigned char  gpsProcessingMethod[GPS_PROCESS_METHOD_LENGTH];
 
    unsigned char  CameraSerialNum[128];     //tag 0xA431 (exif 2.3 version)
    short              FocalLengthIn35mmFilm;     // tag 0xA405
 
    unsigned char  ImageName[128];             //tag 0x010D
    unsigned char  ImageDescription[128];     //tag 0x010E
    short            ImageWidth;                 //tag 0xA002
    short            ImageHeight;             //tag 0xA003
 
    int             thumb_quality;
}EXIFInfo;
 
typedef struct VencRect {
    int nLeft;
    int nTop;
    int nWidth;
    int nHeight;
}VencRect;
 
typedef enum VENC_YUV2YUV {
    VENC_YCCToBT601,
    VENC_BT601ToYCC,
}VENC_YUV2YUV;
 
typedef enum VENC_CODING_MODE {
  VENC_FRAME_CODING         = 0,
  VENC_FIELD_CODING         = 1,
}VENC_CODING_MODE;
 
//* The Amount of Temporal SVC Layers
typedef enum {
    NO_T_SVC = 0,
    T_LAYER_2 = 2,
    T_LAYER_3 = 3,
    T_LAYER_4 = 4
}T_LAYER;
 
//* The Multiple of Skip_Frame
typedef enum {
    NO_SKIP = 0,
    SKIP_2 = 2,
    SKIP_4 = 4,
    SKIP_8 = 8
}SKIP_FRAME;
 
typedef enum VENC_CODEC_TYPE {
    VENC_CODEC_H264,
    VENC_CODEC_JPEG,
    VENC_CODEC_H264_VER2,
    VENC_CODEC_H265,
    VENC_CODEC_VP8,
}VENC_CODEC_TYPE;
 
typedef enum VENC_PIXEL_FMT {
    VENC_PIXEL_YUV420SP,
    VENC_PIXEL_YVU420SP,
    VENC_PIXEL_YUV420P,
    VENC_PIXEL_YVU420P,
    VENC_PIXEL_YUV422SP,
    VENC_PIXEL_YVU422SP,
    VENC_PIXEL_YUV422P,
    VENC_PIXEL_YVU422P,
    VENC_PIXEL_YUYV422,
    VENC_PIXEL_UYVY422,
    VENC_PIXEL_YVYU422,
    VENC_PIXEL_VYUY422,
    VENC_PIXEL_ARGB,
    VENC_PIXEL_RGBA,
    VENC_PIXEL_ABGR,
    VENC_PIXEL_BGRA,
    VENC_PIXEL_TILE_32X32,
    VENC_PIXEL_TILE_128X32,
    VENC_PIXEL_AFBC_AW,
    VENC_PIXEL_LBC_AW, //* for v5v200 and newer ic
}VENC_PIXEL_FMT;
 
typedef enum E_ISP_SCALER_RATIO {
    VENC_ISP_SCALER_0       = 0, //no write back
    VENC_ISP_SCALER_EIGHTH  = 1, //scaler 1/8 write back
    VENC_ISP_SCALER_HALF    = 2, //scaler 1/2 write back
    VENC_ISP_SCALER_QUARTER = 3, //scaler 1/4 write back
}E_ISP_SCALER_RATIO;
 
typedef struct VencThumbInfo {
    unsigned int        nThumbSize;
    unsigned char*      pThumbBuf;
}VencThumbInfo;
 
typedef struct VencBaseConfig {
    unsigned char       bEncH264Nalu;
    unsigned int        nInputWidth;
    unsigned int        nInputHeight;
    unsigned int        nDstWidth;
    unsigned int        nDstHeight;
    unsigned int        nStride;
    VENC_PIXEL_FMT      eInputFormat;
    struct ScMemOpsS *memops;
    VeOpsS*           veOpsS;
    void*             pVeOpsSelf;
 
    unsigned char     bOnlyWbFlag;
 
    //* for v5v200 and newer ic
    unsigned char     bLbcLossyComEnFlag2x;
    unsigned char     bLbcLossyComEnFlag2_5x;
    //* end
}VencBaseConfig;
 
/**
 * H264 profile types
 */
typedef enum VENC_H264PROFILETYPE {
    VENC_H264ProfileBaseline  = 66,         /**< Baseline profile */
    VENC_H264ProfileMain      = 77,         /**< Main profile */
    VENC_H264ProfileHigh      = 100,           /**< High profile */
}VENC_H264PROFILETYPE;
 
/**
 * H264 level types
 */
typedef enum VENC_H264LEVELTYPE {
    VENC_H264Level1   = 10,     /**< Level 1 */
    VENC_H264Level11  = 11,     /**< Level 1.1 */
    VENC_H264Level12  = 12,     /**< Level 1.2 */
    VENC_H264Level13  = 13,     /**< Level 1.3 */
    VENC_H264Level2   = 20,     /**< Level 2 */
    VENC_H264Level21  = 21,     /**< Level 2.1 */
    VENC_H264Level22  = 22,     /**< Level 2.2 */
    VENC_H264Level3   = 30,     /**< Level 3 */
    VENC_H264Level31  = 31,     /**< Level 3.1 */
    VENC_H264Level32  = 32,     /**< Level 3.2 */
    VENC_H264Level4   = 40,     /**< Level 4 */
    VENC_H264Level41  = 41,     /**< Level 4.1 */
    VENC_H264Level42  = 42,     /**< Level 4.2 */
    VENC_H264Level5   = 50,     /**< Level 5 */
    VENC_H264Level51  = 51,     /**< Level 5.1 */
}VENC_H264LEVELTYPE;
 
typedef struct VencH264ProfileLevel {
    VENC_H264PROFILETYPE    nProfile;
    VENC_H264LEVELTYPE        nLevel;
}VencH264ProfileLevel;
 
typedef struct VencQPRange {
    int    nMaxqp;
    int    nMinqp;
}VencQPRange;
 
typedef struct MotionParam {
    int nMotionDetectEnable;
    int nMotionDetectRatio; /* 0~12, advise set 0 */
    int nStaticDetectRatio; /* 0~12, should be larger than  nMotionDetectRatio, advise set 2 */
    int nMaxNumStaticFrame; /* advise set 4 */
    double nStaticBitsRatio; /* advise set 0.2~0.3 at daytime, set 0.1 at night */
    double nMV64x64Ratio; /* advise set 0.01 */
    short nMVXTh; /* advise set 6 */
    short nMVYTh; /* advise set 6 */
}MotionParam;
 
typedef struct VencHeaderData {
    unsigned char*  pBuffer;
    unsigned int    nLength;
}VencHeaderData;
 
/* support 4 ROI region */
typedef struct VencROIConfig {
    int                     bEnable;
    int                        index; /* (0~3) */
    int                     nQPoffset;
    unsigned char           roi_abs_flag;
    VencRect                sRect;
}VencROIConfig;
 
typedef struct VencFixQP {
    int                     bEnable;
    int                     nIQp;
    int                     nPQp;
}VencFixQP;
 
typedef enum {
    AW_CBR = 0,
    AW_VBR = 1,
    AW_AVBR = 2,
    AW_QPMAP = 3,
    AW_FIXQP = 4,
}VENC_RC_MODE;
 
typedef struct VencInputBuffer {
    unsigned long  nID;
    long long         nPts;
    unsigned int   nFlag;
    unsigned char* pAddrPhyY;
    unsigned char* pAddrPhyC;
    unsigned char* pAddrVirY;
    unsigned char* pAddrVirC;
    int            bEnableCorp;
    VencRect       sCropInfo;
 
    int            ispPicVar;
    int            ispPicVarChroma;     //chroma  filter  coef[0-63],  from isp
    int               bUseInputBufferRoi;
    VencROIConfig  roi_param[8];
    int            bAllocMemSelf;
    int            nShareBufFd;
    unsigned char  bUseCsiColorFormat;
    VENC_PIXEL_FMT eCsiColorFormat;
 
    int             envLV;
}VencInputBuffer;
 
typedef struct FrameInfo {
    int             CurrQp;
    int             avQp;
    int             nGopIndex;
    int             nFrameIndex;
    int             nTotalIndex;
}FrameInfo;
 
typedef struct VeProcSet {
    unsigned char               bProcEnable;
    unsigned int                nProcFreq;
    unsigned int                nStatisBitRateTime;
    unsigned int                nStatisFrRateTime;
}VeProcSet;
 
typedef struct VeProcEncInfo {
    unsigned int                nChannelNum;
    unsigned int                nProfileIdc;
    int                         nIDRItl;
    int                         nBitRate;
    int                         nFrameRate;
 
    unsigned int                nInputWidth;
    unsigned int                nInputHeight;
    unsigned int                nDstWidth;
    unsigned int                nDstHeight;
    unsigned int                nStride;
 
    int                         eSliceType;
    int                         nCurrQp;
    int                         nGopIndex;
    int                         nFrameIndex;
    int                         nTotalIndex;
 
    unsigned int                uMaxBitRate;
    int                         nQuality;
 
    VENC_RC_MODE                eRcMode;
    VencFixQP                   fix_qp;
    int                         i_qp_offset;
    int                         qp_max;
    int                         qp_min;
 
    unsigned int                 AFBC_Enable;
    unsigned int                rot_angle;
    unsigned char                filter3d_level;
 
    int                         crop_left;
    int                         crop_top;
    int                         crop_width;
    int                         crop_height;
 
    unsigned int                qp_offset1;
    unsigned int                qp_offset2;
    unsigned int                qp_offset3;
    unsigned int                qp_offset4;
    unsigned int                qp_offset5;
    unsigned int                qp_offset6;
    unsigned int                qp_offset7;
    unsigned int                qp_offset8;
 
    unsigned int                avr_bit_rate;
    unsigned int                real_bit_rate;
    unsigned int                avr_frame_rate;
    unsigned int                real_frame_rate;
 
    int                            vbv_size;
    int                            UnusedBufferSize;
    int                            nValidFrameNum;
    int                            nValidDataSize;
}VeProcEncInfo;
 
typedef struct VencOutputBuffer {
    int               nID;
    long long         nPts;
    unsigned int   nFlag;
    unsigned int   nSize0;
    unsigned int   nSize1;
    unsigned char* pData0;
    unsigned char* pData1;
 
    FrameInfo       frame_info;
    unsigned int   nSize2;
    unsigned char* pData2;
}VencOutputBuffer;
 
typedef struct VencAllocateBufferParam {
    unsigned int   nBufferNum;
    unsigned int   nSizeY;
    unsigned int   nSizeC;
}VencAllocateBufferParam;
 
#define EXTENDED_SAR 255
typedef struct VencH264AspectRatio {
    unsigned char aspect_ratio_idc;
    unsigned short  sar_width;
    unsigned short  sar_height;
}VencH264AspectRatio;
 
typedef struct VencSaveBSFile {
    char filename[256];
    unsigned char save_bsfile_flag;
    unsigned int save_start_time;
    unsigned int save_end_time;
}VencSaveBSFile;
 
typedef enum VENC_COLOR_SPACE {
    RESERVED0    = 0,
    VENC_BT709  = 1,                 /* bt709 */
    RESERVED1    = 2,
    RESERVED2    = 3,
    RESERVED3    = 4,
    VENC_BT601  = 5,                 /* bt601-625 default use this colorspace */
    BT601_525   = 6,                 /* bt601-525 */
    RESERVED4    = 7,
    VENC_YCC    = 8,                /* YCC: full range BT.601  */
}VENC_COLOR_SPACE;
 
typedef enum VENC_VIDEO_FORMAT {
    COMPONENT       = 0,                 /* component */
    PAL               = 1,                 /* pal*/
    NTSC            = 2,                 /* ntsc */
    SECAM            = 3,                /* secam  */
    MAC                = 4,                /* mac  */
    DEFAULT            = 5,                /* Unspecified video format  */
}VENC_VIDEO_FORMAT;
 
typedef struct VencJpegVideoSignal {
    VENC_COLOR_SPACE src_colour_primaries;
    VENC_COLOR_SPACE dst_colour_primaries;
}VencJpegVideoSignal;
 
typedef struct VencH264VideoSignal {
    VENC_VIDEO_FORMAT video_format;
 
    unsigned char full_range_flag;
 
    VENC_COLOR_SPACE src_colour_primaries;
    VENC_COLOR_SPACE dst_colour_primaries;
}VencH264VideoSignal;
 
typedef struct VencH264VideoTiming {
      unsigned long num_units_in_tick;
      unsigned long time_scale;
      unsigned int fixed_frame_rate_flag;
 
}VencH264VideoTiming;
 
// Add for setting SVC and Skip_Frame
typedef struct VencH264SVCSkip {
    T_LAYER        nTemporalSVC;
    SKIP_FRAME     nSkipFrame;
    int            bEnableLayerRatio;
    unsigned int   nLayerRatio[4];
}VencH264SVCSkip;
 
typedef struct VencCyclicIntraRefresh {
    int                     bEnable;
    int                     nBlockNumber;
}VencCyclicIntraRefresh;
 
typedef struct VencSize {
    int                     nWidth;
    int                     nHeight;
}VencSize;
 
typedef enum VENC_VIDEO_GOP_MODE {
    AW_NORMALP         = 1,//one p ref frame
    AW_ADVANCE_SINGLE  = 2,
    AW_DOUBLEP         = 3,
    AW_SPECIAL_DOUBLE  = 4,
    AW_SPECIAL_SMARTP  = 5,//double p ref frames and use virtual i frame,but virtual i ref virtual i
    AW_SMARTP          = 6,//double p ref frames and use virtual i frame
}VENC_VIDEO_GOP_MODE;
 
typedef struct VencAdvancedRefParam {
    unsigned char              bAdvancedRefEn;   //advanced ref frame mode, 0:not use , 1:use
    unsigned int               nBase;       //base frame num
    unsigned int               nEnhance;    //enhance frame num
    unsigned char              bRefBaseEn;  //ctrl base frame ref base frame, 0:enable, 1:disable
}VencAdvancedRefParam;
 
typedef struct VencGopParam {
    unsigned char              bUseGopCtrlEn;   //use user set gop mode
    VENC_VIDEO_GOP_MODE        eGopMode;        //gop mode
    unsigned int               nVirtualIFrameInterval;
    unsigned int               nSpInterval;     //user set special p frame ref interval
    VencAdvancedRefParam       sRefParam;       //user set advanced ref frame mode
}VencGopParam;
 
typedef struct VencCheckColorFormat {
    int                        index;
    VENC_PIXEL_FMT          eColorFormat;
}VencCheckColorFormat;
 
typedef struct VencVP8Param {
    int                     nFramerate; /* fps*/
    int                     nBitrate;   /* bps*/
    int                     nMaxKeyInterval;
}VencVP8Param;
 
typedef enum VENC_SUPERFRAME_MODE {
    VENC_SUPERFRAME_NONE,
    VENC_SUPERFRAME_DISCARD,
    VENC_SUPERFRAME_REENCODE,
}VENC_SUPERFRAME_MODE;
 
typedef struct VencSuperFrameConfig {
    VENC_SUPERFRAME_MODE    eSuperFrameMode;
    unsigned int            nMaxIFrameBits;
    unsigned int            nMaxPFrameBits;
}VencSuperFrameConfig;
 
typedef struct VencBitRateRange {
    int            bitRateMax;
    int            bitRateMin;
}VencBitRateRange;
 
typedef struct VencRoiBgFrameRate {
    int            nSrcFrameRate;
    int            nDstFrameRate;
}VencRoiBgFrameRate;
 
typedef struct VencAlterFrameRateInfo {
    unsigned char       bEnable;
    unsigned char       bUseUserSetRoiInfo;   //0:use csi roi info; 1:use user set roi info
    VencRoiBgFrameRate  sRoiBgFrameRate;
    VencROIConfig       roi_param[8];
}VencAlterFrameRateInfo;
 
typedef struct VencH265TranS {
    /*** unsigned char       transquant_bypass_enabled_flag; not support ***/
    //0:disable transform skip; 1:enable transform skip
    unsigned char       transform_skip_enabled_flag;
    //chroma_qp= sliece_qp+chroma_qp_offset
    char                chroma_qp_offset;
}VencH265TranS;
 
typedef struct VencH265SaoS {
    //0:disable luma sao filter; 1:enable luma sao filter
    unsigned char       slice_sao_luma_flag;
    //0:disable chroma sao filter; 1:enable chroma sao filter
    unsigned char       slice_sao_chroma_flag;
}VencH265SaoS;
 
typedef struct VencH265DblkS {
    //0:enable deblock filter; 1:disable deblock filter
    unsigned char       slice_deblocking_filter_disabled_flag;
    char                slice_beta_offset_div2; //range: [-6,6]
    char                slice_tc_offset_div2; //range: [-6,6]
}VencH265DblkS;
 
typedef struct VencH265TimingS {
    //0:stream without timing info; 1:stream with timing info
    unsigned char       timing_info_present_flag;
    unsigned int        num_units_in_tick;       //time_scale/frameRate
    unsigned int        time_scale;             //1second is  average divided by time_scale
    unsigned int        num_ticks_poc_diff_one; //num ticks of diff frame
}VencH265TimingS;
 
typedef enum VENC_OVERLAY_ARGB_TYPE {
    VENC_OVERLAY_ARGB_MIN    = -1,
    VENC_OVERLAY_ARGB8888    = 0,
    VENC_OVERLAY_ARGB4444   = 1,
    VENC_OVERLAY_ARGB1555   = 2,
    VENC_OVERLAY_ARGB_MAX    = 3,
}VENC_OVERLAY_ARGB_TYPE;
 
typedef enum VENC_OVERLAY_TYPE {
    NORMAL_OVERLAY          = 0,    //normal overlay
    COVER_OVERLAY           = 1,    //use the setting yuv to cover region
    LUMA_REVERSE_OVERLAY    = 2,    //normal overlay and luma reverse
}VENC_OVERLAY_TYPE;
 
typedef struct VencOverlayCoverYuvS {
     //1:use the cover yuv; 0:transform the argb data to yuv ,then cover
     unsigned char       use_cover_yuv_flag;
     unsigned char       cover_y; //the value of cover y
     unsigned char       cover_u; //the value of cover u
     unsigned char       cover_v; //the value of cover v
}VencOverlayCoverYuvS;
 
typedef struct VencOverlayHeaderS {
    unsigned short      start_mb_x;         //horizonal value of  start points divided by 16
    unsigned short      end_mb_x;           //horizonal value of  end points divided by 16
    unsigned short      start_mb_y;         //vertical value of  start points divided by 16
    unsigned short      end_mb_y;           //vertical value of  end points divided by 16
    unsigned char       extra_alpha_flag;   //0:no use extra_alpha; 1:use extra_alpha
    unsigned char       extra_alpha;        //use user set extra_alpha, range is [0, 15]
    VencOverlayCoverYuvS cover_yuv;         //when use COVER_OVERLAY should set the cover yuv
    VENC_OVERLAY_TYPE   overlay_type;       //reference define of VENC_OVERLAY_TYPE
    unsigned char*      overlay_blk_addr;   //the vir addr of overlay block
    unsigned int        bitmap_size;        //the size of bitmap
 
    //* for v5v200 and newer ic
    unsigned int        bforce_reverse_flag;
    unsigned int        reverse_unit_mb_w_minus1;
    unsigned int        reverse_unit_mb_h_minus1;
    //* end
 
}VencOverlayHeaderS;
 
typedef struct VencOverlayInfoS {
    unsigned char               blk_num; //num of overlay region
    VENC_OVERLAY_ARGB_TYPE      argb_type;//reference define of VENC_ARGB_TYPE
    VencOverlayHeaderS          overlayHeaderList[MAX_OVERLAY_SIZE];
 
    //* for v5v200 and newer ic
    unsigned int                invert_mode;
    unsigned int                invert_threshold;
    //* end
 
}VencOverlayInfoS;
 
typedef struct VencBrightnessS {
    unsigned int               dark_th; //dark threshold, default 60, range[0, 255]
    unsigned int               bright_th; //bright threshold, default 200, range[0, 255]
}VencBrightnessS;
 
typedef struct VencEncodeTimeS {
    unsigned int                  frame_num; //current frame num
    unsigned int                  curr_enc_time; //current frame encoder time
    unsigned int                  curr_empty_time; //the time between current frame and last frame
    unsigned int                  avr_enc_time; //average encoder time
    unsigned int                  avr_empty_time; //average empty time
    unsigned int                  max_enc_time;
    unsigned int                  max_enc_time_frame_num;
    unsigned int                  max_empty_time;
    unsigned int                  max_empty_time_frame_num;
}VencEncodeTimeS;
 
typedef enum VENC_INDEXTYPE {
    VENC_IndexParamBitrate                = 0x0,
    /**< reference type: int */
    VENC_IndexParamFramerate,
    /**< reference type: int */
    VENC_IndexParamMaxKeyInterval,
    /**< reference type: int */
    VENC_IndexParamIfilter,
    /**< reference type: int */
    VENC_IndexParamRotation,
    /**< reference type: int */
    VENC_IndexParamSliceHeight,
    /**< reference type: int */
    VENC_IndexParamForceKeyFrame,
    /**< reference type: int (write only)*/
    VENC_IndexParamMotionDetectEnable,
    /**< reference type: MotionParam(write only) */
    VENC_IndexParamMotionDetectStatus,
    /**< reference type: int(read only) */
    VENC_IndexParamRgb2Yuv,
    /**< reference type: VENC_COLOR_SPACE */
    VENC_IndexParamYuv2Yuv,
    /**< reference type: VENC_YUV2YUV */
    VENC_IndexParamROIConfig,
    /**< reference type: VencROIConfig */
    VENC_IndexParamStride,
    /**< reference type: int */
    VENC_IndexParamColorFormat,
    /**< reference type: VENC_PIXEL_FMT */
    VENC_IndexParamSize,
    /**< reference type: VencSize(read only) */
    VENC_IndexParamSetVbvSize,
    /**< reference type: setVbvSize(write only) */
    VENC_IndexParamVbvInfo,
    /**< reference type: getVbvInfo(read only) */
    VENC_IndexParamSuperFrameConfig,
    /**< reference type: VencSuperFrameConfig */
    VENC_IndexParamSetPSkip,
    /**< reference type: unsigned int */
    VENC_IndexParamResetEnc,
    /**< reference type: */
    VENC_IndexParamSaveBSFile,
    /**< reference type: VencSaveBSFile */
    VENC_IndexParamHorizonFlip,
    /**< reference type: unsigned int */
 
    /* check capabiliy */
    VENC_IndexParamMAXSupportSize,
    /**< reference type: VencSize(read only) */
    VENC_IndexParamCheckColorFormat,
    /**< reference type: VencCheckFormat(read only) */
 
    /* H264 param */
    VENC_IndexParamH264Param  = 0x100,
    /**< reference type: VencH264Param */
    VENC_IndexParamH264SPSPPS,
    /**< reference type: VencHeaderData (read only)*/
    VENC_IndexParamH264QPRange,
    /**< reference type: VencQPRange */
    VENC_IndexParamH264ProfileLevel,
    /**< reference type: VencProfileLevel */
    VENC_IndexParamH264EntropyCodingCABAC,
    /**< reference type: int(0:CAVLC 1:CABAC) */
    VENC_IndexParamH264CyclicIntraRefresh,
    /**< reference type: VencCyclicIntraRefresh */
    VENC_IndexParamH264FixQP,
    /**< reference type: VencFixQP */
    VENC_IndexParamH264SVCSkip,
    /**< reference type: VencH264SVCSkip */
    VENC_IndexParamH264AspectRatio,
    /**< reference type: VencH264AspectRatio */
    VENC_IndexParamFastEnc,
    /**< reference type: int */
    VENC_IndexParamH264VideoSignal,
    /**< reference type: VencH264VideoSignal */
    VENC_IndexParamH264VideoTiming,
    /**< reference type: VencH264VideoTiming */
    VENC_IndexParamChmoraGray,
    /**< reference type: unsigned char */
    VENC_IndexParamIQpOffset,
    /**< reference type: constant QP */
    VENC_IndexParamH264ConstantQP,
    /**< reference type: int */
    /* jpeg param */
    VENC_IndexParamJpegQuality            = 0x200,
    /**< reference type: int (1~100) */
    VENC_IndexParamJpegExifInfo,
    /**< reference type: EXIFInfo */
    VENC_IndexParamJpegEncMode,
    /**< reference type: 0:jpeg; 1:motion_jepg */
    VENC_IndexParamJpegVideoSignal,
    /**< reference type: VencJpegVideoSignal */
 
    /* VP8 param */
    VENC_IndexParamVP8Param,
    /* max one frame length */
    VENC_IndexParamSetFrameLenThreshold,
    /**< reference type: int */
    /* decrease the a20 dram bands */
    VENC_IndexParamSetA20LowBands,
    /**< reference type: 0:disable; 1:enable */
    VENC_IndexParamSetBitRateRange,
    /**< reference type: VencBitRateRange */
    VENC_IndexParamLongTermReference,
    /**< reference type: 0:disable; 1:enable, default:enable */
 
    /* h265 param */
    VENC_IndexParamH265Param = 0x300,
    VENC_IndexParamH265Gop,
    VENC_IndexParamH265ToalFramesNum,
    VENC_IndexParamH26xUpdateLTRef,
    VENC_IndexParamH265Header,
    VENC_IndexParamH265TendRatioCoef,
    VENC_IndexParamH265Trans,
    /**< reference type: VencH265TranS */
    VENC_IndexParamH265Sao,
    /**< reference type: VencH265SaoS */
    VENC_IndexParamH265Dblk,
    /**< reference type: VencH265DblkS */
    VENC_IndexParamH265Timing,
    /**< reference type: VencH265TimingS */
    VENC_IndexParamIntraPeriod,
    VENC_IndexParamMBModeCtrl,
    VENC_IndexParamMBSumInfoOutput,
    VENC_IndexParamMBInfoOutput,
    VENC_IndexParamVUIAspectRatio,
    VENC_IndexParamVUIVideoSignal,
    VENC_IndexParamVUIChromaLoc,
    VENC_IndexParamVUIDisplayWindow,
    VENC_IndexParamVUIBitstreamRestriction,
 
    VENC_IndexParamAlterFrame = 0x400,
    /**< reference type: unsigned int */
    VENC_IndexParamVirtualIFrame,
    VENC_IndexParamChannelNum,
    VENC_IndexParamProcSet,
    /**< reference type: VencOverlayInfoS */
    VENC_IndexParamSetOverlay,
    /**< reference type: unsigned char */
    VENC_IndexParamAllParams,
    /**< reference type:VencBrightnessS */
    VENC_IndexParamBright,
    /**< reference type:VencSmartFun */
    VENC_IndexParamSmartFuntion,
    /**< reference type: VencHVS */
    VENC_IndexParamHVS,
    /**< reference type: unsigned char */
    VENC_IndexParamSkipTend,
    /**< reference type: unsigned char */
    VENC_IndexParamHighPassFilter,
    /**< reference type: unsigned char */
    VENC_IndexParamPFrameIntraEn,
    /**< reference type: unsigned char */
    VENC_IndexParamEncodeTimeEn,
    /**< reference type: VencEncodeTimeS */
    VENC_IndexParamGetEncodeTime,
    /**< reference type: unsigned char */
    VENC_IndexParam3DFilter,
    /**< reference type: unsigned char */
    VENC_IndexParamIntra4x4En,
 
    /**< reference type: unsigned int */
    VENC_IndexParamSetNullFrame = 0x500,
    /**< reference type: VencThumbInfo */
    VENC_IndexParamGetThumbYUV,
    /**< reference type: E_ISP_SCALER_RATIO */
    VENC_IndexParamSetThumbScaler,
    /**< reference type: unsigned char */
    VENC_IndexParamAdaptiveIntraInP,
    /**< reference type: VencBaseConfig */
    VENC_IndexParamUpdateBaseInfo,
 
    /**< reference type: unsigned char */
    VENC_IndexParamFillingCbr,
}VENC_INDEXTYPE;
 
typedef enum VENC_RESULT_TYPE {
    VENC_RESULT_ERROR             = -1,
    VENC_RESULT_OK                   = 0,
    VENC_RESULT_NO_FRAME_BUFFER   = 1,
    VENC_RESULT_BITSTREAM_IS_FULL = 2,
    VENC_RESULT_ILLEGAL_PARAM     = 3,
    VENC_RESULT_NOT_SUPPORT     = 4,
    VENC_RESULT_BITSTREAM_IS_EMPTY = 5,
    VENC_RESULT_NO_MEMORY     = 6,
    VENC_RESULT_NO_RESOURCE     = 7,
    VENC_RESULT_NULL_PTR     = 8,
 
    VENC_RESULT_EFUSE_ERROR  = 25,
}VENC_RESULT_TYPE;
 
typedef enum {
    H265_B_SLICE             = 0x0,
    H265_P_SLICE             = 0x1,
    H265_I_SLICE             = 0x2,
    H265_IDR_SLICE           = 0x12
}VENC_H265_CODE_TYPE;
 
typedef struct JpegEncInfo {
    VencBaseConfig  sBaseInfo;
    int             bNoUseAddrPhy;
    unsigned char*  pAddrPhyY;
    unsigned char*  pAddrPhyC;
    unsigned char*  pAddrVirY;
    unsigned char*  pAddrVirC;
    int             bEnableCorp;
    VencRect        sCropInfo;
    int                quality;
    int             nShareBufFd;
}JpegEncInfo;
 
typedef struct VbvInfo {
    unsigned int vbv_size;
    unsigned int coded_frame_num;
    unsigned int coded_size;
    unsigned int maxFrameLen;
}VbvInfo;
 
typedef enum {
    VENC_H265ProfileMain        = 1,
    VENC_H265ProfileMain10      = 2,
    VENC_H265ProfileMainStill   = 3
}VENC_H265PROFILETYPE;
 
typedef enum {
    VENC_H265Level1   = 30,     /**< Level 1 */
    VENC_H265Level2  = 60,     /**< Level 2 */
    VENC_H265Level21  = 63,     /**< Level 2.1 */
    VENC_H265Level3  = 90,     /**< Level 3 */
    VENC_H265Level31   = 93,     /**< Level 3.1 */
    VENC_H265Level41  = 123,     /**< Level 4.1 */
    VENC_H265Level5  = 150,     /**< Level 5 */
    VENC_H265Level51   = 153,     /**< Level 5.1 */
    VENC_H265Level52  = 156,     /**< Level 5.2 */
    VENC_H265Level6  = 180,     /**< Level 6 */
    VENC_H265Level61   = 183,     /**< Level 6.1 */
    VENC_H265Level62  = 186     /**< Level 6.2 */
}VENC_H265LEVELTYPE;
 
typedef enum {
    REF_IDC_DISCARD = 0,
    REF_IDC_CURRENT_USE = 1,
    REF_IDC_FUTURE_USE = 2,
    REF_IDC_LONG_TERM = 4,
    REF_IDC_CURRENT_REF = 8,
}ReferenceIdc;
 
typedef struct {
    VENC_H265PROFILETYPE    nProfile;
    VENC_H265LEVELTYPE        nLevel;
}VencH265ProfileLevel;
 
typedef struct {
    unsigned int            uMaxBitRate;
    unsigned int            uRatioChangeQp; //range[50,100], default:85
    int                     nQuality;       //range[1,13], 1:worst quality, 13:best quality
}VencVbrParam;
 
typedef struct {
    unsigned char mode_ctrl_en;
    unsigned char *p_info;
}VencMBModeCtrl;
 
typedef struct {
    VENC_RC_MODE            eRcMode;
    unsigned char           bUseSetMadThrdFlag;
    unsigned char           uMadThrdI[12]; //range 0-255
    unsigned char           uMadThrdP[12]; //range 0-255
    unsigned char           uMadThrdB[12]; //no support
    unsigned int            uStatTime;      //range [1,10], default:1
    int                     uMinIQp;
    int                     nMaxReEncodeTimes; //default use one time
 
    VencVbrParam            sVbrParam;      //valid only at AW_VBR/AW_AVBR
    VencFixQP               sFixQp;         //valid only at AW_FIXQP
    VencMBModeCtrl          sQpMap;         //valid only at AW_QPMAP
 
    unsigned int            uRowQpDelta; //no support
    unsigned int            uDirectionThrd; //no support
    unsigned int            uQpDeltaLevelI; //no support
    unsigned int            uQpDeltaLevelP; //no support
    unsigned int            uQpDeltaLevelB; //no support
    unsigned int            uInputFrmRate;  //no support
    unsigned int            uOutputFrmRate; //no support
    unsigned int            uFluctuateLevel;//no support
    unsigned int            uMinIprop;      //no support
    unsigned int            uMaxIprop;      //no support
}VencRcParam;
 
typedef struct VencH264Param {
    VencH264ProfileLevel    sProfileLevel;
    int                     bEntropyCodingCABAC; /* 0:CAVLC 1:CABAC*/
    VencQPRange               sQPRange;
    int                     nFramerate; /* fps*/
    int                     nBitrate;   /* bps*/
    int                     nMaxKeyInterval;
    VENC_CODING_MODE        nCodingMode;
    VencGopParam            sGopParam;
    VencRcParam             sRcParam;
}VencH264Param;
 
typedef struct {
    int                     idr_period;
    VencH265ProfileLevel    sProfileLevel;
    VencQPRange               sQPRange;
    int                     nFramerate; /* fps*/
    int                     nBitrate;   /* bps*/
    int                     nIntraPeriod;
    int                     nGopSize;
    int                     nQPInit; /* qp of first IDR_frame if use rate control */
    VencRcParam             sRcParam;
    VencGopParam            sGopParam;
}VencH265Param;
 
typedef struct {
    unsigned int    slice_type;
    int             poc; // dispaly order of the frame within a GOP, ranging from 1 to gop_size
    int             qp_offset;
#if 0
    float           qp_factor; // used for RDO weighting,the bigger value means the lower quality
                                        // and less bits, ranging from 0.3 to 1.0
#endif
    int             tc_offset_div2; // offset of LoopFilterTcOffsetDiv2, ranging from -6 to 6
    int             beta_offset_div2; // offset of LoopFilterTcOffsetDiv2, ranging from -6 to 6
 
    unsigned int    num_ref_pics; // number of ref_frames reserved for cur_frame and future frames
    unsigned int    num_ref_pics_active; // number of ref_frames is permited to be used in L0 or L1
 
    int             reference_pics[MAX_FRM_NUM-1]; // = ref_frame_poc - cur_frame_poc
    // = discard_frame_poc - cur_frame_poc, means derlta_poc of ref_frames which are discarded
    int             discard_pics[MAX_FRM_NUM-1];
 
    unsigned char   lt_ref_flag; // 1: enable cur_frame use long term ref_frame
    int             lt_ref_poc; // poc of lt_ref_frame of cur_frame
 
    // 0 means next 4 member parameters are ignored; 1 means next 3 member parameters are need
    // this parameter of the first frame of a GOP must be 0
    unsigned char   predict;
 
    unsigned int    delta_rps_idx; // = cur_frame_encoding_idx - predictor_frame_encoding_idx
 
    int             delta_rps; // = predictor_frame_poc - cur_frame_poc
 
    // num of ref_idcs to encoder for the current frame, the value is equal to
    // the value of num_st_ref_pics of the predictor_frame + 1 + lt_ref_flag
    unsigned int    num_ref_idcs;
 
    // [][0]=(ref_frame_poc or discard_frame_poc) - cur_frame_poc
    // [][1]indicating the ref_pictures reserved in ref_list_buffer:
    // [][1]=0: will not be a ref_picture anymore
    // [][1]=1: is a ref_picture used by cur_picture
    // [][1]=2: is a ref_picture used by future_picture
    // [][1]=3: is a long term ref_picture
    int             reference_idcs[MAX_FRM_NUM][2];
}RefPicSet;
typedef struct {
    int gop_size;
    int intra_period;
    int max_num_ref_pics;
    unsigned char num_ref_idx_l0_default_active;
    unsigned char num_ref_idx_l1_default_active;
    RefPicSet ref_str[MAX_GOP_SIZE + 2]; // just when custom_rps_flag is 1, it should be set
    unsigned char use_sps_rps_flag; // if it is 1, rps will not occur in slice_header
    unsigned char use_lt_ref_flag;
    unsigned char custom_rps_flag; // 0: default ref_str will be use; 1: user should set ref_str[]
}VencH265GopStruct;
 
#define MAX_NUM_MB (65536)
typedef struct {
    unsigned char mb_mad;
    unsigned char mb_qp;
    unsigned int mb_sse;
    double mb_psnr;
}VencMBInfoPara;
 
typedef struct {
    unsigned int num_mb;
    VencMBInfoPara *p_para;
}VencMBInfo;
 
typedef struct {
    unsigned int sum_mad;
    unsigned int sum_qp;
    unsigned long long sum_sse;
}VencMBSumInfo;
 
typedef struct {
    unsigned char mb_qp; // {5:0}
    unsigned char mb_skip_flag; // {6}
    unsigned char mb_en; // {7}
}VencMBModeCtrlInfo;
 
typedef struct {
    unsigned char hp_filter_en;
    unsigned level_hpf;
}VencHighPassFilter;
 
typedef struct {
    unsigned char hvs_en;
    unsigned int  th_dir;
    unsigned int  th_coef_shift;
}VencHVS;
 
typedef struct {
    unsigned int inter_tend;
    unsigned int skip_tend;
    unsigned int merge_tend;
}VencH265TendRatioCoef;
 
typedef struct {
    unsigned char smart_fun_en;
    unsigned char img_bin_en;
    unsigned int img_bin_th;
    unsigned int shift_bits;
}VencSmartFun;
typedef struct {
    unsigned int chroma_sample_top;
    unsigned int chroma_sample_bottom;
}VencVUIChromaLoc;
 
typedef struct {
    unsigned int win_left_offset;
    unsigned int win_right_offset;
    unsigned int win_top_offset;
    unsigned int win_bottom_offset;
}VencVUIDisplayWindow;
 
typedef struct {
    unsigned char tiles_fixed_structure_flag;
    unsigned char mv_over_pic_boundaries_flag;
    unsigned char restricted_ref_pic_lists_flag;
    unsigned int  min_spatial_seg_idc;
    unsigned int  max_bytes_per_pic_denom;
    unsigned int  max_bits_per_min_cu_denom;
    unsigned int  log2_max_mv_len_hor;
    unsigned int  log2_max_mv_len_ver;
}VencVUIBitstreamRestriction;
 
typedef struct {
    unsigned char* pAddrPhyY;
    unsigned char* pAddrPhyC0;
    unsigned char* pAddrPhyC1;
    unsigned char* pAddrVirY;
    unsigned char* pAddrVirC;
    unsigned int   nWidth;
    unsigned int   nHeight;
             int   colorFormat;
 
}VencIspBufferInfo;
 
typedef struct {
    unsigned int      bScaleFlag;
    unsigned int      nRotateAngle;//* 0: no rotate; 1: 90; 2: 180; 3: 270;
    unsigned int      bHorizonflipFlag;
 
    unsigned int      bOverlayerFlag;
    VencOverlayInfoS *pOverlayerInfo;
 
    unsigned int      bCropFlag;
    VencRect         *pCropInfo;
 
    //* yuv2yuv, 0: disable; 1: BT601 to YCC; 2: YCC to BT601;
    //*                      3: BT709 to YCC; 4: YCC to BT709;
    unsigned int      nColorSpaceYuv2Yuv;
    //* rgb2yuv, 0: BT601, 1: BT709, 2: YCC
    unsigned int      nColorSpaceRgb2Yuv;
 
}VencIspFunction;
 
int AWJpecEnc(JpegEncInfo* pJpegInfo, EXIFInfo* pExifInfo,
    void* pOutBuffer, int* pOutBufferSize);
 
int AWCropYuv(VencIspBufferInfo* pInBuffer, VencRect* pCropInfo, VencIspBufferInfo* pOutBuffer);
typedef void* VideoEncoder;
 
typedef void* VideoEncoderIsp;
 
VideoEncoderIsp* VideoEncIspCreate();
void VideoEncIspDestroy(VideoEncoderIsp* pEncIsp);
int VideoEncIspFunction(VideoEncoderIsp* pEncIsp,
                              VencIspBufferInfo* pInBuffer,
                              VencIspBufferInfo* pOutBuffer,
                              VencIspFunction* pIspFunction);
 
 
VideoEncoder* VideoEncCreate(VENC_CODEC_TYPE eCodecType);
void VideoEncDestroy(VideoEncoder* pEncoder);
int VideoEncInit(VideoEncoder* pEncoder, VencBaseConfig* pConfig);
int VideoEncUnInit(VideoEncoder* pEncoder);
 
int AllocInputBuffer(VideoEncoder* pEncoder, VencAllocateBufferParam *pBufferParam);
int GetOneAllocInputBuffer(VideoEncoder* pEncoder, VencInputBuffer* pInputbuffer);
int FlushCacheAllocInputBuffer(VideoEncoder* pEncoder,  VencInputBuffer *pInputbuffer);
int ReturnOneAllocInputBuffer(VideoEncoder* pEncoder,  VencInputBuffer *pInputbuffer);
int ReleaseAllocInputBuffer(VideoEncoder* pEncoder);
 
int AddOneInputBuffer(VideoEncoder* pEncoder, VencInputBuffer* pInputbuffer);
int VideoEncodeOneFrame(VideoEncoder* pEncoder);
int AlreadyUsedInputBuffer(VideoEncoder* pEncoder, VencInputBuffer* pBuffer);
 
int ValidBitstreamFrameNum(VideoEncoder* pEncoder);
int GetOneBitstreamFrame(VideoEncoder* pEncoder, VencOutputBuffer* pBuffer);
int FreeOneBitStreamFrame(VideoEncoder* pEncoder, VencOutputBuffer* pBuffer);
 
int VideoEncGetParameter(VideoEncoder* pEncoder, VENC_INDEXTYPE indexType, void* paramData);
int VideoEncSetParameter(VideoEncoder* pEncoder, VENC_INDEXTYPE indexType, void* paramData);
 
int VideoEncoderReset(VideoEncoder* pEncoder);
unsigned int VideoEncoderGetUnencodedBufferNum(VideoEncoder* pEncoder);
 
void VideoEncoderGetVeIommuAddr(VideoEncoder* pEncoder, struct user_iommu_param *pIommuBuf);
void VideoEncoderFreeVeIommuAddr(VideoEncoder* pEncoder, struct user_iommu_param *pIommuBuf);
 
int VideoEncoderSetFreq(VideoEncoder* pEncoder, int nVeFreq);
void VideoEncoderSetDdrMode(VideoEncoder* pEncoder, int nDdrType);
 
int AWScalerYuv(VencIspBufferInfo* pInBuffer, VencIspBufferInfo* pOutBuffer);
 
#endif    //_VENCODER_H_
 
#ifdef __cplusplus
}
#endif /* __cplusplus */