summaryrefslogtreecommitdiffstats
path: root/DOCS/tech/nut.txt
blob: ba559978747149eba1607482802c428e72270386 (plain)
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
==================================
NUT Open Container Format 20061104
==================================



Intro:
======

NUT is a free multimedia container format for storage of audio, video,
subtitles and related user defined streams, it provides exact timestamps for
synchronization and seeking, is simple, has low overhead and can recover
in case of errors in the stream.

Other common multimedia container formats are AVI, Ogg, Matroska, MP4, MOV
ASF, MPEG-PS, MPEG-TS.


Features / goals:
    (supported by the format, not necessarily by a specific implementation)

Simplicity
    Use the same encoding for nearly all fields.
    Simple decoding, so slow CPUs (and embedded systems) can handle it.

Extensibility
    No limit for the possible values of all fields (using universal vlc).
    Allow adding of new headers in the future.
    Allow adding more fields at the end of headers.

Compactness
    ~0.2% overhead for normal bitrates.
    The index is <100kb per hour.
    A typical file header is about 100 bytes (audio + video headers together).
    A packet header is about ~1-5 bytes.

Error resistance
    Seeking / playback is possible without an index.
    Headers & index can be repeated.
    Damaged files can be played back with minimal data loss and fast
    resynchronization times.

The specification is frozen. All files following the specification will be
compatible unless the specification is unfrozen.


Definitions:
============

MUST    The specific part must be done to conform to this standard.
SHOULD  It is recommended to be done that way, but not strictly required.

keyframe
    A keyframe is a frame from which you can start decoding, a more
    exact definition is below
    The nth frame is a keyframe if and only if frames n, n+1, ... in
    presentation order (that are all frames with a pts >= frame[n].pts) can
    be decoded successfully without reference to frames prior n in storage
    order (that are all frames with a dts < frame[n].dts).
    If no such frames exist (for example due to using overlapped transforms
    like the MDCT in an audio codec), then the definition shall be extended
    by dropping n out of the set of frames which must be decodable, if this
    is still insufficient then n+1 shall be dropped, and so on until there is
    a keyframe.
    Every frame which is marked as a keyframe MUST be a keyframe according to
    the definition above, a muxer MUST mark every frame it knows is a keyframe
    as such, a muxer SHOULD NOT analyze future frames to determine the
    keyframe status of the current frame but instead just set the frame as
    non-keyframe.
    (FIXME maybe move somewhere else?)
pts
    Presentation time of the first frame/sample that is completed by decoding
    the coded frame.
dts
    The time when a frame is input into a synchronous 1-in-1-out decoder.


Syntax:
=======

Since NUT heavily uses variable length fields, the simplest way to describe it
is using a pseudocode approach.



Conventions:
============

The data types have a name, used in the bitstream syntax description, a short
text description and a pseudocode (functional) definition, optional notes may
follow:

name    (text description)
    functional definition
    [Optional notes]

The bitstream syntax elements have a tagname and a functional definition, they
are presented in a bottom-up approach, again optional notes may follow and
are reproduced in the tag description:

name:    (optional note)
    functional definition
    [Optional notes]

The in-depth tag description follows the bitstream syntax.
The functional definition has a C-like syntax.



Type definitions:
=================

f(n)    (n fixed bits in big-endian order)
u(n)    (unsigned number encoded in n bits in MSB-first order)

v   (variable length value, unsigned)
    value=0
    do{
        more_data                       u(1)
        data                            u(7)
        value= 128*value + data
    }while(more_data)

s   (variable length value, signed)
    temp                                v
    temp++
    if(temp&1) value= -(temp>>1)
    else       value=  (temp>>1)

b   (binary data or string, to be use in vb, see below)
    for(i=0; i<length; i++){
        data[i]                         u(8)
    }
    [Note: strings MUST be encoded in UTF-8]
    [Note: the character NUL (U+0000) is not legal within
    or at the end of a string.]

vb  (variable length binary data or string)
    length                              v
    value                               b

t (v coded universal timestamp)
    tmp                                 v
    id= tmp % time_base_count
    value= (tmp / time_base_count) * time_base[id]


Bitstream syntax:
=================

