[vlc-commits] [Git][videolan/vlc][master] 3 commits: demux: mp4: read clean aperture

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Fri Dec 9 21:01:54 UTC 2022



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
6452b120 by Francois Cartegnie at 2022-12-09T20:50:27+00:00
demux: mp4: read clean aperture

- - - - -
9ca86ce9 by Francois Cartegnie at 2022-12-09T20:50:27+00:00
demux: heif: only copy visible lines

- - - - -
928716f5 by Francois Cartegnie at 2022-12-09T20:50:27+00:00
demux: heif: handle clean aperture

- - - - -


4 changed files:

- modules/demux/mp4/essetup.c
- modules/demux/mp4/heif.c
- modules/demux/mp4/libmp4.c
- modules/demux/mp4/libmp4.h


Changes:

=====================================
modules/demux/mp4/essetup.c
=====================================
@@ -472,6 +472,17 @@ int SetupVideoES( demux_t *p_demux, const mp4_track_t *p_track, const MP4_Box_t
 
     /* Read extensions */
 
+    const MP4_Box_t *p_clap = MP4_BoxGet( p_sample, "clap" );
+    if( p_clap && BOXDATA(p_clap) &&
+        BOXDATA(p_clap)->i_width + BOXDATA(p_clap)->i_x_offset <= p_fmt->video.i_width &&
+        BOXDATA(p_clap)->i_height + BOXDATA(p_clap)->i_y_offset <= p_fmt->video.i_height )
+    {
+        p_fmt->video.i_visible_width = BOXDATA(p_clap)->i_width;
+        p_fmt->video.i_visible_height = BOXDATA(p_clap)->i_height;
+        p_fmt->video.i_x_offset = BOXDATA(p_clap)->i_x_offset;
+        p_fmt->video.i_y_offset = BOXDATA(p_clap)->i_y_offset;
+    }
+
     /* Set up A/R from extension atom */
     const MP4_Box_t *p_pasp = MP4_BoxGet( p_sample, "pasp" );
     if( p_pasp && BOXDATA(p_pasp) && BOXDATA(p_pasp)->i_horizontal_spacing > 0 &&


=====================================
modules/demux/mp4/heif.c
=====================================
@@ -387,6 +387,16 @@ static int SetPictureProperties( demux_t *p_demux, uint32_t i_item_id,
                     fmt->video.i_visible_width = p_prop->data.p_ispe->i_width;
                     fmt->video.i_visible_height = p_prop->data.p_ispe->i_height;
                     break;
+                case ATOM_clap:
+                    if(p_prop->data.p_clap->i_width + p_prop->data.p_clap->i_x_offset <= fmt->video.i_width &&
+                       p_prop->data.p_clap->i_height + p_prop->data.p_clap->i_y_offset <= fmt->video.i_height)
+                    {
+                        fmt->video.i_visible_width = p_prop->data.p_clap->i_width;
+                        fmt->video.i_visible_height = p_prop->data.p_clap->i_height;
+                        fmt->video.i_x_offset = p_prop->data.p_clap->i_x_offset;
+                        fmt->video.i_y_offset = p_prop->data.p_clap->i_y_offset;
+                    }
+                    break;
                 case ATOM_pasp:
                     if( p_prop->data.p_pasp->i_horizontal_spacing &&
                         p_prop->data.p_pasp->i_vertical_spacing )
@@ -589,8 +599,10 @@ static int LoadGridImage( demux_t *p_demux,
         const unsigned offsetpxh = (tile / gridcols) * tileheight;
         if( offsetpxw > imagewidth )
             break;
-        const uint8_t *srcline = p_picture->p[0].p_pixels;
-        unsigned tocopylines = p_picture->p[0].i_lines;
+        const uint8_t *srcline = p_picture->p[0].p_pixels +
+                                 p_picture->format.i_y_offset * p_picture->p[0].i_pitch +
+                                 p_picture->format.i_x_offset * 4;
+        unsigned tocopylines = p_picture->p[0].i_visible_lines;
         if(offsetpxh + tocopylines >= imageheight)
             tocopylines = imageheight - offsetpxh;
         for(unsigned i=0; i<tocopylines; i++)


=====================================
modules/demux/mp4/libmp4.c
=====================================
@@ -4172,6 +4172,39 @@ static int MP4_ReadBox_pasp( stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
+static int MP4_ReadBox_clap( stream_t *p_stream, MP4_Box_t *p_box )
+{
+    MP4_READBOX_ENTER( MP4_Box_data_clap_t, NULL );
+
+    if ( i_read != 32 )
+        MP4_READBOX_EXIT( 0 );
+
+    MP4_Box_data_clap_t *p_clap = p_box->data.p_clap;
+    uint32_t num, den;
+
+    MP4_GET4BYTES( num ); MP4_GET4BYTES( den );
+    p_clap->i_width = num / (den ? den : 1);
+    MP4_GET4BYTES( num ); MP4_GET4BYTES( den );
+    p_clap->i_height = num / (den ? den : 1);
+    MP4_GET4BYTES( num ); MP4_GET4BYTES( den );
+    p_clap->i_x_offset = num / (den ? den : 1);
+    MP4_GET4BYTES( num ); MP4_GET4BYTES( den );
+    p_clap->i_y_offset = num / (den ? den : 1);
+
+    if( UINT32_MAX - p_clap->i_width < p_clap->i_x_offset ||
+        UINT32_MAX - p_clap->i_height < p_clap->i_y_offset )
+        MP4_READBOX_EXIT( 0 );
+
+#ifdef MP4_VERBOSE
+    msg_Dbg( p_stream,
+             "read box: \"clap\" %"PRIu32"x%"PRIu32"+%"PRIu32"+%"PRIu32,
+             p_box->data.p_clap->i_width, p_box->data.p_clap->i_height,
+             p_box->data.p_clap->i_x_offset, p_box->data.p_clap->i_y_offset );
+#endif
+
+    MP4_READBOX_EXIT( 1 );
+}
+
 static int MP4_ReadBox_mehd( stream_t *p_stream, MP4_Box_t *p_box )
 {
     MP4_READBOX_ENTER( MP4_Box_data_mehd_t, NULL );
@@ -5008,6 +5041,7 @@ static const struct
     { ATOM_pcmC,    MP4_ReadBox_pcmC,         0 }, /* ISO-IEC 23003-5 */
     { ATOM_iods,    MP4_ReadBox_iods,         0 },
     { ATOM_pasp,    MP4_ReadBox_pasp,         0 },
+    { ATOM_clap,    MP4_ReadBox_clap,         0 },
     { ATOM_btrt,    MP4_ReadBox_btrt,         0 }, /* codecs bitrate stsd/????/btrt */
     { ATOM_keys,    MP4_ReadBox_keys,         ATOM_meta },
     { ATOM_colr,    MP4_ReadBox_colr,         0 },


=====================================
modules/demux/mp4/libmp4.h
=====================================
@@ -133,6 +133,7 @@ typedef int64_t stime_t;
 #define ATOM_cprt VLC_FOURCC( 'c', 'p', 'r', 't' )
 #define ATOM_iods VLC_FOURCC( 'i', 'o', 'd', 's' )
 #define ATOM_pasp VLC_FOURCC( 'p', 'a', 's', 'p' )
+#define ATOM_clap VLC_FOURCC( 'c', 'l', 'a', 'p' )
 #define ATOM_mfra VLC_FOURCC( 'm', 'f', 'r', 'a' )
 #define ATOM_mfro VLC_FOURCC( 'm', 'f', 'r', 'o' )
 #define ATOM_tfra VLC_FOURCC( 't', 'f', 'r', 'a' )
@@ -1489,6 +1490,14 @@ typedef struct
     uint32_t i_vertical_spacing;
 } MP4_Box_data_pasp_t;
 
+typedef struct
+{
+    uint32_t i_width;
+    uint32_t i_height;
+    uint32_t i_x_offset;
+    uint32_t i_y_offset;
+} MP4_Box_data_clap_t;
+
 typedef struct
 {
     uint8_t  i_version;
@@ -1766,6 +1775,7 @@ typedef union MP4_Box_data_s
     MP4_Box_data_iods_t *p_iods;
     MP4_Box_data_btrt_t *p_btrt;
     MP4_Box_data_pasp_t *p_pasp;
+    MP4_Box_data_clap_t *p_clap;
     MP4_Box_data_trex_t *p_trex;
     MP4_Box_data_mehd_t *p_mehd;
     MP4_Box_data_sdtp_t *p_sdtp;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/076641dcebbb34b9b8a2313c0cfcd9bbef975e13...928716f5b31e3149495260c7579ddfb4f52a94cb

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/076641dcebbb34b9b8a2313c0cfcd9bbef975e13...928716f5b31e3149495260c7579ddfb4f52a94cb
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