Commit bf070a91 authored by Michael Kuron's avatar Michael Kuron Committed by Michael Niedermayer

lavc/dvdsubdec: Move palette parsing to new function

Signed-off-by: 's avatarMichael Kuron <michael.kuron@gmail.com>
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent a15618d2
...@@ -283,6 +283,7 @@ OBJS-$(CONFIG_DST_DECODER) += dstdec.o dsd.o ...@@ -283,6 +283,7 @@ OBJS-$(CONFIG_DST_DECODER) += dstdec.o dsd.o
OBJS-$(CONFIG_DVBSUB_DECODER) += dvbsubdec.o OBJS-$(CONFIG_DVBSUB_DECODER) += dvbsubdec.o
OBJS-$(CONFIG_DVBSUB_ENCODER) += dvbsub.o OBJS-$(CONFIG_DVBSUB_ENCODER) += dvbsub.o
OBJS-$(CONFIG_DVDSUB_DECODER) += dvdsubdec.o OBJS-$(CONFIG_DVDSUB_DECODER) += dvdsubdec.o
OBJS-$(CONFIG_DVDSUB_DECODER) += dvdsub.o
OBJS-$(CONFIG_DVDSUB_ENCODER) += dvdsubenc.o OBJS-$(CONFIG_DVDSUB_ENCODER) += dvdsubenc.o
OBJS-$(CONFIG_DVAUDIO_DECODER) += dvaudiodec.o OBJS-$(CONFIG_DVAUDIO_DECODER) += dvaudiodec.o
OBJS-$(CONFIG_DVVIDEO_DECODER) += dvdec.o dv.o dvdata.o OBJS-$(CONFIG_DVVIDEO_DECODER) += dvdec.o dv.o dvdata.o
......
/*
* DVD subtitle decoding/encoding
* Copyright (c) 2005 Fabrice Bellard
*
* 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.1 of the License, or (at your option) any later version.
*
* 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 FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "internal.h"
#include "libavutil/avstring.h"
#include <stdlib.h>
void ff_dvdsub_parse_palette(uint32_t *palette, const char *p)
{
for (int i = 0; i < 16; i++) {
palette[i] = strtoul(p, &p, 16);
while (*p == ',' || av_isspace(*p))
p++;
}
}
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "libavutil/colorspace.h" #include "libavutil/colorspace.h"
#include "libavutil/opt.h" #include "libavutil/opt.h"
#include "libavutil/imgutils.h" #include "libavutil/imgutils.h"
#include "libavutil/avstring.h"
#include "libavutil/bswap.h" #include "libavutil/bswap.h"
typedef struct DVDSubContext typedef struct DVDSubContext
...@@ -626,18 +625,6 @@ static int dvdsub_decode(AVCodecContext *avctx, ...@@ -626,18 +625,6 @@ static int dvdsub_decode(AVCodecContext *avctx,
return buf_size; return buf_size;
} }
static void parse_palette(DVDSubContext *ctx, char *p)
{
int i;
ctx->has_palette = 1;
for(i=0;i<16;i++) {
ctx->palette[i] = strtoul(p, &p, 16);
while(*p == ',' || av_isspace(*p))
p++;
}
}
static int parse_ifo_palette(DVDSubContext *ctx, char *p) static int parse_ifo_palette(DVDSubContext *ctx, char *p)
{ {
FILE *ifo; FILE *ifo;
...@@ -719,7 +706,8 @@ static int dvdsub_parse_extradata(AVCodecContext *avctx) ...@@ -719,7 +706,8 @@ static int dvdsub_parse_extradata(AVCodecContext *avctx)
break; break;
if (strncmp("palette:", data, 8) == 0) { if (strncmp("palette:", data, 8) == 0) {
parse_palette(ctx, data + 8); ctx->has_palette = 1;
ff_dvdsub_parse_palette(ctx->palette, data + 8);
} else if (strncmp("size:", data, 5) == 0) { } else if (strncmp("size:", data, 5) == 0) {
int w, h; int w, h;
if (sscanf(data + 5, "%dx%d", &w, &h) == 2) { if (sscanf(data + 5, "%dx%d", &w, &h) == 2) {
...@@ -748,8 +736,10 @@ static av_cold int dvdsub_init(AVCodecContext *avctx) ...@@ -748,8 +736,10 @@ static av_cold int dvdsub_init(AVCodecContext *avctx)
if (ctx->ifo_str) if (ctx->ifo_str)
parse_ifo_palette(ctx, ctx->ifo_str); parse_ifo_palette(ctx, ctx->ifo_str);
if (ctx->palette_str) if (ctx->palette_str) {
parse_palette(ctx, ctx->palette_str); ctx->has_palette = 1;
ff_dvdsub_parse_palette(ctx->palette, ctx->palette_str);
}
if (ctx->has_palette) { if (ctx->has_palette) {
int i; int i;
av_log(avctx, AV_LOG_DEBUG, "palette:"); av_log(avctx, AV_LOG_DEBUG, "palette:");
......
...@@ -433,6 +433,8 @@ int64_t ff_guess_coded_bitrate(AVCodecContext *avctx); ...@@ -433,6 +433,8 @@ int64_t ff_guess_coded_bitrate(AVCodecContext *avctx);
int ff_int_from_list_or_default(void *ctx, const char * val_name, int val, int ff_int_from_list_or_default(void *ctx, const char * val_name, int val,
const int * array_valid_values, int default_value); const int * array_valid_values, int default_value);
void ff_dvdsub_parse_palette(uint32_t *palette, const char *p);
#if defined(_WIN32) && CONFIG_SHARED && !defined(BUILDING_avcodec) #if defined(_WIN32) && CONFIG_SHARED && !defined(BUILDING_avcodec)
# define av_export_avcodec __declspec(dllimport) # define av_export_avcodec __declspec(dllimport)
#else #else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment