1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avcodec/bsf: use av_packet_make_refcounted to ensure packets are ref counted

Simplifies code.

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer 2018-03-25 00:23:58 -03:00
parent 38fa61b947
commit 265ec55983

View File

@ -174,6 +174,8 @@ int av_bsf_init(AVBSFContext *ctx)
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt) int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
{ {
int ret;
if (!pkt || (!pkt->data && !pkt->side_data_elems)) { if (!pkt || (!pkt->data && !pkt->side_data_elems)) {
ctx->internal->eof = 1; ctx->internal->eof = 1;
return 0; return 0;
@ -188,15 +190,10 @@ int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
ctx->internal->buffer_pkt->side_data_elems) ctx->internal->buffer_pkt->side_data_elems)
return AVERROR(EAGAIN); return AVERROR(EAGAIN);
if (pkt->buf) { ret = av_packet_make_refcounted(pkt);
av_packet_move_ref(ctx->internal->buffer_pkt, pkt); if (ret < 0)
} else { return ret;
int ret = av_packet_ref(ctx->internal->buffer_pkt, pkt); av_packet_move_ref(ctx->internal->buffer_pkt, pkt);
if (ret < 0)
return ret;
av_packet_unref(pkt);
}
return 0; return 0;
} }