qtmobility/plugins/multimedia/directshow/player/directshowmediatype.cpp
changeset 4 90517678cc4f
parent 1 2b40d63a9c3d
child 11 06b8e2af4411
equal deleted inserted replaced
1:2b40d63a9c3d 4:90517678cc4f
    49         GUID mediaType;
    49         GUID mediaType;
    50     };
    50     };
    51 
    51 
    52     static const TypeLookup qt_typeLookup[] =
    52     static const TypeLookup qt_typeLookup[] =
    53     {
    53     {
    54         { QVideoFrame::Format_RGB24, MEDIASUBTYPE_RGB24 },
    54         { QVideoFrame::Format_RGB32,   /*MEDIASUBTYPE_RGB32*/  {0xe436eb7e, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}} },
    55         { QVideoFrame::Format_RGB32, MEDIASUBTYPE_RGB32 },
    55         { QVideoFrame::Format_BGR24,   /*MEDIASUBTYPE_RGB24*/  {0xe436eb7d, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}} },
    56         { QVideoFrame::Format_YV12, MEDIASUBTYPE_YV12 }
    56         { QVideoFrame::Format_RGB565,  /*MEDIASUBTYPE_RGB565*/ {0xe436eb7b, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}} },
       
    57         { QVideoFrame::Format_RGB555,  /*MEDIASUBTYPE_RGB555*/ {0xe436eb7c, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}} },
       
    58         { QVideoFrame::Format_AYUV444, /*MEDIASUBTYPE_AYUV*/   {0x56555941, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} },
       
    59         { QVideoFrame::Format_YUYV,    /*MEDIASUBTYPE_YUY2*/   {0x32595559, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} },
       
    60         { QVideoFrame::Format_UYVY,    /*MEDIASUBTYPE_UYVY*/   {0x59565955, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} },
       
    61         { QVideoFrame::Format_IMC1,    /*MEDIASUBTYPE_IMC1*/   {0x31434D49, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} },
       
    62         { QVideoFrame::Format_IMC2,    /*MEDIASUBTYPE_IMC2*/   {0x32434D49, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} },
       
    63         { QVideoFrame::Format_IMC3,    /*MEDIASUBTYPE_IMC3*/   {0x33434D49, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} },
       
    64         { QVideoFrame::Format_IMC4,    /*MEDIASUBTYPE_IMC4*/   {0x34434D49, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} },
       
    65         { QVideoFrame::Format_YV12,    /*MEDIASUBTYPE_YV12*/   {0x32315659, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} },
       
    66         { QVideoFrame::Format_NV12,    /*MEDIASUBTYPE_NV12*/   {0x3231564E, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} },
       
    67         { QVideoFrame::Format_YUV420P, /*MEDIASUBTYPE_IYUV*/   {0x56555949, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} }
    57     };
    68     };
    58 }
    69 }
    59 
    70 
    60 void DirectShowMediaType::copy(AM_MEDIA_TYPE *target, const AM_MEDIA_TYPE &source)
    71 void DirectShowMediaType::copy(AM_MEDIA_TYPE *target, const AM_MEDIA_TYPE &source)
    61 {
    72 {
    86 }
    97 }
    87 
    98 
    88 
    99 
    89 GUID DirectShowMediaType::convertPixelFormat(QVideoFrame::PixelFormat format)
   100 GUID DirectShowMediaType::convertPixelFormat(QVideoFrame::PixelFormat format)
    90 {
   101 {
       
   102     // MEDIASUBTYPE_None;
       
   103     static const GUID none = {
       
   104         0xe436eb8e, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70} };
       
   105 
    91     const int count = sizeof(qt_typeLookup) / sizeof(TypeLookup);
   106     const int count = sizeof(qt_typeLookup) / sizeof(TypeLookup);
    92 
   107 
    93     for (int i = 0; i < count; ++i)
   108     for (int i = 0; i < count; ++i)
    94         if (qt_typeLookup[i].pixelFormat == format)
   109         if (qt_typeLookup[i].pixelFormat == format)
    95             return qt_typeLookup[i].mediaType;
   110             return qt_typeLookup[i].mediaType;
    96     return MEDIASUBTYPE_None;
   111     return none;
    97 }
   112 }
    98 
   113 
    99 QVideoSurfaceFormat DirectShowMediaType::formatFromType(const AM_MEDIA_TYPE &type)
   114 QVideoSurfaceFormat DirectShowMediaType::formatFromType(const AM_MEDIA_TYPE &type)
   100 {
   115 {
   101     const int count = sizeof(qt_typeLookup) / sizeof(TypeLookup);
   116     const int count = sizeof(qt_typeLookup) / sizeof(TypeLookup);
   139 }
   154 }
   140 
   155 
   141 int DirectShowMediaType::bytesPerLine(const QVideoSurfaceFormat &format)
   156 int DirectShowMediaType::bytesPerLine(const QVideoSurfaceFormat &format)
   142 {
   157 {
   143     switch (format.pixelFormat()) {
   158     switch (format.pixelFormat()) {
       
   159     // 32 bpp packed formats.
       
   160     case QVideoFrame::Format_RGB32:
       
   161     case QVideoFrame::Format_AYUV444:
       
   162         return format.frameWidth() * 4;
       
   163     // 24 bpp packed formats.
   144     case QVideoFrame::Format_RGB24:
   164     case QVideoFrame::Format_RGB24:
   145         return format.frameWidth() * 4 + 3 - format.frameWidth() % 4;
   165         return format.frameWidth() * 3 + 3 - format.frameWidth() % 4;
   146     case QVideoFrame::Format_RGB32:
   166     // 16 bpp packed formats.
   147         return format.frameWidth() * 4;
   167     case QVideoFrame::Format_RGB565:
       
   168     case QVideoFrame::Format_RGB555:
       
   169     case QVideoFrame::Format_YUYV:
       
   170     case QVideoFrame::Format_UYVY:
       
   171         return format.frameWidth() * 2 + 3 - format.frameWidth() % 4;
       
   172     // Planar formats.
       
   173     case QVideoFrame::Format_IMC1:
       
   174     case QVideoFrame::Format_IMC2:
       
   175     case QVideoFrame::Format_IMC3:
       
   176     case QVideoFrame::Format_IMC4:
   148     case QVideoFrame::Format_YV12:
   177     case QVideoFrame::Format_YV12:
       
   178     case QVideoFrame::Format_NV12:
       
   179     case QVideoFrame::Format_YUV420P:
   149         return format.frameWidth() + 3 - format.frameWidth() % 4;
   180         return format.frameWidth() + 3 - format.frameWidth() % 4;
   150     default:
   181     default:
   151         return 0;
   182         return 0;
   152     }
   183     }
   153 }
   184 }