Opened 11 years ago
Closed 11 years ago
#2839 closed defect (needs_more_info)
Wasted work in av_new_program() and avpriv_new_chapter()
Reported by: | Po-Chun Chang | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | avformat |
Version: | unspecified | Keywords: | performance |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
The problem appears in latest revision. I have attached a simple one-line patch that fixes it.
In method av_new_program() in libavformat/utils.c, the loop in line 3431 keeps overriding "program" with "ac->programs[i]" when its "id" equals to "id" Therefore, only the last written value is visible out of the loop and all the other writes and iterations are not necessary. The patch iterates from the end of "i" and breaks the first time when "program" is set.
Similar problem also appears in avpriv_new_chapter(), the loop in line 3457. The patch iterates from the end of "i" and breaks the first time when "chapter" is set.
Attachments (2)
Change History (4)
by , 11 years ago
Attachment: | patch1.diff added |
---|
comment:1 by , 11 years ago
Component: | undetermined → avformat |
---|
using a ts stream the old loop in av_new_program() executes in 50 cpu cycles, the new after the patch in 77 cycles.
in 30 seconds the code gets about 1000 times executed in my test file which makes this loop take 0.00008% of the execution time.
Thus this code does not appear to be performance relevant and your change makes it slower. At least for the testcase i used.
also please always test performance improvment suggestions and include the test results in the ticket.
Do you have a testcase for these 2 patches that shows a improvment ?
comment:2 by , 11 years ago
Resolution: | → needs_more_info |
---|---|
Status: | new → closed |
Suggested patch part 1