s6410解码问题---linux

转自:  http://www.rosoo.net/a/201111/15255.html

s6410解码问题---linux


我使用的友坚的UT-6410开发板,linux内核版本是2.6.28,7英寸LCD。我使用友坚自带的MFC测试程序( 

他们不提供源代码)UT_MultiMedia_test_800_480,能正常解码。我到网上下载了Multimedia_DD,编 

译通过,拷贝在开发板上运行,出现“Size is too big to be supported”错误。后发现错误在 

urbetter-linux2.6.28-v1.0/drivers/media/video/samsung/post/s3c_pp_6400.c下, 

// S3C6410 support that the source image is up to 4096 x 4096 
//     and the destination image is up to 2048 x 2048. 
     if (    (temp_src_width > 4096) || (temp_src_height > 4096)  
                     || (temp_dst_width > 2048) || (temp_dst_height > 2048) ) 
     { 
     printk(KERN_ERR "/n%s: Size is too big to be  

supported./n", __FUNCTION__); 
     mutex_unlock(h_mutex); 
     return -EINVAL; 
     } 
但是,我的视频文件时三星自带的,不可能超过4096 x 4096,后来我把这段代码注释掉,能运行,但 

是出现黑白屏。我以为是友坚编译的内核出问题,我自己又编译了一次,还是出现同类问题,但是, 

友坚自带的UT_MultiMedia_test_800_480测试代码,却正常。郁闷! 

我的测试代码如下(三星的,我没有修改) 
#include <stdio.h> 
#include <stdlib.h> 
#include <sys/types.h> 
#include <sys/stat.h> 
#include <sys/ioctl.h> 
#include <fcntl.h> 
#include <ctype.h> 
#include <unistd.h> 
#include <sys/mman.h> 
#include <string.h> 
#include <errno.h> 
#include <sys/time.h> 
#include <signal.h> 
#include <linux/vt.h> 
#include <linux/fb.h> 

#include "SsbSipH264Decode.h" 
#include "SsbSipMpeg4Decode.h" 
#include "SsbSipVC1Decode.h" 
#include "FrameExtractor.h" 
#include "MPEG4Frames.h" 
#include "H263Frames.h" 
#include "H264Frames.h" 
#include "VC1Frames.h" 
#include "LogMsg.h" 
#include "performance.h" 
#include "post.h" 
#include "lcd.h" 
#include "MfcDriver.h" 
#include "FileRead.h" 

//#define H264_INPUT_FILE "./TestVectors/veggie.264" 
#define H264_INPUT_FILE "./TestVectors/wanted.264" 
#define MPEG4_INPUT_FILE "./TestVectors/shrek.m4v" 
#define H263_INPUT_FILE "./TestVectors/iron.263" 
#define VC1_INPUT_FILE "./TestVectors/test2_0.rcv" 

static unsigned char delimiter_mpeg4[3] = {0x00, 0x00, 0x01}; 
static unsigned char delimiter_h264[4]  = {0x00, 0x00, 0x00, 0x01}; 


#define INPUT_BUFFER_SIZE (204800) 

static void *handle; 
static int in_fd; 
static int file_size; 
static char *in_addr; 
static int fb_size; 
static int pp_fd, fb_fd; 
static char *fb_addr; 

static void sig_del_h264(int signo); 
static void sig_del_mpeg4(int signo); 
static void sig_del_vc1(int signo); 


int Test_Display_H264(int argc, char **argv) 


void *pStrmBuf; 
int nFrameLeng = 0; 
unsigned int pYUVBuf[2]; 

struct stat s; 
FRAMEX_CTX *pFrameExCtx; // frame extractor  

context 
FRAMEX_STRM_PTR  file_strm; 
SSBSIP_H264_STREAM_INFO stream_info; 

pp_params pp_param; 
s3c_win_info_t osd_info_to_driver; 

struct fb_fix_screeninfo lcd_info; 

#ifdef FPS 
struct timeval start, stop; 
unsigned int time = 0; 
int frame_cnt = 0; 
int mod_cnt = 0; 
#endif 

if(signal(SIGINT, sig_del_h264) == SIG_ERR) { 
printf("Sinal Error/n"); 


// in file open 
in_fd = open(H264_INPUT_FILE, O_RDONLY); 
if(in_fd < 0) { 
printf("Input file open failed/n"); 
return -1; 


// get input file size 
fstat(in_fd, &s); 
file_size = s.st_size; 

// mapping input file to memory 
in_addr = (char *)mmap(0, file_size, PROT_READ, MAP_SHARED, in_fd, 0); 
if(in_addr == NULL) { 
printf("input file memory mapping failed/n"); 
return -1; 


// Post processor open 
pp_fd = open(PP_DEV_NAME, O_RDWR|O_NDELAY); 
if(pp_fd < 0) 

printf("Post processor open error/n"); 
return -1; 


// LCD frame buffer open 
fb_fd = open(FB_DEV_NAME, O_RDWR|O_NDELAY); 
if(fb_fd < 0) 

printf("LCD frame buffer open error/n"); 
return -1; 


/// 
// FrameExtractor Initialization // 
/// 
pFrameExCtx = FrameExtractorInit(FRAMEX_IN_TYPE_MEM, delimiter_h264, sizeof 

(delimiter_h264), 1);    
file_strm.p_start = file_strm.p_cur = (unsigned char *)in_addr; 
file_strm.p_end = (unsigned char *)(in_addr + file_size); 
FrameExtractorFirst(pFrameExCtx, &file_strm); 


// 
///    1. Create new instance      /// 
///      (SsbSipH264DecodeInit)    /// 
// 
handle = SsbSipH264DecodeInit(); 
if (handle == NULL) { 
printf("H264_Dec_Init Failed./n"); 
return -1; 



///    2. Obtaining the Input Buffer      /// 
///      (SsbSipH264DecodeGetInBuf)       /// 

pStrmBuf = SsbSipH264DecodeGetInBuf(handle, nFrameLeng); 
if (pStrmBuf == NULL) { 
printf("SsbSipH264DecodeGetInBuf Failed./n"); 
SsbSipH264DecodeDeInit(handle); 
return -1; 


 
//  H264 CONFIG stream extraction // 
 
nFrameLeng = ExtractConfigStreamH264(pFrameExCtx, &file_strm, pStrmBuf,  

INPUT_BUFFER_SIZE, NULL); 


 
///    3. Configuring the instance with the config stream    /// 
///       (SsbSipH264DecodeExe)                             /// 
 
if (SsbSipH264DecodeExe(handle, nFrameLeng) != SSBSIP_H264_DEC_RET_OK) { 
printf("H.264 Decoder Configuration Failed./n"); 
return -1; 




///   4. Get stream information   /// 

SsbSipH264DecodeGetConfig(handle, H264_DEC_GETCONF_STREAMINFO, &stream_info); 

// printf("/t<STREAMINFO> width=%d   height=%d./n", stream_info.width,  

stream_info.height); 

// set post processor configuration 
pp_param.SrcFullWidth = 100;//stream_info.width; 
pp_param.SrcFullHeight = 200;stream_info.height; 
pp_param.SrcStartX = 0; 
pp_param.SrcStartY = 0; 
pp_param.SrcWidth = pp_param.SrcFullWidth; 
pp_param.SrcHeight = pp_param.SrcFullHeight; 
pp_param.SrcCSpace = YC420; 
pp_param.DstStartX = 0; 
pp_param.DstStartY = 0; 
pp_param.DstFullWidth =  800; // destination width 
pp_param.DstFullHeight = 480; // destination height 
pp_param.DstWidth = pp_param.DstFullWidth; 
pp_param.DstHeight = pp_param.DstFullHeight; 
pp_param.DSTCSpace = RGB16; 
#ifdef RGB24BPP 
pp_param.DSTCSpace = RGB24; 
#endif 
pp_param.OutPath = POST_DMA; 
pp_param.Mode = ONE_SHOT; 


// get LCD frame buffer address 
fb_size = pp_param.DstFullWidth * pp_param.DstFullHeight * 2; // RGB565 
#ifdef RGB24BPP 
fb_size = pp_param.DstFullWidth * pp_param.DstFullHeight * 4; // RGB888 
#endif 

fb_addr = (char *)mmap(0, fb_size, PROT_READ | PROT_WRITE, MAP_SHARED, fb_fd, 0); 
if (fb_addr == NULL) { 
printf("LCD frame buffer mmap failed/n"); 
return -1; 


osd_info_to_driver.Bpp = 16; // RGB16 
#ifdef RGB24BPP 
osd_info_to_driver.Bpp = 24; // RGB16 
#endif 
osd_info_to_driver.LeftTop_x = 0; 
osd_info_to_driver.LeftTop_y = 0; 
osd_info_to_driver.Width =  800; // display width 
osd_info_to_driver.Height =  480; // display height 

// set OSD's information  
if(ioctl(fb_fd, SET_OSD_INFO, &osd_info_to_driver)) { 
printf("Some problem with the ioctl SET_OSD_INFO/n"); 
return -1; 


ioctl(fb_fd, SET_OSD_START); 

printf("/n[1. H.264 display]/n"); 
printf("Using IP          : MFC, Post processor, LCD/n"); 
printf("Input filename    : wanted.264/n"); 
printf("Input vector size : VGA(640x480)/n"); 
printf("Display size      : WVGA(800x480)/n"); 
printf("Bitrate           : 971 Kbps/n"); 
printf("FPS               : 30/n"); 


while(1) 


#ifdef FPS 
gettimeofday(&start, NULL); 
#endif 

// 
///       5. DECODE            /// 
///    (SsbSipH264DecodeExe)   /// 
// 
if (SsbSipH264DecodeExe(handle, nFrameLeng) != SSBSIP_H264_DEC_RET_OK) 
break; 


// 
///    6. Obtaining the Output Buffer      /// 
///      (SsbSipH264DecodeGetOutBuf)       /// 
// 
SsbSipH264DecodeGetConfig(handle, H264_DEC_GETCONF_PHYADDR_FRAM_BUF,  

pYUVBuf); 



// Next H.264 VIDEO stream // 

nFrameLeng = NextFrameH264(pFrameExCtx, &file_strm, pStrmBuf,  

INPUT_BUFFER_SIZE, NULL); 
if (nFrameLeng < 4) 
break; 

// Post processing 
// pp_param.SrcFrmSt俊绰 MFC狼 output buffer狼 physical address啊 
// pp_param.DstFrmSt俊绰 LCD frame buffer狼 physical address啊 涝仿栏肺  

持绢具 茄促. 
pp_param.SrcFrmSt = pYUVBuf[0]; // MFC output buffer 
ioctl(fb_fd, FBIOGET_FSCREENINFO, &lcd_info); 
pp_param.DstFrmSt = lcd_info.smem_start; 

// LCD frame buffer 
ioctl(pp_fd, PPROC_SET_PARAMS, &pp_param); 
ioctl(pp_fd, PPROC_START); 


#ifdef FPS 
gettimeofday(&stop, NULL); 
time += measureTime(&start, &stop); 
frame_cnt++; 
mod_cnt++; 
if (mod_cnt == 50) { 
printf("Average FPS : %u/n", (float)mod_cnt*1000/time); 
mod_cnt = 0; 
time = 0; 

#endif 




#ifdef FPS 
printf("Display Time : %u, Frame Count : %d, FPS : %f/n", time, frame_cnt,  

(float)frame_cnt*1000/time); 
#endif 

ioctl(fb_fd, SET_OSD_STOP); 
SsbSipH264DecodeDeInit(handle); 

munmap(in_addr, file_size); 
munmap(fb_addr, fb_size); 
close(pp_fd); 
close(fb_fd); 
close(in_fd); 

return 0; 





static void sig_del_h264(int signo) 

printf("[H.264 display] signal handling/n"); 

ioctl(fb_fd, SET_OSD_STOP); 
SsbSipH264DecodeDeInit(handle); 

munmap(in_addr, file_size); 
munmap(fb_addr, fb_size); 
close(pp_fd); 
close(fb_fd); 
close(in_fd); 

exit(1); 
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值