mirror of
https://github.com/mpv-player/mpv
synced 2025-02-13 10:27:12 +00:00
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.
31 lines
1.0 KiB
C
31 lines
1.0 KiB
C
#ifndef MPLAYER_SUB_IMG_CONVERT_H
|
|
#define MPLAYER_SUB_IMG_CONVERT_H
|
|
|
|
#include <stdbool.h>
|
|
|
|
struct osd_conv_cache;
|
|
struct sub_bitmaps;
|
|
struct sub_bitmap;
|
|
struct mp_rect;
|
|
|
|
struct osd_conv_cache *osd_conv_cache_new(void);
|
|
|
|
// These functions convert from one OSD format to another. On success, they copy
|
|
// the converted image data into c, and change imgs to point to the data.
|
|
bool osd_conv_ass_to_rgba(struct osd_conv_cache *c, struct sub_bitmaps *imgs);
|
|
// Sub postprocessing
|
|
void mp_blur_rgba_sub_bitmap(struct sub_bitmap *d, double gblur);
|
|
bool osd_scale_rgba(struct osd_conv_cache *c, struct sub_bitmaps *imgs);
|
|
|
|
bool mp_sub_bitmaps_bb(struct sub_bitmaps *imgs, struct mp_rect *out_bb);
|
|
|
|
// Intentionally limit the maximum number of bounding rects to something low.
|
|
// This prevents the algorithm from degrading to O(N^2).
|
|
// Most subtitles yield a very low number of bounding rects (<5).
|
|
#define MP_SUB_BB_LIST_MAX 15
|
|
|
|
int mp_get_sub_bb_list(struct sub_bitmaps *sbs, struct mp_rect *out_rc_list,
|
|
int rc_list_count);
|
|
|
|
#endif
|