[vlc-commits] [Git][videolan/vlc][master] mock: add an option to generate color bars for RGB

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Sep 15 09:41:00 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
b1e4b572 by Steve Lhomme at 2023-09-15T09:26:32+00:00
mock: add an option to generate color bars for RGB

This can be useful to test the order of colors in RGB with mask.

The 15-bit and 16-bit values are currently written as Little-Endian to verify
that's what Windows expects. It can be extended when we add hardcoded
LE and BE chromas.

- - - - -


1 changed file:

- modules/demux/mock.c


Changes:

=====================================
modules/demux/mock.c
=====================================
@@ -200,6 +200,7 @@ var_Read_float(const char *psz)
     Y(video, height, unsigned, add_integer, Unsigned, 480) \
     Y(video, frame_rate, unsigned, add_integer, Unsigned, 25) \
     Y(video, frame_rate_base, unsigned, add_integer, Unsigned, 1) \
+    Y(video, colorbar, bool, add_bool, Bool, false) \
     Y(video, orientation, unsigned, add_integer, Unsigned, ORIENT_NORMAL)
 
 #define OPTIONS_SUB(Y) \
@@ -298,6 +299,9 @@ struct demux_sys
     int current_title;
     vlc_tick_t chapter_gap;
 
+    uint8_t bar_colors[PICTURE_PLANE_MAX][PICTURE_PLANE_MAX];
+    bool b_colors;
+
     unsigned int updates;
     OPTIONS_GLOBAL(DECLARE_OPTION)
     struct mock_video_options video;
@@ -598,7 +602,23 @@ CreateVideoBlock(demux_t *demux, struct mock_track *track)
         block_len += pic->p[i].i_lines * pic->p[i].i_pitch;
 
     uint8_t pixel = (sys->video_pts / VLC_TICK_FROM_MS(delay)) % range;
-    memset(pic->p[0].p_pixels, pixel, block_len);
+    if (sys->b_colors)
+    {
+        int bars = __MAX(3, pic->p[0].i_pixel_pitch);
+        unsigned lines_per_color = pic->p[0].i_visible_lines / bars;
+        for (int bar = 0; bar < bars; bar++)
+        {
+            for (unsigned y=bar*lines_per_color; y < (bar+1)*lines_per_color; y++)
+            {
+                for (int x=0; x < pic->p[0].i_visible_pitch; x += pic->p[0].i_pixel_pitch)
+                {
+                    memcpy(&pic->p[0].p_pixels[x + y*pic->p[0].i_pitch], &sys->bar_colors[bar], pic->p[0].i_pixel_pitch);
+                }
+            }
+        }
+    }
+    else
+        memset(pic->p[0].p_pixels, pixel, block_len);
 
     if(pic->format.p_palette && pixel < PALETTE_BLACK)
     {
@@ -771,6 +791,47 @@ ConfigureVideoTrack(demux_t *demux,
 
     fmt->b_packetized = options->packetized;
 
+    if (options->colorbar && !vlc_fourcc_IsYUV(chroma) && desc->plane_count == 1)
+    {
+        struct demux_sys *sys = demux->p_sys;
+        sys->b_colors = true;
+
+        unsigned bars = __MAX(3, desc->pixel_size);
+        for (unsigned bar = 0; bar < bars; bar++)
+        {
+            memset(&sys->bar_colors[bar], 0, sizeof(*sys->bar_colors));
+            if (desc->pixel_bits == 15)
+            {
+                // ONLY Little-Endian FOR NOW to match AVI
+
+                // only first 2 bytes of bar_colors are used
+                if (bar == 0)
+                    SetWLE(&sys->bar_colors[bar], 0x1F << 10);
+                else if (bar == 1)
+                    SetWLE(&sys->bar_colors[bar], 0x1F << 5);
+                else if (bar == 2)
+                    SetWLE(&sys->bar_colors[bar], 0x1F << 0);
+            }
+            else if (desc->pixel_bits == 16)
+            {
+                // ONLY Little-Endian FOR NOW to match AVI
+
+                // only first 2 bytes of bar_colors are used
+                if (bar == 0)
+                    SetWLE(&sys->bar_colors[bar], 0x1F << 11);
+                else if (bar == 1)
+                    SetWLE(&sys->bar_colors[bar], 0x3F << 5);
+                else if (bar == 2)
+                    SetWLE(&sys->bar_colors[bar], 0x1F << 0);
+            }
+            else if (desc->pixel_bits == 32 || desc->pixel_bits == 24)
+                // write 0xFF on the offset of the bar
+                sys->bar_colors[bar][bar] = 0xFF;
+            else
+                sys->b_colors = false; // unsupported RGB type
+        }
+    }
+
     return VLC_SUCCESS;
 }
 
@@ -1271,6 +1332,8 @@ Open(vlc_object_t *obj)
         return VLC_SUCCESS;
     }
 
+    sys->b_colors = false;
+
     if (sys->chapter_count > 0 && sys->title_count == 0)
         sys->title_count++;
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/b1e4b572ce1b405d889c53c56ae0e2e73cc1b526

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/b1e4b572ce1b405d889c53c56ae0e2e73cc1b526
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list