我想说不同的平台,如tiny210和x210。它们的头文件是有稍微区别的。
我这个是x210下的代码。但都须要注意的是NV12T与NV12的问题,默认要求输入的图片是NV12T,经过调整之后,能够同意用NV12。
即便如此。NV12格式的图片也不好拿到啊。
#include #include #include #include #include '../mfc/SsbSipMfcApi.h' #include '../mfc/MfcConvert.h' #include '../mm/MMClock.h' int test_enc_mpeg4() { MMClock clock; clock.Adjust(1000); SSBSIP_MFC_ERROR_CODE ret = MFC_RET_OK; // 打开 unsigned int buf_type = CACHE; void* handle = SsbSipMfcEncOpen(); if(handle == NULL) { printf('failed to open mfc device!n'); return -1; } printf('== SsbSipMfcDecOpen OK n'); int img_width = 640; int img_height = 480; // 初始化 SSBSIP_MFC_ENC_MPEG4_PARAM param; memset(¶m, 0, sizeof(param)); param.codecType = MPEG4_ENC; param.SourceWidth = img_width; param.SourceHeight = img_height; param.FrameMap = NV12_LINEAR; // 使用linear param.IDRPeriod = 20; // 能够大于3吗? param.SliceMode = 0; param.SliceArgument = 1; param.RandomIntraMBRefresh = 0; // ? // 不使用frame based rate control param.EnableFRMRateControl = 1; param.TimeIncreamentRes = 1000; param.VopTimeIncreament = 40; param.Bitrate = 4000000; param.FrameQp = 1; param.FrameQp_P = 1; param.FrameQp_B = 1; param.QSCodeMax = 45; param.QSCodeMin = 20; param.CBRPeriodRf = 2; // 不使用自己定义padding param.PadControlOn = 0; param.LumaPadVal = 0; param.CbPadVal = 0; param.CrPadVal = 0; param.ProfileIDC = 66; param.LevelIDC = 22; param.NumberBFrames = 0; param.DisableQpelME = 0; if(SsbSipMfcEncInit(handle, ¶m) != MFC_RET_OK) { printf('failed to init encoder !n'); return -1; } /* 得到输入缓冲区地址 */ SSBSIP_MFC_ENC_INPUT_INFO inbuf; if(SsbSipMfcEncGetInBuf (handle, &inbuf) != MFC_RET_OK) { printf('failed to get in buf !n'); return 0; } printf('in buf: Y (addr=%08X, size=%d), CbCr (addr=%08X, size=%d) n' , inbuf.YVirAddr, inbuf.YSize , inbuf.CVirAddr, inbuf.CSize ); /* 得到header */ SSBSIP_MFC_ENC_OUTPUT_INFO outbuf; ret = SsbSipMfcEncGetOutBuf (handle, &outbuf); if(ret != MFC_RET_OK) { printf('failed to get output (%d) n', ret); return -1; } printf('saving header: %d bytes n', outbuf.headerSize); if(1) { FILE* fp = fopen('a00.mpeg4', 'wb'); fwrite(outbuf.StrmVirAddr, 1, outbuf.headerSize, fp); fclose(fp); } int y_size = img_width * img_height; int c_size = y_size / 2; /* 读取图像 */ FILE* fp = fopen('k00.nv12', 'rb'); int n1 = fread(inbuf.YVirAddr, 1, y_size, fp); int n2 = fread(inbuf.CVirAddr, 1, c_size, fp); printf('read bytes: n1=%d, n2=%d n', n1, n2); int count = 0; while(count ++ < 3) { printf('... times: %d , now %d ...n', count, (int) clock.PtsTime()); /* 编码 */ ret = SsbSipMfcEncExe(handle); if(ret != MFC_RET_OK) { printf('failed encoding (%d) n', ret); return -1; } /* 输出结果 */ SSBSIP_MFC_ENC_OUTPUT_INFO outbuf; ret = SsbSipMfcEncGetOutBuf (handle, &outbuf); if(ret != MFC_RET_OK) { printf('failed to get output (%d) n', ret); return -1; } printf('output: frame type=%d, size=%d, header size=%d n' , outbuf.frameType , outbuf.dataSize , outbuf.headerSize); /* 保存成文件*/ char filename[128]; sprintf(filename, 'a%02d.mpeg4', count); FILE* fp = fopen(filename, 'wb'); fwrite(outbuf.StrmVirAddr, 1, outbuf.dataSize, fp); fclose(fp); } SsbSipMfcEncClose(handle); return 0; }
上一篇:基于s5pv210的uboot总结
下一篇:三星s5pv210之芯灵思Sin210与Ti Beaglebone Black之对比
推荐阅读最新更新时间:2026-02-19 11:49
- LTC1733,用于 4.1V 或 4.2V 电池的完整 1.5A 单节锂离子充电器
- MCP39F521,电源监控演示板是一个全功能的 I2C 总线单相电源和能量监控系统
- 具有 4.6A 输入电流限制和 12V、48W 备份模式的 LTC3350IUHF 11V 至 20V、5.3A LiFePO4 电池充电器的典型应用电路
- LT1934IS6-1 1.8V 降压转换器的典型应用电路
- STPIC6D595电源逻辑8位移位寄存器的典型应用
- CAT3200HU2EVB,基于CAT3200HU2升压转换器的评估板
- OP213FSZ-REEL7 5V Only 18-Bit Stereo Op-Amp DAC 的典型应用
- 使用 Analog Devices 的 ADM3066EBRMZ 的参考设计
- RT9284A微型封装、高性能、白光LED恒流开关稳压器驱动5串WLED的典型应用
- LTC2207 演示板,16 位高性能 ADC 驱动器

数字音频技术 (肯·C·波尔曼)
现代雷达系统的信号设计
BFR340T






京公网安备 11010802033920号