Chromium Code Reviews| Index: media/mp4/cenc.cc |
| diff --git a/media/mp4/cenc.cc b/media/mp4/cenc.cc |
| index 996ebb12c28c50fe3b3c520ff78e0f6ae47854f5..ee2721d293e23de91a7dab66cbc4307076f80eb5 100644 |
| --- a/media/mp4/cenc.cc |
| +++ b/media/mp4/cenc.cc |
| @@ -4,6 +4,8 @@ |
| #include "media/mp4/cenc.h" |
| +#include <string.h> |
|
ddorwin
2012/06/26 06:09:19
Why is this needed?
strobe_
2012/06/27 02:01:21
memset().
|
| + |
| #include "media/mp4/box_reader.h" |
| #include "media/mp4/rcheck.h" |
| @@ -15,20 +17,27 @@ 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])); |
|
ddorwin
2012/06/26 06:09:19
Reading one byte at a time isn't the fastest solut
strobe_
2012/06/27 02:01:21
Given the buffer's representation as a uint8 strin
|
| + |
| + 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) && |
|
ddorwin
2012/06/26 06:09:19
Why not eliminate 4 lines by reading into the vect
strobe_
2012/06/27 02:01:21
I modified the vector element to use the definitio
|
| + reader->Read4(&cypher_bytes)); |
| + subsamples[i].clear_bytes = clear_bytes; |
| + subsamples[i].cypher_bytes = cypher_bytes; |
| } |
| return true; |
| } |
| @@ -36,7 +45,7 @@ bool FrameCENCInfo::Parse(int iv_size, BufferReader* reader) { |
| size_t FrameCENCInfo::GetTotalSize() const { |
|
ddorwin
2012/06/26 06:09:19
"Total" appears to not include the iv. Maybe the f
strobe_
2012/06/27 02:01:21
Done.
|
| 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; |
| } |