音视频图像编解码
https://www.iteye.com/blog/lobin-2508589
https://www.iteye.com/blog/lobin-2439912
音视频编解码
离散傅立叶变换
根据殴拉公式,离散傅立叶变换还可以写成以下形式。
殴拉公式
其中∑表示求和,读作"sigma"。
∑求和的例子
求矩形面积
∑求和的例子
求圆面积
编码格式
MPEG
MPEG1
MPEG2
MPEG4
Part 2: Visual
* VisualObjectSequence() { | No. of bits | Mnemonic
* do { | |
* visual_object_sequence_start_code | 32 | bslbf
* profile_and_level_indication | 8 | uimsbf
* while ( next_bits()== user_data_start_code){ | |
* user_data() | |
* } | |
* VisualObject() | |
* } while ( next_bits() != visual_object_sequence_end_code) | |
* visual_object_sequence_end_code | 32 | bslbf
* } | |
* ——————————————————————————————————————————————————————————————+—————————————+—————————
*
* User data
* ——————————————————————————————————————————————————————————————+—————————————+—————————
* user_data() { | No. of bits | Mnemonic
* user_data_start_code | 32 | bslbf
* while( next_bits() != ‘0000 0000 0000 0000 0000 0001’ ) { | |
* user_data | 8 | uimsbf
* } | |
* } | |
* ——————————————————————————————————————————————————————————————+—————————————+—————————
* VisualObject() { | No. of bits | Mnemonic
* visual_object_start_code | 32 | bslbf
* is_visual_object_identifier | 1 | uimsbf
* if (is_visual_object_identifier) { | |
* visual_object_verid | 4 | uimsbf
* visual_object_priority | 3 | uimsbf
* } | |
* visual_object_type | 4 | uimsbf
* if (visual_object_type == “video ID” || visual_object_type == “still texture | |
* ID“) { | |
* video_signal_type() | |
* } | |
* next_start_code() | |
* while ( next_bits()== user_data_start_code){ | |
* user_data() | |
* } | |
* if (visual_object_type == “video ID”) { | |
* video_object_start_code | 32 | bslbf
* VideoObjectLayer() | |
* } | |
* else if (visual_object_type == “still texture ID”) { | |
* StillTextureObject() | |
* } | |
* else if (visual_object_type == “mesh ID”) { | |
* MeshObject() | |
* } | |
* else if (visual_object_type == “FBA ID”) { | |
* FBAObject() | |
* } | |
* else if (visual_object_type == “3D mesh ID”) { | |
* 3D_Mesh_Object() | |
* } | |
* if (next_bits() != “0000 0000 0000 0000 0000 0001”) | |
* next_start_code() | |
* } | |
* —————————————————————————————————————————————————————————————————————————————————+—————————————+—————————
* video_signal_type() { | No. of bits | Mnemonic
* video_signal_type | 1 | bslbf
* if (video_signal_type) { | |
* video_format | 3 | uimsbf
* video_range | 1 | bslbf
* colour_description | 1 | bslbf
* if (colour_description) { | |
* colour_primaries | 8 | uimsbf
* transfer_characteristics | 8 | uimsbf
* matrix_coefficients | 8 | uimsbf
* } | |
* } | |
* } | |
* ——————————————————————————————————————————————————————————————+—————————————+—————————
ASF
ASF对象
ASF对象全局唯一ID(GUID)
// Top-level ASF object GUIDS { "75B22630-668E-11CF-A6D9-00AA0062CE6C", "ASF_Header_Object" }, { "75B22636-668E-11CF-A6D9-00AA0062CE6C", "ASF_Data_Object" }, { "33000890-E5B1-11CF-89F4-00A0C90349CB", "ASF_Simple_Index_Object" }, { "D6E229D3-35DA-11D1-9034-00A0C90349BE", "ASF_Index_Object" }, { "FEB103F8-12AD-4C64-840F-2A1D2F7AD48C", "ASF_Media_Object_Index_Object" }, { "3CB73FD0-0C4A-4803-953D-EDF7B6228F0C", "ASF_Timecode_Index_Object" }, // Header Object GUIDs { "8CABDCA1-A947-11CF-8EE4-00C00C205365", "ASF_File_Properties_Object" }, { "B7DC0791-A9B7-11CF-8EE6-00C00C205365", "ASF_Stream_Properties_Object" }, { "5FBF03B5-A92E-11CF-8EE3-00C00C205365", "ASF_Header_Extension_Object" }, { "86D15240-311D-11D0-A3A4-00A0C90348F6", "ASF_Codec_List_Object" }, { "1EFB1A30-0B62-11D0-A39B-00A0C90348F6", "ASF_Script_Command_Object" }, { "F487CD01-A951-11CF-8EE6-00C00C205365", "ASF_Marker_Object" }, { "D6E229DC-35DA-11D1-9034-00A0C90349BE", "ASF_Bitrate_Mutual_Exclusion_Object" }, { "75B22635-668E-11CF-A6D9-00AA0062CE6C", "ASF_Error_Correction_Object" }, { "75B22633-668E-11CF-A6D9-00AA0062CE6C", "ASF_Content_Description_Object" }, { "D2D0A440-E307-11D2-97F0-00A0C95EA850", "ASF_Extended_Content_Description_Object" }, { "2211B3FA-BD23-11D2-B4B7-00A0C955FC6E", "ASF_Content_Branding_Object" }, { "7BF875CE-468D-11D1-8D82-006097C9A2B2", "ASF_Stream_Bitrate_Properties_Object" }, { "2211B3FB-BD23-11D2-B4B7-00A0C955FC6E", "ASF_Content_Encryption_Object" }, { "298AE614-2622-4C17-B935-DAE07EE9289C", "ASF_Extended_Content_Encryption_Object" }, { "2211B3FC-BD23-11D2-B4B7-00A0C955FC6E", "ASF_Digital_Signature_Object" }, { "1806D474-CADF-4509-A4BA-9AABCB96AAE8", "ASF_Padding_Object" }, // Header Extension Object GUIDs { "14E6A5CB-C672-4332-8399-A96952065B5A", "ASF_Extended_Stream_Properties_Object" }, { "A08649CF-4775-4670-8A16-6E35357566CD", "ASF_Advanced_Mutual_Exclusion_Object" }, { "D1465A40-5A79-4338-B71B-E36B8FD6C249", "ASF_Group_Mutual_Exclusion_Object" }, { "D4FED15B-88D3-454F-81F0-ED5C45999E24", "ASF_Stream_Prioritization_Object" }, { "A69609E6-517B-11D2-B6AF-00C04FD908E9", "ASF_Bandwidth_Sharing_Object" }, { "7C4346A9-EFE0-4BFC-B229-393EDE415C85", "ASF_Language_List_Object" }, { "C5F8CBEA-5BAF-4877-8467-AA8C44FA4CCA", "ASF_Metadata_Object" }, { "44231C94-9498-49D1-A141-1D134E457054", "ASF_Metadata_Library_Object" }, { "D6E229DF-35DA-11D1-9034-00A0C90349BE", "ASF_Index_Parameters_Object" }, { "6B203BAD-3F11-48E4-ACA8-D7613DE2CFA7", "ASF_Media_Object_Index_Parameters_Object" }, { "F55E496D-9797-4B5D-8C8B-604DFE9BFB24", "ASF_Timecode_Index_Parameters_Object" }, { "75B22630-668E-11CF-A6D9-00AA0062CE6C", "ASF_Compatibility_Object" }, { "43058533-6981-49E6-9B74-AD12CB86D58C", "ASF_Advanced_Content_Encryption_Object" }, // Stream Properties Object Stream Type GUIDs { "F8699E40-5B4D-11CF-A8FD-00805F5C442B", "ASF_Audio_Media" }, { "BC19EFC0-5B4D-11CF-A8FD-00805F5C442B", "ASF_Video_Media" }, { "59DACFC0-59E6-11D0-A3AC-00A0C90348F6", "ASF_Command_Media" }, { "B61BE100-5B4E-11CF-A8FD-00805F5C442B", "ASF_JFIF_Media" }, { "35907DE0-E415-11CF-A917-00805F5C442B", "ASF_Degradable_JPEG_Media" }, { "91BD222C-F21C-497A-8B6D-5AA86BFC0185", "ASF_File_Transfer_Media" }, { "3AFB65E2-47EF-40F2-AC2C-70A90D71D343", "ASF_Binary_Media" }, // Web stream Type-Specific Data GUIDs { "776257D4-C627-41CB-8F81-7AC7FF1C40CC", "ASF_Web_Stream_Media_Subtype" }, { "DA1E6B13-8359-4050-B398-388E965BF00C", "ASF_Web_Stream_Format" }, // Stream Properties Object Error Correction Type GUIDs { "20FB5700-5B55-11CF-A8FD-00805F5C442B", "ASF_No_Error_Correction" }, { "BFC3CD50-618F-11CF-8BB2-00AA00B4E220", "ASF_Audio_Spread" }, // Header Extension Object GUIDs { "ABD3D211-A9BA-11cf-8EE6-00C00C205365", "ASF_Reserved_1" }, // Advanced Content Encryption Object System ID GUIDs { "7A079BB6-DAA4-4e12-A5CA-91D38DC11A8D", "ASF_Content_Encryption_System_Windows_Media_DRM_Network_Devices" }, // Codec List Object GUIDs { "86D15241-311D-11D0-A3A4-00A0C90348F6", "ASF_Reserved_2" }, // Script Command Object GUIDs { "4B1ACBE3-100B-11D0-A39B-00A0C90348F6", "ASF_Reserved_3" }, // Marker Object GUIDs { "4CFEDB20-75F6-11CF-9C0F-00A0C90349CB", "ASF_Reserved_4" }, // Mutual Exclusion Object Exclusion Type GUIDs { "D6E22A00-35DA-11D1-9034-00A0C90349BE", "ASF_Mutex_Language" }, { "D6E22A01-35DA-11D1-9034-00A0C90349BE", "ASF_Mutex_Bitrate" }, { "D6E22A02-35DA-11D1-9034-00A0C90349BE", "ASF_Mutex_Unknown" }, // Bandwidth Sharing Object GUIDs { "AF6060AA-5197-11D2-B6AF-00C04FD908E9", "ASF_Bandwidth_Sharing_Exclusive" }, { "AF6060AB-5197-11D2-B6AF-00C04FD908E9", "ASF_Bandwidth_Sharing_Partial" }, // Standard Payload Extension System GUIDs { "399595EC-8667-4E2D-8FDB-98814CE76C1E", "ASF_Payload_Extension_System_Timecode" }, { "E165EC0E-19ED-45D7-B4A7-25CBD1E28E9B", "ASF_Payload_Extension_System_File_Name" }, { "D590DC20-07BC-436C-9CF7-F3BBFBF1A4DC", "ASF_Payload_Extension_System_Content_Type" }, { "1B1EE554-F9EA-4BC8-821A-376B74E4C4B8", "ASF_Payload_Extension_System_Pixel_Aspect_Ratio" }, { "C6BD9450-867F-4907-83A3-C77921B733AD", "ASF_Payload_Extension_System_Sample_Duration" }, { "6698B84E-0AFA-4330-AEB2-1C0A98D7A44D", "ASF_Payload_Extension_System_Encryption_Sample_ID" }
GUID
/** * struct { * unsigned long Data1; * unsigned short Data2; * unsigned short Data3; * unsigned char Data4[8]; * } GUID; * * see https://docs.microsoft.com/zh-tw/previous-versions/bb415594(v=msdn.10) * * 30 26 B2 75 8E 66 CF 11 A6 D9 00 AA 00 62 CE 6C * Data1 -> 30 26 B2 75 -> 75B22630 * Data2 -> 8E 66 -> 668E * Data3 -> CF 11 -> 11CF * Data4 -> A6 D9 00 AA 00 62 CE 6C -> A6D9-00AA0062CE6C * 75B22630-668E-11CF-A6D9-00AA0062CE6C */ struct guid { unsigned long data1; unsigned short data2; unsigned short data3; unsigned char data4[8]; };
GUID相关的几个函数
int guid(unsigned long data1, unsigned short data2, unsigned short data3, unsigned char data4[8], struct guid *out) { out->data1 = data1; out->data2 = data2; out->data3 = data3; memcpy(out->data4, data4, 8); return 0; } // param s, guid with string format. for example: 75B22630-668E-11CF-A6D9-00AA0062CE6C int guid_from(unsigned char s[36], struct guid *out) { unsigned char data5[17]; sscanf(s, "%lx-%hx-%hx-%s", &out->data1, &out->data2, &out->data3, data5); sscanf(data5, "%2hhx%2hhx-%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx", &out->data4[0], &out->data4[1], &out->data4[2], &out->data4[3], &out->data4[4], &out->data4[5], &out->data4[6], &out->data4[7]); return 0; } // param s, guid with string format. for example: 75B22630-668E-11CF-A6D9-00AA0062CE6C int guid_to(struct guid *out, unsigned char s[36]) { sprintf(s, "%.8X-%.4X-%.4X-%.2hhX%.2hhX-%.2hhX%.2hhX%.2hhX%.2hhX%.2hhX%.2hhX", out->data1, out->data2, out->data3, out->data4[0], out->data4[1], out->data4[2], out->data4[3], out->data4[4], out->data4[5], out->data4[6], out->data4[7]); return 0; }
WMV
AVI
Codec
FMP4
MPG
MP4
FLV
int flv_std_read_body(FILE *fp) { unsigned int pre_tag_size; fread(&pre_tag_size, 1, 4, fp); // PreviousTagSize0(4 bytes) pre_tag_size = htonl(pre_tag_size); printf("pre_tag_size=%u\n", pre_tag_size); while (! feof(fp)) { struct flv_tag_header *tag_header = malloc(sizeof(struct flv_tag_header)); struct flv_tag *tag; fread(tag_header, 1, sizeof(struct flv_tag_header), fp); // (11 bytes) tag = realloc(tag_header, sizeof(struct flv_tag_header) + __data_size__(tag_header)); tag_header = (struct flv_tag_header *) tag; fread(tag->data, 1, __data_size__(tag_header), fp); // (data_size bytes) fread(&pre_tag_size, 1, 4, fp); // PreviousTagSize1, 2, ..., n(4 bytes) pre_tag_size = htonl(pre_tag_size); printf("pre_tag_size=%u, type=%u, data_size=%u, timestamp=%u, timestamp_extended=%u, stream_id=%u\n", pre_tag_size, tag_header->type, __data_size__(tag_header), tag_header->timestamp, tag_header->timestamp_extended, __stream_id__(tag_header)); switch (tag_header->type) { case AUDIO_TAG: // 8 { printf("tag: audio\n"); parse_audio(tag->data, __data_size__(tag_header)); break; } case VIDEO_TAG: // 9 { printf("tag: video\n"); parse_video(tag->data, __data_size__(tag_header)); break; } case SCRIPT_DATA_TAG: // 18 { printf("tag: script data\n"); parse_script_data(tag->data, __data_size__(tag_header)); break; } default: // all others(tag) reserved. { break; } } } } int flv_std_load(FILE *fp) { struct flv_header header; fread(&header, 1, sizeof(struct flv_header), fp); // (9 bytes) header.data_offset = htonl(header.data_offset); printf("signature=%.3s, version=%u, reserved0=%u, audio=%u, reserved1=%u, video=%u, data_offset=%u\n", header.signature, header.version, header.reserved0, header.audio, header.reserved1, header.video, header.data_offset); if (header.data_offset > sizeof(struct flv_header)) { } flv_std_read_body(fp); return 0; }
F4V
音频编解码
AUDIO
frame
* frame() * { * header() * error_check() * audio_data() * ancillary_data() * }
header
* header() * { * syncword 12 bits bslbf * ID 1 bit bslbf * layer 2 bits bslbf * protection_bit 1 bit bslbf * bitrate_index 4 bits bslbf * sampling_frequency 2 bits bslbf * padding_bit 1 bit bslbf * private_bit 1 bit bslbf * mode 2 bits bslbf * mode_extension 2 bits bslbf * copyright 1 bit bslbf * original/home 1 bit bslbf * emphasis 2 bits bslbf * }
// layer
//
// "11"Layer I
// "10"Layer II
// "01"Layer III
// "00"reserved
* mode
*
* '00'stereo(also known as 立体声)
* '01'joint_stereo(also known as 联合立体声) (intensity_stereo al-
* so known as 强度立体声 and/or ms_stereo)
* In Layer I and II the joint_stereo mode is intensity_stereo,
* in Layer III it is intensity_stereo and/or ms_stereo.
*
* '10'dual_channel (also known as 双通道)
* '11'single_channel (also known as 单通道)
error_check
* error_check() * { * if (protection_bit==0) * crc_check 16 bits rpchof * }
audio_data
- Audio data, Layer I
* audio_data() * { * if (mode==single_channel) * { * for (sb=0; sb<32; sb++) * allocation[sb] 4 bits uimsbf * for (sb=0; sb<32; sb++) * if (allocation[sb]!=0) * scalefactor[sb] 6 bits uimsbf * for (s=0; s<12; s++) * for (sb=0; sb<32; sb++) * if (allocation[sb]!=0) * sample[sb][s] 2..15 bits uimsbf * } * if (mode==stereo) || (mode==dual_channel) * { * for (sb=0; sb<32; sb++) * for (ch=0; ch<2; ch++) * allocation[ch][sb] 4 bits bsmsbf * for (sb=0; sb<32; sb++) * for (ch=0; ch<2; ch++) * if (allocation[ch][sb]!=0) * scalefactor[ch][sb] 6 bits uimsbf * for (s=0; s<12; s++) * for (sb=0; sb<32; sb++) * for (ch=0; ch<2; ch++) * if (allocation[ch][sb]!=0) * sample[ch][sb][s] 2..15 bits uimsbf * } * if (mode==intensity_stereo) * { * for (sb=0; sb<bound; sb++) * for (ch=0; ch<2; ch++) * allocation[ch][sb] 4 bits uimsbf * for (sb=bound; sb<32; sb++) * allocation[sb] 4 bits uimsbf * for (sb=0; sb<bound; sb++) * for (ch=0; ch<2; ch++) * if (allocation[ch][sb]!=0) * scalefactor[ch][sb] 6 bits uimsbf * for (sb=bound; sb<32; sb++) * for (ch=0; ch<2; ch++) * if (allocation[sb]!=0) * scalefactor[ch][sb] 6 bits uimsbf * for (s=0; s<12; s++) * { * for (sb=0; sb<bound; sb++) * for (ch=0; ch<2; ch++) * if (allocation[ch][sb]!=0) * sample[ch][sb][s] 2..15 bits uimsbf * for (sb=bound; sb<32; sb++) * if (allocation[sb]!=0) * sample[sb][s] 2..15 bits uimsbf * } * } * }
- Audio data, Layer II
* audio_data() * { * if (mode==single_channel) * { * for (sb=0; sb<sblimit; sb++) * allocation[sb] 2..4 bits uimsbf * for (sb=0; sb<sblimit; sb++) * if (allocation[sb]!=0) * scfsi[sb] 2 bits bslbf * for (sb=0; sb<sblimit; sb++) * if (allocation[sb]!=0) * { * if (scfsi[sb]==0) * { * scalefactor[sb][0] 6 bits uimsbf * scalefactor[sb][1] 6 bits uimsbf * scalefactor[sb][2] } 6 bits uimsbf * if (scfsi[sb]==1) || (scfsi[sb]==3) * { * scalefactor[sb][0] 6 bits uimsbf * scalefactor[sb][2] } 6 bits uimsbf * if (scfsi[sb]==2) * scalefactor[sb][0] 6 bits uimsbf * } * for (gr=0; gr<12; gr++) * for (sb=0; sb<sblimit; sb++) * if (allocation[sb]!=0) * { * if (grouping[sb]) * samplecode[sb][gr] 5..10 bits uimsbf * else * for (s=0; s<3; s++) * sample[sb][3*gr+s] 2..16 bits uimsbf * } * } * * if (mode==stereo) || (mode==dual_channel) * { * for (sb=0; sb<sblimit; sb++) * for (ch=0; ch<2; ch++) * allocation[ch][sb] 2..4 bits uimsbf * for (sb=0; sb<sblimit; sb++) * for (ch=0; ch<2; ch++) * if (allocation[ch][sb]!=0) * scfsi[ch][sb] 2 bits bslbf * for (sb=0; sb<sblimit; sb++) * for (ch=0; ch<2; ch++) * if (allocation[ch][sb]!=0) * { * if (scfsi[ch][sb]==0) * { * scalefactor[ch][sb][0] 6 bits uimsbf * scalefactor[ch][sb][1] 6 bits uimsbf * scalefactor[ch][sb][2] } 6 bits uimsbf * if (scfsi[ch][sb]==1) || (scfsi[ch][sb]==3) * { * scalefactor[ch][sb][0] 6 bits uimsbf * scalefactor[ch][sb][2] } 6 bits uimsbf * if (scfsi[ch][sb]==2) * scalefactor[ch][sb][0] 6 bits uimsbf * } * for (gr=0; gr<12; gr++) * for (sb=0; sb<sblimit; sb++) * for (ch=0; ch<2; ch++) * if (allocation[ch][sb]!=0) * { * if (grouping[ch][sb]) * samplecode[ch][sb][gr] 5..10 bits uimsbf * else for (s=0; s<3; s++) * sample[ch][sb][3*gr+s] 2..16 bits uimsbf * } * } * * if (mode==intensity_stereo) * { * for (sb=0; sb<bound; sb++) * for (ch=0; ch<2; ch++) * allocation[ch][sb] 2..4 bits uimsbf * for (sb=bound; sb<sblimit; sb++) * allocation[sb] 2..4 bits uimsbf * for (sb=0; sb<bound; sb++) * for (ch=0; ch<2; ch++) * if (allocation[ch][sb]!=0) * scfsi[ch][sb] 2 bits bslbf * for (sb=bound; sb<sblimit; sb++) * for (ch=0; ch<2; ch++) * if (allocation[sb]!=0) * scfsi[ch][sb] 2 bits bslbf * for (sb=0; sb<bound; sb++) * for (ch=0; ch<2; ch++) * if (allocation[ch][sb]!=0) * { * if (scfsi[ch][sb]==0) * { * scalefactor[ch][sb][0] 6 bits uimsbf * scalefactor[ch][sb][1] 6 bits uimsbf * scalefactor[ch][sb][2] } 6 bits uimsbf * if (scfsi[ch][sb]==1) || (scfsi[ch][sb]==3) * { * scalefactor[ch][sb][0] 6 bits uimsbf * scalefactor[ch][sb][2] } 6 bits uimsbf * if (scfsi[ch][sb]==2) * scalefactor[ch][sb][0] 6 bits uimsbf * } * for (sb=bound; sb<sblimit; sb++) * for (ch=0; ch<2; ch++) * if (allocation[sb]!=0) * { * if (scfsi[ch][sb]==0) * { * scalefactor[ch][sb][0] 6 bits uimsbf * scalefactor[ch][sb][1] 6 bits uimsbf * scalefactor[ch][sb][2] } 6 bits uimsbf * if (scfsi[ch][sb]==1) || (scfsi[ch][sb]==3) * { * scalefactor[ch][sb][0] 6 bits uimsbf * scalefactor[ch][sb][2] } 6 bits uimsbf * if (scfsi[ch][sb]==2) * scalefactor[ch][sb][0] 6 bits uimsbf * } * for (gr=0; gr<12; gr++) * { * for (sb=0; sb<bound; sb++) * for (ch=0; ch<2; ch++) * if (allocation[ch][sb]!=0) * { * if (grouping[ch][sb]) * samplecode[ch][sb][gr] 5..10 bits uimsbf * else for (s=0; s<3; s++) * sample[ch][sb][3*gr+s] 2..16 bits uimsbf * } * for (sb=bound; sb<sblimit; sb++) * if (allocation[sb]!=0) * { * if (grouping[sb]) * samplecode[sb][gr] 5..10 bits uimsbf * else for (s=0; s<3; s++) * sample[sb][3*gr+s] 2..16 bits uimsbf * } * } * } * }
- Audio data, Layer III
* audio_data() * { * if (mode == single_channel) * { * main_data_end 9 bits uimsbf * private_bits 5 bits bslbf * for (scfsi_band=0; scfsi_band<4; scfsi_band++) * scfsi[scfsi_band] 1 bits bslbf * for (gr=0; gr<2; gr++) * { * part2_3_length[gr] 12 bits uimsbf * big_values[gr] 9 bits uimsbf * global_gain[gr] 8 bits uimsbf * scalefac_compress[gr] 4 bits bslbf * blocksplit_flag[gr] 1 bit bslbf * if (blocksplit_flag[gr]) * { * block_type[gr] 2 bits bslbf * switch_point[gr] 1 bits uimsbf * for (region=0; region<2; region++) * table_select[region][gr] 5 bits bslbf * for (window=0; window<3; window++) * subblock_gain[window][gr] 3 bits uimsbf * } * else * { * for (region=0; region<3; region++) * table_select[region][gr] 5 bits bslbf * region_address1[gr] 4 bits bslbf * region_address2[gr] 3 bits bslbf * } * preflag[gr] 1 bit bslbf * scalefac_scale[gr] 1 bit bslbf * count1table_select[gr] 1 bit bslbf * } * * // * // The main_data follows. It does not follow the above side information * // in the bitstream. The main_data ends at a location in the main_data * // bitstream preceding the frame header of the following frame at an offset * // given by the value of main_data_end (see definition of main_data_end * // and 3-Annex Fig.3-A.7.1) * // * for (gr=0; gr<2; gr++) * if (blocksplit_flag[gr] == 1 && block_type[gr] == 2) * { * for (cb=0; cb<switch_point_l[gr]; cb++) * if (scfsi[cb]==0) || (gr==0) * scalefac[cb][gr] 0..4 bits uimsbf * for (cb=switch_point_s[gr]; cb<cblimit_short; cb++) * for (window=0; window<3; window++) * if (scfsi[cb]==0) || (gr==0) * scalefac[cb][window][gr] 0..4 bits uimsbf * } * else * for (cb=0; cb<cblimit; cb++) * if (scfsi[cb]==0) || (gr==0) * scalefac[cb][gr] 0..4 bits uimsbf * Huffmancodebits (part2_3_length-part2_length) bits bslbf * while (position != main_data_end) * { * ancillary_bit 1 bit bslbf * } * * } * * if (mode==stereo) || (mode==dual_channel) || (mode==ms_stereo) * { * main_data_end 9 bits uimsbf * private_bits 3 bits bslbf * for (ch=0; ch<2; ch++) * for (scfsi_band=0; scfsi_band<4; scfsi_band++) * scfsi[scfsi_band][ch] 1 bits bslbf * for (gr=0; gr<2; gr++) * for (ch=0; ch<2; ch++} * part2_3_length[gr][ch] 12 bits uimsbf * big_values[gr][ch] 9 bits uimsbf * global_gain[gr][ch] 8 bits uimsbf * scalefac_compress[gr][ch] 4 bits bslbf * blocksplit_flag[gr][ch] 1 bit bslbf * if (blocksplit_flag[gr][ch]) * { * block_type[gr][ch] 2 bits bslbf * switch_point[gr][ch] 1 bits uimsbf * for (region=0; region<2; region++) * table_select[region][gr][ch] 5 bits bslbf * for (window=0; window<3; window++) * subblock_gain[window][gr][ch] 3 bits uimsbf * } * else * { * for (region=0; region<3; region++) * table_select[region][gr][ch] 5 bits bslbf * region_address1[gr][ch] 4 bits bslbf * region_address2[gr][ch] 3 bits bslbf * } * preflag[gr][ch] 1 bit bslbf * scalefac_scale[gr][ch] 1 bit bslbf * count1table_select[gr][ch] 1 bit bslbf * * // * // The main_data follows. It does not follow the above side information * // in the bitstream. The main_data ends at a location in the main_data * // bitstream preceding the frame header of the following frame at an offset * // given by the value of main_data_end. * // * for (gr=0; gr<2; gr++) * for (ch=0; ch<2; ch++) { * if (blocksplit_flag[gr][ch] == 1 && block_type[gr][ch] == 2) * { * for (cb=0; cb<switch_point_l[gr][ch]; cb++) * if (scfsi[cb]==0) || (gr==0) * scalefac[cb][gr][ch] 0..4 bits uimsbf * for (cb=switch_point_s[gr][ch]; cb<cblimit_short; cb++) * for (window=0; window<3; window++) * if (scfsi[cb]==0) || (gr==0) * scalefac[cb][window][gr][ch] 0..4 bits uimsbf * } * else * for (cb=0; cb<cblimit; cb++) * if (scfsi[cb]==0) || (gr==0) * scalefac[cb][gr][ch] 0..4 bits uimsbf * Huffmancodebits (part2_3_length-part2_length) bits bslbf * while (position != main_data_end) * { * ancillary_bit 1 bit bslbf * } * * } * } * }
MP3
MPEG Audio Layer3
视频编解码
上一篇: 如何调理嗜睡症 嗜睡症应该怎么改善
下一篇: 早上空腹吃1个苹果,身体竟会发生这些变化