[vlc-devel] [PATCH 24/28] hxxx_helper: simplify h264_helper_get_current_sar using vlc_rational_t

Steve Lhomme robux4 at videolabs.io
Fri Mar 31 18:14:39 CEST 2017


---
 modules/codec/hxxx_helper.c  | 5 ++---
 modules/codec/hxxx_helper.h  | 2 +-
 modules/codec/videotoolbox.m | 8 ++++----
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/modules/codec/hxxx_helper.c b/modules/codec/hxxx_helper.c
index fc3122bf8b..e11c2f5581 100644
--- a/modules/codec/hxxx_helper.c
+++ b/modules/codec/hxxx_helper.c
@@ -540,13 +540,12 @@ h264_helper_get_current_picture_size(struct hxxx_helper *hh,
 }
 
 int
-h264_helper_get_current_sar(struct hxxx_helper *hh, int *p_num, int *p_den)
+h264_helper_get_current_sar(struct hxxx_helper *hh, vlc_rational_t *p_sar)
 {
     const struct hxxx_helper_nal *hsps = h264_helper_get_current_sps(hh);
     if (hsps == NULL)
         return VLC_EGENERIC;
-    *p_num = hsps->h264_sps->vui.sar.num;
-    *p_den = hsps->h264_sps->vui.sar.den;
+    *p_sar = hsps->h264_sps->vui.sar;
     return VLC_SUCCESS;
 }
 
diff --git a/modules/codec/hxxx_helper.h b/modules/codec/hxxx_helper.h
index a83f45535d..1a5811a133 100644
--- a/modules/codec/hxxx_helper.h
+++ b/modules/codec/hxxx_helper.h
@@ -78,7 +78,7 @@ int h264_helper_get_current_picture_size(struct hxxx_helper *hh,
                                          unsigned *p_w, unsigned *p_h,
                                          unsigned *p_vw, unsigned *p_vh);
 
-int h264_helper_get_current_sar(struct hxxx_helper *hh, int *p_num, int *p_den);
+int h264_helper_get_current_sar(struct hxxx_helper *hh, vlc_rational_t *p_sar);
 
 int h264_helper_get_current_dpb_values(struct hxxx_helper *hh,
                                        uint8_t *p_depth, unsigned *pi_delay);
diff --git a/modules/codec/videotoolbox.m b/modules/codec/videotoolbox.m
index b1a617e217..21cec1e927 100644
--- a/modules/codec/videotoolbox.m
+++ b/modules/codec/videotoolbox.m
@@ -1017,13 +1017,14 @@ static int avcCFromAnnexBCreate(decoder_t *p_dec)
         return VLC_EGENERIC;
 
     unsigned i_h264_width, i_h264_height, i_video_width, i_video_height;
-    int i_sar_num, i_sar_den, i_ret;
+    vlc_rational_t sar;
+    int i_ret;
     i_ret = h264_helper_get_current_picture_size(&p_sys->hh,
                                                  &i_h264_width, &i_h264_height,
                                                  &i_video_width, &i_video_height);
     if (i_ret != VLC_SUCCESS)
         return i_ret;
-    i_ret = h264_helper_get_current_sar(&p_sys->hh, &i_sar_num, &i_sar_den);
+    i_ret = h264_helper_get_current_sar(&p_sys->hh, &sar);
     if (i_ret != VLC_SUCCESS)
         return i_ret;
 
@@ -1031,8 +1032,7 @@ static int avcCFromAnnexBCreate(decoder_t *p_dec)
     p_dec->fmt_out.video.i_width = i_video_width;
     p_dec->fmt_out.video.i_visible_height =
     p_dec->fmt_out.video.i_height = i_video_height;
-    p_dec->fmt_out.video.sar.num = i_sar_num;
-    p_dec->fmt_out.video.sar.den = i_sar_den;
+    p_dec->fmt_out.video.sar = sar;
 
     block_t *p_avcC = h264_helper_get_avcc_config(&p_sys->hh);
     if (!p_avcC)
-- 
2.11.1



More information about the vlc-devel mailing list