Closed
Bug 495366
Opened 17 years ago
Closed 17 years ago
liboggz oggz_get_next_page() and oggz_read_get_next_page() wrong
Categories
(Core :: Audio/Video, defect)
Core
Audio/Video
Tracking
()
VERIFIED
FIXED
mozilla1.9.2a1
People
(Reporter: cpearce, Assigned: cpearce)
References
Details
(Keywords: verified1.9.1)
Attachments
(2 files)
|
12.19 KB,
patch
|
cajbir
:
review+
roc
:
superreview+
|
Details | Diff | Splinter Review |
|
12.07 KB,
patch
|
cpearce
:
review+
cpearce
:
superreview+
|
Details | Diff | Splinter Review |
The liboggz functions liboggz oggz_get_next_page() and oggz_read_get_next_page() are wrong. This causes us to incorrectly report the duration of a media, and also will cause liboggplay to incorrectly report the offset of pages while seeking.
This bug spun off bug 494305, which contains two liboggz fixes. This bug is the first of those two fixes, and is filed separately so that we can land it separately for 191.
Conrad Parker has looked over the patch, and says it looks ok, so we should take it to fix the duration.
Here's my explanation of the bug that I sent Conrad:
There are two problems with oggz_get_next_page():
1. oggz_get_next_page() often returns the offset of the page after the next page, not the offset of the next page.
After a seek the ogg_sync_state buffer is empty. So the first time through oggz_get_next_page()'s main loop, we fill the buffer, and set bytes > 0. Subsequent iterations will advance to potential capture points. If ogg_sync_pageseek() finds a complete page without needing to rebuffer, we break out of the loop. At this point page_offset is the offset of the page, and |more| is the length of the page. Then because (bytes > 0), we set:
oggz->offset = oggz_tell_raw (oggz) - bytes + page_offset
So oggz->offset now hold the offset of the first page after the previous offset (the seek position). But we return oggz->offset + more which is the offset of the page following the next page, so it's actually the one after the page we want.
2. When calling oggz_get_next_page() after a seek, if we have to fill the sync buffer twice, the offset is calculated incorrectly. After a seek the ogg_sync_state buffer is empty. So the first time through oggz_get_next_page()'s main loop, we fill the buffer. Subsequent iterations will advance to potential capture points. If ogg_sync_pageseek() finds a capture point but it doesn't have the entire page in the sync state buffer, it returns 0. oggz_get_next_page() then calls ogg_sync_buffer() which slides the buffer's window to the start of the capture pattern. Then oggz_get_next_page() reads, putting another 4K in the buffer, and moving the raw IO cursor. In the next iteration, ogg_sync_pageseek() finds the capture pattern and the complete page in the buffer, so succeeds, and breaks out of the loop (with page_offset=0, and bytes=length of second read).
Then because (bytes > 0), we set the oggz->offset to be:
oggz_tell_raw (oggz) - bytes + page_offset;
But because we've done two reads, the IO cursor will be at the end of the second read, and that expression is wrong. "oggz_tell_raw (oggz) - bytes" is the offset of the start of the second chunk read, but the start of the page lies in the first chunk read. So it's out by the (previous page_offset) - (previous bytes).
We go on to return oggz->offset + more, which misses a page again, as I explained in point 1.
| Assignee | ||
Comment 1•17 years ago
|
||
Patch v1, as per bug 494305 "patch v2 part 1".
Assignee: nobody → chris
Attachment #380335 -
Flags: superreview?(roc)
Attachment #380335 -
Flags: review?(chris.double)
| Assignee | ||
Comment 2•17 years ago
|
||
Requesting blocking, since this ensures that we report the duration of a media correctly, and because this we need this to fix bug 495159 and bug 495145 properly.
Flags: blocking1.9.1?
| Assignee | ||
Comment 3•17 years ago
|
||
(In reply to comment #2)
> Requesting blocking, since this ensures that we report the duration of a media
> correctly, and because this we need this to fix bug 495159 and bug 495145
> properly.
I mean we need this to fix bug 495300 not bug 495145.
Blocks: 495300
Attachment #380335 -
Flags: superreview?(roc) → superreview+
Updated•17 years ago
|
Attachment #380335 -
Flags: review?(chris.double) → review+
Flags: blocking1.9.1? → blocking1.9.1+
Whiteboard: [needs landing]
| Assignee | ||
Updated•17 years ago
|
Keywords: checkin-needed
Comment 4•17 years ago
|
||
Status: NEW → RESOLVED
Closed: 17 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Whiteboard: [needs landing]
Comment 5•17 years ago
|
||
This patch doesn't apply cleanly to mozilla-1.9.1; can you post an updated patch?
| Assignee | ||
Comment 6•17 years ago
|
||
As v1, but for 1.9.1 branch.
Attachment #380579 -
Flags: superreview+
Attachment #380579 -
Flags: review+
| Assignee | ||
Updated•17 years ago
|
Keywords: checkin-needed
Whiteboard: [needs 191 landing]
Keywords: checkin-needed → fixed1.9.1
Whiteboard: [needs 191 landing]
Updated•17 years ago
|
Flags: in-testsuite+
Comment 8•17 years ago
|
||
Verified fixed on trunk and 1.9.1 on all platforms with builds like
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2a1pre) Gecko/20090604 Minefield/3.6a1pre ID:20090604031228
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1pre) Gecko/20090604 Shiretoko/3.5pre ID:20090604031153
Status: RESOLVED → VERIFIED
Keywords: fixed1.9.1 → verified1.9.1
Hardware: x86 → All
Target Milestone: --- → mozilla1.9.2a1
You need to log in
before you can comment on or make changes to this bug.
Description
•