#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. 【前端】制作一个handlebars的jQuery插件

    (function($) { var compiled = {}; $.fn.handlebars = function($srcNode, data) { // 取出模版内容 var src = $ ...

  2. 【jQuery】【转】jQuery中filter()和find()的区别

    Precondition: 现在有一个页面,里面HTML代码为: <div class="css"> <p class="rain">测 ...

  3. java递归应用

    /** * 分配人员数据 * @param num 数据条数 * @param taskUs 人员数据 * @param isend 标记第一次循环 */private void distTaskNu ...

  4. 。linux桌面与命令行

    1.输入用户名和密码登录到系统2.vi /etc/inittab3.修改id:后对应的值为5(桌面模式),id:后对应的值改成3(命令行模式)先用命令#startx启动到桌面模式,然后 Ctrl + ...

  5. 携程Ctrip DAL的学习1

    携程Ctrip DAL的学习 1 本人net开发菜鸟,原理请自行看github的官网源码. 我这里是简单的使用(helloworld的水平). Ctrip DAL是携程框架部开发的数据库访问框架,支持 ...

  6. LINQ之路 9:LINQ to SQL 和 Entity Framework(上)

    在上一篇中,我们从理论和概念上详细的了解了LINQ的第二种架构“解释查询”.在这接下来的二个篇章中,我们将使用LINQ to SQL和Entity Framework来实践“解释查询”,学习这些技术的 ...

  7. 开源许可证GPL、BSD、MIT、Mozilla、Apache和LGPL的区别

    以下是上述协议的简单介绍:BSD开源协议BSD开源协议是一个给于使用者很大自由的协议.基本上使用者可以”为所欲为”,可以自由的使用,修改源代码,也可以将修改后的代码作为开源或者专有软件再发布. 但”为 ...

  8. nslookup

    检查DNS http://arch.pconline.com.cn//pcedu/soft/wl/assist/10307/193330.html

  9. Treap

    treap模板 期望复杂度为O(nlogn) 带合并的treap期望复杂度为O(nlognlogn) #include <bits/stdc++.h> ; struct tree{ int ...

  10. Android热修复之微信Tinker使用初探

      文章地址:Android热修复之微信Tinker使用初探 前几天,万众期待的微信团队的Android热修复框架tinker终于在GitHub上开源了. 地址:https://github.com/ ...