📄 inptstrm.cpp
字号:
DisplayInfo(" "); DisplayInfo(" Scanning audio stream for access units information"); info_file = fopen (audio_units, "wb"); if (info_file == NULL) { sprintf(tmpStr, "Unable to create temporary audio units file %s.", audio_units); DisplayInfo(tmpStr); return FALSE; } if (!init_getbits(&bs, audio_file)) goto exit3; empty_aaunit_struc (&access_unit); if (!getbits(&bs, &retval, 12)) goto exit3; if (retval==AUDIO_SYNCWORD) { if (!marker_bit(&bs, 1)) goto exit3; audio_info->num_syncword++; if (!getbits(&bs, &retval, 2)) goto exit3; audio_info->layer = retval; if (!get1bit(&bs, &retval)) goto exit3; audio_info->protection = retval; if (!getbits(&bs, &retval, 4)) goto exit3; audio_info->bit_rate = retval; if (!getbits(&bs, &retval, 2)) goto exit3; audio_info->frequency = retval; if (!get1bit(&bs, &retval)) goto exit3; padding_bit = retval; if (!get1bit(&bs, &retval)) goto exit3; if (!getbits(&bs, &retval, 2)) goto exit3; audio_info->mode = retval; if (!getbits(&bs, &retval, 2)) goto exit3; audio_info->mode_extension = retval; if (!get1bit(&bs, &retval)) goto exit3; audio_info->copyright = retval; if (!get1bit(&bs, &retval)) goto exit3; audio_info->original_copy = retval; if (!getbits(&bs, &retval, 2)) goto exit3; audio_info->emphasis = retval; framesize = (uint)(bitrate_index[3-audio_info->layer][audio_info->bit_rate] / frequency[audio_info->frequency] * slots [3-audio_info->layer]); audio_info->size_frames[0] = framesize; audio_info->size_frames[1] = framesize+1; access_unit.length = audio_info->size_frames[padding_bit]; samples_per_second = (double)frequency [audio_info->frequency]; PTS = decoding_order * samples [3-audio_info->layer] / samples_per_second * 27000. + *startup_delay; make_timecode (PTS, &access_unit.PTS); decoding_order++; if (fwrite (&access_unit, sizeof (Aaunit_struc),1, info_file) != 1) { sprintf(tmpStr, "Error writing to temporary audio units file %s: %s.", audio_units, strerrno()); DisplayError(tmpStr); goto exit3; } audio_count++; audio_info->num_frames[padding_bit]++; do { if (AbortMPEG) break; percent = (int)floor(((bitcount(&bs) / 8.0)) / ((double) length) * 100.0); if (percent != oldPercent) { sprintf(tmpStr, "Scanning audio stream: %d%% - byte offset %.0f of %d.", percent, bitcount(&bs) / 8.0, length); DisplayProgress(tmpStr, percent); oldPercent = percent; } skip=access_unit.length-4; if (skip & 0x1) if (!getbits(&bs, &retval, 8)) goto exit3; if (skip & 0x2) if (!getbits(&bs, &retval, 16)) goto exit3; skip = skip >> 2; for (i = 0; i < skip; i++) if (!getbits(&bs, &retval, 32)) if (end_bs(&bs)) break; else goto exit3; offset_bits = bitcount(&bs); if (!getbits(&bs, &retval, 12)) { if (!end_bs(&bs)) goto exit3; else break; } if (retval != AUDIO_SYNCWORD) { // try to find next SYNCWORD u_int ret; do { if (!getbits(&bs, &ret, 8)) break; ; retval=(retval&0xf)<<8|ret; if (retval == AUDIO_SYNCWORD) break; } while (!end_bs(&bs)); } if (retval == AUDIO_SYNCWORD) { if (!marker_bit(&bs, 1)) goto exit3; audio_info->num_syncword++; if (!getbits(&bs, &retval, 9)) goto exit3; if (!get1bit(&bs, &retval)) goto exit3; padding_bit = retval; access_unit.length = audio_info->size_frames[padding_bit]; PTS = decoding_order * samples [3-audio_info->layer] / samples_per_second * 27000. + *startup_delay; make_timecode (PTS, &access_unit.PTS); decoding_order++; if (fwrite (&access_unit, sizeof (Aaunit_struc),1, info_file) != 1) { sprintf(tmpStr, "Error writing to temporary audio units file %s: %s.", audio_units, strerrno()); DisplayError(tmpStr); goto exit3; } audio_count++; audio_info->num_frames[padding_bit]++; if (!getbits(&bs, &retval, 9)) goto exit3; } else break; } while (!end_bs(&bs)); } else { finish_getbits(&bs); if (!init_getbits(&bs, audio_file)) goto exit3; if (seek_sync(&bs, AC3_SYNCWORD, 16)) { audio_info->layer = 0; /* let'em know it's AC3 */ audio_info->num_syncword++; if (!getbits(&bs, &retval, 16)) /* CRC field */ goto exit3; if (!getbits(&bs, &retval, 2)) /* sample rate code */ goto exit3; audio_info->frequency = retval; if (!getbits(&bs, &retval, 6)) /* frame size code */ goto exit3; framesize = ac3_frame_size[audio_info->frequency][retval >> 1]; if ((retval & 1) && (audio_info->frequency == 1)) framesize++; framesize = framesize << 1; audio_info->bit_rate = ac3_bitrate_index[retval >> 1]; audio_info->protection = 0; audio_info->mode = 0; audio_info->mode_extension = 0; audio_info->copyright = 0; audio_info->original_copy = 0; audio_info->emphasis = 0; audio_info->size_frames[0] = framesize; access_unit.length = framesize; samples_per_second = (double)ac3_frequency [audio_info->frequency]; PTS = decoding_order * 1536 / samples_per_second * 27000. + *startup_delay; make_timecode (PTS, &access_unit.PTS); decoding_order++; if (fwrite (&access_unit, sizeof (Aaunit_struc),1, info_file) != 1) { sprintf(tmpStr, "Error writing to temporary audio units file %s: %s.", audio_units, strerrno()); DisplayError(tmpStr); goto exit3; } audio_count++; audio_info->num_frames[0]++; do { if (AbortMPEG) break; percent = (int)floor(((bitcount(&bs) / 8.0)) / ((double) length) * 100.0); if (percent != oldPercent) { sprintf(tmpStr, "Scanning audio stream: %d%% - byte offset %.0f of %d.", percent, bitcount(&bs) / 8.0, length); DisplayProgress(tmpStr, percent); oldPercent = percent; } skip = framesize - 5; for (i = 0; i < skip; i++) { if (!getbits(&bs, &retval, 8)) break; } offset_bits = bitcount(&bs); if (seek_sync(&bs, AC3_SYNCWORD, 16)) { audio_info->num_syncword++; if (!getbits(&bs, &retval, 16)) /* CRC field */ goto exit3; if (!getbits(&bs, &retval, 2)) /* sample rate code */ goto exit3; if (!getbits(&bs, &retval, 6)) /* frame size code */ goto exit3; framesize = ac3_frame_size[audio_info->frequency][retval >> 1]; if ((retval & 1) && (audio_info->frequency == 1)) framesize++; framesize = framesize << 1; access_unit.length = framesize; PTS = decoding_order * 1536 / samples_per_second * 27000. + *startup_delay; make_timecode (PTS, &access_unit.PTS); decoding_order++; if (fwrite (&access_unit, sizeof (Aaunit_struc),1, info_file) != 1) { sprintf(tmpStr, "Error writing to temporary audio units file %s: %s.", audio_units, strerrno()); DisplayError(tmpStr); goto exit3; } audio_count++; audio_info->num_frames[0]++; } else break; } while (!end_bs(&bs)); } else { DisplayError("Only MPEG and AC3 audio stream formats are supported."); goto exit3; } } if (!AbortMPEG) { sprintf(tmpStr, " Found %d audio frame headers, stream bit offset %.0f.", audio_info->num_syncword, offset_bits); DisplayInfo(tmpStr); audio_info->stream_length = (unsigned long) ceil(offset_bits / 8.0); exiterror = FALSE; *audio_total = audio_count; }exit3: finish_getbits(&bs); fclose(info_file); if (exiterror) unlink(audio_units); else output_info_audio(audio_info); return !exiterror;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -