summaryrefslogtreecommitdiffstats
path: root/libmpdemux
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2012-01-28 13:41:36 +0200
committerUoti Urpala <uau@mplayer2.org>2012-02-01 22:46:27 +0200
commitdb8cdc73e38c3490389212d94ae9b92dfddd5975 (patch)
treeee6486888b90afe0e5a42a8e0c080366f5c8a7e5 /libmpdemux
parent637d6b7c8e12b4f71ccbc64f73a402b573e71697 (diff)
downloadmpv-db8cdc73e38c3490389212d94ae9b92dfddd5975.tar.bz2
mpv-db8cdc73e38c3490389212d94ae9b92dfddd5975.tar.xz
Update Libav API uses
Change various code to use the latest Libav API. The libavcodec error_recognition setting has been removed and replaced with different semantics. I removed the "--lavdopts=er=<value>" option accordingly, as I don't think it's widely enough used to be worth attempting to emulate the old option semantics using the new API. A new option with the new semantics can be added later if needed. Libav dropped APIs that were necessary with all Libav versions until quite recently (like setting avctx->age), and it would thus not be possible to keep compatibility with previous Libav versions without adding workarounds. The new APIs also had some bugs/limitations in the recent Libav release 0.8, and it would not work fully (at least some avcodec options would not be set correctly). Because of those issues, this commit makes no attempt to maintain compatibility with anything but the latest Libav git head. Hopefully the required fixes and improvements will be included in a following Libav point release.
Diffstat (limited to 'libmpdemux')
-rw-r--r--libmpdemux/demux_lavf.c31
-rw-r--r--libmpdemux/demux_rtp_codec.cpp2
-rw-r--r--libmpdemux/demuxer.c2
-rw-r--r--libmpdemux/ebml.c10
4 files changed, 21 insertions, 24 deletions
diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c
index 4314a96c02..cf17664aab 100644
--- a/libmpdemux/demux_lavf.c
+++ b/libmpdemux/demux_lavf.c
@@ -25,6 +25,13 @@
#include <stdbool.h>
#include <string.h>
+#include <libavformat/avformat.h>
+#include <libavformat/avio.h>
+#include <libavutil/avutil.h>
+#include <libavutil/avstring.h>
+#include <libavutil/mathematics.h>
+#include <libavutil/opt.h>
+
#include "config.h"
#include "options.h"
#include "mp_msg.h"
@@ -38,13 +45,6 @@
#include "m_option.h"
#include "sub/sub.h"
-#include "libavformat/avformat.h"
-#include "libavformat/avio.h"
-#include "libavutil/avutil.h"
-#include "libavutil/avstring.h"
-#include <libavutil/mathematics.h>
-#include "libavcodec/opt.h"
-
#include "mp_taglists.h"
#define INITIAL_PROBE_SIZE STREAM_BUFFER_SIZE
@@ -534,7 +534,6 @@ static demuxer_t *demux_open_lavf(demuxer_t *demuxer)
struct MPOpts *opts = demuxer->opts;
struct lavfdopts *lavfdopts = &opts->lavfdopts;
AVFormatContext *avfc;
- const AVOption *opt;
AVDictionaryEntry *t = NULL;
lavf_priv_t *priv = demuxer->priv;
int i;
@@ -559,16 +558,14 @@ static demuxer_t *demux_open_lavf(demuxer_t *demuxer)
avfc->flags |= AVFMT_FLAG_IGNIDX;
if (lavfdopts->probesize) {
- opt = av_set_int(avfc, "probesize", lavfdopts->probesize);
- if (!opt)
+ if (av_opt_set_int(avfc, "probesize", lavfdopts->probesize, 0) < 0)
mp_msg(MSGT_HEADER, MSGL_ERR,
"demux_lavf, couldn't set option probesize to %u\n",
lavfdopts->probesize);
}
if (lavfdopts->analyzeduration) {
- opt = av_set_int(avfc, "analyzeduration",
- lavfdopts->analyzeduration * AV_TIME_BASE);
- if (!opt)
+ if (av_opt_set_int(avfc, "analyzeduration",
+ lavfdopts->analyzeduration * AV_TIME_BASE, 0) < 0)
mp_msg(MSGT_HEADER, MSGL_ERR, "demux_lavf, couldn't set option "
"analyzeduration to %u\n", lavfdopts->analyzeduration);
}
@@ -609,7 +606,7 @@ static demuxer_t *demux_open_lavf(demuxer_t *demuxer)
priv->avfc = avfc;
- if (av_find_stream_info(avfc) < 0) {
+ if (avformat_find_stream_info(avfc, NULL) < 0) {
mp_msg(MSGT_HEADER, MSGL_ERR,
"LAVF_header: av_find_stream_info() failed\n");
return NULL;
@@ -617,7 +614,7 @@ static demuxer_t *demux_open_lavf(demuxer_t *demuxer)
/* Add metadata. */
while ((t = av_dict_get(avfc->metadata, "", t,
- AV_METADATA_IGNORE_SUFFIX)))
+ AV_DICT_IGNORE_SUFFIX)))
demux_info_add(demuxer, t->key, t->value);
for (i = 0; i < avfc->nb_chapters; i++) {
@@ -708,7 +705,7 @@ static void check_internet_radio_hack(struct demuxer *demuxer)
AVDictionaryEntry *t = NULL;
AVStream *stream = avfc->streams[avfc->nb_streams - 1];
while ((t = av_dict_get(stream->metadata, "", t,
- AV_METADATA_IGNORE_SUFFIX)))
+ AV_DICT_IGNORE_SUFFIX)))
demux_info_add(demuxer, t->key, t->value);
} else {
if (priv->internet_radio_hack)
@@ -995,7 +992,7 @@ static void demux_close_lavf(demuxer_t *demuxer)
if (priv) {
if (priv->avfc) {
av_freep(&priv->avfc->key);
- av_close_input_file(priv->avfc);
+ avformat_close_input(&priv->avfc);
}
av_freep(&priv->pb);
free(priv);
diff --git a/libmpdemux/demux_rtp_codec.cpp b/libmpdemux/demux_rtp_codec.cpp
index 28fb51e96e..cb21e6b633 100644
--- a/libmpdemux/demux_rtp_codec.cpp
+++ b/libmpdemux/demux_rtp_codec.cpp
@@ -135,7 +135,7 @@ void rtpCodecInitialize_video(demuxer_t* demuxer,
int fooLen;
const uint8_t* fooData;
h264parserctx = av_parser_init(CODEC_ID_H264);
- avcctx = avcodec_alloc_context();
+ avcctx = avcodec_alloc_context3(NULL);
// Pass the config to the parser
h264parserctx->parser->parser_parse(h264parserctx, avcctx,
&fooData, &fooLen, configData, configLen);
diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c
index b3a1998d0c..0ff734b074 100644
--- a/libmpdemux/demuxer.c
+++ b/libmpdemux/demuxer.c
@@ -547,7 +547,7 @@ static void allocate_parser(AVCodecContext **avctx, AVCodecParserContext **parse
break;
}
if (codec_id != CODEC_ID_NONE) {
- *avctx = avcodec_alloc_context();
+ *avctx = avcodec_alloc_context3(NULL);
if (!*avctx)
return;
*parser = av_parser_init(codec_id);
diff --git a/libmpdemux/ebml.c b/libmpdemux/ebml.c
index 28b4a4643a..9bce3b5182 100644
--- a/libmpdemux/ebml.c
+++ b/libmpdemux/ebml.c
@@ -29,7 +29,7 @@
#include <stddef.h>
#include <assert.h>
-#include <libavutil/intfloat_readwrite.h>
+#include <libavutil/intfloat.h>
#include <libavutil/common.h>
#include "talloc.h"
#include "ebml.h"
@@ -191,11 +191,11 @@ double ebml_read_float(stream_t *s, uint64_t *length)
len = ebml_read_length(s, &l);
switch (len) {
case 4:
- value = av_int2flt(stream_read_dword(s));
+ value = av_int2float(stream_read_dword(s));
break;
case 8:
- value = av_int2dbl(stream_read_qword(s));
+ value = av_int2double(stream_read_qword(s));
break;
default:
@@ -382,9 +382,9 @@ static double ebml_parse_float(uint8_t *data, int length)
assert(length == 4 || length == 8);
uint64_t i = ebml_parse_uint(data, length);
if (length == 4)
- return av_int2flt(i);
+ return av_int2float(i);
else
- return av_int2dbl(i);
+ return av_int2double(i);
}