Mercurial > libavcodec.hg
annotate dvdsub_parser.c @ 11515:34080d73a504 libavcodec
fix minor typo
author | kostya |
---|---|
date | Sun, 21 Mar 2010 10:26:09 +0000 |
parents | 043574c5c153 |
children |
rev | line source |
---|---|
4091 | 1 /* |
2 * DVD subtitle decoding for ffmpeg | |
8629
04423b2f6e0b
cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents:
8573
diff
changeset
|
3 * Copyright (c) 2005 Fabrice Bellard |
4091 | 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 */ | |
8573
2acf0ae7b041
Fix build: Add intreadwrite.h and bswap.h #includes where necessary.
diego
parents:
5399
diff
changeset
|
21 |
2acf0ae7b041
Fix build: Add intreadwrite.h and bswap.h #includes where necessary.
diego
parents:
5399
diff
changeset
|
22 #include "libavutil/intreadwrite.h" |
4091 | 23 #include "avcodec.h" |
24 | |
25 /* parser definition */ | |
26 typedef struct DVDSubParseContext { | |
27 uint8_t *packet; | |
28 int packet_len; | |
29 int packet_index; | |
30 } DVDSubParseContext; | |
31 | |
9007
043574c5c153
Add missing av_cold in static init/close functions.
stefano
parents:
8629
diff
changeset
|
32 static av_cold int dvdsub_parse_init(AVCodecParserContext *s) |
4091 | 33 { |
34 return 0; | |
35 } | |
36 | |
37 static int dvdsub_parse(AVCodecParserContext *s, | |
38 AVCodecContext *avctx, | |
4931
0d1cc37d9430
make some parser parameters const to avoid casting const to non-const
aurel
parents:
4924
diff
changeset
|
39 const uint8_t **poutbuf, int *poutbuf_size, |
4091 | 40 const uint8_t *buf, int buf_size) |
41 { | |
42 DVDSubParseContext *pc = s->priv_data; | |
43 | |
44 if (pc->packet_index == 0) { | |
45 if (buf_size < 2) | |
46 return 0; | |
4438
fe3179006730
Remove the getbe16 functions and use the AV_RB16 macro instead. Patch by Ian
takis
parents:
4437
diff
changeset
|
47 pc->packet_len = AV_RB16(buf); |
5399
27b3ee661472
Update the dvdsub parser to be able to parse HD-DVD subtitle packets.
takis
parents:
4931
diff
changeset
|
48 if (pc->packet_len == 0) /* HD-DVD subpicture packet */ |
27b3ee661472
Update the dvdsub parser to be able to parse HD-DVD subtitle packets.
takis
parents:
4931
diff
changeset
|
49 pc->packet_len = AV_RB32(buf+2); |
4091 | 50 av_freep(&pc->packet); |
51 pc->packet = av_malloc(pc->packet_len); | |
52 } | |
53 if (pc->packet) { | |
54 if (pc->packet_index + buf_size <= pc->packet_len) { | |
55 memcpy(pc->packet + pc->packet_index, buf, buf_size); | |
56 pc->packet_index += buf_size; | |
57 if (pc->packet_index >= pc->packet_len) { | |
58 *poutbuf = pc->packet; | |
59 *poutbuf_size = pc->packet_len; | |
60 pc->packet_index = 0; | |
61 return buf_size; | |
62 } | |
63 } else { | |
64 /* erroneous size */ | |
65 pc->packet_index = 0; | |
66 } | |
67 } | |
68 *poutbuf = NULL; | |
69 *poutbuf_size = 0; | |
70 return buf_size; | |
71 } | |
72 | |
9007
043574c5c153
Add missing av_cold in static init/close functions.
stefano
parents:
8629
diff
changeset
|
73 static av_cold void dvdsub_parse_close(AVCodecParserContext *s) |
4091 | 74 { |
75 DVDSubParseContext *pc = s->priv_data; | |
76 av_freep(&pc->packet); | |
77 } | |
78 | |
79 AVCodecParser dvdsub_parser = { | |
80 { CODEC_ID_DVD_SUBTITLE }, | |
81 sizeof(DVDSubParseContext), | |
82 dvdsub_parse_init, | |
83 dvdsub_parse, | |
84 dvdsub_parse_close, | |
85 }; |