}
static int ass_encode_frame(AVCodecContext *avctx,
- unsigned char *buf, int bufsize, void *data)
+ unsigned char *buf, int bufsize,
+ const AVSubtitle *sub)
{
- AVSubtitle *sub = data;
int i, len, total_len = 0;
for (i=0; i<sub->num_rects; i++) {
.type = AVMEDIA_TYPE_SUBTITLE,
.id = AV_CODEC_ID_SSA,
.init = ass_encode_init,
- .encode = ass_encode_frame,
+ .encode_sub = ass_encode_frame,
};
typedef struct AVCodecDefault AVCodecDefault;
+struct AVSubtitle;
+
/**
* AVCodec.
*/
void (*init_static_data)(struct AVCodec *codec);
int (*init)(AVCodecContext *);
- int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
+ int (*encode_sub)(AVCodecContext *, uint8_t *buf, int buf_size,
+ const struct AVSubtitle *sub);
/**
* Encode data to an AVPacket.
*
}
static int encode_dvb_subtitles(DVBSubtitleContext *s,
- uint8_t *outbuf, AVSubtitle *h)
+ uint8_t *outbuf, const AVSubtitle *h)
{
uint8_t *q, *pseg_len;
int page_id, region_id, clut_id, object_id, i, bpp_index, page_state;
}
static int dvbsub_encode(AVCodecContext *avctx,
- unsigned char *buf, int buf_size, void *data)
+ unsigned char *buf, int buf_size,
+ const AVSubtitle *sub)
{
DVBSubtitleContext *s = avctx->priv_data;
- AVSubtitle *sub = data;
int ret;
ret = encode_dvb_subtitles(s, buf, sub);
.type = AVMEDIA_TYPE_SUBTITLE,
.id = AV_CODEC_ID_DVB_SUBTITLE,
.priv_data_size = sizeof(DVBSubtitleContext),
- .encode = dvbsub_encode,
+ .encode_sub = dvbsub_encode,
.long_name = NULL_IF_CONFIG_SMALL("DVB subtitles"),
};
}
static int dvdsub_encode(AVCodecContext *avctx,
- unsigned char *buf, int buf_size, void *data)
+ unsigned char *buf, int buf_size,
+ const AVSubtitle *sub)
{
//DVDSubtitleContext *s = avctx->priv_data;
- AVSubtitle *sub = data;
int ret;
ret = encode_dvd_subtitles(buf, buf_size, sub);
.name = "dvdsub",
.type = AVMEDIA_TYPE_SUBTITLE,
.id = AV_CODEC_ID_DVD_SUBTITLE,
- .encode = dvdsub_encode,
+ .encode_sub = dvdsub_encode,
.long_name = NULL_IF_CONFIG_SMALL("DVD subtitles"),
};
int av_codec_is_encoder(const AVCodec *codec)
{
- return codec && (codec->encode || codec->encode2);
+ return codec && (codec->encode_sub || codec->encode2);
}
int av_codec_is_decoder(const AVCodec *codec)
}
if(sub->num_rects == 0 || !sub->rects)
return -1;
- ret = avctx->codec->encode(avctx, buf, buf_size, sub);
+ ret = avctx->codec->encode_sub(avctx, buf, buf_size, sub);
avctx->frame_number++;
return ret;
}
}
static int xsub_encode(AVCodecContext *avctx, unsigned char *buf,
- int bufsize, void *data)
+ int bufsize, const AVSubtitle *h)
{
- AVSubtitle *h = data;
uint64_t startTime = h->pts / 1000; // FIXME: need better solution...
uint64_t endTime = startTime + h->end_display_time - h->start_display_time;
int start_tc[4], end_tc[4];
.type = AVMEDIA_TYPE_SUBTITLE,
.id = AV_CODEC_ID_XSUB,
.init = xsub_encoder_init,
- .encode = xsub_encode,
+ .encode_sub= xsub_encode,
.long_name = NULL_IF_CONFIG_SMALL("DivX subtitles (XSUB)"),
};