?? play_mosaic.c
字號:
/* * * Copyright (c) Sigma Designs, Inc. 2002. All rights reserved. * */#include "../samples/sample_os.h"#define ALLOW_OS_CODE 1#include "../dcc/include/dcc.h"#include "../rmlibcw/include/rmfile.h"#include "../samples/common.h"#include "../rmsoftmixer/include/rmsoftmixer.h"#include "../samples/command_ids.h"#define KEY_CMD_FULLSCREEN 'F'#undef RMFEATURE_HAS_VIDEOPLANE /* defined in rmfeatures.h but not yet implemented on this branch */#define COMMON_TIMEOUT_US 10000#define DMA_BUFFER_SIZE_LOG2 12#define DMA_BUFFER_COUNT 12#define VIDEO_FIFO_SIZE (1024*1024)#define XFER_FIFO_COUNT (32)#define KEYFLAGS (SET_KEY_DISPLAY | SET_KEY_PLAYBACK | SET_KEY_DEBUG)#define ALLOW_OS_CODE 1#define MAX_TASK_COUNT 20struct task_context { RMuint32 id; struct RUABufferPool *pDMA; RMuint8 *buf; RMbool buffer_used; RMfile file; RMuint32 byte_counter; RMstatus file_status; RMuint32 nTimes; RMbool sync_timer; struct emhwlib_info send_info; struct rmsmx_window smx_window; struct rmsmx_window smx_thumb_window; RMbool smx_eos_wait;};enum mosaic_layout_mode{ mosaic_portrait_layout, mosaic_landscape_layout, mosaic_square_layout};static struct RM_PSM_Context PSMcontext;RMuint32 task_count = 0;static struct task_context task_list[MAX_TASK_COUNT];static struct dcc_context dcc_info[MAX_TASK_COUNT] = { {0, }, {0, } };static struct dcc_context *pdcc_info[MAX_TASK_COUNT];static struct playback_cmdline *play_opt;static struct display_cmdline *disp_opt;static struct video_cmdline *video_opt;static struct playback_cmdline playback_options[MAX_TASK_COUNT]; /*access through play_opt*/static struct display_cmdline display_options[MAX_TASK_COUNT];/*access through disp_opt*/static struct video_cmdline video_options[MAX_TASK_COUNT]; /*access through video_opt*/static RMsmx smx;static enum mosaic_layout_mode layout_mode = mosaic_portrait_layout;#ifdef RMFEATURE_HAS_GRAPHACC_CSCONVstatic enum EMhwlibSamplingMode sampling_mode = EMhwlibSamplingMode_422;#elsestatic enum EMhwlibSamplingMode sampling_mode = EMhwlibSamplingMode_444;#endifstatic void show_usage(char *progname){ show_playback_options(); show_display_options(); show_video_options(); fprintf(stderr, "MOSAIC OPTIONS (default values inside brackets)\n" "\t-layout layout_mode: Selects the mosaic's layout mode \n" "\t\t[portrait] landscape square \n" "\t-sampling sampling_mode: Selects the mosaic's sampling mode \n" "\t\t[422] 444 \n" ); fprintf(stderr, "--------------------------------\n"); fprintf(stderr, "Minimum cmd line: %s <filename> \n", progname); fprintf(stderr, "--------------------------------\n"); exit(1);}static void parse_cmdline(int argc, char *argv[]){ int i; RMstatus err; if(task_count == 0) { play_opt = &playback_options[0]; disp_opt = &display_options[0]; video_opt = &video_options[0]; task_list[0].id = 0; } if (argc < 2) show_usage(argv[0]); i = 1; while ((argc > i)) { if (argv[i][0] != '-') { if (play_opt->filename == NULL) { play_opt->filename = argv[i]; i++; } else show_usage(argv[0]); } else if ( ! strcmp(argv[i], "-task")) { if (argc > i+1) { RMuint32 j = 0, task_index; task_index = strtol(argv[i+1], NULL, 10); i+=2; if (task_count > MAX_TASK_COUNT) show_usage(argv[0]); for (j=0; j < task_count; j++) { if( task_index != task_list[j].id) continue; } if ( (task_count==0) || (j >= task_count)) { fprintf(stderr, "initing %ld\n", task_count); play_opt = &playback_options[task_count]; disp_opt = &display_options[task_count]; video_opt = &video_options[task_count]; task_list[task_count].id = task_index; task_count++; } } else show_usage(argv[0]); }#ifdef RMFEATURE_HAS_GRAPHACC_CSCONV else if ( ! strcmp(argv[i], "-sampling")) { if (argc > i+1) { if ( ! strcmp(argv[i+1], "422")){ sampling_mode = EMhwlibSamplingMode_422; } else if ( ! strcmp(argv[i+1], "444")){ sampling_mode = EMhwlibSamplingMode_444; } else show_usage(argv[0]); } else show_usage(argv[0]); i += 2; }#endif else if ( ! strcmp(argv[i], "-layout")) { if (argc > i+1) { if ( ! strcmp(argv[i+1], "square")){ layout_mode = mosaic_square_layout; } else if ( ! strcmp(argv[i+1], "landscape")){ layout_mode = mosaic_landscape_layout; } else if ( ! strcmp(argv[i+1], "portrait")){ layout_mode = mosaic_portrait_layout; } else show_usage(argv[0]); } else show_usage(argv[0]); i += 2; } else { err = parse_playback_cmdline(argc, argv, &i, play_opt); if (err == RM_ERROR) show_usage(argv[0]); if (err != RM_PENDING) continue; err = parse_display_cmdline(argc, argv, &i, disp_opt); if (err == RM_ERROR) show_usage(argv[0]); if (err != RM_PENDING) continue; err = parse_video_cmdline(argc, argv, &i, video_opt); if (RMFAILED(err)) show_usage(argv[0]); } } if (play_opt->filename == NULL) show_usage(argv[0]); if(task_count == 0) { task_count = 1; }}int main(int argc, char *argv[]){ RMstatus err; struct DCC *pDCC = NULL; struct RUA *pRUA = NULL; /* each task can only wait on one event */ /* the event_list[MAX_TASK_COUNT] entry is for next_picture event */ struct RUAEvent event_list[MAX_TASK_COUNT+1]; struct dh_context dh_info[MAX_TASK_COUNT] = {{0,},}; RMuint32 i, n = 0, m = 0; static struct RM_PSM_Actions actions; struct EMhwlibTVFormatAnalog tv_format; RMuint32 col_no = 0; /* number of windows on a row */ RMuint32 row_no = 0; /* number of windows on a column */ RMuint32 mosaic_width; /* width of the mosaic in pixels */ RMuint32 mosaic_height; /* height of the mosaic in pixels */ RMbool fullscreen = FALSE; for (i=0; i< MAX_TASK_COUNT; i++) { play_opt = &playback_options[i]; disp_opt = &display_options[i]; video_opt = &video_options[i]; init_display_options(disp_opt); init_video_options(video_opt); init_playback_options(play_opt); disp_opt->dh_info = &dh_info[i]; video_opt->display_cc = FALSE; /* we cannot display multiple cc streams! */ pdcc_info[i] = &dcc_info[i]; } parse_cmdline(argc, argv); /* use the options parsed before any '-task' tag as global options */ play_opt = &playback_options[0]; disp_opt = &display_options[0]; video_opt = &video_options[0]; while((n*m) < task_count){ if(n == m) n++; else m++; } switch(layout_mode){ case mosaic_square_layout: col_no = n; row_no = n; break; case mosaic_landscape_layout: col_no = m; row_no = n; break; case mosaic_portrait_layout: col_no = n; row_no = m; break; } err = RUACreateInstance(&pRUA, play_opt->chip_num); if (RMFAILED(err)) { fprintf(stderr, "Error creating RUA instance! %d\n", err); return -1; } err = DCCOpen(pRUA, &pDCC); if (RMFAILED(err)) { fprintf(stderr, "Error Opening DCC! %d\n", err); return -1; } err = DCCInitMicroCodeEx(pDCC, disp_opt->init_mode); if (RMFAILED(err)) { fprintf(stderr, "Cannot initialize microcode %d\n", err); return -1; } for (i=0; i< task_count; i++) { dcc_info[i].chip_num = play_opt->chip_num; dcc_info[i].pRUA = pRUA; dcc_info[i].pDCC = pDCC; dcc_info[i].route = disp_opt->route; dcc_info[i].disp_info = NULL; } /* set first decoder in top corner, second decoder in bottom corner */ set_display_out_window(&dcc_info[0]); err = apply_display_options(&dcc_info[0], disp_opt); if (RMFAILED(err)) { fprintf(stderr, "Cannot set display options %d\n", err); goto cleanup; } err = RUAExchangeProperty(pRUA, DisplayBlock, RMDisplayBlockPropertyID_TVFormatAnalog, &(disp_opt->standard), sizeof(disp_opt->standard), &tv_format, sizeof(tv_format)); if (RMFAILED(err)) { fprintf(stderr, "Cannot get TV format %d\n", err); goto cleanup; } mosaic_width = tv_format.ActiveWidth; mosaic_height = tv_format.ActiveHeight; fprintf(stderr, "active width %ld, active height %ld\n", tv_format.ActiveWidth, tv_format.ActiveHeight); /* open rmsmx */ { struct rmsmx_config config; config.pDCC = pDCC; config.pRUA = pRUA; config.canvas_profile.SamplingMode = sampling_mode; if(sampling_mode == EMhwlibSamplingMode_422){ #ifdef RMFEATURE_HAS_VIDEOPLANE RMDBGLOG((ENABLE, "422 picture on DispVideoPlane\n")); config.canvas_scaler = DispVideoPlane;#else RMDBGLOG((ENABLE, "422 picture on DispMainVideoScaler\n")); config.canvas_scaler = DispMainVideoScaler;#endif config.canvas_color = 0xff808080; config.canvas_profile.ColorMode = EMhwlibColorMode_VideoInterleaved; } else{#ifdef RMFEATURE_HAS_VIDEOPLANE RMDBGLOG((ENABLE, "444 picture on DispVideoPlane\n")); config.canvas_scaler = DispVideoPlane;#else RMDBGLOG((ENABLE, "444 picture on DispOSDScaler\n")); config.canvas_scaler = DispOSDScaler;#endif config.canvas_color = 0xff808080; config.canvas_profile.ColorMode = EMhwlibColorMode_TrueColor; config.canvas_profile.SamplingMode = EMhwlibSamplingMode_444; } config.canvas_profile.ColorSpace = EMhwlibColorSpace_YUV_601; config.canvas_profile.ColorFormat = EMhwlibColorFormat_32BPP; config.canvas_profile.PixelAspectRatio.X = 1; config.canvas_profile.PixelAspectRatio.Y = 1;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -