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

📄 fileplayer.c

📁 Sample code for use on smp 863x processor.
💻 C
📖 第 1 页 / 共 5 页
字号:
					bitrate = specificInfo.data.mpegAudio.bitrate;				else					bitrate = 0;				frequency = specificInfo.data.mpegAudio.sampleRate;				channel_count = specificInfo.data.mpegAudio.channels;				break;			case eAudioFormat_AAC_ADTS:				RMDBGLOG((ENABLE, "AAC ADTS\n"));								bitrate = 0;				frequency = specificInfo.data.adts.sampleRate;				channel_count = specificInfo.data.adts.channels;						break;			case eAudioFormat_AAC_ADIF:				RMDBGLOG((ENABLE, "AAC ADIF\n"));								if (!specificInfo.data.adif.isVBR)					bitrate = specificInfo.data.adif.bitrate;				else					bitrate = 0;				frequency = specificInfo.data.adif.sampleRate;				channel_count = specificInfo.data.adif.channels;				break;							case eAudioFormat_UNKNOWN:				RMDBGLOG((ENABLE, "the specific info request seems to be invalid\n"));				break;			default:				RMDBGLOG((ENABLE, "unrecognised specific info!\n"));				break;			}			RMDBGLOG((ENABLE, "sampleRate %lu, bitrate %lu, channels %lu\n", frequency, bitrate, channel_count));			stream_info->audio_type = detectedAudioType;		}				if (bitrate) {			play_opt->duration = (8000*file_size)/bitrate;			RMDBGLOG((LOCALDBG, "estimated duration is %lld (bitrate %lu)\n", play_opt->duration, bitrate));		}		else			RMDBGLOG((ENABLE, "Could not estimate duration\n"));		AudioFormatToCodec(stream_info->audio_type, audio_opt);				audio_opt->SamplingFrequency = 0;  // default: same as SampleRate		if (audio_opt->dh_info && audio_opt->dh_info->pDH) {  // HDMI is active, up/downsample to basic HDMI audio frequencies			if (audio_opt->Codec == AudioDecoder_Codec_PCM) {				RMDBGLOG((LOCALDBG, "Setting PCM audio sampling rate to %ld\n", frequency));				audio_opt->SamplingFrequency = frequency;  // maintain source sample rate for uncompressed audio			}			switch (frequency) {			case 8000: 			case 12000: 			case 16000: 			case 32000: 			case 64000: 			case 128000: 				audio_opt->SampleRate = 32000;				break;			case 11025: 			case 22050: 			case 44100: 			case 88200: 			case 176400: 				audio_opt->SampleRate = 44100;				break;			case 24000: 			case 48000: 			case 96000: 			case 192000: 			default:				audio_opt->SampleRate = 48000;				break;			}		} else {			audio_opt->SampleRate = frequency;		}		audio_opt->ForceSampleRate = TRUE;		RMDBGLOG((LOCALDBG, "Setting audio sample rate to %ld\n", audio_opt->SampleRate));		stream_info->system_type = RM_SYSTEM_ELEMENTARY_AUDIO;		break;	case DETECTOR_VIDEO_MPEG1:	case DETECTOR_VIDEO_MPEG2:		fprintf(stderr, "video\n");		RMFDetectVideo(detector, NULL, 0, &stream_info->video_type, &bitrate, &detected);		VideoFormatToCodec(stream_info->video_type, video_opt, detect_opt);		stream_info->system_type = RM_SYSTEM_ELEMENTARY_VIDEO;		break;	case DETECTOR_VIDEO_MPEG4:		fprintf(stderr, "video\n");		VideoFormatToCodec(RM_VIDEO_MPEG4, video_opt, detect_opt);		stream_info->video_type = RM_VIDEO_MPEG4;		stream_info->system_type = RM_SYSTEM_ELEMENTARY_VIDEO;		break;	case DETECTOR_VIDEO_H263:		fprintf(stderr, "video\n");		VideoFormatToCodec(RM_VIDEO_H263, video_opt, detect_opt);		stream_info->video_type = RM_VIDEO_H263;		stream_info->system_type = RM_SYSTEM_ELEMENTARY_VIDEO;		break;	case DETECTOR_VIDEO_H264:		fprintf(stderr, "video\n");		VideoFormatToCodec(RM_VIDEO_H264, video_opt, detect_opt);		stream_info->video_type = RM_VIDEO_H264;		stream_info->system_type = RM_SYSTEM_ELEMENTARY_VIDEO;		break;	case DETECTOR_VIDEO_VC1:		fprintf(stderr, "video\n");		VideoFormatToCodec(RM_VIDEO_VC1, video_opt, detect_opt);		stream_info->video_type = RM_VIDEO_VC1;		stream_info->system_type = RM_SYSTEM_ELEMENTARY_VIDEO;		break;	case DETECTOR_SYSTEM_M1S:		fprintf(stderr, "m1s\n");		RMDBGLOG((LOCALDBG, "DETECTOR_SYSTEM_M1S (%ld)\n", type));		demux_opt->system_type = RM_SYSTEM_MPEG1;		demux_opt->repack_sample = FALSE;		stream_info->system_type = RM_SYSTEM_MPEG1;		break;	case DETECTOR_SYSTEM_M2P:		fprintf(stderr, "m2p\n");		RMDBGLOG((LOCALDBG, "DETECTOR_SYSTEM_M2P (%ld)\n", type));		demux_opt->system_type = RM_SYSTEM_MPEG2_PROGRAM;		demux_opt->repack_sample = FALSE;		stream_info->system_type = RM_SYSTEM_MPEG2_PROGRAM;		break;	case DETECTOR_SYSTEM_M2T_192:		fprintf(stderr, "m2t_192\n");		RMDBGLOG((LOCALDBG, "DETECTOR_SYSTEM_M2T_192 (%ld)\n", type));		demux_opt->system_type = RM_SYSTEM_MPEG2_TRANSPORT_192;		demux_opt->repack_sample = TRUE;		stream_info->system_type = RM_SYSTEM_MPEG2_TRANSPORT_192;		break;	case DETECTOR_SYSTEM_M2T:		fprintf(stderr, "m2t\n");		RMDBGLOG((LOCALDBG, "DETECTOR_SYSTEM_M2T (%ld)\n", type));		demux_opt->system_type = RM_SYSTEM_MPEG2_TRANSPORT;		demux_opt->repack_sample = TRUE;		stream_info->system_type = RM_SYSTEM_MPEG2_TRANSPORT;		break;	case DETECTOR_SYSTEM_M4T:		fprintf(stderr, "m4t\n");		RMDBGLOG((LOCALDBG, "DETECTOR_SYSTEM_M4T (%ld)\n", type));		demux_opt->system_type = RM_SYSTEM_MPEG2_TRANSPORT;		demux_opt->repack_sample = TRUE;		stream_info->system_type = RM_SYSTEM_MPEG2_TRANSPORT;		break;	case DETECTOR_SYSTEM_M4P:		fprintf(stderr, "m4p\n");		RMDBGLOG((LOCALDBG, "DETECTOR_SYSTEM_M4P (%ld)\n", type));		demux_opt->system_type = RM_SYSTEM_MPEG2_PROGRAM;		stream_info->system_type = RM_SYSTEM_MPEG2_PROGRAM;		demux_opt->repack_sample = FALSE;		break;	case DETECTOR_SYSTEM_VOB:		fprintf(stderr, "vob\n");		RMDBGLOG((LOCALDBG, "DETECTOR_SYSTEM_VOB (%ld)\n", type));		demux_opt->system_type = RM_SYSTEM_MPEG2_DVD;		demux_opt->repack_sample = FALSE;		stream_info->system_type = RM_SYSTEM_MPEG2_DVD;		break;	case DETECTOR_SYSTEM_AVI:		fprintf(stderr, "avi\n");				/* create a avi demux, demux video and find user data */		{			struct parse_avi_context context = {0,};			/* #### Begin DTCP code #### */			if (!app_params->dtcpCookieHandle)			/* #### End DTCP code #### */				parse_avi(file, &context);						/* #### Begin DTCP code #### */			else {				RMfile dtcp_file;							/* Open the stream with caching if it is DTCP, because we seek a lot during parsing */				app_params->stream_opts.http_flags |=  RM_HTTP_OPEN_CACHED;				dtcp_file = open_stream(play_opt->filename, RM_FILE_OPEN_READ, &app_params->stream_opts);				if (dtcp_file == NULL) {					RMDBGLOG((ENABLE, "Cannot open file %s\n", play_opt->filename));					break;				}				parse_avi(dtcp_file, &context);				RMCloseFile(dtcp_file);							}			/* #### End DTCP code #### */				if (context.packed) {				RMDBGLOG((ENABLE, "PACKED!!     version %lu, build %lu\n", context.version, context.build));				video_opt->skipNCP = TRUE;			}			else {				RMDBGLOG((ENABLE, "NOT PACKED!! version %lu, build %lu\n", context.version, context.build));				video_opt->skipNCP = FALSE;			}		}		{			struct RM_Detection_Specific_Info specificInfo;			err = RMFGetSystemSpecificInfo(detector, RM_SYSTEM_AVI, &specificInfo);			if (err != RM_OK) {				RMDBGLOG((ENABLE, "error getting specific information!\n"));				ERROR_CLEANUP(-1);			}			stream_info->video_type = specificInfo.data.avi.videoType;			if ((stream_info->video_type == RM_VIDEO_H264) ||			    (stream_info->video_type == RM_VIDEO_MPEG4) ||			    (stream_info->video_type == RM_VIDEO_XVID) ||			    (stream_info->video_type == RM_VIDEO_VC1)) {				RMDBGLOG((ENABLE, "dont send mpeg4/h264/vc1 pts\n"));				play_opt->dontSendMPEG4pts = TRUE;			}			if(VideoFormatToCodec(stream_info->video_type, video_opt, detect_opt)){				RMDBGLOG((LOCALDBG, "DETECTOR_SYSTEM_AVI (%ld)\n", type));				stream_info->system_type = RM_SYSTEM_AVI;			}			else{				RMDBGLOG((ENABLE, "Found SYSTEM_AVI, but the video codec is unsupported\n"));			}			break;		}		break;	case DETECTOR_SYSTEM_ASF: /* -9 */		fprintf(stderr, "asf\n");		RMDBGLOG((LOCALDBG, "DETECTOR_SYSTEM_ASF (%ld)\n", type));		stream_info->system_type = RM_SYSTEM_ASF;		break;	case DETECTOR_PICTURE_JPEG:		fprintf(stderr, "jpg\n");		app_params->osd_scaler = 2;		RMDBGLOG((LOCALDBG, "Picture (%ld)\n", type));		stream_info->system_type = RM_SYSTEM_ELEMENTARY_VIDEO;		stream_info->video_type = RM_VIDEO_JPEG;		VideoFormatToCodec(stream_info->video_type, video_opt, detect_opt);		{			RMuint32 width = 0;			RMuint32 height = 0;			enum PictureOrientation orientation = 0;			RMuint32 profile = EMhwlib_JPEG_Invalid_Profile;			err = detect_jpeg_header_info(file, &width, &height, &profile, &orientation);			if(RMFAILED(err)){ 				RMDBGLOG((ENABLE, "Picture detect_jpeg_header_info failed, use default jpeg parameters\n"));			}			// if not changed by the detect functions, give them some default value			if( profile == EMhwlib_JPEG_Invalid_Profile ) {				RMDBGLOG((ENABLE, "Invalid jpeg profile 0x%lx\n", profile ));			}			video_opt->vcodec_profile = profile;			if( profile == EMhwlib_JPEG_444_Profile ) {				video_opt->vcodec_profile = EMhwlib_JPEG_Invalid_Profile;				RMDBGLOG((ENABLE, "Not supporting jpeg 444 profile, set to invalid 0x%lx\n", video_opt->vcodec_profile ));			}			if( orientation == 0 )				video_opt->vcodec_orientation = 1; //no rotation			else				video_opt->vcodec_orientation = (RMuint32)orientation;			if( height == 0 )				video_opt->vcodec_max_height = 2448;			else				video_opt->vcodec_max_height = height;  // use the dimension stored in jpeg header			if( width == 0 )				video_opt->vcodec_max_width = 3264;			else				video_opt->vcodec_max_width = width;			video_opt->vcodec_extra_pictures = -2;  // not to allocate the extra picture buffer for jpeg			RMDBGLOG((LOCALDBG, "Picture W %d H %d Profile %d Orientation %d\n", video_opt->vcodec_max_width, video_opt->vcodec_max_height, video_opt->vcodec_profile, video_opt->vcodec_orientation ));		}		break;	case DETECTOR_PICTURE_BMP:		fprintf(stderr, "bmp\n");		stream_info->system_type = RM_SYSTEM_ELEMENTARY_VIDEO;		app_params->osd_scaler = 0;		RMDBGLOG((LOCALDBG, "Picture (%ld)\n", type));		stream_info->video_type = RM_VIDEO_BMP;		break;	case DETECTOR_PICTURE_TIFF:		fprintf(stderr, "tiff\n");		stream_info->video_type = RM_VIDEO_TIFF;		stream_info->system_type = RM_SYSTEM_ELEMENTARY_VIDEO;		app_params->osd_scaler = 0;		RMDBGLOG((LOCALDBG, "Picture (%ld)\n", type));		break;	case DETECTOR_PICTURE_GIF:		fprintf(stderr, "gif\n");		stream_info->video_type = RM_VIDEO_GIF;		stream_info->system_type = RM_SYSTEM_ELEMENTARY_VIDEO;		app_params->osd_scaler = 0;		RMDBGLOG((LOCALDBG, "Picture (%ld)\n", type));		break;	case DETECTOR_PICTURE_PNG:		fprintf(stderr, "png\n");		stream_info->video_type = RM_VIDEO_PNG;		stream_info->system_type = RM_SYSTEM_ELEMENTARY_VIDEO;		app_params->osd_scaler = 0;		RMDBGLOG((LOCALDBG, "Picture (%ld)\n", type));		break;	case DETECTOR_SYSTEM_MP4:		fprintf(stderr, "mp4\n");		RMDBGLOG((LOCALDBG, "DETECTOR_SYSTEM_MP4 (%ld)\n", type));		stream_info->system_type = RM_SYSTEM_MPEG4;		break;	case DETECTOR_SYSTEM_RIFFCDXA:		fprintf(stderr, "riff/cdxa, format not supported\n");		break; 	case DETECTOR_TYPE_UNKNOWN:	default:		fprintf(stderr, "unknown type!\n");		RMDBGLOG((LOCALDBG, "unknown type!\n"));		break;	}		if((stream_info->system_type == RM_SYSTEM_MPEG1) ||	   (stream_info->system_type == RM_SYSTEM_MPEG2_PROGRAM) ||	   (stream_info->system_type == RM_SYSTEM_MPEG2_TRANSPORT_192) ||	   (stream_info->system_type == RM_SYSTEM_MPEG2_TRANSPORT) ||	   (stream_info->system_type == RM_SYSTEM_MPEG2_PROGRAM) ||	   (stream_info->system_type == RM_SYSTEM_MPEG2_DVD)){		RMint32 index;		RMuint32 i, numStreams, count, streamType;		RMuint16 pid;		RMuint8 buf[512], subId;		RMbool got_audio = FALSE, got_video = FALSE;		ExternalRMvdemux demux;		struct detection_callback_info detection_info = { 0, };		/* takes only the first audio and the first video */		demux_opt->video_pid = 0;		demux_opt->audio_pid = 0;		demux_opt->audio_subid = 0;		demux_opt->spu_subid = 0;		demux_opt->data_type = 0;		demux_opt->xfer_count = 0; /* let the application set this */		demux_opt->fifo_size = 0;  /* let the application set this */				if (demux_opt->system_type != RM_SYSTEM_UNKNOWN) {			err = RMCreateVdemux(&demux);			if (RMFAILED(err)) {				RMDBGLOG((ENABLE, "Cannot create demux %d\n", err));				ERROR_CLEANUP(-1);			}			RMvdemuxSetType(demux, demux_opt->system_type);		}		RMvdemuxReset(demux);		RMvdemuxSetVideoStream(demux, 0, 0);		RMvdemuxSetAudioStream(demux, 0, 0);		RMvdemuxSetCallbackData(demux, DetectionPESCallback, &(detection_info));		RMvdemuxSetAudioCallbacks(demux, NULL, LPCMCallback, NULL, NULL);		detection_info.detector = detector;		detection_info.last_pts = 0;		detection_info.first_pts = (RMuint64)-1;		detection_info.audio_detected = FALSE;		detection_info.pcm_detected = FALSE;		RMFDetectorReset(detection_info.detector);		if (RMSeekFile(file, 0 , RM_FILE_SEEK_START) != RM_OK) {			RMDBGLOG((ENABLE, "Error seeking file\n"));			ERROR_CLEANUP(-1);		}		index = 0;		numStreams = 0;		/* parse at least 16*512 bytes to make sure we get a PMT */		/* todo: make this cleaner */		while (((!detection_info.audio_detected) || (index < 16) || (numStreams<2)) 			&& (index < 16384)) {			err = RMReadFile(file, buf, 512, &count);			if (RMFAILED(err)) {				RMDBGLOG((ENABLE, "Error reading file %s", RMstatusToString(err)));				break;			}			RMvdemuxDemux(demux, buf, count);			RMvdemuxGetNumberOfStreams(demux, &numStreams);			index++;		}		for(i = 0; i< numStreams; i++){			RMvdemuxGetStreamType(demux, i, &pid, &subId,  &streamType);			fprintf(stderr, "stream %lu/%lu (pid %3lu [0x%02lx] subId %3lu [0x%02lx] type %3lu [0x%02lx])\n", 				i, 				numStreams-1,				(RMuint32)pid,				(RMuint32)pid,				(RMuint32)subId,				(RMuint32)subId,				(RMuint32)streamType,				(RMuint32)streamType);			switch(streamType){			case STREAM_TYPE_PCM:			case STREAM_TYPE_AOB_PCM:				if((!got_audio) && detection_info.pcm_detected){					fprintf(stderr, "system audio pcm\n");					detection_info.audio_type = eAudioFormat_PCM;					demux_opt->audio_subid = 0x7 & subId;					audio_opt->SubCodec = 1;					audio_opt->SamplingFrequency = detection_info.audio_freq;					audio_opt->LpcmVobParams.ChannelAssign = LpcmVob2_LR;					audio_opt->LpcmVobParams.BitsPerSample = detection_info.audio_depth;					switch(detection_info.audio_channels){					case 1:						audio_opt->PcmCdaParams.ChannelAssign = LpcmVob1_C;

⌨️ 快捷键说明

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