#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. [LeetCode_5] Longest Palindromic Substring

    LeetCode: 5. Longest Palindromic Substring class Solution { public: //动态规划算法 string longestPalindrom ...

  2. append追加的使用

    #!/usr/bin/env python def fun(arg) : ret = [] for i in range(len(arg)) : if i % 2 ==1 : ret.append(a ...

  3. ie不兼容的几个js问题及解决办法

    1.table问题 在动态新增tr或者td时,createElement()一般用appendChild();都不生效,解决办法是用新增tbody,如 var table=document.creat ...

  4. DEV GridControl小结

    1. 如何解决单击记录整行选中的问题 View->OptionsBehavior->EditorShowMode 设置为:Click 2. 如何新增一条记录 (1).gridView.Ad ...

  5. WebForm 控件

    一.简单控件 1.Label(作用:显示文字) Web中: <asp:Label ID="Label1" runat="server" Text=&quo ...

  6. Spire.Office组件使用例子

    用.NET开发程序通常要涉及到对Office文件读写操作,比较常见的操作比如提取文本,导出Excel格式数据,动态生成word文档,生成pdf文档等. 实现这些功能通常需要在服务端安装office软件 ...

  7. Too Many Connections: How to Increase the MySQL Connection Count To Avoid This Problem

    1.问题描述 在启动使用mysql数据库的项目时,遇到一个报错,如下: Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConn ...

  8. 使用SQL语句查询每张表的column name

    exec sp_columns tableName 上面这行代码可以查出该表所有的column,改为sp_pkeys,可以查出该表的主键.但是我如果想只查出column name,select COL ...

  9. [重要公告] 关于禁止发布Windows系统及非法激活软件的通知

    Skyfree 发表于 2013-11-15 09:45:17 https://www.itsk.com/thread-306891-1-1.html 接微软方面法务通知,要求删除涉及发布Win8/8 ...

  10. VMWARE里启动kylin16.0时出现'SMBus Host Controller not enabled'(还未进入系统)

    在Vmware里安装完Ubuntu16.10,启动时出现'SMBus Host Controller not enabled'错误提示,进不到图形界面.网上搜了一下,解决办法是在图形界面里进终端窗口, ...