diff -Nru mplayer-1.4+ds1/debian/changelog mplayer-1.4+ds1/debian/changelog --- mplayer-1.4+ds1/debian/changelog 2022-07-19 14:59:14.000000000 +0200 +++ mplayer-1.4+ds1/debian/changelog 2022-08-19 17:21:32.000000000 +0200 @@ -1,3 +1,9 @@ +mplayer (2:1.4+ds1-3ubuntu1) kinetic; urgency=medium + + * Backport upstream patches to build against ffmpeg 5 (LP: #1987114) + + -- Olivier Gayot Fri, 19 Aug 2022 17:21:32 +0200 + mplayer (2:1.4+ds1-3build3) kinetic; urgency=medium * No-change rebuild against libavcodec59 diff -Nru mplayer-1.4+ds1/debian/patches/r38215.patch mplayer-1.4+ds1/debian/patches/r38215.patch --- mplayer-1.4+ds1/debian/patches/r38215.patch 1970-01-01 01:00:00.000000000 +0100 +++ mplayer-1.4+ds1/debian/patches/r38215.patch 2022-08-19 17:10:25.000000000 +0200 @@ -0,0 +1,61 @@ +Description: av_helpers: switch to new lavc audio encode API. +Origin: upstream, commit: r38215 +Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1004579 +Forwarded: no +Last-Update: 2022-08-19 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +Index: b/av_helpers.c +=================================================================== +--- a/av_helpers.c 2022-08-19 16:52:03.979666019 +0200 ++++ b/av_helpers.c 2022-08-19 16:52:37.000000000 +0200 +@@ -98,7 +98,6 @@ + if (!avcodec_initialized) { + show_av_version(MSGT_DECVIDEO, "libavcodec", LIBAVCODEC_VERSION_INT, + avcodec_version(), avcodec_configuration()); +- avcodec_register_all(); + avcodec_initialized = 1; + av_log_set_callback(mp_msp_av_log_callback); + } +@@ -109,7 +108,6 @@ + if (!avformat_initialized) { + show_av_version(MSGT_DEMUX, "libavformat", LIBAVFORMAT_VERSION_INT, + avformat_version(), avformat_configuration()); +- av_register_all(); + avformat_initialized = 1; + av_log_set_callback(mp_msp_av_log_callback); + } +@@ -132,8 +130,6 @@ + ctx->channels, + src_len / bps, bps); + } +- pkt.data = dst; +- pkt.size = dst_len; + frame->nb_samples = src_len / ctx->channels / bps; + if (planar) { + // TODO: this is horribly inefficient. +@@ -150,11 +146,22 @@ + } + } + } ++ frame->format = ctx->sample_fmt; ++ frame->channels = ctx->channels; + n = avcodec_fill_audio_frame(frame, ctx->channels, ctx->sample_fmt, src, src_len, 1); + if (n < 0) return 0; +- n = avcodec_encode_audio2(ctx, &pkt, frame, &got); ++ n = avcodec_send_frame(ctx, frame); ++ av_init_packet(&pkt); ++ got = avcodec_receive_packet(ctx, &pkt); + av_frame_free(&frame); + if (planar) av_free(src); + if (n < 0) return n; +- return got ? pkt.size : 0; ++ if (got >= 0) { ++ int size = pkt.size; ++ if (size > dst_len) return -1; ++ memcpy(dst, pkt.data, size); ++ av_packet_unref(&pkt); ++ return size; ++ } ++ return 0; + } diff -Nru mplayer-1.4+ds1/debian/patches/r38216.patch mplayer-1.4+ds1/debian/patches/r38216.patch --- mplayer-1.4+ds1/debian/patches/r38216.patch 1970-01-01 01:00:00.000000000 +0100 +++ mplayer-1.4+ds1/debian/patches/r38216.patch 2022-08-19 17:09:46.000000000 +0200 @@ -0,0 +1,86 @@ +Description: ad_ffmpeg: switch to new lavc API. +Origin: upstream, commit: r38216 +Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1004579 +Forwarded: no +Last-Update: 2022-08-19 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +Index: b/libmpcodecs/ad_ffmpeg.c +=================================================================== +--- a/libmpcodecs/ad_ffmpeg.c 2022-08-19 16:52:04.011665773 +0200 ++++ b/libmpcodecs/ad_ffmpeg.c 2022-08-19 16:52:04.003665834 +0200 +@@ -310,34 +310,41 @@ + + static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen) + { ++ int draining_started = 0; + unsigned char *start=NULL; +- int y,len=-1, got_frame; ++ int y,len=-1; + AVFrame *frame = av_frame_alloc(); + + if (!frame) + return AVERROR(ENOMEM); + + while(lencontext, frame); ++ if (y == AVERROR(EAGAIN) || y == AVERROR_EOF) { ++ AVPacket pkt; + double pts; + int x=ds_get_packet_pts(sh_audio->ds,&start, &pts); + if(x<=0) { + start = NULL; + x = 0; + ds_parse(sh_audio->ds, &start, &x, MP_NOPTS_VALUE, 0); +- if (x <= 0) +- break; // error + } else { + int in_size = x; + int consumed = ds_parse(sh_audio->ds, &start, &x, pts, 0); + sh_audio->ds->buffer_pos -= in_size - consumed; +- // Note: hopefully below is correct, it was only ++ // Note: hopefully the following x <= 0 handling is correct, it was only + // added because FFmpeg broke the API and 0-sized + // packets started to break e.g. AC3 decode. +- if (x <= 0) +- break; // error or not enough data + } ++ if (x <= 0) { ++ if (sh_audio->ds->eof && !draining_started) { ++ avcodec_send_packet(sh_audio->context, NULL); ++ draining_started = 1; ++ continue; ++ } ++ break; // error or not enough data ++ } + + av_init_packet(&pkt); + pkt.data = start; +@@ -346,16 +353,18 @@ + sh_audio->pts = pts; + sh_audio->pts_bytes = 0; + } +- y=avcodec_decode_audio4(sh_audio->context, frame, &got_frame, &pkt); +-//printf("return:%d samples_out:%d bitstream_in:%d sample_sum:%d\n", y, len2, x, len); fflush(stdout); +- // LATM may need many packets to find mux info +- if (y == AVERROR(EAGAIN)) +- continue; ++ y=avcodec_send_packet(sh_audio->context, &pkt); ++ if(y<0){ mp_msg(MSGT_DECAUDIO,MSGL_V,"lavc_audio: error\n");break; } ++ continue; ++ } + if(y<0){ mp_msg(MSGT_DECAUDIO,MSGL_V,"lavc_audio: error\n");break; } ++//printf("return:%d samples_out:%d bitstream_in:%d sample_sum:%d\n", y, len2, x, len); fflush(stdout); ++#if 0 ++ // this should be obsolete since the new API does no support it ++ // and we support inserting parsers as necessary instead. + if(!sh_audio->parser && yds->buffer_pos+=y-x; // put back data (HACK!) +- if (!got_frame) +- continue; ++#endif + len2 = copy_samples(sh_audio->context, frame, buf, maxlen); + if (len2 < 0) + return len2; diff -Nru mplayer-1.4+ds1/debian/patches/r38217.patch mplayer-1.4+ds1/debian/patches/r38217.patch --- mplayer-1.4+ds1/debian/patches/r38217.patch 1970-01-01 01:00:00.000000000 +0100 +++ mplayer-1.4+ds1/debian/patches/r38217.patch 2022-08-19 17:09:04.000000000 +0200 @@ -0,0 +1,47 @@ +Description: vd_ffmpeg: Switch to newer lavc decode API. +Origin: upstream, commit: r38217 +Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1004579 +Forwarded: no +Last-Update: 2022-08-19 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +Index: b/libmpcodecs/vd_ffmpeg.c +=================================================================== +--- a/libmpcodecs/vd_ffmpeg.c 2022-08-19 16:52:04.039665557 +0200 ++++ b/libmpcodecs/vd_ffmpeg.c 2022-08-19 16:52:37.000000000 +0200 +@@ -484,7 +484,7 @@ + set_dr_slice_settings(avctx, lavc_codec); + avctx->thread_count = lavc_param_threads; + avctx->thread_type = FF_THREAD_FRAME | FF_THREAD_SLICE; +- avctx->refcounted_frames = 1; ++ av_dict_set(&opts, "refcounted_frames", "1", 0); + + /* open it */ + if (avcodec_open2(avctx, lavc_codec, &opts) < 0) { +@@ -925,7 +925,16 @@ + } + ctx->palette_sent = 1; + } +- ret = avcodec_decode_video2(avctx, pic, &got_picture, &pkt); ++ ret = avcodec_send_packet(avctx, !pkt.data && !pkt.size ? NULL : &pkt); ++ if (ret == AVERROR(EAGAIN)) { ++ mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Too many frames buffered in decode, MPlayer cannot handle that yet!\n"); ++ ret = 0; ++ } ++ if (ret >= 0 || ret == AVERROR_EOF) { ++ ret = avcodec_receive_frame(avctx, pic); ++ got_picture = ret >= 0; ++ if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) ret = 0; ++ } + ctx->refcount_frame = pic; + pkt.data = NULL; + pkt.size = 0; +@@ -935,7 +944,7 @@ + // FFmpeg allocate - this mostly happens with nonref_dr. + // Ensure we treat it correctly. + dr1= ctx->do_dr1 && pic->opaque != NULL; +- if(ret<0) mp_msg(MSGT_DECVIDEO, MSGL_WARN, "Error while decoding frame!\n"); ++ if(ret<0) mp_msg(MSGT_DECVIDEO, MSGL_WARN, "Error while decoding frame! (%i)\n", ret); + //printf("repeat: %d\n", pic->repeat_pict); + //-- vstats generation + while(lavc_param_vstats){ // always one time loop diff -Nru mplayer-1.4+ds1/debian/patches/r38219.patch mplayer-1.4+ds1/debian/patches/r38219.patch --- mplayer-1.4+ds1/debian/patches/r38219.patch 1970-01-01 01:00:00.000000000 +0100 +++ mplayer-1.4+ds1/debian/patches/r38219.patch 2022-08-19 17:08:26.000000000 +0200 @@ -0,0 +1,104 @@ +Description: demux_lavf: avoid several deprecated lavf features. +Origin: upstream, commit: r38219 +Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1004579 +Forwarded: no +Last-Update: 2022-08-19 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +Index: b/libmpdemux/demux_lavf.c +=================================================================== +--- a/libmpdemux/demux_lavf.c 2022-08-19 16:52:03.951666234 +0200 ++++ b/libmpdemux/demux_lavf.c 2022-08-19 16:52:37.000000000 +0200 +@@ -146,9 +146,10 @@ + } + + static void list_formats(void) { +- AVInputFormat *fmt; ++ void *i = 0; ++ const AVInputFormat *fmt; + mp_msg(MSGT_DEMUX, MSGL_INFO, "Available lavf input formats:\n"); +- for (fmt = av_iformat_next(NULL); fmt; fmt = av_iformat_next(fmt)) ++ while ((fmt = av_demuxer_iterate(&i))) + mp_msg(MSGT_DEMUX, MSGL_INFO, "%15s : %s\n", fmt->name, fmt->long_name); + } + +@@ -288,7 +289,7 @@ + static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) { + lavf_priv_t *priv= demuxer->priv; + AVStream *st= avfc->streams[i]; +- AVCodecContext *codec= st->codec; ++ AVCodecParameters *codec= st->codecpar; + char *stream_type = NULL; + int stream_id; + AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0); +@@ -396,7 +397,7 @@ + if (codec->bits_per_coded_sample && codec->bits_per_coded_sample > 0 && + codec->codec_tag == MKTAG('r', 'a', 'w', 32)) + codec->codec_tag = 0; +- switch (codec->pix_fmt) { ++ switch (codec->format) { + case AV_PIX_FMT_RGB24: + codec->codec_tag= MKTAG(24, 'B', 'G', 'R'); + break; +@@ -420,8 +421,8 @@ + sh_video->video.dwRate= st->time_base.den; + sh_video->video.dwScale= st->time_base.num; + } else { +- sh_video->video.dwRate= codec->time_base.den; +- sh_video->video.dwScale= codec->time_base.num; ++ sh_video->video.dwRate= st->codec->time_base.den; ++ sh_video->video.dwScale= st->codec->time_base.num; + } + sh_video->fps=av_q2d(st->r_frame_rate); + sh_video->frametime=1/av_q2d(st->r_frame_rate); +@@ -513,7 +514,7 @@ + break; + } + case AVMEDIA_TYPE_ATTACHMENT:{ +- if (st->codec->codec_id == AV_CODEC_ID_TTF || st->codec->codec_id == AV_CODEC_ID_OTF) { ++ if (st->codecpar->codec_id == AV_CODEC_ID_TTF || st->codecpar->codec_id == AV_CODEC_ID_OTF) { + AVDictionaryEntry *fnametag = av_dict_get(st->metadata, "filename", NULL, 0); + AVDictionaryEntry *mimetype = av_dict_get(st->metadata, "mimetype", NULL, 0); + demuxer_add_attachment(demuxer, fnametag ? fnametag->value : NULL, +@@ -716,23 +717,19 @@ + ds=demux->sub; + sub_utf8=1; + } else { +- av_free_packet(&pkt); ++ av_packet_unref(&pkt); + return 1; + } + + av_packet_merge_side_data(&pkt); + dp=new_demux_packet(pkt.size); + memcpy(dp->buffer, pkt.data, pkt.size); +- av_free_packet(&pkt); + + if(pkt.pts != AV_NOPTS_VALUE){ + dp->pts=pkt.pts * av_q2d(priv->avfc->streams[id]->time_base); + priv->last_pts= dp->pts * AV_TIME_BASE; + if(pkt.duration > 0) + dp->endpts = dp->pts + pkt.duration * av_q2d(priv->avfc->streams[id]->time_base); +- /* subtitle durations are sometimes stored in convergence_duration */ +- if(ds == demux->sub && pkt.convergence_duration > 0) +- dp->endpts = dp->pts + pkt.convergence_duration * av_q2d(priv->avfc->streams[id]->time_base); + } + dp->pos=demux->filepos; + dp->flags= !!(pkt.flags&AV_PKT_FLAG_KEY); +@@ -741,6 +738,7 @@ + dp->stream_pts = stream_pts; + // append packet to DS stream: + ds_add_packet(ds,dp); ++ av_packet_unref(&pkt); + return 1; + } + +@@ -879,7 +877,7 @@ + program = priv->avfc->programs[p]; + for(i=0; inb_stream_indexes; i++) + { +- switch(priv->avfc->streams[program->stream_index[i]]->codec->codec_type) ++ switch(priv->avfc->streams[program->stream_index[i]]->codecpar->codec_type) + { + case AVMEDIA_TYPE_VIDEO: + if(prog->vid == -2) diff -Nru mplayer-1.4+ds1/debian/patches/r38246.patch mplayer-1.4+ds1/debian/patches/r38246.patch --- mplayer-1.4+ds1/debian/patches/r38246.patch 1970-01-01 01:00:00.000000000 +0100 +++ mplayer-1.4+ds1/debian/patches/r38246.patch 2022-08-19 17:07:36.000000000 +0200 @@ -0,0 +1,39 @@ +Description: Use new lavc decode API for GUI's PNG decode. +Origin: upstream, commit: r38246 +Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1004579 +Forwarded: no +Last-Update: 2022-08-19 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +Index: b/gui/util/bitmap.c +=================================================================== +--- a/gui/util/bitmap.c 2022-08-19 16:52:04.067665341 +0200 ++++ b/gui/util/bitmap.c 2022-08-19 16:52:04.063665372 +0200 +@@ -124,8 +124,6 @@ + return 6; + } + +- avcodec_register_all(); +- + if (avcodec_open2(avctx, avcodec_find_decoder(AV_CODEC_ID_PNG), NULL) < 0) { + av_free(frame); + av_free(avctx); +@@ -139,7 +137,8 @@ + /* HACK: Make PNGs decode normally instead of as CorePNG delta frames. */ + pkt.flags = AV_PKT_FLAG_KEY; + +- avcodec_decode_video2(avctx, frame, &decode_ok, &pkt); ++ decode_ok = (avcodec_send_packet(avctx, &pkt) == 0 && ++ avcodec_receive_frame(avctx, frame) == 0); + + memset(img, 0, sizeof(*img)); + memset(palette, 0, sizeof(palette)); +@@ -186,6 +185,8 @@ + decode_ok = False; + } + ++ avcodec_send_packet(avctx, NULL); // flush the decoder ++ + avcodec_close(avctx); + av_free(frame); + av_free(avctx); diff -Nru mplayer-1.4+ds1/debian/patches/r38306.patch mplayer-1.4+ds1/debian/patches/r38306.patch --- mplayer-1.4+ds1/debian/patches/r38306.patch 1970-01-01 01:00:00.000000000 +0100 +++ mplayer-1.4+ds1/debian/patches/r38306.patch 2022-08-19 17:19:15.000000000 +0200 @@ -0,0 +1,67 @@ +Description: vo_png: switch to new FFmpeg API. +Origin: upstream, commit: r38306 +Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1004579 +Forwarded: no +Last-Update: 2022-08-19 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +Index: b/libvo/vo_png.c +=================================================================== +--- a/libvo/vo_png.c 2022-08-19 16:52:03.919666480 +0200 ++++ b/libvo/vo_png.c 2022-08-19 16:52:03.915666511 +0200 +@@ -150,8 +150,7 @@ + + static uint32_t draw_image(mp_image_t* mpi){ + AVFrame *pic; +- int buffersize; +- int res, got_pkt; ++ int res; + char buf[100]; + FILE *outfile; + AVPacket pkt; +@@ -174,26 +173,25 @@ + pic->format = imgfmt2pixfmt(png_format); + pic->data[0] = mpi->planes[0]; + pic->linesize[0] = mpi->stride[0]; +- buffersize = mpi->w * mpi->h * 8; +- if (outbuffer_size < buffersize) { +- av_freep(&outbuffer); +- outbuffer = av_malloc(buffersize); +- outbuffer_size = buffersize; +- } + av_init_packet(&pkt); +- pkt.data = outbuffer; +- pkt.size = outbuffer_size; +- res = avcodec_encode_video2(avctx, &pkt, pic, &got_pkt); ++ res = avcodec_send_frame(avctx, pic); ++ if (res >= 0) { ++ res = avcodec_receive_packet(avctx, &pkt); ++ if (res == AVERROR(EAGAIN)) { ++ avcodec_send_frame(avctx, NULL); ++ res = avcodec_receive_packet(avctx, &pkt); ++ } ++ } + av_frame_free(&pic); + +- if (res < 0 || !got_pkt) { ++ if (res < 0) { + mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_PNG_ErrorInCreatePng); + } else { +- fwrite(outbuffer, pkt.size, 1, outfile); ++ fwrite(pkt.data, pkt.size, 1, outfile); + } + + fclose(outfile); +- av_free_packet(&pkt); ++ av_packet_unref(&pkt); + + return VO_TRUE; + } +@@ -251,7 +249,6 @@ + if (subopt_parse(arg, subopts) != 0) { + return -1; + } +- avcodec_register_all(); + return 0; + } + diff -Nru mplayer-1.4+ds1/debian/patches/r38307.patch mplayer-1.4+ds1/debian/patches/r38307.patch --- mplayer-1.4+ds1/debian/patches/r38307.patch 1970-01-01 01:00:00.000000000 +0100 +++ mplayer-1.4+ds1/debian/patches/r38307.patch 2022-08-19 17:06:50.000000000 +0200 @@ -0,0 +1,498 @@ +Description: Fix compilation against latest FFmpeg. + Only for MPlayer, mencoder needs more changes. +Origin: upstream, commit: r38307 +Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1004579 +Forwarded: no +Last-Update: 2022-08-19 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +Index: b/Makefile +=================================================================== +--- a/Makefile 2022-08-19 16:52:04.099665096 +0200 ++++ b/Makefile 2022-08-19 16:52:04.091665157 +0200 +@@ -70,7 +70,9 @@ + SRCS_COMMON-$(FFMPEG_A) += libmpcodecs/vf_fspp.c \ + libmpcodecs/vf_qp.c \ + libmpcodecs/vf_spp.c \ +- libmpcodecs/vf_uspp.c \ ++ ++# needs update for missing coded_frame ++#libmpcodecs/vf_uspp.c \ + + SRCS_COMMON-$(FREETYPE) += sub/font_load_ft.c + SRCS_COMMON-$(FTP) += stream/stream_ftp.c +Index: b/av_helpers.c +=================================================================== +--- a/av_helpers.c 2022-08-19 16:52:04.099665096 +0200 ++++ b/av_helpers.c 2022-08-19 16:52:21.000000000 +0200 +@@ -20,6 +20,7 @@ + + #include "libavcodec/avcodec.h" + #include "libavformat/avformat.h" ++#include "libavutil/intreadwrite.h" + #include "mp_msg.h" + #include "av_helpers.h" + #include "libaf/reorder_ch.h" +@@ -165,3 +166,93 @@ + } + return 0; + } ++ ++#define MERGE_MARKER 0x8c4d9d108e25e9feULL ++ ++static void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size) ++{ ++ memcpy(*b, src, size); ++ *b += size; ++} ++ ++int mp_packet_merge_side_data(AVPacket *pkt){ ++ if(pkt->side_data_elems){ ++ AVBufferRef *buf; ++ int i; ++ uint8_t *p; ++ uint64_t size= pkt->size + 8LL + AV_INPUT_BUFFER_PADDING_SIZE; ++ AVPacket old= *pkt; ++ for (i=0; i INT_MAX) ++ return AVERROR(EINVAL); ++ buf = av_buffer_alloc(size); ++ if (!buf) ++ return AVERROR(ENOMEM); ++ pkt->buf = buf; ++ pkt->data = p = buf->data; ++ pkt->size = size - AV_INPUT_BUFFER_PADDING_SIZE; ++ bytestream_put_buffer(&p, old.data, old.size); ++ for (i=old.side_data_elems-1; i>=0; i--) { ++ bytestream_put_buffer(&p, old.side_data[i].data, old.side_data[i].size); ++ AV_WB32(p, old.side_data[i].size); ++ p += 4; ++ *p++ = old.side_data[i].type | ((i==old.side_data_elems-1)*128); ++ } ++ AV_WB64(p, MERGE_MARKER); ++ p += 8; ++ memset(p, 0, AV_INPUT_BUFFER_PADDING_SIZE); ++ av_packet_unref(&old); ++ pkt->side_data_elems = 0; ++ pkt->side_data = NULL; ++ return 1; ++ } ++ return 0; ++} ++ ++int mp_packet_split_side_data(AVPacket *pkt){ ++ if (!pkt->side_data_elems && pkt->size >12 && AV_RB64(pkt->data + pkt->size - 8) == MERGE_MARKER){ ++ int i; ++ unsigned int size; ++ uint8_t *p; ++ ++ p = pkt->data + pkt->size - 8 - 5; ++ for (i=1; ; i++){ ++ size = AV_RB32(p); ++ if (size>INT_MAX - 5 || p - pkt->data < size) ++ return 0; ++ if (p[4]&128) ++ break; ++ if (p - pkt->data < size + 5) ++ return 0; ++ p-= size+5; ++ } ++ ++ if (i > AV_PKT_DATA_NB) ++ return AVERROR(ERANGE); ++ ++ pkt->side_data = av_malloc_array(i, sizeof(*pkt->side_data)); ++ if (!pkt->side_data) ++ return AVERROR(ENOMEM); ++ ++ p= pkt->data + pkt->size - 8 - 5; ++ for (i=0; ; i++){ ++ size= AV_RB32(p); ++ pkt->side_data[i].data = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE); ++ pkt->side_data[i].size = size; ++ pkt->side_data[i].type = p[4]&127; ++ if (!pkt->side_data[i].data) ++ return AVERROR(ENOMEM); ++ memcpy(pkt->side_data[i].data, p-size, size); ++ pkt->size -= size + 5; ++ if(p[4]&128) ++ break; ++ p-= size+5; ++ } ++ pkt->size -= 8; ++ pkt->side_data_elems = i+1; ++ return 1; ++ } ++ return 0; ++} +Index: b/av_helpers.h +=================================================================== +--- a/av_helpers.h 2022-08-19 16:52:04.099665096 +0200 ++++ b/av_helpers.h 2022-08-19 16:52:04.091665157 +0200 +@@ -22,9 +22,13 @@ + #define MPLAYER_AV_HELPERS_H + + struct AVCodecContext; ++struct AVFrame; ++struct AVPacket; + + void init_avcodec(void); + void init_avformat(void); + int lavc_encode_audio(struct AVCodecContext *ctx, void *src, int src_len, void *dst, int dst_len); ++int mp_packet_merge_side_data(struct AVPacket *pkt); ++int mp_packet_split_side_data(struct AVPacket *pkt); + + #endif /* MPLAYER_AV_HELPERS_H */ +Index: b/libmpcodecs/ad_spdif.c +=================================================================== +--- a/libmpcodecs/ad_spdif.c 2022-08-19 16:52:04.099665096 +0200 ++++ b/libmpcodecs/ad_spdif.c 2022-08-19 16:52:04.091665157 +0200 +@@ -126,7 +126,7 @@ + lavf_ctx->start_time = AV_NOPTS_VALUE; + for (i = 0; fmt_id_type[i].name; i++) { + if (!strcmp(codec_idx2str(sh->codec->dll_idx), fmt_id_type[i].name)) { +- lavf_ctx->streams[0]->codec->codec_id = fmt_id_type[i].id; ++ lavf_ctx->streams[0]->codecpar->codec_id = fmt_id_type[i].id; + break; + } + } +@@ -161,7 +161,7 @@ + } + sh->ds->buffer_pos -= in_size; + +- switch (lavf_ctx->streams[0]->codec->codec_id) { ++ switch (lavf_ctx->streams[0]->codecpar->codec_id) { + case AV_CODEC_ID_AAC: + spdif_ctx->iec61937_packet_size = 16384; + sh->sample_format = AF_FORMAT_IEC61937_LE; +Index: b/libmpcodecs/vd_ffmpeg.c +=================================================================== +--- a/libmpcodecs/vd_ffmpeg.c 2022-08-19 16:52:04.099665096 +0200 ++++ b/libmpcodecs/vd_ffmpeg.c 2022-08-19 16:52:04.091665157 +0200 +@@ -902,7 +902,7 @@ + pkt.size = len; + // Necessary to decode e.g. CorePNG and ZeroCodec correctly + pkt.flags = (sh->ds->flags & 1) ? AV_PKT_FLAG_KEY : 0; +- av_packet_split_side_data(&pkt); ++ mp_packet_split_side_data(&pkt); + if (av_packet_get_side_data(&pkt, AV_PKT_DATA_PALETTE, NULL)) + ctx->palette_sent = 1; + if (!ctx->palette_sent && sh->bih && sh->bih->biBitCount <= 8) { +@@ -975,6 +975,8 @@ + + // average MB quantizer + { ++// TODO: still possible in new FFmpeg API? ++#if 0 + int x, y; + int w = ((avctx->width << lavc_param_lowres)+15) >> 4; + int h = ((avctx->height << lavc_param_lowres)+15) >> 4; +@@ -987,6 +989,7 @@ + q += qstride; + } + quality /= w * h; ++#endif + } + + all_len+=len; +@@ -1077,7 +1080,8 @@ + swap_palette(mpi->planes[1]); + #endif + /* to comfirm with newer lavc style */ +- mpi->qscale = av_frame_get_qp_table(pic, &mpi->qstride, &mpi->qscale_type); ++// TODO: still possible in new FFmpeg API? ++// mpi->qscale = av_frame_get_qp_table(pic, &mpi->qstride, &mpi->qscale_type); + mpi->pict_type=pic->pict_type; + mpi->fields = MP_IMGFIELD_ORDERED; + if(pic->interlaced_frame) mpi->fields |= MP_IMGFIELD_INTERLACED; +Index: b/libmpcodecs/vf.c +=================================================================== +--- a/libmpcodecs/vf.c 2022-08-19 16:52:04.099665096 +0200 ++++ b/libmpcodecs/vf.c 2022-08-19 16:52:04.095665126 +0200 +@@ -197,7 +197,7 @@ + &vf_info_hue, + #ifdef CONFIG_FFMPEG_A + &vf_info_spp, +- &vf_info_uspp, ++// &vf_info_uspp, // TODO: does not currently build + &vf_info_fspp, + &vf_info_qp, + // &vf_info_mcdeint, //TODO: vf_mcdeint is deactivated because it doesn't build after latest FFmpeg major bumps +Index: b/libmpcodecs/vf_lavc.c +=================================================================== +--- a/libmpcodecs/vf_lavc.c 2022-08-19 16:52:04.099665096 +0200 ++++ b/libmpcodecs/vf_lavc.c 2022-08-19 16:52:04.095665126 +0200 +@@ -33,12 +33,12 @@ + + + struct vf_priv_s { +- unsigned char* outbuf; +- int outbuf_size; + AVCodecContext* context; + AVFrame* pic; +- AVCodec* codec; ++ const AVCodec* codec; + vo_mpegpes_t pes; ++ AVPacket *pkt; ++ int pkt_has_ref; + }; + + #define lavc_venc_context (*vf->priv->context) +@@ -69,10 +69,7 @@ + } + } + +- free(vf->priv->outbuf); +- +- vf->priv->outbuf_size=10000+width*height; // must be enough! +- vf->priv->outbuf = malloc(vf->priv->outbuf_size); ++ if (vf->priv->pkt_has_ref) av_packet_unref(vf->priv->pkt); + + if (avcodec_open2(&lavc_venc_context, vf->priv->codec, NULL) != 0) { + mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_CantOpenCodec); +@@ -84,10 +81,9 @@ + + static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts, double endpts){ + mp_image_t* dmpi; +- int out_size; + AVFrame *pic= vf->priv->pic; +- int ret, got_pkt; +- AVPacket pkt; ++ AVPacket *pkt = vf->priv->pkt; ++ int ret; + + pic->data[0]=mpi->planes[0]; + pic->data[1]=mpi->planes[1]; +@@ -96,21 +92,21 @@ + pic->linesize[1]=mpi->stride[1]; + pic->linesize[2]=mpi->stride[2]; + +- av_init_packet(&pkt); +- pkt.data = vf->priv->outbuf; +- pkt.size = vf->priv->outbuf_size; +- ret = avcodec_encode_video2(&lavc_venc_context, &pkt, pic, &got_pkt); +- +- if(ret<=0) return 1; +- if(!got_pkt) return 1; +- out_size = pkt.size; ++ if (vf->priv->pkt_has_ref) av_packet_unref(pkt); ++ ret = avcodec_send_frame(&lavc_venc_context, pic); ++ if (ret >= 0) { ++ ret = avcodec_receive_packet(&lavc_venc_context, pkt); ++ } ++ vf->priv->pkt_has_ref = ret >= 0; ++ ++ if(ret<0) return 1; + + dmpi=vf_get_image(vf->next,IMGFMT_MPEGPES, + MP_IMGTYPE_EXPORT, 0, + mpi->w, mpi->h); + +- vf->priv->pes.data=vf->priv->outbuf; +- vf->priv->pes.size=out_size; ++ vf->priv->pes.data=pkt->data; ++ vf->priv->pes.size=pkt->size; + vf->priv->pes.id=0x1E0; + vf->priv->pes.timestamp=-1; // dunno + +@@ -151,6 +147,7 @@ + + vf->priv->context=avcodec_alloc_context3(vf->priv->codec); + vf->priv->pic = av_frame_alloc(); ++ vf->priv->pkt = av_packet_alloc(); + + // TODO: parse args -> + if(args) sscanf(args, "%d:%f", &p_quality, &p_fps); +Index: b/libmpcodecs/vf_screenshot.c +=================================================================== +--- a/libmpcodecs/vf_screenshot.c 2022-08-19 16:52:04.099665096 +0200 ++++ b/libmpcodecs/vf_screenshot.c 2022-08-19 16:52:04.095665126 +0200 +@@ -54,10 +54,9 @@ + int shot, store_slices; + int dw, dh; + AVFrame *pic; ++ AVPacket *pkt; + struct SwsContext *ctx; + AVCodecContext *avctx; +- uint8_t *outbuffer; +- int outbuffer_size; + }; + + //===========================================================================// +@@ -80,7 +79,6 @@ + vf->priv->ctx=sws_getContextFromCmdLine(width, height, outfmt, + d_width, d_height, IMGFMT_RGB24); + +- av_fast_malloc(&vf->priv->outbuffer, &vf->priv->outbuffer_size, d_width * d_height * 3 * 2); + if (!vf->priv->avctx) { + vf->priv->avctx = avcodec_alloc_context3(NULL); + vf->priv->avctx->pix_fmt = AV_PIX_FMT_RGB24; +@@ -111,17 +109,21 @@ + { + char *fname = priv->fname; + FILE * fp; +- AVPacket pkt; +- int res, got_pkt; ++ AVPacket *pkt = priv->pkt; ++ int res; + +- av_init_packet(&pkt); +- pkt.data = priv->outbuffer; +- pkt.size = priv->outbuffer_size; + priv->pic->width = priv->avctx->width; + priv->pic->height = priv->avctx->height; + priv->pic->format = priv->avctx->pix_fmt; +- res = avcodec_encode_video2(priv->avctx, &pkt, priv->pic, &got_pkt); +- if (res < 0 || !got_pkt || pkt.size <= 0) { ++ res = avcodec_send_frame(priv->avctx, priv->pic); ++ if (res >= 0) { ++ res = avcodec_receive_packet(priv->avctx, pkt); ++ if (res == AVERROR(EAGAIN)) { ++ avcodec_send_frame(priv->avctx, NULL); ++ res = avcodec_receive_packet(priv->avctx, pkt); ++ } ++ } ++ if (res < 0 || pkt->size <= 0) { + mp_msg(MSGT_VFILTER,MSGL_ERR,"\nFailed to encode screenshot %s!\n", fname); + return; + } +@@ -132,7 +134,8 @@ + return; + } + +- fwrite(priv->outbuffer, pkt.size, 1, fp); ++ fwrite(pkt->data, pkt->size, 1, fp); ++ av_packet_unref(pkt); + + fclose (fp); + mp_msg(MSGT_VFILTER,MSGL_INFO,"*** screenshot '%s' ***\n",priv->fname); +@@ -286,7 +289,7 @@ + if(vf->priv->ctx) sws_freeContext(vf->priv->ctx); + av_freep(&vf->priv->pic->data[0]); + av_frame_free(&vf->priv->pic); +- av_freep(&vf->priv->outbuffer); ++ av_packet_free(&vf->priv->pkt); + free(vf->priv->prefix); + free(vf->priv); + } +@@ -303,8 +306,8 @@ + vf->uninit=uninit; + vf->priv = calloc(1, sizeof(struct vf_priv_s)); + vf->priv->pic = av_frame_alloc(); ++ vf->priv->pkt = av_packet_alloc(); + vf->priv->prefix = strdup(args ? args : "shot"); +- avcodec_register_all(); + if (!avcodec_find_encoder(AV_CODEC_ID_PNG)) { + mp_msg(MSGT_VFILTER, MSGL_FATAL, "Could not find libavcodec PNG encoder\n"); + return 0; +Index: b/libmpdemux/demux_lavf.c +=================================================================== +--- a/libmpdemux/demux_lavf.c 2022-08-19 16:52:04.099665096 +0200 ++++ b/libmpdemux/demux_lavf.c 2022-08-19 16:52:04.095665126 +0200 +@@ -68,7 +68,7 @@ + #define BIO_BUFFER_SIZE 32768 + + typedef struct lavf_priv { +- AVInputFormat *avif; ++ const AVInputFormat *avif; + AVFormatContext *avfc; + AVIOContext *pb; + int audio_streams; +@@ -366,7 +366,7 @@ + if (demuxer->audio->id != i) + st->discard= AVDISCARD_ALL; + if (priv->audio_streams == 0) { +- int rg_size; ++ size_t rg_size; + AVReplayGain *rg = (AVReplayGain*)av_stream_get_side_data(st, AV_PKT_DATA_REPLAYGAIN, &rg_size); + if (rg && rg_size >= sizeof(*rg)) { + priv->r_gain = rg->track_gain / 10000; +@@ -420,9 +420,12 @@ + if (st->time_base.den) { /* if container has time_base, use that */ + sh_video->video.dwRate= st->time_base.den; + sh_video->video.dwScale= st->time_base.num; ++#if 0 + } else { ++ // not available in latest FFmpeg API, ok to just remove? + sh_video->video.dwRate= st->codec->time_base.den; + sh_video->video.dwScale= st->codec->time_base.num; ++#endif + } + sh_video->fps=av_q2d(st->r_frame_rate); + sh_video->frametime=1/av_q2d(st->r_frame_rate); +@@ -527,7 +530,7 @@ + st->discard= AVDISCARD_ALL; + } + if (stream_type) { +- AVCodec *avc = avcodec_find_decoder(codec->codec_id); ++ const AVCodec *avc = avcodec_find_decoder(codec->codec_id); + const char *codec_name = avc ? avc->name : "unknown"; + if (!avc && *stream_type == 's' && demuxer->s_streams[i]) + codec_name = sh_sub_type2str(((sh_sub_t *)demuxer->s_streams[i])->type); +@@ -602,7 +605,6 @@ + avfc->pb = priv->pb; + } + +- av_dict_set(&opts, "fflags", "+keepside", 0); + if(avformat_open_input(&avfc, mp_filename, priv->avif, &opts)<0){ + mp_msg(MSGT_HEADER,MSGL_ERR,"LAVF_header: av_open_input_stream() failed\n"); + return NULL; +@@ -707,7 +709,7 @@ + } + sh = ds->sh; + if (sh && sh->bih) { +- int size = 0; ++ size_t size = 0; + const uint8_t *pal = av_packet_get_side_data(&pkt, AV_PKT_DATA_PALETTE, &size); + if (pal && size) + memcpy(((uint8_t *)sh->bih) + sh->bih->biSize, pal, FFMIN(size, 1024)); +@@ -721,7 +723,7 @@ + return 1; + } + +- av_packet_merge_side_data(&pkt); ++ mp_packet_merge_side_data(&pkt); + dp=new_demux_packet(pkt.size); + memcpy(dp->buffer, pkt.data, pkt.size); + +Index: b/sub/av_sub.c +=================================================================== +--- a/sub/av_sub.c 2022-08-19 16:52:04.099665096 +0200 ++++ b/sub/av_sub.c 2022-08-19 16:52:04.095665126 +0200 +@@ -43,9 +43,9 @@ + + if (num_rects == 1) { + spudec_set_paletted(vo_spudec, +- rects[0]->pict.data[0], +- rects[0]->pict.linesize[0], +- rects[0]->pict.data[1], ++ rects[0]->data[0], ++ rects[0]->linesize[0], ++ rects[0]->data[1], + rects[0]->x, + rects[0]->y, + rects[0]->w, +@@ -66,9 +66,9 @@ + spudec_packet_clear(packet); + for (i = 0; i < num_rects; i++) + spudec_packet_fill(packet, +- rects[i]->pict.data[0], +- rects[i]->pict.linesize[0], +- rects[i]->pict.data[1], ++ rects[i]->data[0], ++ rects[i]->linesize[0], ++ rects[i]->data[1], + rects[i]->x - xmin, + rects[i]->y - ymin, + rects[i]->w, +@@ -105,7 +105,7 @@ + pkt.size = *size; + pkt.pts = *pts * 1000; + if (*pts != MP_NOPTS_VALUE && *endpts != MP_NOPTS_VALUE) +- pkt.convergence_duration = (*endpts - *pts) * 1000; ++ pkt.duration = (*endpts - *pts) * 1000; + if (!ctx) { + AVCodec *sub_codec; + init_avcodec(); diff -Nru mplayer-1.4+ds1/debian/patches/r38309.patch mplayer-1.4+ds1/debian/patches/r38309.patch --- mplayer-1.4+ds1/debian/patches/r38309.patch 1970-01-01 01:00:00.000000000 +0100 +++ mplayer-1.4+ds1/debian/patches/r38309.patch 2022-08-19 17:06:00.000000000 +0200 @@ -0,0 +1,86 @@ +Description: muxer_lavf: fix compilation with newer FFmpeg. + Note that this also moves the time base setting from codec to + stream, which makes it actually work again as the codec + time base is ignored by FFmpeg. + Leaves ve_lavc to fix for mencoder, which is a bit more complicated, + mostly because it's so many parameters that need to be replaced + with the matching dictionary setting, which is not easy to find. +Origin: upstream, commit: r38309 +Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1004579 +Forwarded: no +Last-Update: 2022-08-19 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +Index: b/libmpdemux/muxer_lavf.c +=================================================================== +--- a/libmpdemux/muxer_lavf.c 2022-08-19 16:52:04.127664880 +0200 ++++ b/libmpdemux/muxer_lavf.c 2022-08-19 16:52:04.123664911 +0200 +@@ -112,7 +112,7 @@ + muxer_priv_t *priv = muxer->priv; + muxer_stream_t *stream; + muxer_stream_priv_t *spriv; +- AVCodecContext *ctx; ++ AVCodecParameters *ctx; + + if(type != MUXER_TYPE_VIDEO && type != MUXER_TYPE_AUDIO) + { +@@ -154,7 +154,7 @@ + } + spriv->avstream->id = 1; + +- ctx = spriv->avstream->codec; ++ ctx = spriv->avstream->codecpar; + ctx->codec_id = AV_CODEC_ID_NONE; + switch(type) + { +@@ -177,11 +177,9 @@ + static void fix_parameters(muxer_stream_t *stream) + { + muxer_stream_priv_t *spriv = stream->priv; +- AVCodecContext *ctx = spriv->avstream->codec; ++ AVCodecParameters *ctx = spriv->avstream->codecpar; + + ctx->bit_rate= stream->avg_rate; +- ctx->rc_buffer_size= stream->vbv_size; +- ctx->rc_max_rate= stream->max_rate; + + if(stream->type == MUXER_TYPE_AUDIO) + { +@@ -221,12 +219,12 @@ + ctx->codec_tag= stream->bih->biCompression; + mp_msg(MSGT_MUXER, MSGL_INFO, "VIDEO CODEC ID: %d\n", ctx->codec_id); + if (stream->imgfmt) +- ctx->pix_fmt = imgfmt2pixfmt(stream->imgfmt); ++ ctx->format = imgfmt2pixfmt(stream->imgfmt); + ctx->width = stream->bih->biWidth; + ctx->height = stream->bih->biHeight; + ctx->bit_rate = 800000; +- ctx->time_base.den = stream->h.dwRate; +- ctx->time_base.num = stream->h.dwScale; ++ spriv->avstream->time_base.den = stream->h.dwRate; ++ spriv->avstream->time_base.num = stream->h.dwScale; + if (stream->aspect) + ctx->sample_aspect_ratio = + spriv->avstream->sample_aspect_ratio = av_d2q(stream->aspect * ctx->height / ctx->width, 255); +@@ -319,9 +317,10 @@ + } + + static void list_formats(void) { +- AVOutputFormat *fmt; ++ void *i = NULL; ++ const AVOutputFormat *fmt; + mp_msg(MSGT_DEMUX, MSGL_INFO, "Available lavf output formats:\n"); +- for (fmt = av_oformat_next(NULL); fmt; fmt = av_oformat_next(fmt)) ++ while ((fmt = av_muxer_iterate(&i))) + mp_msg(MSGT_DEMUX, MSGL_INFO, "%15s : %s\n", fmt->name, fmt->long_name); + } + +@@ -368,7 +367,7 @@ + const char *src = out_filename; + if (!strncmp(out_filename, "ffmpeg://dummy://", 17)) src += 17; + else if (!strncmp(out_filename, "ffmpeg://", 9)) src += 9; +- av_strlcpy(priv->oc->filename, src, sizeof(priv->oc->filename)); ++ priv->oc->url = av_strdup(src); + } + priv->oc->oformat = fmt; + diff -Nru mplayer-1.4+ds1/debian/patches/r38310.patch mplayer-1.4+ds1/debian/patches/r38310.patch --- mplayer-1.4+ds1/debian/patches/r38310.patch 1970-01-01 01:00:00.000000000 +0100 +++ mplayer-1.4+ds1/debian/patches/r38310.patch 2022-08-19 17:05:13.000000000 +0200 @@ -0,0 +1,153 @@ +Description: libmpcodecs/ve_lavc: Don't set options via deprecated AVCodecContext fields + Those fields were removed in libavcodec major 59. + + Some options won't work for some codecs anymore. Probably they + didn't work before too but were simply ignored. We can't keep + passing all options in all cases, because some encoders don't + support them and if they were passed in as dict paramters, we + will fail if they weren't accepted. + + For a few options the default was changed, because their default + in libavcodec is different. Now the default can be different in + every encoder, because that is how codec private options work + in libavcodec. + + These defaults were changed: + -static int lavc_param_prediction_method= FF_PRED_LEFT; + +static int lavc_param_prediction_method= 0; // method left (for some encoders) + -static int lavc_param_pre_me= 1; + +static int lavc_param_pre_me= 0; + -static int lavc_param_skip_cmp=0; + +static int lavc_param_skip_cmp = FF_CMP_DCTMAX; +Origin: upstream, commit: r38310 +Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1004579 +Forwarded: no +Last-Update: 2022-08-19 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +Index: b/libmpcodecs/ve_lavc.c +=================================================================== +--- a/libmpcodecs/ve_lavc.c 2022-08-19 16:52:04.159664634 +0200 ++++ b/libmpcodecs/ve_lavc.c 2022-08-19 16:52:28.000000000 +0200 +@@ -99,7 +99,7 @@ + static float lavc_param_spatial_cplx_masking= 0.0; + static float lavc_param_p_masking= 0.0; + static int lavc_param_interlaced_dct= 0; +-static int lavc_param_prediction_method= FF_PRED_LEFT; ++static int lavc_param_prediction_method= 0; // method left (for some encoders) + static int lavc_param_format= IMGFMT_YV12; + static int lavc_param_debug= 0; + static int lavc_param_psnr= 0; +@@ -122,7 +122,7 @@ + static int lavc_param_obmc= 0; + static int lavc_param_loop= 0; + static int lavc_param_last_pred= 0; +-static int lavc_param_pre_me= 1; ++static int lavc_param_pre_me= 0; + static int lavc_param_me_subpel_quality= 8; + static int lavc_param_me_range= 0; + static int lavc_param_coder= 0; +@@ -144,7 +144,7 @@ + static int lavc_param_skip_threshold=0; + static int lavc_param_skip_factor=0; + static int lavc_param_skip_exp=0; +-static int lavc_param_skip_cmp=0; ++static int lavc_param_skip_cmp = FF_CMP_DCTMAX; + static int lavc_param_brd_scale = 0; + static int lavc_param_bidir_refine = 0; + static int lavc_param_video_global_header= 0; +@@ -344,9 +344,11 @@ + lavc_venc_context->qblur= lavc_param_vqblur; + lavc_venc_context->max_b_frames= lavc_param_vmax_b_frames; + lavc_venc_context->b_quant_factor= lavc_param_vb_qfactor; +- lavc_venc_context->b_frame_strategy= lavc_param_vb_strategy; ++ if (lavc_param_vb_strategy) ++ av_dict_set_int(&opts, "b_strategy", lavc_param_vb_strategy, 0); + lavc_venc_context->b_quant_offset= (int)(FF_QP2LAMBDA * lavc_param_vb_qoffset + 0.5); +- lavc_venc_context->rtp_payload_size= lavc_param_packet_size; ++ if (lavc_param_packet_size) ++ av_dict_set_int(&opts, "ps", lavc_param_packet_size, 0); + lavc_venc_context->strict_std_compliance= lavc_param_strict; + lavc_venc_context->i_quant_factor= lavc_param_vi_qfactor; + lavc_venc_context->i_quant_offset= (int)(FF_QP2LAMBDA * lavc_param_vi_qoffset + 0.5); +@@ -363,20 +365,29 @@ + lavc_param_rc_initial_buffer_occupancy; + lavc_venc_context->debug= lavc_param_debug; + lavc_venc_context->last_predictor_count= lavc_param_last_pred; +- lavc_venc_context->pre_me= lavc_param_pre_me; ++ if (lavc_param_pre_me) ++ av_dict_set_int(&opts, "mepre", lavc_param_pre_me, 0); + lavc_venc_context->me_pre_cmp= lavc_param_me_pre_cmp; + lavc_venc_context->pre_dia_size= lavc_param_pre_dia_size; + lavc_venc_context->me_subpel_quality= lavc_param_me_subpel_quality; + lavc_venc_context->me_range= lavc_param_me_range; +- lavc_venc_context->coder_type= lavc_param_coder; +- lavc_venc_context->context_model= lavc_param_context; +- lavc_venc_context->scenechange_threshold= lavc_param_sc_threshold; +- lavc_venc_context->noise_reduction= lavc_param_noise_reduction; ++ if (lavc_param_coder) ++ av_dict_set_int(&opts, "coder", lavc_param_coder, 0); ++ if (lavc_param_context) ++ av_dict_set_int(&opts, "context", lavc_param_context, 0); ++ if (lavc_param_sc_threshold) ++ av_dict_set_int(&opts, "sc_threshold", lavc_param_sc_threshold, 0); ++ if (lavc_param_noise_reduction) ++ av_dict_set_int(&opts, "noise_reduction", lavc_param_noise_reduction, 0); + lavc_venc_context->nsse_weight= lavc_param_nssew; +- lavc_venc_context->frame_skip_threshold= lavc_param_skip_threshold; +- lavc_venc_context->frame_skip_factor= lavc_param_skip_factor; +- lavc_venc_context->frame_skip_exp= lavc_param_skip_exp; +- lavc_venc_context->frame_skip_cmp= lavc_param_skip_cmp; ++ if (lavc_param_skip_threshold) ++ av_dict_set_int(&opts, "skip_threshold", lavc_param_skip_threshold, 0); ++ if (lavc_param_skip_factor) ++ av_dict_set_int(&opts, "skip_factor", lavc_param_skip_factor, 0); ++ if (lavc_param_skip_exp) ++ av_dict_set_int(&opts, "skip_exp", lavc_param_skip_exp, 0); ++ if (lavc_param_skip_cmp != FF_CMP_DCTMAX) ++ av_dict_set_int(&opts, "skip_cmp", lavc_param_skip_cmp, 0); + + if (lavc_param_intra_matrix) + { +@@ -444,7 +455,8 @@ + } + lavc_venc_context->rc_override_count=i; + +- lavc_venc_context->mpeg_quant=lavc_param_mpeg_quant; ++ if (lavc_param_mpeg_quant) ++ av_dict_set_int(&opts, "mpeg_quant", lavc_param_mpeg_quant, 0); + + lavc_venc_context->dct_algo= lavc_param_fdct; + lavc_venc_context->idct_algo= lavc_param_idct; +@@ -534,8 +546,10 @@ + if(lavc_param_interlaced_dct) lavc_venc_context->flags|= AV_CODEC_FLAG_INTERLACED_DCT; + lavc_venc_context->flags|= lavc_param_psnr; + lavc_venc_context->intra_dc_precision = lavc_param_dc_precision - 8; +- lavc_venc_context->prediction_method= lavc_param_prediction_method; +- lavc_venc_context->brd_scale = lavc_param_brd_scale; ++ if (lavc_param_prediction_method) ++ av_dict_set_int(&opts, "pred", lavc_param_prediction_method, 0); ++ if (lavc_param_brd_scale) ++ av_dict_set_int(&opts, "brd_scale", lavc_param_brd_scale, 0); + lavc_venc_context->bidir_refine = lavc_param_bidir_refine; + if((lavc_param_video_global_header&1) + /*|| (video_global_header==0 && (oc->oformat->flags & AVFMT_GLOBALHEADER))*/){ +@@ -546,7 +560,8 @@ + } + lavc_venc_context->mv0_threshold = lavc_param_mv0_threshold; + lavc_venc_context->refs = lavc_param_refs; +- lavc_venc_context->b_sensitivity = lavc_param_b_sensitivity; ++ if (lavc_param_b_sensitivity != 40) ++ av_dict_set_int(&opts, "b_sensitivity", lavc_param_b_sensitivity, 0); + lavc_venc_context->level = lavc_param_level; + + if(lavc_param_avopt){ +@@ -611,7 +626,7 @@ + lavc_venc_context->pre_dia_size = 0; + lavc_venc_context->dia_size = 1; + +- lavc_venc_context->noise_reduction = 0; // nr=0 ++ av_dict_set(&opts, "noise_reduction", "0", 0); // nr=0 + lavc_venc_context->mb_decision = 0; // mbd=0 ("realtime" encoding) + + lavc_venc_context->flags &= ~AV_CODEC_FLAG_QPEL; diff -Nru mplayer-1.4+ds1/debian/patches/r38311.patch mplayer-1.4+ds1/debian/patches/r38311.patch --- mplayer-1.4+ds1/debian/patches/r38311.patch 1970-01-01 01:00:00.000000000 +0100 +++ mplayer-1.4+ds1/debian/patches/r38311.patch 2022-08-19 17:03:09.000000000 +0200 @@ -0,0 +1,95 @@ +Description: libmpcodecs/ve_lavc: Use side data to implement subopt psnr + Previously coded_frame from AVCodecContext was used, but that got + removed in libavcodec major 59. +Origin: upstream, commit: r38311 +Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1004579 +Forwarded: no +Last-Update: 2022-08-19 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +Index: b/libmpcodecs/ve_lavc.c +=================================================================== +--- a/libmpcodecs/ve_lavc.c 2022-08-19 16:52:04.187664419 +0200 ++++ b/libmpcodecs/ve_lavc.c 2022-08-19 16:52:24.000000000 +0200 +@@ -32,6 +32,7 @@ + #endif + + #include "config.h" ++#include "libavutil/intreadwrite.h" + #include "mencoder.h" + #include "mp_msg.h" + #include "help_mp.h" +@@ -295,6 +296,7 @@ + muxer_stream_t* mux; + AVCodecContext *context; + AVFrame *pic; ++ int coded_picture_number; + AVCodec *codec; + FILE *stats_file; + }; +@@ -785,7 +787,7 @@ + char filename[20]; + double f= lavc_venc_context->width*lavc_venc_context->height*255.0*255.0; + double quality=0.0; +- int8_t *q; ++ uint8_t *sd = av_packet_get_side_data(&pkt, AV_PKT_DATA_QUALITY_STATS, NULL); + + if(!fvstats) { + time_t today2; +@@ -804,32 +806,27 @@ + } + } + +- // average MB quantizer +- q = lavc_venc_context->coded_frame->qscale_table; +- if(q) { +- int x, y; +- int w = (lavc_venc_context->width+15) >> 4; +- int h = (lavc_venc_context->height+15) >> 4; +- for( y = 0; y < h; y++ ) { +- for( x = 0; x < w; x++ ) +- quality += (double)*(q+x); +- q += lavc_venc_context->coded_frame->qstride; +- } +- quality /= w * h; +- } else +- quality = lavc_venc_context->coded_frame->quality / (float)FF_QP2LAMBDA; ++ if(sd && sd[5] >= 3) { ++ uint8_t pict_type = sd[4] * (sd[4] < FF_ARRAY_ELEMS(pict_type_char)); ++ uint64_t error[3] = { ++ AV_RL64(sd + 8), AV_RL64(sd + 16), AV_RL64(sd + 24) ++ }; ++ quality = AV_RL32(sd) / (float)FF_QP2LAMBDA; + + fprintf(fvstats, "%6d, %2.2f, %6d, %2.2f, %2.2f, %2.2f, %2.2f %c\n", +- lavc_venc_context->coded_frame->coded_picture_number, ++ vf->priv->coded_picture_number, + quality, + pkt.size, +- psnr(lavc_venc_context->coded_frame->error[0]/f), +- psnr(lavc_venc_context->coded_frame->error[1]*4/f), +- psnr(lavc_venc_context->coded_frame->error[2]*4/f), +- psnr((lavc_venc_context->coded_frame->error[0]+lavc_venc_context->coded_frame->error[1]+lavc_venc_context->coded_frame->error[2])/(f*1.5)), +- pict_type_char[lavc_venc_context->coded_frame->pict_type] ++ psnr(error[0]/f), ++ psnr(error[1]*4/f), ++ psnr(error[2]*4/f), ++ psnr((error[0]+error[1]+error[2])/(f*1.5)), ++ pict_type_char[pict_type] + ); ++ } + } ++ vf->priv->coded_picture_number++; ++ ++vf->priv->coded_picture_number; + res = pkt.size; + av_packet_unref(&pkt); + return res; +@@ -839,7 +836,7 @@ + + if(lavc_param_psnr){ + double f= lavc_venc_context->width*lavc_venc_context->height*255.0*255.0; +- f*= lavc_venc_context->coded_frame->coded_picture_number; ++ f*= vf->priv->coded_picture_number; + + mp_msg(MSGT_MENCODER, MSGL_INFO, "PSNR: Y:%2.2f, Cb:%2.2f, Cr:%2.2f, All:%2.2f\n", + psnr(lavc_venc_context->error[0]/f), diff -Nru mplayer-1.4+ds1/debian/patches/r38312.patch mplayer-1.4+ds1/debian/patches/r38312.patch --- mplayer-1.4+ds1/debian/patches/r38312.patch 1970-01-01 01:00:00.000000000 +0100 +++ mplayer-1.4+ds1/debian/patches/r38312.patch 2022-08-19 17:02:23.000000000 +0200 @@ -0,0 +1,129 @@ +Description: libmpcodecs/ve_lavc: Port to avcodec_send_frame/avcodec_receive_packet + Previously avcodec_encode_video2 used, but that got removed + in libavcodec major 59. +Origin: upstream, commit: r38312 +Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1004579 +Forwarded: no +Last-Update: 2022-08-19 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +Index: b/libmpcodecs/ve_lavc.c +=================================================================== +--- a/libmpcodecs/ve_lavc.c 2022-08-19 16:52:04.215664203 +0200 ++++ b/libmpcodecs/ve_lavc.c 2022-08-19 16:52:04.211664234 +0200 +@@ -297,7 +297,8 @@ + AVCodecContext *context; + AVFrame *pic; + int coded_picture_number; +- AVCodec *codec; ++ const AVCodec *codec; ++ AVPacket *pkt; + FILE *stats_file; + }; + +@@ -736,8 +737,8 @@ + static int encode_frame(struct vf_instance *vf, AVFrame *pic, double pts){ + const char pict_type_char[5]= {'?', 'I', 'P', 'B', 'S'}; + double dts; +- AVPacket pkt; +- int res, got_pkt; ++ AVPacket *pkt= vf->priv->pkt; ++ int res; + + if(pts == MP_NOPTS_VALUE) + pts= lavc_venc_context->frame_number * av_q2d(lavc_venc_context->time_base); +@@ -753,10 +754,12 @@ + pic->pts= MP_NOPTS_VALUE; + #endif + } +- av_init_packet(&pkt); +- pkt.data = mux_v->buffer; +- pkt.size = mux_v->buffer_size; +- res = avcodec_encode_video2(lavc_venc_context, &pkt, pic, &got_pkt); ++ res = avcodec_send_frame(lavc_venc_context, pic); ++ if (res < 0 && res != AVERROR(EAGAIN) && res != AVERROR_EOF) ++ return res; ++ res = avcodec_receive_packet(lavc_venc_context, pkt); ++ if (res < 0 && res != AVERROR(EAGAIN)) ++ return res == AVERROR_EOF ? 0 : res; + + /* store stats if there are any */ + if(lavc_venc_context->stats_out && stats_file) { +@@ -765,20 +768,20 @@ + lavc_venc_context->stats_out[0] = 0; + } + +- if (res < 0) +- return 0; +- if(!got_pkt && lavc_param_skip_threshold==0 && lavc_param_skip_factor==0){ ++ if(res == AVERROR(EAGAIN) && lavc_param_skip_threshold==0 && lavc_param_skip_factor==0){ + ++mux_v->encoder_delay; + return 0; + } + + dts = pts = MP_NOPTS_VALUE; +- if (pkt.pts != AV_NOPTS_VALUE) +- pts = pkt.pts * av_q2d(lavc_venc_context->time_base); +- if (pkt.dts != AV_NOPTS_VALUE) +- dts = pkt.dts * av_q2d(lavc_venc_context->time_base); +- +- muxer_write_chunk(mux_v,pkt.size,pkt.flags & AV_PKT_FLAG_KEY ?0x10:0, ++ if (pkt->pts != AV_NOPTS_VALUE) ++ pts = pkt->pts * av_q2d(lavc_venc_context->time_base); ++ if (pkt->dts != AV_NOPTS_VALUE) ++ dts = pkt->dts * av_q2d(lavc_venc_context->time_base); ++ ++ mux_v->buffer = pkt->data; // use ref-counted packet ++ mux_v->buffer_size = pkt->size; // update size for consistency ++ muxer_write_chunk(mux_v,pkt->size,pkt->flags & AV_PKT_FLAG_KEY ?0x10:0, + dts, pts); + + /* store psnr / pict size / type / qscale */ +@@ -787,7 +790,7 @@ + char filename[20]; + double f= lavc_venc_context->width*lavc_venc_context->height*255.0*255.0; + double quality=0.0; +- uint8_t *sd = av_packet_get_side_data(&pkt, AV_PKT_DATA_QUALITY_STATS, NULL); ++ uint8_t *sd = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, NULL); + + if(!fvstats) { + time_t today2; +@@ -816,7 +819,7 @@ + fprintf(fvstats, "%6d, %2.2f, %6d, %2.2f, %2.2f, %2.2f, %2.2f %c\n", + vf->priv->coded_picture_number, + quality, +- pkt.size, ++ pkt->size, + psnr(error[0]/f), + psnr(error[1]*4/f), + psnr(error[2]*4/f), +@@ -825,10 +828,9 @@ + ); + } + } +- vf->priv->coded_picture_number++; + ++vf->priv->coded_picture_number; +- res = pkt.size; +- av_packet_unref(&pkt); ++ res = pkt->size; ++ av_packet_unref(pkt); + return res; + } + +@@ -846,6 +848,8 @@ + ); + } + ++ av_packet_free(&vf->priv->pkt); ++ + av_freep(&lavc_venc_context->intra_matrix); + av_freep(&lavc_venc_context->inter_matrix); + +@@ -977,6 +981,7 @@ + return 0; + } + ++ vf->priv->pkt = av_packet_alloc(); + vf->priv->pic = av_frame_alloc(); + vf->priv->context = avcodec_alloc_context3(vf->priv->codec); + vf->priv->context->codec_id = vf->priv->codec->id; diff -Nru mplayer-1.4+ds1/debian/patches/r38361.patch mplayer-1.4+ds1/debian/patches/r38361.patch --- mplayer-1.4+ds1/debian/patches/r38361.patch 1970-01-01 01:00:00.000000000 +0100 +++ mplayer-1.4+ds1/debian/patches/r38361.patch 2022-08-19 17:01:04.000000000 +0200 @@ -0,0 +1,62 @@ +Description: configure, av_helpers.c: Fix compilation against latest FFmpeg. +Origin: upstream, commit: r38361 +Bug: +Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1004579 +Forwarded: no +Last-Update: 2022-08-19 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +Index: b/av_helpers.c +=================================================================== +--- a/av_helpers.c 2022-08-19 16:52:04.247663957 +0200 ++++ b/av_helpers.c 2022-08-19 16:52:04.239664018 +0200 +@@ -51,11 +51,9 @@ + AVCodecContext *s= ptr; + if(s->codec){ + if(s->codec->type == AVMEDIA_TYPE_AUDIO){ +- if(s->codec->decode) +- type= MSGT_DECAUDIO; ++ type= MSGT_DECAUDIO; + }else if(s->codec->type == AVMEDIA_TYPE_VIDEO){ +- if(s->codec->decode) +- type= MSGT_DECVIDEO; ++ type= MSGT_DECVIDEO; + } + //FIXME subtitles, encoders (what msgt for them? there is no appropriate ...) + } +Index: b/configure +=================================================================== +--- a/configure 2022-08-19 16:52:04.247663957 +0200 ++++ b/configure 2022-08-19 16:52:04.243663987 +0200 +@@ -1553,8 +1553,8 @@ + } + + echocheck "ffmpeg/libavcodec/allcodecs.c" +-libavdecoders_all=$(list_subparts_extern AVCodec decoder codec/allcodecs.c) +-libavencoders_all=$(list_subparts_extern AVCodec encoder codec/allcodecs.c) ++libavdecoders_all=$(list_subparts_extern FFCodec decoder codec/allcodecs.c) ++libavencoders_all=$(list_subparts_extern FFCodec encoder codec/allcodecs.c) + libavparsers_all=$(list_subparts_extern AVCodecParser parser codec/parsers.c) + test $? -eq 0 && _list_subparts=found || _list_subparts="not found" + echores "$_list_subparts" +@@ -1572,7 +1572,7 @@ + echores "$_list_subparts" + + echocheck "ffmpeg/libavcodec/bitsteram_filters.c" +-libavbsfs_all=$(list_subparts_extern AVBitStreamFilter bsf codec/bitstream_filters.c) ++libavbsfs_all=$(list_subparts_extern FFBitStreamFilter bsf codec/bitstream_filters.c) + test $? -eq 0 && _list_subparts_extern=found || _list_subparts_extern="not found" + echores "$_list_subparts_extern" + +@@ -9527,9 +9527,9 @@ + cp $TMPH ffmpeg/$file + } + +-print_enabled_components libavcodec/codec_list.c AVCodec codec_list $libavdecoders $libavencoders ++print_enabled_components libavcodec/codec_list.c FFCodec codec_list $libavdecoders $libavencoders + print_enabled_components libavcodec/parser_list.c AVCodecParser parser_list $libavparsers +-print_enabled_components libavcodec/bsf_list.c AVBitStreamFilter bitstream_filters $libavbsfs ++print_enabled_components libavcodec/bsf_list.c FFBitStreamFilter bitstream_filters $libavbsfs + print_enabled_components libavdevice/indev_list.c AVInputFormat indev_list "" + print_enabled_components libavdevice/outdev_list.c AVOutputFormat outdev_list "" + print_enabled_components libavformat/demuxer_list.c AVInputFormat demuxer_list $libavdemuxers diff -Nru mplayer-1.4+ds1/debian/patches/series mplayer-1.4+ds1/debian/patches/series --- mplayer-1.4+ds1/debian/patches/series 2021-09-09 23:05:55.000000000 +0200 +++ mplayer-1.4+ds1/debian/patches/series 2022-08-19 17:11:49.000000000 +0200 @@ -5,3 +5,15 @@ 0202_glibc-2.27.patch 0203_generic-arch-fallback.patch 0007-ad_spdif-Use-avformat_free_context-to-free-context.patch +r38215.patch +r38216.patch +r38217.patch +r38219.patch +r38246.patch +r38306.patch +r38307.patch +r38309.patch +r38310.patch +r38311.patch +r38312.patch +r38361.patch