summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-12-07 19:44:29 +0100
committerwm4 <wm4@nowhere>2016-12-07 19:53:11 +0100
commit3eceac2eab0b42ee082a0b615ebf40a21f0fb915 (patch)
treea7f719897b49f44006d44a1efcdab3b8d203aad8 /audio
parenta660e15c9b96bd46209e78b3c3d4cf136a039a50 (diff)
downloadmpv-3eceac2eab0b42ee082a0b615ebf40a21f0fb915.tar.bz2
mpv-3eceac2eab0b42ee082a0b615ebf40a21f0fb915.tar.xz
Remove compatibility things
Possible with bumped FFmpeg/Libav. These are just the simple cases.
Diffstat (limited to 'audio')
-rw-r--r--audio/decode/ad_lavc.c22
-rw-r--r--audio/decode/ad_spdif.c10
-rw-r--r--audio/filter/af_lavcac3enc.c16
-rw-r--r--audio/filter/af_lavrresample.c5
-rw-r--r--audio/out/ao_lavc.c23
5 files changed, 1 insertions, 75 deletions
diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c
index e28558414d..276ce69739 100644
--- a/audio/decode/ad_lavc.c
+++ b/audio/decode/ad_lavc.c
@@ -207,7 +207,6 @@ static int decode_packet(struct dec_audio *da, struct demux_packet *mpkt,
if (priv->needs_reset)
control(da, ADCTRL_RESET, NULL);
-#if HAVE_AVCODEC_NEW_CODEC_API
int ret = avcodec_send_packet(avctx, &pkt);
if (ret >= 0 || ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
if (ret >= 0 && mpkt)
@@ -220,24 +219,6 @@ static int decode_packet(struct dec_audio *da, struct demux_packet *mpkt,
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
ret = 0;
}
-#else
- int ret = avcodec_decode_audio4(avctx, priv->avframe, &got_frame, &pkt);
- if (mpkt) {
- // At least "shorten" decodes sub-frames, instead of the whole packet.
- // At least "mpc8" can return 0 and wants the packet again next time.
- if (ret >= 0) {
- ret = FFMIN(ret, mpkt->len); // sanity check against decoder overreads
- mpkt->buffer += ret;
- mpkt->len -= ret;
- mpkt->pts = MP_NOPTS_VALUE; // don't reset PTS next time
- }
- // LATM may need many packets to find mux info
- if (ret == AVERROR(EAGAIN)) {
- mpkt->len = 0;
- return 0;
- }
- }
-#endif
if (ret < 0) {
MP_ERR(da, "Error decoding audio.\n");
return -1;
@@ -245,8 +226,7 @@ static int decode_packet(struct dec_audio *da, struct demux_packet *mpkt,
if (!got_frame)
return 0;
- double out_pts = mp_pts_from_av(MP_AVFRAME_DEC_PTS(priv->avframe),
- &priv->codec_timebase);
+ double out_pts = mp_pts_from_av(priv->avframe->pts, &priv->codec_timebase);
struct mp_audio *mpframe = mp_audio_from_avframe(priv->avframe);
if (!mpframe)
diff --git a/audio/decode/ad_spdif.c b/audio/decode/ad_spdif.c
index 56e4a8102d..e15aca5c53 100644
--- a/audio/decode/ad_spdif.c
+++ b/audio/decode/ad_spdif.c
@@ -116,16 +116,10 @@ static int determine_codec_profile(struct dec_audio *da, AVPacket *pkt)
goto done;
}
-#if HAVE_AVCODEC_NEW_CODEC_API
if (avcodec_send_packet(ctx, pkt) < 0)
goto done;
if (avcodec_receive_frame(ctx, frame) < 0)
goto done;
-#else
- int got_frame = 0;
- if (avcodec_decode_audio4(ctx, frame, &got_frame, pkt) < 1 || !got_frame)
- goto done;
-#endif
profile = ctx->profile;
@@ -178,11 +172,7 @@ static int init_filter(struct dec_audio *da, AVPacket *pkt)
if (!stream)
goto fail;
-#if HAVE_AVCODEC_HAS_CODECPAR
stream->codecpar->codec_id = spdif_ctx->codec_id;
-#else
- stream->codec->codec_id = spdif_ctx->codec_id;
-#endif
AVDictionary *format_opts = NULL;
diff --git a/audio/filter/af_lavcac3enc.c b/audio/filter/af_lavcac3enc.c
index 0a7c5d4440..9df5adb96f 100644
--- a/audio/filter/af_lavcac3enc.c
+++ b/audio/filter/af_lavcac3enc.c
@@ -280,7 +280,6 @@ static int filter_out(struct af_instance *af)
AVPacket pkt = {0};
av_init_packet(&pkt);
-#if HAVE_AVCODEC_NEW_CODEC_API
// Send input as long as it wants.
while (1) {
err = read_input_frame(af, frame);
@@ -310,21 +309,6 @@ static int filter_out(struct af_instance *af)
MP_FATAL(af, "Encode failed.\n");
goto done;
}
-#else
- err = read_input_frame(af, frame);
- if (err < 0)
- goto done;
- if (err == 0)
- goto done;
- err = -1;
- int ok;
- int lavc_ret = avcodec_encode_audio2(s->lavc_actx, &pkt, frame, &ok);
- s->input->samples = 0;
- if (lavc_ret < 0 || !ok) {
- MP_FATAL(af, "Encode failed.\n");
- goto done;
- }
-#endif
MP_DBG(af, "avcodec_encode_audio got %d, pending %d.\n",
pkt.size, s->pending->samples + s->input->samples);
diff --git a/audio/filter/af_lavrresample.c b/audio/filter/af_lavrresample.c
index dc5d1a0d23..828be66247 100644
--- a/audio/filter/af_lavrresample.c
+++ b/audio/filter/af_lavrresample.c
@@ -111,12 +111,7 @@ static double get_delay(struct af_resample *s)
}
static int get_out_samples(struct af_resample *s, int in_samples)
{
-#if LIBSWRESAMPLE_VERSION_MAJOR > 1 || LIBSWRESAMPLE_VERSION_MINOR >= 2
return swr_get_out_samples(s->avrctx, in_samples);
-#else
- return av_rescale_rnd(in_samples, s->out_rate, s->in_rate, AV_ROUND_UP)
- + swr_get_delay(s->avrctx, s->out_rate);
-#endif
}
#endif
diff --git a/audio/out/ao_lavc.c b/audio/out/ao_lavc.c
index 8ae1317407..4dbc55a369 100644
--- a/audio/out/ao_lavc.c
+++ b/audio/out/ao_lavc.c
@@ -258,7 +258,6 @@ static void encode_audio_and_write(struct ao *ao, AVFrame *frame)
struct priv *ac = ao->priv;
AVPacket packet = {0};
-#if HAVE_AVCODEC_NEW_CODEC_API
int status = avcodec_send_frame(ac->codec, frame);
if (status < 0) {
MP_ERR(ao, "error encoding at %d %d/%d\n",
@@ -297,28 +296,6 @@ static void encode_audio_and_write(struct ao *ao, AVFrame *frame)
write_packet(ao, &packet);
av_packet_unref(&packet);
}
-#else
- av_init_packet(&packet);
- int got_packet = 0;
- int status = avcodec_encode_audio2(ac->codec, &packet, frame, &got_packet);
- if (status < 0) {
- MP_ERR(ao, "error encoding at %d %d/%d\n",
- frame ? (int) frame->pts : -1,
- ac->codec->time_base.num,
- ac->codec->time_base.den);
- return;
- }
- if (!got_packet) {
- return;
- }
- if (frame) {
- if (ac->savepts == AV_NOPTS_VALUE)
- ac->savepts = frame->pts;
- }
- encode_lavc_write_stats(ao->encode_lavc_ctx, ac->codec);
- write_packet(ao, &packet);
- av_packet_unref(&packet);
-#endif
}
// must get exactly ac->aframesize amount of data