file:
    file_id_string
    while(!eof){
        if(next_byte == 'N'){
            packet_header
            switch(startcode){
                case      main_startcode:  main_header; break;
                case    stream_startcode:stream_header; break;
                case      info_startcode:  info_packet; break;
                case     index_startcode:        index; break;
                case syncpoint_startcode:    syncpoint; break;
            }
            packet_footer
        }else
            frame
    }

The structure of an undamaged file should look like the following, but
demuxers should be flexible and be able to deal with damaged headers so the
above is a better loop in practice (not to mention it is simpler).
Note: Demuxers MUST be able to deal with new and unknown headers.

file:
    file_id_string
    while(!eof){
        packet_header, main_header, packet_footer
        reserved_headers
        for(i=0; i<stream_count; i++){
            packet_header, stream_header, packet_footer
            reserved_headers
        }
        while(next_code == info_startcode){
            packet_header, info_packet, packet_footer
            reserved_headers
        }
        if(next_code == index_startcode){
            packet_header, index_packet, packet_footer
        }
        if (!eof) while(next_code != main_startcode){
            if(next_code == syncpoint_startcode){
                packet_header, syncpoint, packet_footer
            }
            frame
            reserved_headers
        }
    }


Common elements:
----------------

reserved_bytes:
    for(i=0; i<forward_ptr - length_of_non_reserved; i++)
        reserved                        u(8)
    [A demuxer MUST ignore any reserved bytes.
    A muxer MUST NOT write any reserved bytes, as this would make it
    impossible to add new fields at the end of packets in the future
    in a compatible way.]

packet_header
    startcode                           f(64)
    forward_ptr                         v
    if(forward_ptr > 4096)
        header_checksum                 u(32)

packet_footer
    checksum                            u(32)

reserved_headers
    while(next_byte == 'N' && next_code !=      main_startcode
                           && next_code !=    stream_startcode
                           && next_code !=      info_startcode
                           && next_code !=     index_startcode
                           && next_code != syncpoint_startcode){
        packet_header
        reserved_bytes
        packet_footer
    }

        Headers:

main_header:
    version                             v
    stream_count                        v
    max_distance                        v
    time_base_count                     v
    for(i=0; i<time_base_count; i++)
        time_base_num                   v
        time_base_denom                 v
        time_base[i]= time_base_num/time_base_denom
    tmp_pts=0
    tmp_mul=1
    tmp_stream=0
    for(i=0; i<256; ){
        tmp_flag                        v
        tmp_fields                      v
        if(tmp_fields>0) tmp_pts        s
        if(tmp_fields>1) tmp_mul        v
        if(tmp_fields>2) tmp_stream     v
        if(tmp_fields>3) tmp_size       v
        else tmp_size=0
        if(tmp_fields>4) tmp_res        v
        else tmp_res=0
        if(tmp_fields>5) count          v
        else count= tmp_mul - tmp_size
        for(j=6; j<tmp_fields; j++){
            tmp_reserved[i]             v
        }
        for(j=0; j<count && i<256; j++, i++){
            if (i == 'N') {
                flags[i]= FLAG_INVALID;
                j--;
                continue;
            }
            flags[i]= tmp_flag;
            stream_id[i]= tmp_stream;
            data_size_mul[i]= tmp_mul;
            data_size_lsb[i]= tmp_size + j;
            pts_delta[i]= tmp_pts;
            reserved_count[i]= tmp_res;
        }
    }
    reserved_bytes

stream_header:
    stream_id                           v
    stream_class                        v
    fourcc                              vb
    time_base_id                        v
    msb_pts_shift                       v
    max_pts_distance                    v
    decode_delay                        v
    stream_flags                        v
    codec_specific_data                 vb
    if(stream_class == video){
        width                           v
        height                          v
        sample_width                    v
        sample_height                   v
        colorspace_type                 v
    }else if(stream_class == audio){
        samplerate_num                  v
        samplerate_denom                v
        channel_count                   v
    }
    reserved_bytes

        Basic Packets:

