diff options
author | Anton Khirnov <anton@khirnov.net> | 2012-08-18 16:41:24 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2012-09-17 15:48:20 +0200 |
commit | 466b39efaf09adecc7314eaba5904b0ee8442528 (patch) | |
tree | aeb8839317065d0df14454019d13f96ad77f1d92 | |
parent | 9f64c8219ada4bd48927abaa5eebd7ff9ba95f61 (diff) | |
download | ffmpeg-466b39efaf09adecc7314eaba5904b0ee8442528.tar.gz |
lavc: replace AVCodecContext.encode with subtitle-specific callback
AVCodecContext.encode is currently used only for subtitles, encode2 is
used for audio and video.
-rw-r--r-- | libavcodec/assenc.c | 6 | ||||
-rw-r--r-- | libavcodec/avcodec.h | 5 | ||||
-rw-r--r-- | libavcodec/dvbsub.c | 8 | ||||
-rw-r--r-- | libavcodec/dvdsubenc.c | 6 | ||||
-rw-r--r-- | libavcodec/utils.c | 4 | ||||
-rw-r--r-- | libavcodec/xsubenc.c | 5 |
6 files changed, 18 insertions, 16 deletions
diff --git a/libavcodec/assenc.c b/libavcodec/assenc.c index 6b4462349c..caf266e037 100644 --- a/libavcodec/assenc.c +++ b/libavcodec/assenc.c @@ -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, }; diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index d0c5e07d10..c5cdf41ed3 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -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. * diff --git a/libavcodec/dvbsub.c b/libavcodec/dvbsub.c index 51317f0a87..26d14bd363 100644 --- a/libavcodec/dvbsub.c +++ b/libavcodec/dvbsub.c @@ -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"), }; diff --git a/libavcodec/dvdsubenc.c b/libavcodec/dvdsubenc.c index c41a98394d..5e362b7f64 100644 --- a/libavcodec/dvdsubenc.c +++ b/libavcodec/dvdsubenc.c @@ -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"), }; diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 23ac50038f..f56dd7b793 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -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; } diff --git a/libavcodec/xsubenc.c b/libavcodec/xsubenc.c index ff3b495a03..6f359a1d6e 100644 --- a/libavcodec/xsubenc.c +++ b/libavcodec/xsubenc.c @@ -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)"), }; |