video, demux: rip out unused spherical metadata code

This was preparation into something that never happened.

Spherical video is a shit idea anyway.
This commit is contained in:
wm4 2019-10-17 22:49:26 +02:00
parent c75e0320f6
commit 60ab82df32
8 changed files with 1 additions and 132 deletions

View File

@ -274,17 +274,6 @@ Available mpv-only filters are:
but values such as ``[16:9]`` can be passed too (``[...]`` for quoting but values such as ``[16:9]`` can be passed too (``[...]`` for quoting
to prevent the option parser from interpreting the ``:`` character). to prevent the option parser from interpreting the ``:`` character).
``<spherical-type>``
Type of the spherical projection:
:auto: As indicated by the file (default)
:none: Normal video
:equirect: Equirectangular
:unknown: Unknown projection
``<spherical-yaw>``, ``<spherical-pitch>``, ``<spherical-roll>``
Reference angle in degree, if spherical video is used.
``lavfi=graph[:sws-flags[:o=opts]]`` ``lavfi=graph[:sws-flags[:o=opts]]``
Filter video using FFmpeg's libavfilter. Filter video using FFmpeg's libavfilter.

View File

@ -33,7 +33,6 @@
#include <libavutil/avstring.h> #include <libavutil/avstring.h>
#include <libavutil/mathematics.h> #include <libavutil/mathematics.h>
#include <libavutil/replaygain.h> #include <libavutil/replaygain.h>
#include <libavutil/spherical.h>
#include <libavutil/display.h> #include <libavutil/display.h>
#include <libavutil/opt.h> #include <libavutil/opt.h>
@ -702,17 +701,6 @@ static void handle_new_stream(demuxer_t *demuxer, int i)
sh->codec->rotate = (((int)(-r) % 360) + 360) % 360; sh->codec->rotate = (((int)(-r) % 360) + 360) % 360;
} }
sd = av_stream_get_side_data(st, AV_PKT_DATA_SPHERICAL, NULL);
if (sd) {
AVSphericalMapping *sp = (void *)sd;
struct mp_spherical_params *mpsp = &sh->codec->spherical;
mpsp->type = sp->projection == AV_SPHERICAL_EQUIRECTANGULAR ?
MP_SPHERICAL_EQUIRECTANGULAR : MP_SPHERICAL_UNKNOWN;
mpsp->ref_angles[0] = sp->yaw / (float)(1 << 16);
mpsp->ref_angles[1] = sp->pitch / (float)(1 << 16);
mpsp->ref_angles[2] = sp->roll / (float)(1 << 16);
}
// This also applies to vfw-muxed mkv, but we can't detect these easily. // This also applies to vfw-muxed mkv, but we can't detect these easily.
sh->codec->avi_dts = matches_avinputformat_name(priv, "avi"); sh->codec->avi_dts = matches_avinputformat_name(priv, "avi");

View File

