mirror of
https://github.com/mpv-player/mpv
synced 2025-01-18 13:14:36 +00:00
Update libav API uses
Update various code to use newer alternatives instead of deprecated functions/fields that are being dropped at libav API bump. An exception is avcodec_thread_init() which is being dropped even though it's still _necessary_ with fairly recent libav versions, so there's no good alternative which would work with both those recent versions and latest libavcodec. I think there are grounds to consider the drop premature and revert it for now; if that doesn't happen I'll add a version-test #if check around it later.
This commit is contained in:
parent
726c28dd9b
commit
c33fafd6f1
4
av_log.c
4
av_log.c
@ -57,10 +57,10 @@ static int extract_msg_type_from_ctx(void *ptr)
|
|||||||
if (!strcmp(avc->class_name, "AVCodecContext")) {
|
if (!strcmp(avc->class_name, "AVCodecContext")) {
|
||||||
AVCodecContext *s = ptr;
|
AVCodecContext *s = ptr;
|
||||||
if (s->codec) {
|
if (s->codec) {
|
||||||
if (s->codec->type == CODEC_TYPE_AUDIO) {
|
if (s->codec->type == AVMEDIA_TYPE_AUDIO) {
|
||||||
if (s->codec->decode)
|
if (s->codec->decode)
|
||||||
return MSGT_DECAUDIO;
|
return MSGT_DECAUDIO;
|
||||||
} else if (s->codec->type == CODEC_TYPE_VIDEO) {
|
} else if (s->codec->type == AVMEDIA_TYPE_VIDEO) {
|
||||||
if (s->codec->decode)
|
if (s->codec->decode)
|
||||||
return MSGT_DECVIDEO;
|
return MSGT_DECVIDEO;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ int parse_avopts(void *v, char *str){
|
|||||||
arg = strchr(str, '=');
|
arg = strchr(str, '=');
|
||||||
if(arg) *arg++= 0;
|
if(arg) *arg++= 0;
|
||||||
|
|
||||||
if(!av_set_string(v, str, arg)){
|
if (av_set_string3(v, str, arg, 0, NULL) < 0) {
|
||||||
free(start);
|
free(start);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ static int init(sh_audio_t *sh_audio)
|
|||||||
}
|
}
|
||||||
lavc_context->request_channels = opts->audio_output_channels;
|
lavc_context->request_channels = opts->audio_output_channels;
|
||||||
lavc_context->codec_tag = sh_audio->format; //FOURCC
|
lavc_context->codec_tag = sh_audio->format; //FOURCC
|
||||||
lavc_context->codec_type = CODEC_TYPE_AUDIO;
|
lavc_context->codec_type = AVMEDIA_TYPE_AUDIO;
|
||||||
lavc_context->codec_id = lavc_codec->id; // not sure if required, imho not --A'rpi
|
lavc_context->codec_id = lavc_codec->id; // not sure if required, imho not --A'rpi
|
||||||
|
|
||||||
/* alloc extra data */
|
/* alloc extra data */
|
||||||
|
@ -208,7 +208,7 @@ static int init(sh_video_t *sh){
|
|||||||
ctx->avctx = avcodec_alloc_context();
|
ctx->avctx = avcodec_alloc_context();
|
||||||
avctx = ctx->avctx;
|
avctx = ctx->avctx;
|
||||||
avctx->opaque = sh;
|
avctx->opaque = sh;
|
||||||
avctx->codec_type = CODEC_TYPE_VIDEO;
|
avctx->codec_type = AVMEDIA_TYPE_VIDEO;
|
||||||
avctx->codec_id = lavc_codec->id;
|
avctx->codec_id = lavc_codec->id;
|
||||||
|
|
||||||
if (lavc_codec->capabilities & CODEC_CAP_HWACCEL // XvMC
|
if (lavc_codec->capabilities & CODEC_CAP_HWACCEL // XvMC
|
||||||
@ -541,14 +541,12 @@ static int get_buffer(AVCodecContext *avctx, AVFrame *pic){
|
|||||||
type = MP_IMGTYPE_STATIC;
|
type = MP_IMGTYPE_STATIC;
|
||||||
flags |= MP_IMGFLAG_PRESERVE;
|
flags |= MP_IMGFLAG_PRESERVE;
|
||||||
}
|
}
|
||||||
flags|=(!avctx->hurry_up && ctx->do_slices) ?
|
flags |= ctx->do_slices ? MP_IMGFLAG_DRAW_CALLBACK : 0;
|
||||||
MP_IMGFLAG_DRAW_CALLBACK:0;
|
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_DBG2, type == MP_IMGTYPE_STATIC ? "using STATIC\n" : "using TEMP\n");
|
mp_msg(MSGT_DECVIDEO, MSGL_DBG2, type == MP_IMGTYPE_STATIC ? "using STATIC\n" : "using TEMP\n");
|
||||||
} else {
|
} else {
|
||||||
if(!pic->reference){
|
if(!pic->reference){
|
||||||
ctx->b_count++;
|
ctx->b_count++;
|
||||||
flags|=(!avctx->hurry_up && ctx->do_slices) ?
|
flags |= ctx->do_slices ? MP_IMGFLAG_DRAW_CALLBACK:0;
|
||||||
MP_IMGFLAG_DRAW_CALLBACK:0;
|
|
||||||
}else{
|
}else{
|
||||||
ctx->ip_count++;
|
ctx->ip_count++;
|
||||||
flags|= MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE
|
flags|= MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE
|
||||||
@ -787,7 +785,7 @@ static struct mp_image *decode(struct sh_video *sh, void *data, int len,
|
|||||||
pkt.data = data;
|
pkt.data = data;
|
||||||
pkt.size = len;
|
pkt.size = len;
|
||||||
// HACK: make PNGs decode normally instead of as CorePNG delta frames
|
// HACK: make PNGs decode normally instead of as CorePNG delta frames
|
||||||
pkt.flags = PKT_FLAG_KEY;
|
pkt.flags = AV_PKT_FLAG_KEY;
|
||||||
// The avcodec opaque field stupidly supports only int64_t type
|
// The avcodec opaque field stupidly supports only int64_t type
|
||||||
*(double *)&avctx->reordered_opaque = *reordered_pts;
|
*(double *)&avctx->reordered_opaque = *reordered_pts;
|
||||||
ret = avcodec_decode_video2(avctx, pic, &got_picture, &pkt);
|
ret = avcodec_decode_video2(avctx, pic, &got_picture, &pkt);
|
||||||
|
@ -116,7 +116,7 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
|
|||||||
const_values[3]=y;
|
const_values[3]=y;
|
||||||
for(x=0; x<w; x++){
|
for(x=0; x<w; x++){
|
||||||
const_values[2]=x;
|
const_values[2]=x;
|
||||||
dst[x + y * dst_stride] = av_eval_expr(vf->priv->e[plane],
|
dst[x + y * dst_stride] = av_expr_eval(vf->priv->e[plane],
|
||||||
const_values, vf);
|
const_values, vf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -176,7 +176,7 @@ static int vf_open(vf_instance_t *vf, char *args){
|
|||||||
plane==0 ? lum : (plane==1 ? cb : cr),
|
plane==0 ? lum : (plane==1 ? cb : cr),
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
res = av_parse_expr(&vf->priv->e[plane], eq[plane], const_names, NULL, NULL, func2_names, func2, 0, NULL);
|
res = av_expr_parse(&vf->priv->e[plane], eq[plane], const_names, NULL, NULL, func2_names, func2, 0, NULL);
|
||||||
|
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
mp_msg(MSGT_VFILTER, MSGL_ERR, "geq: error loading equation `%s'\n", eq[plane]);
|
mp_msg(MSGT_VFILTER, MSGL_ERR, "geq: error loading equation `%s'\n", eq[plane]);
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
struct vf_priv_s {
|
struct vf_priv_s {
|
||||||
int pp;
|
int pp;
|
||||||
pp_mode_t *ppMode[PP_QUALITY_MAX+1];
|
pp_mode *ppMode[PP_QUALITY_MAX+1];
|
||||||
void *context;
|
void *context;
|
||||||
unsigned int outfmt;
|
unsigned int outfmt;
|
||||||
};
|
};
|
||||||
|
@ -289,7 +289,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
|
|||||||
codec->codec_tag = override_tag;
|
codec->codec_tag = override_tag;
|
||||||
|
|
||||||
switch(codec->codec_type){
|
switch(codec->codec_type){
|
||||||
case CODEC_TYPE_AUDIO:{
|
case AVMEDIA_TYPE_AUDIO:{
|
||||||
WAVEFORMATEX *wf;
|
WAVEFORMATEX *wf;
|
||||||
sh_audio_t* sh_audio;
|
sh_audio_t* sh_audio;
|
||||||
sh_audio = new_sh_audio_aid(demuxer, i, priv->audio_streams);
|
sh_audio = new_sh_audio_aid(demuxer, i, priv->audio_streams);
|
||||||
@ -361,7 +361,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
|
|||||||
stream_id = priv->audio_streams++;
|
stream_id = priv->audio_streams++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CODEC_TYPE_VIDEO:{
|
case AVMEDIA_TYPE_VIDEO:{
|
||||||
sh_video_t* sh_video;
|
sh_video_t* sh_video;
|
||||||
BITMAPINFOHEADER *bih;
|
BITMAPINFOHEADER *bih;
|
||||||
sh_video=new_sh_video_vid(demuxer, i, priv->video_streams);
|
sh_video=new_sh_video_vid(demuxer, i, priv->video_streams);
|
||||||
@ -433,7 +433,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
|
|||||||
stream_id = priv->video_streams++;
|
stream_id = priv->video_streams++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CODEC_TYPE_SUBTITLE:{
|
case AVMEDIA_TYPE_SUBTITLE:{
|
||||||
sh_sub_t* sh_sub;
|
sh_sub_t* sh_sub;
|
||||||
char type;
|
char type;
|
||||||
/* only support text subtitles for now */
|
/* only support text subtitles for now */
|
||||||
@ -476,9 +476,12 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
|
|||||||
stream_id = priv->sub_streams++;
|
stream_id = priv->sub_streams++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CODEC_TYPE_ATTACHMENT:{
|
case AVMEDIA_TYPE_ATTACHMENT:{
|
||||||
|
AVMetadataTag *ftag = av_metadata_get(st->metadata, "filename",
|
||||||
|
NULL, 0);
|
||||||
|
char *filename = ftag ? ftag->value : NULL;
|
||||||
if (st->codec->codec_id == CODEC_ID_TTF)
|
if (st->codec->codec_id == CODEC_ID_TTF)
|
||||||
demuxer_add_attachment(demuxer, BSTR(st->filename),
|
demuxer_add_attachment(demuxer, BSTR(filename),
|
||||||
BSTR("application/x-truetype-font"),
|
BSTR("application/x-truetype-font"),
|
||||||
(struct bstr){codec->extradata,
|
(struct bstr){codec->extradata,
|
||||||
codec->extradata_size});
|
codec->extradata_size});
|
||||||
@ -755,14 +758,14 @@ static int demux_lavf_fill_buffer(demuxer_t *demux, demux_stream_t *dsds){
|
|||||||
if(ts != AV_NOPTS_VALUE){
|
if(ts != AV_NOPTS_VALUE){
|
||||||
dp->pts = ts * av_q2d(priv->avfc->streams[id]->time_base);
|
dp->pts = ts * av_q2d(priv->avfc->streams[id]->time_base);
|
||||||
priv->last_pts= dp->pts * AV_TIME_BASE;
|
priv->last_pts= dp->pts * AV_TIME_BASE;
|
||||||
// always set duration for subtitles, even if PKT_FLAG_KEY is not set,
|
// always set duration for subtitles, even if AV_PKT_FLAG_KEY isn't set,
|
||||||
// otherwise they will stay on screen to long if e.g. ASS is demuxed from mkv
|
// otherwise they will stay on screen to long if e.g. ASS is demuxed from mkv
|
||||||
if((ds == demux->sub || (pkt.flags & PKT_FLAG_KEY)) &&
|
if ((ds == demux->sub || (pkt.flags & AV_PKT_FLAG_KEY)) &&
|
||||||
pkt.convergence_duration > 0)
|
pkt.convergence_duration > 0)
|
||||||
dp->duration = pkt.convergence_duration * av_q2d(priv->avfc->streams[id]->time_base);
|
dp->duration = pkt.convergence_duration * av_q2d(priv->avfc->streams[id]->time_base);
|
||||||
}
|
}
|
||||||
dp->pos=demux->filepos;
|
dp->pos=demux->filepos;
|
||||||
dp->flags= !!(pkt.flags&PKT_FLAG_KEY);
|
dp->flags = !!(pkt.flags & AV_PKT_FLAG_KEY);
|
||||||
// append packet to DS stream:
|
// append packet to DS stream:
|
||||||
ds_add_packet(ds,dp);
|
ds_add_packet(ds,dp);
|
||||||
return 1;
|
return 1;
|
||||||
@ -922,15 +925,15 @@ redo:
|
|||||||
{
|
{
|
||||||
switch(priv->avfc->streams[program->stream_index[i]]->codec->codec_type)
|
switch(priv->avfc->streams[program->stream_index[i]]->codec->codec_type)
|
||||||
{
|
{
|
||||||
case CODEC_TYPE_VIDEO:
|
case AVMEDIA_TYPE_VIDEO:
|
||||||
if(prog->vid == -2)
|
if(prog->vid == -2)
|
||||||
prog->vid = program->stream_index[i];
|
prog->vid = program->stream_index[i];
|
||||||
break;
|
break;
|
||||||
case CODEC_TYPE_AUDIO:
|
case AVMEDIA_TYPE_AUDIO:
|
||||||
if(prog->aid == -2)
|
if(prog->aid == -2)
|
||||||
prog->aid = program->stream_index[i];
|
prog->aid = program->stream_index[i];
|
||||||
break;
|
break;
|
||||||
case CODEC_TYPE_SUBTITLE:
|
case AVMEDIA_TYPE_SUBTITLE:
|
||||||
if(prog->sid == -2 && priv->avfc->streams[program->stream_index[i]]->codec->codec_id == CODEC_ID_TEXT)
|
if(prog->sid == -2 && priv->avfc->streams[program->stream_index[i]]->codec->codec_id == CODEC_ID_TEXT)
|
||||||
prog->sid = program->stream_index[i];
|
prog->sid = program->stream_index[i];
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user