Mercurial > libavcodec.hg
annotate movsub_bsf.c @ 6919:7cf90c252373 libavcodec
set coded_frame
author | michael |
---|---|
date | Wed, 28 May 2008 11:33:28 +0000 |
parents | d8a712661dff |
children | 2acf0ae7b041 |
rev | line source |
---|---|
6194
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
1 /* |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
2 * Copyright (c) 2008 Reimar Döffinger |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
3 * |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
4 * This file is part of FFmpeg. |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
5 * |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
6 * FFmpeg is free software; you can redistribute it and/or |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
7 * modify it under the terms of the GNU Lesser General Public |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
8 * License as published by the Free Software Foundation; either |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
9 * version 2.1 of the License, or (at your option) any later version. |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
10 * |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
11 * FFmpeg is distributed in the hope that it will be useful, |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
14 * Lesser General Public License for more details. |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
15 * |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
16 * You should have received a copy of the GNU Lesser General Public |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
17 * License along with FFmpeg; if not, write to the Free Software |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
19 */ |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
20 |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
21 #include "avcodec.h" |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
22 |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
23 |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
24 static int text2movsub(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
25 uint8_t **poutbuf, int *poutbuf_size, |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
26 const uint8_t *buf, int buf_size, int keyframe){ |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
27 if (buf_size > 0xffff) return 0; |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
28 *poutbuf_size = buf_size + 2; |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
29 *poutbuf = av_malloc(*poutbuf_size + FF_INPUT_BUFFER_PADDING_SIZE); |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
30 AV_WB16(*poutbuf, buf_size); |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
31 memcpy(*poutbuf + 2, buf, buf_size); |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
32 return 1; |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
33 } |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
34 |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
35 AVBitStreamFilter text2movsub_bsf={ |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
36 "text2movsub", |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
37 0, |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
38 text2movsub, |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
39 }; |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
40 |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
41 static int mov2textsub(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
42 uint8_t **poutbuf, int *poutbuf_size, |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
43 const uint8_t *buf, int buf_size, int keyframe){ |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
44 if (buf_size < 2) return 0; |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
45 *poutbuf_size = FFMIN(buf_size - 2, AV_RB16(buf)); |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
46 *poutbuf = av_malloc(*poutbuf_size + FF_INPUT_BUFFER_PADDING_SIZE); |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
47 memcpy(*poutbuf, buf + 2, *poutbuf_size); |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
48 return 1; |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
49 } |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
50 |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
51 AVBitStreamFilter mov2textsub_bsf={ |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
52 "mov2textsub", |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
53 0, |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
54 mov2textsub, |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
55 }; |