From f72eb5b394c5145c1f5ae2546f8c628550e928e4 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 17 Jun 2016 20:10:39 +0200 Subject: sub: move paletted image handling completely to sd_lavc.c Until now, subtitle renderers could export SUBBITMAP_INDEXED, which is a 8 bit per pixel with palette format. sd_lavc.c was the only renderer doing this, and the result was converted to RGBA in every use-case (except maybe when the subtitles were hidden.) Change it so that sd_lavc.c converts to RGBA on its own. This simplifies everything a bit, and the palette handling can be removed from the common code. This is also preparation for making subtitle images refcounted. The "caching" in img_convert.c is a PITA in this respect, and needs to be redone. So getting rid of some img_convert.c code is a positive side- effect. Also related to refcounted subtitles is packing them into a single mp_image. Fewer objects to refcount is easier, and for the libass format the same will be done. The plan is to remove manual packing from the VOs which need single images entirely. --- sub/osd.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'sub/osd.c') diff --git a/sub/osd.c b/sub/osd.c index 4e269ce5aa..ea33961c9f 100644 --- a/sub/osd.c +++ b/sub/osd.c @@ -295,12 +295,6 @@ static void render_object(struct osd_state *osd, struct osd_object *obj, bool cached = false; // do we have a copy of all the image data? - if (out_imgs->format == SUBBITMAP_INDEXED && opts->sub_gray) - cached |= osd_conv_idx_to_gray(obj->cache[0], out_imgs); - - if (formats[SUBBITMAP_RGBA] && out_imgs->format == SUBBITMAP_INDEXED) - cached |= osd_conv_idx_to_rgba(obj->cache[1], out_imgs); - if (out_imgs->format == SUBBITMAP_RGBA && opts->sub_gauss != 0.0f) cached |= osd_conv_blur_rgba(obj->cache[2], out_imgs, opts->sub_gauss); -- cgit v1.2.3 From 56058a95e55c200828525f555baf47f91d81ccdd Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 17 Jun 2016 21:54:12 +0200 Subject: sub: fix --sub-gauss Implement it directly in sd_lavc.c as well. Blurring requires extending the size of the sub-images by the blur radius. Since we now want sub_bitmaps to be packed into a single image, and we don't want to repack for blurring, we add some extra padding to each sub-bitmap in the initial packing, and then extend their size later. This relies on the previous bitmap_packer commit, which always adds the padding in all cases. Since blurring is now done on parts of a large bitmap, the data pointers can become unaligned, depending on their position. To avoid shitty libswscale printing a dumb warning, allocate an extra image, so that the blurring pass is done on two newly allocated images. (I don't find this feature important enough to waste more time on it.) The previous refactor accidentally broke this feature due to a logic bug in osd.c. It didn't matter before it happened to break, and doesn't matter now since the code paths are different. --- sub/osd.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'sub/osd.c') diff --git a/sub/osd.c b/sub/osd.c index ea33961c9f..a0618aafd9 100644 --- a/sub/osd.c +++ b/sub/osd.c @@ -295,10 +295,6 @@ static void render_object(struct osd_state *osd, struct osd_object *obj, bool cached = false; // do we have a copy of all the image data? - if (out_imgs->format == SUBBITMAP_RGBA && opts->sub_gauss != 0.0f) - cached |= osd_conv_blur_rgba(obj->cache[2], out_imgs, opts->sub_gauss); - - // Do this conversion last to not trigger gauss blurring for ASS if (formats[SUBBITMAP_RGBA] && out_imgs->format == SUBBITMAP_LIBASS) cached |= osd_conv_ass_to_rgba(obj->cache[3], out_imgs); -- cgit v1.2.3