[vlc-commits] packetizer: hevc: extract sar

Francois Cartegnie git at videolan.org
Tue Oct 3 14:01:56 CEST 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Oct  3 13:24:54 2017 +0200| [d2eaa993c8f0e7e79eb72632d7675dd937af6a19] | committer: Francois Cartegnie

packetizer: hevc: extract sar

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d2eaa993c8f0e7e79eb72632d7675dd937af6a19
---

 modules/packetizer/hevc_nal.c | 44 +++++++++++++++++++++++++++++++++++++++++++
 modules/packetizer/hevc_nal.h |  2 ++
 2 files changed, 46 insertions(+)

diff --git a/modules/packetizer/hevc_nal.c b/modules/packetizer/hevc_nal.c
index 90d8ce2102..6a098c388d 100644
--- a/modules/packetizer/hevc_nal.c
+++ b/modules/packetizer/hevc_nal.c
@@ -1099,6 +1099,50 @@ bool hevc_get_frame_rate( const hevc_sequence_parameter_set_t *p_sps,
     return false;
 }
 
+bool hevc_get_aspect_ratio( const hevc_sequence_parameter_set_t *p_sps,
+                            unsigned *num, unsigned *den )
+{
+    if( p_sps->vui_parameters_present_flag )
+    {
+        if( p_sps->vui.ar.aspect_ratio_idc != 255 )
+        {
+            static const uint8_t ar_table[16][2] =
+            {
+                {    1,      1 },
+                {   12,     11 },
+                {   10,     11 },
+                {   16,     11 },
+                {   40,     33 },
+                {   24,     11 },
+                {   20,     11 },
+                {   32,     11 },
+                {   80,     33 },
+                {   18,     11 },
+                {   15,     11 },
+                {   64,     33 },
+                {  160,     99 },
+                {    4,      3 },
+                {    3,      2 },
+                {    2,      1 },
+            };
+            if( p_sps->vui.ar.aspect_ratio_idc > 0 &&
+                p_sps->vui.ar.aspect_ratio_idc < 17 )
+            {
+                *num = ar_table[p_sps->vui.ar.aspect_ratio_idc - 1][0];
+                *den = ar_table[p_sps->vui.ar.aspect_ratio_idc - 1][1];
+                return true;
+            }
+        }
+        else
+        {
+            *num = p_sps->vui.ar.sar_width;
+            *den = p_sps->vui.ar.sar_height;
+            return true;
+        }
+    }
+    return false;
+}
+
 bool hevc_get_colorimetry( const hevc_sequence_parameter_set_t *p_sps,
                            video_color_primaries_t *p_primaries,
                            video_transfer_func_t *p_transfer,
diff --git a/modules/packetizer/hevc_nal.h b/modules/packetizer/hevc_nal.h
index 7f1d3f3183..9eff3e714e 100644
--- a/modules/packetizer/hevc_nal.h
+++ b/modules/packetizer/hevc_nal.h
@@ -187,6 +187,8 @@ bool hevc_get_picture_size( const hevc_sequence_parameter_set_t *, unsigned *p_w
 bool hevc_get_frame_rate( const hevc_sequence_parameter_set_t *,
                           const hevc_video_parameter_set_t * /* can be NULL */,
                           unsigned *pi_num, unsigned *pi_den );
+bool hevc_get_aspect_ratio( const hevc_sequence_parameter_set_t *,
+                            unsigned *pi_num, unsigned *pi_den );
 bool hevc_get_colorimetry( const hevc_sequence_parameter_set_t *p_sps,
                            video_color_primaries_t *p_primaries,
                            video_transfer_func_t *p_transfer,



More information about the vlc-commits mailing list