VLC 4.0.0-dev
Loading...
Searching...
No Matches
vout_spuregion_helper.h
Go to the documentation of this file.
1/*****************************************************************************
2 * vout_spuregion_helper.h : vout subpicture region helpers
3 *****************************************************************************
4 * Copyright (C) 2017 VLC authors, VideoLAN and VideoLabs
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
20#include <vlc_image.h>
21#include <vlc_subpicture.h>
22
23#define RGB2YUV( R, G, B ) \
24 ((0.257 * R) + (0.504 * G) + (0.098 * B) + 16), \
25 (-(0.148 * R) - (0.291 * G) + (0.439 * B) + 128),\
26 ((0.439 * R) - (0.368 * G) - (0.071 * B) + 128)
27
28#define HEX2YUV( rgb ) \
29 RGB2YUV( (rgb >> 16), ((rgb & 0xFF00) >> 8), (rgb & 0xFF) )
30
31static inline void
33 uint32_t argb1, uint32_t argb2 )
34{
35 for( uint8_t i = 0; i<i_splits; i++ )
36 {
37 uint32_t rgb1 = argb1 & 0x00FFFFFF;
38 uint32_t rgb2 = argb2 & 0x00FFFFFF;
39
40 uint32_t r = ((((rgb1 >> 16) * (i_splits - i)) + (rgb2 >> 16) * i)) / i_splits;
41 uint32_t g = (((((rgb1 >> 8) & 0xFF) * (i_splits - i)) + ((rgb2 >> 8) & 0xFF) * i)) / i_splits;
42 uint32_t b = ((((rgb1 & 0xFF) * (i_splits - i)) + (rgb2 & 0xFF) * i)) / i_splits;
43 uint8_t entry[4] = { RGB2YUV( r,g,b ), argb1 >> 24 };
44 memcpy( p_palette->palette[i], entry, 4 );
45 }
46 p_palette->i_entries = i_splits;
47}
48
49static inline void
51{
52 const int i_split = p->i_visible_lines / i_splits;
53 const int i_left = p->i_visible_lines % i_splits + p->i_lines - p->i_visible_lines;
54 for( int i = 0; i<i_splits; i++ )
55 {
56 memset( &p->p_pixels[p->i_pitch * (i * i_split)],
57 i,
58 p->i_pitch * i_split );
59 }
60 memset( &p->p_pixels[p->i_pitch * (i_splits - 1) * i_split],
61 i_splits - 1,
62 p->i_pitch * i_left );
63}
64
65
66static inline subpicture_region_t *
68 const char *psz_uri )
69{
70 picture_t *p_pic = NULL;
71 struct vlc_logger *logger = p_this->logger;
72 bool no_interact = p_this->no_interact;
73 p_this->logger = NULL;
74 p_this->no_interact = true;
75 image_handler_t *p_image = image_HandlerCreate( p_this );
76 if( p_image )
77 {
78 p_pic = image_ReadUrl( p_image, psz_uri, p_fmt );
79 image_HandlerDelete( p_image );
80 }
81 p_this->no_interact = no_interact;
82 p_this->logger = logger;
83
84 if(!p_pic)
85 return NULL;
86
88 picture_Release( p_pic );
89
90 return region;
91}
#define p(t)
static void picture_Release(picture_t *picture)
Decrements the picture reference count.
Definition vlc_picture.h:374
subpicture_region_t * subpicture_region_ForPicture(const video_format_t *p_fmt, picture_t *pic)
Create a subpicture region containing the picture.
Definition subpicture.c:289
void image_HandlerDelete(image_handler_t *p_image)
Delete the image_handler_t instance.
Definition image.c:119
Definition fourcc_gen.c:52
Definition vlc_image.h:40
Video picture.
Definition vlc_picture.h:130
Description of a planar graphic field.
Definition vlc_picture.h:50
Video subtitle region.
Definition vlc_subpicture.h:72
video format description
Definition vlc_es.h:356
Definition vlc_es.h:45
int i_entries
number of in-use palette entries
Definition vlc_es.h:46
uint8_t palette[256][4]
4-byte RGBA/YUVA palette
Definition vlc_es.h:47
Definition messages.c:85
VLC object common members.
Definition vlc_objects.h:53
struct vlc_logger * logger
Definition vlc_objects.h:54
bool no_interact
Definition vlc_objects.h:60
This file defines functions and structures for image conversions in vlc.
#define image_HandlerCreate(a)
Definition vlc_image.h:67
#define image_ReadUrl(a, b, c)
Definition vlc_image.h:71
Subpictures functions.
#define RGB2YUV(R, G, B)
Definition vout_spuregion_helper.h:23
static void spuregion_CreateVGradientPalette(video_palette_t *p_palette, uint8_t i_splits, uint32_t argb1, uint32_t argb2)
Definition vout_spuregion_helper.h:32
static void spuregion_CreateVGradientFill(plane_t *p, uint8_t i_splits)
Definition vout_spuregion_helper.h:50
static subpicture_region_t * spuregion_CreateFromPicture(vlc_object_t *p_this, video_format_t *p_fmt, const char *psz_uri)
Definition vout_spuregion_helper.h:67