⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fileplayer.c

📁 Sample code for use on smp 863x processor.
💻 C
📖 第 1 页 / 共 5 页
字号:
		RMDBGLOG((JPEGDBG, "detect_jpeg_header_info Error reading file\n"));		return RM_ERROR;	}	if( header[0] != 0xff || header[1] != JPEG_MARKER_SOI ) {  // SOI has to be the first marker		RMDBGLOG((JPEGDBG, "detect_jpeg_header_info Error while parsing SOI chunk(%02x%02x)\n", header[0], header[1] ));		return RM_ERROR;	}		marker_count ++;	byte_count += 2;	more_marker = TRUE;	while( more_marker ) {				err = RMReadFile(file, header, 2, &read_size); // get 2 bytes		if(RMFAILED(err) || (read_size!= 2)){			RMDBGLOG((JPEGDBG, "Error reading file \n"));			return RM_ERROR;		}		byte_count += 2;		RMDBGLOG((JPEGDBG, " Got marker 0x%02x%02x \n", header[0], header[1]));		if( header[0] != 0xff ) {			RMDBGLOG((JPEGDBG, "Error marker %02x %02x\n", header[0], header[1]));			return RM_ERROR;		}				switch( header[1] ) {		case JPEG_MARKER_EOI:  // EOI is the last marker			more_marker = FALSE;  // end of the jpeg stream?			break;		case JPEG_MARKER_SOS:			more_marker = FALSE; // end of the jpeg header			break;		case JPEG_MARKER_SOF0:		case JPEG_MARKER_SOF1:		case JPEG_MARKER_SOF2:		case JPEG_MARKER_SOF9:		case JPEG_MARKER_SOF10:			RMDBGLOG((JPEGDBG, "calling jpeg_header_get_sof\n"));			err = jpeg_header_get_sof( file, width, height, profile, &byte_count);			if(RMFAILED(err) ) {				RMDBGLOG((JPEGDBG, "jpeg_header_get_sof Error\n"));				return RM_ERROR;			}			RMDBGLOG((JPEGDBG, "jpeg_header_get_sof W %d H %d P %d \n", *width, *height, *profile));			more_marker = TRUE;			break;		case JPEG_MARKER_APP1:  // APP1			RMDBGLOG((JPEGDBG, "calling jpeg_header_get_app1\n"));			jpeg_header_get_app1( file, (RMuint32*)orientation, &byte_count );			if(RMFAILED(err) ) {				RMDBGLOG((JPEGDBG, "jpeg_header_get_app1 Error\n"));				return RM_ERROR;			}			RMDBGLOG((JPEGDBG, "jpeg_header_get_app1 %d \n", *orientation));			more_marker = TRUE;			break;		case JPEG_MARKER_RST0:		case JPEG_MARKER_RST1:		case JPEG_MARKER_RST2:		case JPEG_MARKER_RST3:		case JPEG_MARKER_RST4:		case JPEG_MARKER_RST5:		case JPEG_MARKER_RST6:		case JPEG_MARKER_RST7:		case JPEG_MARKER_TEM:			// no reading			more_marker = TRUE;			break;		default:  // skip a marker			err = jpeg_header_skip_marker( file, &byte_count );			if(RMFAILED(err) ) {				RMDBGLOG((JPEGDBG, "jpeg_header_skip_marker Error\n"));				return RM_ERROR;			}			more_marker = TRUE;		}		marker_count ++;		RMDBGLOG((JPEGDBG, "detect_jpeg_header_info unhandled marker %d bytes %d\n", marker_count, byte_count ));	}	return RM_OK;}static inline enum rfp_application get_app_from_stream_info(struct rfp_stream_info *stream_info){	switch(stream_info->system_type){	case RM_SYSTEM_MPEG4:		return APP_MP4;	case RM_SYSTEM_ASF:		return APP_ASF;	case RM_SYSTEM_ELEMENTARY_VIDEO:		switch(stream_info->video_type){		case RM_VIDEO_MPEG12:		case RM_VIDEO_MPEG4:		case RM_VIDEO_H263:		case RM_VIDEO_H264:		case RM_VIDEO_WMV:		case RM_VIDEO_VC1:		case RM_VIDEO_DIVX3:		case RM_VIDEO_DIVX4:		case RM_VIDEO_XVID:		case RM_VIDEO_MJPEG:			return APP_VIDEO;		case RM_VIDEO_BMP:		case RM_VIDEO_TIFF:		case RM_VIDEO_GIF:		case RM_VIDEO_PNG:		case RM_VIDEO_JPEG:			return APP_PICTURE;		case RM_VIDEO_UNKNOWN:			return NOT_SUPPORTED;		}		break;	case RM_SYSTEM_ELEMENTARY_AUDIO:		return APP_AUDIO;	case RM_SYSTEM_MPEG2_TRANSPORT:	case RM_SYSTEM_MPEG2_TRANSPORT_192:		return APP_DEMUX;	case RM_SYSTEM_MPEG1:	case RM_SYSTEM_MPEG2_PROGRAM:	case RM_SYSTEM_MPEG2_DVD:		return APP_DEMUX;	case RM_SYSTEM_AVI:		return APP_AVI;		/* the following are deprecated types (use RM_SYTEM_AVI instead) */	case RM_SYSTEM_MPEG2_DVD_AUDIO:	case RM_SYSTEM_DIVX_MP3:	case RM_SYSTEM_DIVX_AC3:	case RM_SYSTEM_DIVX_MPEG1:	case RM_SYSTEM_DIVX_PCM:	case RM_SYSTEM_DIVX_WMA:	case RM_SYSTEM_DIVX_WMV9_MP3:	case RM_SYSTEM_DIVX_WMV9_AC3:	case RM_SYSTEM_DIVX_WMV9_MPEG1:	case RM_SYSTEM_DIVX_WMV9_PCM:	case RM_SYSTEM_DIVX3_MP3:	case RM_SYSTEM_DIVX3_AC3:	case RM_SYSTEM_DIVX3_MPEG1:	case RM_SYSTEM_DIVX3_PCM:	case RM_SYSTEM_RIFFCDXA:	case RM_SYSTEM_ID3:	case RM_SYSTEM_UNKNOWN:		break;	}	return NOT_SUPPORTED;}static inline RMbool AudioFormatToCodec(eAudioFormat_type audio_format, struct audio_cmdline *audio_opt){	switch(audio_format){	case eAudioFormat_MPEG1_LAYER3:	case eAudioFormat_MPEG2_LAYER1:	case eAudioFormat_MPEG2_LAYER2:	case eAudioFormat_MPEG2_LAYER3:	case eAudioFormat_MPEG2:	case eAudioFormat_MPEG1:		RMDBGLOG((LOCALDBG, "audio type is mpeg1\n"));		fprintf(stderr, "audio type is mpeg1\n");		audio_opt->Codec = AudioDecoder_Codec_MPEG1;		break;	case eAudioFormat_AC3:		RMDBGLOG((LOCALDBG, "audio type is ac3\n"));		fprintf(stderr, "audio type is ac3\n");		audio_opt->Codec = AudioDecoder_Codec_AC3;		break;	case eAudioFormat_PCM:		RMDBGLOG((LOCALDBG, "audio type is pcm\n"));		fprintf(stderr, "audio type is pcm\n");		audio_opt->Codec = AudioDecoder_Codec_PCM;		break;	case eAudioFormat_DTS:		RMDBGLOG((LOCALDBG, "audio type is dts\n"));		fprintf(stderr, "audio type is dts\n");		audio_opt->Codec = AudioDecoder_Codec_DTS;		break;	case eAudioFormat_DVD_AUDIO:		RMDBGLOG((LOCALDBG, "audio type is dvda\n"));		fprintf(stderr, "audio type is dvda\n");		audio_opt->Codec = AudioDecoder_Codec_DVDA;		break;	case eAudioFormat_AAC_ADTS:		RMDBGLOG((LOCALDBG, "audio type is aac_adts\n"));		fprintf(stderr, "audio type is aac_adts\n");		audio_opt->Codec = AudioDecoder_Codec_AAC;		audio_opt->AACParams.InputFormat = 1;	// adts, sync word		break;	case eAudioFormat_AAC_ADIF:		RMDBGLOG((LOCALDBG, "audio type is aac_adif\n"));		fprintf(stderr, "audio type is aac_adif\n");		audio_opt->Codec = AudioDecoder_Codec_AAC;		audio_opt->AACParams.InputFormat = 0;	// adif, no sync word		break;	case eAudioFormat_AAC_LATM:		RMDBGLOG((LOCALDBG, "audio type is aac_latm\n"));		fprintf(stderr, "audio type is aac_latm\n");		audio_opt->Codec = AudioDecoder_Codec_AAC;		audio_opt->AACParams.InputFormat = 3;	// latm		break;	case eAudioFormat_WMA:		RMDBGLOG((LOCALDBG, "audio type is wma\n"));		fprintf(stderr, "audio type is wma\n");		audio_opt->Codec = AudioDecoder_Codec_WMA;		break;	default:		RMDBGLOG((LOCALDBG, "Can't translate eAudioFormat_type %ld\n", audio_format));		fprintf(stderr, "audio type is unknown\n");		return FALSE;	}	return TRUE;}static inline RMbool VideoFormatToCodec(RMvideoType video_type, struct video_cmdline *video_opt, struct rfp_detect_options *detect_opt){	switch(video_type){	case RM_VIDEO_MPEG12:		if(!detect_opt->force_sd){			RMDBGLOG((LOCALDBG, "video type is mpeg2 HD video\n" ));			fprintf(stderr, "video type is mpeg2 HD\n");			video_opt->MPEGProfile = Profile_MPEG2_HD;			video_opt->Codec = VideoDecoder_Codec_MPEG2_HD;		}		else{			RMDBGLOG((LOCALDBG, "video type is mpeg2 SD video\n" ));			fprintf(stderr, "video type is mpeg2 SD\n");			video_opt->MPEGProfile = Profile_MPEG2_HD;			video_opt->Codec = VideoDecoder_Codec_MPEG2_HD;		}		break;	case RM_VIDEO_MPEG4:		if(!detect_opt->force_sd){			RMDBGLOG((LOCALDBG, "video type is mpeg4 HD video\n" ));			fprintf(stderr, "video type is mpeg4 HD\n");			video_opt->MPEGProfile = Profile_MPEG4_HD;			video_opt->Codec = VideoDecoder_Codec_MPEG4_HD;		}		else{			RMDBGLOG((LOCALDBG, "video type is mpeg4 SD video\n" ));			fprintf(stderr, "video type is mpeg4 SD\n");			video_opt->MPEGProfile = Profile_MPEG4_SD;			video_opt->Codec = VideoDecoder_Codec_MPEG4_SD;		}		break;	case RM_VIDEO_H263:		RMDBGLOG((LOCALDBG, "video type is h263 video, set codec to mpeg4\n" ));		fprintf(stderr, "video type is mpeg4\n");		video_opt->MPEGProfile = Profile_MPEG4_HD;		video_opt->Codec = VideoDecoder_Codec_MPEG4_HD;		break;	case RM_VIDEO_WMV:		if(!detect_opt->force_sd){			RMDBGLOG((LOCALDBG, "video type is WMV HD video\n" ));			fprintf(stderr, "video type is WMV HD\n");			video_opt->MPEGProfile = Profile_WMV_HD;			video_opt->Codec = VideoDecoder_Codec_WMV_HD;		}		else{			RMDBGLOG((LOCALDBG, "video type is WMV SD video\n" ));			fprintf(stderr, "video type is WMV SD\n");			video_opt->MPEGProfile = Profile_WMV_816P;			video_opt->Codec = VideoDecoder_Codec_WMV_816P;		}		break;	case RM_VIDEO_VC1:		if(!detect_opt->force_sd){			RMDBGLOG((LOCALDBG, "video type is vc1 HD video\n" ));			fprintf(stderr, "video type is vc1 HD\n");			video_opt->MPEGProfile = Profile_VC1_HD;			video_opt->Codec = VideoDecoder_Codec_VC1_HD;		}		else{			RMDBGLOG((LOCALDBG, "video type is vc1 SD video\n" ));			fprintf(stderr, "video type is vc1 SD\n");			video_opt->MPEGProfile = Profile_VC1_SD;			video_opt->Codec = VideoDecoder_Codec_VC1_SD;		}		break;	case RM_VIDEO_DIVX3:		if(!detect_opt->force_sd){			RMDBGLOG((LOCALDBG, "video type is divx3 HD video\n" ));			fprintf(stderr, "video type is divx3 HD\n");			video_opt->MPEGProfile = Profile_DIVX3_HD;			video_opt->Codec = VideoDecoder_Codec_DIVX3_HD;		}		else {			RMDBGLOG((LOCALDBG, "video type is divx3 SD video\n" ));			video_opt->MPEGProfile = Profile_DIVX3_SD;			video_opt->Codec = VideoDecoder_Codec_DIVX3_SD;		}		break;	case RM_VIDEO_XVID:		if(!detect_opt->force_sd){			RMDBGLOG((LOCALDBG, "video type is xvid HD video\n" ));			fprintf(stderr, "video type is xvid HD\n");			video_opt->MPEGProfile = Profile_MPEG4_HD_Padding;			video_opt->Codec = VideoDecoder_Codec_MPEG4_HD_Padding;		}		else{			RMDBGLOG((LOCALDBG, "video type is xvid SD video\n" ));			video_opt->MPEGProfile = Profile_MPEG4_SD_Padding;			video_opt->Codec = VideoDecoder_Codec_MPEG4_SD_Padding;		}		break;	case RM_VIDEO_H264:		if(!detect_opt->force_sd){			RMDBGLOG((LOCALDBG, "video type is h264 HD video\n" ));			fprintf(stderr, "video type is h264 HD\n");			video_opt->MPEGProfile = Profile_H264_HD;			video_opt->Codec = VideoDecoder_Codec_H264_HD;		}		else{			RMDBGLOG((LOCALDBG, "video type is h264 SD video\n" ));			video_opt->MPEGProfile = Profile_H264_SD;			video_opt->Codec = VideoDecoder_Codec_H264_SD;		}		break;	case RM_VIDEO_JPEG:		video_opt->vcodec = EMhwlibJPEGCodec;		break;	case RM_VIDEO_DIVX4:		RMDBGLOG((ENABLE, "video type is divx4 video\n" ));		RMDBGLOG((ENABLE, "NOT SUPPORTED YET\n" ));		return FALSE;	case RM_VIDEO_MJPEG:	case RM_VIDEO_BMP:	case RM_VIDEO_TIFF:	case RM_VIDEO_GIF:	case RM_VIDEO_PNG:	case RM_VIDEO_UNKNOWN:		RMDBGLOG((ENABLE, "video type is not recognized\n" ));		return FALSE;	}	return TRUE;}static void DetectionPESCallback(RMuint8 *buffer, RMuint32 length, RMuint64 PTS, RMbool isPtsValid,				RMvdemuxDataType dataType, RMuint64 PESOffset, void *detect_info){	struct detection_callback_info *dinfo = (struct detection_callback_info*) detect_info;	if((dataType == RMVDEMUX_AUDIO) && (! dinfo->audio_detected)) {		dinfo->parsedBytes += length;		RMFDetectAudio(dinfo->detector, buffer, length, &(dinfo->audio_type),			       &(dinfo->audio_freq), &(dinfo->audio_channels), &(dinfo->audio_bitrate), 			       &(dinfo->audio_detected));				if (dinfo->parsedBytes < AUDIO_DETECTION_THRESHOLD) {			if ((dinfo->audio_type == eAudioFormat_AAC) && dinfo->audio_detected) {				RMDBGLOG((ENABLE, "clearing AAC false positive (byteCount %lu)\n", dinfo->parsedBytes));				dinfo->audio_detected = FALSE;			}		}		if(dinfo->audio_detected)			RMDBGLOG((ENABLE, "Detected Audio Format type %ld\n", dinfo->audio_type));			}	if ((isPtsValid) && (PTS > dinfo->last_pts)){		dinfo->last_pts = PTS;		RMDBGLOG((ENABLE, "Last pts is %lld\n", dinfo->last_pts));	}	if ((isPtsValid) && (PTS < dinfo->first_pts)){		dinfo->first_pts = PTS;		RMDBGLOG((ENABLE, "First pts is %lld\n", dinfo->first_pts));	}}static void LPCMCallback(RMuint8 numberOfFrameHeaders, RMuint16 firstAccessUnitPointer, RMuint32 frequency,			 RMuint8 numberOfChannels, RMvdemuxQuantization quantizationWordLength, void *detect_info){	struct detection_callback_info *dinfo = (struct detection_callback_info*) detect_info;	dinfo->pcm_detected = TRUE;	dinfo->audio_freq = frequency;	dinfo->audio_depth = quantizationWordLength;	dinfo->audio_channels = numberOfChannels;	return;}// ASF Duration detection routinesstruct detect_asf_context {	ExternalRMASFDemux vASFDemux;	RMuint64 Duration;	RMuint64 headerObjectSize;	RMuint32 packetSize;};static void detect_asf_duration_file_properties_callback(void *context,							 unsigned long long File_Size,							 unsigned long long Creation_Date,							 unsigned long long Data_Packets_Count,							 unsigned long long Play_Duration,							 unsigned long long Send_Duration,							 unsigned long long Preroll,							 unsigned long Minimum_Data_Packet_Size,							 unsigned long Maximum_Data_Packet_Size,							 unsigned long Maximum_Bitrate,							 unsigned char Broadcast,							 unsigned char Seekable) {		RMuint64 duration;	RMuint64 hour, min, sec, milisec;	struct detect_asf_context *pSendContext = (struct detect_asf_context *) context;	RMDBGLOG((ENABLE, "    Send Duration = %llu ms\n", Send_Duration / 10000));	RMDBGLOG((ENABLE, "    Preroll = %llu ms\n", Preroll));	pSendContext->Duration = (Play_Duration / 10000) - Preroll;	RMDBGLOG((ENABLE, "    Play Duration = %llu ms\n", pSendContext->Duration));	RMDBGLOG((ENABLE, "    Maximum_Bitrate = %lu bits/s\n", Maximum_Bitrate));	RMDBGLOG((ENABLE, "    Minimum_Data_Packet_Size = %lu, Maximum_Data_Packet_Size = %lu\n",		  Minimum_Data_Packet_Size, Maximum_Data_Packet_Size));	duration = pSendContext->Duration;	hour = duration / (3600 * 1000);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -