diff --git a/media/filters/filters.gyp b/media/filters/filters.gyp new file mode 100644 index 0000000000..5ce9a44ddb --- /dev/null +++ b/media/filters/filters.gyp @@ -0,0 +1,46 @@ +# Copyright 2014 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE filters or at +# https://developers.google.com/open-source/licenses/bsd + +{ + 'variables': { + # Compile as chromium code to enable warnings and warnings-as-errors. + 'chromium_code': 1, + }, + 'target_defaults': { + 'include_dirs': [ + '../..', + ], + }, + 'targets': [ + { + 'target_name': 'filters', + 'type': '<(component)', + 'sources': [ + 'h264_bit_reader.cc', + 'h264_bit_reader.h', + 'h264_parser.cc', + 'h264_parser.h', + ], + 'dependencies': [ + '../../base/base.gyp:base', + ], + }, + { + 'target_name': 'filters_unittest', + 'type': '<(gtest_target_type)', + 'sources': [ + 'h264_bit_reader_unittest.cc', + 'h264_parser_unittest.cc', + ], + 'dependencies': [ + '../../testing/gtest.gyp:gtest', + '../../testing/gtest.gyp:gtest_main', + '../test/media_test.gyp:media_test_support', + 'filters', + ], + }, + ], +} diff --git a/media/filters/h264_bit_reader.cc b/media/filters/h264_bit_reader.cc index 9894d97897..064a277933 100644 --- a/media/filters/h264_bit_reader.cc +++ b/media/filters/h264_bit_reader.cc @@ -6,6 +6,7 @@ #include "media/filters/h264_bit_reader.h" namespace media { +namespace filters { H264BitReader::H264BitReader() : data_(NULL), @@ -110,4 +111,5 @@ size_t H264BitReader::NumEmulationPreventionBytesRead() { return emulation_prevention_bytes_; } +} // namespace filters } // namespace media diff --git a/media/filters/h264_bit_reader.h b/media/filters/h264_bit_reader.h index 01cfd74109..0f517c42dd 100644 --- a/media/filters/h264_bit_reader.h +++ b/media/filters/h264_bit_reader.h @@ -10,15 +10,15 @@ #include #include "base/basictypes.h" -#include "media/base/media_export.h" namespace media { +namespace filters { // A class to provide bit-granularity reading of H.264 streams. // This is not a generic bit reader class, as it takes into account // H.264 stream-specific constraints, such as skipping emulation-prevention // bytes and stop bits. See spec for more details. -class MEDIA_EXPORT H264BitReader { +class H264BitReader { public: H264BitReader(); ~H264BitReader(); @@ -74,6 +74,7 @@ class MEDIA_EXPORT H264BitReader { DISALLOW_COPY_AND_ASSIGN(H264BitReader); }; +} // namespace filters } // namespace media #endif // MEDIA_FILTERS_H264_BIT_READER_H_ diff --git a/media/filters/h264_bit_reader_unittest.cc b/media/filters/h264_bit_reader_unittest.cc index e12e75ebcd..8bd16c11d1 100644 --- a/media/filters/h264_bit_reader_unittest.cc +++ b/media/filters/h264_bit_reader_unittest.cc @@ -6,6 +6,7 @@ #include "testing/gtest/include/gtest/gtest.h" namespace media { +namespace filters { TEST(H264BitReaderTest, ReadStreamWithoutEscapeAndTrailingZeroBytes) { H264BitReader reader; @@ -70,4 +71,5 @@ TEST(H264BitReaderTest, StopBitOccupyFullByte) { EXPECT_FALSE(reader.HasMoreRBSPData()); } +} // namespace filters } // namespace media diff --git a/media/filters/h264_parser.cc b/media/filters/h264_parser.cc index 4cdc695933..56d7e438f3 100644 --- a/media/filters/h264_parser.cc +++ b/media/filters/h264_parser.cc @@ -9,6 +9,7 @@ #include "media/filters/h264_parser.h" namespace media { +namespace filters { bool H264SliceHeader::IsPSlice() const { return (slice_type % 5 == kPSlice); @@ -1261,4 +1262,5 @@ H264Parser::Result H264Parser::ParseSEI(H264SEIMessage* sei_msg) { return kOk; } +} // namespace filters } // namespace media diff --git a/media/filters/h264_parser.h b/media/filters/h264_parser.h index 5dc8f51cfd..9213612116 100644 --- a/media/filters/h264_parser.h +++ b/media/filters/h264_parser.h @@ -12,14 +12,14 @@ #include #include "base/basictypes.h" -#include "media/base/media_export.h" #include "media/filters/h264_bit_reader.h" namespace media { +namespace filters { // For explanations of each struct and its members, see H.264 specification // at http://www.itu.int/rec/T-REC-H.264. -struct MEDIA_EXPORT H264NALU { +struct H264NALU { H264NALU(); enum Type { @@ -49,7 +49,7 @@ enum { kH264ScalingList8x8Length = 64, }; -struct MEDIA_EXPORT H264SPS { +struct H264SPS { H264SPS(); int profile_idc; @@ -104,7 +104,7 @@ struct MEDIA_EXPORT H264SPS { int chroma_array_type; }; -struct MEDIA_EXPORT H264PPS { +struct H264PPS { H264PPS(); int pic_parameter_set_id; @@ -132,7 +132,7 @@ struct MEDIA_EXPORT H264PPS { int second_chroma_qp_index_offset; }; -struct MEDIA_EXPORT H264ModificationOfPicNum { +struct H264ModificationOfPicNum { int modification_of_pic_nums_idc; union { int abs_diff_pic_num_minus1; @@ -140,7 +140,7 @@ struct MEDIA_EXPORT H264ModificationOfPicNum { }; }; -struct MEDIA_EXPORT H264WeightingFactors { +struct H264WeightingFactors { bool luma_weight_flag; bool chroma_weight_flag; int luma_weight[32]; @@ -149,7 +149,7 @@ struct MEDIA_EXPORT H264WeightingFactors { int chroma_offset[32][2]; }; -struct MEDIA_EXPORT H264DecRefPicMarking { +struct H264DecRefPicMarking { int memory_mgmnt_control_operation; int difference_of_pic_nums_minus1; int long_term_pic_num; @@ -157,7 +157,7 @@ struct MEDIA_EXPORT H264DecRefPicMarking { int max_long_term_frame_idx_plus1; }; -struct MEDIA_EXPORT H264SliceHeader { +struct H264SliceHeader { H264SliceHeader(); enum { @@ -240,7 +240,7 @@ struct H264SEIRecoveryPoint { int changing_slice_group_idc; }; -struct MEDIA_EXPORT H264SEIMessage { +struct H264SEIMessage { H264SEIMessage(); enum Type { @@ -258,7 +258,7 @@ struct MEDIA_EXPORT H264SEIMessage { // Class to parse an Annex-B H.264 stream, // as specified in chapters 7 and Annex B of the H.264 spec. -class MEDIA_EXPORT H264Parser { +class H264Parser { public: enum Result { kOk, @@ -394,6 +394,7 @@ class MEDIA_EXPORT H264Parser { DISALLOW_COPY_AND_ASSIGN(H264Parser); }; +} // namespace filters } // namespace media #endif // MEDIA_FILTERS_H264_PARSER_H_ diff --git a/media/filters/h264_parser_unittest.cc b/media/filters/h264_parser_unittest.cc index a08cf26a15..f44e9e51f4 100644 --- a/media/filters/h264_parser_unittest.cc +++ b/media/filters/h264_parser_unittest.cc @@ -7,11 +7,12 @@ #include "base/logging.h" #include "base/path_service.h" #include "base/strings/string_number_conversions.h" -#include "media/base/test_data_util.h" +#include "media/test/test_data_util.h" #include "media/filters/h264_parser.h" #include "testing/gtest/include/gtest/gtest.h" namespace media { +namespace filters { TEST(H264ParserTest, StreamFileParsing) { base::FilePath file_path = GetTestDataFilePath("test-25fps.h264"); @@ -28,8 +29,8 @@ TEST(H264ParserTest, StreamFileParsing) { // Parse until the end of stream/unsupported stream/error in stream is found. int num_parsed_nalus = 0; while (true) { - media::H264SliceHeader shdr; - media::H264SEIMessage sei_msg; + H264SliceHeader shdr; + H264SEIMessage sei_msg; H264NALU nalu; H264Parser::Result res = parser.AdvanceToNextNALU(&nalu); if (res == H264Parser::kEOStream) { @@ -69,4 +70,5 @@ TEST(H264ParserTest, StreamFileParsing) { } } +} // namespace filters } // namespace media diff --git a/media/test/data/README b/media/test/data/README index b28b749f7f..ff82bb6b7d 100644 --- a/media/test/data/README +++ b/media/test/data/README @@ -56,3 +56,10 @@ bear.mjpeg -- created using "avconv -i bear.ogv -f mjpeg bear.mjpeg". bear.mpeg -- created using "avconv -i bear.ogv -f mpeg bear.mpeg". bear.rm -- created using "avconv -i bear.ogv -f rm -b 192k bear.rm". bear.swf -- created using "avconv -i bear.ogv -f swf -an bear.swf". + +// VDA test files: test-25fps +test-25fps.h264: + Using ffmpeg SVN-r0.5.9-4:0.5.9-0ubuntu0.10.04.1 @ WebKit r122718, generated + with: + ffmpeg -i third_party/WebKit/LayoutTests/media/content/test-25fps.mp4 \ + -vcodec copy -vbsf h264_mp4toannexb -an test-25fps.h264 diff --git a/media/test/data/test-25fps.h264 b/media/test/data/test-25fps.h264 new file mode 100644 index 0000000000..b1c36d9de6 Binary files /dev/null and b/media/test/data/test-25fps.h264 differ diff --git a/packager.gyp b/packager.gyp index 908f1a702c..bd9d482d4a 100644 --- a/packager.gyp +++ b/packager.gyp @@ -75,6 +75,7 @@ 'media/base/media_base.gyp:media_base_unittest', 'media/event/media_event.gyp:media_event_unittest', 'media/file/file.gyp:file_unittest', + 'media/filters/filters.gyp:filters_unittest', 'media/formats/mp4/mp4.gyp:mp4_unittest', 'mpd/mpd.gyp:mpd_unittest', 'packager_test',