-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathdixie.js
7930 lines (6711 loc) · 228 KB
/
dixie.js
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
// Copyright 2011 Google Inc. All Rights Reserved.
//
// This code is licensed under the same terms as WebM:
// Software License Agreement: http://www.webmproject.org/license/software/
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
// -----------------------------------------------------------------------------
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// -----------------------------------------------------------------------------
//
// Author: John Koleszar ([email protected])
// Dominik Homberger ([email protected])
"use strict";
/* Definition of the argument values for the exit() function stdlib.h*/
//int strcmp ( const char * str1, const char * str2 );
function strcmp (str1, str2 ) {
return ((str1 == str2) ? 0 : ((str1 > str2) ? 1 : -1));
}
var ptr = 0;
//stdio.h
/* Seek method constants */
var EXIT_SUCCESS = 0;
var EXIT_FAILURE = 1;
var SEEK_CUR = 1;
var SEEK_END = 2;
var SEEK_SET = 0;
var buffer8k=function() {return Arr(8800,0)};
//fread
//size_t fread ( void * ptr, size_t size, size_t count, FILE * stream );
function fread ( ptr, size, count, stream ) {
ptr.val=new buffer8k();//new Array();
//todo: size include
if(stream.data.length<count+stream.data_off) {stream.data_off += count; return 0; }
for(var i=0;i<count;++i)
ptr.val[i]=(stream.data[stream.data_off++]);
ptr.val.length=count;
return i;
}
//fseek
//ftell
//long int ftell ( FILE * stream );
function ftell(stream) {
return stream.data_off;
}
//ferror
//int ferror ( FILE * stream );
//feof
function feof(stream) {
if(stream.data.length<stream.data_off) return 1; return 0;
}
var char_=0, short_=0, int_=0, long_=0, void_=0;
var int8_t=char_;
var uint8_t=char_;
var int16_t=short_;
var uint16_t=short_;
var int32_t=int_;
var uint32_t=int_;
var uint64_t=long_;
var int64_t=long_;
var float_=0.00;
var size_t=0;
var double_=0;
var score_t=int64_t;
var CHAR_BIT = 8; /* number of bits in a char */
var ptrdiff_t=int_;
var UINT8=char_; var INT16=short_;
/*function convertBinaryToArray(binary) {
var arr = new Array();
if(binary.length<200000)
var num=binary.length; else num=200000;
for(i=0;i<num;++i)
arr.push(binary.charCodeAt(i));
return arr;
}*/
function newObjectIt(ObjIt) {
return (typeof ObjIt==='undefined')?'error':JSON.parse(JSON.stringify(ObjIt));
}
function memcpy(dst, dst_off, src, src_off, num) {
var i;
for(i=0;i<num;++i)
dst[dst_off + i] = src[src_off + i];
return dst;
}
function memset(ptr, ptr_off, value, num) {
var i=0;
for(i=0; i<num; ++i)
ptr[ptr_off + i]=value;
}
//function memset_O(ptr, ptr_off, value, num) {
// if(typeof ptr=='object')
// for (var key in ptr) {
// //if(typeof ptr[key]!='object') {
// ptr[key]=value;
// //}
// }
//}
function malloc(size,value) {
var i;
var output = new Array(); for (i = 0; i < size; ++i) output.push(value);
return output
//return size
}
function assert(bCondition) {
if (!bCondition) {
throw new Error('assert :P');
}
}
function setjmp(jmp) {
//todo: return 1 um zur?ckzusetzen
return 0;
}
function offsetof(val1,val2) {
return val2;
}
//function sizeof(val) {
// return 1;
//}
//function intBitLeft(uint_t, lefts) {
// //same as (int64)uint64_t<<lefts
// var zeros = new Array();
// var i;
// for(i=0;i<lefts;++i)
// zeros[i] ='0';
// bits = ( uint_t.toString(2) +''+ zeros.join("") );
// return parseInt(bits,2);
//}
function Arr(len,val) {
var i;
var result = new Array(); for (i = 0; i < len; ++i) result.push(val);
return result;
}
function Arr_new(len,val) {
var i;
var result = new Array(); for (i = 0; i < len; ++i) result.push(new val);
return result;
}
function Arr_nOI(len,val) {
var i;
var result = new Array(); for (i = 0; i < len; ++i) result.push(newObjectIt(val));
return result;
}
function ArrM(AOfLen,val) {
var a;
var result, resStr=new Array();
for (a = (AOfLen.length-1); a >= 0; --a)
val = newObjectIt(Arr(AOfLen[a],val));
return val;
}
///////////////////////////////
//if(!Object.keys) Object.keys = function(o){
//// if (o !== Object(o))
//// throw new TypeError('Object.keys called on non-object');
// var ret=[],p;
// for(p in o) if(Object.prototype.hasOwnProperty.call(o,p)) ret.push(p);
// return ret;
//}
//
function create_obj_vals_from_arrayChilds(Obj,Arr) {
var i;
for(i=0;i<Arr.length;++i)
Arr[i]=create_obj_vals_from_array(new Obj(),Arr[i]);
return Arr;
}
function create_obj_vals_from_array(Obj,Arr) {
var new_Obj = Obj;
var i=0;
for (var key in new_Obj) {
if(typeof new_Obj[key]=='object' && (Object.keys(new_Obj[key]).length==Arr[i].length)) {
new_Obj[key]=create_obj_vals_from_array(new_Obj[key],Arr[i]);
} else
{
new_Obj[key]=Arr[i];
}
i++;
}
return new_Obj;
}
//dixie functions & ariables
//74
var
DC_PRED=0, /* average of above and left pixels */
V_PRED=1, /* vertical prediction */
H_PRED=2, /* horizontal prediction */
TM_PRED=3, /* Truemotion prediction */
B_PRED=4, /* block based prediction, each block has its own prediction mode */
NEARESTMV=5,
NEARMV=6,
ZEROMV=7,
NEWMV=8,
SPLITMV=9,
MB_MODE_COUNT=10
;// MB_PREDICTION_MODE;
//109
var
//{
B_DC_PRED=0, /* average of above and left pixels */
B_TM_PRED=1,
B_VE_PRED=2, /* vertical prediction */
B_HE_PRED=3, /* horizontal prediction */
B_LD_PRED=4,
B_RD_PRED=5,
B_VR_PRED=6,
B_VL_PRED=7,
B_HD_PRED=8,
B_HU_PRED=9,
LEFT4X4=10,
ABOVE4X4=11,
ZERO4X4=12,
NEW4X4=13,
B_MODE_COUNT=14
;//} B_PREDICTION_MODE;
function CODEC_INTERFACE(id,arr) {
//vpx_codec_iface_t* id(void) { return &id##_algo; }
window[id+'_algo']=create_obj_vals_from_array(vpx_codec_iface_t,arr);
}
var VPX_CODEC_INTERNAL_ABI_VERSION = (3); /**<\hideinitializer*/
var VPX_CODEC_CAP_DECODER = 0x1; /**< Is a decoder */
var vpx_codec_ctrl_fn_map_t = function()
{
this.ctrl_id=int_,
this.fn=0//'todo:findfuction:vpx_codec_control_fn_t'
} ;
/*!\brief Decoder algorithm interface interface 285
*
* All decoders \ref MUST expose a variable of this type.
*/
var vpx_codec_iface = function()
{
this.name=char_, /**< Identification String */ //*name
this.abi_version=int_, /**< Implemented ABI version */
this.caps=long_,//todo //vpx_codec_caps_t, sollte erst inialisiert werden wenn variable verf?gbar //typedef long /**< Decoder capabilities */
this.init='vpx_codec_init_fn_t', /**< \copydoc ::vpx_codec_init_fn_t */
this.destroy='vpx_codec_destroy_fn_t', /**< \copydoc ::vpx_codec_destroy_fn_t */
this.ctrl_maps=new vpx_codec_ctrl_fn_map_t(), /**< \copydoc ::vpx_codec_ctrl_fn_map_t */
this.get_mmap='vpx_codec_get_mmap_fn_t', /**< \copydoc ::vpx_codec_get_mmap_fn_t */
this.set_mmap='vpx_codec_set_mmap_fn_t', /**< \copydoc ::vpx_codec_set_mmap_fn_t */
this.dec=new Object(
{
peek_si:'vpx_codec_peek_si_fn_t', /**< \copydoc ::vpx_codec_peek_si_fn_t */
get_si:'vpx_codec_get_si_fn_t', /**< \copydoc ::vpx_codec_peek_si_fn_t */
decode:'vpx_codec_decode_fn_t', /**< \copydoc ::vpx_codec_decode_fn_t */
get_frame:'vpx_codec_get_frame_fn_t' /**< \copydoc ::vpx_codec_get_frame_fn_t */
})
};
var vpx_codec_iface_t=vpx_codec_iface;
var VERSION_STRING = " v0.9.7";
var VPX_CODEC_OK=0,
VPX_CODEC_MEM_ERROR=2;//,
/*!\brief Current ABI version number 23
*
* \internal
* If this file is altered in any way that changes the ABI, this value
* must be bumped. Examples include, but are not limited to, changing
* types, removing or reassigning enums, adding/removing/rearranging
* fields to structures
*/
var VPX_IMAGE_ABI_VERSION =(1); /**<\hideinitializer*/
//56
VPX_IMG_FMT_I420 = 258;// todo:VPX_IMG_FMT_I420 = VPX_IMG_FMT_PLANAR | 2,
//58
VPX_IMG_FMT_VPXI420 = 260;// todo:VPX_IMG_FMT_VPXI420 = VPX_IMG_FMT_PLANAR | 4
/**\brief Image Descriptor */
/* Image data pointers. */
var VPX_PLANE_PACKED = 0; /**< To be used for all packed formats */
var VPX_PLANE_Y = 0; /**< Y (Luminance) plane */
var VPX_PLANE_U = 1; /**< U (Chroma) plane */
var VPX_PLANE_V = 2; /**< V (Chroma) plane */
var VPX_PLANE_ALPHA = 3; /**< A (Transparency) plane */
//#if !defined(VPX_CODEC_DISABLE_COMPAT) || !VPX_CODEC_DISABLE_COMPAT
var PLANE_PACKED = VPX_PLANE_PACKED;
var PLANE_Y = VPX_PLANE_Y;
var PLANE_U = VPX_PLANE_U;
var PLANE_V = VPX_PLANE_V;
var PLANE_ALPHA = VPX_PLANE_ALPHA;
//#endif
var vpx_image_t = function() //vpx_image
{
this.fmt=0, //enum /**< Image Format */'vpx_img_fmt_t'
/* Image storage dimensions */
this.w=this["w"]=int_, /**< Stored image width */
this.h=this["h"]=int_, /**< Stored image height */
/* Image display dimensions */
this.d_w=this["d_w"]=int_, /**< Displayed image width */
this.d_h=this["d_h"]=int_, /**< Displayed image height */
/* Chroma subsampling info */
this.x_chroma_shift=this["x_chroma_shift"]=int_, /**< subsampling order, X */
this.y_chroma_shift=this["y_chroma_shift"]=int_, /**< subsampling order, Y */
this.planes=this["planes"]=new Array(4),/*,char),*/ this.planes_off=this["planes_off"]=new Array(4),//,char),//unsigned char *planes[4]; /**< pointer to the top left pixel for each plane */
this.stride=this["stride"]=new Array(4),//,int_), /**< stride between rows for each plane */
this.bps=this["bps"]=int_, /**< bits per sample (for packed formats) */
/* The following member may be set by the application to associate data
* with this image.
*/
this.user_priv=this["user_priv"]=void_, /* /**< may be set by the application to associate data
* with this image. */
/* The following members should be treated as private. */
this.img_data=this["img_data"]=char_, /**< private */
this.img_data_off=this["img_data_off"]=0, /**< private */
this.img_data_owner=this["img_data_owner"]=int_, /**< private */
this.self_allocd=this["self_allocd"]=int_ /**< private */
} ; /**< alias for struct vpx_image */
/** @file 62
The <tt>libnestegg</tt> C API. */
var NESTEGG_TRACK_VIDEO = 0; /**< Track is of type video. */
var NESTEGG_TRACK_AUDIO = 1; /**< Track is of type audio. */
var NESTEGG_CODEC_VP8 = 0; /**< Track uses Google On2 VP8 codec. */
var NESTEGG_CODEC_VORBIS = 1; /**< Track uses Xiph Vorbis codec. */
//71
var NESTEGG_SEEK_SET = 0; /**< Seek offset relative to beginning of stream. */
var NESTEGG_SEEK_CUR = 1; /**< Seek offset relative to current position in stream. */
var NESTEGG_SEEK_END = 2; /**< Seek offset relative to end of stream. */
//76
var NESTEGG_LOG_DEBUG = 1; /**< Debug level log message. */
var NESTEGG_LOG_INFO = 10; /**< Informational level log message. */
var NESTEGG_LOG_WARNING = 100; /**< Warning level log message. */
var NESTEGG_LOG_ERROR = 1000; /**< Error level log message. */
var NESTEGG_LOG_CRITICAL = 10000; /**< Critical level log message. */
/** User supplied IO context. 84 */
var nestegg_io = function(){
/** User supplied read callback.
@param buffer Buffer to read data into.
@param length Length of supplied buffer in bytes.
@param userdata The #userdata supplied by the user.
@retval 1 Read succeeded.
@retval 0 End of stream.
@retval -1 Error. */
//int (* read)(void * buffer, size_t length, void * userdata);
this.read=int_,
/** User supplied seek callback.
@param offset Offset within the stream to seek to.
@param whence Seek direction. One of #NESTEGG_SEEK_SET,
#NESTEGG_SEEK_CUR, or #NESTEGG_SEEK_END.
@param userdata The #userdata supplied by the user.
@retval 0 Seek succeeded.
@retval -1 Error. */
//int (* seek)(int64_t offset, int whence, void * userdata);
this.seek=int_,
/** User supplied tell callback.
@param userdata The #userdata supplied by the user.
@returns Current position within the stream.
@retval -1 Error. */
//int64_t (* tell)(void * userdata);
this.tell=int64_t,
/** User supplied pointer to be passed to the IO callbacks. */
//void * userdata;
this.userdata=void_ //*
} ;
/** Parameters specific to a video track. */
var nestegg_video_params = function(){
this.width=int_, /**< Width of the video frame in pixels. */
this.height=int_, /**< Height of the video frame in pixels. */
this.display_width=int_, /**< Display width of the video frame in pixels. */
this.display_height=int_, /**< Display height of the video frame in pixels. */
this.crop_bottom=int_, /**< Pixels to crop from the bottom of the frame. */
this.crop_top=int_, /**< Pixels to crop from the top of the frame. */
this.crop_left=int_, /**< Pixels to crop from the left of the frame. */
this.crop_right=int_ /**< Pixels to crop from the right of the frame. */
} ;
/* EBML Elements 14 */
var ID_EBML = 0x1a45dfa3;
var ID_EBML_VERSION = 0x4286;
var ID_EBML_READ_VERSION = 0x42f7;
var ID_EBML_MAX_ID_LENGTH = 0x42f2;
var ID_EBML_MAX_SIZE_LENGTH = 0x42f3;
var ID_DOCTYPE = 0x4282;
var ID_DOCTYPE_VERSION = 0x4287;
var ID_DOCTYPE_READ_VERSION = 0x4285;
/* Global Elements */
var ID_VOID = 0xec;
var ID_CRC32 = 0xbf;
/* WebMedia Elements */
var ID_SEGMENT = 0x18538067;
/* Seek Head Elements */
var ID_SEEK_HEAD = 0x114d9b74;
var ID_SEEK = 0x4dbb;
var ID_SEEK_ID = 0x53ab;
var ID_SEEK_POSITION = 0x53ac;
/* Info Elements */
var ID_INFO = 0x1549a966;
var ID_TIMECODE_SCALE = 0x2ad7b1;
var ID_DURATION = 0x4489;
/* Cluster Elements */
var ID_CLUSTER = 0x1f43b675;
var ID_TIMECODE = 0xe7;
var ID_BLOCK_GROUP = 0xa0;
var ID_SIMPLE_BLOCK = 0xa3;
/* BlockGroup Elements */
var ID_BLOCK = 0xa1;
var ID_BLOCK_DURATION = 0x9b;
var ID_REFERENCE_BLOCK = 0xfb;
/* Tracks Elements */
var ID_TRACKS = 0x1654ae6b;
var ID_TRACK_ENTRY = 0xae;
var ID_TRACK_NUMBER = 0xd7;
var ID_TRACK_UID = 0x73c5;
var ID_TRACK_TYPE = 0x83;
var ID_FLAG_ENABLED = 0xb9;
var ID_FLAG_DEFAULT = 0x88;
var ID_FLAG_LACING = 0x9c;
var ID_TRACK_TIMECODE_SCALE=0x23314f;
var ID_LANGUAGE = 0x22b59c;
var ID_CODEC_ID = 0x86;
var ID_CODEC_PRIVATE = 0x63a2;
/* Video Elements */
var ID_VIDEO = 0xe0;
var ID_PIXEL_WIDTH = 0xb0;
var ID_PIXEL_HEIGHT = 0xba;
var ID_PIXEL_CROP_BOTTOM = 0x54aa;
var ID_PIXEL_CROP_TOP = 0x54bb;
var ID_PIXEL_CROP_LEFT = 0x54cc;
var ID_PIXEL_CROP_RIGHT = 0x54dd;
var ID_DISPLAY_WIDTH = 0x54b0;
var ID_DISPLAY_HEIGHT = 0x54ba;
/* Audio Elements */
var ID_AUDIO = 0xe1;
var ID_SAMPLING_FREQUENCY = 0xb5;
var ID_CHANNELS = 0x9f;
var ID_BIT_DEPTH = 0x6264;
/* Cues Elements */
var ID_CUES = 0x1c53bb6b;
var ID_CUE_POINT = 0xbb;
var ID_CUE_TIME = 0xb3;
var ID_CUE_TRACK_POSITIONS= 0xb7;
var ID_CUE_TRACK = 0xf7;
var ID_CUE_CLUSTER_POSITION=0xf1;
var ID_CUE_BLOCK_NUMBER = 0x5378;
/* EBML Types 93 */
var //ebml_type_enum = {
TYPE_UNKNOWN=0,
TYPE_MASTER=1,
TYPE_UINT=2,
TYPE_FLOAT=3,
TYPE_INT=4,
TYPE_STRING=5,
TYPE_BINARY=6
//}
;
var LIMIT_STRING = (1 << 20);
var LIMIT_BINARY = (1 << 24);
var LIMIT_BLOCK = (1 << 30);
var LIMIT_FRAME = (1 << 28);
/* Field Flags 109 */
var DESC_FLAG_NONE = 0;
var DESC_FLAG_MULTI = (1 << 0);
var DESC_FLAG_SUSPEND = (1 << 1);
var DESC_FLAG_OFFSET = (1 << 2);
/* Block Header Flags */
var BLOCK_FLAGS_LACING = 6;
/* Lacing Constants */
var LACING_NONE = 0;
var LACING_XIPH = 1;
var LACING_FIXED = 2;
var LACING_EBML = 3;
/* Track Types */
var TRACK_TYPE_VIDEO = 1;
var TRACK_TYPE_AUDIO = 2;
/* Track IDs */
var TRACK_ID_VP8 = "V_VP8";
var TRACK_ID_VORBIS = "A_VORBIS";
var// vint_mask {
MASK_NONE=0,
MASK_FIRST_BIT=1
//}
;
//137
var ebml_binary = function(){
this.data=char_,//*
this.length=size_t
};
var ebml_list_node = function(){
this.next=null,//'ebml_list_node',//*
this.id=uint64_t,
this.data=void_//*
};
var ebml_list = function(){
this.head=null,//'newObjectI(ebml_list_node)',//*
this.tail=null//'newObjectI(ebml_list_node)'//*
};
var ebml_type = function(){
this.v=new Object({//union ebml_value
u:uint64_t,
f:double_,
i:int64_t,
s:char_,//*
b:new ebml_binary()
}),
this.type=0, //enum'ebml_type_enum'
this.read=int_
};
/* EBML Definitions 165 */
var ebml = window["ebml"] = function(){
this.ebml_version=this["ebml_version"]=new ebml_type(),
this.ebml_read_version=this["ebml_read_version"]=new ebml_type(),
this.ebml_max_id_length=this["ebml_max_id_length"]=new ebml_type(),
this.ebml_max_size_length=this["ebml_max_size_length"]=new ebml_type(),
this.doctype=this["doctype"]=new ebml_type(),
this.doctype_version=this["doctype_version"]=new ebml_type(),
this.doctype_read_version=this["doctype_read_version"]=new ebml_type()
};
/* Matroksa Definitions */
var seek = window["seek"] = function(){
this.id=this["id"]=new ebml_type(),
this.position=this["position"]=new ebml_type()
};
var seek_head = window["seek_head"] = function(){
this.seek=this["seek"]=new ebml_list()
};
var info = window["info"] = function(){
this.timecode_scale=this["timecode_scale"]=new ebml_type(),
this.duration=this["duration"]=new ebml_type()
};
var block_group = window["block_group"] = function(){
this.duration=this["duration"]=new ebml_type(),
this.reference_block=this["reference_block"]=new ebml_type()
};
var cluster = window["cluster"] = function(){
this.timecode=this["timecode"]=new ebml_type(),
this.block_group=this["block_group"]=new ebml_list()
};
var video = window["video"] = function(){
this.pixel_width=this["pixel_width"]=new ebml_type(),
this.pixel_height=this["pixel_height"]=new ebml_type(),
this.pixel_crop_bottom=this["pixel_crop_bottom"]=new ebml_type(),
this.pixel_crop_top=this["pixel_crop_top"]=new ebml_type(),
this.pixel_crop_left=this["pixel_crop_left"]=new ebml_type(),
this.pixel_crop_right=this["pixel_crop_right"]=new ebml_type(),
this.display_width=this["display_width"]=new ebml_type(),
this.display_height=this["display_height"]=new ebml_type()
};
var audio = window["audio"] = function(){
this.sampling_frequency=this["sampling_frequency"]=new ebml_type(),
this.channels=this["channels"]=new ebml_type(),
this.bit_depth=this["bit_depth"]=new ebml_type()
};
var track_entry = window["track_entry"] = function(){
this.number=this["number"]=new ebml_type(),
this.uid=this["uid"]=new ebml_type(),
this.type=this["type"]=new ebml_type(),
this.flag_enabled=this["flag_enabled"]=new ebml_type(),
this.flag_default=this["flag_default"]=new ebml_type(),
this.flag_lacing=this["flag_lacing"]=new ebml_type(),
this.track_timecode_scale=this["track_timecode_scale"]=new ebml_type(),
this.language=this["language"]=new ebml_type(),
this.codec_id=this["codec_id"]=new ebml_type(),
this.codec_private=this["codec_private"]=new ebml_type(),
this.video=this["video"]=new video(),
this.audio=this["audio"]=new audio()
};
var tracks = window["tracks"] = function(){
this.track_entry=this["track_entry"]=new ebml_list()
};
var cue_track_positions = window["cue_track_positions"] = function(){
this.track=this["track"]=new ebml_type(),
this.cluster_position=this["cluster_position"]=new ebml_type(),
this.block_number=this["block_number"]=new ebml_type()
};
var cue_point = window["cue_point"] = function(){
this.time=this["time"]=new ebml_type(),
this.cue_track_positions=this["cue_track_positions"]=new ebml_list()
};
var cues = window["cues"] = function(){
this.cue_point=this["cue_point"]=new ebml_list()
};
var segment = window["segment"] = function(){
this.seek_head=this["seek_head"]=new ebml_list(),
this.info=this["info"]=new info(),
this.cluster=this["cluster"]=new ebml_list(),
this.tracks=this["tracks"]=new tracks(),
this.cues=this["cues"]=new cues()
};
/* Misc. 260 */
var pool_ctx = function(){
this.dummy=char_
};
var list_node = function(){
this.previous=0, //todo: endlosschleife verhindern //*'list_node'
this.node=new ebml_element_desc(),//*
this.data=char_ //*
};
var frame = function() {
this.data=char_,
this.length=size_t,
this.next=null//'frame'
};
/* Public (opaque) Structures 284 */
var nestegg = function(){
this.io=new nestegg_io(), //*
this.log_=0,//'nestegg_log' todo:
this.alloc_pool=new pool_ctx(), //*
this.last_id=uint64_t,
this.last_size=uint64_t,
this.ancestor=null,//'newObjectI(list_node)',//*
this.ebml=this["ebml"]=new ebml(),
this.segment=this["segment"]=new segment(),
this.segment_offset=int64_t,
this.track_count=int_
};
var nestegg_packet = function() {
this.track=uint64_t,
this.timecode=uint64_t,
this.frame=new frame()//*
};
/* Element Descriptor 304 */
var ebml_element_desc = function(){
this.name=char_,//const *
this.id=uint64_t,
this.type=0, //enum'ebml_type_enum'
this.offset=size_t,
this.flags=int_,
this.children=null,//wiederholungsschleife //*'ebml_element_desc'
this.size=size_t,
this.data_offset=size_t
};
function E_FIELD(ID, _ID, TYPE, STRUCT, FIELD) {
return new Array( ID, _ID, TYPE, FIELD/*offsetof(STRUCT, FIELD)*/, DESC_FLAG_NONE, null, 0, 0 ) }
function E_MASTER(ID, _ID, TYPE, STRUCT, FIELD, NE_FIELD_ELEMENTS) {
return new Array( ID, _ID, TYPE, FIELD/*offsetof(STRUCT, FIELD)*/, DESC_FLAG_MULTI, NE_FIELD_ELEMENTS,
1/*sizeof(FIELD)*/, 0 ) }
function E_SINGLE_MASTER_O(ID, _ID, TYPE, STRUCT, FIELD, NE_FIELD_ELEMENTS) {
return new Array( ID, _ID, TYPE, FIELD/*offsetof(STRUCT, FIELD)*/, DESC_FLAG_OFFSET, NE_FIELD_ELEMENTS, 0,
FIELD+'_offset'/*offsetof(STRUCT, FIELD+'_offset')*/ ) }
function E_SINGLE_MASTER(ID, _ID, TYPE, STRUCT, FIELD, NE_FIELD_ELEMENTS) {
return new Array( ID, _ID, TYPE, FIELD/*offsetof(STRUCT, FIELD)*/, DESC_FLAG_NONE, NE_FIELD_ELEMENTS, 0, 0 ) }
function E_SUSPEND(ID, _ID, TYPE) {
return new Array( ID, _ID, TYPE, 0, DESC_FLAG_SUSPEND, null, 0, 0 ) }
var E_LAST =
new Array( null, 0, 0, 0, DESC_FLAG_NONE, null, 0, 0 );
/* EBML Element Lists */
var ne_ebml_elements = create_ebml_element_desc(new Array(
E_FIELD('ID_EBML_VERSION', ID_EBML_VERSION, TYPE_UINT, 'ebml', 'ebml_version'),
E_FIELD('ID_EBML_READ_VERSION', ID_EBML_READ_VERSION, TYPE_UINT, 'ebml', 'ebml_read_version'),
E_FIELD('ID_EBML_MAX_ID_LENGTH', ID_EBML_MAX_ID_LENGTH, TYPE_UINT, 'ebml', 'ebml_max_id_length'),
E_FIELD('ID_EBML_MAX_SIZE_LENGTH', ID_EBML_MAX_SIZE_LENGTH, TYPE_UINT, 'ebml', 'ebml_max_size_length'),
E_FIELD('ID_DOCTYPE', ID_DOCTYPE, TYPE_STRING, 'ebml', 'doctype'),
E_FIELD('ID_DOCTYPE_VERSION', ID_DOCTYPE_VERSION, TYPE_UINT, 'ebml', 'doctype_version'),
E_FIELD('ID_DOCTYPE_READ_VERSION', ID_DOCTYPE_READ_VERSION, TYPE_UINT, 'ebml', 'doctype_read_version'),
E_LAST
));
/* WebMedia Element Lists */
var ne_seek_elements = create_ebml_element_desc(new Array(
E_FIELD('ID_SEEK_ID', ID_SEEK_ID, TYPE_BINARY, 'seek', 'id'),
E_FIELD('ID_SEEK_POSITION', ID_SEEK_POSITION, TYPE_UINT, 'seek', 'position'),
E_LAST
));
var ne_seek_head_elements = create_ebml_element_desc(new Array(
E_MASTER('ID_SEEK', ID_SEEK, TYPE_MASTER, 'seek_head', 'seek', ne_seek_elements),
E_LAST
));
var ne_info_elements = create_ebml_element_desc(new Array(
E_FIELD('ID_TIMECODE_SCALE', ID_TIMECODE_SCALE, TYPE_UINT, 'info', 'timecode_scale'),
E_FIELD('ID_DURATION', ID_DURATION, TYPE_FLOAT, 'info', 'duration'),
E_LAST
));
var ne_block_group_elements = create_ebml_element_desc(new Array(
E_SUSPEND('ID_BLOCK', ID_BLOCK, TYPE_BINARY),
E_FIELD('ID_BLOCK_DURATION', ID_BLOCK_DURATION, TYPE_UINT, 'block_group', 'duration'),
E_FIELD('ID_REFERENCE_BLOCK', ID_REFERENCE_BLOCK, TYPE_INT, 'block_group', 'reference_block'),
E_LAST
));
var ne_cluster_elements = create_ebml_element_desc(new Array(
E_FIELD('ID_TIMECODE', ID_TIMECODE, TYPE_UINT, 'cluster', 'timecode'),
E_MASTER('ID_BLOCK_GROUP', ID_BLOCK_GROUP, TYPE_MASTER, 'cluster', 'block_group', ne_block_group_elements),
E_SUSPEND('ID_SIMPLE_BLOCK', ID_SIMPLE_BLOCK, TYPE_BINARY),
E_LAST
));
var ne_video_elements = create_ebml_element_desc(new Array(
E_FIELD('ID_PIXEL_WIDTH', ID_PIXEL_WIDTH, TYPE_UINT, 'video', 'pixel_width'),
E_FIELD('ID_PIXEL_HEIGHT', ID_PIXEL_HEIGHT, TYPE_UINT, 'video', 'pixel_height'),
E_FIELD('ID_PIXEL_CROP_BOTTOM', ID_PIXEL_CROP_BOTTOM, TYPE_UINT, 'video', 'pixel_crop_bottom'),
E_FIELD('ID_PIXEL_CROP_TOP', ID_PIXEL_CROP_TOP, TYPE_UINT, 'video', 'pixel_crop_top'),
E_FIELD('ID_PIXEL_CROP_LEFT', ID_PIXEL_CROP_LEFT, TYPE_UINT, 'video', 'pixel_crop_left'),
E_FIELD('ID_PIXEL_CROP_RIGHT', ID_PIXEL_CROP_RIGHT, TYPE_UINT, 'video', 'pixel_crop_right'),
E_FIELD('ID_DISPLAY_WIDTH', ID_DISPLAY_WIDTH, TYPE_UINT, 'video', 'display_width'),
E_FIELD('ID_DISPLAY_HEIGHT', ID_DISPLAY_HEIGHT, TYPE_UINT, 'video', 'display_height'),
E_LAST
));
var ne_audio_elements = create_ebml_element_desc(new Array(
E_FIELD('ID_SAMPLING_FREQUENCY', ID_SAMPLING_FREQUENCY, TYPE_FLOAT, 'audio', 'sampling_frequency'),
E_FIELD('ID_CHANNELS', ID_CHANNELS, TYPE_UINT, 'audio', 'channels'),
E_FIELD('ID_BIT_DEPTH', ID_BIT_DEPTH, TYPE_UINT, 'audio', 'bit_depth'),
E_LAST
));
var ne_track_entry_elements = create_ebml_element_desc(new Array(
E_FIELD('ID_TRACK_NUMBER', ID_TRACK_NUMBER, TYPE_UINT, 'track_entry', 'number'),
E_FIELD('ID_TRACK_UID', ID_TRACK_UID, TYPE_UINT, 'track_entry', 'uid'),
E_FIELD('ID_TRACK_TYPE', ID_TRACK_TYPE, TYPE_UINT, 'track_entry', 'type'),
E_FIELD('ID_FLAG_ENABLED', ID_FLAG_ENABLED, TYPE_UINT, 'track_entry', 'flag_enabled'),
E_FIELD('ID_FLAG_DEFAULT', ID_FLAG_DEFAULT, TYPE_UINT, 'track_entry', 'flag_default'),
E_FIELD('ID_FLAG_LACING', ID_FLAG_LACING, TYPE_UINT, 'track_entry', 'flag_lacing'),
E_FIELD('ID_TRACK_TIMECODE_SCALE', ID_TRACK_TIMECODE_SCALE, TYPE_FLOAT, 'track_entry', 'track_timecode_scale'),
E_FIELD('ID_LANGUAGE', ID_LANGUAGE, TYPE_STRING, 'track_entry', 'language'),
E_FIELD('ID_CODEC_ID', ID_CODEC_ID, TYPE_STRING, 'track_entry', 'codec_id'),
E_FIELD('ID_CODEC_PRIVATE', ID_CODEC_PRIVATE, TYPE_BINARY, 'track_entry', 'codec_private'),
E_SINGLE_MASTER('ID_VIDEO', ID_VIDEO, TYPE_MASTER, 'track_entry', 'video', ne_video_elements),
E_SINGLE_MASTER('ID_AUDIO', ID_AUDIO, TYPE_MASTER, 'track_entry', 'audio', ne_audio_elements),
E_LAST
));
var ne_tracks_elements = create_ebml_element_desc(new Array(
E_MASTER('ID_TRACK_ENTRY', ID_TRACK_ENTRY, TYPE_MASTER, 'tracks', 'track_entry', ne_track_entry_elements),
E_LAST
));
var ne_cue_track_positions_elements = create_ebml_element_desc(new Array(
E_FIELD('ID_CUE_TRACK', ID_CUE_TRACK, TYPE_UINT, 'cue_track_positions', 'track'),
E_FIELD('ID_CUE_CLUSTER_POSITION', ID_CUE_CLUSTER_POSITION, TYPE_UINT, 'cue_track_positions', 'cluster_position'),
E_FIELD('ID_CUE_BLOCK_NUMBER', ID_CUE_BLOCK_NUMBER, TYPE_UINT, 'cue_track_positions', 'block_number'),
E_LAST
))
var ne_cue_point_elements = create_ebml_element_desc(new Array(
E_FIELD('ID_CUE_TIME', ID_CUE_TIME, TYPE_UINT, 'cue_point', 'time'),
E_MASTER('ID_CUE_TRACK_POSITIONS', ID_CUE_TRACK_POSITIONS, TYPE_MASTER, 'cue_point', 'cue_track_positions', ne_cue_track_positions_elements),
E_LAST
));
var ne_cues_elements = create_ebml_element_desc(new Array(
E_MASTER('ID_CUE_POINT', ID_CUE_POINT, TYPE_MASTER, 'cues', 'cue_point', ne_cue_point_elements),
E_LAST
));
var ne_segment_elements = create_ebml_element_desc(new Array(
E_MASTER('ID_SEEK_HEAD', ID_SEEK_HEAD, TYPE_MASTER, 'segment', 'seek_head', ne_seek_head_elements),
E_SINGLE_MASTER('ID_INFO', ID_INFO, TYPE_MASTER, 'segment', 'info', ne_info_elements),
E_MASTER('ID_CLUSTER', ID_CLUSTER, TYPE_MASTER, 'segment', 'cluster', ne_cluster_elements),
E_SINGLE_MASTER('ID_TRACKS', ID_TRACKS, TYPE_MASTER, 'segment', 'tracks', ne_tracks_elements),
E_SINGLE_MASTER('ID_CUES', ID_CUES, TYPE_MASTER, 'segment', 'cues', ne_cues_elements),
E_LAST
));
//442
var ne_top_level_elements = create_ebml_element_desc(new Array(
E_SINGLE_MASTER('ID_EBML', ID_EBML, TYPE_MASTER, 'nestegg', 'ebml', ne_ebml_elements),
E_SINGLE_MASTER_O('ID_SEGMENT', ID_SEGMENT, TYPE_MASTER, 'nestegg', 'segment', ne_segment_elements),
E_LAST
));
function create_ebml_element_desc(Arr) {
var newArr=new Array();
for(var i=0;i<Arr.length;++i) {
var a=0;
var createitem = new ebml_element_desc();
for (var key in createitem)//ebml_element_desc
if(Arr[i][a]!=='undefined')
createitem[key]=Arr[i][a++];
newArr.push(createitem);
}
return newArr;
}
//455
function
ne_pool_init(void_)
{
var pool=new pool_ctx();//*
//todo: pool = h_malloc(sizeof(*pool));
//if (!pool)
// abort();
return pool;
}
var buffer_8192=Arr(8192,0);
function //508
ne_io_read_skip(io, length)
{
var get_=size_t;
var buf={val:buffer_8192};//,char_
var r = 1;
while (length > 0) {
get_ = length < /*sizeof(buf)**/buf.val.length ? length : /*sizeof(buf)**/buf.val.length;
r = ne_io_read(io, buf, get_);
if (r != 1)
break;
length -= get_;
}
return r;
}
function //526
ne_io_tell(io)
{
return io.tell(io.userdata);
}
function
ne_bare_read_vint(io, value, length, maskflag)
{
var r=int_;
var b={val:char_};
var maxlen = 8;
var count = 1, mask = 1 << 7;
r = ne_io_read(io, b, 1);//&b
if (r != 1)
return r;
while (count < maxlen) {
if ((b.val[0] & mask) != 0)
break;
mask >>= 1;
count += 1;
}
if (length)
length.val = count;
value.val = b.val[0];
if (maskflag == MASK_FIRST_BIT)
value.val = b.val[0] & ~mask;
while (--count) {
r = ne_io_read(io, b, 1);//&b
if (r != 1)
return r;
value.val <<= 8;
value.val |= b.val[0];
}
return 1;
}
function
ne_io_read(io, buffer, length)
{
//io.userdata={val:io.userdata};
var r = io.read(buffer, length, io.userdata);
//io.userdata=io.userdata.val;
return r;
}
function //569
ne_read_id(io, value, length)
{
return ne_bare_read_vint(io, value, length, MASK_NONE);
}
function
ne_read_vint(io, value, length)
{
return ne_bare_read_vint(io, value, length, MASK_FIRST_BIT);
}
function //581
ne_read_svint(io, value, length)
{
var r=int_;
var uvalue=[uint64_t];
var ulength=[uint64_t];
var svint_subtr = new Array(
0x3f, 0x1fff,
0xfffff, 0x7ffffff,
0x3ffffffff, 0x1ffffffffff,