Mercurial > libavcodec.hg
annotate dvdsub_parser.c @ 5032:d47ee2d1d7da libavcodec
add proper prefix to extern mpeg audio data tables
author | aurel |
---|---|
date | Sat, 19 May 2007 00:13:35 +0000 |
parents | 0d1cc37d9430 |
children | 27b3ee661472 |
rev | line source |
---|---|
4091 | 1 /* |
2 * DVD subtitle decoding for ffmpeg | |
3 * Copyright (c) 2005 Fabrice Bellard. | |
4 * | |
5 * This file is part of FFmpeg. | |
6 * | |
7 * FFmpeg is free software; you can redistribute it and/or | |
8 * modify it under the terms of the GNU Lesser General Public | |
9 * License as published by the Free Software Foundation; either | |
10 * version 2.1 of the License, or (at your option) any later version. | |
11 * | |
12 * FFmpeg is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Lesser General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Lesser General Public | |
18 * License along with FFmpeg; if not, write to the Free Software | |
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
20 */ | |
21 #include "avcodec.h" | |
22 | |
23 /* parser definition */ | |
24 typedef struct DVDSubParseContext { | |
25 uint8_t *packet; | |
26 int packet_len; | |
27 int packet_index; | |
28 } DVDSubParseContext; | |
29 | |
30 static int dvdsub_parse_init(AVCodecParserContext *s) | |
31 { | |
32 return 0; | |
33 } | |
34 | |
35 static int dvdsub_parse(AVCodecParserContext *s, | |
36 AVCodecContext *avctx, | |
4931
0d1cc37d9430
make some parser parameters const to avoid casting const to non-const
aurel
parents:
4924
diff
changeset
|
37 const uint8_t **poutbuf, int *poutbuf_size, |
4091 | 38 const uint8_t *buf, int buf_size) |
39 { | |
40 DVDSubParseContext *pc = s->priv_data; | |
41 | |
42 if (pc->packet_index == 0) { | |
43 if (buf_size < 2) | |
44 return 0; | |
4438
fe3179006730
Remove the getbe16 functions and use the AV_RB16 macro instead. Patch by Ian
takis
parents:
4437
diff
changeset
|
45 pc->packet_len = AV_RB16(buf); |
4091 | 46 av_freep(&pc->packet); |
47 pc->packet = av_malloc(pc->packet_len); | |
48 } | |
49 if (pc->packet) { | |
50 if (pc->packet_index + buf_size <= pc->packet_len) { | |
51 memcpy(pc->packet + pc->packet_index, buf, buf_size); | |
52 pc->packet_index += buf_size; | |
53 if (pc->packet_index >= pc->packet_len) { | |
54 *poutbuf = pc->packet; | |
55 *poutbuf_size = pc->packet_len; | |
56 pc->packet_index = 0; | |
57 return buf_size; | |
58 } | |
59 } else { | |
60 /* erroneous size */ | |
61 pc->packet_index = 0; | |
62 } | |
63 } | |
64 *poutbuf = NULL; | |
65 *poutbuf_size = 0; | |
66 return buf_size; | |
67 } | |
68 | |
69 static void dvdsub_parse_close(AVCodecParserContext *s) | |
70 { | |
71 DVDSubParseContext *pc = s->priv_data; | |
72 av_freep(&pc->packet); | |
73 } | |
74 | |
75 AVCodecParser dvdsub_parser = { | |
76 { CODEC_ID_DVD_SUBTITLE }, | |
77 sizeof(DVDSubParseContext), | |
78 dvdsub_parse_init, | |
79 dvdsub_parse, | |
80 dvdsub_parse_close, | |
81 }; |