|
|
"use strict";function H264SPSParser(){function a(){w=0,x=new Map}function b(a,b){var c=b,d=w+c>>k;return c=w+b&h,a[d]>>i-(c&i)&1}function c(a,c){var d=0,e=0,f=0;if(1===c)e=b(a,d);else for(var g=0;c>g;g++)f=b(a,g),e=(e<<1)+f;return w+=c,e}function d(a,c){for(var d=0,e=0,f=0,g=c;w+g<8*a.length&&!(e=b(a,g++));)d++;if(0===d)return w+=1,0;f=1<<d;for(var h=d-1;h>=0;h--,g++)e=b(a,g),f|=e<<h;var i=d*j+1;return w+=i,f-1}function e(a,b){var c=d(a,b);return 1&c?(c+1)/j:-c/j}function f(a){x.put("cpb_cnt_minus1",d(a,0)),x.put("bit_rate_scale",c(a,l)),x.put("cpb_size_scale",c(a,l));for(var b=x.get("cpb_cnt_minus1"),e=new Array(b),f=new Array(b),g=new Array(b),h=0;b>=h;h++)e[h]=d(a,0),f[h]=d(a,0),g[h]=c(a,1);x.put("bit_rate_value_minus1",e),x.put("cpb_size_value_minus1",f),x.put("cbr_flag",g),x.put("initial_cpb_removal_delay_length_minus1",c(a,m)),x.put("cpb_removal_delay_length_minus1",c(a,m)),x.put("dpb_output_delay_length_minus1",c(a,m)),x.put("time_offset_length",c(a,m))}function g(a){x.put("aspect_ratio_info_present_flag",c(a,1)),x.get("aspect_ratio_info_present_flag")&&(x.put("aspect_ratio_idc",c(a,o)),x.get("aspect_ratio_idc")===u&&(x.put("sar_width",c(a,r)),x.put("sar_height",c(a,r)))),x.put("overscan_info_present_flag",c(a,1)),x.get("overscan_info_present_flag")&&x.put("overscan_appropriate_flag",c(a,1)),x.put("video_signal_type_present_flag",c(a,1)),x.get("video_signal_type_present_flag")&&(x.put("video_format",c(a,k)),x.put("video_full_range_flag",c(a,1)),x.put("colour_description_present_flag",c(a,1)),x.get("colour_description_present_flag")&&(x.put("colour_primaries",c(a,o)),x.put("transfer_characteristics",c(a,o)),x.put("matrix_coefficients",c(a,o)))),x.put("chroma_loc_info_present_flag",c(a,1)),x.get("chroma_loc_info_present_flag")&&(x.put("chroma_sample_loc_type_top_field",d(a,0)),x.put("chroma_sample_loc_type_bottom_field",d(a,0))),x.put("timing_info_present_flag",c(a,1)),x.get("timing_info_present_flag")&&(x.put("num_units_in_tick",c(a,s)),x.put("time_scale",c(a,s)),x.put("fixed_frame_rate_flag",c(a,1))),x.put("nal_hrd_parameters_present_flag",c(a,1)),x.get("nal_hrd_parameters_present_flag")&&f(a),x.put("vcl_hrd_parameters_present_flag",c(a,1)),x.get("vcl_hrd_parameters_present_flag")&&f(a),(x.get("nal_hrd_parameters_present_flag")||x.get("vcl_hrd_parameters_present_flag"))&&x.put("low_delay_hrd_flag",c(a,1)),x.put("pic_struct_present_flag",c(a,1)),x.put("bitstream_restriction_flag",c(a,1)),x.get("bitstream_restriction_flag")&&(x.put("motion_vectors_over_pic_boundaries_flag",c(a,1)),x.put("max_bytes_per_pic_denom",d(a,0)),x.put("max_bits_per_mb_denom",d(a,0)))}var h=7,i=7,j=2,k=3,l=4,m=5,n=6,o=8,p=12,q=15,r=16,s=32,t=64,u=255,v=256,w=0,x=null;return a.prototype={parse:function(a){w=0,x.clear(),x.put("forbidden_zero_bit",c(a,1)),x.put("nal_ref_idc",c(a,j)),x.put("nal_unit_type",c(a,m)),x.put("profile_idc",c(a,o)),x.put("profile_compatibility",c(a,o)),x.put("level_idc",c(a,o)),x.put("seq_parameter_set_id",d(a,0));var b=x.get("profile_idc"),f=100,h=110,i=122,l=244,q=44,s=83,u=86,y=118,z=128,A=138,B=139,C=134;if((b===f||b===h||b===i||b===l||b===q||b===s||b===u||b===y||b===z||b===A||b===B||b===C)&&(x.put("chroma_format_idc",d(a,0)),x.get("chroma_format_idc")===k&&x.put("separate_colour_plane_flag",c(a,1)),x.put("bit_depth_luma_minus8",d(a,0)),x.put("bit_depth_chroma_minus8",d(a,0)),x.put("qpprime_y_zero_transform_bypass_flag",c(a,1)),x.put("seq_scaling_matrix_present_flag",c(a,1)),x.get("seq_scaling_matrix_present_flag"))){for(var D=x.get("chroma_format_idc")!==k?o:p,E=new Array(D),F=0;D>F;F++)if(E[F]=c(a,1),E[F])for(var G=n>F?r:t,H=8,I=8,J=0,K=0;G>K;K++)I&&(J=e(a,0),I=(H+J+v)%v),H=0===I?H:I;x.put("seq_scaling_list_present_flag",E)}if(x.put("log2_max_frame_num_minus4",d(a,0)),x.put("pic_order_cnt_type",d(a,0)),0===x.get("pic_order_cnt_type"))x.put("log2_max_pic_order_cnt_lsb_minus4",d(a,0));else if(1===x.get("pic_order_cnt_type")){x.put("delta_pic_order_always_zero_flag",c(a,1)),x.put("offset_for_non_ref_pic",e(a,0)),x.put("offset_for_top_to_bottom_field",e(a,0)),x.put("num_ref_frames_in_pic_order_cnt_cycle",d(a,0));for(v
|