History

lavc: replace AVCodecContext.encode with subtitle-specific callback

AVCodecContext.encode is currently used only for subtitles, encode2 is used for audio and video.

Anton Khirnov committed 14 years ago

Commit 466b39e1 parent 9f64c826 files · +18 −16Browse files

Unified · Split

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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t