mirror of
https://github.com/mpv-player/mpv
synced 2025-03-20 02:09:52 +00:00
Libav API updates (remove most deprecated-in-0.7 uses)
Update various code using Libav libraries to remove use of API features that were deprecated at Libav release 0.7. I think this removes them all with the exception of URLContext functions still used in stream_ffmpeg.c (at least other uses that generated deprecation warnings with libraries from 0.7 are removed).
This commit is contained in:
parent
37e4a928ca
commit
1bd5871762
@ -281,8 +281,7 @@ static int decode_audio(sh_audio_t *sh_audio, unsigned char *buf, int minlen,
|
||||
}
|
||||
if (len2 > 0) {
|
||||
if (avctx->channels >= 5) {
|
||||
int samplesize = av_get_bits_per_sample_format(
|
||||
avctx->sample_fmt) / 8;
|
||||
int samplesize = av_get_bytes_per_sample(avctx->sample_fmt);
|
||||
reorder_channel_nch(buf, AF_CHANNEL_LAYOUT_LAVC_DEFAULT,
|
||||
AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT,
|
||||
avctx->channels,
|
||||
|
@ -311,27 +311,13 @@ static int init(sh_video_t *sh)
|
||||
memcpy(avctx->extradata, sh->bih + 1, avctx->extradata_size);
|
||||
break;
|
||||
}
|
||||
/* Pass palette to codec */
|
||||
if (sh->bih && (sh->bih->biBitCount <= 8)) {
|
||||
avctx->palctrl = calloc(1, sizeof(AVPaletteControl));
|
||||
avctx->palctrl->palette_changed = 1;
|
||||
if (sh->bih->biSize - sizeof(*sh->bih))
|
||||
/* Palette size in biSize */
|
||||
memcpy(avctx->palctrl->palette, sh->bih + 1,
|
||||
FFMIN(sh->bih->biSize - sizeof(*sh->bih), AVPALETTE_SIZE));
|
||||
else
|
||||
/* Palette size in biClrUsed */
|
||||
memcpy(avctx->palctrl->palette, sh->bih + 1,
|
||||
FFMIN(sh->bih->biClrUsed * 4, AVPALETTE_SIZE));
|
||||
}
|
||||
|
||||
if (sh->bih)
|
||||
avctx->bits_per_coded_sample = sh->bih->biBitCount;
|
||||
|
||||
if (lavc_param->threads > 1) {
|
||||
if (lavc_param->threads > 1)
|
||||
avctx->thread_count = lavc_param->threads;
|
||||
avcodec_thread_init(avctx, lavc_param->threads);
|
||||
}
|
||||
|
||||
/* open it */
|
||||
if (avcodec_open(avctx, lavc_codec) < 0) {
|
||||
mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Could not open codec.\n");
|
||||
@ -362,7 +348,6 @@ static void uninit(sh_video_t *sh)
|
||||
mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Could not close codec.\n");
|
||||
|
||||
av_freep(&avctx->extradata);
|
||||
free(avctx->palctrl);
|
||||
av_freep(&avctx->slice_offset);
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ const m_option_t lavfdopts_conf[] = {
|
||||
typedef struct lavf_priv {
|
||||
AVInputFormat *avif;
|
||||
AVFormatContext *avfc;
|
||||
ByteIOContext *pb;
|
||||
AVIOContext *pb;
|
||||
uint8_t buffer[BIO_BUFFER_SIZE];
|
||||
int audio_streams;
|
||||
int video_streams;
|
||||
@ -286,8 +286,8 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i)
|
||||
AVCodecContext *codec = st->codec;
|
||||
char *stream_type = NULL;
|
||||
int stream_id;
|
||||
AVMetadataTag *lang = av_metadata_get(st->metadata, "language", NULL, 0);
|
||||
AVMetadataTag *title = av_metadata_get(st->metadata, "title", NULL, 0);
|
||||
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
|
||||
AVDictionaryEntry *title = av_dict_get(st->metadata, "title", NULL, 0);
|
||||
// Don't use native MPEG codec tag values with our generic tag tables.
|
||||
// May contain for example value 3 for MP3, which we'd map to PCM audio.
|
||||
if (matches_avinputformat_name(priv, "mpeg") ||
|
||||
@ -500,7 +500,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i)
|
||||
break;
|
||||
}
|
||||
case AVMEDIA_TYPE_ATTACHMENT: {
|
||||
AVMetadataTag *ftag = av_metadata_get(st->metadata, "filename",
|
||||
AVDictionaryEntry *ftag = av_dict_get(st->metadata, "filename",
|
||||
NULL, 0);
|
||||
char *filename = ftag ? ftag->value : NULL;
|
||||
if (st->codec->codec_id == CODEC_ID_TTF)
|
||||
@ -534,15 +534,12 @@ static demuxer_t *demux_open_lavf(demuxer_t *demuxer)
|
||||
struct MPOpts *opts = demuxer->opts;
|
||||
struct lavfdopts *lavfdopts = &opts->lavfdopts;
|
||||
AVFormatContext *avfc;
|
||||
AVFormatParameters ap;
|
||||
const AVOption *opt;
|
||||
AVMetadataTag *t = NULL;
|
||||
AVDictionaryEntry *t = NULL;
|
||||
lavf_priv_t *priv = demuxer->priv;
|
||||
int i;
|
||||
char mp_filename[256] = "mp:";
|
||||
|
||||
memset(&ap, 0, sizeof(AVFormatParameters));
|
||||
|
||||
stream_seek(demuxer->stream, 0);
|
||||
|
||||
avfc = avformat_alloc_context();
|
||||
@ -561,7 +558,6 @@ static demuxer_t *demux_open_lavf(demuxer_t *demuxer)
|
||||
if (index_mode == 0)
|
||||
avfc->flags |= AVFMT_FLAG_IGNIDX;
|
||||
|
||||
ap.prealloced_context = 1;
|
||||
if (lavfdopts->probesize) {
|
||||
opt = av_set_int(avfc, "probesize", lavfdopts->probesize);
|
||||
if (!opt)
|
||||
@ -596,17 +592,18 @@ static demuxer_t *demux_open_lavf(demuxer_t *demuxer)
|
||||
av_strlcat(mp_filename, "foobar.dummy", sizeof(mp_filename));
|
||||
|
||||
if (!(priv->avif->flags & AVFMT_NOFILE)) {
|
||||
priv->pb = av_alloc_put_byte(priv->buffer, BIO_BUFFER_SIZE, 0,
|
||||
demuxer, mp_read, NULL, mp_seek);
|
||||
priv->pb = avio_alloc_context(priv->buffer, BIO_BUFFER_SIZE, 0,
|
||||
demuxer, mp_read, NULL, mp_seek);
|
||||
priv->pb->read_seek = mp_read_seek;
|
||||
priv->pb->is_streamed = !demuxer->stream->end_pos ||
|
||||
(demuxer->stream->flags & MP_STREAM_SEEK) != MP_STREAM_SEEK;
|
||||
priv->pb->seekable = demuxer->stream->end_pos
|
||||
&& (demuxer->stream->flags & MP_STREAM_SEEK) == MP_STREAM_SEEK
|
||||
? AVIO_SEEKABLE_NORMAL : 0;
|
||||
avfc->pb = priv->pb;
|
||||
}
|
||||
|
||||
if (av_open_input_stream(&avfc, priv->pb, mp_filename, priv->avif,
|
||||
&ap) < 0) {
|
||||
if (avformat_open_input(&avfc, mp_filename, priv->avif, NULL) < 0) {
|
||||
mp_msg(MSGT_HEADER, MSGL_ERR,
|
||||
"LAVF_header: av_open_input_stream() failed\n");
|
||||
"LAVF_header: avformat_open_input() failed\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -619,8 +616,7 @@ static demuxer_t *demux_open_lavf(demuxer_t *demuxer)
|
||||
}
|
||||
|
||||
/* Add metadata. */
|
||||
av_metadata_conv(avfc, NULL, avfc->iformat->metadata_conv);
|
||||
while ((t = av_metadata_get(avfc->metadata, "", t,
|
||||
while ((t = av_dict_get(avfc->metadata, "", t,
|
||||
AV_METADATA_IGNORE_SUFFIX)))
|
||||
demux_info_add(demuxer, t->key, t->value);
|
||||
|
||||
@ -630,7 +626,7 @@ static demuxer_t *demux_open_lavf(demuxer_t *demuxer)
|
||||
(AVRational){1, 1000000000});
|
||||
uint64_t end = av_rescale_q(c->end, c->time_base,
|
||||
(AVRational){1, 1000000000});
|
||||
t = av_metadata_get(c->metadata, "title", NULL, 0);
|
||||
t = av_dict_get(c->metadata, "title", NULL, 0);
|
||||
demuxer_add_chapter(demuxer, t ? bstr(t->value) : bstr(NULL),
|
||||
start, end);
|
||||
}
|
||||
@ -643,7 +639,7 @@ static demuxer_t *demux_open_lavf(demuxer_t *demuxer)
|
||||
int p;
|
||||
for (p = 0; p < avfc->nb_programs; p++) {
|
||||
AVProgram *program = avfc->programs[p];
|
||||
t = av_metadata_get(program->metadata, "title", NULL, 0);
|
||||
t = av_dict_get(program->metadata, "title", NULL, 0);
|
||||
mp_msg(MSGT_HEADER, MSGL_INFO, "LAVF: Program %d %s\n",
|
||||
program->id, t ? t->value : "");
|
||||
mp_msg(MSGT_IDENTIFY, MSGL_V, "PROGRAM_ID=%d\n", program->id);
|
||||
@ -709,9 +705,9 @@ static void check_internet_radio_hack(struct demuxer *demuxer)
|
||||
}
|
||||
priv->internet_radio_hack = true;
|
||||
// use new per-track metadata as global metadata
|
||||
AVMetadataTag *t = NULL;
|
||||
AVDictionaryEntry *t = NULL;
|
||||
AVStream *stream = avfc->streams[avfc->nb_streams - 1];
|
||||
while ((t = av_metadata_get(stream->metadata, "", t,
|
||||
while ((t = av_dict_get(stream->metadata, "", t,
|
||||
AV_METADATA_IGNORE_SUFFIX)))
|
||||
demux_info_add(demuxer, t->key, t->value);
|
||||
} else {
|
||||
@ -999,7 +995,7 @@ static void demux_close_lavf(demuxer_t *demuxer)
|
||||
if (priv) {
|
||||
if (priv->avfc) {
|
||||
av_freep(&priv->avfc->key);
|
||||
av_close_input_stream(priv->avfc);
|
||||
av_close_input_file(priv->avfc);
|
||||
}
|
||||
av_freep(&priv->pb);
|
||||
free(priv);
|
||||
|
Loading…
Reference in New Issue
Block a user