#include "mpu.h"
#include "mem.h"
#include "my_errno.h"
#include "resampler.h"
#include "media_buffer.h" #define same_ptr (void *) (1)
static mpu_item* same_link(fourcc** ccptr); extern media_process_unit speex_dec_8k16b1_mode8;
extern media_process_unit silk_dec_8k16b1;
extern media_process_unit silk_dec_16k16b1;
extern media_process_unit silk_enc_16k16b1;
extern media_process_unit silk_enc_8k16b1; extern media_process_unit aac_dec_8k16b1;
extern media_process_unit aac_dec_8k16b2;
extern media_process_unit aac_dec_16k16b1;
extern media_process_unit aac_dec_16k16b2;
extern media_process_unit aac_dec_22k16b1;
extern media_process_unit aac_dec_22k16b2;
extern media_process_unit aac_dec_24k16b1;
extern media_process_unit aac_dec_24k16b2;
extern media_process_unit aac_dec_32k16b1;
extern media_process_unit aac_dec_32k16b2;
extern media_process_unit aac_dec_44k16b1;
extern media_process_unit aac_dec_44k16b2;
extern media_process_unit aac_dec_48k16b1;
extern media_process_unit aac_dec_48k16b2; extern media_process_unit aac_enc_8k16b1;
extern media_process_unit aac_enc_8k16b2;
extern media_process_unit aac_enc_16k16b1;
extern media_process_unit aac_enc_16k16b2; extern media_process_unit aacplus_dec_8k16b1;
extern media_process_unit aacplus_dec_8k16b2;
extern media_process_unit aacplus_dec_11k16b1;
extern media_process_unit aacplus_dec_11k16b2;
extern media_process_unit aacplus_dec_16k16b1;
extern media_process_unit aacplus_dec_16k16b2;
extern media_process_unit aacplus_dec_22k16b1;
extern media_process_unit aacplus_dec_22k16b2;
extern media_process_unit aacplus_dec_24k16b1;
extern media_process_unit aacplus_dec_24k16b2; extern media_process_unit opus_dec_8k16b1;
extern media_process_unit opus_dec_16k16b1;
extern media_process_unit opus_dec_24k16b1;
extern media_process_unit opus_dec_24k16b2;
extern media_process_unit opus_dec_32k16b1;
extern media_process_unit opus_dec_32k16b2;
extern media_process_unit opus_dec_48k16b1;
extern media_process_unit opus_dec_48k16b2; extern media_process_unit x264_h264_enc;
extern media_process_unit ffmpeg_h264_dec; #if defined(__ANDROID__)
void probe_omx_h264_dec();
extern media_process_unit omx_h264_dec; void probe_java_h264_enc();
extern media_process_unit java_h264_enc; #elif defined(__APPLE__)
void probe_apple_h264_dec();
extern media_process_unit apple_h264_dec; void probe_apple_h264_enc();
media_process_unit apple_h264_enc;
#endif static media_process_unit* mpu_table[] = {
&ffmpeg_h264_dec,
#if defined(__ANDROID__)
&omx_h264_dec,
&java_h264_enc,
#elif defined(__APPLE__)
&apple_h264_dec,
&apple_h264_enc,
#endif
&x264_h264_enc, &silk_dec_16k16b1,
&silk_dec_8k16b1,
&silk_enc_16k16b1,
&silk_enc_8k16b1, &aac_dec_8k16b1,
&aac_dec_8k16b2,
&aac_dec_16k16b1,
&aac_dec_16k16b2,
&aac_dec_22k16b1,
&aac_dec_22k16b2,
&aac_dec_24k16b1,
&aac_dec_24k16b2,
&aac_dec_32k16b1,
&aac_dec_32k16b2,
&aac_dec_44k16b1,
&aac_dec_44k16b2,
&aac_dec_48k16b1,
&aac_dec_48k16b2, &aac_enc_8k16b1,
&aac_enc_8k16b2,
&aac_enc_16k16b1,
&aac_enc_16k16b2, &aacplus_dec_8k16b1,
&aacplus_dec_8k16b2,
&aacplus_dec_11k16b1,
&aacplus_dec_11k16b2,
&aacplus_dec_16k16b1,
&aacplus_dec_16k16b2,
&aacplus_dec_22k16b1,
&aacplus_dec_22k16b2,
&aacplus_dec_24k16b1,
&aacplus_dec_24k16b2, &opus_dec_8k16b1,
&opus_dec_16k16b1,
&opus_dec_24k16b1,
&opus_dec_24k16b2,
&opus_dec_32k16b1,
&opus_dec_32k16b2,
&opus_dec_48k16b1,
&opus_dec_48k16b2, &speex_dec_8k16b1_mode8,
all_resampler
}; struct dijstra_node {
struct list_head entry;
media_process_unit* unit;
struct dijstra_node* prev;
fourcc** fmt;
uint32_t point;
}; static struct dijstra_node* shortest(struct dijstra_node* from, struct list_head* head, fourcc** left)
{
struct dijstra_node* selected = NULL;
for (struct list_head* ent = head->next; ent != head; ent = ent->next) {
struct dijstra_node* item = list_entry(ent, struct dijstra_node, entry); if (media_same(left, item->unit->infmt)) {
if (from == NULL) {
item->point = item->unit->point;
item->fmt = dynamic_output(left, item->unit->outfmt);
} else {
uint32_t point = from->point + item->unit->point;
if (point < item->point) {
item->fmt = dynamic_output(left, item->unit->outfmt);
item->point = point;
item->prev = from;
}
}
} if (selected == NULL || selected->point > item->point) {
selected = item;
}
} if (selected != NULL) {
list_del(&selected->entry);
}
return selected;
} static void* same_open(fourcc** in, fourcc** out)
{
my_assert(in == out);
return same_ptr;
} static int32_t same_write(void* any, struct my_buffer* mbuf, struct list_head* headp, int32_t* delay)
{
(void) delay;
my_assert(any == same_ptr);
if (__builtin_expect(mbuf == NULL, 0)) {
return 0;
}
list_add_tail(&mbuf->head, headp); int32_t n = 1;
media_buffer* media = (media_buffer *) mbuf->ptr[0];
if (audio_type == media_type(*media->pptr_cc)) {
n = (int32_t) media->vp[0].stride;
}
return n;
} static void same_close(void* any)
{
my_assert(any == same_ptr);
} static void same_unit_init(media_process_unit* unit, fourcc** ccptr)
{
static mpu_operation same_ops = {
same_open,
same_write,
same_close
};
unit->infmt = unit->outfmt = ccptr;
unit->ops = &same_ops;
unit->name = "same";
} static mpu_item* collect_node(struct dijstra_node* last, intptr_t need_same)
{
LIST_HEAD(head); int nr = 0;
struct dijstra_node* cur = last;
while (cur != NULL) {
++nr;
cur = cur->prev;
} if (need_same != 0) {
need_same = sizeof(mpu_item) + sizeof(media_process_unit);
} mpu_item* link = (mpu_item *) my_malloc(sizeof(mpu_item) * nr + need_same);
if (link == NULL) {
errno = ENOMEM;
return NULL;
} if (need_same != 0) {
media_process_unit* unit = (media_process_unit *) (link + nr + 1);
same_unit_init(unit, last->unit->outfmt);
link[nr].unit = unit;
link[nr].handle = NULL;
list_add(&link[nr].entry, &head);
} for (int i = nr - 1; i >= 0; --i) {
list_add(&link[i].entry, &head);
link[i].unit = last->unit;
link[i].handle = NULL;
link[i].infmt = link[i].unit->infmt;
link[i].outfmt = link[i].unit->outfmt;
last = last->prev;
} list_del(&head);
return link;
} mpu_item* alloc_mpu_link(fourcc** in, fourcc** out, intptr_t need_same)
{
if (media_same(in, out)) {
my_assert(need_same != 0);
return same_link(in);
} uint32_t exclude = 0;
if (media_type_raw(in)) {
exclude |= mpu_decoder;
} if (media_type_raw(out)) {
exclude |= mpu_encoder;
} LIST_HEAD(head);
fourcc** cur = in; struct dijstra_node nodes[elements(mpu_table)];
for (int i = 0; i < elements(nodes); ++i) {
INIT_LIST_HEAD(&nodes[i].entry);
nodes[i].unit = mpu_table[i];
if ((nodes[i].unit->role & exclude) ||
(nodes[i].unit->infmt[0]->type != in[0]->type))
{
continue;
} #if defined(__ANDROID__)
if (nodes[i].unit == &omx_h264_dec) {
probe_omx_h264_dec();
} else if (nodes[i].unit == &java_h264_enc) {
probe_java_h264_enc();
}
#elif defined(__APPLE__)
if (nodes[i].unit == &apple_h264_dec) {
probe_apple_h264_dec();
} else if (nodes[i].unit == &apple_h264_enc) {
probe_apple_h264_enc();
}
#endif
if (nodes[i].unit->ops == NULL) {
continue;
}
nodes[i].prev = NULL;
nodes[i].fmt = nodes[i].unit->outfmt;
nodes[i].point = ((uint32_t) -1);
list_add_tail(&nodes[i].entry, &head);
}
struct dijstra_node* pitem = NULL; do {
pitem = shortest(pitem, &head, cur);
if (pitem == NULL) {
break;
} if (media_same(pitem->fmt, out)) {
return collect_node(pitem, need_same);
}
cur = pitem->fmt;
} while (!list_empty(&head) && pitem->point != (uint32_t) (-1)); errno = ESRCH;
return NULL;
} void free_mpu_link(mpu_item* link)
{
my_free(link);
} static mpu_item* same_link(fourcc** ccptr)
{
mpu_item* link = (mpu_item *) my_malloc(sizeof(mpu_item) + sizeof(media_process_unit));
if (link == NULL) {
errno = ENOMEM;
return NULL;
} media_process_unit* unit = (media_process_unit *) (link + 1);
same_unit_init(unit, ccptr);
link->unit = unit;
link->handle = NULL;
INIT_LIST_HEAD(&link->entry);
return link;
}

