-
Notifications
You must be signed in to change notification settings - Fork 1
/
frame.go
641 lines (511 loc) · 24.9 KB
/
frame.go
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
package rkcodec
//#include <rockchip/mpp_frame.h>
import "C"
// bit definition for mode flag in MppFrame
const MppFrameFlagFrame = C.MPP_FRAME_FLAG_FRAME // progressive frame
const MppFrameFlagTopField = C.MPP_FRAME_FLAG_TOP_FIELD // top field only
const MppFrameFlagBotField = C.MPP_FRAME_FLAG_BOT_FIELD // bottom field only
const MppFrameFlagPairedField = C.MPP_FRAME_FLAG_PAIRED_FIELD // paired field
const MppFrameFlagTopFirst = C.MPP_FRAME_FLAG_TOP_FIRST // paired field with field order of top first
const MppFrameFlagBotFirst = C.MPP_FRAME_FLAG_BOT_FIRST // paired field with field order of bottom first
const MppFrameFlagDeinterlaced = C.MPP_FRAME_FLAG_DEINTERLACED // paired field with unknown field order (MBAFF)
const MppFrameFlagFieldOrderMask = C.MPP_FRAME_FLAG_FIELD_ORDER_MASK // field order mask
const MppFrameFlagViewIdMask = C.MPP_FRAME_FLAG_VIEW_ID_MASK // view id mask
const MppFrameFlagIepDeiMask = C.MPP_FRAME_FLAG_IEP_DEI_MASK // iep dei mask
const MppFrameFlagIepDeiI2O1 = C.MPP_FRAME_FLAG_IEP_DEI_I2O1 // iep dei i2o1
const MppFrameFlagIepDeiI4O2 = C.MPP_FRAME_FLAG_IEP_DEI_I4O2 // iep dei i4o2
const MppFrameFlagIepDeiI4O1 = C.MPP_FRAME_FLAG_IEP_DEI_I4O1 // iep dei i4o1
// MPEG vs JPEG YUV range
type MppFrameColorRange = C.int
const (
MppFrameRangeUnspecified = MppFrameColorRange(C.MPP_FRAME_RANGE_UNSPECIFIED)
MppFrameRangeMpeg = MppFrameColorRange(C.MPP_FRAME_RANGE_MPEG)
MppFrameRangeJpeg = MppFrameColorRange(C.MPP_FRAME_RANGE_JPEG)
MppFrameRangeNB = MppFrameColorRange(C.MPP_FRAME_RANGE_NB)
)
type MppFrameChromaDownSampleMode = C.int
const (
MppFrameChromaDownSampleModeNone = MppFrameChromaDownSampleMode(C.MPP_FRAME_CHROMA_DOWN_SAMPLE_MODE_NONE)
MppFrameChromaDownSampleModeAverage = MppFrameChromaDownSampleMode(C.MPP_FRAME_CHORMA_DOWN_SAMPLE_MODE_AVERAGE)
MppFrameChromaDownSampleModeDiscard = MppFrameChromaDownSampleMode(C.MPP_FRAME_CHORMA_DOWN_SAMPLE_MODE_DISCARD)
)
type MppFrameVideoFormat = C.int
const (
MppFrameVideoFmtComponent = MppFrameVideoFormat(C.MPP_FRAME_VIDEO_FMT_COMPONEMT)
MppFrameVideoFmtPal = MppFrameVideoFormat(C.MPP_FRAME_VIDEO_FMT_PAL)
MppFrameVideoFmtNtsc = MppFrameVideoFormat(C.MPP_FRAME_VIDEO_FMT_NTSC)
MppFrameVideoFmtSecam = MppFrameVideoFormat(C.MPP_FRAME_VIDEO_FMT_SECAM)
MppFrameVideoFmtMac = MppFrameVideoFormat(C.MPP_FRAME_VIDEO_FMT_MAC)
MppFrameVideoFmtUnspecified = MppFrameVideoFormat(C.MPP_FRAME_VIDEO_FMT_UNSPECIFIED)
MppFrameVideoFmtReserved0 = MppFrameVideoFormat(C.MPP_FRAME_VIDEO_FMT_RESERVED0)
MppFrameVideoFmtReserved1 = MppFrameVideoFormat(C.MPP_FRAME_VIDEO_FMT_RESERVED1)
)
// Chromaticity coordinates of the source primaries.
type MppFrameColorPrimaries = C.MppFrameColorPrimaries
const (
MppFramePrimariesReserved0 = MppFrameColorPrimaries(C.MPP_FRAME_PRI_RESERVED0)
MppFramePrimariesBt709 = MppFrameColorPrimaries(C.MPP_FRAME_PRI_BT709) // also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
MppFramePrimariesUnspecified = MppFrameColorPrimaries(C.MPP_FRAME_PRI_UNSPECIFIED)
MppFramePrimariesReserved = MppFrameColorPrimaries(C.MPP_FRAME_PRI_RESERVED)
MppFramePrimariesBt470M = MppFrameColorPrimaries(C.MPP_FRAME_PRI_BT470M) // also FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
MppFramePrimariesBt470BG = MppFrameColorPrimaries(C.MPP_FRAME_PRI_BT470BG) // also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
MppFramePrimariesSmpte170M = MppFrameColorPrimaries(C.MPP_FRAME_PRI_SMPTE170M) // also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC/SMPTE ST 170 (2004)
MppFramePrimariesSmpte240M = MppFrameColorPrimaries(C.MPP_FRAME_PRI_SMPTE240M) // functionally identical to above/SMPTE ST 240
MppFramePrimariesFilm = MppFrameColorPrimaries(C.MPP_FRAME_PRI_FILM) // colour filters using Illuminant C
MppFramePrimariesBt2020 = MppFrameColorPrimaries(C.MPP_FRAME_PRI_BT2020) // ITU-R BT2020 / ITU-R BT.2100-2
MppFramePrimariesSmpte428_1 = MppFrameColorPrimaries(C.MPP_FRAME_PRI_SMPTEST428_1) // SMPTE ST 428-1 (CIE 1931 XYZ)
MppFramePrimariesSmpte431 = MppFrameColorPrimaries(C.MPP_FRAME_PRI_SMPTE431) // SMPTE ST 431-2 (2011) / DCI P3
MppFramePrimariesSmpte432 = MppFrameColorPrimaries(C.MPP_FRAME_PRI_SMPTE432) // SMPTE ST 432-1 (2010) / P3 D65 / Display P3
MppFramePrimariesJedecP22 = MppFrameColorPrimaries(C.MPP_FRAME_PRI_JEDEC_P22) // JEDEC P22 phosphors
MppFramePrimariesNB = MppFrameColorPrimaries(C.MPP_FRAME_PRI_NB) // Not part of ABI
)
// Color Transfer Characteristic
type MppFrameColorTransferCharacteristic = C.MppFrameColorTransferCharacteristic
const (
MppFrameTrcReserved0 = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_RESERVED0)
MppFrameTrcBt709 = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_BT709) // also ITU-R BT1361
MppFrameTrcUnspecified = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_UNSPECIFIED)
MppFrameTrcReserved = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_RESERVED)
MppFrameTrcGamma22 = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_GAMMA22) // also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
MppFrameTrcGamma28 = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_GAMMA28) // also ITU-R BT470BG
MppFrameTrcSmpte170M = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_SMPTE170M) // also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC
MppFrameTrcSmpte240M = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_SMPTE240M)
MppFrameTrcLinear = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_LINEAR) // "Linear transfer characteristics"
MppFrameTrcLog = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_LOG) // "Logarithmic transfer characteristic (100:1 range)"
MppFrameTrcLogSqrt = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_LOG_SQRT) // "Logarithmic transfer characteristic (100 * Sqrt(10) : 1 range)"
MppFrameTrcIec61966_2_4 = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_IEC61966_2_4) // IEC 61966-2-4
MppFrameTrcBt1361Ecg = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_BT1361_ECG) // ITU-R BT1361 Extended Colour Gamut
MppFrameTrcIec61966_2_1 = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_IEC61966_2_1) // IEC 61966-2-1 (sRGB or sYCC)
MppFrameTrcBt2020_10 = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_BT2020_10) // ITU-R BT2020 for 10 bit system
MppFrameTrcBt2020_12 = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_BT2020_12) // ITU-R BT2020 for 12 bit system
MppFrameTrcSmpte2084 = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_SMPTEST2084) // SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems
MppFrameTrcSmpte428_1 = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_SMPTEST428_1) // SMPTE ST 428-1
MppFrameTrcAribStdB67 = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_ARIB_STD_B67) // ARIB STD-B67, known as "Hybrid log-gamma"
MppFrameTrcNB = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_NB) // Not part of ABI
)
// YUV colorspace type
type MppFrameColorSpace = C.MppFrameColorSpace
const (
MppFrameSpcRGB = MppFrameColorSpace(C.MPP_FRAME_SPC_RGB) // order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB)
MppFrameSpcBt709 = MppFrameColorSpace(C.MPP_FRAME_SPC_BT709) // also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
MppFrameSpcUnspecified = MppFrameColorSpace(C.MPP_FRAME_SPC_UNSPECIFIED)
MppFrameSpcReserved = MppFrameColorSpace(C.MPP_FRAME_SPC_RESERVED)
MppFrameSpcFcc = MppFrameColorSpace(C.MPP_FRAME_SPC_FCC) // FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
MppFrameSpcBt470bg = MppFrameColorSpace(C.MPP_FRAME_SPC_BT470BG) // also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
MppFrameSpcSmpte170m = MppFrameColorSpace(C.MPP_FRAME_SPC_SMPTE170M) // also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
MppFrameSpcSmpte240m = MppFrameColorSpace(C.MPP_FRAME_SPC_SMPTE240M)
MppFrameSpcYcocg = MppFrameColorSpace(C.MPP_FRAME_SPC_YCOCG) // Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
MppFrameSpcBt2020Ncl = MppFrameColorSpace(C.MPP_FRAME_SPC_BT2020_NCL) // ITU-R BT2020 non-constant luminance system
MppFrameSpcBt2020Cl = MppFrameColorSpace(C.MPP_FRAME_SPC_BT2020_CL) // ITU-R BT2020 constant luminance system
MppFrameSpcSmpte2085 = MppFrameColorSpace(C.MPP_FRAME_SPC_SMPTE2085) // SMPTE 2085, Y'D'zD'x
MppFrameSpcChromaDerivedNcl = MppFrameColorSpace(C.MPP_FRAME_SPC_CHROMA_DERIVED_NCL) // Chromaticity-derived non-constant luminance system
MppFrameSpcChromaDerivedCl = MppFrameColorSpace(C.MPP_FRAME_SPC_CHROMA_DERIVED_CL) // Chromaticity-derived constant luminance system
MppFrameSpcIctcp = MppFrameColorSpace(C.MPP_FRAME_SPC_ICTCP) // ITU-R BT.2100-0, ICtCp
MppFrameSpcNB = MppFrameColorSpace(C.MPP_FRAME_SPC_NB) // Not part of ABI
)
// Location of chroma samples
type MppFrameChromaLocation = C.MppFrameChromaLocation
const (
MppChromaLocUnspecified = MppFrameChromaLocation(C.MPP_CHROMA_LOC_UNSPECIFIED)
MppChromaLocLeft = MppFrameChromaLocation(C.MPP_CHROMA_LOC_LEFT) // mpeg2/4 4:2:0, h264 default for 4:2:0
MppChromaLocCenter = MppFrameChromaLocation(C.MPP_CHROMA_LOC_CENTER) // mpeg1 4:2:0, jpeg 4:2:0, h263 4:2:0
MppChromaLocTopLeft = MppFrameChromaLocation(C.MPP_CHROMA_LOC_TOPLEFT) // ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2
MppChromaLocTop = MppFrameChromaLocation(C.MPP_CHROMA_LOC_TOP)
MppChromaLocBottomLeft = MppFrameChromaLocation(C.MPP_CHROMA_LOC_BOTTOMLEFT)
MppChromaLocBottom = MppFrameChromaLocation(C.MPP_CHROMA_LOC_BOTTOM)
MppChromaLocNB = MppFrameChromaLocation(C.MPP_CHROMA_LOC_NB) // Not part of ABI
)
type MppFrameChromaFormat = C.int
const (
MppChromaFormatUnspecified = MppFrameChromaFormat(C.MPP_CHROMA_UNSPECIFIED)
MppChromaFormat400 = MppFrameChromaFormat(C.MPP_CHROMA_400)
MppChromaFormat410 = MppFrameChromaFormat(C.MPP_CHROMA_410)
MppChromaFormat411 = MppFrameChromaFormat(C.MPP_CHROMA_411)
MppChromaFormat420 = MppFrameChromaFormat(C.MPP_CHROMA_420)
MppChromaFormat422 = MppFrameChromaFormat(C.MPP_CHROMA_422)
MppChromaFormat440 = MppFrameChromaFormat(C.MPP_CHROMA_440)
MppChromaFormat444 = MppFrameChromaFormat(C.MPP_CHROMA_444)
)
// MppFrameFormat bit flag
const (
MppFrameFmtMask = C.MPP_FRAME_FMT_MASK
MppFrameFmtPropMask = C.MPP_FRAME_FMT_PROP_MASK
MppFrameFmtColorMask = C.MPP_FRAME_FMT_COLOR_MASK
MppFrameFmtYuv = C.MPP_FRAME_FMT_YUV
MppFrameFmtRgb = C.MPP_FRAME_FMT_RGB
MppFrameFbcMask = C.MPP_FRAME_FBC_MASK
MppFrameFbcNone = C.MPP_FRAME_FBC_NONE
MppFrameHdrMask = C.MPP_FRAME_HDR_MASK
MppFrameHdrNone = C.MPP_FRAME_HDR_NONE
MppFrameHdr = C.MPP_FRAME_HDR
MppFrameTileFlag = C.MPP_FRAME_TILE_FLAG
)
// AFBC_V1 is for ISP output.
const MppFrameFbcAfbcV1 = C.MPP_FRAME_FBC_AFBC_V1
// AFBC_V2 is for video decoder output.
const MppFrameFbcAfbcV2 = C.MPP_FRAME_FBC_AFBC_V2
const MppFrameFmtLeMask = C.MPP_FRAME_FMT_LE_MASK
func MppFrameFmtIsYUV(fmt MppFrameFormat) bool {
return ((fmt & MppFrameFmtColorMask) == MppFrameFmtYuv) && ((fmt & MppFrameFmtMask) < MppFmtYuvButt)
}
func MppFrameFmtIsYUV10Bit(fmt MppFrameFormat) bool {
return (fmt&MppFrameFmtMask) == MppFmtYuv420sp10Bit || (fmt&MppFrameFmtMask) == MppFmtYuv422sp10Bit
}
func MppFrameFmtIsRGB(fmt MppFrameFormat) bool {
return ((fmt & MppFrameFmtColorMask) == MppFrameFmtRgb) && ((fmt & MppFrameFmtMask) < MppFmtRgbButt)
}
// For MPP_FRAME_FBC_AFBC_V1 the 16byte aligned stride is used.
func MppFrameFmtIsFbc(fmt MppFrameFormat) bool {
return (fmt & MppFrameFbcMask) != MppFrameFbcNone
}
func MppFrameFmtIsHdr(fmt MppFrameFormat) bool {
return (fmt & MppFrameHdrMask) != MppFrameHdrNone
}
func MppFrameFmtIsLe(fmt MppFrameFormat) bool {
return (fmt & MppFrameFmtLeMask) == MppFrameFmtLeMask
}
func MppFrameFmtIsBe(fmt MppFrameFormat) bool {
return (fmt & MppFrameFmtLeMask) == 0
}
func MppFrameFmtIsTile(fmt MppFrameFormat) bool {
return (fmt & MppFrameTileFlag) != 0
}
// mpp color format index definition
type MppFrameFormat = C.MppFrameFormat
const (
MppFmtYuv420sp = MppFrameFormat(C.MPP_FMT_YUV420SP) // YYYY... UV... (NV12)
/*
* A rockchip specific pixel format, without gap between pixel aganist
* the P010_10LE/P010_10BE
*/
MppFmtYuv420sp10Bit = MppFrameFormat(C.MPP_FMT_YUV420SP_10BIT)
MppFmtYuv422sp = MppFrameFormat(C.MPP_FMT_YUV422SP) // YYYY... UVUV... (NV16)
MppFmtYuv422sp10Bit = MppFrameFormat(C.MPP_FMT_YUV422SP_10BIT) ///< Not part of ABI
MppFmtYuv420p = MppFrameFormat(C.MPP_FMT_YUV420P) // YYYY... U...V... (I420)
MppFmtYuv420spVu = MppFrameFormat(C.MPP_FMT_YUV420SP_VU) // YYYY... VUVUVU... (NV21)
MppFmtYuv422p = MppFrameFormat(C.MPP_FMT_YUV422P) // YYYY... UU...VV...(422P)
MppFmtYuv422spVu = MppFrameFormat(C.MPP_FMT_YUV422SP_VU) // YYYY... VUVUVU... (NV61)
MppFmtYuv422Yuyv = MppFrameFormat(C.MPP_FMT_YUV422_YUYV) // YUYVYUYV... (YUY2)
MppFmtYuv422Yvyu = MppFrameFormat(C.MPP_FMT_YUV422_YVYU) // YVYUYVYU... (YVY2)
MppFmtYuv422Uyvy = MppFrameFormat(C.MPP_FMT_YUV422_UYVY) // UYVYUYVY... (UYVY)
MppFmtYuv422Vyuy = MppFrameFormat(C.MPP_FMT_YUV422_VYUY) // VYUYVYUY... (VYUY)
MppFmtYuv400 = MppFrameFormat(C.MPP_FMT_YUV400) // YYYY...
MppFmtYuv440sp = MppFrameFormat(C.MPP_FMT_YUV440SP) // YYYY... UVUV...
MppFmtYuv411sp = MppFrameFormat(C.MPP_FMT_YUV411SP) // YYYY... UV...
MppFmtYuv444sp = MppFrameFormat(C.MPP_FMT_YUV444SP) // YYYY... UVUVUVUV...
MppFmtYuv444p = MppFrameFormat(C.MPP_FMT_YUV444P) // YYYY... UUUU... VVVV...
MppFmtYuvButt = MppFrameFormat(C.MPP_FMT_YUV_BUTT)
MppFmtRgb565 = MppFrameFormat(C.MPP_FMT_RGB565) // 16-bit RGB
MppFmtBgr565 = MppFrameFormat(C.MPP_FMT_BGR565) // 16-bit RGB
MppFmtRgb555 = MppFrameFormat(C.MPP_FMT_RGB555) // 15-bit RGB
MppFmtBgr555 = MppFrameFormat(C.MPP_FMT_BGR555) // 15-bit RGB
MppFmtRgb444 = MppFrameFormat(C.MPP_FMT_RGB444) // 12-bit RGB
MppFmtBgr444 = MppFrameFormat(C.MPP_FMT_BGR444) // 12-bit RGB
MppFmtRgb888 = MppFrameFormat(C.MPP_FMT_RGB888) // 24-bit RGB
MppFmtBgr888 = MppFrameFormat(C.MPP_FMT_BGR888) // 24-bit RGB
MppFmtRgb101010 = MppFrameFormat(C.MPP_FMT_RGB101010) // 30-bit RGB
MppFmtBgr101010 = MppFrameFormat(C.MPP_FMT_BGR101010) // 30-bit RGB
MppFmtArgb8888 = MppFrameFormat(C.MPP_FMT_ARGB8888) // 32-bit RGB
MppFmtAbgr8888 = MppFrameFormat(C.MPP_FMT_ABGR8888) // 32-bit RGB
MppFmtBgra8888 = MppFrameFormat(C.MPP_FMT_BGRA8888) // 32-bit RGB
MppFmtRgba8888 = MppFrameFormat(C.MPP_FMT_RGBA8888) // 32-bit RGB
MppFmtRgbButt = MppFrameFormat(C.MPP_FMT_RGB_BUTT)
MppFmtButt = MppFrameFormat(C.MPP_FMT_BUTT)
)
type MppFrameRational struct {
c C.struct_MppFrameRational
}
func (r *MppFrameRational) Num() int32 {
return int32(r.c.num)
}
func (r *MppFrameRational) Den() int32 {
return int32(r.c.den)
}
func (r *MppFrameRational) SetNum(num int32) {
r.c.num = cS32(num)
}
func (r *MppFrameRational) SetDen(den int32) {
r.c.den = cS32(den)
}
type MppFrameMasteringDisplayMetadata struct {
c C.struct_MppFrameMasteringDisplayMetadata
}
func (m *MppFrameMasteringDisplayMetadata) DisplayPrimaries() [3][2]uint16 {
var result [3][2]uint16
for i := 0; i < 3; i++ {
for j := 0; j < 2; j++ {
result[i][j] = uint16(m.c.display_primaries[i][j])
}
}
return result
}
func (m *MppFrameMasteringDisplayMetadata) WhitePoint() [2]uint16 {
var result [2]uint16
for i := 0; i < 2; i++ {
result[i] = uint16(m.c.white_point[i])
}
return result
}
func (m *MppFrameMasteringDisplayMetadata) MaxLuminance() uint32 {
return uint32(m.c.max_luminance)
}
func (m *MppFrameMasteringDisplayMetadata) MinLuminance() uint32 {
return uint32(m.c.min_luminance)
}
func (m *MppFrameMasteringDisplayMetadata) SetDisplayPrimaries(displayPrimaries [3][2]uint16) {
for i := 0; i < 3; i++ {
for j := 0; j < 2; j++ {
m.c.display_primaries[i][j] = cU16(displayPrimaries[i][j])
}
}
}
func (m *MppFrameMasteringDisplayMetadata) SetWhitePoint(whitePoint [2]uint16) {
for i := 0; i < 2; i++ {
m.c.white_point[i] = cU16(whitePoint[i])
}
}
func (m *MppFrameMasteringDisplayMetadata) SetMaxLuminance(maxLuminance uint32) {
m.c.max_luminance = cU32(maxLuminance)
}
func (m *MppFrameMasteringDisplayMetadata) SetMinLuminance(minLuminance uint32) {
m.c.min_luminance = cU32(minLuminance)
}
type MppFrameContentLightMetadata struct {
c C.struct_MppFrameContentLightMetadata
}
func (m *MppFrameContentLightMetadata) MaxCLL() uint16 {
return uint16(m.c.MaxCLL)
}
func (m *MppFrameContentLightMetadata) MaxFALL() uint16 {
return uint16(m.c.MaxFALL)
}
func (m *MppFrameContentLightMetadata) SetMaxCLL(maxCLL uint16) {
m.c.MaxCLL = cU16(maxCLL)
}
func (m *MppFrameContentLightMetadata) SetMaxFALL(maxFALL uint16) {
m.c.MaxFALL = cU16(maxFALL)
}
type MppFrameHdrDynamicMeta struct {
c *C.struct_MppFrameHdrDynamicMeta
}
func (m *MppFrameHdrDynamicMeta) HdrFmt() uint32 {
return uint32(m.c.hdr_fmt)
}
func (m *MppFrameHdrDynamicMeta) Size() uint32 {
return uint32(m.c.size)
}
func (m *MppFrameHdrDynamicMeta) SetHdrFmt(hdrFmt uint32) {
m.c.hdr_fmt = cU32(hdrFmt)
}
func (m *MppFrameHdrDynamicMeta) SetSize(size uint32) {
m.c.size = cU32(size)
}
type MppFrameError = C.int
const (
MppFrameErrUnknow = MppFrameError(C.MPP_FRAME_ERR_UNKNOW) // General error not specified
MppFrameErrUnsupport = MppFrameError(C.MPP_FRAME_ERR_UNSUPPORT) // Critical error for decoder not support error
MppFrameErrDecInvalid = MppFrameError(C.MPP_FRAME_ERR_DEC_INVALID) // Fatal error for decoder can not parse a valid frame for hardware. the pixel data is all invalid.
MppFrameErrDecHwErr = MppFrameError(C.MPP_FRAME_ERR_DEC_HW_ERR) // Normal error for decoder found hardware error on decoding.
MppFrameErrDecMissRef = MppFrameError(C.MPP_FRAME_ERR_DEC_MISS_REF) // Normal error for decoder found missing reference frame on decoding.
)
func MppFrameInit() (*MppFrame, MppRet) {
cFrame := C.MppFrame(nil)
ret := MppRet(C.mpp_frame_init(&cFrame))
return &MppFrame{c: &cFrame}, ret
}
func (f *MppFrame) Deinit() MppRet {
return MppRet(C.mpp_frame_deinit(f.c))
}
func (f *MppFrame) GetWidth() uint32 {
return uint32(C.mpp_frame_get_width(*f.c))
}
func (f *MppFrame) SetWidth(width uint32) {
C.mpp_frame_set_width(*f.c, cU32(width))
}
func (f *MppFrame) GetHeight() uint32 {
return uint32(C.mpp_frame_get_height(*f.c))
}
func (f *MppFrame) SetHeight(height uint32) {
C.mpp_frame_set_height(*f.c, cU32(height))
}
func (f *MppFrame) GetHorStride() uint32 {
return uint32(C.mpp_frame_get_hor_stride(*f.c))
}
func (f *MppFrame) SetHorStride(horStride uint32) {
C.mpp_frame_set_hor_stride(*f.c, cU32(horStride))
}
func (f *MppFrame) GetVerStride() uint32 {
return uint32(C.mpp_frame_get_ver_stride(*f.c))
}
func (f *MppFrame) SetVerStride(verStride uint32) {
C.mpp_frame_set_ver_stride(*f.c, cU32(verStride))
}
func (f *MppFrame) SetHorStridePixel(horStridePixel uint32) {
C.mpp_frame_set_hor_stride_pixel(*f.c, cU32(horStridePixel))
}
func (f *MppFrame) GetHorStridePixel() uint32 {
return uint32(C.mpp_frame_get_hor_stride_pixel(*f.c))
}
func (f *MppFrame) SetFbcHdrStride(fbcHdrStride uint32) {
C.mpp_frame_set_fbc_hdr_stride(*f.c, cU32(fbcHdrStride))
}
func (f *MppFrame) GetFbcHdrStride() uint32 {
return uint32(C.mpp_frame_get_fbc_hdr_stride(*f.c))
}
func (f *MppFrame) GetOffsetX() uint32 {
return uint32(C.mpp_frame_get_offset_x(*f.c))
}
func (f *MppFrame) SetOffsetX(offsetX uint32) {
C.mpp_frame_set_offset_x(*f.c, cU32(offsetX))
}
func (f *MppFrame) GetOffsetY() uint32 {
return uint32(C.mpp_frame_get_offset_y(*f.c))
}
func (f *MppFrame) SetOffsetY(offsetY uint32) {
C.mpp_frame_set_offset_y(*f.c, cU32(offsetY))
}
func (f *MppFrame) GetMode() uint32 {
return uint32(C.mpp_frame_get_mode(*f.c))
}
func (f *MppFrame) SetMode(mode uint32) {
C.mpp_frame_set_mode(*f.c, cU32(mode))
}
func (f *MppFrame) GetDiscard() uint32 {
return uint32(C.mpp_frame_get_discard(*f.c))
}
func (f *MppFrame) SetDiscard(discard uint32) {
C.mpp_frame_set_discard(*f.c, cU32(discard))
}
func (f *MppFrame) GetViewId() uint32 {
return uint32(C.mpp_frame_get_viewid(*f.c))
}
func (f *MppFrame) SetViewId(viewId uint32) {
C.mpp_frame_set_viewid(*f.c, cU32(viewId))
}
func (f *MppFrame) GetPoc() uint32 {
return uint32(C.mpp_frame_get_poc(*f.c))
}
func (f *MppFrame) SetPoc(poc uint32) {
C.mpp_frame_set_poc(*f.c, cU32(poc))
}
func (f *MppFrame) GetPts() int64 {
return int64(C.mpp_frame_get_pts(*f.c))
}
func (f *MppFrame) SetPts(pts int64) {
C.mpp_frame_set_pts(*f.c, cS64(pts))
}
func (f *MppFrame) GetDts() int64 {
return int64(C.mpp_frame_get_dts(*f.c))
}
func (f *MppFrame) SetDts(dts int64) {
C.mpp_frame_set_dts(*f.c, cS64(dts))
}
func (f *MppFrame) GetErrInfo() uint32 {
return uint32(C.mpp_frame_get_errinfo(*f.c))
}
func (f *MppFrame) SetErrInfo(errInfo uint32) {
C.mpp_frame_set_errinfo(*f.c, cU32(errInfo))
}
func (f *MppFrame) GetBufSize() int64 {
return int64(C.mpp_frame_get_buf_size(*f.c))
}
func (f *MppFrame) SetBufSize(bufSize int64) {
C.mpp_frame_set_buf_size(*f.c, C.size_t(bufSize))
}
func (f *MppFrame) SetThumbnailEn(thumbnailEn uint32) {
C.mpp_frame_set_thumbnail_en(*f.c, cU32(thumbnailEn))
}
func (f *MppFrame) GetThumbnailEn() uint32 {
return uint32(C.mpp_frame_get_thumbnail_en(*f.c))
}
// flow control parmeter
func (f *MppFrame) GetEos() uint32 {
return uint32(C.mpp_frame_get_eos(*f.c))
}
func (f *MppFrame) SetEos(eos uint32) {
C.mpp_frame_set_eos(*f.c, cU32(eos))
}
func (f *MppFrame) GetInfoChange() uint32 {
return uint32(C.mpp_frame_get_info_change(*f.c))
}
func (f *MppFrame) SetInfoChange(infoChange uint32) {
C.mpp_frame_set_info_change(*f.c, cU32(infoChange))
}
// buffer parameter
func (f *MppFrame) GetBuffer() *MppBuffer {
return &MppBuffer{c: C.mpp_frame_get_buffer(*f.c)}
}
func (f *MppFrame) SetBuffer(buf *MppBuffer) {
C.mpp_frame_set_buffer(*f.c, buf.c)
}
// meta data parameter
func (f *MppFrame) HasMeta() uint32 {
return uint32(C.mpp_frame_has_meta(*f.c))
}
func (f *MppFrame) GetMeta() *MppMeta {
return &MppMeta{c: C.mpp_frame_get_meta(*f.c)}
}
func (f *MppFrame) SetMeta(meta *MppMeta) {
C.mpp_frame_set_meta(*f.c, meta.c)
}
// color related parameter
func (f *MppFrame) GetColorRange() MppFrameColorRange {
return MppFrameColorRange(C.mpp_frame_get_color_range(*f.c))
}
func (f *MppFrame) SetColorRange(colorRange MppFrameColorRange) {
C.mpp_frame_set_color_range(*f.c, C.MppFrameColorRange(colorRange))
}
func (f *MppFrame) GetColorPrimaries() MppFrameColorPrimaries {
return MppFrameColorPrimaries(C.mpp_frame_get_color_primaries(*f.c))
}
func (f *MppFrame) SetColorPrimaries(colorPrimaries MppFrameColorPrimaries) {
C.mpp_frame_set_color_primaries(*f.c, colorPrimaries)
}
func (f *MppFrame) GetColorTrc() MppFrameColorTransferCharacteristic {
return MppFrameColorTransferCharacteristic(C.mpp_frame_get_color_trc(*f.c))
}
func (f *MppFrame) SetColorTrc(colorTrc MppFrameColorTransferCharacteristic) {
C.mpp_frame_set_color_trc(*f.c, colorTrc)
}
func (f *MppFrame) GetColorSpace() MppFrameColorSpace {
return MppFrameColorSpace(C.mpp_frame_get_colorspace(*f.c))
}
func (f *MppFrame) SetColorSpace(colorSpace MppFrameColorSpace) {
C.mpp_frame_set_colorspace(*f.c, colorSpace)
}
func (f *MppFrame) GetChromaLocation() MppFrameChromaLocation {
return MppFrameChromaLocation(C.mpp_frame_get_chroma_location(*f.c))
}
func (f *MppFrame) SetChromaLocation(chromaLocation MppFrameChromaLocation) {
C.mpp_frame_set_chroma_location(*f.c, chromaLocation)
}
func (f *MppFrame) GetFmt() MppFrameFormat {
return MppFrameFormat(C.mpp_frame_get_fmt(*f.c))
}
func (f *MppFrame) SetFmt(fmt MppFrameFormat) {
C.mpp_frame_set_fmt(*f.c, fmt)
}
func (f *MppFrame) GetSar() *MppFrameRational {
return &MppFrameRational{c: C.mpp_frame_get_sar(*f.c)}
}
func (f *MppFrame) SetSar(sar *MppFrameRational) {
C.mpp_frame_set_sar(*f.c, sar.c)
}
func (f *MppFrame) GetMasteringDisplay() *MppFrameMasteringDisplayMetadata {
return &MppFrameMasteringDisplayMetadata{c: C.mpp_frame_get_mastering_display(*f.c)}
}
func (f *MppFrame) SetMasteringDisplay(masteringDisplay *MppFrameMasteringDisplayMetadata) {
C.mpp_frame_set_mastering_display(*f.c, masteringDisplay.c)
}
func (f *MppFrame) GetContentLight() *MppFrameContentLightMetadata {
return &MppFrameContentLightMetadata{c: C.mpp_frame_get_content_light(*f.c)}
}
func (f *MppFrame) SetContentLight(contentLight *MppFrameContentLightMetadata) {
C.mpp_frame_set_content_light(*f.c, contentLight.c)
}
func (f *MppFrame) GetHdrDynamicMeta() *MppFrameHdrDynamicMeta {
return &MppFrameHdrDynamicMeta{c: C.mpp_frame_get_hdr_dynamic_meta(*f.c)}
}
func (f *MppFrame) SetHdrDynamicMeta(hdrDynamicMeta *MppFrameHdrDynamicMeta) {
C.mpp_frame_set_hdr_dynamic_meta(*f.c, hdrDynamicMeta.c)
}