summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sub/img_convert.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/sub/img_convert.c b/sub/img_convert.c
index 888380cf70..9437226c64 100644
--- a/sub/img_convert.c
+++ b/sub/img_convert.c
@@ -26,6 +26,9 @@
#include "img_convert.h"
#include "sub.h"
#include "spudec.h"
+#include "libmpcodecs/img_format.h"
+#include "libmpcodecs/mp_image.h"
+#include "libmpcodecs/sws_utils.h"
struct osd_conv_cache {
struct sub_bitmap part;
@@ -199,12 +202,14 @@ bool osd_conv_idx_to_rgba(struct osd_conv_cache *c, struct sub_bitmaps *imgs)
rgba_to_premultiplied_rgba(sb.palette, 256);
*d = *s;
- d->stride = s->w * 4;
- d->bitmap = talloc_size(c->parts, s->h * d->stride);
+ struct mp_image *image = alloc_mpi(s->w, s->h, IMGFMT_BGRA);
+ talloc_steal(c->parts, image);
+ d->stride = image->stride[0];
+ d->bitmap = image->planes[0];
- uint32_t *outbmp = d->bitmap;
for (int y = 0; y < s->h; y++) {
uint8_t *inbmp = sb.bitmap + y * s->stride;
+ uint32_t *outbmp = (uint32_t*)((uint8_t*)d->bitmap + y * d->stride);
for (int x = 0; x < s->w; x++)
*outbmp++ = sb.palette[*inbmp++];
}