summaryrefslogtreecommitdiff
path: root/m2ts/webm2pes.cc
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-12-04 20:36:26 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-12-04 20:36:26 +0000
commitc9365c1311423beb6d9de1e98fc0f0945bd6f672 (patch)
tree1df2a4965f354fcb732ed90b80f33e7ee692b043 /m2ts/webm2pes.cc
parent2ddc3a5c1a38898c51f8d188c94d3f60d39dbd19 (diff)
parente546ccacd3177e86ab7cd5ff1c457748313a750f (diff)
downloadlibwebm-c9365c1311423beb6d9de1e98fc0f0945bd6f672.tar.gz
Snap for 11174750 from e546ccacd3177e86ab7cd5ff1c457748313a750f to mainline-adservices-releaseaml_ads_341720000aml_ads_341615050aml_ads_341517040aml_ads_341413000android14-mainline-adservices-release
Change-Id: I3f1337c7be42e395df11c8df01eb5fa6104fa346
Diffstat (limited to 'm2ts/webm2pes.cc')
-rw-r--r--m2ts/webm2pes.cc41
1 files changed, 21 insertions, 20 deletions
diff --git a/m2ts/webm2pes.cc b/m2ts/webm2pes.cc
index afa8a6b..a4169c0 100644
--- a/m2ts/webm2pes.cc
+++ b/m2ts/webm2pes.cc
@@ -33,9 +33,6 @@ std::string ToString(const char* str) {
//
void PesOptionalHeader::SetPtsBits(std::int64_t pts_90khz) {
- std::uint64_t* pts_bits = &pts.bits;
- *pts_bits = 0;
-
// PTS is broken up and stored in 40 bits as shown:
//
// PES PTS Only flag
@@ -48,32 +45,36 @@ void PesOptionalHeader::SetPtsBits(std::int64_t pts_90khz) {
const std::uint32_t pts2 = (pts_90khz >> 15) & 0x7FFF;
const std::uint32_t pts3 = pts_90khz & 0x7FFF;
- std::uint8_t buffer[5] = {0};
- // PTS only flag.
- buffer[0] |= 1 << 5;
- // Top 3 bits of PTS and 1 bit marker.
- buffer[0] |= pts1 << 1;
- // Marker.
- buffer[0] |= 1;
+ pts.bits = 0;
- // Next 15 bits of pts and 1 bit marker.
- // Top 8 bits of second PTS chunk.
- buffer[1] |= (pts2 >> 7) & 0xff;
// bottom 7 bits of second PTS chunk.
- buffer[2] |= (pts2 << 1);
+ pts.bits |= (pts3 << 1) & 0xff;
// Marker.
- buffer[2] |= 1;
+ pts.bits |= 1;
// Last 15 bits of pts and 1 bit marker.
// Top 8 bits of second PTS chunk.
- buffer[3] |= (pts3 >> 7) & 0xff;
+ pts.bits <<= 8;
+ pts.bits |= (pts3 >> 7) & 0xff;
+
// bottom 7 bits of second PTS chunk.
- buffer[4] |= (pts3 << 1) & 0xff;
+ pts.bits <<= 8;
+ pts.bits |= (pts2 << 1);
// Marker.
- buffer[4] |= 1;
+ pts.bits |= 1;
- // Write bits into PesHeaderField.
- std::memcpy(reinterpret_cast<std::uint8_t*>(pts_bits), buffer, 5);
+ // Next 15 bits of pts and 1 bit marker.
+ // Top 8 bits of second PTS chunk.
+ pts.bits <<= 8;
+ pts.bits |= (pts2 >> 7) & 0xff;
+
+ // PTS only flag.
+ pts.bits <<= 8;
+ pts.bits |= 1 << 5;
+ // Top 3 bits of PTS and 1 bit marker.
+ pts.bits |= pts1 << 1;
+ // Marker.
+ pts.bits |= 1;
}
// Writes fields to |buffer| and returns true. Returns false when write or