AVCodecContext.encode is currently used only for subtitles, encode2 is used for audio and video.
Unified · Split
| @@ -37,9 +37,9 @@ static av_cold int ass_encode_init(AVCodecContext *avctx) · 36 unmodified lines | ||
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | static int ass_encode_frame(AVCodecContext *avctx, |
| 40 | − unsigned char *buf, int bufsize, void *data) | |
| 40 | + unsigned char *buf, int bufsize, | |
| 41 | + const AVSubtitle *sub) | |
| 41 | 42 | { |
| 42 | − AVSubtitle *sub = data; | |
| 43 | 43 | int i, len, total_len = 0; |
| 44 | 44 | |
| 45 | 45 | for (i=0; i<sub->num_rects; i++) { |
| @@ -67,5 +67,5 @@ AVCodec ff_ass_encoder = { · 21 unmodified lines | ||
| 67 | 67 | .type = AVMEDIA_TYPE_SUBTITLE, |
| 68 | 68 | .id = AV_CODEC_ID_SSA, |
| 69 | 69 | .init = ass_encode_init, |
| 70 | − .encode = ass_encode_frame, | |
| 70 | + .encode_sub = ass_encode_frame, | |
| 71 | 71 | }; |
| @@ -2901,6 +2901,8 @@ typedef struct AVProfile { · 2900 unmodified lines | ||
| 2901 | 2901 | |
| 2902 | 2902 | typedef struct AVCodecDefault AVCodecDefault; |
| 2903 | 2903 | |
| 2904 | +struct AVSubtitle; | |
| 2905 | + | |
| 2904 | 2906 | /** |
| 2905 | 2907 | * AVCodec. |
| 2906 | 2908 | */ |
| @@ -2973,7 +2975,8 @@ typedef struct AVCodec { · 66 unmodified lines | ||
| 2973 | 2975 | void (*init_static_data)(struct AVCodec *codec); |
| 2974 | 2976 | |
| 2975 | 2977 | int (*init)(AVCodecContext *); |
| 2976 | − int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data); | |
| 2978 | + int (*encode_sub)(AVCodecContext *, uint8_t *buf, int buf_size, | |
| 2979 | + const struct AVSubtitle *sub); | |
| 2977 | 2980 | /** |
| 2978 | 2981 | * Encode data to an AVPacket. |
| 2979 | 2982 | * |
| @@ -195,7 +195,7 @@ static void dvb_encode_rle4(uint8_t **pq, · 194 unmodified lines | ||
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | static int encode_dvb_subtitles(DVBSubtitleContext *s, |
| 198 | − uint8_t *outbuf, AVSubtitle *h) | |
| 198 | + uint8_t *outbuf, const AVSubtitle *h) | |
| 199 | 199 | { |
| 200 | 200 | uint8_t *q, *pseg_len; |
| 201 | 201 | 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, · 190 unmodified lines | ||
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | static int dvbsub_encode(AVCodecContext *avctx, |
| 395 | − unsigned char *buf, int buf_size, void *data) | |
| 395 | + unsigned char *buf, int buf_size, | |
| 396 | + const AVSubtitle *sub) | |
| 396 | 397 | { |
| 397 | 398 | DVBSubtitleContext *s = avctx->priv_data; |
| 398 | − AVSubtitle *sub = data; | |
| 399 | 399 | int ret; |
| 400 | 400 | |
| 401 | 401 | ret = encode_dvb_subtitles(s, buf, sub); |
| @@ -407,6 +407,6 @@ AVCodec ff_dvbsub_encoder = { · 5 unmodified lines | ||
| 407 | 407 | .type = AVMEDIA_TYPE_SUBTITLE, |
| 408 | 408 | .id = AV_CODEC_ID_DVB_SUBTITLE, |
| 409 | 409 | .priv_data_size = sizeof(DVBSubtitleContext), |
| 410 | − .encode = dvbsub_encode, | |
| 410 | + .encode_sub = dvbsub_encode, | |
| 411 | 411 | .long_name = NULL_IF_CONFIG_SMALL("DVB subtitles"), |
| 412 | 412 | }; |
| @@ -205,10 +205,10 @@ static int encode_dvd_subtitles(uint8_t *outbuf, int outbuf_size, · 204 unmodified lines | ||
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | static int dvdsub_encode(AVCodecContext *avctx, |
| 208 | − unsigned char *buf, int buf_size, void *data) | |
| 208 | + unsigned char *buf, int buf_size, | |
| 209 | + const AVSubtitle *sub) | |
| 209 | 210 | { |
| 210 | 211 | //DVDSubtitleContext *s = avctx->priv_data; |
| 211 | − AVSubtitle *sub = data; | |
| 212 | 212 | int ret; |
| 213 | 213 | |
| 214 | 214 | ret = encode_dvd_subtitles(buf, buf_size, sub); |
| @@ -219,6 +219,6 @@ AVCodec ff_dvdsub_encoder = { · 4 unmodified lines | ||
| 219 | 219 | .name = "dvdsub", |
| 220 | 220 | .type = AVMEDIA_TYPE_SUBTITLE, |
| 221 | 221 | .id = AV_CODEC_ID_DVD_SUBTITLE, |
| 222 | − .encode = dvdsub_encode, | |
| 222 | + .encode_sub = dvdsub_encode, | |
| 223 | 223 | .long_name = NULL_IF_CONFIG_SMALL("DVD subtitles"), |
| 224 | 224 | }; |
| @@ -115,7 +115,7 @@ static void avcodec_init(void) · 114 unmodified lines | ||
| 115 | 115 | |
| 116 | 116 | int av_codec_is_encoder(const AVCodec *codec) |
| 117 | 117 | { |
| 118 | − return codec && (codec->encode || codec->encode2); | |
| 118 | + return codec && (codec->encode_sub || codec->encode2); | |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | int av_codec_is_decoder(const AVCodec *codec) |
| @@ -1174,7 +1174,7 @@ int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, · 1052 unmodified lines | ||
| 1174 | 1174 | } |
| 1175 | 1175 | if(sub->num_rects == 0 || !sub->rects) |
| 1176 | 1176 | return -1; |
| 1177 | − ret = avctx->codec->encode(avctx, buf, buf_size, sub); | |
| 1177 | + ret = avctx->codec->encode_sub(avctx, buf, buf_size, sub); | |
| 1178 | 1178 | avctx->frame_number++; |
| 1179 | 1179 | return ret; |
| 1180 | 1180 | } |
| @@ -111,9 +111,8 @@ static int make_tc(uint64_t ms, int *tc) · 110 unmodified lines | ||
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | static int xsub_encode(AVCodecContext *avctx, unsigned char *buf, |
| 114 | − int bufsize, void *data) | |
| 114 | + int bufsize, const AVSubtitle *h) | |
| 115 | 115 | { |
| 116 | − AVSubtitle *h = data; | |
| 117 | 116 | uint64_t startTime = h->pts / 1000; // FIXME: need better solution... |
| 118 | 117 | uint64_t endTime = startTime + h->end_display_time - h->start_display_time; |
| 119 | 118 | int start_tc[4], end_tc[4]; |
| @@ -215,6 +214,6 @@ AVCodec ff_xsub_encoder = { · 95 unmodified lines | ||
| 215 | 214 | .type = AVMEDIA_TYPE_SUBTITLE, |
| 216 | 215 | .id = AV_CODEC_ID_XSUB, |
| 217 | 216 | .init = xsub_encoder_init, |
| 218 | − .encode = xsub_encode, | |
| 217 | + .encode_sub= xsub_encode, | |
| 219 | 218 | .long_name = NULL_IF_CONFIG_SMALL("DivX subtitles (XSUB)"), |
| 220 | 219 | }; |