📄 umc_transcoder_con.h
字号:
/*//////////////////////////////////////////////////////////////////////////////
//
// 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.
//
*/
#ifndef __UMC_TRANSCODER_H
#define __UMC_TRANSCODER_H
#include "umc_structures.h"
#include "vm_thread.h"
#include "vm_strings.h"
#include "umc_defs.h"
#include "umc_self_destruction_pointer.h"
#include "umc_data_reader.h"
#include "umc_data_writer.h"
#include "umc_splitter.h"
#include "umc_video_decoder.h"
#include "umc_video_encoder.h"
#include "umc_muxer.h"
#include "umc_audio_codec.h"
#include "umc_dual_thread_codec.h"
#include "umc_media_data_ex.h"
#include "umc_video_processing.h"
#include "codec_pipeline.h"
#include "umc_cyclic_buffer.h"
#include "umc_media_buffer.h"
#if ! defined (MAX_PATH)
#define MAX_PATH 1024
#endif
#if ! defined (NULL)
#define NULL 0
#endif
#define DEFAULT_FRAMERATE 24
#define BUF_NUMBER_OF_FRAMES 100
#define BUF_INPUT_SIZE 6144
#define ENCODED_AUDIO_BUFFER_SIZE 1048576
enum
{
DEFAULT_VIDEO_BITRATE = 5242880,
DEFAULT_AUDIO_BITRATE = 128000
};
enum
{
TIME_TO_SWITCH_THREAD = 0,
TIME_TO_SLEEP = 5,
};
Ipp32u VM_THREAD_CALLCONVENTION VideoTranscodingThreadRoutine(void *lpvParam);
Ipp32u VM_THREAD_CALLCONVENTION AudioDecodingThreadRoutine (void *lpvParam);
Ipp32u VM_THREAD_CALLCONVENTION AudioEncodingThreadRoutine (void *lpvParam);
struct TranscoderParams
{
vm_char* input_video_filename;
vm_char* input_audio_filename;
vm_char* par_filename;
vm_char* output_filename;
UMC::AudioStreamType audio_stream_type;
UMC::VideoStreamType video_stream_type;
UMC::SystemStreamType system_stream_type;
TranscoderParams()
{
input_video_filename = NULL;
input_audio_filename = NULL;
output_filename = NULL;
par_filename = NULL;
audio_stream_type = UMC::UNDEF_AUDIO;
video_stream_type = UMC::UNDEF_VIDEO;
system_stream_type = UMC::UNDEF_STREAM;
};
bool CheckParams()
{
if (!input_video_filename || !output_filename)
return false;
if (system_stream_type == UMC::UNDEF_STREAM)
return false;
if (video_stream_type == UMC::UNDEF_VIDEO && audio_stream_type == UMC::UNDEF_AUDIO)
return false;
if (system_stream_type == UMC::MP4_ATOM_STREAM &&
(video_stream_type != UMC::MPEG4_VIDEO && video_stream_type != UMC::H264_VIDEO))
return false;
if (audio_stream_type != UMC::UNDEF_AUDIO &&
(system_stream_type & UMC::MPEGx_PURE_VIDEO_STREAM ||
system_stream_type & UMC::H26x_PURE_VIDEO_STREAM ||
system_stream_type & UMC::VC1_PURE_VIDEO_STREAM ||
system_stream_type & UMC::AVS_PURE_VIDEO_STREAM))
audio_stream_type = UMC::UNDEF_AUDIO;
return true;
};
};
class Transcoder
{
public:
// Default constructor
Transcoder(void);
// Destructor
~Transcoder(void);
// initialize transcoder
UMC::Status Init(TranscoderParams transcoder_params);
// Close transcoder
UMC::Status Close();
//gets stream(s) info and returns it in video_info and audio_info
UMC::Status GetStreamInfo(UMC::VideoStreamInfo &video_info, UMC::AudioStreamInfo &audio_info);
// Start transcoding
UMC::Status Run(void);
// Get current position of transcoding
double GetProgress(void);
// Reset media stream(s) to original state
UMC::Status Reset(void);
// Get current performance
void GetPerformance(Ipp32u &lEncodedFrames, Ipp64f &dElapsedTime);
// return transcoding status
UMC::Status GetErrorStatus() { return (error_status ? UMC::UMC_ERR_FAILED : UMC::UMC_OK); };
// Working procedure for video transcoding thread
Ipp32u VideoTranscoding();
// Working procedure for video audio decoding thread
Ipp32u AudioDecoding();
// Working procedure for video audio encoding thread
Ipp32u AudioEncoding();
private:
TranscoderParams m_TranscoderParams; //information about destination video, audio and system types
// Release video chain of transcoder
void ReleaseVideo(void);
// Release audio chain of transcoder
void ReleaseAudio(void);
// Set video encoder parameters
UMC::Status SetVideoEncoderParams();
// Create and initialize video encoder
UMC::Status CreateVideoEncoder(void);
// Set audio encoder parameters
UMC::Status SetAudioEncoderParams();
// Create and initialize audio encoder
UMC::Status CreateAudioEncoder(void);
// Set muxer parameters
UMC::Status SetMuxerParams();
// Create and initialize muxer
UMC::Status CreateMuxer();
//gets stream(s) info
UMC::Status GetStreamInfo();
bool m_bExit; // (bool) flag to exit
UMC::DataReader *m_lpDataReaderVideo; // (UMC::DataReader *) pointer to video data reader
UMC::Splitter *m_lpVideoSplitter; // (UMC::Splitter *) pointer to video splitter
UMC::VideoStreamInfo m_video_info; // (UMC::VideoStreamInfo) video stream information
UMC::DataReader *m_lpDataReaderAudio; // (UMC::DataReader *) pointer to audio data reader
UMC::Splitter *m_lpAudioSplitter; // (UMC::Splitter *) pointer to audio splitter
UMC::AudioStreamInfo m_audio_info; // (UMC::AudioStreamInfo) audio stream information
UMC::MediaData *m_lpVideoDecSpecInfo; // (UMC::MediaData) Decoder Specific information
UMC::MediaData *m_lpAudioDecSpecInfo; // (UMC::MediaData) Decoder Specific information
UMC::VideoProcessing *m_lpVideoProcessing; // (UMC::VideoProcessing) pointer to video processing
UMC::VideoDecoder *m_lpVideoDecoder; // (UMC::VideoDecoder *) pointer to video decoder
UMC::BaseCodec *m_lpAudioDecoder; // (UMC::BaseCodec *) pointer to audio decoder
UMC::VideoEncoderParams *m_lpVideoEncoderParams; // (UMC::BaseCodecParams *) external pointer to video encoder params
UMC::VideoEncoder *m_lpVideoEncoder; // (UMC::VideoEncoder *) pointer to video encoder
UMC::AudioCodecParams *m_lpAudioEncoderParams; // (UMC::BaseCodecParams *) external pointer to audio encoder params
UMC::BaseCodec *m_lpAudioEncoder; // (UMC::BaseCodec *) pointer to audio encoder
UMC::MediaBuffer *m_lpPCMBuffer; // (UMC::MediaBuffer *) pointer to uncompressed audio buffer
UMC::DualThreadedCodec *m_lpDTAudioEncoder; // (UMC::DualThreadedCodec *) pointer to dual threaded audio encoder
UMC::MediaBuffer *m_lpMediaBuffer; // (UMC::MediaBuffer *) pointer to uncompressed audio buffer
UMC::DualThreadedCodec *m_lpDTAudioDecoder; // (UMC::DualThreadedCodec *) pointer to dual threaded audio encoder
UMC::DataWriter *m_lpDataWriter; // (UMC::DataWriter *) pointer to data writer
UMC::MuxerParams *m_lpMuxerParams; // (UMC::MuxerParams *) external pointer to muxer params
UMC::Muxer *m_lpMuxer; // (UMC::Muxer *) pointer to muxer
vm_thread m_hVideoTranscoding; // (vm_thread) handle to video decoding thread
vm_thread m_hAudioDecoding; // (vm_thread) handle to audio decoding thread
vm_thread m_hAudioEncoding; // (vm_thread) handle to audio encoding thread
long m_lEncodedFrames; // (long) counter of encoded frames
Ipp64f m_dElapsedTime; // (Ipp64f) time spended for transcoding
Ipp64f m_dAdditionalTime; // (Ipp64f) time spended for transcoding before pause
bool m_bInit;
bool error_status;
double time_counter1; // time in sec of counter1
double time_counter2; // time in sec of counter2
double time_counter3; // time in sec of counter3
double time_counter4; // time in sec of counter4
double time_counter5; // time in sec of counter5
Ipp32s audio_track_num, video_track_num;
Ipp32u number_of_audio_tracks, number_of_video_tracks;
};
#endif //__UMC_TRANSCODER_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -