Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "avcodec.h"
00023 #include "ass.h"
00024
00025 static av_cold int ass_decode_init(AVCodecContext *avctx)
00026 {
00027 avctx->subtitle_header = av_malloc(avctx->extradata_size);
00028 if (!avctx->extradata)
00029 return AVERROR(ENOMEM);
00030 memcpy(avctx->subtitle_header, avctx->extradata, avctx->extradata_size);
00031 avctx->subtitle_header_size = avctx->extradata_size;
00032 return 0;
00033 }
00034
00035 static int ass_decode_frame(AVCodecContext *avctx, void *data, int *got_sub_ptr,
00036 AVPacket *avpkt)
00037 {
00038 const char *ptr = avpkt->data;
00039 int len, size = avpkt->size;
00040
00041 ff_ass_init(data);
00042
00043 while (size > 0) {
00044 len = ff_ass_add_rect(data, ptr, 0, 0, 1);
00045 if (len < 0)
00046 return len;
00047 ptr += len;
00048 size -= len;
00049 }
00050
00051 *got_sub_ptr = avpkt->size > 0;
00052 return avpkt->size;
00053 }
00054
00055 AVCodec ff_ass_decoder = {
00056 .name = "ass",
00057 .long_name = NULL_IF_CONFIG_SMALL("Advanced SubStation Alpha subtitle"),
00058 .type = AVMEDIA_TYPE_SUBTITLE,
00059 .id = CODEC_ID_SSA,
00060 .init = ass_decode_init,
00061 .decode = ass_decode_frame,
00062 };