Closed
Bug 1412183
Opened 7 years ago
Closed 7 years ago
Use BufferReader in mp4 parser
Categories
(Core :: Audio/Video: Playback, enhancement, P3)
Core
Audio/Video: Playback
Tracking
()
RESOLVED
FIXED
mozilla58
Tracking | Status | |
---|---|---|
firefox58 | --- | fixed |
People
(Reporter: ayang, Assigned: ayang)
References
(Blocks 1 open bug)
Details
Attachments
(4 files)
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment 5•7 years ago
|
||
mozreview-review |
Comment on attachment 8922621 [details]
Bug 1412183 - use BufferReader instead of ByteReader in mp4 index parser.
https://reviewboard.mozilla.org/r/193734/#review198858
Attachment #8922621 -
Flags: review?(kinetik) → review+
Comment 6•7 years ago
|
||
mozreview-review |
Comment on attachment 8922624 [details]
Bug 1412183 - use BufferReader instead of ByteReader in DecoderData.
https://reviewboard.mozilla.org/r/193740/#review198860
Attachment #8922624 -
Flags: review?(kinetik) → review+
Comment 7•7 years ago
|
||
mozreview-review |
Comment on attachment 8922623 [details]
Bug 1412183 - use BufferReader instead of ByteReader in H264 parser.
https://reviewboard.mozilla.org/r/193738/#review198862
::: media/libstagefright/binding/H264.cpp:816
(Diff revision 1)
> - ByteReader reader(aSample->Data(), aSample->Size());
> + BufferReader reader(aSample->Data(), aSample->Size());
>
> while (reader.Remaining() >= nalLenSize) {
> - uint32_t nalLen;
> + uint32_t nalLen = 0;
> switch (nalLenSize) {
> - case 1: nalLen = reader.ReadU8(); break;
> + case 1: reader.ReadU8().map([&] (uint8_t x) mutable { nalLen = x; return Ok(); }); break;
This is pretty awkward... another case where mozilla::Result needs unwrap_or to clean this up.
Attachment #8922623 -
Flags: review?(kinetik) → review+
Comment 8•7 years ago
|
||
mozreview-review |
Comment on attachment 8922622 [details]
Bug 1412183 - use BufferReader instead of ByteReader in AnnexB parser.
https://reviewboard.mozilla.org/r/193736/#review198866
Attachment #8922622 -
Flags: review?(kinetik) → review+
Comment 9•7 years ago
|
||
(In reply to Matthew Gregan [:kinetik] from comment #7)
> Comment on attachment 8922623 [details]
> Bug 1412183 - use BufferReader instead of ByteReader in H264 parser.
>
> https://reviewboard.mozilla.org/r/193738/#review198862
>
> ::: media/libstagefright/binding/H264.cpp:816
> (Diff revision 1)
> > - ByteReader reader(aSample->Data(), aSample->Size());
> > + BufferReader reader(aSample->Data(), aSample->Size());
> >
> > while (reader.Remaining() >= nalLenSize) {
> > - uint32_t nalLen;
> > + uint32_t nalLen = 0;
> > switch (nalLenSize) {
> > - case 1: nalLen = reader.ReadU8(); break;
> > + case 1: reader.ReadU8().map([&] (uint8_t x) mutable { nalLen = x; return Ok(); }); break;
>
> This is pretty awkward... another case where mozilla::Result needs unwrap_or
> to clean this up.
Happy to review patches to add things like this.
Assignee | ||
Comment 10•7 years ago
|
||
mozreview-review-reply |
Comment on attachment 8922623 [details]
Bug 1412183 - use BufferReader instead of ByteReader in H264 parser.
https://reviewboard.mozilla.org/r/193738/#review198862
> This is pretty awkward... another case where mozilla::Result needs unwrap_or to clean this up.
Frankly speaking, I've no idea how to add unwrap_or in mozilla::Result. I'll add a comment to author and try to find a better way to rewrite it.
Assignee | ||
Comment 11•7 years ago
|
||
mozreview-review-reply |
Comment on attachment 8922623 [details]
Bug 1412183 - use BufferReader instead of ByteReader in H264 parser.
https://reviewboard.mozilla.org/r/193738/#review198862
> Frankly speaking, I've no idea how to add unwrap_or in mozilla::Result. I'll add a comment to author and try to find a better way to rewrite it.
I change it slightly but no obvious improvement unfortunately.
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Assignee | ||
Comment 16•7 years ago
|
||
Comment 17•7 years ago
|
||
Pushed by ayang@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/de11750ca8ed
use BufferReader instead of ByteReader in mp4 index parser. r=kinetik
https://hg.mozilla.org/integration/autoland/rev/f042748e5f83
use BufferReader instead of ByteReader in AnnexB parser. r=kinetik
https://hg.mozilla.org/integration/autoland/rev/71bad9dae18b
use BufferReader instead of ByteReader in H264 parser. r=kinetik
https://hg.mozilla.org/integration/autoland/rev/cce51f29025f
use BufferReader instead of ByteReader in DecoderData. r=kinetik
Comment 18•7 years ago
|
||
(In reply to Alfredo Yang (:alfredo) from comment #11)
> I change it slightly but no obvious improvement unfortunately.
I was imagining that:
case 1: reader.ReadU8().map([&] (uint8_t x) mutable { nalLen = x; return Ok(); }); break;
becomes:
case 1: nalLen = reader.ReadU8().unwrap_or(0); break;
...which is closer to the original code, and easier to read without the lamba.
Comment 19•7 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/de11750ca8ed
https://hg.mozilla.org/mozilla-central/rev/f042748e5f83
https://hg.mozilla.org/mozilla-central/rev/71bad9dae18b
https://hg.mozilla.org/mozilla-central/rev/cce51f29025f
Status: NEW → RESOLVED
Closed: 7 years ago
status-firefox58:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla58
Comment 20•7 years ago
|
||
mozreview-review |
Comment on attachment 8922621 [details]
Bug 1412183 - use BufferReader instead of ByteReader in mp4 index parser.
https://reviewboard.mozilla.org/r/193734/#review199920
::: media/libstagefright/binding/Index.cpp:182
(Diff revision 2)
>
> for (size_t i = 0; i < count; i++) {
> - writer->mCrypto.mPlainSizes.AppendElement(reader.ReadU16());
> - writer->mCrypto.mEncryptedSizes.AppendElement(reader.ReadU32());
> + auto res_16 = reader.ReadU16();
> + auto res_32 = reader.ReadU32();
> + if (res_16.isErr() || res_32.isErr()) {
> + return nullptr;
you can never enter there as we still have the test line 172
Comment 21•7 years ago
|
||
mozreview-review |
Comment on attachment 8922622 [details]
Bug 1412183 - use BufferReader instead of ByteReader in AnnexB parser.
https://reviewboard.mozilla.org/r/193736/#review199926
::: media/libstagefright/binding/AnnexB.cpp:143
(Diff revision 2)
> -FindStartCodeInternal(ByteReader& aBr) {
> +FindStartCodeInternal(BufferReader& aBr) {
> size_t offset = aBr.Offset();
>
> for (uint32_t i = 0; i < aBr.Align() && aBr.Remaining() >= 3; i++) {
> - if (aBr.PeekU24() == 0x000001) {
> - return true;
> + auto res = aBr.PeekU24();
> + if (res.isOk() && (res.unwrap() == 0x000001)) {
res will always be Ok, as the condition for the loop as aBr.Remaining() >= 3
You need to log in
before you can comment on or make changes to this bug.
Description
•