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
3737 }
3838
3939 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)
4142 {
42− AVSubtitle *sub = data;
4343 int i, len, total_len = 0;
4444
4545 for (i=0; i<sub->num_rects; i++) {
@@ -67,5 +67,5 @@ AVCodec ff_ass_encoder = { · 21 unmodified lines
6767 .type = AVMEDIA_TYPE_SUBTITLE,
6868 .id = AV_CODEC_ID_SSA,
6969 .init = ass_encode_init,
70− .encode = ass_encode_frame,
70+ .encode_sub = ass_encode_frame,
7171 };
libavcodec/avcodec.h+4−1
@@ -2901,6 +2901,8 @@ typedef struct AVProfile { · 2900 unmodified lines
29012901
29022902 typedef struct AVCodecDefault AVCodecDefault;
29032903
2904+struct AVSubtitle;
2905+
29042906 /**
29052907 * AVCodec.
29062908 */
@@ -2973,7 +2975,8 @@ typedef struct AVCodec { · 66 unmodified lines
29732975 void (*init_static_data)(struct AVCodec *codec);
29742976
29752977 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);
29772980 /**
29782981 * Encode data to an AVPacket.
29792982 *
libavcodec/dvbsub.c+4−4
@@ -195,7 +195,7 @@ static void dvb_encode_rle4(uint8_t **pq, · 194 unmodified lines
195195 }
196196
197197 static int encode_dvb_subtitles(DVBSubtitleContext *s,
198− uint8_t *outbuf, AVSubtitle *h)
198+ uint8_t *outbuf, const AVSubtitle *h)
199199 {
200200 uint8_t *q, *pseg_len;
201201 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
392392 }
393393
394394 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)
396397 {
397398 DVBSubtitleContext *s = avctx->priv_data;
398− AVSubtitle *sub = data;
399399 int ret;
400400
401401 ret = encode_dvb_subtitles(s, buf, sub);
@@ -407,6 +407,6 @@ AVCodec ff_dvbsub_encoder = { · 5 unmodified lines
407407 .type = AVMEDIA_TYPE_SUBTITLE,
408408 .id = AV_CODEC_ID_DVB_SUBTITLE,
409409 .priv_data_size = sizeof(DVBSubtitleContext),
410− .encode = dvbsub_encode,
410+ .encode_sub = dvbsub_encode,
411411 .long_name = NULL_IF_CONFIG_SMALL("DVB subtitles"),
412412 };
libavcodec/dvdsubenc.c+3−3
@@ -205,10 +205,10 @@ static int encode_dvd_subtitles(uint8_t *outbuf, int outbuf_size, · 204 unmodified lines
205205 }
206206
207207 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)
209210 {
210211 //DVDSubtitleContext *s = avctx->priv_data;
211− AVSubtitle *sub = data;
212212 int ret;
213213
214214 ret = encode_dvd_subtitles(buf, buf_size, sub);
@@ -219,6 +219,6 @@ AVCodec ff_dvdsub_encoder = { · 4 unmodified lines
219219 .name = "dvdsub",
220220 .type = AVMEDIA_TYPE_SUBTITLE,
221221 .id = AV_CODEC_ID_DVD_SUBTITLE,
222− .encode = dvdsub_encode,
222+ .encode_sub = dvdsub_encode,
223223 .long_name = NULL_IF_CONFIG_SMALL("DVD subtitles"),
224224 };
libavcodec/utils.c+2−2
@@ -115,7 +115,7 @@ static void avcodec_init(void) · 114 unmodified lines
115115
116116 int av_codec_is_encoder(const AVCodec *codec)
117117 {
118− return codec && (codec->encode || codec->encode2);
118+ return codec && (codec->encode_sub || codec->encode2);
119119 }
120120
121121 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
11741174 }
11751175 if(sub->num_rects == 0 || !sub->rects)
11761176 return -1;
1177− ret = avctx->codec->encode(avctx, buf, buf_size, sub);
1177+ ret = avctx->codec->encode_sub(avctx, buf, buf_size, sub);
11781178 avctx->frame_number++;
11791179 return ret;
11801180 }
libavcodec/xsubenc.c+2−3
@@ -111,9 +111,8 @@ static int make_tc(uint64_t ms, int *tc) · 110 unmodified lines
111111 }
112112
113113 static int xsub_encode(AVCodecContext *avctx, unsigned char *buf,
114− int bufsize, void *data)
114+ int bufsize, const AVSubtitle *h)
115115 {
116− AVSubtitle *h = data;
117116 uint64_t startTime = h->pts / 1000; // FIXME: need better solution...
118117 uint64_t endTime = startTime + h->end_display_time - h->start_display_time;
119118 int start_tc[4], end_tc[4];
@@ -215,6 +214,6 @@ AVCodec ff_xsub_encoder = { · 95 unmodified lines
215214 .type = AVMEDIA_TYPE_SUBTITLE,
216215 .id = AV_CODEC_ID_XSUB,
217216 .init = xsub_encoder_init,
218− .encode = xsub_encode,
217+ .encode_sub= xsub_encode,
219218 .long_name = NULL_IF_CONFIG_SMALL("DivX subtitles (XSUB)"),
220219 };

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