sub: rename SUBBITMAP_RGBA to SUBBITMAP_BGRA

This was a misnomer, the actual channel order is IMGFMT_BGRA (as the
comment explicitly point out). Rename the enum for consistency.
This commit is contained in:
Niklas Haas 2022-01-11 21:03:27 +01:00 committed by Jan Ekström
parent 429402cb08
commit 9e2c0b8baa
10 changed files with 25 additions and 25 deletions

View File

@ -4188,7 +4188,7 @@ static void recreate_overlays(struct MPContext *mpctx)
struct command_ctx *cmd = mpctx->command_ctx;
int overlay_next = !cmd->overlay_osd_current;
struct sub_bitmaps *new = &cmd->overlay_osd[overlay_next];
new->format = SUBBITMAP_RGBA;
new->format = SUBBITMAP_BGRA;
new->change_id = 1;
bool valid = false;

View File

@ -285,7 +285,7 @@ static bool pack_rgba(struct mp_ass_packer *p, struct sub_bitmaps *res)
struct sub_bitmaps imgs = {
.change_id = res->change_id,
.format = SUBBITMAP_RGBA,
.format = SUBBITMAP_BGRA,
.parts = p->rgba_imgs,
.num_parts = num_bb,
};
@ -341,7 +341,7 @@ void mp_ass_packer_pack(struct mp_ass_packer *p, ASS_Image **image_lists,
int num_image_lists, bool image_lists_changed,
int preferred_osd_format, struct sub_bitmaps *out)
{
int format = preferred_osd_format == SUBBITMAP_RGBA ? SUBBITMAP_RGBA
int format = preferred_osd_format == SUBBITMAP_BGRA ? SUBBITMAP_BGRA
: SUBBITMAP_LIBASS;
if (p->cached_subs_valid && !image_lists_changed &&
@ -379,7 +379,7 @@ void mp_ass_packer_pack(struct mp_ass_packer *p, ASS_Image **image_lists,
}
bool r = false;
if (format == SUBBITMAP_RGBA) {
if (format == SUBBITMAP_BGRA) {
r = pack_rgba(p, &res);
} else {
r = pack_libass(p, &res);

View File

@ -32,7 +32,7 @@
const bool mp_draw_sub_formats[SUBBITMAP_COUNT] = {
[SUBBITMAP_LIBASS] = true,
[SUBBITMAP_RGBA] = true,
[SUBBITMAP_BGRA] = true,
};
struct part {
@ -84,7 +84,7 @@ struct mp_draw_sub_cache
struct mp_sws_context *alpha_to_calpha; // scaler for overlay -> calpha
bool scale_in_tiles;
struct mp_sws_context *sub_scale; // scaler for SUBBITMAP_RGBA
struct mp_sws_context *sub_scale; // scaler for SUBBITMAP_BGRA
struct mp_repack *overlay_to_f32; // convert video_overlay to float
struct mp_image *overlay_tmp; // slice in float32
@ -363,7 +363,7 @@ static void draw_rgba(uint8_t *dst, ptrdiff_t dst_stride,
static bool render_rgba(struct mp_draw_sub_cache *p, struct part *part,
struct sub_bitmaps *sb)
{
assert(sb->format == SUBBITMAP_RGBA);
assert(sb->format == SUBBITMAP_BGRA);
if (part->change_id != sb->change_id) {
for (int n = 0; n < part->num_imgs; n++)
@ -462,7 +462,7 @@ static bool render_sb(struct mp_draw_sub_cache *p, struct sub_bitmaps *sb)
case SUBBITMAP_LIBASS:
render_ass(p, sb);
return true;
case SUBBITMAP_RGBA:
case SUBBITMAP_BGRA:
return render_rgba(p, part, sb);
}

View File

@ -284,7 +284,7 @@ static struct sub_bitmaps *render_object(struct osd_state *osd,
{
int format = SUBBITMAP_LIBASS;
if (!sub_formats[format] || osd->opts->force_rgba_osd)
format = SUBBITMAP_RGBA;
format = SUBBITMAP_BGRA;
struct sub_bitmaps *res = NULL;

View File

@ -24,11 +24,11 @@
#include "options/m_option.h"
// NOTE: VOs must support at least SUBBITMAP_RGBA.
// NOTE: VOs must support at least SUBBITMAP_BGRA.
enum sub_bitmap_format {
SUBBITMAP_EMPTY = 0,// no bitmaps; always has num_parts==0
SUBBITMAP_LIBASS, // A8, with a per-surface blend color (libass.color)
SUBBITMAP_RGBA, // IMGFMT_BGRA (MSB=A, LSB=B), scaled, premultiplied alpha
SUBBITMAP_BGRA, // IMGFMT_BGRA (MSB=A, LSB=B), scaled, premultiplied alpha
SUBBITMAP_COUNT
};
@ -64,7 +64,7 @@ struct sub_bitmaps {
// Packed representation of the bitmap data. If non-NULL, then the
// parts[].bitmap pointer points into the image data here (and stride will
// correspond to packed->stride[0]).
// SUBBITMAP_RGBA: IMGFMT_BGRA (exact match)
// SUBBITMAP_BGRA: IMGFMT_BGRA (exact match)
// SUBBITMAP_LIBASS: IMGFMT_Y8 (not the same, but compatible layout)
// Other formats have this set to NULL.
struct mp_image *packed;
@ -82,7 +82,7 @@ struct sub_bitmap_list {
int64_t change_id;
// Bounding box for rendering. It's notable that SUBBITMAP_LIBASS images are
// always within these bounds, while SUBBITMAP_RGBA is not necessarily.
// always within these bounds, while SUBBITMAP_BGRA is not necessarily.
int w, h;
// Sorted by sub_bitmaps.render_index. Unused parts are not in the array,

View File

@ -433,7 +433,7 @@ static struct sub_bitmaps *get_bitmaps(struct sd *sd, struct mp_osd_res d,
res->packed = current->data;
res->packed_w = current->bound_w;
res->packed_h = current->bound_h;
res->format = SUBBITMAP_RGBA;
res->format = SUBBITMAP_BGRA;
double video_par = 0;
if (priv->avctx->codec_id == AV_CODEC_ID_DVD_SUBTITLE &&

View File

@ -31,7 +31,7 @@
static const int blend_factors[SUBBITMAP_COUNT][4] = {
[SUBBITMAP_LIBASS] = {RA_BLEND_SRC_ALPHA, RA_BLEND_ONE_MINUS_SRC_ALPHA,
RA_BLEND_ONE, RA_BLEND_ONE_MINUS_SRC_ALPHA},
[SUBBITMAP_RGBA] = {RA_BLEND_ONE, RA_BLEND_ONE_MINUS_SRC_ALPHA,
[SUBBITMAP_BGRA] = {RA_BLEND_ONE, RA_BLEND_ONE_MINUS_SRC_ALPHA,
RA_BLEND_ONE, RA_BLEND_ONE_MINUS_SRC_ALPHA},
};
@ -86,7 +86,7 @@ struct mpgl_osd *mpgl_osd_init(struct ra *ra, struct mp_log *log,
};
ctx->fmt_table[SUBBITMAP_LIBASS] = ra_find_unorm_format(ra, 1, 1);
ctx->fmt_table[SUBBITMAP_RGBA] = ra_find_unorm_format(ra, 1, 4);
ctx->fmt_table[SUBBITMAP_BGRA] = ra_find_unorm_format(ra, 1, 4);
for (int n = 0; n < MAX_OSD_PARTS; n++)
ctx->parts[n] = talloc_zero(ctx, struct mpgl_osd_part);
@ -215,7 +215,7 @@ bool mpgl_osd_draw_prepare(struct mpgl_osd *ctx, int index,
gl_sc_uniform_texture(sc, "osdtex", part->texture);
switch (fmt) {
case SUBBITMAP_RGBA: {
case SUBBITMAP_BGRA: {
GLSL(color = texture(osdtex, texcoord).bgra;)
break;
}

View File

@ -215,7 +215,7 @@ static void write_overlays(struct vo *vo, struct mp_osd_res res, double pts,
struct priv *p = vo->priv;
static const bool subfmt_all[SUBBITMAP_COUNT] = {
[SUBBITMAP_LIBASS] = true,
[SUBBITMAP_RGBA] = true,
[SUBBITMAP_BGRA] = true,
};
struct sub_bitmap_list *subs = osd_render(vo->osd, res, pts, flags, subfmt_all);
@ -283,7 +283,7 @@ static void write_overlays(struct vo *vo, struct mp_osd_res res, double pts,
};
switch (item->format) {
case SUBBITMAP_RGBA:
case SUBBITMAP_BGRA:
ol->mode = PL_OVERLAY_NORMAL;
ol->repr.alpha = PL_ALPHA_PREMULTIPLIED;
break;
@ -1153,7 +1153,7 @@ static int preinit(struct vo *vo)
p->rr = pl_renderer_create(p->pllog, p->gpu);
p->queue = pl_queue_create(p->gpu);
p->osd_fmt[SUBBITMAP_LIBASS] = pl_find_named_fmt(p->gpu, "r8");
p->osd_fmt[SUBBITMAP_RGBA] = pl_find_named_fmt(p->gpu, "rgba8");
p->osd_fmt[SUBBITMAP_BGRA] = pl_find_named_fmt(p->gpu, "rgba8");
char *cache_file = get_cache_file(p);
if (cache_file) {

View File

@ -62,7 +62,7 @@ const struct formatmap_entry formats[] = {
{SDL_PIXELFORMAT_RGBX8888, IMGFMT_RGB0, 0}, // has no alpha -> bad for OSD
{SDL_PIXELFORMAT_BGR888, IMGFMT_0BGR, 0}, // BGR888 means XBGR8888
{SDL_PIXELFORMAT_BGRX8888, IMGFMT_BGR0, 0}, // has no alpha -> bad for OSD
{SDL_PIXELFORMAT_ARGB8888, IMGFMT_ARGB, 1}, // matches SUBBITMAP_RGBA
{SDL_PIXELFORMAT_ARGB8888, IMGFMT_ARGB, 1}, // matches SUBBITMAP_BGRA
{SDL_PIXELFORMAT_RGBA8888, IMGFMT_RGBA, 1},
{SDL_PIXELFORMAT_ABGR8888, IMGFMT_ABGR, 1},
{SDL_PIXELFORMAT_BGRA8888, IMGFMT_BGRA, 1},
@ -71,7 +71,7 @@ const struct formatmap_entry formats[] = {
{SDL_PIXELFORMAT_RGBX8888, IMGFMT_0BGR, 0}, // has no alpha -> bad for OSD
{SDL_PIXELFORMAT_BGR888, IMGFMT_RGB0, 0}, // BGR888 means XBGR8888
{SDL_PIXELFORMAT_BGRX8888, IMGFMT_0RGB, 0}, // has no alpha -> bad for OSD
{SDL_PIXELFORMAT_ARGB8888, IMGFMT_BGRA, 1}, // matches SUBBITMAP_RGBA
{SDL_PIXELFORMAT_ARGB8888, IMGFMT_BGRA, 1}, // matches SUBBITMAP_BGRA
{SDL_PIXELFORMAT_RGBA8888, IMGFMT_ABGR, 1},
{SDL_PIXELFORMAT_ABGR8888, IMGFMT_RGBA, 1},
{SDL_PIXELFORMAT_BGRA8888, IMGFMT_ARGB, 1},
@ -800,7 +800,7 @@ static void draw_osd(struct vo *vo)
struct priv *vc = vo->priv;
static const bool osdformats[SUBBITMAP_COUNT] = {
[SUBBITMAP_RGBA] = true,
[SUBBITMAP_BGRA] = true,
};
osd_draw(vo->osd, vc->osd_res, vc->osd_pts, 0, osdformats, draw_osd_cb, vo);

View File

@ -596,7 +596,7 @@ static void generate_osd_part(struct vo *vo, struct sub_bitmaps *imgs)
case SUBBITMAP_LIBASS:
format = VDP_RGBA_FORMAT_A8;
break;
case SUBBITMAP_RGBA:
case SUBBITMAP_BGRA:
format = VDP_RGBA_FORMAT_B8G8R8A8;
break;
default:
@ -687,7 +687,7 @@ static void draw_osd(struct vo *vo)
bool formats[SUBBITMAP_COUNT] = {
[SUBBITMAP_LIBASS] = vc->supports_a8,
[SUBBITMAP_RGBA] = true,
[SUBBITMAP_BGRA] = true,
};
double pts = vc->current_image ? vc->current_image->pts : 0;