mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-08 06:09:50 +00:00
avcodec/mov2textsub: move the reference in the bsf internal buffer
There's no need to allocate a new packet for it. Reviewed-by: Mark Thompson <sw@jkqxz.net> Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
9c6dd9d624
commit
11bef2fe72
1 changed files with 8 additions and 20 deletions
|
|
@ -62,35 +62,23 @@ const AVBitStreamFilter ff_text2movsub_bsf = {
|
||||||
.filter = text2movsub,
|
.filter = text2movsub,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int mov2textsub(AVBSFContext *ctx, AVPacket *out)
|
static int mov2textsub(AVBSFContext *ctx, AVPacket *pkt)
|
||||||
{
|
{
|
||||||
AVPacket *in;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
ret = ff_bsf_get_packet(ctx, &in);
|
ret = ff_bsf_get_packet_ref(ctx, pkt);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (in->size < 2) {
|
if (pkt->size < 2) {
|
||||||
ret = AVERROR_INVALIDDATA;
|
av_packet_unref(pkt);
|
||||||
goto fail;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = av_new_packet(out, FFMIN(in->size - 2, AV_RB16(in->data)));
|
pkt->data += 2;
|
||||||
if (ret < 0)
|
pkt->size = FFMIN(pkt->size - 2, AV_RB16(pkt->data));
|
||||||
goto fail;
|
|
||||||
|
|
||||||
ret = av_packet_copy_props(out, in);
|
return 0;
|
||||||
if (ret < 0)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
memcpy(out->data, in->data + 2, out->size);
|
|
||||||
|
|
||||||
fail:
|
|
||||||
if (ret < 0)
|
|
||||||
av_packet_unref(out);
|
|
||||||
av_packet_free(&in);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const AVBitStreamFilter ff_mov2textsub_bsf = {
|
const AVBitStreamFilter ff_mov2textsub_bsf = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue