summaryrefslogtreecommitdiffstats
path: root/media/mp4
diff options
context:
space:
mode:
Diffstat (limited to 'media/mp4')
-rw-r--r--media/mp4/box_definitions.cc18
-rw-r--r--media/mp4/box_definitions.h8
-rw-r--r--media/mp4/mp4_stream_parser.cc5
3 files changed, 28 insertions, 3 deletions
diff --git a/media/mp4/box_definitions.cc b/media/mp4/box_definitions.cc
index 5d18c32..c4e14e9 100644
--- a/media/mp4/box_definitions.cc
+++ b/media/mp4/box_definitions.cc
@@ -340,6 +340,16 @@ bool AVCDecoderConfigurationRecord::Parse(BoxReader* reader) {
return true;
}
+PixelAspectRatioBox::PixelAspectRatioBox() : h_spacing(1), v_spacing(1) {}
+PixelAspectRatioBox::~PixelAspectRatioBox() {}
+FourCC PixelAspectRatioBox::BoxType() const { return FOURCC_PASP; }
+
+bool PixelAspectRatioBox::Parse(BoxReader* reader) {
+ RCHECK(reader->Read4(&h_spacing) &&
+ reader->Read4(&v_spacing));
+ return true;
+}
+
VideoSampleEntry::VideoSampleEntry()
: format(FOURCC_NULL),
data_reference_index(0),
@@ -363,6 +373,7 @@ bool VideoSampleEntry::Parse(BoxReader* reader) {
reader->SkipBytes(50));
RCHECK(reader->ScanChildren());
+ RCHECK(reader->MaybeReadChild(&pixel_aspect));
if (format == FOURCC_ENCV) {
RCHECK(reader->ReadChild(&sinf));
}
@@ -483,7 +494,12 @@ MovieExtendsHeader::~MovieExtendsHeader() {}
FourCC MovieExtendsHeader::BoxType() const { return FOURCC_MEHD; }
bool MovieExtendsHeader::Parse(BoxReader* reader) {
- RCHECK(reader->Read8(&fragment_duration));
+ RCHECK(reader->ReadFullBoxHeader());
+ if (reader->version() == 1) {
+ RCHECK(reader->Read8(&fragment_duration));
+ } else {
+ RCHECK(reader->Read4Into8(&fragment_duration));
+ }
return true;
}
diff --git a/media/mp4/box_definitions.h b/media/mp4/box_definitions.h
index 594e69b..53e6b67 100644
--- a/media/mp4/box_definitions.h
+++ b/media/mp4/box_definitions.h
@@ -162,6 +162,13 @@ struct MEDIA_EXPORT AVCDecoderConfigurationRecord : Box {
std::vector<PPS> pps_list;
};
+struct PixelAspectRatioBox : Box {
+ DECLARE_BOX_METHODS(PixelAspectRatioBox);
+
+ uint32 h_spacing;
+ uint32 v_spacing;
+};
+
struct VideoSampleEntry : Box {
DECLARE_BOX_METHODS(VideoSampleEntry);
@@ -170,6 +177,7 @@ struct VideoSampleEntry : Box {
uint16 width;
uint16 height;
+ PixelAspectRatioBox pixel_aspect;
ProtectionSchemeInfo sinf;
// Currently expected to be present regardless of format.
diff --git a/media/mp4/mp4_stream_parser.cc b/media/mp4/mp4_stream_parser.cc
index fff9ff5..2e20c5c 100644
--- a/media/mp4/mp4_stream_parser.cc
+++ b/media/mp4/mp4_stream_parser.cc
@@ -178,14 +178,15 @@ bool MP4StreamParser::ParseMoov(BoxReader* reader) {
// (entry.format == FOURCC_ENCV &&
// entry.sinf.format.format == FOURCC_AVC1));
- // TODO(strobe): Recover correct crop box and pixel aspect ratio
+ // TODO(strobe): Recover correct crop box
video_config.Initialize(kCodecH264, H264PROFILE_MAIN, VideoFrame::YV12,
gfx::Size(entry.width, entry.height),
gfx::Rect(0, 0, entry.width, entry.height),
// Bogus duration used for framerate, since real
// framerate may be variable
1000, track->media.header.timescale,
- 1, 1,
+ entry.pixel_aspect.h_spacing,
+ entry.pixel_aspect.v_spacing,
// No decoder-specific buffer needed for AVC;
// SPS/PPS are embedded in the video stream
NULL, 0, false);