Changeset 23f9442398a0a7a7b2f4a7b163fada125bfdc148

Show
Ignore:
Timestamp:
17/03/05 17:59:16 (4 years ago)
Author:
Christophe Massiot <massiot@videolan.org>
git-committer:
Christophe Massiot <massiot@videolan.org> 1111078756 +0000
git-parent:

[05c786b6f3234f0b70952add5263f3446f5da217]

git-author:
Christophe Massiot <massiot@videolan.org> 1111078756 +0000
Message:

* modules/stream_out/switcher.c: Fixed aspect ratio.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/stream_out/switcher.c

    rdb70826 r23f9442  
    132132    int             i_gop; 
    133133    int             i_qscale; 
    134     AVRational      sample_aspect_ratio
     134    int             i_aspect
    135135    sout_stream_id_t *pp_audio_ids[MAX_AUDIO]; 
    136136 
     
    234234        { 
    235235            *psz_parser++ = '\0'; 
    236             p_sys->sample_aspect_ratio.num = atoi( val.psz_string ); 
    237             p_sys->sample_aspect_ratio.den = atoi( psz_parser ); 
     236            p_sys->i_aspect = atoi( val.psz_string ) * VOUT_ASPECT_FACTOR 
     237                / atoi( psz_parser ); 
    238238        } 
    239239        else 
    240240        { 
    241241            msg_Warn( p_stream, "bad aspect ratio %s", val.psz_string ); 
    242             p_sys->sample_aspect_ratio.num = 4; 
    243             p_sys->sample_aspect_ratio.den = 3; 
     242            p_sys->i_aspect = 4 * VOUT_ASPECT_FACTOR / 3; 
    244243        } 
    245244 
     
    248247    else 
    249248    { 
    250         p_sys->sample_aspect_ratio.num = 4; 
    251         p_sys->sample_aspect_ratio.den = 3; 
     249        p_sys->i_aspect = 4 * VOUT_ASPECT_FACTOR / 3; 
    252250    } 
    253251 
     
    696694        /* Create a new encoder. */ 
    697695        int i_ff_codec = CODEC_ID_MPEG2VIDEO; 
     696        int i_aspect_num, i_aspect_den; 
     697 
    698698        if( i_ff_codec == 0 ) 
    699699        { 
     
    733733        id->ff_enc_c->width = p_sys->p_pictures[p_sys->i_cmd-1].format.i_width; 
    734734        id->ff_enc_c->height = p_sys->p_pictures[p_sys->i_cmd-1].format.i_height; 
     735        av_reduce( &i_aspect_num, &i_aspect_den, 
     736                   p_sys->i_aspect, 
     737                   VOUT_ASPECT_FACTOR, 1 << 30 /* something big */ ); 
     738        av_reduce( &id->ff_enc_c->sample_aspect_ratio.num, 
     739                   &id->ff_enc_c->sample_aspect_ratio.den, 
     740                   i_aspect_num * (int64_t)id->ff_enc_c->height, 
     741                   i_aspect_den * (int64_t)id->ff_enc_c->width, 1 << 30 ); 
    735742 
    736743        id->ff_enc_c->frame_rate    = 25; /* FIXME */ 
    737744        id->ff_enc_c->frame_rate_base = 1; 
    738         memcpy( &id->ff_enc_c->sample_aspect_ratio, &p_sys->sample_aspect_ratio, 
    739                 sizeof(AVRational) ); 
    740745 
    741746        id->ff_enc_c->gop_size = 200;