[vlc-commits] codec: hxxx_helper: refactor using codec

Francois Cartegnie git at videolan.org
Tue Oct 3 14:16:26 CEST 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Oct  2 17:17:56 2017 +0200| [1a9816928bf9fefa1f0766788c1934841b3666d6] | committer: Francois Cartegnie

codec: hxxx_helper: refactor using codec

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

 modules/codec/hxxx_helper.c      | 76 +++++++++++++++++++++++++++++-----------
 modules/codec/hxxx_helper.h      |  6 ++--
 modules/codec/omxil/mediacodec.c |  2 +-
 3 files changed, 60 insertions(+), 24 deletions(-)

diff --git a/modules/codec/hxxx_helper.c b/modules/codec/hxxx_helper.c
index 001eeb301b..c451d052cc 100644
--- a/modules/codec/hxxx_helper.c
+++ b/modules/codec/hxxx_helper.c
@@ -687,26 +687,50 @@ h264_helper_get_current_sps(const struct hxxx_helper *hh)
 }
 
 int
-h264_helper_get_current_picture_size(const struct hxxx_helper *hh,
+hxxx_helper_get_current_picture_size(const struct hxxx_helper *hh,
                                      unsigned *p_w, unsigned *p_h,
                                      unsigned *p_vw, unsigned *p_vh)
 {
-    const struct hxxx_helper_nal *hsps = h264_helper_get_current_sps(hh);
-    if (hsps == NULL)
-        return VLC_EGENERIC;
-    return h264_get_picture_size(hsps->h264_sps, p_w, p_h, p_vw, p_vh) ?
-           VLC_SUCCESS : VLC_EGENERIC;
+    if(hh->i_codec == VLC_CODEC_H264)
+    {
+        const struct hxxx_helper_nal *hsps = h264_helper_get_current_sps(hh);
+        if (hsps && h264_get_picture_size(hsps->h264_sps, p_w, p_h, p_vw, p_vh))
+               return VLC_SUCCESS;
+    }
+    else if(hh->i_codec == VLC_CODEC_HEVC)
+    {
+        const struct hxxx_helper_nal *hsps = &hh->hevc.sps_list[hh->hevc.i_current_sps];
+        if(hsps && hevc_get_picture_size(hsps->hevc_sps, p_w, p_h, p_vw, p_vh))
+            return VLC_SUCCESS;
+    }
+    return VLC_EGENERIC;
 }
 
 int
-h264_helper_get_current_sar(const struct hxxx_helper *hh, int *p_num, int *p_den)
+hxxx_helper_get_current_sar(const struct hxxx_helper *hh, int *p_num, int *p_den)
 {
-    const struct hxxx_helper_nal *hsps = h264_helper_get_current_sps(hh);
-    if (hsps == NULL)
-        return VLC_EGENERIC;
-    *p_num = hsps->h264_sps->vui.i_sar_num;
-    *p_den = hsps->h264_sps->vui.i_sar_den;
-    return VLC_SUCCESS;
+    if(hh->i_codec == VLC_CODEC_H264)
+    {
+        const struct hxxx_helper_nal *hsps = h264_helper_get_current_sps(hh);
+        if (hsps)
+        {
+            *p_num = hsps->h264_sps->vui.i_sar_num;
+            *p_den = hsps->h264_sps->vui.i_sar_den;
+            return VLC_SUCCESS;
+        }
+    }
+    else if(hh->i_codec == VLC_CODEC_HEVC)
+    {
+        const struct hxxx_helper_nal *hsps = &hh->hevc.sps_list[hh->hevc.i_current_sps];
+        unsigned num, den;
+        if(hsps && hevc_get_aspect_ratio(hsps->hevc_sps, &num, &den))
+        {
+            *p_num = num;
+            *p_den = den;
+            return VLC_SUCCESS;
+        }
+    }
+    return VLC_EGENERIC;
 }
 
 int
@@ -721,15 +745,27 @@ h264_helper_get_current_dpb_values(const struct hxxx_helper *hh,
 }
 
 int
-h264_helper_get_current_profile_level(const struct hxxx_helper *hh,
+hxxx_helper_get_current_profile_level(const struct hxxx_helper *hh,
                                       uint8_t *p_profile, uint8_t *p_level)
 {
-    const struct hxxx_helper_nal *hsps = h264_helper_get_current_sps(hh);
-    if (hsps == NULL)
-        return VLC_EGENERIC;
-    *p_profile = hsps->h264_sps->i_profile;
-    *p_level = hsps->h264_sps->i_level;
-    return VLC_SUCCESS;
+    if(hh->i_codec == VLC_CODEC_H264)
+    {
+        const struct hxxx_helper_nal *hsps = h264_helper_get_current_sps(hh);
+        if (hsps)
+        {
+            *p_profile = hsps->h264_sps->i_profile;
+            *p_level = hsps->h264_sps->i_level;
+            return VLC_SUCCESS;
+        }
+    }
+    else if(hh->i_codec == VLC_CODEC_HEVC)
+    {
+        const struct hxxx_helper_nal *hsps = &hh->hevc.sps_list[hh->hevc.i_current_sps];
+        if (hsps &&
+            hevc_get_sps_profile_tier_level(hsps->hevc_sps, p_profile, p_level))
+            return VLC_SUCCESS;
+    }
+    return VLC_EGENERIC;
 }
 
 int
diff --git a/modules/codec/hxxx_helper.h b/modules/codec/hxxx_helper.h
index d74b5e4542..6a9e51d1a2 100644
--- a/modules/codec/hxxx_helper.h
+++ b/modules/codec/hxxx_helper.h
@@ -89,16 +89,16 @@ block_t *h264_helper_get_annexb_config(const struct hxxx_helper *hh);
 
 block_t *h264_helper_get_avcc_config(const struct hxxx_helper *hh);
 
-int h264_helper_get_current_picture_size(const struct hxxx_helper *hh,
+int hxxx_helper_get_current_picture_size(const struct hxxx_helper *hh,
                                          unsigned *p_w, unsigned *p_h,
                                          unsigned *p_vw, unsigned *p_vh);
 
-int h264_helper_get_current_sar(const struct hxxx_helper *hh, int *p_num, int *p_den);
+int hxxx_helper_get_current_sar(const struct hxxx_helper *hh, int *p_num, int *p_den);
 
 int h264_helper_get_current_dpb_values(const struct hxxx_helper *hh,
                                        uint8_t *p_depth, unsigned *pi_delay);
 
-int h264_helper_get_current_profile_level(const struct hxxx_helper *hh,
+int hxxx_helper_get_current_profile_level(const struct hxxx_helper *hh,
                                           uint8_t *p_profile, uint8_t *p_level);
 
 int hxxx_helper_get_colorimetry(const struct hxxx_helper *hh,
diff --git a/modules/codec/omxil/mediacodec.c b/modules/codec/omxil/mediacodec.c
index f7a6027a1b..c50bec2853 100644
--- a/modules/codec/omxil/mediacodec.c
+++ b/modules/codec/omxil/mediacodec.c
@@ -258,7 +258,7 @@ static int H264SetCSD(decoder_t *p_dec, bool *p_size_changed)
         CSDInit(p_dec, p_spspps_blocks, 2);
 
     unsigned i_w, i_h, i_vw, i_vh;
-    h264_helper_get_current_picture_size(hh, &i_w, &i_h, &i_vw, &i_vh);
+    hxxx_helper_get_current_picture_size(hh, &i_w, &i_h, &i_vw, &i_vh);
 
     if (p_size_changed)
         *p_size_changed = (i_w != p_dec->fmt_out.video.i_width



More information about the vlc-commits mailing list