Add webm_info.

Migrated from the webm-tools repository with minor tweaks to
fix its build in the new location.

Last location/revision:
https://chromium.googlesource.com/webm/webm-tools
a7e97e8f0a913ddd97444392bb8816f44a4821a1

Change-Id: Icfad43d9fdd37fc413a6a28b57b370c97c7c28df
This commit is contained in:
Tom Finegan 2016-03-31 19:46:21 -07:00
parent ccf75f67a0
commit 596f5e0544
9 changed files with 1275 additions and 5 deletions

1
.gitignore vendored
View File

@ -23,6 +23,7 @@ sample_muxer
vttdemux
muxer_tests
parser_tests
webm_info
webm2pes
webm2pes_tests
webm2ts

View File

@ -40,6 +40,7 @@ else ()
endif ()
set(CMAKE_CXX_FLAGS "-D__STDC_CONSTANT_MACROS ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "-D__STDC_FORMAT_MACROS ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "-D__STDC_LIMIT_MACROS ${CMAKE_CXX_FLAGS}")
# mkvmuxer section.
@ -113,6 +114,16 @@ add_executable(vttdemux
"${LIBWEBM_SRC_DIR}/webvtt/webvttparser.h")
target_link_libraries(vttdemux LINK_PUBLIC webm)
# Webm_info section.
add_executable(webm_info
"${LIBWEBM_SRC_DIR}/common/indent.cc"
"${LIBWEBM_SRC_DIR}/common/indent.h"
"${LIBWEBM_SRC_DIR}/common/webm_constants.h"
"${LIBWEBM_SRC_DIR}/common/webm_endian.cc"
"${LIBWEBM_SRC_DIR}/common/webm_endian.h"
"${LIBWEBM_SRC_DIR}/webm_info.cc")
target_link_libraries(webm_info LINK_PUBLIC webm)
if (ENABLE_WEBMTS)
# webmts (PES/TS support) library section.
add_library(webmts

View File

@ -1,5 +1,6 @@
CXX := g++
DEFINES := -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS
DEFINES := -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
DEFINES += -D__STDC_LIMIT_MACROS
INCLUDES := -I.
CXXFLAGS := -W -Wall -g
ALL_CXXFLAGS := -MMD -MP $(DEFINES) $(INCLUDES) $(CXXFLAGS)
@ -11,13 +12,14 @@ WEBMOBJS += common/file_util.o common/hdr_util.o
OBJSA := $(WEBMOBJS:.o=_a.o)
OBJSSO := $(WEBMOBJS:.o=_so.o)
VTTOBJS := webvtt/vttreader.o webvtt/webvttparser.o sample_muxer_metadata.o
EXEOBJS := sample.o sample_muxer.o dumpvtt.o vttdemux.o
EXEOBJS := sample.o sample_muxer.o dumpvtt.o vttdemux.o webm_info.o
INFOOBJS := common/indent.o common/webm_endian.o
DEPS := $(WEBMOBJS:.o=.d) $(OBJECTS1:.o=.d) $(OBJECTS2:.o=.d)
DEPS += $(OBJECTS3:.o=.d) $(OBJECTS4:.o=.d) $(OBJSA:.o=.d) $(OBJSSO:.o=.d)
DEPS += $(VTTOBJS:.o=.d) $(EXEOBJS:.o=.d)
EXES := sample_muxer sample dumpvtt vttdemux
DEPS += $(VTTOBJS:.o=.d) $(EXEOBJS:.o=.d) $(INFOOBJS:.o=.d)
EXES := sample_muxer sample dumpvtt vttdemux webm_info
CLEAN := $(EXEOBJS) $(VTTOBJS) $(WEBMOBJS) $(OBJSA) $(OBJSSO) $(LIBWEBMA)
CLEAN += $(LIBWEBMSO) $(EXES) $(DEPS)
CLEAN += $(LIBWEBMSO) $(EXES) $(DEPS) $(INFOOBJS)
all: $(EXES)
@ -33,6 +35,9 @@ dumpvtt: dumpvtt.o $(VTTOBJS) $(WEBMOBJS)
vttdemux: vttdemux.o $(VTTOBJS) $(LIBWEBMA)
$(CXX) $^ -o $@
webm_info: webm_info.o $(INFOOBJS) $(LIBWEBMA)
$(CXX) $^ -o $@
shared: $(LIBWEBMSO)
libwebm.a: $(OBJSA)

29
common/indent.cc Normal file
View File

@ -0,0 +1,29 @@
/*
* Copyright (c) 2012 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "common/indent.h"
#include <string>
namespace libwebm {
Indent::Indent(int indent) : indent_(indent), indent_str_() { Update(); }
void Indent::Adjust(int indent) {
indent_ += indent;
if (indent_ < 0)
indent_ = 0;
Update();
}
void Indent::Update() { indent_str_ = std::string(indent_, ' '); }
} // namespace libwebm

48
common/indent.h Normal file
View File

@ -0,0 +1,48 @@
/*
* Copyright (c) 2012 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef LIBWEBM_COMMON_INDENT_H_
#define LIBWEBM_COMMON_INDENT_H_
#include <string>
#include "mkvmuxer/mkvmuxertypes.h"
namespace libwebm {
const int kIncreaseIndent = 2;
const int kDecreaseIndent = -2;
// Used for formatting output so objects only have to keep track of spacing
// within their scope.
class Indent {
public:
explicit Indent(int indent);
// Changes the number of spaces output. The value adjusted is relative to
// |indent_|.
void Adjust(int indent);
std::string indent_str() const { return indent_str_; }
private:
// Called after |indent_| is changed. This will set |indent_str_| to the
// proper number of spaces.
void Update();
int indent_;
std::string indent_str_;
LIBWEBM_DISALLOW_COPY_AND_ASSIGN(Indent);
};
} // namespace libwebm
#endif // LIBWEBM_COMMON_INDENT_H_

20
common/webm_constants.h Normal file
View File

@ -0,0 +1,20 @@
// Copyright (c) 2012 The WebM project authors. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
#ifndef LIBWEBM_COMMON_WEBM_CONSTANTS_H_
#define LIBWEBM_COMMON_WEBM_CONSTANTS_H_
namespace libwebm {
const double kNanosecondsPerSecond = 1000000000.0;
const int kNanosecondsPerSecondi = 1000000000;
const int kNanosecondsPerMillisecond = 1000000;
} // namespace libwebm
#endif // LIBWEBM_COMMON_WEBM_CONSTANTS_H_

54
common/webm_endian.cc Normal file
View File

@ -0,0 +1,54 @@
// Copyright (c) 2012 The WebM project authors. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
#include "common/webm_endian.h"
#include <stdint.h>
namespace {
// Swaps unsigned 64 bit values to big endian if needed. Returns |value|
// unmodified if architecture is big endian. Returns swapped bytes of |value|
// if architecture is little endian. Returns 0 otherwise.
uint64_t swap64_check_little_endian(uint64_t value) {
// Check endianness.
union {
uint64_t val64;
uint8_t c[8];
} check;
check.val64 = 0x0123456789ABCDEFULL;
// Check for big endian.
if (check.c[7] == 0xEF)
return value;
// Check for not little endian.
if (check.c[0] != 0xEF)
return 0;
return value << 56 | ((value << 40) & 0x00FF000000000000ULL) |
((value << 24) & 0x0000FF0000000000ULL) |
((value << 8) & 0x000000FF00000000ULL) |
((value >> 8) & 0x00000000FF000000ULL) |
((value >> 24) & 0x0000000000FF0000ULL) |
((value >> 40) & 0x000000000000FF00ULL) | value >> 56;
}
} // namespace
namespace libwebm {
uint64_t host_to_bigendian(uint64_t value) {
return swap64_check_little_endian(value);
}
uint64_t bigendian_to_host(uint64_t value) {
return swap64_check_little_endian(value);
}
} // namespace libwebm

28
common/webm_endian.h Normal file
View File

@ -0,0 +1,28 @@
// Copyright (c) 2012 The WebM project authors. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
#ifndef LIBWEBM_COMMON_WEBM_ENDIAN_H_
#define LIBWEBM_COMMON_WEBM_ENDIAN_H_
#include <stdint.h>
namespace libwebm {
// Swaps unsigned 64 bit values to big endian if needed. Returns |value| if
// architecture is big endian. Returns little endian value if architecture is
// little endian. Returns 0 otherwise.
uint64_t host_to_bigendian(uint64_t value);
// Swaps unsigned 64 bit values to little endian if needed. Returns |value| if
// architecture is big endian. Returns little endian value if architecture is
// little endian. Returns 0 otherwise.
uint64_t bigendian_to_host(uint64_t value);
} // namespace libwebm
#endif // LIBWEBM_COMMON_WEBM_ENDIAN_H_

1074
webm_info.cc Normal file

File diff suppressed because it is too large Load Diff