summaryrefslogtreecommitdiffstats
path: root/core/av_common.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-06-04 00:29:29 +0200
committerwm4 <wm4@nowhere>2013-06-04 00:29:44 +0200
commit92ae48db0f91fbfcfbb1722fa81c922808f62d5a (patch)
treee32fe21b5f8c11ada7788768a76e2d9f7d061c66 /core/av_common.c
parentdaf8ed831b4ae63cf0931cc3d6727956137f865f (diff)
parentc1ac97b99b3e80bbf84ed540178dd6689ead0b87 (diff)
downloadmpv-92ae48db0f91fbfcfbb1722fa81c922808f62d5a.tar.bz2
mpv-92ae48db0f91fbfcfbb1722fa81c922808f62d5a.tar.xz
Merge branch 'sub_mess'
This branch heavily refactors the subtitle code (both loading and rendering), and adds support for a few new formats through FFmpeg. We don't remove any of the old code yet. There are still some subtleties related to subreader.c to be resolved: code page detection & conversion, timing post-processing, UTF-16 subtitle support, support for the -subfps option. Also, SRT reading and loading ASS via libass should be turned into proper demuxers. (SRT is needed because Libav's is gravely broken, and we want ASS loading via libass to cover full libass format support. Both should be demuxers which are probed _before_ libavformat, so that all subtitles can be loaded through the demuxer infrastructure, and libavformat subtitles don't need to be treated in a special way.)
Diffstat (limited to 'core/av_common.c')
-rw-r--r--core/av_common.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/core/av_common.c b/core/av_common.c
index 5e6c8a4352..a4dc525aa9 100644
--- a/core/av_common.c
+++ b/core/av_common.c
@@ -18,8 +18,10 @@
#include <assert.h>
#include <libavutil/common.h>
+#include <libavcodec/avcodec.h>
#include "core/mp_talloc.h"
+#include "demux/demux_packet.h"
#include "av_common.h"
#include "codecs.h"
@@ -58,6 +60,24 @@ void mp_copy_lav_codec_headers(AVCodecContext *avctx, AVCodecContext *st)
avctx->bits_per_coded_sample = st->bits_per_coded_sample;
}
+// Set dst from mpkt. Note that dst is not refcountable.
+// mpkt can be NULL to generate empty packets (used to flush delayed data).
+// Does not set pts or duration fields.
+void mp_set_av_packet(AVPacket *dst, struct demux_packet *mpkt)
+{
+ av_init_packet(dst);
+ dst->data = mpkt ? mpkt->buffer : NULL;
+ dst->size = mpkt ? mpkt->len : 0;
+ /* Some codecs (ZeroCodec, some cases of PNG) may want keyframe info
+ * from demuxer. */
+ if (mpkt && mpkt->keyframe)
+ dst->flags |= AV_PKT_FLAG_KEY;
+ if (mpkt && mpkt->avpacket) {
+ dst->side_data = mpkt->avpacket->side_data;
+ dst->side_data_elems = mpkt->avpacket->side_data_elems;
+ }
+}
+
void mp_add_lavc_decoders(struct mp_decoder_list *list, enum AVMediaType type)
{
AVCodec *cur = NULL;