path: root/common
diff options
authorwm4 <wm4@nowhere>2016-03-31 22:00:45 +0200
committerwm4 <wm4@nowhere>2016-03-31 22:00:45 +0200
commitc971220cdd360b56efc0e67536bdf19501477aa4 (patch)
tree74ffd570b80306725898d81e705e09b3a4dfdb8d /common
parent38c813c919a2c7d59d6113f16252aa3be96f3fca (diff)
demux_lavf, ad_lavc, ad_spdif, vd_lavc: handle FFmpeg codecpar API change
AVFormatContext.codec is deprecated now, and you're supposed to use AVFormatContext.codecpar instead. Handle this for all of the normal playback code. Encoding mode isn't touched.
Diffstat (limited to 'common')
2 files changed, 18 insertions, 0 deletions
diff --git a/common/av_common.c b/common/av_common.c
index 6efa1803fd..e40c751e9f 100644
--- a/common/av_common.c
+++ b/common/av_common.c
@@ -25,9 +25,12 @@
#include <libavutil/cpu.h>
#include <libavcodec/avcodec.h>
+#include "config.h"
#include "common/common.h"
#include "common/msg.h"
#include "demux/packet.h"
+#include "demux/stheader.h"
#include "av_common.h"
#include "codecs.h"
@@ -68,6 +71,19 @@ void mp_copy_lav_codec_headers(AVCodecContext *avctx, AVCodecContext *st)
avctx->has_b_frames = st->has_b_frames;
+// This only copies ffmpeg-native codec parameters. Parameters produced by
+// other demuxers must be handled manually.
+void mp_set_lav_codec_headers(AVCodecContext *avctx, struct mp_codec_params *c)
+ if (c->lav_codecpar)
+ avcodec_parameters_to_context(avctx, c->lav_codecpar);
+ if (c->lav_headers)
+ mp_copy_lav_codec_headers(avctx, c->lav_headers);
// We merely pass-through our PTS/DTS as an int64_t; libavcodec won't use it.
union pts { int64_t i; double d; };
diff --git a/common/av_common.h b/common/av_common.h
index 1478adf8fb..e2b86bfe40 100644
--- a/common/av_common.h
+++ b/common/av_common.h
@@ -26,11 +26,13 @@
struct mp_decoder_list;
struct demux_packet;
+struct mp_codec_params;
struct AVDictionary;
struct mp_log;
int mp_lavc_set_extradata(AVCodecContext *avctx, void *ptr, int size);
void mp_copy_lav_codec_headers(AVCodecContext *avctx, AVCodecContext *st);
+void mp_set_lav_codec_headers(AVCodecContext *avctx, struct mp_codec_params *c);
void mp_set_av_packet(AVPacket *dst, struct demux_packet *mpkt, AVRational *tb);
int64_t mp_pts_to_av(double mp_pts, AVRational *tb);
double mp_pts_from_av(int64_t av_pts, AVRational *tb);