OSDN Git Service

fix video size.
authorNoumi Akira <noumiakira@users.sourceforge.jp>
Fri, 10 Jul 2009 05:42:54 +0000 (14:42 +0900)
committerNoumi Akira <noumiakira@users.sourceforge.jp>
Fri, 10 Jul 2009 05:42:54 +0000 (14:42 +0900)
Lib/QDecoder/QDecoder.vcproj
Lib/QDecoder/QFilter.h
Lib/QDecoder/QImageConverter.h
Lib/QDecoder/QMediaType.h
Lib/QDecoder/QPinVideo.h
Lib/QDecoder/QReader.h
Lib/QDecoder/QStreamer.h

index 343b6ab..f6bc2a8 100644 (file)
@@ -41,7 +41,7 @@
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories="../QMatroska;../QTheora;../QVorbis"
+                               AdditionalIncludeDirectories="../QMatroska;../QTheoraEx;../QVorbis"
                                PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
                                MinimalRebuild="true"
                                BasicRuntimeChecks="3"
                                Name="VCCLCompilerTool"
                                Optimization="2"
                                EnableIntrinsicFunctions="true"
-                               AdditionalIncludeDirectories="../QMatroska;../QTheora;../QVorbis"
+                               AdditionalIncludeDirectories="../QMatroska;../QTheoraEx;../QVorbis"
                                PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
                                RuntimeLibrary="2"
                                EnableFunctionLevelLinking="true"
index 54e428f..d112dec 100644 (file)
@@ -159,11 +159,10 @@ public:
 
                const QM_Track_t* vtrack = m_Reader.GetVideoTrack();
                if (vtrack != 0) {
-                       const QM_TrackVideo_t* v = vtrack->Video;
+                       const QT_Format_t* v = m_Reader.GetVideoFormat();
 
                        m_pPinVideo->SetupVideoFormat(
-                               v->PixelWidth,
-                               v->PixelHeight,
+                               v,
                                vtrack->TrackDuration);
                }
 
@@ -670,7 +669,8 @@ private:
                        hRslt = m_pStreamer->SetupVideo(
                                m_pPinVideo->GetMemInputPin(),
                                m_pPinVideo->GetMemAllocator(),
-                               m_pPinVideo->GetVideoHeader());
+                               m_pPinVideo->GetVideoHeader(),
+                               m_Reader.GetVideoFormat());
                        if (FAILED(hRslt)) {
                                return hRslt;
                        }
