summaryrefslogtreecommitdiffstats
path: root/libaf
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 /libaf
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 'libaf')
-rw-r--r--libaf/af_lavcac3enc.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/libaf/af_lavcac3enc.c b/libaf/af_lavcac3enc.c
index db6dc52163..ebb1c6ebea 100644
--- a/libaf/af_lavcac3enc.c
+++ b/libaf/af_lavcac3enc.c
@@ -98,15 +98,14 @@ static int control(struct af_instance_s *af, int cmd, void *arg)
s->lavc_actx->sample_rate != af->data->rate ||
s->lavc_actx->bit_rate != bit_rate) {
- if (s->lavc_actx->codec)
- avcodec_close(s->lavc_actx);
+ avcodec_close(s->lavc_actx);
// Put sample parameters
s->lavc_actx->channels = af->data->nch;
s->lavc_actx->sample_rate = af->data->rate;
s->lavc_actx->bit_rate = bit_rate;
- if(avcodec_open(s->lavc_actx, s->lavc_acodec) < 0) {
+ if (avcodec_open2(s->lavc_actx, s->lavc_acodec, NULL) < 0) {
mp_tmsg(MSGT_AFILTER, MSGL_ERR, "Couldn't open codec %s, br=%d.\n", "ac3", bit_rate);
return AF_ERROR;
}
@@ -160,9 +159,8 @@ static void uninit(struct af_instance_s* af)
af_ac3enc_t *s = af->setup;
af->setup = NULL;
if(s->lavc_actx) {
- if (s->lavc_actx->codec)
- avcodec_close(s->lavc_actx);
- free(s->lavc_actx);
+ avcodec_close(s->lavc_actx);
+ av_free(s->lavc_actx);
}
free(s->pending_data);
free(s);
@@ -291,23 +289,22 @@ static int af_open(af_instance_t* af){
return AF_ERROR;
}
- s->lavc_actx = avcodec_alloc_context();
+ s->lavc_actx = avcodec_alloc_context3(s->lavc_acodec);
if (!s->lavc_actx) {
mp_tmsg(MSGT_AFILTER, MSGL_ERR, "Audio LAVC, couldn't allocate context!\n");
return AF_ERROR;
}
- // using deprecated SampleFormat/FMT, AV* versions only added in 2010-11
- const enum SampleFormat *fmts = s->lavc_acodec->sample_fmts;
+ const enum AVSampleFormat *fmts = s->lavc_acodec->sample_fmts;
for (int i = 0; ; i++) {
- if (fmts[i] == SAMPLE_FMT_NONE) {
+ if (fmts[i] == AV_SAMPLE_FMT_NONE) {
mp_msg(MSGT_AFILTER, MSGL_ERR, "Audio LAVC, encoder doesn't "
"support expected sample formats!\n");
return AF_ERROR;
- } else if (fmts[i] == SAMPLE_FMT_S16) {
+ } else if (fmts[i] == AV_SAMPLE_FMT_S16) {
s->in_sampleformat = AF_FORMAT_S16_NE;
s->lavc_actx->sample_fmt = fmts[i];
break;
- } else if (fmts[i] == SAMPLE_FMT_FLT) {
+ } else if (fmts[i] == AV_SAMPLE_FMT_FLT) {
s->in_sampleformat = AF_FORMAT_FLOAT_NE;
s->lavc_actx->sample_fmt = fmts[i];
break;