frame:
    frame_code                          f(8)
    frame_flags= flags[frame_code]
    frame_res= reserved_count[frame_code]
    if(frame_flags&FLAG_CODED){
        coded_flags                     v
        frame_flags ^= coded_flags
    }
    if(frame_flags&FLAG_STREAM_ID){
        stream_id                       v
    }
    if(frame_flags&FLAG_CODED_PTS){
        coded_pts                       v
    }
    if(frame_flags&FLAG_SIZE_MSB){
        data_size_msb                   v
    }
    if(frame_flags&FLAG_RESERVED)
        frame_res                       v
    for(i=0; i<frame_res; i++)
        reserved                        v
    if(frame_flags&FLAG_CHECKSUM){
        checksum                        u(32)
    }
    data

index:
    max_pts                             t
    syncpoints                          v
    for(i=0; i<syncpoints; i++){
        syncpoint_pos_div16             v
    }
    for(i=0; i<stream_count; i++){
        last_pts= -1
        for(j=0; j<syncpoints; ){
            x                           v
            type= x & 1
            x>>=1
            n=j
            if(type){
                flag= x & 1
                x>>=1
                while(x--)
                    has_keyframe[n++][i]=flag
                has_keyframe[n++][i]=!flag;
            }else{
                while(x != 1){
                    has_keyframe[n++][i]=x&1;
                    x>>=1;
                }
            }
            for(; j<n && j<syncpoints; j++){
                if (!has_keyframe[j][i]) continue
                A                           v
                if(!A){
                    A                       v
                    B                       v
                    eor_pts[j][i] = last_pts + A + B
                }else
                    B=0
                keyframe_pts[j][i] = last_pts + A
                last_pts += A + B
            }
        }
    }
    reserved_bytes
    index_ptr                           u(64)

info_packet:
    stream_id_plus1                     v
    chapter_id                          s (Note: Due to a typo this was v
                                           until 2006-11-04.)
    chapter_start                       t
    chapter_len                         v
    count                               v
    for(i=0; i<count; i++){
        name                            vb
        value                           s
        if (value==-1){
            type= "UTF-8"
            value                       vb
        }else if (value==-2){
            type                        vb
            value                       vb
        }else if (value==-3){
            type= "s"
            value                       s
        }else if (value==-4){
            type= "t"
            value                       t
        }else if (value<-4){
            type= "r"
            value.den= -value-4
            value.num                   s
        }else{
            type= "v"
        }
    }
    reserved_bytes

syncpoint:
    global_key_pts                      t
    back_ptr_div16                      v
    reserved_bytes

            Complete definition:


Tag description:
----------------

file_id_string
    "nut/multimedia container\0"
    The very first thing in every NUT file, useful for identifying NUT files.

*_startcode (f(64))
    all startcodes start with 'N'

main_startcode (f(64))
    0x7A561F5F04ADULL + (((uint64_t)('N'<<8) + 'M')<<48)

stream_startcode (f(64))
    0x11405BF2F9DBULL + (((uint64_t)('N'<<8) + 'S')<<48)

syncpoint_startcode (f(64))
    0xE4ADEECA4569ULL + (((uint64_t)('N'<<8) + 'K')<<48)

index_startcode (f(64))
    0xDD672F23E64EULL + (((uint64_t)('N'<<8) + 'X')<<48)

info_startcode (f(64))
    0xAB68B596BA78ULL + (((uint64_t)('N'<<8) + 'I')<<48)

version (v)
    NUT version. The current value is 3. All lower values are pre-freeze.

stream_count (v)
    number of streams in this file

time_base_count (v)
    number of different time bases in this file
    This MUST NOT be 0.

forward_ptr (v)
    Size of the packet data (exactly the distance from the first byte
    after the packet_header to the first byte of the next packet).
    Every NUT packet contains a forward_ptr immediately after its startcode
    with the exception of frame_code-based packets. The forward pointer
    can be used to skip over the packet without decoding its contents.

max_distance (v)
    maximum distance between startcodes. If p1 and p2 are the byte
    positions of the first byte of two consecutive startcodes, then
    p2-p1 MUST be less than or equal to max_distance unless the entire
    span from p1 to p2 comprises a single packet or a syncpoint
    followed by a single frame. This imposition places efficient upper
    bounds on seek operations and allows for the detection of damaged
    frame headers, should a chain of frame headers pass max_distance
    without encountering any startcode.

    Syncpoints SHOULD be placed immediately before a keyframe if the
    previous frame of the same stream was a non-keyframe, unless such
    non-keyframe - keyframe transitions are very frequent.

    SHOULD be set to <=32768.
    If the stored value is >65536 then max_distance MUST be set to 65536.

    This is also half the maximum frame size without a checksum after the
    frame header.