index 1ad0f11..2e211ac 100644 (file)
@@ -49,21 +49,21 @@ public:
        }
 
        void Setup(
-               QIType      type,
-               INT32       stride,
-               INT32       rasters,
-               const RECT* rc)
+               QIType             type,
+               INT32              stride,
+               INT32              rasters,
+               const QT_Format_t* fmt)
        {
                m_Type = type;
 
                m_Stride  = stride;
                m_Rasters = (rasters >= 0) ? rasters : -rasters;
 
-               m_x = rc->left;
-               m_y = rc->top;
+               m_x = fmt->PX;
+               m_y = fmt->PY;
 
-               m_cx = rc->right  - rc->left;
-               m_cy = rc->bottom - rc->top;
+               m_cx = fmt->PW;
+               m_cy = fmt->PH;
 
                switch (type) {
                case IT_YUY2:
index a93c6ab..754c842 100644 (file)
@@ -143,7 +143,7 @@ struct QMediaType : public AM_MEDIA_TYPE {
                VID_Count
        };
 
-       void SetVideo(INT32 id, INT32 cx, INT32 cy, INT64 rate)
+       void SetVideo(INT32 id, const QT_Format_t* fmt, INT64 rate)
        {
                majortype = MEDIATYPE_Video;
 
@@ -157,6 +157,9 @@ struct QMediaType : public AM_MEDIA_TYPE {
 
                v.AvgTimePerFrame = rate;
 
+               INT32 cx = fmt->PW;
+               INT32 cy = fmt->PH;
+
                INT32 g = gcd(cx, cy);
 
                v.dwPictAspectRatioX = cx / g;
index ca8a997..cadad48 100644 (file)
@@ -63,16 +63,15 @@ public:
        /* */
 
        void SetupVideoFormat(
-               INT32 cx,
-               INT32 cy,
-               INT64 rate)
+               const QT_Format_t* fmt,
+               INT64              rate)
        {
                SetupMediaTypes(MTYPES);
 
                QMediaType* mt = MediaTypes();
 
-               mt[MI_YUY2].SetVideo(QMediaType::VID_YUY2, cx, cy, rate);
-               mt[MI_YV12].SetVideo(QMediaType::VID_YV12, cx, cy, rate);
+               mt[MI_YUY2].SetVideo(QMediaType::VID_YUY2, fmt, rate);
+               mt[MI_YV12].SetVideo(QMediaType::VID_YV12, fmt, rate);
        }
 
        const VIDEOINFOHEADER2* GetVideoHeader()
@@ -124,6 +123,7 @@ public:
                        const BITMAPINFOHEADER* bmi = &(v->bmiHeader);
 
                        ATLTRACE("SIZE: %d, %d\n", bmi->biWidth, bmi->biHeight);
+                       ATLTRACE("SRCR: %d, %d - %d, %d\n", v->rcSource.left, v->rcSource.top, v->rcSource.right, v->rcSource.bottom);
 
                        memcpy(&m_VideoHeader, v, sizeof(VIDEOINFOHEADER2));
 
index 74ce286..d4d3851 100644 (file)
@@ -28,6 +28,8 @@ class QReader {
 
        QVorbisDecoder_t* m_adecoder;
 
+       QT_Format_t m_vf;
+
        INT64 m_scale;
        INT64 m_vrate;
 
@@ -56,6 +58,7 @@ public:
                m_bVideoEOS(false),  m_bAudioEOS(false),
                m_StartPos(0), m_EndPos(-1)
        {
+               memset(&m_vf, 0, sizeof(m_vf));
        }
 
        ~QReader()
@@ -87,6 +90,11 @@ public:
                return m_atrack;
        }
 
+       const QT_Format_t* GetVideoFormat()
+       {
+               return &m_vf;
+       }
+
        /* */
 
        bool Open(LPCWSTR path)
@@ -155,6 +163,10 @@ public:
                                return false;
                        }
 
+                       if (!QT_GetFormatSetup(m_vsetup, &m_vf)) {
+                               return false;
+                       }
+
                        m_vdecoder = QT_CreateDecoder();
                        if (m_vdecoder == 0) {
                                return false;
index 0f3deb6..dd2a9b5 100644 (file)
@@ -147,7 +147,8 @@ public:
        HRESULT SetupVideo(
                IMemInputPin*           pin,
                IMemAllocator*          alloc,
-               const VIDEOINFOHEADER2* v)
+               const VIDEOINFOHEADER2* v,
+               const QT_Format_t*      fmt)
        {
                if (pin == 0) {
                        return S_OK;
@@ -164,28 +165,19 @@ public:
 
                const BITMAPINFOHEADER* bmi = &(v->bmiHeader);
 
-               RECT rc = v->rcSource;
-               if (rc.right == 0 && rc.bottom == 0 &&
-                       rc.left  == 0 && rc.top    == 0) {
-                       rc.right  = bmi->biWidth;
-                       rc.bottom = bmi->biHeight;
-
-                       if (rc.bottom < 0) rc.bottom = -rc.bottom;
-               }
-
                if (bmi->biCompression == MAKEFOURCC('Y', 'U', 'Y', '2')) {
                        m_Converter.Setup(
                                IT_YUY2,
                                bmi->biWidth * 2,
                                bmi->biHeight,
-                               &rc);
+                               fmt);
 
                } else if (bmi->biCompression == MAKEFOURCC('Y', 'V', '1', '2')) {
                        m_Converter.Setup(
                                IT_YV12,
                                bmi->biWidth,
                                bmi->biHeight,
-                               &rc);
+                               fmt);
                }
 
                return S_OK;