+
+ 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);