max_pts_distance (v)
    Maximum absolute difference of the pts of the new frame from last_pts in
    the timebase of the stream, without a checksum after the frame header.
    A frame header MUST include a checksum if abs(pts-last_pts) is
    strictly greater than max_pts_distance.
    Note that last_pts is not necessarily the pts of the last frame
    on the same stream, as it is altered by syncpoint timestamps.
    SHOULD NOT be higher than 1/timebase.

stream_id (v)
    Stream identifier
    stream_id MUST be < stream_count

stream_class (v)
    0    video
    1    audio
    2    subtitles
    3    userdata
    Note: The remaining values are reserved and MUST NOT be used.
          A demuxer MUST ignore streams with reserved classes.

fourcc (vb)
    identification for the codec
    example: "H264"
    MUST contain 2 or 4 bytes, note, this might be increased in the future
    if needed.
    The ID values used are the same as in AVI, so if a codec uses a specific
    FourCC in AVI then the same FourCC MUST be used here.

time_base_num (v) / time_base_denom (v) = time_base
    the length of a timer tick in seconds, this MUST be equal to the 1/fps
    if FLAG_FIXED_FPS is set
    time_base_num and time_base_denom MUST NOT be 0
    time_base_num and time_base_denom MUST be relatively prime
    time_base_denom MUST be < 2^31
    examples:
        fps       time_base_num    time_base_denom
        30        1                30
        29.97     1001             30000
        23.976    1001             24000
    There MUST NOT be 2 identical timebases in a file.
    There SHOULD NOT be more timebases than streams.

time_base_id (v)
    index into the time_base table
    MUST be < time_base_count.

convert_ts
    To switch from 2 different timebases, the following calculation is
    defined:

    ln        = from_time_base_num*to_time_base_denom
    sn        = from_timestamp
    d1        = from_time_base_denom
    d2        = to_time_base_num
    timestamp = (ln/d1*sn + ln%d1*sn/d1)/d2
    Note: This calculation MUST be done with unsigned 64 bit integers, and
    is equivalent to (ln*sn)/(d1*d2) but this would require a 96 bit integer.

compare_ts
    Compares timestamps from 2 different timebases,
    if a is before b then compare_ts(a, b) = -1
    if a is after  b then compare_ts(a, b) =  1
    else                  compare_ts(a, b) =  0

    Care must be taken that this is done exactly with no rounding errors,
    simply casting to float or double and doing the obvious
    a*timebase > b*timebase is not compliant or correct, neither is the
    same with integers, and
    a*a_timebase.num*b_timebase.den > b*b_timebase.num*a_timebase.den
    will overflow. One possible implementation which shouldn't overflow
    within the range of legal timestamps and timebases is:

    if (convert_ts(a, a_timebase, b_timebase) < b) return -1;
    if (convert_ts(b, b_timebase, a_timebase) < a) return  1;
    return 0;

msb_pts_shift (v)
    amount of bits in lsb_pts
    MUST be <16.

decode_delay (v)
    Size of the reordering buffer used to convert pts to dts.
    Codecs which do not support B-frames normally use 0.
    MPEG-1/MPEG-2-style codecs with B-frames use 1.
    H.264-style B-pyramid uses 2.
    H.264 and future codecs might need values >2.
    Audio codecs generally use 0. (We are not aware of any, but it
    is theoretically possible that a codec might need a value >0.)
    decode_delay MUST NOT be set higher than necessary for a codec.

stream_flags (v)
     Bit  Name            Description
       1  FLAG_FIXED_FPS  indicates that the fps is fixed

codec_specific_data (vb)
    Private global data for a codec (could be huffman tables or ...).
    If a codec has a global header it SHOULD be placed in here instead of
    at the start of every keyframe.
    The exact format is specified in the codec specification.
    For H.264 the NAL units MUST be formatted as in a bytestream
    (with 00 00 01 prefixes).
    codec_specific_data SHOULD contain exactly the essential global packets
    needed to decode a stream, more specifically it SHOULD NOT contain packets
    which contain only non essential metadata like author, title, ...
    It also MUST NOT contain normal packets which cause the reference decoder
    to generate any specific decoded samples.
    The encoder name and version shall be considered essential as it is very
    useful to work around possible encoder bugs.
    The global headers MUST consist of the normal
    sequence of header packets required for codec initialization, in the
    order defined in the codec spec. An implementation MAY strip metadata and
    other redundant information not necessary for correct playback from the
    global headers as long as no incorrect values are stored and as long as
    the stripped result is not less valid per codec spec as before stripping.

