Mercurial > libavcodec.hg
annotate movsub_bsf.c @ 9271:527759ed54fb libavcodec
Globally ignore all example binaries.
author | diego |
---|---|
date | Sun, 29 Mar 2009 14:42:52 +0000 |
parents | 2acf0ae7b041 |
children |
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 |
8573
2acf0ae7b041
Fix build: Add intreadwrite.h and bswap.h #includes where necessary.
diego
parents:
6194
diff
changeset
|
21 #include "libavutil/intreadwrite.h" |
6194
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
22 #include "avcodec.h" |
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 |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
25 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
|
26 uint8_t **poutbuf, int *poutbuf_size, |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
27 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
|
28 if (buf_size > 0xffff) return 0; |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
29 *poutbuf_size = buf_size + 2; |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
30 *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
|
31 AV_WB16(*poutbuf, buf_size); |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
32 memcpy(*poutbuf + 2, buf, buf_size); |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
33 return 1; |
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 |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
36 AVBitStreamFilter text2movsub_bsf={ |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
37 "text2movsub", |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
38 0, |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
39 text2movsub, |
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 |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
42 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
|
43 uint8_t **poutbuf, int *poutbuf_size, |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
44 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
|
45 if (buf_size < 2) return 0; |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
46 *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
|
47 *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
|
48 memcpy(*poutbuf, buf + 2, *poutbuf_size); |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
49 return 1; |
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 |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
52 AVBitStreamFilter mov2textsub_bsf={ |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
53 "mov2textsub", |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
54 0, |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
55 mov2textsub, |
d8a712661dff
Add bitstream filter to convert between mov and plain text subtitles
reimar
parents:
diff
changeset
|
56 }; |