다음에 인코딩 할 YUV 프레임을 생성하기 위해 cuda HW 디코더를 사용하는 custum 비디오 디코더를 구현하기 시작했습니다.Cuda ffmpeg의 비디오 디코더
"CUVIDPICPARAMS"struc을 어떻게 채울 수 있습니까? 가능합니까?
내 알고리즘은 다음과 같습니다
GET 비디오 스트림 패킷에 대한난 사용는 FFmpeg-DEV libs와 avcodec, avformat ...
내 단계 :
1) 열기 입력 파일 :
avformat_open_input(&ff_formatContext,in_filename,nullptr,nullptr);
2) 가져 오기 비디오 스트림 속성의 :
avformat_find_stream_info(ff_formatContext,nullptr);
위젯 515,
3) 비디오 스트림 :
ff_video_stream=ff_formatContext->streams[i];
4) CUDA 장치를 얻고 그것을 초기화하기 :
cuDeviceGet(&cu_device,0);
CUcontext cu_vid_ctx;
5) 초기화 비디오 CUDA 디코더 및 PARAMS를 생성 설정 :
CUVIDDECODECREATEINFO *cu_decoder_info=new CUVIDDECODECREATEINFO;
memset(cu_decoder_info,0,sizeof(CUVIDDECODECREATEINFO));
...
cuvidCreateDecoder(cu_video_decoder,cu_decoder_info);
6) AV 패킷으로의 프레임 데이터 읽기
av_read_frame(ff_formatContext,ff_packet);
,210
그리고 지금 나는 이론에, CUDA 비디오 디코더에 프레임 패킷을 디코딩이 필요합니다
cuvidDecodePicture(pDecoder,&picParams);
하지만 CUVIDPICPARAMS을 채울 필요하기 전에
CUVIDPICPARAMS picParams; // = 새로운 CUVIDPICPARAMS; memset (& picParams, 0, sizeof (CUVIDPICPARAMS));
HOW CAN I FILL "CUVIDPICPARAMS" struc ???
typedef struct _CUVIDPICPARAMS
{
int PicWidthInMbs; // Coded Frame Size
int FrameHeightInMbs; // Coded Frame Height
int CurrPicIdx; // Output index of the current picture
int field_pic_flag; // 0=frame picture, 1=field picture
int bottom_field_flag; // 0=top field, 1=bottom field (ignored if field_pic_flag=0)
int second_field; // Second field of a complementary field pair
// Bitstream data
unsigned int nBitstreamDataLen; // Number of bytes in bitstream data buffer
const unsigned char *pBitstreamData; // Ptr to bitstream data for this picture (slice-layer)
unsigned int nNumSlices; // Number of slices in this picture
const unsigned int *pSliceDataOffsets; // nNumSlices entries, contains offset of each slice within the bitstream data buffer
int ref_pic_flag; // This picture is a reference picture
int intra_pic_flag; // This picture is entirely intra coded
unsigned int Reserved[30]; // Reserved for future use
// Codec-specific data
union {
CUVIDMPEG2PICPARAMS mpeg2; // Also used for MPEG-1
CUVIDH264PICPARAMS h264;
CUVIDVC1PICPARAMS vc1;
CUVIDMPEG4PICPARAMS mpeg4;
CUVIDJPEGPICPARAMS jpeg;
unsigned int CodecReserved[1024];
} CodecSpecific;
} CUVIDPICPARAMS;
typedef struct _CUVIDH264PICPARAMS
{
// SPS
int log2_max_frame_num_minus4;
int pic_order_cnt_type;
int log2_max_pic_order_cnt_lsb_minus4;
int delta_pic_order_always_zero_flag;
int frame_mbs_only_flag;
int direct_8x8_inference_flag;
int num_ref_frames; // NOTE: shall meet level 4.1 restrictions
unsigned char residual_colour_transform_flag;
unsigned char bit_depth_luma_minus8; // Must be 0 (only 8-bit supported)
unsigned char bit_depth_chroma_minus8; // Must be 0 (only 8-bit supported)
unsigned char qpprime_y_zero_transform_bypass_flag;
// PPS
int entropy_coding_mode_flag;
int pic_order_present_flag;
int num_ref_idx_l0_active_minus1;
int num_ref_idx_l1_active_minus1;
int weighted_pred_flag;
int weighted_bipred_idc;
int pic_init_qp_minus26;
int deblocking_filter_control_present_flag;
int redundant_pic_cnt_present_flag;
int transform_8x8_mode_flag;
int MbaffFrameFlag;
int constrained_intra_pred_flag;
int chroma_qp_index_offset;
int second_chroma_qp_index_offset;
int ref_pic_flag;
int frame_num;
int CurrFieldOrderCnt[2];
// DPB
CUVIDH264DPBENTRY dpb[16]; // List of reference frames within the DPB
// Quantization Matrices (raster-order)
unsigned char WeightScale4x4[6][16];
unsigned char WeightScale8x8[2][64];
// FMO/ASO
unsigned char fmo_aso_enable;
unsigned char num_slice_groups_minus1;
unsigned char slice_group_map_type;
signed char pic_init_qs_minus26;
unsigned int slice_group_change_rate_minus1;
union
{
unsigned long long slice_group_map_addr;
const unsigned char *pMb2SliceGroupMap;
} fmo;
unsigned int Reserved[12];
// SVC/MVC
union
{
CUVIDH264MVCEXT mvcext;
CUVIDH264SVCEXT svcext;
};
} CUVIDH264PICPARAMS;
[CUDA nccuvid 및 ffmpeg로 비디오 디코딩] 가능한 복제본 (http://stackoverflow.com/questions/16203930/decode-video-with-cuda-nccuvid-and-ffmpeg) – talonmies
이미이 질문을했습니다. 다시 묻지 마십시오. – talonmies
NVIDIA 비디오 디코딩 [샘플] (http://docs.nvidia.com/cuda/cuda-samples/index.html#cuda-video-decoder-d3d9-api)을 보셨습니까? –