[Merge] lp:~fboucault/qtubuntu-camera/jpeg_quality into lp:qtubuntu-camera

Jim Hodapp jim.hodapp at canonical.com
Tue Nov 25 15:25:06 UTC 2014


Review: Needs Information code

Looks good. Just the one question inline and I'd be happy with this.

Diff comments:

> === modified file 'debian/control'
> --- debian/control	2014-09-23 18:12:45 +0000
> +++ debian/control	2014-11-24 19:35:54 +0000
> @@ -5,7 +5,7 @@
>  Build-Depends: debhelper (>= 9),
>                 libgl1-mesa-dev | libgl-dev,
>                 libgles2-mesa-dev,
> -               libhybris-dev (>= 0.1.0+git20131207+e452e83-0ubuntu23),
> +               libhybris-dev (>= 0.1.0+git20131207+e452e83-0ubuntu34),
>                 libpulse-dev,
>                 libqt5opengl5-dev,
>                 libqtubuntu-media-signals-dev,
> 
> === modified file 'src/aalimageencodercontrol.cpp'
> --- src/aalimageencodercontrol.cpp	2014-10-30 20:09:40 +0000
> +++ src/aalimageencodercontrol.cpp	2014-11-24 19:35:54 +0000
> @@ -29,6 +29,9 @@
>        m_currentSize(),
>        m_currentThumbnailSize()
>  {
> +    int jpegQuality;
> +    android_camera_get_jpeg_quality(m_service->androidControl(), &jpegQuality);
> +    m_encoderSettings.setQuality(jpegQualityToQtEncodingQuality(jpegQuality));
>  }
>  
>  AalImageEncoderControl::~AalImageEncoderControl()
> @@ -43,12 +46,32 @@
>  
>  QImageEncoderSettings AalImageEncoderControl::imageSettings() const
>  {
> -    return QImageEncoderSettings();
> +    return m_encoderSettings;
>  }
>  
>  void AalImageEncoderControl::setImageSettings(const QImageEncoderSettings &settings)
>  {
> -    Q_UNUSED(settings);
> +    if (!settings.isNull()) {
> +        // JPEG quality
> +        m_encoderSettings.setQuality(settings.quality());
> +        int jpegQuality = qtEncodingQualityToJpegQuality(settings.quality());
> +        android_camera_set_jpeg_quality(m_service->androidControl(), jpegQuality);
> +
> +        // codec

Have you tested various combinations of these? For example, if the codec is set but no resolution, what happens to the resulting image? Or If the codec is not set, but some encoding options are, what happens?

> +        if (!settings.codec().isNull()) {
> +            m_encoderSettings.setCodec(settings.codec());
> +        }
> +
> +        // resolution
> +        if (!settings.resolution().isNull()) {
> +            m_encoderSettings.setResolution(settings.resolution());
> +        }
> +
> +        // encoding options
> +        if (!settings.encodingOptions().isEmpty()) {
> +            m_encoderSettings.setEncodingOptions(settings.encodingOptions());
> +        }
> +    }
>  }
>  
>  QStringList AalImageEncoderControl::supportedImageCodecs() const
> @@ -175,3 +198,44 @@
>  {
>      m_availableThumbnailSizes.append(QSize(width, height));
>  }
> +
> +
> +QMultimedia::EncodingQuality AalImageEncoderControl::jpegQualityToQtEncodingQuality(int jpegQuality)
> +{
> +    QMultimedia::EncodingQuality quality;
> +    if (jpegQuality <= 40) {
> +        quality = QMultimedia::VeryLowQuality;
> +    } else if (jpegQuality <= 60) {
> +        quality = QMultimedia::LowQuality;
> +    } else if (jpegQuality <= 80) {
> +        quality = QMultimedia::NormalQuality;
> +    } else if (jpegQuality <= 90) {
> +        quality = QMultimedia::HighQuality;
> +    } else {
> +        quality = QMultimedia::VeryHighQuality;
> +    }
> +    return quality;
> +}
> +
> +int AalImageEncoderControl::qtEncodingQualityToJpegQuality(QMultimedia::EncodingQuality quality)
> +{
> +    int jpegQuality = 100;
> +    switch (quality) {
> +    case QMultimedia::VeryLowQuality:
> +        jpegQuality = 40;
> +        break;
> +    case QMultimedia::LowQuality:
> +        jpegQuality = 60;
> +        break;
> +    case QMultimedia::NormalQuality:
> +        jpegQuality = 80;
> +        break;
> +    case QMultimedia::HighQuality:
> +        jpegQuality = 90;
> +        break;
> +    case QMultimedia::VeryHighQuality:
> +        jpegQuality = 100;
> +        break;
> +    }
> +    return jpegQuality;
> +}
> 
> === modified file 'src/aalimageencodercontrol.h'
> --- src/aalimageencodercontrol.h	2014-10-27 17:25:50 +0000
> +++ src/aalimageencodercontrol.h	2014-11-24 19:35:54 +0000
> @@ -54,9 +54,12 @@
>      QList<QSize> m_availableThumbnailSizes;
>      QSize m_currentSize;
>      QSize m_currentThumbnailSize;
> +    QImageEncoderSettings m_encoderSettings;
>  
>      void getPictureSize(int width, int height);
>      void getThumbnailSize(int width, int height);
> +    QMultimedia::EncodingQuality jpegQualityToQtEncodingQuality(int jpegQuality);
> +    int qtEncodingQualityToJpegQuality(QMultimedia::EncodingQuality quality);
>  };
>  
>  #endif
> 
> === modified file 'unittests/aalimagecapturecontrol/aalimageencodercontrol.cpp'
> --- unittests/aalimagecapturecontrol/aalimageencodercontrol.cpp	2014-10-27 17:25:50 +0000
> +++ unittests/aalimagecapturecontrol/aalimageencodercontrol.cpp	2014-11-24 19:35:54 +0000
> @@ -115,3 +115,15 @@
>      Q_UNUSED(width);
>      Q_UNUSED(height);
>  }
> +
> +QMultimedia::EncodingQuality AalImageEncoderControl::jpegQualityToQtEncodingQuality(int jpegQuality)
> +{
> +    Q_UNUSED(jpegQuality)
> +    return QMultimedia::NormalQuality;
> +}
> +
> +int AalImageEncoderControl::qtEncodingQualityToJpegQuality(QMultimedia::EncodingQuality quality)
> +{
> +    Q_UNUSED(quality)
> +    return 100;
> +}
> 
> === modified file 'unittests/mocks/aal/camera_compatibility_layer.cpp'
> --- unittests/mocks/aal/camera_compatibility_layer.cpp	2014-07-17 19:10:12 +0000
> +++ unittests/mocks/aal/camera_compatibility_layer.cpp	2014-11-24 19:35:54 +0000
> @@ -127,6 +127,18 @@
>      crashTest(control);
>  }
>  
> +void android_camera_set_jpeg_quality(CameraControl* control, int quality)
> +{
> +    Q_UNUSED(quality);
> +    crashTest(control);
> +}
> +
> +void android_camera_get_jpeg_quality(CameraControl* control, int* quality)
> +{
> +    Q_UNUSED(quality);
> +    crashTest(control);
> +}
> +
>  void android_camera_set_effect_mode(CameraControl* control, EffectMode mode)
>  {
>      Q_UNUSED(mode);
> 
> === modified file 'unittests/mocks/aal/camera_compatibility_layer_capabilities.h'
> --- unittests/mocks/aal/camera_compatibility_layer_capabilities.h	2014-07-17 19:10:12 +0000
> +++ unittests/mocks/aal/camera_compatibility_layer_capabilities.h	2014-11-24 19:35:54 +0000
> @@ -121,6 +121,7 @@
>  void android_camera_get_scene_mode(CameraControl* control, SceneMode* mode);
>  void android_camera_get_auto_focus_mode(CameraControl* control, AutoFocusMode* mode);
>  void android_camera_get_preview_format(CameraControl* control, CameraPixelFormat* format);
> +void android_camera_get_jpeg_quality(struct CameraControl* control, int* quality);
>  
>  // Adjusts camera parameters
>  void android_camera_set_preview_size(CameraControl* control, int width, int height); 
> @@ -132,6 +133,7 @@
>  void android_camera_set_scene_mode(CameraControl* control, SceneMode mode);
>  void android_camera_set_auto_focus_mode(CameraControl* control, AutoFocusMode mode);
>  void android_camera_set_preview_format(CameraControl* control, CameraPixelFormat format);
> +void android_camera_set_jpeg_quality(struct CameraControl* control, int quality);
>  
>  void android_camera_set_focus_region(CameraControl* control, FocusRegion* region);
>  void android_camera_reset_focus_region(CameraControl* control);
> 


-- 
https://code.launchpad.net/~fboucault/qtubuntu-camera/jpeg_quality/+merge/242649
Your team Ubuntu Phablet Team is subscribed to branch lp:qtubuntu-camera.



More information about the Ubuntu-reviews mailing list