Changeset 3469


Ignore:
Timestamp:
Mar 22, 2011 9:43:24 AM (10 years ago)
Author:
nanang
Message:

Re #1219: updated stack aligning mechanism using PJ_ALIGN_DATA (see ticket #1220).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-codec/ffmpeg_codecs.c

    r3466 r3469  
    253253    { 
    254254        {PJMEDIA_FORMAT_H263,   {"H263",4},         PJMEDIA_RTP_PT_H263}, 
    255         0,                      1000000,    2000000, 
    256         &h263_packetize, &h263_unpacketize, &h263_parse_fmtp, 
    257         {2, { {{"CIF",3}, {"2",1}}, {{"QCIF",4}, {"1",1}}, } }, 
    258255    }, 
    259256    { 
     
    12301227    int out_buf_len = output_buf_len; 
    12311228    int err; 
    1232     unsigned i; 
     1229 
     1230    /* For some reasons (e.g: SSE/MMX usage), the avcodec_encode_video() must 
     1231     * have stack aligned to 16 bytes. Let's try to be safe by preparing the 
     1232     * 16-bytes aligned stack here, in case it's not managed by the ffmpeg. 
     1233     */ 
     1234    PJ_ALIGN_DATA(pj_uint32_t i[4], 16); 
    12331235 
    12341236    /* Check if encoder has been opened */ 
     
    12381240    avframe.pts = input->timestamp.u64; 
    12391241     
    1240     for (i = 0; i < ff->enc_vfi->plane_cnt; ++i) { 
    1241         avframe.data[i] = p; 
    1242         avframe.linesize[i] = ff->enc_vafp.strides[i]; 
    1243         p += ff->enc_vafp.plane_bytes[i]; 
    1244     } 
    1245  
    1246 #if 0 && defined(_MSC_VER) 
    1247     /* Align stack for MSVC environment to avoid 'random' crash, as advised in 
    1248      * http://ffmpeg.arrozcru.org/forum/viewtopic.php?f=1&t=549 
    1249      */ 
    1250 #   define VHALIGNCALL16(x) \ 
    1251     {\ 
    1252         _asm { mov ebx, esp }\ 
    1253         _asm { and esp, 0xfffffff0 }\ 
    1254         _asm { sub esp, 12 }\ 
    1255         _asm { push ebx }\ 
    1256         x;\ 
    1257         _asm { pop ebx }\ 
    1258         _asm { mov esp, ebx }\ 
    1259      } 
    1260 #else 
    1261 #   define VHALIGNCALL16(x)     x 
    1262 #endif 
    1263  
    1264     VHALIGNCALL16(err = avcodec_encode_video(ff->enc_ctx, out_buf,  
    1265                                              out_buf_len, &avframe)); 
    1266  
     1242    for (i[0] = 0; i[0] < ff->enc_vfi->plane_cnt; ++i[0]) { 
     1243        avframe.data[i[0]] = p; 
     1244        avframe.linesize[i[0]] = ff->enc_vafp.strides[i[0]]; 
     1245        p += ff->enc_vafp.plane_bytes[i[0]]; 
     1246    } 
     1247 
     1248    err = avcodec_encode_video(ff->enc_ctx, out_buf, out_buf_len, &avframe); 
    12671249    if (err < 0) { 
    12681250        print_ffmpeg_err(err); 
Note: See TracChangeset for help on using the changeset viewer.