summaryrefslogtreecommitdiffstats
path: root/libavfilter/vf_subtitles.c
diff options
context:
space:
mode:
authorClément Bœsch <u@pkh.me>2016-06-25 16:41:38 +0200
committerClément Bœsch <u@pkh.me>2016-06-25 16:53:35 +0200
commit6bcb1e1aff2c3cc505d2508aedb00636b94be62d (patch)
tree3b9b438beee8c4cb21189b380f045dd92de2ce21 /libavfilter/vf_subtitles.c
parent0296b4b8d899ee720a812f8018ff9bba216c8c6d (diff)
downloadffmpeg-streaming-6bcb1e1aff2c3cc505d2508aedb00636b94be62d.zip
ffmpeg-streaming-6bcb1e1aff2c3cc505d2508aedb00636b94be62d.tar.gz
lavfi/subtitles: switch to codecpar
Diffstat (limited to 'libavfilter/vf_subtitles.c')
-rw-r--r--libavfilter/vf_subtitles.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c
index 916db65..5c3cffb 100644
--- a/libavfilter/vf_subtitles.c
+++ b/libavfilter/vf_subtitles.c
@@ -333,7 +333,7 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
ret = -1;
if (ass->stream_index < fmt->nb_streams) {
for (j = 0; j < fmt->nb_streams; j++) {
- if (fmt->streams[j]->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+ if (fmt->streams[j]->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
if (ass->stream_index == k) {
ret = j;
break;
@@ -355,7 +355,7 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
/* Load attached fonts */
for (j = 0; j < fmt->nb_streams; j++) {
AVStream *st = fmt->streams[j];
- if (st->codec->codec_type == AVMEDIA_TYPE_ATTACHMENT &&
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_ATTACHMENT &&
attachment_is_font(st)) {
const AVDictionaryEntry *tag = NULL;
tag = av_dict_get(st->metadata, "filename", NULL,
@@ -365,8 +365,8 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
av_log(ctx, AV_LOG_DEBUG, "Loading attached font: %s\n",
tag->value);
ass_add_font(ass->library, tag->value,
- st->codec->extradata,
- st->codec->extradata_size);
+ st->codecpar->extradata,
+ st->codecpar->extradata_size);
} else {
av_log(ctx, AV_LOG_WARNING,
"Font attachment has no filename, ignored.\n");
@@ -378,14 +378,13 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
ass_set_fonts(ass->renderer, NULL, NULL, 1, NULL, 1);
/* Open decoder */
- dec_ctx = st->codec;
- dec = avcodec_find_decoder(dec_ctx->codec_id);
+ dec = avcodec_find_decoder(st->codecpar->codec_id);
if (!dec) {
av_log(ctx, AV_LOG_ERROR, "Failed to find subtitle codec %s\n",
- avcodec_get_name(dec_ctx->codec_id));
+ avcodec_get_name(st->codecpar->codec_id));
return AVERROR(EINVAL);
}
- dec_desc = avcodec_descriptor_get(dec_ctx->codec_id);
+ dec_desc = avcodec_descriptor_get(st->codecpar->codec_id);
if (dec_desc && !(dec_desc->props & AV_CODEC_PROP_TEXT_SUB)) {
av_log(ctx, AV_LOG_ERROR,
"Only text based subtitles are currently supported\n");
@@ -395,7 +394,26 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
av_dict_set(&codec_opts, "sub_charenc", ass->charenc, 0);
if (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57,26,100))
av_dict_set(&codec_opts, "sub_text_format", "ass", 0);
- ret = avcodec_open2(dec_ctx, dec, &codec_opts);
+
+ dec_ctx = avcodec_alloc_context3(dec);
+ if (!dec_ctx)
+ return AVERROR(ENOMEM);
+
+ ret = avcodec_parameters_to_context(dec_ctx, st->codecpar);
+ if (ret < 0)
+ goto end;
+
+ /*
+ * This is required by the decoding process in order to rescale the
+ * timestamps: in the current API the decoded subtitles have their pts
+ * expressed in AV_TIME_BASE, and thus the lavc internals need to know the
+ * stream time base in order to achieve the rescaling.
+ *
+ * That API is old and needs to be reworked to match behaviour with A/V.
+ */
+ av_codec_set_pkt_timebase(dec_ctx, st->time_base);
+
+ ret = avcodec_open2(dec_ctx, NULL, &codec_opts);
if (ret < 0)
goto end;
OpenPOWER on IntegriCloud