mirror of https://git.ffmpeg.org/ffmpeg.git
lavc: replace AVCodecContext.encode with subtitle-specific callback
AVCodecContext.encode is currently used only for subtitles, encode2 is used for audio and video.
This commit is contained in:
parent
9f64c8219a
commit
466b39efaf
|
@ -37,9 +37,9 @@ static av_cold int ass_encode_init(AVCodecContext *avctx)
|
|||
}
|
||||
|
||||
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++) {
|
||||
|
@ -67,5 +67,5 @@ AVCodec ff_ass_encoder = {
|
|||
.type = AVMEDIA_TYPE_SUBTITLE,
|
||||
.id = AV_CODEC_ID_SSA,
|
||||
.init = ass_encode_init,
|
||||
.encode = ass_encode_frame,
|
||||
.encode_sub = ass_encode_frame,
|
||||
};
|
||||
|
|
|
@ -2901,6 +2901,8 @@ typedef struct AVProfile {
|
|||
|
||||
typedef struct AVCodecDefault AVCodecDefault;
|
||||
|
||||
struct AVSubtitle;
|
||||
|
||||
/**
|
||||
* AVCodec.
|
||||
*/
|
||||
|
@ -2973,7 +2975,8 @@ typedef struct 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.
|
||||
*
|
||||
|
|
|
@ -195,7 +195,7 @@ static void dvb_encode_rle4(uint8_t **pq,
|
|||
}
|
||||
|
||||
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;
|
||||
|
@ -392,10 +392,10 @@ static int encode_dvb_subtitles(DVBSubtitleContext *s,
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -407,6 +407,6 @@ AVCodec ff_dvbsub_encoder = {
|
|||
.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"),
|
||||
};
|
||||
|
|
|
@ -205,10 +205,10 @@ static int encode_dvd_subtitles(uint8_t *outbuf, int outbuf_size,
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -219,6 +219,6 @@ AVCodec ff_dvdsub_encoder = {
|
|||
.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"),
|
||||
};
|
||||
|
|
|
@ -115,7 +115,7 @@ static void avcodec_init(void)
|
|||
|
||||
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)
|
||||
|
@ -1174,7 +1174,7 @@ int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
|
|||
}
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -111,9 +111,8 @@ static int make_tc(uint64_t ms, int *tc)
|
|||
}
|
||||
|
||||
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];
|
||||
|
@ -215,6 +214,6 @@ AVCodec ff_xsub_encoder = {
|
|||
.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)"),
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue