The code currently use cur_buf as the target of the copy, but cur_buf can be cleared by the filter if it has given the reference away or stored it elsewhere as soon as start_frame. The code still relies on the fact that the reference is not destroyed until end_frame. All filters currently follow that condition. An av_assert1() is added to check it; it should at least cause very visible errors in valgrind.
Showing the changes to libavfilter/avfilter.h (1 of 2 files). Show all
Unified · Split
| @@ -669,6 +669,15 @@ struct AVFilterLink { · 668 unmodified lines | ||
| 669 | 669 | * called with more samples, it will split them. |
| 670 | 670 | */ |
| 671 | 671 | int max_samples; |
| 672 | + | |
| 673 | + /** | |
| 674 | + * The buffer reference currently being received across the link by the | |
| 675 | + * destination filter. This is used internally by the filter system to | |
| 676 | + * allow automatic copying of buffers which do not have sufficient | |
| 677 | + * permissions for the destination. This should not be accessed directly | |
| 678 | + * by the filters. | |
| 679 | + */ | |
| 680 | + AVFilterBufferRef *cur_buf_copy; | |
| 672 | 681 | }; |
| 673 | 682 | |
| 674 | 683 | /** |