mpu的更多相关文章

  1. silk mpu

    #include "mpu.h" #include "mbuf.h" #include "media_buffer.h" #include ...

  2. CPU MPU MCU SOC SOPC关系及区别

    在嵌入式开过程,会经常接触到一些缩写术语概念,这些概念在嵌入式行业中使用率非常高,下面我们就解释一下这些概念之间的关系和区别: 1.CPU(Central Processing Unit),是一台计算 ...

  3. CPU,MPU,MCU,SOC,SOPC联系与差别

    转自CPU,MPU,MCU,SOC,SOPC联系与差别 1.CPU(Central Processing Unit),是一台计算机的运算核心和控制核心.CPU由运算器.控制器和寄存器及实现它们之间联系 ...

  4. MPU和CPU有什么区别?

    MPU(或称MP,微处理器)和CPU(中央处理器)同为处理器,但范畴不同. 计算机(即电脑)分为巨型机,大型机,中型机,小型机和微型计算机5类.这5类计算机的运算核心统称为CPU,而MPU只是微型计算 ...

  5. MMU 和 MPU的区别

    S3C2440里面带的是MMU,而现在流行的Cortex-M3/4 里面带的是MPU. MMU vs MPU 内存是现代计算机最重要的组件之一.因此,它的内容不能被任何错误的应用所篡改.这个功能可以通 ...

  6. 【STM32H7教程】第23章 STM32H7的MPU内存保护单元(重要)

    完整教程下载地址:http://forum.armfly.com/forum.php?mod=viewthread&tid=86980 第23章       STM32H7的MPU内存保护单元 ...

  7. 谈谈IC、ASIC、SoC、MPU、MCU、CPU、GPU、DSP、FPGA、CPLD

    IC (integrated circuit) 集成电路:微电路.微芯片.芯片:集成电路又分成:模拟集成电路(线性电路).数字集成电路.数/模混合集成电路: 模拟集成电路:产生.放大.处理各种模拟信号 ...

  8. 意法半导体STM32MP157A MPU加持,米尔科技首款ST Linux开发板MYD-YA157C评测

    ST公司去年推出了MPU系列芯片,MPU系列不同于以往产品,它既包含有ARM公司Cortex M 单片机核心,也包含有ARM公司Cortex A 应用处理器核心,以期将STM32单片机产品优势扩展到更 ...

  9. 【.NET 与树莓派】六轴飞控传感器(MPU 6050)

    所谓"飞控",其实是重力加速度计和陀螺仪的组合,因为多用于控制飞行器的平衡(无人机.遥控飞机).有同学会问,这货为什么会有六轴呢?咱们常见的不是X.Y.Z三轴吗?重力加速度有三轴, ...

