简体   繁体   中英

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

enter image description here

x264_picture_t* pPic_in; 

here is my init about 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

x264_picture_clean

here is more detail abuot pPic_in when crash occer enter image description here

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_free( pic->img.plane[0] );

(see x264/common.c )

But img.plane[0] is now pointing to yuv420_data , instead of the memory internally allocated within 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. (If yuv420_data is dynamically allocated, you still need to deallocated it elsewhere).

BTW, x264_picture_init is called within x264_picture_alloc .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM