Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bb784236 authored by Patrik2 Carlsson's avatar Patrik2 Carlsson Committed by Steve Kondik
Browse files

Support MPEG4 and H263 FourCC types in Matroska files

Handles MPEG4 and H263 content with FourCC header in Matroska files
based on how these are handled in the AVI parser.

Also adding placehoders for DivX.

Change-Id: I38b2c2fd429b6e4810a7b118bf60823d502320ae
parent a6027112
Loading
Loading
Loading
Loading
+57 −0
Original line number Diff line number Diff line
@@ -37,6 +37,20 @@

namespace android {

typedef struct {
    uint32_t biSize;
    uint32_t biWidth;
    uint32_t biHeight;
    uint16_t biPlanes;
    uint16_t biBitCount;
    uint32_t biCompression;
    uint32_t biSizeImage;
    uint32_t biXPelsPerMeter;
    uint32_t biYPelsPerMeter;
    uint32_t biClrUsed;
    uint32_t biClrImportant;
} BITMAPINFOHEADER;

struct DataSourceReader : public mkvparser::IMkvReader {
    DataSourceReader(const sp<DataSource> &source)
        : mSource(source) {
@@ -1011,6 +1025,49 @@ void MatroskaExtractor::addTracks() {
                    meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_VP8);
                } else if (!strcmp("V_VP9", codecID)) {
                    meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_VP9);
                } else if (!strcmp("V_MS/VFW/FOURCC", codecID)) {
                    if (codecPrivateSize >= sizeof(BITMAPINFOHEADER)) {
                        char *fourcc = (char *) &((BITMAPINFOHEADER *) codecPrivate)->biCompression;

                        switch (FOURCC(fourcc[0], fourcc[1], fourcc[2], fourcc[3])) {
                        case 'XVID':
                        case 'xvid':
                        case 'FMP4':
                        case 'fmp4':
                        case 'MP4V':
                        case 'mp4v':
                            meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_MPEG4);
                            break;
                        case 'H263':
                        case 'h263':
                            meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_H263);
                            break;
                        case 'DIV3':
                        case 'div3':
                        case 'DIV4':
                        case 'div4':
                            ALOGW("DivX 3.11 codec not supported");
                            continue;
                        case 'DIVX':
                        case 'divx':
                            ALOGW("DivX 4 codec not supported");
                            continue;
                        case 'DX50':
                        case 'dx50':
                            ALOGW("DivX 5 codec not supported");
                            continue;
                        case 'MP42':
                        default:
                            ALOGW("fourcc id: %hhX%hhX%hhX%hhX is not supported\n",
                                    fourcc[0], fourcc[1], fourcc[2], fourcc[3]);
                            continue;
                        }

                        ALOGV("fourcc id: %.4s", fourcc);
                    } else {
                        ALOGW("fourcc size: %d is not supported\n", codecPrivateSize);
                        continue;
                    }
                } else {
                    ALOGW("%s is not supported.", codecID);
                    continue;