]> git.sesse.net Git - vlc/blobdiff - src/video_output/video_epg.c
Win32: use OutputDebugStringA directly
[vlc] / src / video_output / video_epg.c
index 996a07423b6166484f3f4e14c5a1b782c04a9976..624caf198cf04bc4f2adf6b43eadda79a38bd038 100644 (file)
@@ -5,25 +5,27 @@
  *
  * Author: Adrien Maglo <magsoft@videolan.org>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
 
+#include <time.h>
+
 #include <vlc_common.h>
 #include <vlc_vout.h>
 #include <vlc_vout_osd.h>
@@ -41,17 +43,26 @@ static subpicture_region_t * vout_OSDEpgSlider(int x, int y,
                                                int width, int height,
                                                float ratio)
 {
-    video_format_t fmt;
-    subpicture_region_t *region;
-
     /* Create a new subpicture region */
-    video_format_Init(&fmt, VLC_CODEC_YUVA);
+    video_palette_t palette = {
+        .i_entries = 4,
+        .palette = {
+            [0] = { 0xff, 0x80, 0x80, 0x00 },
+            [1] = { 0x00, 0x80, 0x80, 0x00 },
+            [2] = { 0xff, 0x80, 0x80, 0xff },
+            [3] = { 0x00, 0x80, 0x80, 0xff },
+        },
+    };
+
+    video_format_t fmt;
+    video_format_Init(&fmt, VLC_CODEC_YUVP);
     fmt.i_width  = fmt.i_visible_width  = width;
     fmt.i_height = fmt.i_visible_height = height;
     fmt.i_sar_num = 1;
     fmt.i_sar_den = 1;
+    fmt.p_palette = &palette;
 
-    region = subpicture_region_New(&fmt);
+    subpicture_region_t *region = subpicture_region_New(&fmt);
     if (!region)
         return NULL;
 
@@ -60,29 +71,21 @@ static subpicture_region_t * vout_OSDEpgSlider(int x, int y,
 
     picture_t *picture = region->p_picture;
 
-    ratio = __MIN(__MAX(ratio, 0), 1);
+    ratio = VLC_CLIP(ratio, 0, 1);
     int filled_part_width = ratio * width;
 
     for (int j = 0; j < height; j++) {
         for (int i = 0; i < width; i++) {
-            #define WRITE_COMP(plane, value) \
-                picture->p[plane].p_pixels[picture->p[plane].i_pitch * j + i] = value
-
-            /* Draw the slider. */
+            /* Slider border. */
             bool is_outline = j == 0 || j == height - 1 ||
                               i == 0 || i == width  - 1;
-            WRITE_COMP(0, is_outline ? 0x00 : 0xff);
-            WRITE_COMP(1, 0x80);
-            WRITE_COMP(2, 0x80);
-
             /* We can see the video through the part of the slider
                which corresponds to the leaving time. */
             bool is_border = j < 3 || j > height - 4 ||
                              i < 3 || i > width  - 4 ||
                              i < filled_part_width;
-            WRITE_COMP(3, is_border ? 0xff : 0x00);
 
-            #undef WRITE_COMP
+            picture->p->p_pixels[picture->p->i_pitch * j + i] = 2 * is_border + is_outline;
         }
     }
 
@@ -214,10 +217,11 @@ static int OSDEpgValidate(subpicture_t *subpic,
                           bool has_dst_changed, const video_format_t *fmt_dst,
                           mtime_t ts)
 {
-    VLC_UNUSED(subpic); VLC_UNUSED(ts); VLC_UNUSED(fmt_src);
-    VLC_UNUSED(has_dst_changed); VLC_UNUSED(fmt_dst);
+    VLC_UNUSED(subpic); VLC_UNUSED(ts);
+    VLC_UNUSED(fmt_src); VLC_UNUSED(has_src_changed);
+    VLC_UNUSED(fmt_dst);
 
-    if (!has_src_changed && !has_dst_changed)
+    if (!has_dst_changed)
         return VLC_SUCCESS;
     return VLC_EGENERIC;
 }