📄 umc_transcoder_con.cpp
字号:
/*//////////////////////////////////////////////////////////////////////////////
//
// INTEL CORPORATION PROPRIETARY INFORMATION
// This software is supplied under the terms of a license agreement or
// nondisclosure agreement with Intel Corporation and may not be copied
// or disclosed except in accordance with the terms of that agreement.
// Copyright(c) 2003-2007 Intel Corporation. All Rights Reserved.
//
*/
#include "umc_transcoder_con.h"
//create new instance of Transcoder
Transcoder::Transcoder(void)
{
m_bExit = false;
m_lpDataReaderVideo = NULL;
m_lpDataReaderAudio = NULL;
m_lpVideoSplitter = NULL;
m_lpAudioSplitter = NULL;
m_lpVideoDecoder = NULL;
m_lpAudioDecoder = NULL;
m_lpVideoProcessing = NULL;
m_lpPCMBuffer = NULL;
m_lpDTAudioEncoder = NULL;
m_lpMediaBuffer = NULL;
m_lpDTAudioDecoder = NULL;
m_lpVideoEncoder = NULL;
m_lpAudioEncoder = NULL;
m_lpMuxer = NULL;
m_lpDataWriter = NULL;
m_lpAudioEncoderParams = NULL;
m_lpVideoEncoderParams = NULL;
m_lpMuxerParams = NULL;
vm_thread_set_invalid(&m_hVideoTranscoding);
vm_thread_set_invalid(&m_hAudioDecoding);
vm_thread_set_invalid(&m_hAudioEncoding);
m_lEncodedFrames = 0;
m_dElapsedTime = 0.0;
m_dAdditionalTime = 0.0;
time_counter1 = 0;
time_counter2 = 0;
time_counter3 = 0;
time_counter4 = 0;
time_counter5 = 0;
m_lpAudioDecSpecInfo = m_lpVideoDecSpecInfo = NULL;
error_status = false;
audio_track_num = video_track_num = -1;
number_of_audio_tracks = number_of_video_tracks = 0;
m_bInit = false;
}; //Transcoder::Transcoder(void)
//delete new instance of Transcoder
Transcoder::~Transcoder(void)
{
Close();
}; //Transcoder::~Transcoder(void)
//close and delete all used objects
UMC::Status Transcoder::Close(void)
{
m_bExit = true;
ReleaseVideo();
ReleaseAudio();
if (m_lpMuxer)
delete m_lpMuxer;
if (m_lpMuxerParams)
delete m_lpMuxerParams;
if (m_lpDataWriter)
delete m_lpDataWriter;
m_lpMuxer = NULL;
m_lpDataWriter = NULL;
m_lpMuxerParams = NULL;
m_lEncodedFrames = 0;
m_dElapsedTime = 0.0;
m_dAdditionalTime = 0.0;
m_bExit = false;
time_counter1 = 0;
time_counter2 = 0;
time_counter3 = 0;
time_counter4 = 0;
time_counter5 = 0;
audio_track_num = video_track_num = -1;
number_of_audio_tracks = number_of_video_tracks = 0;
return UMC::UMC_OK;
}; //UMC::Status Transcoder::Close(void)
//close and delete all used video objects
void Transcoder::ReleaseVideo(void)
{
// wait working thread(s)
if (vm_thread_is_valid(&m_hVideoTranscoding))
vm_thread_wait(&m_hVideoTranscoding);
// release object(s)
if (m_lpVideoDecoder)
delete m_lpVideoDecoder;
if (m_lpVideoSplitter == m_lpAudioSplitter)
m_lpAudioSplitter = NULL;
if (m_lpVideoSplitter)
delete m_lpVideoSplitter;
if ((m_lpDataReaderVideo) && (m_lpDataReaderVideo != m_lpDataReaderAudio))
delete m_lpDataReaderVideo;
if (m_lpVideoProcessing)
delete m_lpVideoProcessing;
if (m_lpVideoEncoderParams)
delete m_lpVideoEncoderParams;
if (m_lpVideoEncoder)
delete m_lpVideoEncoder;
m_lpVideoDecSpecInfo = NULL;
m_lpDataReaderVideo = NULL;
m_lpVideoSplitter = NULL;
m_lpVideoDecoder = NULL;
m_lpVideoProcessing = NULL;
m_lpVideoEncoder = NULL;
m_lpVideoEncoderParams = NULL;
vm_thread_set_invalid(&m_hVideoTranscoding);
}; // void Transcoder::ReleaseVideo(void)
//close and delete all used audio objects
void Transcoder::ReleaseAudio(void)
{
if (vm_thread_is_valid(&m_hAudioDecoding))
vm_thread_wait(&m_hAudioDecoding);
if (vm_thread_is_valid(&m_hAudioEncoding))
vm_thread_wait(&m_hAudioEncoding);
// release object(s)
if (m_lpDTAudioDecoder)
delete m_lpDTAudioDecoder;
if (m_lpMediaBuffer)
delete m_lpMediaBuffer;
if ((m_lpAudioSplitter) && (m_lpAudioSplitter != m_lpVideoSplitter))
delete m_lpAudioSplitter;
if ((m_lpDataReaderAudio) && (m_lpDataReaderAudio != m_lpDataReaderVideo))
delete m_lpDataReaderAudio;
if (m_lpDTAudioEncoder)
delete m_lpDTAudioEncoder;
if (m_lpPCMBuffer)
delete m_lpPCMBuffer;
if (m_lpAudioEncoder)
delete m_lpAudioEncoder;
if (m_lpAudioEncoderParams)
delete m_lpAudioEncoderParams;
m_lpAudioDecSpecInfo = NULL;
m_lpDataReaderAudio = NULL;
m_lpAudioSplitter = NULL;
m_lpAudioDecoder = NULL;
m_lpDTAudioEncoder = NULL;
m_lpPCMBuffer = NULL;
m_lpDTAudioDecoder = NULL;
m_lpMediaBuffer = NULL;
m_lpAudioEncoder = NULL;
m_lpAudioEncoderParams = NULL;
vm_thread_set_invalid(&m_hAudioDecoding);
vm_thread_set_invalid(&m_hAudioEncoding);
} // void Transcoder::ReleaseAudio(void)
// Get current position of transcoding
Ipp64f Transcoder::GetProgress(void)
{
UMC::DataReader* lpDataReader = NULL;
// when no running thread(s) - no transcoding
if (vm_thread_is_valid(&m_hVideoTranscoding) ||
vm_thread_is_valid(&m_hAudioDecoding) ||
vm_thread_is_valid(&m_hAudioEncoding))
// get current position
if (lpDataReader = m_lpDataReaderVideo ? m_lpDataReaderVideo : m_lpDataReaderAudio)
{
Ipp64u dProgress = lpDataReader->GetPosition();
return ((double)dProgress) / lpDataReader->GetSize();
}
return -1.0;
}; //Ipp64f Transcoder::GetProgress(void)
// Reset media stream(s) to original state
UMC::Status Transcoder::Reset(void)
{
Close();
return Init(m_TranscoderParams);
}; //UMC::Status Transcoder::Reset(void)
// Get current performance
void Transcoder::GetPerformance(Ipp32u &lEncodedFrames, Ipp64f &dElapsedTime)
{
if (m_lpVideoSplitter)
{
lEncodedFrames = m_lEncodedFrames;
dElapsedTime = m_dElapsedTime + m_dAdditionalTime;
}
else
{
lEncodedFrames = -1;
dElapsedTime = -1.0;
};
}; //void Transcoder::GetPerformance(long &lEncodedFrames, Ipp64f &dElapsedTime)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -