diff options
author | Aleksoid <aleksoid@users.sourceforge.net> | 2011-05-05 14:49:58 +0400 |
---|---|---|
committer | Aleksoid <aleksoid@users.sourceforge.net> | 2011-05-05 14:49:58 +0400 |
commit | 7dc0a565fbb7d98d5883115205f742b7509bacf3 (patch) | |
tree | 770aa12e4ed0144bd3c35df5178c767b89d75ed8 /src/filters/parser/MP4Splitter | |
parent | bdff8b3d82da78bdaea6b18e8e2eb8cb254b54d6 (diff) |
Fix : MP4Splitter read correct Aspect Ratio from video field header, ticket #285;
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@3084 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/parser/MP4Splitter')
8 files changed, 107 insertions, 2 deletions
diff --git a/src/filters/parser/MP4Splitter/AP4/Core/Ap4Atom.h b/src/filters/parser/MP4Splitter/AP4/Core/Ap4Atom.h index 69339653d..cd3941852 100644 --- a/src/filters/parser/MP4Splitter/AP4/Core/Ap4Atom.h +++ b/src/filters/parser/MP4Splitter/AP4/Core/Ap4Atom.h @@ -305,6 +305,8 @@ const AP4_Atom::Type AP4_ATOM_TYPE_3IV2 = AP4_ATOM_TYPE('3','I','V','2'); const AP4_Atom::Type AP4_ATOM_TYPE_IV32 = AP4_ATOM_TYPE('I','V','3','2');
const AP4_Atom::Type AP4_ATOM_TYPE_VP31 = AP4_ATOM_TYPE('V','P','3','1');
const AP4_Atom::Type AP4_ATOM_TYPE_YV12 = AP4_ATOM_TYPE('y','v','1','2');
+
+const AP4_Atom::Type AP4_ATOM_TYPE_PASP = AP4_ATOM_TYPE('p','a','s','p');
/*----------------------------------------------------------------------
| AP4_AtomListInspector
+---------------------------------------------------------------------*/
diff --git a/src/filters/parser/MP4Splitter/AP4/Core/Ap4AtomFactory.cpp b/src/filters/parser/MP4Splitter/AP4/Core/Ap4AtomFactory.cpp index e90e66294..304ad443b 100644 --- a/src/filters/parser/MP4Splitter/AP4/Core/Ap4AtomFactory.cpp +++ b/src/filters/parser/MP4Splitter/AP4/Core/Ap4AtomFactory.cpp @@ -70,6 +70,7 @@ #include "Ap4DcomAtom.h"
#include "Ap4CmvdAtom.h"
#include "Ap4EndaAtom.h"
+#include "Ap4PaspAtom.h"
/*----------------------------------------------------------------------
| class variables
+---------------------------------------------------------------------*/
@@ -461,6 +462,10 @@ AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream& stream, atom = DNew AP4_EndaAtom(size, stream);
break;
+ case AP4_ATOM_TYPE_PASP:
+ atom = DNew AP4_PaspAtom(size, stream);
+ break;
+
default:
if(parent && parent->GetType() == AP4_ATOM_TYPE_STSD && (type & 0xffff0000) == AP4_ATOM_TYPE('m', 's', 0, 0))
diff --git a/src/filters/parser/MP4Splitter/AP4/Core/Ap4PaspAtom.cpp b/src/filters/parser/MP4Splitter/AP4/Core/Ap4PaspAtom.cpp new file mode 100644 index 000000000..ba140a524 --- /dev/null +++ b/src/filters/parser/MP4Splitter/AP4/Core/Ap4PaspAtom.cpp @@ -0,0 +1,26 @@ +/*****************************************************************
+|
+| AP4 - pasp Atom
+|
+| Copyright 2011 Aleksoid1978
+|
+ ****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+
+#include "Ap4PaspAtom.h"
+
+/*----------------------------------------------------------------------
+| AP4_PaspAtom::AP4_PaspAtom
++---------------------------------------------------------------------*/
+
+AP4_PaspAtom::AP4_PaspAtom(AP4_Size size,
+ AP4_ByteStream& stream)
+ : AP4_Atom(AP4_ATOM_TYPE_PASP)
+{
+ size -= AP4_ATOM_HEADER_SIZE;
+ stream.ReadUI32(m_num);
+ stream.ReadUI32(m_den);
+}
diff --git a/src/filters/parser/MP4Splitter/AP4/Core/Ap4PaspAtom.h b/src/filters/parser/MP4Splitter/AP4/Core/Ap4PaspAtom.h new file mode 100644 index 000000000..8947ac79b --- /dev/null +++ b/src/filters/parser/MP4Splitter/AP4/Core/Ap4PaspAtom.h @@ -0,0 +1,41 @@ +/*****************************************************************
+|
+| AP4 - pasp Atom
+|
+| Copyright 2011 Aleksoid1978
+|
+ ****************************************************************/
+
+#ifndef _AP4_PASP_ATOM_H_
+#define _AP4_PASP_ATOM_H_
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "Ap4Atom.h"
+#include "Ap4Types.h"
+#include "Ap4Array.h"
+#include "Ap4DataBuffer.h"
+
+/*----------------------------------------------------------------------
+| AP4_PaspAtom
++---------------------------------------------------------------------*/
+
+class AP4_PaspAtom : public AP4_Atom
+{
+public:
+ AP4_PaspAtom(AP4_Size size,
+ AP4_ByteStream& stream);
+
+ AP4_Result WriteFields(AP4_ByteStream& stream) { return AP4_FAILURE; }
+
+ AP4_UI32 GetNum() const { return m_num; }
+ AP4_UI32 GetDen() const { return m_den; }
+
+private:
+ AP4_UI32 m_num;
+ AP4_UI32 m_den;
+
+};
+
+#endif // _AP4_PASP_ATOM_H_
diff --git a/src/filters/parser/MP4Splitter/MP4Splitter.cpp b/src/filters/parser/MP4Splitter/MP4Splitter.cpp index ba7a1d307..812d40737 100644 --- a/src/filters/parser/MP4Splitter/MP4Splitter.cpp +++ b/src/filters/parser/MP4Splitter/MP4Splitter.cpp @@ -36,6 +36,7 @@ #include "Ap4ChplAtom.h"
#include "Ap4FtabAtom.h"
#include "Ap4DataAtom.h"
+#include "Ap4PaspAtom.h"
#ifdef REGISTER_FILTER
@@ -393,6 +394,14 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) if(!di) {
di = ∅
}
+ int num = 1;
+ int den = 1;
+ if(AP4_PaspAtom* pasp = dynamic_cast<AP4_PaspAtom*>(avc1->GetChild(AP4_ATOM_TYPE_PASP))) {
+ num = pasp->GetNum();
+ den = pasp->GetDen();
+ }
+ if(!num) num = 1;
+ if(!den) den = 1;
const AP4_Byte* data = di->GetData();
AP4_Size size = di->GetDataSize();
@@ -409,8 +418,14 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) vih->hdr.bmiHeader.biCompression = '1cva';
vih->hdr.bmiHeader.biPlanes = 1;
vih->hdr.bmiHeader.biBitCount = 24;
- vih->hdr.dwPictAspectRatioX = vih->hdr.bmiHeader.biWidth;
- vih->hdr.dwPictAspectRatioY = vih->hdr.bmiHeader.biHeight;
+
+ CSize aspect(vih->hdr.bmiHeader.biWidth * num, vih->hdr.bmiHeader.biHeight * den);
+ int lnko = LNKO(aspect.cx, aspect.cy);
+ if(lnko > 1) {
+ aspect.cx /= lnko, aspect.cy /= lnko;
+ }
+ vih->hdr.dwPictAspectRatioX = aspect.cx;
+ vih->hdr.dwPictAspectRatioY = aspect.cy;
if (item->GetData()->GetSampleCount() > 1) {
vih->hdr.AvgTimePerFrame = item->GetData()->GetDurationMs()*10000 / (item->GetData()->GetSampleCount()-1);
}
diff --git a/src/filters/parser/MP4Splitter/MP4Splitter.vcproj b/src/filters/parser/MP4Splitter/MP4Splitter.vcproj index d28a7d669..200f79410 100644 --- a/src/filters/parser/MP4Splitter/MP4Splitter.vcproj +++ b/src/filters/parser/MP4Splitter/MP4Splitter.vcproj @@ -856,6 +856,14 @@ >
</File>
<File
+ RelativePath=".\AP4\Core\Ap4PaspAtom.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\AP4\Core\Ap4PaspAtom.h"
+ >
+ </File>
+ <File
RelativePath=".\AP4\Core\Ap4DataBuffer.cpp"
>
</File>
diff --git a/src/filters/parser/MP4Splitter/MP4Splitter.vcxproj b/src/filters/parser/MP4Splitter/MP4Splitter.vcxproj index 308e70e19..cd61eda06 100644 --- a/src/filters/parser/MP4Splitter/MP4Splitter.vcxproj +++ b/src/filters/parser/MP4Splitter/MP4Splitter.vcxproj @@ -282,6 +282,7 @@ <ClCompile Include="AP4\Core\Ap4ContainerAtom.cpp" />
<ClCompile Include="AP4\Core\Ap4CttsAtom.cpp" />
<ClCompile Include="AP4\Core\Ap4DataAtom.cpp" />
+ <ClCompile Include="AP4\Core\Ap4PaspAtom.cpp" />
<ClCompile Include="AP4\Core\Ap4DataBuffer.cpp" />
<ClCompile Include="AP4\Core\Ap4DcomAtom.cpp" />
<ClCompile Include="AP4\Core\Ap4Debug.cpp" />
@@ -373,6 +374,7 @@ <ClInclude Include="AP4\Core\Ap4ContainerAtom.h" />
<ClInclude Include="AP4\Core\Ap4CttsAtom.h" />
<ClInclude Include="AP4\Core\Ap4DataAtom.h" />
+ <ClInclude Include="AP4\Core\Ap4PaspAtom.h" />
<ClInclude Include="AP4\Core\Ap4DataBuffer.h" />
<ClInclude Include="AP4\Core\Ap4DcomAtom.h" />
<ClInclude Include="AP4\Core\Ap4Debug.h" />
diff --git a/src/filters/parser/MP4Splitter/MP4Splitter.vcxproj.filters b/src/filters/parser/MP4Splitter/MP4Splitter.vcxproj.filters index 7d4bf53c8..44c1dac93 100644 --- a/src/filters/parser/MP4Splitter/MP4Splitter.vcxproj.filters +++ b/src/filters/parser/MP4Splitter/MP4Splitter.vcxproj.filters @@ -75,6 +75,9 @@ <ClCompile Include="AP4\Core\Ap4DataAtom.cpp">
<Filter>AP4\Core</Filter>
</ClCompile>
+ <ClCompile Include="AP4\Core\Ap4PaspAtom.cpp">
+ <Filter>AP4\Core</Filter>
+ </ClCompile>
<ClCompile Include="AP4\Core\Ap4DataBuffer.cpp">
<Filter>AP4\Core</Filter>
</ClCompile>
@@ -311,6 +314,9 @@ <ClInclude Include="AP4\Core\Ap4DataAtom.h">
<Filter>AP4\Core</Filter>
</ClInclude>
+ <ClInclude Include="AP4\Core\Ap4PaspAtom.h">
+ <Filter>AP4\Core</Filter>
+ </ClInclude>
<ClInclude Include="AP4\Core\Ap4DataBuffer.h">
<Filter>AP4\Core</Filter>
</ClInclude>
|