DSCaptureFormat.cxx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* Copyright (C) 2011-2013 Doubango Telecom <http://www.doubango.org>
  2. *
  3. * This file is part of Open Source Doubango Framework.
  4. *
  5. * DOUBANGO is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * DOUBANGO is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with DOUBANGO.
  17. */
  18. #include "internals/DSCaptureFormat.h"
  19. #include <uuids.h>
  20. int DSCaptureFormat::getMatchScore(int w, int h)
  21. {
  22. int factor;
  23. if ((w == width) && (h = height)) {
  24. factor = 100;
  25. }
  26. else if ((w > this->width) && (h > this->height)) {
  27. factor = 0;
  28. }
  29. else {
  30. factor = (50 * w) / this->width + (50 * h) / this->height;
  31. }
  32. if (isRGB()) {
  33. factor *= 2;
  34. }
  35. return factor;
  36. }
  37. bool DSCaptureFormat::isRGB()
  38. {
  39. // Order used is optimized for most used RGB types
  40. if (IsEqualGUID(this->chroma, MEDIASUBTYPE_RGB32)) {
  41. return true;
  42. }
  43. if (IsEqualGUID(this->chroma, MEDIASUBTYPE_RGB24)) {
  44. return true;
  45. }
  46. if (IsEqualGUID(this->chroma, MEDIASUBTYPE_RGB565)) {
  47. return true;
  48. }
  49. if (IsEqualGUID(this->chroma, MEDIASUBTYPE_RGB555)) {
  50. return true;
  51. }
  52. if (IsEqualGUID(this->chroma, MEDIASUBTYPE_RGB8)) {
  53. return true;
  54. }
  55. if (IsEqualGUID(this->chroma, MEDIASUBTYPE_RGB4)) {
  56. return true;
  57. }
  58. if (IsEqualGUID(this->chroma, MEDIASUBTYPE_RGB1)) {
  59. return true;
  60. }
  61. #ifndef _WIN32_WCE
  62. if (IsEqualGUID(this->chroma, MEDIASUBTYPE_ARGB32)) {
  63. return true;
  64. }
  65. if (IsEqualGUID(this->chroma, MEDIASUBTYPE_ARGB4444)) {
  66. return true;
  67. }
  68. if (IsEqualGUID(this->chroma, MEDIASUBTYPE_ARGB1555)) {
  69. return true;
  70. }
  71. #endif
  72. return false;
  73. }