Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(540)

Side by Side Diff: media/formats/mp4/cenc.cc

Issue 1534273002: Switch to standard integer types in media/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/formats/mp4/cenc.h" 5 #include "media/formats/mp4/cenc.h"
6 6
7 #include <cstring> 7 #include <cstring>
8 8
9 #include "media/formats/mp4/box_reader.h" 9 #include "media/formats/mp4/box_reader.h"
10 #include "media/formats/mp4/rcheck.h" 10 #include "media/formats/mp4/rcheck.h"
11 11
12 namespace media { 12 namespace media {
13 namespace mp4 { 13 namespace mp4 {
14 14
15 FrameCENCInfo::FrameCENCInfo() {} 15 FrameCENCInfo::FrameCENCInfo() {}
16 FrameCENCInfo::~FrameCENCInfo() {} 16 FrameCENCInfo::~FrameCENCInfo() {}
17 17
18 bool FrameCENCInfo::Parse(int iv_size, BufferReader* reader) { 18 bool FrameCENCInfo::Parse(int iv_size, BufferReader* reader) {
19 const int kEntrySize = 6; 19 const int kEntrySize = 6;
20 // Mandated by CENC spec 20 // Mandated by CENC spec
21 RCHECK(iv_size == 8 || iv_size == 16); 21 RCHECK(iv_size == 8 || iv_size == 16);
22 22
23 memset(iv, 0, sizeof(iv)); 23 memset(iv, 0, sizeof(iv));
24 for (int i = 0; i < iv_size; i++) 24 for (int i = 0; i < iv_size; i++)
25 RCHECK(reader->Read1(&iv[i])); 25 RCHECK(reader->Read1(&iv[i]));
26 26
27 if (!reader->HasBytes(1)) return true; 27 if (!reader->HasBytes(1)) return true;
28 28
29 uint16 subsample_count; 29 uint16_t subsample_count;
30 RCHECK(reader->Read2(&subsample_count) && 30 RCHECK(reader->Read2(&subsample_count) &&
31 reader->HasBytes(subsample_count * kEntrySize)); 31 reader->HasBytes(subsample_count * kEntrySize));
32 32
33 subsamples.resize(subsample_count); 33 subsamples.resize(subsample_count);
34 for (int i = 0; i < subsample_count; i++) { 34 for (int i = 0; i < subsample_count; i++) {
35 uint16 clear_bytes; 35 uint16_t clear_bytes;
36 uint32 cypher_bytes; 36 uint32_t cypher_bytes;
37 RCHECK(reader->Read2(&clear_bytes) && 37 RCHECK(reader->Read2(&clear_bytes) &&
38 reader->Read4(&cypher_bytes)); 38 reader->Read4(&cypher_bytes));
39 subsamples[i].clear_bytes = clear_bytes; 39 subsamples[i].clear_bytes = clear_bytes;
40 subsamples[i].cypher_bytes = cypher_bytes; 40 subsamples[i].cypher_bytes = cypher_bytes;
41 } 41 }
42 return true; 42 return true;
43 } 43 }
44 44
45 bool FrameCENCInfo::GetTotalSizeOfSubsamples(size_t* total_size) const { 45 bool FrameCENCInfo::GetTotalSizeOfSubsamples(size_t* total_size) const {
46 size_t size = 0; 46 size_t size = 0;
47 for (size_t i = 0; i < subsamples.size(); i++) { 47 for (size_t i = 0; i < subsamples.size(); i++) {
48 size += subsamples[i].clear_bytes; 48 size += subsamples[i].clear_bytes;
49 RCHECK(size >= subsamples[i].clear_bytes); // overflow 49 RCHECK(size >= subsamples[i].clear_bytes); // overflow
50 size += subsamples[i].cypher_bytes; 50 size += subsamples[i].cypher_bytes;
51 RCHECK(size >= subsamples[i].cypher_bytes); // overflow 51 RCHECK(size >= subsamples[i].cypher_bytes); // overflow
52 } 52 }
53 *total_size = size; 53 *total_size = size;
54 return true; 54 return true;
55 } 55 }
56 56
57 } // namespace mp4 57 } // namespace mp4
58 } // namespace media 58 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698