[英]x264 Encoding use x264_picture_clean crash
When I use iphone encoding CMSampleBufferRef To H264, it offen crash at x264_picture_clean
I dont't know how to deal it 当我使用iphone编码CMSampleBufferRef到H264时,它崩溃了
x264_picture_clean
我不知道如何处理它
enter image description here 在此输入图像描述
x264_picture_t* pPic_in;
here is my init about pPic_in 这是关于pPic_in的初始化
pPic_in = (x264_picture_t*)malloc(sizeof(x264_picture_t));
pPic_out = (x264_picture_t*)malloc(sizeof(x264_picture_t));
x264_picture_init(pPic_out);
x264_picture_init(pPic_in);
x264_picture_alloc(pPic_in, csp, pParam->i_width, pParam->i_height);
pPic_in->img.i_stride[0] = width;
pPic_in->img.i_stride[1] = width / 2;
pPic_in->img.i_stride[2] = width / 2;
pPic_in->img.i_plane = 3;
and i set data here 我在这里设置数据
picture_buf = yuv420_data;
pPic_in->img.plane[0] = picture_buf;
pPic_in->img.plane[1] = picture_buf + y_size;
pPic_in->img.plane[2] = picture_buf + y_size*5/4;
it looks well , when i run it on my iphone,but sometimes it will crash at 它看起来很好,当我在我的iPhone上运行它,但有时它会崩溃
x264_picture_clean
here is more detail abuot pPic_in when crash occer enter image description here 当崩溃occer在这里输入图像描述时,这里有更多细节abPot_in
Thank u very much 十分感谢
I suspect this error happened because x264_picture_clean
tries to free up the memory allocated to img.plane[0]
: 我怀疑发生了这个错误,因为
x264_picture_clean
试图释放分配给img.plane[0]
的内存:
x264_free( pic->img.plane[0] );
(see x264/common.c
) (见
x264/common.c
)
But img.plane[0]
is now pointing to yuv420_data
, instead of the memory internally allocated within x264_picture_alloc
. 但是
img.plane[0]
现在指向yuv420_data
,而不是在x264_picture_alloc
内部分配的内存。
Since x264_picture_clean
basically just free up the allocated memory pointed to by img.plane[0]
and reinitialize pPic_in
, it might be possible that you can skip calling x264_picture_clean
without memory leak. 由于
x264_picture_clean
基本上只是释放img.plane[0]
指向的已分配内存并重新初始化pPic_in
,因此您可以跳过调用x264_picture_clean
而不会出现内存泄漏。 (If yuv420_data
is dynamically allocated, you still need to deallocated it elsewhere). (如果动态分配
yuv420_data
,您仍需要在其他位置解除分配)。
BTW, x264_picture_init
is called within x264_picture_alloc
. BTW,
x264_picture_init
在x264_picture_alloc
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.