Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
avcodec/utils: Add utility functions for bsf
Several bitstream filters (e.g. dump_extradata, imxdump, mjpeg2jpeg, mjpegadump, mp3decomp, ...) don't buffer packets; instead, they just modify the buffer of one packet and don't change any other of the packet's non-buffer properties. The usual approach of these bitstream filters is to use separate packets for in- and output as follows: 1. Get the input packet via ff_bsf_get_packet which entails an allocation. 2. Use av_new_packet to allocate a big enough buffer in the output packet. 3. Perform the actual work of the bitstream filter, i.e. fill the output buffer. 4. Use av_packet_copy_props to copy the non-buffer fields of the input packet to the output packet. 5. Free the input packet and return. This commit adds two utility functions that allow a different approach: A function to (re)allocate a refcounted buffer with zeroed padding and a function to replace a packet's buffer and the buffer-related fields with information from an AVBufferRef. This allows to modify the bitstream filters as follows: 1. Get the packet via ff_bsf_get_packet_ref. 2. Use ff_buffer_padded_realloc to get a big enough refcounted buffer. 3. Perform the actual work of the bitstream filter. 4. Use ff_packet_replace_buffer to replace the old data in the packet with the modified one and return. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
- Loading branch information