1
mirror of https://github.com/mpv-player/mpv synced 2024-10-02 16:25:33 +02:00

mp_image: introduce a hw_subfmt field

For hwaccel formats, mp_image will merely point to a hardware surface
handle. In these cases, the mp_image_params.imgfmt field describes the
format insufficiently, because it mostly only describes the type of the
hardware format, not its underlying format.

Introduce hw_subfmt to describe the underlying format. It makes sense to
use it with most hwaccels, though for now it will be used with the
following commit only.
This commit is contained in:
wm4 2016-04-07 18:46:43 +02:00
parent 8a67606c20
commit f34d086cb9
2 changed files with 8 additions and 0 deletions

View File

@ -507,6 +507,8 @@ char *mp_image_params_to_str_buf(char *b, size_t bs,
if (p->p_w != p->p_h || !p->p_w)
mp_snprintf_cat(b, bs, " [%d:%d]", p->p_w, p->p_h);
mp_snprintf_cat(b, bs, " %s", mp_imgfmt_to_name(p->imgfmt));
if (p->hw_subfmt)
mp_snprintf_cat(b, bs, "[%llu]", (unsigned long long)(p->hw_subfmt));
mp_snprintf_cat(b, bs, " %s/%s",
m_opt_choice_str(mp_csp_names, p->colorspace),
m_opt_choice_str(mp_csp_levels_names, p->colorlevels));
@ -547,6 +549,9 @@ bool mp_image_params_valid(const struct mp_image_params *p)
if (!desc.id)
return false;
if (p->hw_subfmt && !(desc.flags & MP_IMGFLAG_HWACCEL))
return false;
return true;
}
@ -554,6 +559,7 @@ bool mp_image_params_equal(const struct mp_image_params *p1,
const struct mp_image_params *p2)
{
return p1->imgfmt == p2->imgfmt &&
p1->hw_subfmt == p2->hw_subfmt &&
p1->w == p2->w && p1->h == p2->h &&
p1->p_w == p2->p_w && p1->p_h == p2->p_h &&
p1->colorspace == p2->colorspace &&

View File

@ -39,6 +39,8 @@
// usually copy the whole struct, so that fields added later will be preserved.
struct mp_image_params {
enum mp_imgfmt imgfmt; // pixel format
uint64_t hw_subfmt; // underlying format for some hwaccel pixfmts
// (will use the HW API's format identifiers)
int w, h; // image dimensions
int p_w, p_h; // define pixel aspect ratio (never 0/0)
enum mp_csp colorspace;