frame_code (f(8))
    frame_code is an 8-bit field which exists before every frame, it can
    store part of the size of the frame, the stream number, the timestamp
    and some flags amongst other things. What is not directly stored
    in it but is needed is stored in various fields immediately after it.
    The values stored in it can be found in the main header.
    The value 78 ('N') is forbidden to ensure that the byte is always
    different from the first byte of any startcode.
    A muxer SHOULD mark 0x00 and 0xFF as invalid to improve error
    detection.

flags[frame_code], frame_flags (v)
     Bit  Name             Description
       0  FLAG_KEY         If set, the frame is a keyframe.
       1  FLAG_EOR         If set, the stream has no relevance on
                           presentation. (EOR)
       3  FLAG_CODED_PTS   If set, coded_pts is in the frame header.
       4  FLAG_STREAM_ID   If set, stream_id is coded in the frame header.
       5  FLAG_SIZE_MSB    If set, data_size_msb at the frame header,
                           otherwise data_size_msb is 0.
       6  FLAG_CHECKSUM    If set, the frame header contains a checksum.
       7  FLAG_RESERVED    If set, reserved_count is coded in the frame header.
      12  FLAG_CODED       If set, coded_flags are stored in the frame header.
      13  FLAG_INVALID     If set, frame_code is invalid.

    EOR frames MUST be zero-length and must be set keyframe.
    All streams SHOULD end with EOR, where the pts of the EOR indicates the
    end presentation time of the final frame.
    An EOR set stream is unset by the first content frames.
    EOR can only be unset in streams with zero decode_delay .
    FLAG_CHECKSUM MUST be set if the frame's data_size is strictly greater than
    2*max_distance or the difference abs(pts-last_pts) is strictly greater than
    max_pts_distance (where pts represents this frame's pts and last_pts is
    defined as below).

last_pts
    The timestamp of the last frame with the same stream_id as the current.
    If there is no such frame between the last syncpoint and the current
    frame then the syncpoint timestamp is used, see global_key_pts.

stream_id[frame_code] (v)
    If FLAG_STREAM_ID is not set then this is the stream number for the
    frame following this frame_code.
    If FLAG_STREAM_ID is set then this value has no meaning.
    MUST be <250.

data_size_mul[frame_code] (v)
    If FLAG_SIZE_MSB is set then data_size_msb which is stored after the
    frame code is multiplied with it and forms the more significant part
    of the size of the following frame.
    If FLAG_SIZE_MSB is not set then this field has no meaning.
    MUST be <16384.

data_size_lsb[frame_code] (v)
    The less significant part of the size of the following frame.
    This added together with data_size_mul*data_size_msb is the size of
    the following frame.
    MUST be <16384.

pts_delta[frame_code] (s)
    If FLAG_CODED_PTS is set in the flags of the current frame then this
    value MUST be ignored, if FLAG_CODED_PTS is not set then pts_delta is the
    difference between the current pts and last_pts.
    MUST be <16384 and >-16384.

reserved_count[frame_code] (v)
    MUST be <256.

data_size
    The size of the following frame.
    data_size = data_size_lsb + data_size_msb * data_size_mul ;

coded_pts (v)
    If coded_pts < ( 1 << msb_pts_shift ) then it is an lsb
    pts, otherwise it is a full pts + ( 1 << msb_pts_shift ).
    lsb pts is converted to a full pts by:
    mask  = ( 1 << msb_pts_shift ) - 1;
    delta = last_pts - mask / 2
    pts   = ( (pts_lsb - delta) & mask ) + delta

lsb_pts
    Least significant bits of the pts in time_base precision.
        Example: IBBP display order
        keyframe pts=0                       -> pts=0
        frame                    lsb_pts=3   -> pts=3
        frame                    lsb_pts=1   -> pts=1
        frame