From: Philip de N. <ph...@us...> - 2010-06-25 14:22:31
|
Update of /cvsroot/ingex/ingex/studio/ace-tao/Recorder In directory sfp-cvsdas-4.v30.ch3.sourceforge.com:/tmp/cvs-serv980/ace-tao/Recorder Modified Files: recorder_functions.cpp Log Message: Shared memory audio now in mono buffers Index: recorder_functions.cpp =================================================================== RCS file: /cvsroot/ingex/ingex/studio/ace-tao/Recorder/recorder_functions.cpp,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** recorder_functions.cpp 2 Jun 2010 13:09:53 -0000 1.34 --- recorder_functions.cpp 25 Jun 2010 14:22:21 -0000 1.35 *************** *** 61,64 **** --- 61,66 ---- #include <cstdio> + #include <cstring> + #include <cerrno> #include <iostream> #include <sstream> *************** *** 419,422 **** --- 421,433 ---- mt_possible = true; break; + case MaterialResolution::XDCAMHD422_RAW: + //case MaterialResolution::XDCAMHD422_MXF_OP1A: TODO Not yet implemented + //pix_fmt = PIXFMT_422; + //codec_input_format = HD_422; + encoder = ENCODER_FFMPEG; + filename_extension = ".m2v"; + + break; + // Browse formats case MaterialResolution::DVD: *************** *** 536,539 **** --- 547,552 ---- } + + // Override file name extension for MXF or MOV wrapping switch (file_format) *************** *** 551,554 **** --- 564,568 ---- } + // (video) filename std::ostringstream filename_prefix; *************** *** 777,780 **** --- 791,796 ---- } + + // Initialisation for av files // ffmpeg av encoder *************** *** 967,979 **** IngexShm::Instance()->InfoSetRecording(channel_i, p_opt->index, quad_video, true); IngexShm::Instance()->InfoSetDesc(channel_i, p_opt->index, quad_video, ! "%s%s %s%s%s%s%s", resolution_name.c_str(), ! quad_video ? "(quad)" : "", ! raw ? "RAW" : "MXF", ! /*enable_audio12 ? " A12" : "", ! enable_audio34 ? " A34" : "", ! enable_audio56 ? " A56" : "", ! enable_audio78 ? " A78" : ""*/ ! "", "", "", "" ); --- 983,989 ---- IngexShm::Instance()->InfoSetRecording(channel_i, p_opt->index, quad_video, true); IngexShm::Instance()->InfoSetDesc(channel_i, p_opt->index, quad_video, ! "%s%s", resolution_name.c_str(), ! quad_video ? " (quad)" : "" ); *************** *** 1076,1113 **** } - // Set up some audio pointers. - // NB. Assuming all from same hardware channel. - - // Pointer to audio12 - int32_t * p_audio12 = IngexShm::Instance()->pAudio12(channel_i, frame[channel_i]); - - // Pointer to audio34 - int32_t * p_audio34 = IngexShm::Instance()->pAudio34(channel_i, frame[channel_i]); - - // Pointer to audio56 - int32_t * p_audio56 = IngexShm::Instance()->pAudio56(channel_i, frame[channel_i]); - - // Pointer to audio78 - int32_t * p_audio78 = IngexShm::Instance()->pAudio78(channel_i, frame[channel_i]); - - // Need to set this for each captured frame because the number - // varies in NTSC. int audio_samples_per_frame = IngexShm::Instance()->NumAudioSamples(channel_i, frame[channel_i]); - // Guard against garbage data - if (audio_samples_per_frame < 0 || audio_samples_per_frame > 1920) - { - audio_samples_per_frame = 1920; - } - - // Until we have mono audio buffers in IngexShm, demultiplex the audio. - // Buffers for audio de-interleaving - int16_t a[8][audio_samples_per_frame]; - deinterleave_32to16(p_audio12, a[0], a[1], audio_samples_per_frame); - deinterleave_32to16(p_audio34, a[2], a[3], audio_samples_per_frame); - if (IngexShm::Instance()->AudioTracksPerChannel() >= 8) - { - deinterleave_32to16(p_audio56, a[4], a[5], audio_samples_per_frame); - deinterleave_32to16(p_audio78, a[6], a[7], audio_samples_per_frame); - } // Set up all the input pointers as tracks of an EncodeFrame --- 1086,1090 ---- *************** *** 1151,1164 **** else { ! //p = IngexShm::Instance()->pAudio(hw.channel, hw.track, frames[hw.channel]); ! // Mono audio buffers not yet available ! p = a[hw.track - 1]; ! size = audio_samples_per_frame * 2; ! ! // Audio not in shared memory buffer so we need to copy for multi-threaded encode ! if (mt_encoder) ! { ! copy = true; ! } } --- 1128,1135 ---- else { ! // Get pointer to 16bit mono audio buffer (in shared memory) for this track ! p = IngexShm::Instance()->pSecondaryAudio(channel_i, frame[channel_i], hw.track - 1); ! ! size = audio_samples_per_frame * 2; // 16bit audio } *************** *** 1304,1313 **** // Mix audio for browse version ! int16_t mixed_audio[audio_samples_per_frame * 2]; // for stereo pair output - // Needs update for mono 32-bit audio buffers when we have them if (browse_audio || ENCODER_FFMPEG_AV == encoder) { ! mixer.Mix(p_audio12, p_audio34, mixed_audio, audio_samples_per_frame); } --- 1275,1287 ---- // Mix audio for browse version ! int16_t mixed_audio[audio_samples_per_frame * 2]; // for 16bit stereo pair output if (browse_audio || ENCODER_FFMPEG_AV == encoder) { ! int16_t *pA1 = IngexShm::Instance()->pSecondaryAudio(channel_i, frame[channel_i], 0); ! int16_t *pA2 = IngexShm::Instance()->pSecondaryAudio(channel_i, frame[channel_i], 1); ! int16_t *pA3 = IngexShm::Instance()->pSecondaryAudio(channel_i, frame[channel_i], 2); ! int16_t *pA4 = IngexShm::Instance()->pSecondaryAudio(channel_i, frame[channel_i], 3); ! mixer.Mix(pA1, pA2, pA3, pA4, mixed_audio, audio_samples_per_frame); } *************** *** 1525,1534 **** { // Video ! size_t n = fwrite(eft.Data(), eft.Size(), 1, fp); ! if (n == 0) { ! ACE_DEBUG((LM_ERROR, ACE_TEXT("Raw video file write error!\n"))); ! fclose(fp); ! fp = NULL; } } --- 1499,1511 ---- { // Video ! if (eft.Size()) { ! size_t n = fwrite(eft.Data(), eft.Size(), 1, fp); ! if (n == 0) ! { ! ACE_DEBUG((LM_ERROR, ACE_TEXT("Raw video file write error!\n"))); ! fclose(fp); ! fp = NULL; ! } } } *************** *** 1673,1676 **** --- 1650,1654 ---- IngexShm::Instance()->InfoSetRecording(channel_i, p_opt->index, quad_video, false); + IngexShm::Instance()->InfoSetDesc(channel_i, p_opt->index, quad_video, ""); // Get user comments (only available after stop) *************** *** 1743,1746 **** --- 1721,1728 ---- if (mxf || (SAVE_PACKAGE_DATA && ENCODER_FFMPEG_AV == encoder && !quad_video)) { + std::ostringstream creating_metadata_filename; + creating_metadata_filename << p_opt->dir << PATH_SEPARATOR << + mxf_subdir_creating << PATH_SEPARATOR << + p_opt->file_ident << ".xml"; std::ostringstream metadata_filename; metadata_filename << p_opt->dir << PATH_SEPARATOR << *************** *** 1748,1755 **** p_opt->file_ident << ".xml"; ! package_creator->SaveToFile(metadata_filename.str()); ! ACE_DEBUG((LM_DEBUG, ACE_TEXT("Saved package group '%C' to metadata file '%C'\n"), ! package_creator->GetMaterialPackage()->name.c_str(), ! metadata_filename.str().c_str())); } } --- 1730,1748 ---- p_opt->file_ident << ".xml"; ! // save to creating directory and then move to the metadata directory ! package_creator->SaveToFile(creating_metadata_filename.str()); ! if (rename(creating_metadata_filename.str().c_str(), metadata_filename.str().c_str()) != 0) ! { ! ACE_DEBUG((LM_ERROR, ACE_TEXT("Failed to rename metadata file from '%C' to '%C': %C\n"), ! creating_metadata_filename.str().c_str(), ! metadata_filename.str().c_str(), ! strerror(errno))); ! } ! else ! { ! ACE_DEBUG((LM_DEBUG, ACE_TEXT("Saved package group '%C' to metadata file '%C'\n"), ! package_creator->GetMaterialPackage()->name.c_str(), ! metadata_filename.str().c_str())); ! } } } |