qn1561991023

qn1561991023

0个粉丝

11

问答

0

专栏

0

资料

qn1561991023  发布于  2019-07-16 18:41:56
采纳率 0%
11个问答
1860

3516熟悉ffmpeg的看过来,avformat_alloc_context为什么会出错

 

我编译了ffmpeg的最小库,自己写了一个测试程序本来就没有几行代码,在板子上运行

/Include ffmpeg header file/

include <libavformat/avformat.h>

include <libavcodec/avcodec.h>

include <libavutil/imgutils.h>

include <libavutil/opt.h>

include <libavutil/mathematics.h>

include <libavutil/samplefmt.h>

include <libavutil/samplefmt.h>

void main() { //变量 AVFormatContext pFormatCtx = NULL; //const char rtspUrl[] = "rtsp://172.16.3.119/live/stream0"; AVPacket packet; int i =0,j = 0,m =0; //初始化 printf("Test ffmpeg 2019 0716 1\n"); av_register_all(); printf("Test ffmpeg 1.1\n"); avformat_network_init(); printf("Test ffmpeg 1.2\n"); [color=Red] pFormatCtx = avformat_alloc_context();[/color] printf("Test ffmpeg 1.3\n");

av_free(pFormatCtx);
//av_free(packet);

}

红色部份报错,Test ffmpeg 1.2都可以打印,实在是分析不出来了,我的板子flash空间只有1M多,内存空间只有3M 不知道这个有没有影响,avformat_alloc_context()这个申请的内存空间到底是多大啊

我来回答
回答3个
时间排序
认可量排序

qn1561991023

0个粉丝

11

问答

0

专栏

0

资料

qn1561991023 2019-07-17 10:20:46
认可0
自己顶一个,

qn1532917771

0个粉丝

7

问答

0

专栏

0

资料

qn1532917771 2019-07-17 13:49:03
认可0
AVFormatContext *avformat_alloc_context(void)
{
    AVFormatContext *ic;
    ic = av_malloc(sizeof(AVFormatContext));
    if (!ic)

        return ic;
    avformat_get_context_defaults(ic);

    ic->internal = av_mallocz(sizeof(*ic->internal));
    if (!ic->internal) {
        avformat_free_context(ic);
        return NULL;
    }

    return ic;
}




static size_t max_alloc_size= INT_MAX;

//INT_MAX定义在limits.h头文件中,具体的数没必要记住,只要知道是很大的就行了!

//好像c中32位的int的范围是:-2147483648->2147483647.

void *av_malloc(size_t size)
{
    void *ptr = NULL;
#if CONFIG_MEMALIGN_HACK//这都是定义在config.h中的。初始定义为0
    long diff;
#endif

    /* let's disallow possibly ambiguous cases */
    if (size > (max_alloc_size - 32))
        return NULL;

#if CONFIG_MEMALIGN_HACK
    ptr = malloc(size + ALIGN);//ALIGN=32
    if (!ptr)
        return ptr;//一般会走到这里就结束了
    diff              = ((~(long)ptr)&(ALIGN - 1)) + 1;
    ptr               = (char *)ptr + diff;
    ((char *)ptr)[-1] = diff;
#elif HAVE_POSIX_MEMALIGN
    if (size) //OS X on SDK 10.6 has a broken posix_memalign implementation
    if (posix_memalign(&ptr, ALIGN, size))
        ptr = NULL;
#elif HAVE_ALIGNED_MALLOC
    ptr = _aligned_malloc(size, ALIGN);
#elif HAVE_MEMALIGN
#ifndef __DJGPP__
    ptr = memalign(ALIGN, size);
#else
    ptr = memalign(size, ALIGN);
#endif
    /* Why 64?
     * Indeed, we should align it:
     *   on  4 for 386
     *   on 16 for 486
     *   on 32 for 586, PPro - K6-III
     *   on 64 for K7 (maybe for P3 too).
     * Because L1 and L2 caches are aligned on those values.
     * But I don't want to code such logic here!
     */
    /* Why 32?
     * For AVX ASM. SSE / NEON needs only 16.
     * Why not larger? Because I did not see a difference in benchmarks ...
     */
    /* benchmarks with P3
     * memalign(64) + 1          3071, 3051, 3032
     * memalign(64) + 2          3051, 3032, 3041
     * memalign(64) + 4          2911, 2896, 2915
     * memalign(64) + 8          2545, 2554, 2550
     * memalign(64) + 16         2543, 2572, 2563
     * memalign(64) + 32         2546, 2545, 2571
     * memalign(64) + 64         2570, 2533, 2558
     *
     * BTW, malloc seems to do 8-byte alignment by default here.
     */
#else
    ptr = malloc(size);
#endif
    if(!ptr && !size) {
        size = 1;
        ptr= av_malloc(1);
    }
#if CONFIG_MEMORY_POISONING
    if (ptr)
        memset(ptr, FF_MEMORY_POISON, size);
#endif
    return ptr;
}

qn1532917771

0个粉丝

7

问答

0

专栏

0

资料

qn1532917771 2019-07-17 13:49:42
认可0
太小了,ffmpeg的动态库都放不下吧
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
+ 添加网盘链接/附件

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
相关问答
无更多相似问答 去提问
举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

易百纳技术社区