Skip to content

Commit

Permalink
command: remove deprecated packet-*-bitrate properties
Browse files Browse the repository at this point in the history
These have been deprecated for 9 years so it's fine to remove them.

Using the replacement properties like video-bitrate in stats.lua will
convert big enough bitrates to Mbps.
  • Loading branch information
guidocella committed Jun 28, 2024
1 parent eb0af02 commit 21a87ef
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 25 deletions.
1 change: 1 addition & 0 deletions DOCS/interface-changes/packet-bitrate.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
remove deprecated `packet-video-bitrate` `packet-audio-bitrate` and `packet-sub-bitrate` properties
8 changes: 0 additions & 8 deletions DOCS/man/input.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3479,14 +3479,6 @@ Property list
In earlier versions of mpv, these properties returned a static (but bad)
guess using a completely different method.

``packet-video-bitrate``, ``packet-audio-bitrate``, ``packet-sub-bitrate``
Old and deprecated properties for ``video-bitrate``, ``audio-bitrate``,
``sub-bitrate``. They behave exactly the same, but return a value in
kilobits. Also, they don't have any OSD formatting, though the same can be
achieved with e.g. ``${=video-bitrate}``.

These properties shouldn't be used anymore.

``audio-device-list``
The list of discovered audio devices. This is mostly for use with the
client API, and reflects what ``--audio-device=help`` with the command line
Expand Down
19 changes: 4 additions & 15 deletions player/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -3340,8 +3340,7 @@ static int mp_property_packet_bitrate(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
int type = (uintptr_t)prop->priv & ~0x100;
bool old = (uintptr_t)prop->priv & 0x100;
int type = *(int *)prop->priv;

struct demuxer *demuxer = NULL;
if (mpctx->current_track[0][type])
Expand All @@ -3359,10 +3358,6 @@ static int mp_property_packet_bitrate(void *ctx, struct m_property *prop,
// r[type] is in bytes/second -> bits
double rate = r[type] * 8;

// Same story, but used kilobits for some reason.
if (old)
return m_property_int64_ro(action, arg, llrint(rate / 1000.0));

if (action == M_PROPERTY_PRINT) {
rate /= 1000;
if (rate < 1000) {
Expand Down Expand Up @@ -4133,15 +4128,9 @@ static const struct m_property mp_properties_base[] = {
{"ab-loop-a", mp_property_ab_loop},
{"ab-loop-b", mp_property_ab_loop},

#define PROPERTY_BITRATE(name, old, type) \
{name, mp_property_packet_bitrate, (void *)(uintptr_t)((type)|(old?0x100:0))}
PROPERTY_BITRATE("packet-video-bitrate", true, STREAM_VIDEO),
PROPERTY_BITRATE("packet-audio-bitrate", true, STREAM_AUDIO),
PROPERTY_BITRATE("packet-sub-bitrate", true, STREAM_SUB),

PROPERTY_BITRATE("video-bitrate", false, STREAM_VIDEO),
PROPERTY_BITRATE("audio-bitrate", false, STREAM_AUDIO),
PROPERTY_BITRATE("sub-bitrate", false, STREAM_SUB),
{"video-bitrate", mp_property_packet_bitrate, .priv = (void *)&(const int){STREAM_VIDEO}},
{"audio-bitrate", mp_property_packet_bitrate, .priv = (void *)&(const int){STREAM_AUDIO}},
{"sub-bitrate", mp_property_packet_bitrate, .priv = (void *)&(const int){STREAM_SUB}},

{"focused", mp_property_focused},
{"display-names", mp_property_display_names},
Expand Down
4 changes: 2 additions & 2 deletions player/lua/stats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ local function add_video(s)
end
append_img_params(s, r, ro)
append_hdr(s, ro)
append_property(s, "packet-video-bitrate", {prefix="Bitrate:", suffix=" kbps"})
append_property(s, "video-bitrate", {prefix="Bitrate:"})
append_filters(s, "vf", "Filters:")
end

Expand Down Expand Up @@ -1038,7 +1038,7 @@ local function add_audio(s)
append(s, merge(r, ro, "format"), {prefix="Format:", nl=cc and "" or o.nl,
indent=cc and o.prefix_sep .. o.prefix_sep})
append(s, merge(r, ro, "samplerate"), {prefix="Sample Rate:", suffix=" Hz"})
append_property(s, "packet-audio-bitrate", {prefix="Bitrate:", suffix=" kbps"})
append_property(s, "audio-bitrate", {prefix="Bitrate:"})
append_filters(s, "af", "Filters:")
end

Expand Down

0 comments on commit 21a87ef

Please sign in to comment.