-
Notifications
You must be signed in to change notification settings - Fork 2
/
de265.cc
738 lines (574 loc) · 19.9 KB
/
de265.cc
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
/*
* H.265 video codec.
* Copyright (c) 2013-2014 struktur AG, Dirk Farin <[email protected]>
*
* This file is part of libde265.
*
* libde265 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* libde265 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with libde265. If not, see <http://www.gnu.org/licenses/>.
*/
#define DEBUG_INSERT_STREAM_ERRORS 0
#include "de265.h"
#include "decctx.h"
#include "util.h"
#include "scan.h"
#include "image.h"
#include "sei.h"
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <mutex>
// TODO: should be in some vps.c related header
de265_error read_vps(decoder_context* ctx, bitreader* reader, video_parameter_set* vps);
extern "C" {
LIBDE265_API const char *de265_get_version(void)
{
return (LIBDE265_VERSION);
}
LIBDE265_API uint32_t de265_get_version_number(void)
{
return (LIBDE265_NUMERIC_VERSION);
}
LIBDE265_API int de265_get_version_number_major(void)
{
return ((LIBDE265_NUMERIC_VERSION)>>24) & 0xFF;
}
LIBDE265_API int de265_get_version_number_minor(void)
{
return ((LIBDE265_NUMERIC_VERSION)>>16) & 0xFF;
}
LIBDE265_API int de265_get_version_number_maintenance(void)
{
return ((LIBDE265_NUMERIC_VERSION)>>8) & 0xFF;
}
LIBDE265_API const char* de265_get_error_text(de265_error err)
{
switch (err) {
case DE265_OK: return "no error";
case DE265_ERROR_NO_SUCH_FILE: return "no such file";
//case DE265_ERROR_NO_STARTCODE: return "no startcode found";
//case DE265_ERROR_EOF: return "end of file";
case DE265_ERROR_COEFFICIENT_OUT_OF_IMAGE_BOUNDS: return "coefficient out of image bounds";
case DE265_ERROR_CHECKSUM_MISMATCH: return "image checksum mismatch";
case DE265_ERROR_CTB_OUTSIDE_IMAGE_AREA: return "CTB outside of image area";
case DE265_ERROR_OUT_OF_MEMORY: return "out of memory";
case DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE: return "coded parameter out of range";
case DE265_ERROR_IMAGE_BUFFER_FULL: return "DPB/output queue full";
case DE265_ERROR_CANNOT_START_THREADPOOL: return "cannot start decoding threads";
case DE265_ERROR_LIBRARY_INITIALIZATION_FAILED: return "global library initialization failed";
case DE265_ERROR_LIBRARY_NOT_INITIALIZED: return "cannot free library data (not initialized";
//case DE265_ERROR_MAX_THREAD_CONTEXTS_EXCEEDED:
// return "internal error: maximum number of thread contexts exceeded";
//case DE265_ERROR_MAX_NUMBER_OF_SLICES_EXCEEDED:
// return "internal error: maximum number of slices exceeded";
case DE265_ERROR_NOT_IMPLEMENTED_YET:
return "unimplemented decoder feature";
//case DE265_ERROR_SCALING_LIST_NOT_IMPLEMENTED:
//return "scaling list not implemented";
case DE265_ERROR_WAITING_FOR_INPUT_DATA:
return "no more input data, decoder stalled";
case DE265_ERROR_CANNOT_PROCESS_SEI:
return "SEI data cannot be processed";
case DE265_ERROR_PARAMETER_PARSING:
return "command-line parameter error";
case DE265_ERROR_NO_INITIAL_SLICE_HEADER:
return "first slice missing, cannot decode dependent slice";
case DE265_ERROR_PREMATURE_END_OF_SLICE:
return "premature end of slice data";
case DE265_ERROR_UNSPECIFIED_DECODING_ERROR:
return "unspecified decoding error";
case DE265_WARNING_NO_WPP_CANNOT_USE_MULTITHREADING:
return "Cannot run decoder multi-threaded because stream does not support WPP";
case DE265_WARNING_WARNING_BUFFER_FULL:
return "Too many warnings queued";
case DE265_WARNING_PREMATURE_END_OF_SLICE_SEGMENT:
return "Premature end of slice segment";
case DE265_WARNING_INCORRECT_ENTRY_POINT_OFFSET:
return "Incorrect entry-point offsets";
case DE265_WARNING_CTB_OUTSIDE_IMAGE_AREA:
return "CTB outside of image area (concealing stream error...)";
case DE265_WARNING_SPS_HEADER_INVALID:
return "sps header invalid";
case DE265_WARNING_PPS_HEADER_INVALID:
return "pps header invalid";
case DE265_WARNING_SLICEHEADER_INVALID:
return "slice header invalid";
case DE265_WARNING_INCORRECT_MOTION_VECTOR_SCALING:
return "impossible motion vector scaling";
case DE265_WARNING_NONEXISTING_PPS_REFERENCED:
return "non-existing PPS referenced";
case DE265_WARNING_NONEXISTING_SPS_REFERENCED:
return "non-existing SPS referenced";
case DE265_WARNING_BOTH_PREDFLAGS_ZERO:
return "both predFlags[] are zero in MC";
case DE265_WARNING_NONEXISTING_REFERENCE_PICTURE_ACCESSED:
return "non-existing reference picture accessed";
case DE265_WARNING_NUMMVP_NOT_EQUAL_TO_NUMMVQ:
return "numMV_P != numMV_Q in deblocking";
case DE265_WARNING_NUMBER_OF_SHORT_TERM_REF_PIC_SETS_OUT_OF_RANGE:
return "number of short-term ref-pic-sets out of range";
case DE265_WARNING_SHORT_TERM_REF_PIC_SET_OUT_OF_RANGE:
return "short-term ref-pic-set index out of range";
case DE265_WARNING_FAULTY_REFERENCE_PICTURE_LIST:
return "faulty reference picture list";
case DE265_WARNING_EOSS_BIT_NOT_SET:
return "end_of_sub_stream_one_bit not set to 1 when it should be";
case DE265_WARNING_MAX_NUM_REF_PICS_EXCEEDED:
return "maximum number of reference pictures exceeded";
case DE265_WARNING_INVALID_CHROMA_FORMAT:
return "invalid chroma format in SPS header";
case DE265_WARNING_SLICE_SEGMENT_ADDRESS_INVALID:
return "slice segment address invalid";
case DE265_WARNING_DEPENDENT_SLICE_WITH_ADDRESS_ZERO:
return "dependent slice with address 0";
case DE265_WARNING_NUMBER_OF_THREADS_LIMITED_TO_MAXIMUM:
return "number of threads limited to maximum amount";
case DE265_NON_EXISTING_LT_REFERENCE_CANDIDATE_IN_SLICE_HEADER:
return "non-existing long-term reference candidate specified in slice header";
case DE265_WARNING_CANNOT_APPLY_SAO_OUT_OF_MEMORY:
return "cannot apply SAO because we ran out of memory";
case DE265_WARNING_SPS_MISSING_CANNOT_DECODE_SEI:
return "SPS header missing, cannot decode SEI";
case DE265_WARNING_COLLOCATED_MOTION_VECTOR_OUTSIDE_IMAGE_AREA:
return "collocated motion-vector is outside image area";
case DE265_WARNING_PCM_BITDEPTH_TOO_LARGE:
return "PCM bit-depth too large";
default: return "unknown error";
}
}
LIBDE265_API int de265_isOK(de265_error err)
{
return err == DE265_OK || err >= 1000;
}
static int de265_init_count;
static std::mutex& de265_init_mutex()
{
static std::mutex de265_init_mutex;
return de265_init_mutex;
}
LIBDE265_API de265_error de265_init()
{
std::lock_guard<std::mutex> lock(de265_init_mutex());
de265_init_count++;
if (de265_init_count > 1) {
// we are not the first -> already initialized
return DE265_OK;
}
// do initializations
init_scan_orders();
if (!alloc_and_init_significant_coeff_ctxIdx_lookupTable()) {
de265_init_count--;
return DE265_ERROR_LIBRARY_INITIALIZATION_FAILED;
}
return DE265_OK;
}
LIBDE265_API de265_error de265_free()
{
std::lock_guard<std::mutex> lock(de265_init_mutex());
if (de265_init_count<=0) {
return DE265_ERROR_LIBRARY_NOT_INITIALIZED;
}
de265_init_count--;
if (de265_init_count==0) {
free_significant_coeff_ctxIdx_lookupTable();
}
return DE265_OK;
}
LIBDE265_API de265_decoder_context* de265_new_decoder()
{
de265_error init_err = de265_init();
if (init_err != DE265_OK) {
return NULL;
}
decoder_context* ctx = new decoder_context;
if (!ctx) {
de265_free();
return NULL;
}
return (de265_decoder_context*)ctx;
}
LIBDE265_API de265_error de265_free_decoder(de265_decoder_context* de265ctx)
{
decoder_context* ctx = (decoder_context*)de265ctx;
ctx->stop_thread_pool();
delete ctx;
return de265_free();
}
LIBDE265_API de265_error de265_start_worker_threads(de265_decoder_context* de265ctx, int number_of_threads)
{
decoder_context* ctx = (decoder_context*)de265ctx;
if (number_of_threads > MAX_THREADS) {
number_of_threads = MAX_THREADS;
}
if (number_of_threads>0) {
de265_error err = ctx->start_thread_pool(number_of_threads);
if (de265_isOK(err)) {
err = DE265_OK;
}
return err;
}
else {
return DE265_OK;
}
}
#ifndef LIBDE265_DISABLE_DEPRECATED
LIBDE265_API de265_error de265_decode_data(de265_decoder_context* de265ctx,
const void* data8, int len)
{
//decoder_context* ctx = (decoder_context*)de265ctx;
de265_error err;
if (len > 0) {
err = de265_push_data(de265ctx, data8, len, 0, NULL);
} else {
err = de265_flush_data(de265ctx);
}
if (err != DE265_OK) {
return err;
}
int more = 0;
do {
err = de265_decode(de265ctx, &more);
if (err != DE265_OK) {
more = 0;
}
switch (err) {
case DE265_ERROR_WAITING_FOR_INPUT_DATA:
// ignore error (didn't exist in 0.4 and before)
err = DE265_OK;
break;
default:
break;
}
} while (more);
return err;
}
#endif
static void dumpdata(const void* data, int len)
{
for (int i=0;i<len;i++) {
printf("%02x ", ((uint8_t*)data)[i]);
}
printf("\n");
}
LIBDE265_API de265_error de265_push_data(de265_decoder_context* de265ctx,
const void* data8, int len,
de265_PTS pts, void* user_data)
{
decoder_context* ctx = (decoder_context*)de265ctx;
uint8_t* data = (uint8_t*)data8;
//printf("push data (size %d)\n",len);
//dumpdata(data8,16);
return ctx->nal_parser.push_data(data,len,pts,user_data);
}
LIBDE265_API de265_error de265_push_NAL(de265_decoder_context* de265ctx,
const void* data8, int len,
de265_PTS pts, void* user_data)
{
decoder_context* ctx = (decoder_context*)de265ctx;
uint8_t* data = (uint8_t*)data8;
//printf("push NAL (size %d)\n",len);
//dumpdata(data8,16);
return ctx->nal_parser.push_NAL(data,len,pts,user_data);
}
LIBDE265_API de265_error de265_decode(de265_decoder_context* de265ctx, int* more)
{
decoder_context* ctx = (decoder_context*)de265ctx;
return ctx->decode(more);
}
LIBDE265_API void de265_push_end_of_NAL(de265_decoder_context* de265ctx)
{
decoder_context* ctx = (decoder_context*)de265ctx;
ctx->nal_parser.flush_data();
}
LIBDE265_API void de265_push_end_of_frame(de265_decoder_context* de265ctx)
{
de265_push_end_of_NAL(de265ctx);
decoder_context* ctx = (decoder_context*)de265ctx;
ctx->nal_parser.mark_end_of_frame();
}
LIBDE265_API de265_error de265_flush_data(de265_decoder_context* de265ctx)
{
de265_push_end_of_NAL(de265ctx);
decoder_context* ctx = (decoder_context*)de265ctx;
ctx->nal_parser.flush_data();
ctx->nal_parser.mark_end_of_stream();
return DE265_OK;
}
LIBDE265_API void de265_reset(de265_decoder_context* de265ctx)
{
decoder_context* ctx = (decoder_context*)de265ctx;
//printf("--- reset ---\n");
ctx->reset();
}
LIBDE265_API const struct de265_image* de265_get_next_picture(de265_decoder_context* de265ctx)
{
const struct de265_image* img = de265_peek_next_picture(de265ctx);
if (img) {
de265_release_next_picture(de265ctx);
}
return img;
}
LIBDE265_API const struct de265_image* de265_peek_next_picture(de265_decoder_context* de265ctx)
{
decoder_context* ctx = (decoder_context*)de265ctx;
if (ctx->num_pictures_in_output_queue()>0) {
de265_image* img = ctx->get_next_picture_in_output_queue();
return img;
}
else {
return NULL;
}
}
LIBDE265_API void de265_release_next_picture(de265_decoder_context* de265ctx)
{
decoder_context* ctx = (decoder_context*)de265ctx;
// no active output picture -> ignore release request
if (ctx->num_pictures_in_output_queue()==0) { return; }
de265_image* next_image = ctx->get_next_picture_in_output_queue();
loginfo(LogDPB, "release DPB with POC=%d\n",next_image->PicOrderCntVal);
next_image->PicOutputFlag = false;
// TODO: actually, we want to release it here, but we cannot without breaking API
// compatibility, because get_next_picture calls this immediately. Hence, we release
// images while scanning for available slots in the DPB.
// if (next_image->can_be_released()) { next_image->release(); }
// pop output queue
ctx->pop_next_picture_in_output_queue();
}
LIBDE265_API int de265_get_highest_TID(de265_decoder_context* de265ctx)
{
decoder_context* ctx = (decoder_context*)de265ctx;
return ctx->get_highest_TID();
}
LIBDE265_API int de265_get_current_TID(de265_decoder_context* de265ctx)
{
decoder_context* ctx = (decoder_context*)de265ctx;
return ctx->get_current_TID();
}
LIBDE265_API void de265_set_limit_TID(de265_decoder_context* de265ctx,int max_tid)
{
decoder_context* ctx = (decoder_context*)de265ctx;
ctx->set_limit_TID(max_tid);
}
LIBDE265_API void de265_set_framerate_ratio(de265_decoder_context* de265ctx,int percent)
{
decoder_context* ctx = (decoder_context*)de265ctx;
ctx->set_framerate_ratio(percent);
}
LIBDE265_API int de265_change_framerate(de265_decoder_context* de265ctx,int more)
{
decoder_context* ctx = (decoder_context*)de265ctx;
return ctx->change_framerate(more);
}
LIBDE265_API de265_error de265_get_warning(de265_decoder_context* de265ctx)
{
decoder_context* ctx = (decoder_context*)de265ctx;
return ctx->get_warning();
}
LIBDE265_API void de265_set_parameter_bool(de265_decoder_context* de265ctx, enum de265_param param, int value)
{
decoder_context* ctx = (decoder_context*)de265ctx;
switch (param)
{
case DE265_DECODER_PARAM_BOOL_SEI_CHECK_HASH:
ctx->param_sei_check_hash = !!value;
break;
case DE265_DECODER_PARAM_SUPPRESS_FAULTY_PICTURES:
ctx->param_suppress_faulty_pictures = !!value;
break;
case DE265_DECODER_PARAM_DISABLE_DEBLOCKING:
ctx->param_disable_deblocking = !!value;
break;
case DE265_DECODER_PARAM_DISABLE_SAO:
ctx->param_disable_sao = !!value;
break;
/*
case DE265_DECODER_PARAM_DISABLE_MC_RESIDUAL_IDCT:
ctx->param_disable_mc_residual_idct = !!value;
break;
case DE265_DECODER_PARAM_DISABLE_INTRA_RESIDUAL_IDCT:
ctx->param_disable_intra_residual_idct = !!value;
break;
*/
default:
assert(false);
break;
}
}
LIBDE265_API void de265_set_parameter_int(de265_decoder_context* de265ctx, enum de265_param param, int value)
{
decoder_context* ctx = (decoder_context*)de265ctx;
switch (param)
{
case DE265_DECODER_PARAM_DUMP_SPS_HEADERS:
ctx->param_sps_headers_fd = value;
break;
case DE265_DECODER_PARAM_DUMP_VPS_HEADERS:
ctx->param_vps_headers_fd = value;
break;
case DE265_DECODER_PARAM_DUMP_PPS_HEADERS:
ctx->param_pps_headers_fd = value;
break;
case DE265_DECODER_PARAM_DUMP_SLICE_HEADERS:
ctx->param_slice_headers_fd = value;
break;
case DE265_DECODER_PARAM_ACCELERATION_CODE:
ctx->set_acceleration_functions((enum de265_acceleration)value);
break;
default:
assert(false);
break;
}
}
LIBDE265_API int de265_get_parameter_bool(de265_decoder_context* de265ctx, enum de265_param param)
{
decoder_context* ctx = (decoder_context*)de265ctx;
switch (param)
{
case DE265_DECODER_PARAM_BOOL_SEI_CHECK_HASH:
return ctx->param_sei_check_hash;
case DE265_DECODER_PARAM_SUPPRESS_FAULTY_PICTURES:
return ctx->param_suppress_faulty_pictures;
case DE265_DECODER_PARAM_DISABLE_DEBLOCKING:
return ctx->param_disable_deblocking;
case DE265_DECODER_PARAM_DISABLE_SAO:
return ctx->param_disable_sao;
/*
case DE265_DECODER_PARAM_DISABLE_MC_RESIDUAL_IDCT:
return ctx->param_disable_mc_residual_idct;
case DE265_DECODER_PARAM_DISABLE_INTRA_RESIDUAL_IDCT:
return ctx->param_disable_intra_residual_idct;
*/
default:
assert(false);
return false;
}
}
LIBDE265_API int de265_get_number_of_input_bytes_pending(de265_decoder_context* de265ctx)
{
decoder_context* ctx = (decoder_context*)de265ctx;
return ctx->nal_parser.bytes_in_input_queue();
}
LIBDE265_API int de265_get_number_of_NAL_units_pending(de265_decoder_context* de265ctx)
{
decoder_context* ctx = (decoder_context*)de265ctx;
return ctx->nal_parser.number_of_NAL_units_pending();
}
LIBDE265_API int de265_get_image_width(const struct de265_image* img,int channel)
{
switch (channel) {
case 0:
return img->width_confwin;
case 1:
case 2:
return img->chroma_width_confwin;
default:
return 0;
}
}
LIBDE265_API int de265_get_image_height(const struct de265_image* img,int channel)
{
switch (channel) {
case 0:
return img->height_confwin;
case 1:
case 2:
return img->chroma_height_confwin;
default:
return 0;
}
}
LIBDE265_API int de265_get_bits_per_pixel(const struct de265_image* img,int channel)
{
switch (channel) {
case 0:
return img->get_sps().BitDepth_Y;
case 1:
case 2:
return img->get_sps().BitDepth_C;
default:
return 0;
}
}
LIBDE265_API enum de265_chroma de265_get_chroma_format(const struct de265_image* img)
{
return img->get_chroma_format();
}
LIBDE265_API const uint8_t* de265_get_image_plane(const de265_image* img, int channel, int* stride)
{
assert(channel>=0 && channel <= 2);
uint8_t* data = img->pixels_confwin[channel];
if (stride) *stride = img->get_image_stride(channel) * ((de265_get_bits_per_pixel(img, channel)+7) / 8);
return data;
}
LIBDE265_API void *de265_get_image_plane_user_data(const struct de265_image* img, int channel)
{
assert(channel>=0 && channel <= 2);
return img->plane_user_data[channel];
}
LIBDE265_API void de265_set_image_plane(de265_image* img, int cIdx, void* mem, int stride, void *userdata)
{
// The internal "stride" is the number of pixels per line.
stride = stride / ((de265_get_bits_per_pixel(img, cIdx)+7) / 8);
img->set_image_plane(cIdx, (uint8_t*)mem, stride, userdata);
}
LIBDE265_API void de265_set_image_allocation_functions(de265_decoder_context* de265ctx,
de265_image_allocation* allocfunc,
void* userdata)
{
decoder_context* ctx = (decoder_context*)de265ctx;
ctx->set_image_allocation_functions(allocfunc, userdata);
}
LIBDE265_API const struct de265_image_allocation *de265_get_default_image_allocation_functions(void)
{
return &de265_image::default_image_allocation;
}
LIBDE265_API de265_PTS de265_get_image_PTS(const struct de265_image* img)
{
return img->pts;
}
LIBDE265_API void* de265_get_image_user_data(const struct de265_image* img)
{
return img->user_data;
}
LIBDE265_API void de265_set_image_user_data(struct de265_image* img, void *user_data)
{
img->user_data = user_data;
}
LIBDE265_API void de265_get_image_NAL_header(const struct de265_image* img,
int* nal_unit_type,
const char** nal_unit_name,
int* nuh_layer_id,
int* nuh_temporal_id)
{
if (nal_unit_type) *nal_unit_type = img->nal_hdr.nal_unit_type;
if (nal_unit_name) *nal_unit_name = get_NAL_name(img->nal_hdr.nal_unit_type);
if (nuh_layer_id) *nuh_layer_id = img->nal_hdr.nuh_layer_id;
if (nuh_temporal_id) *nuh_temporal_id = img->nal_hdr.nuh_temporal_id;
}
LIBDE265_API int de265_get_image_full_range_flag(const struct de265_image* img)
{
return img->get_sps().vui.video_full_range_flag;
}
LIBDE265_API int de265_get_image_colour_primaries(const struct de265_image* img)
{
return img->get_sps().vui.colour_primaries;
}
LIBDE265_API int de265_get_image_transfer_characteristics(const struct de265_image* img)
{
return img->get_sps().vui.transfer_characteristics;
}
LIBDE265_API int de265_get_image_matrix_coefficients(const struct de265_image* img)
{
return img->get_sps().vui.matrix_coeffs;
}
}