camerauis/cameraxui/cxengine/src/cxequalitypresetssymbian.cpp
changeset 37 64817133cd1d
parent 29 699651f2666f
child 42 feebad15db8c
child 48 42ba2d16bf40
equal deleted inserted replaced
36:b12f3922a74f 37:64817133cd1d
    38     // Display IDs for cameras, used when requesting data from ICM
    38     // Display IDs for cameras, used when requesting data from ICM
    39     const int    PRIMARY_CAMERA_DISPLAY_ID   = 2;
    39     const int    PRIMARY_CAMERA_DISPLAY_ID   = 2;
    40     const int    SECONDARY_CAMERA_DISPLAY_ID = 3;
    40     const int    SECONDARY_CAMERA_DISPLAY_ID = 3;
    41 
    41 
    42     const int    ONE_MILLION    = 1000000;
    42     const int    ONE_MILLION    = 1000000;
    43     const qreal  ASPECT_16_BY_9 = (16/9.0);
    43 
    44     const qreal  DELTA_ERROR    = 0.20;
    44     const QSize ASPECT_RATIO_SIZE_4BY3  = QSize(4,3);
       
    45     const QSize ASPECT_RATIO_SIZE_16BY9 = QSize(16, 9);
       
    46     const QSize ASPECT_RATIO_SIZE_11BY9 = QSize(11, 9);
    45 
    47 
    46     // ICM "camcorderVisible" parameter value below this means sharing aka mms quality.
    48     // ICM "camcorderVisible" parameter value below this means sharing aka mms quality.
    47     const int    MMS_QUALITY_CAMCORDERVISIBLE_LIMIT = 200;
    49     const int    MMS_QUALITY_CAMCORDERVISIBLE_LIMIT = 200;
    48 
    50 
    49     // Average video bit rate scaler
    51     // Average video bit rate scaler
   303 */
   305 */
   304 Cxe::AspectRatio CxeQualityPresetsSymbian::calculateAspectRatio(int width, int height) const
   306 Cxe::AspectRatio CxeQualityPresetsSymbian::calculateAspectRatio(int width, int height) const
   305 {
   307 {
   306     Cxe::AspectRatio aspectRatio = Cxe::AspectRatio4to3;
   308     Cxe::AspectRatio aspectRatio = Cxe::AspectRatio4to3;
   307 
   309 
   308     qreal ratio = 0;
   310     // calculate delta error for the resolution against supported aspect ratio's
   309     if (height != 0) {
   311     int delta16by9 = abs((width * ASPECT_RATIO_SIZE_16BY9.height()) - (height * ASPECT_RATIO_SIZE_16BY9.width()));
   310         ratio = (1.0 * width) / height;
   312     int delta11by9 = abs((width * ASPECT_RATIO_SIZE_11BY9.height()) - (height * ASPECT_RATIO_SIZE_11BY9.width()));
   311 
   313     int delta4by3  = abs((width * ASPECT_RATIO_SIZE_4BY3.height()) - (height * ASPECT_RATIO_SIZE_4BY3.width()));
   312         qreal delta16by9 = ratio - ASPECT_16_BY_9;
   314     
   313         if (abs(delta16by9) < DELTA_ERROR) {
   315     // get the closest aspect ratio
   314             aspectRatio = Cxe::AspectRatio16to9;
   316     int minValue = qMin(qMin(delta16by9, delta11by9), delta4by3);
   315         }
   317     
       
   318     if (minValue == delta16by9) {
       
   319         aspectRatio = Cxe::AspectRatio16to9;
       
   320     } else if (minValue == delta11by9) {
       
   321         aspectRatio = Cxe::AspectRatio11to9;
       
   322     } else if (minValue == delta4by3) {
       
   323         aspectRatio = Cxe::AspectRatio4to3;
   316     }
   324     }
   317 
   325 
   318     return aspectRatio;
   326     return aspectRatio;
   319 }
   327 }
   320 
   328