2 * Copyright (c) 2008 Reimar Döffinger
4 * This file is part of FFmpeg.
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "libavutil/common.h"
22 #include "libavutil/intreadwrite.h"
24 #include "bsf_internal.h"
26 static int text2movsub(AVBSFContext *ctx, AVPacket *out)
31 ret = ff_bsf_get_packet(ctx, &in);
35 if (in->size > 0xffff) {
36 ret = AVERROR_INVALIDDATA;
40 ret = av_new_packet(out, in->size + 2);
42 ret = AVERROR(ENOMEM);
46 ret = av_packet_copy_props(out, in);
50 AV_WB16(out->data, in->size);
51 memcpy(out->data + 2, in->data, in->size);
60 const AVBitStreamFilter ff_text2movsub_bsf = {
61 .name = "text2movsub",
62 .filter = text2movsub,
65 static int mov2textsub(AVBSFContext *ctx, AVPacket *pkt)
69 ret = ff_bsf_get_packet_ref(ctx, pkt);
75 return AVERROR_INVALIDDATA;
78 pkt->size = FFMIN(pkt->size - 2, AV_RB16(pkt->data));
84 const AVBitStreamFilter ff_mov2textsub_bsf = {
85 .name = "mov2textsub",
86 .filter = mov2textsub,