@ -107,7 +107,6 @@ typedef struct mkv_track {
uint32_t colorspace; uint32_t colorspace;
int stereo_mode; int stereo_mode;
struct mp_colorspace color; struct mp_colorspace color;
struct mp_spherical_params spherical;
uint32_t a_channels, a_bps; uint32_t a_channels, a_bps;
float a_sfreq; float a_sfreq;
@ -603,49 +602,6 @@ static void parse_trackcolour(struct demuxer *demuxer, struct mkv_track *track,
} }
} }
static void parse_trackprojection(struct demuxer *demuxer, struct mkv_track *track,
struct ebml_projection *projection)
{
if (projection->n_projection_type) {
const char *name;
switch (projection->projection_type) {
case 0:
name = "rectangular";
track->spherical.type = MP_SPHERICAL_NONE;
break;
case 1:
name = "equirectangular";
track->spherical.type = MP_SPHERICAL_EQUIRECTANGULAR;
break;
default:
name = "unknown";
track->spherical.type = MP_SPHERICAL_UNKNOWN;
}
MP_VERBOSE(demuxer, "| + ProjectionType: %s (%"PRIu64")\n", name,
projection->projection_type);
}
if (projection->n_projection_private) {
MP_VERBOSE(demuxer, "| + ProjectionPrivate: %zd bytes\n",
projection->projection_private.len);
MP_WARN(demuxer, "Unknown ProjectionPrivate element.\n");
}
if (projection->n_projection_pose_yaw) {
track->spherical.ref_angles[0] = projection->projection_pose_yaw;
MP_VERBOSE(demuxer, "| + ProjectionPoseYaw: %f\n",
projection->projection_pose_yaw);
}
if (projection->n_projection_pose_pitch) {
track->spherical.ref_angles[1] = projection->projection_pose_pitch;
MP_VERBOSE(demuxer, "| + ProjectionPosePitch: %f\n",
projection->projection_pose_pitch);
}
if (projection->n_projection_pose_roll) {
track->spherical.ref_angles[2] = projection->projection_pose_roll;
MP_VERBOSE(demuxer, "| + ProjectionPoseRoll: %f\n",
projection->projection_pose_roll);
}
}
static void parse_trackvideo(struct demuxer *demuxer, struct mkv_track *track, static void parse_trackvideo(struct demuxer *demuxer, struct mkv_track *track,
struct ebml_video *video) struct ebml_video *video)
{ {
@ -690,8 +646,6 @@ static void parse_trackvideo(struct demuxer *demuxer, struct mkv_track *track,
} }
if (video->n_colour) if (video->n_colour)
parse_trackcolour(demuxer, track, &video->colour); parse_trackcolour(demuxer, track, &video->colour);
if (video->n_projection)
parse_trackprojection(demuxer, track, &video->projection);
} }
/** /**
@ -1516,7 +1470,6 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track)
sh_v->stereo_mode = track->stereo_mode; sh_v->stereo_mode = track->stereo_mode;
sh_v->color = track->color; sh_v->color = track->color;
sh_v->spherical = track->spherical;
done: done:
demux_add_sh_stream(demuxer, sh); demux_add_sh_stream(demuxer, sh);

View File

@ -104,7 +104,6 @@ struct mp_codec_params {
int rotate; // intended display rotation, in degrees, [0, 359] int rotate; // intended display rotation, in degrees, [0, 359]
int stereo_mode; // mp_stereo3d_mode (0 if none/unknown) int stereo_mode; // mp_stereo3d_mode (0 if none/unknown)
struct mp_colorspace color; // colorspace info where available struct mp_colorspace color; // colorspace info where available
struct mp_spherical_params spherical;
// STREAM_VIDEO + STREAM_AUDIO // STREAM_VIDEO + STREAM_AUDIO
int bits_per_coded_sample; int bits_per_coded_sample;

View File

@ -312,10 +312,6 @@ static void fix_image_params(struct priv *p,
m.color.sig_peak = 0.0; m.color.sig_peak = 0.0;
} }
m.spherical = c->spherical;
if (m.spherical.type == MP_SPHERICAL_AUTO)
m.spherical.type = MP_SPHERICAL_NONE;
// Guess missing colorspace fields from metadata. This guarantees all // Guess missing colorspace fields from metadata. This guarantees all
// fields are at least set to legal values afterwards. // fields are at least set to legal values afterwards.
mp_image_params_guess_csp(&m); mp_image_params_guess_csp(&m);

View File

@ -53,8 +53,6 @@ struct vf_format_opts {
int rotate; int rotate;
int dw, dh; int dw, dh;
double dar; double dar;
int spherical;
float spherical_ref_angles[3];
}; };
static void vf_format_process(struct mp_filter *f) static void vf_format_process(struct mp_filter *f)
@ -121,13 +119,6 @@ static void vf_format_process(struct mp_filter *f)
dsize = av_d2q(p->dar, INT_MAX); dsize = av_d2q(p->dar, INT_MAX);
mp_image_params_set_dsize(out, dsize.num, dsize.den); mp_image_params_set_dsize(out, dsize.num, dsize.den);
if (p->spherical)
out->spherical.type = p->spherical;
for (int n = 0; n < 3; n++) {
if (isfinite(p->spherical_ref_angles[n]))
out->spherical.ref_angles[n] = p->spherical_ref_angles[n];
}
// Make sure the user-overrides are consistent (no RGB csp for YUV, etc.). // Make sure the user-overrides are consistent (no RGB csp for YUV, etc.).
mp_image_params_guess_csp(out); mp_image_params_guess_csp(out);
@ -184,10 +175,6 @@ static const m_option_t vf_opts_fields[] = {
OPT_INT("dw", dw, 0), OPT_INT("dw", dw, 0),
OPT_INT("dh", dh, 0), OPT_INT("dh", dh, 0),
OPT_DOUBLE("dar", dar, 0), OPT_DOUBLE("dar", dar, 0),
OPT_CHOICE_C("spherical", spherical, 0, mp_spherical_names),
OPT_FLOAT("spherical-yaw", spherical_ref_angles[0], 0),
OPT_FLOAT("spherical-pitch", spherical_ref_angles[1], 0),
OPT_FLOAT("spherical-roll", spherical_ref_angles[2], 0),
OPT_REMOVED("outputlevels", "use the --video-output-levels global option"), OPT_REMOVED("outputlevels", "use the --video-output-levels global option"),
OPT_REMOVED("peak", "use sig-peak instead (changed value scale!)"), OPT_REMOVED("peak", "use sig-peak instead (changed value scale!)"),
{0} {0}
@ -200,7 +187,6 @@ const struct mp_user_filter_entry vf_format = {
.priv_size = sizeof(OPT_BASE_STRUCT), .priv_size = sizeof(OPT_BASE_STRUCT),
.priv_defaults = &(const OPT_BASE_STRUCT){ .priv_defaults = &(const OPT_BASE_STRUCT){
.rotate = -1, .rotate = -1,
.spherical_ref_angles = {NAN, NAN, NAN},
}, },
.options = vf_opts_fields, .options = vf_opts_fields,
}, },

View File

@ -40,14 +40,6 @@
#include "sws_utils.h" #include "sws_utils.h"
#include "fmt-conversion.h" #include "fmt-conversion.h"
const struct m_opt_choice_alternatives mp_spherical_names[] = {
{"auto", MP_SPHERICAL_AUTO},
{"none", MP_SPHERICAL_NONE},
{"unknown", MP_SPHERICAL_UNKNOWN},
{"equirect", MP_SPHERICAL_EQUIRECTANGULAR},
{0}
};
// Determine strides, plane sizes, and total required size for an image // Determine strides, plane sizes, and total required size for an image
// allocation. Returns total size on success, <0 on error. Unused planes // allocation. Returns total size on success, <0 on error. Unused planes
// have out_stride/out_plane_size to 0, and out_plane_offset set to -1 up // have out_stride/out_plane_size to 0, and out_plane_offset set to -1 up
@ -522,7 +514,6 @@ void mp_image_copy_attributes(struct mp_image *dst, struct mp_image *src)
dst->params.p_h = src->params.p_h; dst->params.p_h = src->params.p_h;
dst->params.color = src->params.color; dst->params.color = src->params.color;
dst->params.chroma_location = src->params.chroma_location; dst->params.chroma_location = src->params.chroma_location;
dst->params.spherical = src->params.spherical;
dst->nominal_fps = src->nominal_fps; dst->nominal_fps = src->nominal_fps;
// ensure colorspace consistency // ensure colorspace consistency
if (mp_image_params_get_forced_csp(&dst->params) != if (mp_image_params_get_forced_csp(&dst->params) !=
@ -659,12 +650,6 @@ char *mp_image_params_to_str_buf(char *b, size_t bs,
mp_snprintf_cat(b, bs, " stereo=%s", mp_snprintf_cat(b, bs, " stereo=%s",
MP_STEREO3D_NAME_DEF(p->stereo3d, "?")); MP_STEREO3D_NAME_DEF(p->stereo3d, "?"));
} }
if (p->spherical.type != MP_SPHERICAL_NONE) {
const float *a = p->spherical.ref_angles;
mp_snprintf_cat(b, bs, " (%s %f/%f/%f)",
m_opt_choice_str(mp_spherical_names, p->spherical.type),
a[0], a[1], a[2]);
}
} else { } else {
snprintf(b, bs, "???"); snprintf(b, bs, "???");
} }
@ -699,16 +684,6 @@ bool mp_image_params_valid(const struct mp_image_params *p)
return true; return true;
} }
static bool mp_spherical_equal(const struct mp_spherical_params *p1,
const struct mp_spherical_params *p2)
{
for (int n = 0; n < 3; n++) {
if (p1->ref_angles[n] != p2->ref_angles[n])
return false;
}
return p1->type == p2->type;
}
bool mp_image_params_equal(const struct mp_image_params *p1, bool mp_image_params_equal(const struct mp_image_params *p1,
const struct mp_image_params *p2) const struct mp_image_params *p2)
{ {
@ -719,8 +694,7 @@ bool mp_image_params_equal(const struct mp_image_params *p1,
mp_colorspace_equal(p1->color, p2->color) && mp_colorspace_equal(p1->color, p2->color) &&
p1->chroma_location == p2->chroma_location && p1->chroma_location == p2->chroma_location &&
p1->rotate == p2->rotate && p1->rotate == p2->rotate &&
p1->stereo3d == p2->stereo3d && p1->stereo3d == p2->stereo3d;
mp_spherical_equal(&p1->spherical, &p2->spherical);
} }
// Set most image parameters, but not image format or size. // Set most image parameters, but not image format or size.
@ -894,7 +868,6 @@ struct mp_image *mp_image_from_av_frame(struct AVFrame *src)
struct mp_image_params *p = (void *)src->opaque_ref->data; struct mp_image_params *p = (void *)src->opaque_ref->data;
dst->params.rotate = p->rotate; dst->params.rotate = p->rotate;
dst->params.stereo3d = p->stereo3d; dst->params.stereo3d = p->stereo3d;
dst->params.spherical = p->spherical;
// Might be incorrect if colorspace changes. // Might be incorrect if colorspace changes.
dst->params.color.light = p->color.light; dst->params.color.light = p->color.light;
} }

View File

@ -38,20 +38,6 @@
#define MP_IMGFIELD_REPEAT_FIRST 0x04 #define MP_IMGFIELD_REPEAT_FIRST 0x04
#define MP_IMGFIELD_INTERLACED 0x20 #define MP_IMGFIELD_INTERLACED 0x20
enum mp_spherical_type {
MP_SPHERICAL_AUTO = 0,
MP_SPHERICAL_NONE, // normal video
MP_SPHERICAL_UNKNOWN, // unknown projection
MP_SPHERICAL_EQUIRECTANGULAR, // (untiled)
};
extern const struct m_opt_choice_alternatives mp_spherical_names[];
struct mp_spherical_params {
enum mp_spherical_type type;
float ref_angles[3]; // yaw/pitch/roll, refer to AVSphericalMapping
};
// Describes image parameters that usually stay constant. // Describes image parameters that usually stay constant.
// New fields can be added in the future. Code changing the parameters should // New fields can be added in the future. Code changing the parameters should
// usually copy the whole struct, so that fields added later will be preserved. // usually copy the whole struct, so that fields added later will be preserved.
@ -65,7 +51,6 @@ struct mp_image_params {
// The image should be rotated clockwise (0-359 degrees). // The image should be rotated clockwise (0-359 degrees).
int rotate; int rotate;
enum mp_stereo3d_mode stereo3d; // image is encoded with this mode enum mp_stereo3d_mode stereo3d; // image is encoded with this mode
struct mp_spherical_params spherical;
}; };
/* Memory management: /* Memory management: