Opened 19 years ago
Closed 19 years ago
#2984 closed enhancement (fixed)
Enhancement for finding MPEG2 startcodes
Reported by: | Owned by: | Janne Grunau | |
---|---|---|---|
Priority: | minor | Milestone: | unknown |
Component: | mythtv | Version: | 0.20 |
Severity: | low | Keywords: | |
Cc: | Ticket locked: | no |
Description
Two patches to speed up finding start codes in MPEG2 streams. One patch for recording (dtvrecorder) and one for playback (avformatdecoder).
I did some micro benchmarks comparing three scanning methods; the current one-byte-at-a-time approach, memchr(), and this three-btyes-at-a-time approach. I was expecting the memchr() to be the fastest but three-bytes-at-a-time always seemed to be quicker.
Sample output from a run on an old celeron:
Found 13437824 matches in 42.4915 seconds (three-bytes ...)
Found 13437824 matches in 54.9326 seconds (memchr())
Found 13437824 matches in 96.6009 seconds (one-byte ... current)
Problem: These patches both use nothl() for endian issues, this is undesireable. :/ But Janne says he has a way around this? :)
Also, I think danielk has said that these scanning methods are 'naive' and could be improved. If anyone has some pointers or hints on how to do that I would be interested.
Attachments (3)
Change History (7)
by , 19 years ago
Attachment: | FindMPEG2Keyframes.diff added |
---|
comment:1 by , 19 years ago
Owner: | changed from | to
---|
The algorithm is naive in that it is just searching for certain bytecodes instead of parsing the stream. This will still always work with PVR-x50 output, and still works with 99.9% of DVB/ATSC/QAM streams.
If you want too look at getting the remaining 0.1% to work, have a look at #799, it points to some sample streams via other tickets it points to. One way to make those work would be to use ffmpeg to find the frames, another would be to look at their code and extract the relevant parts, and finally you could buy copies of the relevant MPEG standards and implement something based on that.
comment:2 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
(In [12750]) Closes #2984. mpeg start code optimizations
use libavcodec's ff_find_start_code() it's three times faster than the current code in avformatdecoder and dtvrecorder (micro benchmarks) cleaned and optimized the H264 keyframe detection in H264Utils (more than 30 times faster with oprofile)
Idea and micro benchmarks by gnome42 [at] gmail.com
by , 19 years ago
Attachment: | dvbrecorder.audio_scan_code2.diff added |
---|
Use ff_find_start_code() on audio pkts too
comment:3 by , 19 years ago
Resolution: | fixed |
---|---|
Severity: | medium → low |
Status: | closed → reopened |
Found another place in dvbrecorder that could use ffmpeg's ff_find_start_code().
Attached patch with my first attempt at converting the audio pkt scan to ff_find_start_code().
comment:4 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
I won't apply the dvbrecorder.audio_scan_code2.diff patch. I doubt the effect is measurable for audio packets and the code becomes messier.
dtvrecorder patch