Changeset 6149 for pjproject


Ignore:
Timestamp:
Feb 3, 2020 6:26:55 AM (5 years ago)
Author:
ming
Message:

Re #2253
Fix vpx fmtp apply:

  • Only adjust the frame rate if it exceeds max-fr
  • Maintain aspect ratio when adjusting resolution
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/vid_codec_util.c

    r6110 r6149  
    816816 
    817817        if (fmtp.max_fr > 0) { 
    818             vfd->fps.num   = fmtp.max_fr; 
    819             vfd->fps.denum = 1; 
     818            if ((float)vfd->fps.num/vfd->fps.denum > (float)fmtp.max_fr) { 
     819                vfd->fps.num   = fmtp.max_fr; 
     820                vfd->fps.denum = 1; 
     821            } 
    820822        } 
    821823         
     
    823825            unsigned max_res = ((int)pj_isqrt(fmtp.max_fs * 8)) * 16; 
    824826             
    825             /* Do we need to maintain the aspect ratio or scale down 
    826              * to some predetermined resolution instead (for example, 
    827              * if the requested resolution is 640x480 and max_res is 
    828              * 600, should we scale down to 480xx360)? 
    829              */ 
    830             if (vfd->size.w > max_res) 
    831                 vfd->size.w = max_res; 
    832             if (vfd->size.h > max_res) 
    833                 vfd->size.h = max_res; 
     827            if (vfd->size.w > max_res || vfd->size.h > max_res) { 
     828                /* Here we maintain the aspect ratio. Or should we scale down 
     829                 * to some predetermined resolution instead (for example, 
     830                 * if the requested resolution is 640x480 and max_res is 
     831                 * 600, should we scale down to 480x360)? 
     832                 */ 
     833                unsigned larger = (vfd->size.w > vfd->size.h)? 
     834                                  vfd->size.w: vfd->size.h; 
     835                float scale = (float)max_res/larger; 
     836 
     837                vfd->size.w = (int)(scale * vfd->size.w); 
     838                vfd->size.h = (int)(scale * vfd->size.h); 
     839            } 
    834840        } 
    835841    } 
Note: See TracChangeset for help on using the changeset viewer.