mirror of https://git.ffmpeg.org/ffmpeg.git
avcodec/bsf: Add ff_bsf_get_packet_ref() function
Use of this function can save unnecessary malloc operation in bitstream filter. Signed-off-by: Jan Sebechlebsky <sebechlebskyjan@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
This commit is contained in:
parent
21733b39d0
commit
87d5686151
|
@ -227,3 +227,19 @@ int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt)
|
||||||
|
{
|
||||||
|
AVBSFInternal *in = ctx->internal;
|
||||||
|
|
||||||
|
if (in->eof)
|
||||||
|
return AVERROR_EOF;
|
||||||
|
|
||||||
|
if (!ctx->internal->buffer_pkt->data &&
|
||||||
|
!ctx->internal->buffer_pkt->side_data_elems)
|
||||||
|
return AVERROR(EAGAIN);
|
||||||
|
|
||||||
|
av_packet_move_ref(pkt, ctx->internal->buffer_pkt);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,17 @@
|
||||||
*/
|
*/
|
||||||
int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt);
|
int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by bitstream filters to get packet for filtering.
|
||||||
|
* The reference to packet is moved to provided packet structure.
|
||||||
|
*
|
||||||
|
* @param ctx pointer to AVBSFContext of filter
|
||||||
|
* @param pkt pointer to packet to move reference to
|
||||||
|
*
|
||||||
|
* @return 0>= on success, negative AVERROR in case of failure
|
||||||
|
*/
|
||||||
|
int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt);
|
||||||
|
|
||||||
const AVClass *ff_bsf_child_class_next(const AVClass *prev);
|
const AVClass *ff_bsf_child_class_next(const AVClass *prev);
|
||||||
|
|
||||||
#endif /* AVCODEC_BSF_H */
|
#endif /* AVCODEC_BSF_H */
|
||||||
|
|
Loading…
Reference in New Issue