随机推荐

  1. 0.[WP Developer体验Andriod开发]之从零安装配置Android Studio并编写第一个Android App

    0. 所需的安装文件 笔者做了几年WP,近来对Android有点兴趣,尝试一下Android开发,废话不多说,直接进入主题,先安装开发环境,笔者的系统环境为windows8.1&x64. 安装 ...

  2. 学生信息管理系统(cocos2d引擎)——数据结构课程设计

    老师手把手教了两天半,看了一下模式,加了几个功能就大功告成了!!! 给我的感想就是全都是指针! 添加图片精灵: CCSprite*  spBG = CCSprite::create("&qu ...

  3. Unbuntu下使用SVN

    一.查看SVN版本 svn --version 二.查看SVN仓库 # 查看被svn仓库占用的所有端口 netstat -anp |grep svn # 查看所有端口对应的仓库 ps -ef | gr ...

  4. Java-输入输出流

    JAVA-输入输出流 1.输入输出: 输入/输出(Input/Output)是指对某个设备或环境进行数据的输入或输出.任何语言都有输入输出的功能,在Java程序中,是通过流来完成输入和输出的,它通过J ...

  5. Java开发中经典的小实例-(冒泡法)

    public class Test25 {    public static void main(String[] args) {        // 冒泡法        int[] array = ...

  6. 已禁用对分布式事务管理器(MSDTC)的网络访问的解决方法之一

    C# ASP.NET项目提示上述错误,在代码中使用分布式事务提示添加或修改到数据库的时候.添加数据到数据库时,不会设置实体类的主键字段.

  7. Java集合常用类特点整理

    集合的结构如下图所示: 集合的两个顶级接口分别为:Collection和Map Collection下有两个比较常用的接口分别是List(列表)和Set(集),其中List可以存储重复元素,元素是有序 ...

  8. [poj2492]A Bug's Life(并查集+补集)

    A Bug's Life Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 34678   Accepted: 11339 D ...

  9. jquery.trim() vs JS.trim()

    如果你在IE8浏览器下开发网站,其实这是个假命题,因为原生的javascript 并不支持 .trim()方法,如果你写了类似document.getElementByID().trim();的代码, ...

  10. apt-get 与 yum 的区别

    一般来说著名的 linux 系统基本上分两大类: RedHat系列:Redhat.CentOS.Fedora等 Debian系列:Debian.Ubuntu等 RedHat 系列 1 常见的安装包格式 ...