Commit 240c1657 authored by Fabrice Bellard's avatar Fabrice Bellard

subtitle codec type support

Originally committed as revision 4346 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent c62112ff
...@@ -17,8 +17,8 @@ OBJS= bitstream.o utils.o mem.o allcodecs.o \ ...@@ -17,8 +17,8 @@ OBJS= bitstream.o utils.o mem.o allcodecs.o \
ratecontrol.o adpcm.o eval.o error_resilience.o \ ratecontrol.o adpcm.o eval.o error_resilience.o \
fft.o mdct.o raw.o golomb.o cabac.o\ fft.o mdct.o raw.o golomb.o cabac.o\
dpcm.o adx.o rational.o faandct.o parser.o g726.o \ dpcm.o adx.o rational.o faandct.o parser.o g726.o \
vp3dsp.o integer.o h264idct.o rangecoder.o pnm.o h263.o msmpeg4.o h263dec.o vp3dsp.o integer.o h264idct.o rangecoder.o pnm.o h263.o msmpeg4.o h263dec.o dvdsub.o dvbsub.o
ifeq ($(CONFIG_AASC_DECODER),yes) ifeq ($(CONFIG_AASC_DECODER),yes)
OBJS+= aasc.o OBJS+= aasc.o
endif endif
......
...@@ -551,6 +551,10 @@ PCM_CODEC(CODEC_ID_ADPCM_SWF, adpcm_swf); ...@@ -551,6 +551,10 @@ PCM_CODEC(CODEC_ID_ADPCM_SWF, adpcm_swf);
#undef PCM_CODEC #undef PCM_CODEC
/* subtitles */
register_avcodec(&dvdsub_decoder);
register_avcodec(&dvbsub_encoder);
/* parsers */ /* parsers */
av_register_codec_parser(&mpegvideo_parser); av_register_codec_parser(&mpegvideo_parser);
av_register_codec_parser(&mpeg4video_parser); av_register_codec_parser(&mpeg4video_parser);
...@@ -568,5 +572,6 @@ PCM_CODEC(CODEC_ID_ADPCM_SWF, adpcm_swf); ...@@ -568,5 +572,6 @@ PCM_CODEC(CODEC_ID_ADPCM_SWF, adpcm_swf);
#ifdef CONFIG_AC3 #ifdef CONFIG_AC3
av_register_codec_parser(&ac3_parser); av_register_codec_parser(&ac3_parser);
#endif #endif
av_register_codec_parser(&dvdsub_parser);
} }
...@@ -17,7 +17,7 @@ extern "C" { ...@@ -17,7 +17,7 @@ extern "C" {
#define FFMPEG_VERSION_INT 0x000409 #define FFMPEG_VERSION_INT 0x000409
#define FFMPEG_VERSION "0.4.9-pre1" #define FFMPEG_VERSION "0.4.9-pre1"
#define LIBAVCODEC_BUILD 4755 #define LIBAVCODEC_BUILD 4756
#define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT #define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT
#define LIBAVCODEC_VERSION FFMPEG_VERSION #define LIBAVCODEC_VERSION FFMPEG_VERSION
...@@ -175,6 +175,10 @@ enum CodecID { ...@@ -175,6 +175,10 @@ enum CodecID {
CODEC_ID_GSM, CODEC_ID_GSM,
CODEC_ID_OGGTHEORA= 0x16000, CODEC_ID_OGGTHEORA= 0x16000,
/* subtitle codecs */
CODEC_ID_DVD_SUBTITLE= 0x17000,
CODEC_ID_DVB_SUBTITLE,
CODEC_ID_MPEG2TS= 0x20000, /* _FAKE_ codec to indicate a raw MPEG2 transport CODEC_ID_MPEG2TS= 0x20000, /* _FAKE_ codec to indicate a raw MPEG2 transport
stream (only used by libavformat) */ stream (only used by libavformat) */
...@@ -188,6 +192,7 @@ enum CodecType { ...@@ -188,6 +192,7 @@ enum CodecType {
CODEC_TYPE_VIDEO, CODEC_TYPE_VIDEO,
CODEC_TYPE_AUDIO, CODEC_TYPE_AUDIO,
CODEC_TYPE_DATA, CODEC_TYPE_DATA,
CODEC_TYPE_SUBTITLE,
}; };
/** /**
...@@ -1880,6 +1885,20 @@ typedef struct AVPaletteControl { ...@@ -1880,6 +1885,20 @@ typedef struct AVPaletteControl {
} AVPaletteControl; } AVPaletteControl;
typedef struct AVSubtitle {
uint16_t format; /* 0 = graphics */
uint16_t x;
uint16_t y;
uint16_t w;
uint16_t h;
uint16_t nb_colors;
uint32_t start_display_time; /* relative to packet pts, in ms */
uint32_t end_display_time; /* relative to packet pts, in ms */
int linesize;
uint32_t *rgba_palette;
uint8_t *bitmap;
} AVSubtitle;
extern AVCodec ac3_encoder; extern AVCodec ac3_encoder;
extern AVCodec mp2_encoder; extern AVCodec mp2_encoder;
extern AVCodec mp3lame_encoder; extern AVCodec mp3lame_encoder;
...@@ -2067,6 +2086,10 @@ extern AVCodec rawvideo_decoder; ...@@ -2067,6 +2086,10 @@ extern AVCodec rawvideo_decoder;
extern AVCodec ac3_decoder; extern AVCodec ac3_decoder;
extern AVCodec dts_decoder; extern AVCodec dts_decoder;
/* subtitles */
extern AVCodec dvdsub_decoder;
extern AVCodec dvbsub_encoder;
/* resample.c */ /* resample.c */
struct ReSampleContext; struct ReSampleContext;
...@@ -2204,6 +2227,9 @@ int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples, ...@@ -2204,6 +2227,9 @@ int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
int *got_picture_ptr, int *got_picture_ptr,
uint8_t *buf, int buf_size); uint8_t *buf, int buf_size);
int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub,
int *got_sub_ptr,
const uint8_t *buf, int buf_size);
int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata, int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata,
int *data_size_ptr, int *data_size_ptr,
uint8_t *buf, int buf_size); uint8_t *buf, int buf_size);
...@@ -2211,6 +2237,8 @@ int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, ...@@ -2211,6 +2237,8 @@ int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
const short *samples); const short *samples);
int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
const AVFrame *pict); const AVFrame *pict);
int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
const AVSubtitle *sub);
int avcodec_close(AVCodecContext *avctx); int avcodec_close(AVCodecContext *avctx);
...@@ -2310,6 +2338,7 @@ extern AVCodecParser mjpeg_parser; ...@@ -2310,6 +2338,7 @@ extern AVCodecParser mjpeg_parser;
extern AVCodecParser pnm_parser; extern AVCodecParser pnm_parser;
extern AVCodecParser mpegaudio_parser; extern AVCodecParser mpegaudio_parser;
extern AVCodecParser ac3_parser; extern AVCodecParser ac3_parser;
extern AVCodecParser dvdsub_parser;
/* memory */ /* memory */
void *av_malloc(unsigned int size); void *av_malloc(unsigned int size);
......
This diff is collapsed.
This diff is collapsed.
...@@ -590,6 +590,15 @@ int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, ...@@ -590,6 +590,15 @@ int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
return 0; return 0;
} }
int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
const AVSubtitle *sub)
{
int ret;
ret = avctx->codec->encode(avctx, buf, buf_size, (void *)sub);
avctx->frame_number++;
return ret;
}
/** /**
* decode a frame. * decode a frame.
* @param buf bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE larger then the actual read bytes * @param buf bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE larger then the actual read bytes
...@@ -639,6 +648,23 @@ int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples, ...@@ -639,6 +648,23 @@ int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
return ret; return ret;
} }
/* decode a subtitle message. return -1 if error, otherwise return the
*number of bytes used. If no subtitle could be decompressed,
*got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */
int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub,
int *got_sub_ptr,
const uint8_t *buf, int buf_size)
{
int ret;
*got_sub_ptr = 0;
ret = avctx->codec->decode(avctx, sub, got_sub_ptr,
(uint8_t *)buf, buf_size);
if (*got_sub_ptr)
avctx->frame_number++;
return ret;
}
int avcodec_close(AVCodecContext *avctx) int avcodec_close(AVCodecContext *avctx)
{ {
if (avctx->codec->close) if (avctx->codec->close)
...@@ -808,6 +834,10 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) ...@@ -808,6 +834,10 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
snprintf(buf, buf_size, "Data: %s", codec_name); snprintf(buf, buf_size, "Data: %s", codec_name);
bitrate = enc->bit_rate; bitrate = enc->bit_rate;
break; break;
case CODEC_TYPE_SUBTITLE:
snprintf(buf, buf_size, "Subtitle: %s", codec_name);
bitrate = enc->bit_rate;
break;
default: default:
snprintf(buf, buf_size, "Invalid Codec type %d", enc->codec_type); snprintf(buf, buf_size, "Invalid Codec type %d", enc->codec_type);
return; return;
......
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