Filters library and unit test builds.

Added filters gyp file.

Some tweaks to get the h.264 related filters library and unit tests building
in the packager source tree.

Change-Id: Ib79ffe307d3357b4b38f13ee87cbd93f0f93b1cc
This commit is contained in:
Thomas Inskip 2014-04-01 14:18:11 -07:00
parent 0ad332896e
commit 5557ce7677
10 changed files with 79 additions and 15 deletions

46
media/filters/filters.gyp Normal file
View File

@ -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',
],
},
],
}

View File

@ -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

View File

@ -10,15 +10,15 @@
#include <sys/types.h>
#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_

View File

@ -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

View File

@ -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

View File

@ -12,14 +12,14 @@
#include <map>
#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_

View File

@ -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

View File

@ -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

Binary file not shown.

View File

@ -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',