Index: media/mp4/cenc.cc |
diff --git a/media/mp4/cenc.cc b/media/mp4/cenc.cc |
index 996ebb12c28c50fe3b3c520ff78e0f6ae47854f5..ef16f10333c69685599fe29b406ba78562f69f2f 100644 |
--- a/media/mp4/cenc.cc |
+++ b/media/mp4/cenc.cc |
@@ -4,6 +4,8 @@ |
#include "media/mp4/cenc.h" |
+#include <string.h> |
xhwang
2012/06/27 19:37:43
Use C++ headers? #include <cstring>
strobe_
2012/07/13 00:47:07
Done.
|
+ |
#include "media/mp4/box_reader.h" |
#include "media/mp4/rcheck.h" |
@@ -15,28 +17,35 @@ FrameCENCInfo::~FrameCENCInfo() {} |
bool FrameCENCInfo::Parse(int iv_size, BufferReader* reader) { |
const int kEntrySize = 6; |
- |
// Mandated by CENC spec |
RCHECK(iv_size == 8 || iv_size == 16); |
- iv.resize(iv_size); |
+ |
+ memset(iv, 0, sizeof(iv)); |
+ for (int i = 0; i < iv_size; i++) |
+ RCHECK(reader->Read1(&iv[i])); |
+ |
+ if (!reader->HasBytes(1)) return true; |
uint16 subsample_count; |
- RCHECK(reader->ReadVec(&iv, iv_size) && |
- reader->Read2(&subsample_count) && |
+ RCHECK(reader->Read2(&subsample_count) && |
reader->HasBytes(subsample_count * kEntrySize)); |
- subsamples.resize(subsample_count); |
+ subsamples.resize(subsample_count); |
for (int i = 0; i < subsample_count; i++) { |
- RCHECK(reader->Read2(&subsamples[i].clear_size) && |
- reader->Read4(&subsamples[i].encrypted_size)); |
+ uint16 clear_bytes; |
+ uint32 cypher_bytes; |
+ RCHECK(reader->Read2(&clear_bytes) && |
+ reader->Read4(&cypher_bytes)); |
+ subsamples[i].clear_bytes = clear_bytes; |
+ subsamples[i].cypher_bytes = cypher_bytes; |
ddorwin
2012/07/03 21:03:47
This doesn't cause a possible overflow warning? (u
strobe_
2012/07/13 00:47:07
Surprisingly, no. I'm more than happy to use uint3
ddorwin
2012/07/17 01:14:21
I think if you're dealing with data and it can rea
strobe_
2012/07/19 02:43:34
Done.
|
} |
return true; |
} |
-size_t FrameCENCInfo::GetTotalSize() const { |
+size_t FrameCENCInfo::GetTotalSizeOfSubsamples() const { |
size_t size = 0; |
for (size_t i = 0; i < subsamples.size(); i++) { |
- size += subsamples[i].clear_size + subsamples[i].encrypted_size; |
+ size += subsamples[i].clear_bytes + subsamples[i].cypher_bytes; |
} |
return size; |
} |