* DVD subtitle decoding for ffmpeg
* Copyright (c) 2005 Fabrice Bellard.
*
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avcodec.h"
return 0;
}
-uint16_t getbe16(const uint8_t *p)
+static uint16_t getbe16(const uint8_t *p)
{
return (p[0] << 8) | p[1];
}
-int get_nibble(const uint8_t *buf, int nibble_offset)
+static int get_nibble(const uint8_t *buf, int nibble_offset)
{
return (buf[nibble_offset >> 1] >> ((1 - (nibble_offset & 1)) << 2)) & 0xf;
}
-static int decode_rle(uint8_t *bitmap, int linesize, int w, int h,
+static int decode_rle(uint8_t *bitmap, int linesize, int w, int h,
const uint8_t *buf, int nibble_offset, int buf_size)
{
unsigned int v;
{
uint8_t color_used[16];
int nb_opaque_colors, i, level, j, r, g, b;
-
+
for(i = 0; i < 4; i++)
rgba_palette[i] = 0;
nb_opaque_colors++;
}
}
-
+
if (nb_opaque_colors == 0)
return;
-
+
j = nb_opaque_colors;
memset(color_used, 0, 16);
for(i = 0; i < 4; i++) {
}
}
-static int decode_dvd_subtitles(AVSubtitle *sub_header,
+static int decode_dvd_subtitles(AVSubtitle *sub_header,
const uint8_t *buf, int buf_size)
{
int cmd_pos, pos, cmd, x1, y1, x2, y2, offset1, offset2, next_cmd_pos;
int date;
int i;
int is_menu = 0;
-
+
if (buf_size < 4)
return -1;
sub_header->rects = NULL;
date = getbe16(buf + cmd_pos);
next_cmd_pos = getbe16(buf + cmd_pos + 2);
#ifdef DEBUG
- av_log(NULL, AV_LOG_INFO, "cmd_pos=0x%04x next=0x%04x date=%d\n",
+ av_log(NULL, AV_LOG_INFO, "cmd_pos=0x%04x next=0x%04x date=%d\n",
cmd_pos, next_cmd_pos, date);
#endif
pos = cmd_pos + 4;
if (offset1 >= 0) {
int w, h;
uint8_t *bitmap;
-
+
/* decode the bitmap */
w = x2 - x1 + 1;
if (w < 0)
return -1;
}
-static int is_transp(const uint8_t *buf, int pitch, int n,
+static int is_transp(const uint8_t *buf, int pitch, int n,
const uint8_t *transp_color)
{
int i;
goto no_subtitle;
#if defined(DEBUG)
- av_log(NULL, AV_LOG_INFO, "start=%d ms end =%d ms\n",
+ av_log(NULL, AV_LOG_INFO, "start=%d ms end =%d ms\n",
sub->start_display_time,
sub->end_display_time);
ppm_save("/tmp/a.ppm", sub->rects[0].bitmap,
static int dvdsub_parse(AVCodecParserContext *s,
AVCodecContext *avctx,
- uint8_t **poutbuf, int *poutbuf_size,
+ uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size)
{
DVDSubParseContext *pc = s->priv_data;
-
+
if (pc->packet_index == 0) {
if (buf_size < 2)
return 0;