Revision 2d3beede

View differences:

configure
2292 2292
enabled libtheora  && require  libtheora theora/theora.h theora_info_init -ltheora -logg
2293 2293
enabled libvorbis  && require  libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
2294 2294
enabled libx264    && require  libx264 x264.h x264_encoder_encode -lx264 -lm &&
2295
                      { check_cpp_condition x264.h "X264_BUILD >= 65" ||
2296
                        die "ERROR: libx264 version must be >= 0.65."; }
2295
                      { check_cpp_condition x264.h "X264_BUILD >= 76" ||
2296
                        die "ERROR: libx264 version must be >= 0.76."; }
2297 2297
enabled libxvid    && require  libxvid xvid.h xvid_global -lxvidcore
2298 2298
enabled mlib       && require  mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
2299 2299

  
libavcodec/libx264.c
52 52
}
53 53

  
54 54

  
55
static int
56
encode_nals(AVCodecContext *ctx, uint8_t *buf, int size, x264_nal_t *nals, int nnal, int skip_sei)
55
static int encode_nals(AVCodecContext *ctx, uint8_t *buf, int size, x264_nal_t *nals, int nnal, int skip_sei)
57 56
{
58 57
    X264Context *x4 = ctx->priv_data;
59 58
    uint8_t *p = buf;
60
    int i, s;
59
    int i;
61 60

  
62 61
    /* Write the SEI as part of the first frame. */
63
    if(x4->sei_size > 0 && nnal > 0)
64
    {
62
    if(x4->sei_size > 0 && nnal > 0){
65 63
        memcpy(p, x4->sei, x4->sei_size);
66 64
        p += x4->sei_size;
67 65
        x4->sei_size = 0;
......
69 67

  
70 68
    for(i = 0; i < nnal; i++){
71 69
        /* Don't put the SEI in extradata. */
72
        if(skip_sei && nals[i].i_type == NAL_SEI)
73
        {
74
            x4->sei = av_malloc( 5 + nals[i].i_payload * 4 / 3 );
75
            if(x264_nal_encode(x4->sei, &x4->sei_size, 1, nals + i) < 0)
76
                return -1;
70
        if(skip_sei && nals[i].i_type == NAL_SEI){
71
            x4->sei_size = nals[i].i_payload;
72
            x4->sei = av_malloc(x4->sei_size);
73
            memcpy(x4->sei, nals[i].p_payload, nals[i].i_payload);
77 74
            continue;
78 75
        }
79
        s = x264_nal_encode(p, &size, 1, nals + i);
80
        if(s < 0)
81
            return -1;
82
        p += s;
76
        memcpy(p, nals[i].p_payload, nals[i].i_payload);
77
        p += nals[i].i_payload;
83 78
    }
84 79

  
85 80
    return p - buf;
......
97 92
    x4->pic.img.i_csp = X264_CSP_I420;
98 93
    x4->pic.img.i_plane = 3;
99 94

  
100
    if (frame) {
95
    if(frame){
101 96
        for(i = 0; i < 3; i++){
102 97
            x4->pic.img.plane[i] = frame->data[i];
103 98
            x4->pic.img.i_stride[i] = frame->linesize[i];
......
107 102
        x4->pic.i_type = X264_TYPE_AUTO;
108 103
    }
109 104

  
110
    if(x264_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL,
111
                           &pic_out))
105
    if(x264_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL, &pic_out) < 0)
112 106
        return -1;
113 107

  
114 108
    bufsize = encode_nals(ctx, buf, bufsize, nal, nnal, 0);
......
296 290

  
297 291
    if(avctx->flags & CODEC_FLAG_GLOBAL_HEADER){
298 292
        x264_nal_t *nal;
299
        int nnal, i, s = 0;
300

  
301
        x264_encoder_headers(x4->enc, &nal, &nnal);
293
        int nnal, s;
302 294

  
303
        /* 5 bytes NAL header + worst case escaping */
304
        for(i = 0; i < nnal; i++)
305
            s += 5 + nal[i].i_payload * 4 / 3;
295
        s = x264_encoder_headers(x4->enc, &nal, &nnal);
306 296

  
307 297
        avctx->extradata = av_malloc(s);
308 298
        avctx->extradata_size = encode_nals(avctx, avctx->extradata, s, nal, nnal, 1);

Also available in: Unified diff