📄 play_gt.c
字号:
a clean application could determine which is the decoder that will require the biggest amount of shared memory and allocate that before DCCXOpenVideoDecoderSource, but here we will just allocate 1MB to be safe and quick. */ mpeg_engine = EMHWLIB_MODULE(MpegEngine, video_profile.MpegEngineID); err = RUAGetProperty(dcc_info.pRUA, mpeg_engine, RMMpegEnginePropertyID_DecoderSharedMemory, &shared, sizeof(shared)); if (err != RM_OK) { RMDBGLOG((ENABLE, "Cannot get DecoderSharedMemory, %s\n", RMstatusToString(err))); return err; } if (shared.Address) { if (shared.Size < 1024*1024) { RMDBGLOG((ENABLE, "ERROR: video shared memory is already set with a smaller value than needed by DCCOpen %s\n", RMstatusToString(err))); return err; } } else { /* allocate and set the shared memory used by all decoders of the same engine */ shared.Size = 1024*1024; if (shared.Size) { shared.Address = RUAMalloc(dcc_info.pRUA, 0, RUA_DRAM_UNCACHED, shared.Size); if (!shared.Address) { RMDBGLOG((ENABLE, "ERROR: could not allocate shared 0x%08lX bytes in DRAM %lu!\n", shared.Address, 0L)); return RM_FATALOUTOFMEMORY; } while(RUASetProperty(dcc_info.pRUA, mpeg_engine, RMMpegEnginePropertyID_DecoderSharedMemory, &shared, sizeof(shared),0)==RM_PENDING); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot open video decoder %d\n", err)); return RM_FATALOUTOFMEMORY; } } } } err = DCCXOpenVideoDecoderSource(dcc_info.pDCC, &video_profile, &pVideoSource); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot open video decoder %d\n", err)); goto cleanup; } vcodec = video_profile.Codec; err = DCCXSetVideoDecoderSourceCodec(pVideoSource, vcodec); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot set video decoder codec %d\n", err)); goto cleanup; } err = DCCGetOSDSurfaceInfo(dcc_info.pDCC, pVideoSource, NULL, &video_surface, NULL); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot get canvas surface info %d\n", err)); return err; } } /* Initialize PictureTransform module */ { struct PictureTransform_DecoderMemory_in_type memory_in; struct PictureTransform_DecoderMemory_out_type memory_out; xform_decoder = PictureTransform; /* * * (1) Find out how much memory we need to allocate * */ memory_in.TransformType = EMhwlibPictureTransformType_Orientation; memory_in.PictureSize = 1080*1920*2; /* FIXME: call getpicturesize instead */ memory_in.PictureCount = 2; memory_in.InPlace = in_place; memory_in.InbandFIFOCount = 16; err = RUAExchangeProperty(dcc_info.pRUA, xform_decoder, RMPictureTransformPropertyID_DecoderMemory, &memory_in, sizeof(memory_in), &memory_out, sizeof(memory_out)); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Error getting property RMVideoDecoderPropertyID_DecoderMemory! %s\n", RMstatusToString(err))); return err; } /* * * (2) Allocate the memory * */ /* Allocate the decoder data memory. Can reside in protected area */ xform_profile.DecoderDataAddress = 0; xform_profile.DecoderDataSize = memory_out.DecoderDataSize; if (xform_profile.DecoderDataSize > 0) { xform_profile.DecoderDataAddress = RUAMalloc(dcc_info.pRUA, 0, RUA_DRAM_UNCACHED, xform_profile.DecoderDataSize); if (!xform_profile.DecoderDataAddress) { RMDBGLOG((ENABLE, "ERROR: could not allocate 0x%08lX bytes in Protected DRAM %lu!\n", xform_profile.DecoderDataSize)); return RM_FATALOUTOFMEMORY; } RMDBGLOG((ENABLE, "video DecoderDataAddress: 0x%08lX, size %ld kb\n", xform_profile.DecoderDataAddress, (xform_profile.DecoderDataSize+1023)/1204)); } /* Allocate the decoder interface memory. Must reside in unprotected area */ xform_profile.DecoderInterfaceAddress = 0; xform_profile.DecoderInterfaceSize = memory_out.DecoderInterfaceSize; if (xform_profile.DecoderInterfaceSize > 0) { xform_profile.DecoderInterfaceAddress = RUAMalloc(dcc_info.pRUA, 0, RUA_DRAM_UNCACHED, xform_profile.DecoderInterfaceSize); if (!xform_profile.DecoderInterfaceAddress) { RMDBGLOG((ENABLE, "ERROR: could not allocate %ld bytes in unprotected DRAM %lu!\n", xform_profile.DecoderInterfaceSize, 0L)); return RM_FATALOUTOFMEMORY; } RMDBGLOG((ENABLE, "video DecoderInterfaceAddress: 0x%08lX, size %ld kb\n", xform_profile.DecoderInterfaceAddress, (xform_profile.DecoderInterfaceSize + 1023)/1024)); } else RMDBGLOG((ENABLE, "DecoderInterfaceSize was 0\n")); /* * * (3) Open PictureTransform module * */ xform_profile.STCId = 0; xform_profile.InbandFIFOCount = memory_in.InbandFIFOCount; xform_profile.InPlace = memory_in.InPlace; xform_profile.TransformType = memory_in.TransformType; xform_profile.InputSurface = video_surface; while((err=RUASetProperty(dcc_info.pRUA, xform_decoder, RMPictureTransformPropertyID_Open, &xform_profile, sizeof(xform_profile),0)) == RM_PENDING); if (err != RM_OK) { RMDBGLOG((ENABLE, "Cannot get the video surface, %s\n", RMstatusToString(err))); return err; } /* * * (4) Obtain the output surface and connect it to the scaler * */ err = RUAGetProperty(dcc_info.pRUA, xform_decoder, RMGenericPropertyID_Surface, &output_surface, sizeof(output_surface)); if (err != RM_OK) { RMDBGLOG((ENABLE, "Cannot get the video surface, %s\n", RMstatusToString(err))); return err; } err = DCCGetScalerModuleID(dcc_info.pDCC, dcc_info.route, DCCSurface_Video, videoscaler_id, &(dcc_info.SurfaceID)); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot get surface to display video source %d\n", err)); goto cleanup; } while((err=RUASetProperty(dcc_info.pRUA, dcc_info.SurfaceID, RMGenericPropertyID_Surface, &output_surface, sizeof(output_surface), 0)) == RM_PENDING); if (err != RM_OK) { RMDBGLOG((ENABLE, "Cannot get the video surface, %s\n", RMstatusToString(err))); return err; } while(RUASetProperty(dcc_info.pRUA, dcc_info.SurfaceID, RMGenericPropertyID_Validate, NULL, 0, 0) == RM_PENDING); /* * * (5) Set the orientation. It can be changed "on-the-fly" if needed. * */ while((err=RUASetProperty(dcc_info.pRUA, xform_decoder, RMPictureTransformPropertyID_OrientationMode, &orientation, sizeof(orientation),0)) == RM_PENDING); if (err != RM_OK) { RMDBGLOG((ENABLE, "Cannot get the video surface, %s\n", RMstatusToString(err))); return err; } /* * * (6) Set the PictureTransform ucode in play mode (initilize first) * */ err = gt_send_video_command(dcc_info.pRUA, xform_decoder, VideoDecoder_Command_Uninit); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot send VideoDecoder_Command_Uninit, %s\n", RMstatusToString(err))); return err; } err = gt_send_video_command(dcc_info.pRUA, xform_decoder, VideoDecoder_Command_Init); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot send VideoDecoder_Command_Init, %s\n", RMstatusToString(err))); return err; } err = gt_send_video_command(dcc_info.pRUA, xform_decoder, VideoDecoder_Command_PlayFwd); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot send VideoDecoder_Command_Init, %s\n", RMstatusToString(err))); return err; } } err = DCCGetVideoDecoderSourceInfo(pVideoSource, &(dcc_info.video_decoder), &(dcc_info.spu_decoder), &(dcc_info.video_timer)); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Error getting video decoder source information %d\n", err)); goto cleanup; } dcc_info.pVideoSource = pVideoSource; dcc_info.seek_supported = FALSE; dcc_info.iframe_supported = FALSE; switch (context.video_opt->MPEGProfile) { case Profile_FIRST_: case Profile_LAST_: break; case Profile_MPEG2_SD: case Profile_MPEG2_DVD: case Profile_MPEG2_HD: case Profile_MPEG2_SD_Packed: case Profile_MPEG2_HD_Packed: case Profile_MPEG2_DVD_Packed: case Profile_MPEG2_SD_DeInt: case Profile_MPEG2_DVD_DeInt: case Profile_MPEG2_HD_DeInt: case Profile_MPEG2_SD_Packed_DeInt: case Profile_MPEG2_DVD_Packed_DeInt: case Profile_MPEG2_HD_Packed_DeInt: RMDBGLOG((ENABLE, "MPEG 2 video\n")); break; case Profile_DIVX3_SD: case Profile_DIVX3_HD: case Profile_DIVX3_SD_Packed: case Profile_DIVX3_HD_Packed: RMDBGLOG((ENABLE, "DIVX3 video\n")); break; case Profile_WMV_SD: case Profile_WMV_816P: case Profile_WMV_HD: RMDBGLOG((ENABLE, "WMV9 video\n")); break; case Profile_MPEG4_SD: case Profile_MPEG4_HD: case Profile_MPEG4_SD_Packed: case Profile_MPEG4_HD_Packed: case Profile_MPEG4_SD_DeInt: case Profile_MPEG4_HD_DeInt: case Profile_MPEG4_SD_Packed_DeInt: case Profile_MPEG4_HD_Packed_DeInt: case Profile_MPEG4_SD_Padding: case Profile_MPEG4_HD_Padding: case Profile_MPEG4_SD_DeInt_Padding: case Profile_MPEG4_HD_DeInt_Padding: RMDBGLOG((ENABLE, "MPEG4 video. Set video timescale\n")); if (!context.video_opt->vtimescale.enable) { context.video_opt->vtimescale.enable = TRUE; context.video_opt->vtimescale.time_resolution = 90000; } break; case Profile_VC1_SD: case Profile_VC1_HD: RMDBGLOG((ENABLE, "WMV9 video\n")); break; case Profile_H264_SD: case Profile_H264_HD: case Profile_H264_SD_DeInt: case Profile_H264_HD_DeInt: RMDBGLOG((ENABLE, "H264 video\n")); break;/* case Profile_XFORM: *//* RMDBGLOG((ENABLE, "XFORM\n")); */ break; } // apply the fixed vop rate if required err = apply_video_decoder_options(&dcc_info, context.video_opt); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Error applying video_decoder_options %d\n", err)); goto cleanup; }#ifndef WITH_MONO set_default_out_window(&(dcc_info.disp_info->out_window)); set_default_out_window(&(dcc_info.disp_info->osd_window[0])); set_default_out_window(&(dcc_info.disp_info->osd_window[1])); dcc_info.disp_info->active_window = &(dcc_info.disp_info->out_window); dcc_info.disp_info->video_enable = TRUE; err = apply_display_options(&dcc_info, context.disp_opt); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot set display options %d\n", err)); goto cleanup; } display_key_usage(KEYFLAGS);#endif /*WITH_MONO*/ /* dmapool must be created after the module open in case we do no copy transfers */ err = RUAOpenPool(dcc_info.pRUA, dcc_info.video_decoder, context.play_opt->dmapool_count, context.play_opt->dmapool_log2size, RUA_POOL_DIRECTION_SEND, &pDMA); if (RMFAILED(err)) { RMuint32 poolSize = context.play_opt->dmapool_count << context.play_opt->dmapool_log2size; fprintf(stderr, "Error cannot open dmapool %d\n\n" "requested %lu bytes of dmapool (%lu buffers of %lu bytes), make sure you\n" "loaded llad with the right parameters. For example:\n" "max_dmapool_memory_size >= %lu max_dmabuffer_log2_size >= %lu\n\n", err, poolSize, context.play_opt->dmapool_count, (RMuint32)(1 << context.play_opt->dmapool_log2size), poolSize, context.play_opt->dmapool_log2size); goto cleanup; } context.pDMA = pDMA; file = open_stream(context.play_opt->filename, RM_FILE_OPEN_READ, 0); if (file == NULL) { RMDBGLOG((ENABLE, "Cannot open file %s\n", context.play_opt->filename)); goto cleanup; } context.f_bitstream = file; RMSizeOfOpenFile(file, &context.fileSize);#if !(STORE_SEQ_HEADER_LOCALLY) RMDBGLOG((ENABLE, "file: %s, size %llu, duration %llu s \n", context.play_opt->filename, context.fileSize, context.play_opt->duration / 1000)); if (context.play_opt->duration) fprintf(stderr, "duration %llu secs\n", context.play_opt->duration / 1000); dcc_info.RM_PSM_commands = RM_PSM_ENABLE_PLAY; dcc_info.RM_PSM_commands |= RM_PSM_ENABLE_STOP; dcc_info.RM_PSM_commands |= RM_PSM_ENABLE_PAUSE; dcc_info.RM_PSM_commands |= RM_PSM_ENABLE_SPEED; dcc_info.RM_PSM_commands |= RM_PSM_ENABLE_FASTER; dcc_info.RM_PSM_commands |= RM_PSM_ENABLE_SLOWER; dcc_info.RM_PSM_commands |= RM_PSM_ENABLE_NEXTPIC; dcc_info.trick_supported = TRUE; if ((context.play_opt->duration > 1000) && (context.fileSize > 0)) { RMDBGLOG((ENABLE, "seek, ffwd and iframe modes enabled\n")); dcc_info.RM_PSM_commands |= RM_PSM_ENABLE_SEEK; dcc_info.RM_PSM_commands |= RM_PSM_ENABLE_IFWD; dcc_info.seek_supported = TRUE; dcc_info.iframe_supported = TRUE; }#endif //STORE_SEQ_HEADER_LOCALLY#if FORCE_IFRAME_FWD_COMMAND RMDBGLOG((ENABLE, "\n\n\nIFrame forward command forced to enabled. Use ']' key to enter IFrameFwd state\n\n")); dcc_info.RM_PSM_commands |= RM_PSM_ENABLE_IFWD;#endif /* initialize the external close caption source */ context.PSMcontext = &PSMContext; PSMContext.validPSMContexts = 1; PSMContext.currentActivePSMContext = 1; PSMContext.keyflags = KEYFLAGS; /* Send WMV9 parameters */ if (context.video_opt->vcodec == EMhwlibVideoCodec_WMV) { struct VideoDecoder_WMV9VSProp_type wmv9_prop; RMuint32 Image_Width, Image_Height; RMDBGLOG((ENABLE, "Setting WMV9 parameters...size is %lu x %lu\n", context.video_opt->vcodec_max_width, context.video_opt->vcodec_max_height)); Image_Width = context.video_opt->vcodec_max_width; Image_Height = context.video_opt->vcodec_max_height; wmv9_prop.Sequence = context.video_opt->wmv9_seq; wmv9_prop.Image_Width = Image_Width; wmv9_prop.Image_Height = Image_Height; wmv9_prop.MB_Width = (Image_Width + 15) / 16; wmv9_prop.MB_Height = (Image_Height + 15) / 16; err = RUASetProperty(dcc_info.pRUA, dcc_info.video_decoder, RMVideoDecoderPropertyID_WMV9VSProp, &wmv9_prop, sizeof(wmv9_prop), 0); }#if ENABLE_MONITOR context.monitor = TRUE;#endif#ifndef WITH_MONO RMTermInit(TRUE); // don't allow ctrl-C and the like ... RMSignalInit(NULL, NULL); // ... but catch other termination signals to call RMTermExit()#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -