[x264-devel] Issue with lookahead when encoding (Android)

BugMaster BugMaster at narod.ru
Mon Jan 7 13:14:27 CET 2013


On Sat, 5 Jan 2013 13:16:53 +0000, Wazar Apps wrote:
> Hello


> I have compiled FFMPEG with x264 (v129) on Android and I am using
> the encoder to encode frames to a video file. I am using the
> following call to encode frames (as I decode them from another file):

> out_size = avcodec_encode_video2(gVideoWriteCodecCtx, &writePkt, pCurrentFrame, &gotPacket);

> The first few frames get buffered and on the 14th a call is made to
> lookahead_get_frames(). On slice type_decide, the following code is executed:


frames[0] = h->>lookahead->last_nonb;
> memcpy( &frames[1], h->lookahead->next.list, (bframes+1) * sizeof(x264_frame_t*) );
> if( IS_X264_TYPE_I( h->lookahead->next.list[bframes]->i_type ) )
>     p0 = bframes + 1;
> else // P
>     p0 = 0;

Here, h->>lookahead->last_nonb is null. As a consequence, in x264_slicetype_frame_cost I get a SIGSEGV in x264_weights_analyse (ref is null)


> static void x264_weights_analyse( x264_t *h, x264_frame_t *fenc,
> x264_frame_t *ref, int b_lookahead )
> {
>     int i_delta_index = fenc->i_frame - ref->i_frame - 1;



> Shouldn't last_nonb have been set before this call? for example
> with x264_lookahead_update_last_nonb( h, h->lookahead->next.list[0]
> ); that is called in lookahead.c just after slicetype_decide?

> Thanks
> Nicolas

It would crash (last_nonb == NULL) there only if you *forced* first
frame (frame 0) to be anything other than I-frame (which is wrong for
sure). To make libx264 a lit bit more foolproof you can try attached
patch.

btw what you (if it was you) did in
http://stackoverflow.com/questions/14104129/ffmpeg-x264-encoding-on-android-error-with-lookahead
is wrong.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: application/octet-stream
Size: 765 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x264-devel/attachments/20130107/9aa83915/attachment.obj>


More information about the x264-devel mailing list