forked from mirrors/nixpkgs
mp4v2: Add patches from Handbrake project
mp4v2 seems abandoned upstream. Patches: - A00: Add API call for subpicture subtitles - A01: Fix divide by zero - A02: Give a meaningfull error when hitting 4GB limit - P00: Fix compilation with mingw32
This commit is contained in:
parent
ccb065a08c
commit
d1ebc1a2b3
142
pkgs/development/libraries/mp4v2/A00-nero-vobsub.patch
Normal file
142
pkgs/development/libraries/mp4v2/A00-nero-vobsub.patch
Normal file
|
@ -0,0 +1,142 @@
|
|||
diff -Naur mp4v2-trunk-r355/include/mp4v2/general.h mp4v2-trunk-r355/include/mp4v2/general.h
|
||||
--- mp4v2-trunk-r355/include/mp4v2/general.h 2009-05-23 06:09:58.000000000 -0700
|
||||
+++ mp4v2-trunk-r355/include/mp4v2/general.h 2010-05-23 14:22:21.949288657 -0700
|
||||
@@ -75,6 +75,7 @@
|
||||
#define MP4_CNTL_TRACK_TYPE "cntl" /**< Constant: control track. */
|
||||
#define MP4_TEXT_TRACK_TYPE "text" /**< Constant: text track. */
|
||||
#define MP4_SUBTITLE_TRACK_TYPE "sbtl" /**< Constant: subtitle track. */
|
||||
+#define MP4_SUBPIC_TRACK_TYPE "subp" /**< Constant: subtitle track. */
|
||||
/*
|
||||
* This second set of track types should be created
|
||||
* via MP4AddSystemsTrack(type)
|
||||
diff -Naur mp4v2-trunk-r355/include/mp4v2/track.h mp4v2-trunk-r355/include/mp4v2/track.h
|
||||
--- mp4v2-trunk-r355/include/mp4v2/track.h 2009-05-23 06:21:49.000000000 -0700
|
||||
+++ mp4v2-trunk-r355/include/mp4v2/track.h 2010-05-23 15:43:47.249286008 -0700
|
||||
@@ -310,6 +310,13 @@
|
||||
uint16_t height );
|
||||
|
||||
MP4V2_EXPORT
|
||||
+MP4TrackId MP4AddSubpicTrack(
|
||||
+ MP4FileHandle hFile,
|
||||
+ uint32_t timescale,
|
||||
+ uint16_t width,
|
||||
+ uint16_t height );
|
||||
+
|
||||
+MP4V2_EXPORT
|
||||
MP4TrackId MP4AddPixelAspectRatio(
|
||||
MP4FileHandle hFile,
|
||||
MP4TrackId refTrackId,
|
||||
diff -Naur mp4v2-trunk-r355/src/descriptors.h mp4v2-trunk-r355/src/descriptors.h
|
||||
--- mp4v2-trunk-r355/src/descriptors.h 2009-05-20 19:52:32.000000000 -0700
|
||||
+++ mp4v2-trunk-r355/src/descriptors.h 2010-05-23 16:29:34.800935677 -0700
|
||||
@@ -119,6 +119,7 @@
|
||||
// ES objectTypeId
|
||||
const uint8_t MP4SystemsV1ObjectType = 0x01;
|
||||
const uint8_t MP4SystemsV2ObjectType = 0x02;
|
||||
+const uint8_t MP4SubpicObjectType = 0xe0;
|
||||
|
||||
// ES streamType
|
||||
const uint8_t MP4ObjectDescriptionStreamType = 0x01;
|
||||
@@ -131,6 +132,7 @@
|
||||
const uint8_t MP4OCIStreamType = 0x08;
|
||||
const uint8_t MP4MPEGJStreamType = 0x09;
|
||||
const uint8_t MP4UserPrivateStreamType = 0x20;
|
||||
+const uint8_t MP4NeroSubpicStreamType = 0x38;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
diff -Naur mp4v2-trunk-r355/src/mp4.cpp mp4v2-trunk-r355/src/mp4.cpp
|
||||
--- mp4v2-trunk-r355/src/mp4.cpp 2009-05-23 06:29:37.000000000 -0700
|
||||
+++ mp4v2-trunk-r355/src/mp4.cpp 2010-05-23 15:45:28.852222074 -0700
|
||||
@@ -1174,6 +1174,23 @@
|
||||
return MP4_INVALID_TRACK_ID;
|
||||
}
|
||||
|
||||
+ MP4TrackId MP4AddSubpicTrack(MP4FileHandle hFile,
|
||||
+ uint32_t timescale,
|
||||
+ uint16_t width,
|
||||
+ uint16_t height)
|
||||
+ {
|
||||
+ if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
|
||||
+ try {
|
||||
+ return ((MP4File*)hFile)->AddSubpicTrack(timescale, width, height);
|
||||
+ }
|
||||
+ catch (MP4Error* e) {
|
||||
+ PRINT_ERROR(e);
|
||||
+ delete e;
|
||||
+ }
|
||||
+ }
|
||||
+ return MP4_INVALID_TRACK_ID;
|
||||
+ }
|
||||
+
|
||||
MP4TrackId MP4AddChapterTextTrack(
|
||||
MP4FileHandle hFile, MP4TrackId refTrackId, uint32_t timescale)
|
||||
{
|
||||
diff -Naur mp4v2-trunk-r355/src/mp4file.cpp mp4v2-trunk-r355/src/mp4file.cpp
|
||||
--- mp4v2-trunk-r355/src/mp4file.cpp 2009-05-26 19:34:56.000000000 -0700
|
||||
+++ mp4v2-trunk-r355/src/mp4file.cpp 2010-05-23 16:32:52.654220633 -0700
|
||||
@@ -2095,6 +2095,50 @@
|
||||
return trackId;
|
||||
}
|
||||
|
||||
+MP4TrackId MP4File::AddSubpicTrack(uint32_t timescale,
|
||||
+ uint16_t width,
|
||||
+ uint16_t height)
|
||||
+{
|
||||
+ MP4TrackId trackId =
|
||||
+ AddTrack(MP4_SUBPIC_TRACK_TYPE, timescale);
|
||||
+
|
||||
+ InsertChildAtom(MakeTrackName(trackId, "mdia.minf"), "nmhd", 0);
|
||||
+
|
||||
+ (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), "mp4s");
|
||||
+
|
||||
+ SetTrackFloatProperty(trackId, "tkhd.width", width);
|
||||
+ SetTrackFloatProperty(trackId, "tkhd.height", height);
|
||||
+ SetTrackIntegerProperty(trackId, "tkhd.layer", 0);
|
||||
+
|
||||
+ // stsd is a unique beast in that it has a count of the number
|
||||
+ // of child atoms that needs to be incremented after we add the mp4s atom
|
||||
+ MP4Integer32Property* pStsdCountProperty;
|
||||
+ FindIntegerProperty(
|
||||
+ MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"),
|
||||
+ (MP4Property**)&pStsdCountProperty);
|
||||
+ pStsdCountProperty->IncrementValue();
|
||||
+
|
||||
+ SetTrackIntegerProperty(trackId,
|
||||
+ "mdia.minf.stbl.stsd.mp4s.esds.ESID",
|
||||
+#if 0
|
||||
+ // note - for a file, these values need to
|
||||
+ // be 0 - wmay - 04/16/2003
|
||||
+ trackId
|
||||
+#else
|
||||
+ 0
|
||||
+#endif
|
||||
+ );
|
||||
+
|
||||
+ SetTrackIntegerProperty(trackId,
|
||||
+ "mdia.minf.stbl.stsd.mp4s.esds.decConfigDescr.objectTypeId",
|
||||
+ MP4SubpicObjectType);
|
||||
+
|
||||
+ SetTrackIntegerProperty(trackId,
|
||||
+ "mdia.minf.stbl.stsd.mp4s.esds.decConfigDescr.streamType",
|
||||
+ MP4NeroSubpicStreamType);
|
||||
+ return trackId;
|
||||
+}
|
||||
+
|
||||
MP4TrackId MP4File::AddChapterTextTrack(MP4TrackId refTrackId, uint32_t timescale)
|
||||
{
|
||||
// validate reference track id
|
||||
diff -Naur mp4v2-trunk-r355/src/mp4file.h mp4v2-trunk-r355/src/mp4file.h
|
||||
--- mp4v2-trunk-r355/src/mp4file.h 2009-05-23 06:29:37.000000000 -0700
|
||||
+++ mp4v2-trunk-r355/src/mp4file.h 2010-05-23 15:44:57.568026299 -0700
|
||||
@@ -388,6 +388,10 @@
|
||||
uint16_t width,
|
||||
uint16_t height);
|
||||
|
||||
+ MP4TrackId AddSubpicTrack(uint32_t timescale,
|
||||
+ uint16_t width,
|
||||
+ uint16_t height);
|
||||
+
|
||||
MP4TrackId AddPixelAspectRatio(MP4TrackId trackId, uint32_t hSpacing, uint32_t vSpacing);
|
||||
MP4TrackId AddColr(MP4TrackId trackId, uint16_t pri, uint16_t tran, uint16_t mat);
|
||||
|
22
pkgs/development/libraries/mp4v2/A01-divide-zero.patch
Normal file
22
pkgs/development/libraries/mp4v2/A01-divide-zero.patch
Normal file
|
@ -0,0 +1,22 @@
|
|||
--- mp4v2-r355/src/mp4track.cpp 2012-01-05 15:44:29.000000000 +0100
|
||||
+++ mp4v2-r355/src/mp4track.cpp 2012-01-05 15:47:34.000000000 +0100
|
||||
@@ -819,13 +819,14 @@
|
||||
(thisSecStart + timeScale) - lastSampleTime;
|
||||
// calculate the duration of the last sample
|
||||
MP4Duration lastSampleDur = sampleTime - lastSampleTime;
|
||||
- uint32_t overflow_bytes;
|
||||
// now, calculate the number of bytes we overflowed. Round up.
|
||||
- overflow_bytes =
|
||||
- ((lastSampleSize * overflow_dur) + (lastSampleDur - 1)) / lastSampleDur;
|
||||
+ if( lastSampleDur > 0 ) {
|
||||
+ uint32_t overflow_bytes = 0;
|
||||
+ overflow_bytes = ((lastSampleSize * overflow_dur) + (lastSampleDur - 1)) / lastSampleDur;
|
||||
|
||||
- if (bytesThisSec - overflow_bytes > maxBytesPerSec) {
|
||||
- maxBytesPerSec = bytesThisSec - overflow_bytes;
|
||||
+ if (bytesThisSec - overflow_bytes > maxBytesPerSec) {
|
||||
+ maxBytesPerSec = bytesThisSec - overflow_bytes;
|
||||
+ }
|
||||
}
|
||||
|
||||
// now adjust the values for this sample. Remove the bytes
|
|
@ -0,0 +1,14 @@
|
|||
diff -Naur mp4v2-trunk-r355/src/mp4atom.cpp mp4v2-trunk-r355/src/mp4atom.cpp
|
||||
--- mp4v2-trunk-r355/src/mp4atom.cpp 2012-02-21 19:40:03.000000000 +0100
|
||||
+++ mp4v2-trunk-r355/src/mp4atom.cpp 2012-02-21 19:36:38.000000000 +0100
|
||||
@@ -543,6 +543,10 @@
|
||||
m_pFile->SetPosition(m_start + 8);
|
||||
m_pFile->WriteUInt64(m_size);
|
||||
} else {
|
||||
+ if (!(m_size <= (uint64_t)0xFFFFFFFF)) {
|
||||
+ // Let the user know what the following assert is all about
|
||||
+ fprintf(stderr, "MP4ERROR: File size exceeded 4 GB; output unplayable. Enable \"Large file size\" to fix it.\n");
|
||||
+ }
|
||||
ASSERT(m_size <= (uint64_t)0xFFFFFFFF);
|
||||
m_pFile->SetPosition(m_start);
|
||||
m_pFile->WriteUInt32(m_size);
|
11
pkgs/development/libraries/mp4v2/P00-mingw-dllimport.patch
Normal file
11
pkgs/development/libraries/mp4v2/P00-mingw-dllimport.patch
Normal file
|
@ -0,0 +1,11 @@
|
|||
--- mp4v2-trunk-r355/include/mp4v2/platform.h 2009-05-20 19:52:26.000000000 -0700
|
||||
+++ xxx/include/mp4v2/platform.h 2010-09-11 09:36:20.881523832 -0700
|
||||
@@ -24,7 +24,7 @@
|
||||
#if defined( _WIN32 ) || defined( __MINGW32__ )
|
||||
# if defined( _WINDLL ) || defined( DLL_EXPORT )
|
||||
# define MP4V2_EXPORT __declspec(dllexport)
|
||||
-# elif defined( _DLL ) || defined( DLL_IMPORT )
|
||||
+# elif defined( DLL_IMPORT )
|
||||
# define MP4V2_EXPORT __declspec(dllimport)
|
||||
# else
|
||||
# define MP4V2_EXPORT
|
|
@ -1,13 +1,19 @@
|
|||
{ stdenv, fetchurl }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
name = "mp4v2-1.9.1";
|
||||
name = "mp4v2-1.9.1p4";
|
||||
|
||||
src = fetchurl {
|
||||
url = "http://mp4v2.googlecode.com/files/${name}.tar.bz2";
|
||||
sha256 = "1d73qbi0faqad3bpmjfr4kk0mfmqpl1f43ysrx4gq9i3mfp1qf2w";
|
||||
};
|
||||
|
||||
# From Handbrake
|
||||
# mp4v2 doesn't seem to be actively maintained any more :-/
|
||||
patches = [
|
||||
./A00-nero-vobsub.patch ./A01-divide-zero.patch ./A02-meaningful-4gb-warning.patch
|
||||
./P00-mingw-dllimport.patch
|
||||
];
|
||||
# `faac' expects `mp4.h'.
|
||||
postInstall = "ln -s mp4v2/mp4v2.h $out/include/mp4.h";
|
||||
|
||||
|
|
Loading…
Reference in a new issue