From: Zhao Zhili <quinkblack-at-foxmail.com@ffmpeg.org> To: ffmpeg-devel@ffmpeg.org Cc: Zhao Zhili <zhilizhao@tencent.com> Subject: [FFmpeg-devel] [PATCH v4 1/3] avcodec/hevc: Rewrite scalability_mask_flag parse in decode_vps_ext Date: Thu, 6 Feb 2025 11:50:01 +0800 Message-ID: <tencent_0F40049A609F76ABD54E35709F2DEF9A2C08@qq.com> (raw) From: Zhao Zhili <zhilizhao@tencent.com> Remove a for loop and make it easy to extend to support other types of scalability. Move ScalabilityMask to hevc header file so it can be used in hevc decoder. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com> --- libavcodec/hevc/hevc.h | 7 +++++++ libavcodec/hevc/ps.c | 33 +++++++++++++++------------------ libavcodec/hevc/ps.h | 2 ++ 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/libavcodec/hevc/hevc.h b/libavcodec/hevc/hevc.h index 8bd59142db..b2229fda40 100644 --- a/libavcodec/hevc/hevc.h +++ b/libavcodec/hevc/hevc.h @@ -162,5 +162,12 @@ enum { HEVC_MAX_PALETTE_PREDICTOR_SIZE = 128, }; +enum HEVCScalabilityMask { + HEVC_SCALABILITY_DEPTH = 1 << (15 - 0), + HEVC_SCALABILITY_MULTIVIEW = 1 << (15 - 1), + HEVC_SCALABILITY_SPATIAL = 1 << (15 - 2), + HEVC_SCALABILITY_AUXILIARY = 1 << (15 - 3), + HEVC_SCALABILITY_MASK_MAX = 0xFFFF, +}; #endif /* AVCODEC_HEVC_HEVC_H */ diff --git a/libavcodec/hevc/ps.c b/libavcodec/hevc/ps.c index 285084685b..861a6bb0a2 100644 --- a/libavcodec/hevc/ps.c +++ b/libavcodec/hevc/ps.c @@ -450,14 +450,6 @@ static void hevc_vps_free(AVRefStructOpaque opaque, void *obj) av_freep(&vps->data); } -enum ScalabilityMask { - HEVC_SCALABILITY_DEPTH = 0, - HEVC_SCALABILITY_MULTIVIEW = 1, - HEVC_SCALABILITY_SPATIAL = 2, - HEVC_SCALABILITY_AUXILIARY = 3, - HEVC_SCALABILITY_MASK_MAX = 15, -}; - enum DependencyType { HEVC_DEP_TYPE_SAMPLE = 0, HEVC_DEP_TYPE_MV = 1, @@ -532,17 +524,22 @@ static int decode_vps_ext(GetBitContext *gb, AVCodecContext *avctx, HEVCVPS *vps return AVERROR_INVALIDDATA; splitting_flag = get_bits1(gb); - num_scalability_types = 0; - for (int i = 0; i <= HEVC_SCALABILITY_MASK_MAX; i++) { - int scalability_mask_flag = get_bits1(gb); - if (scalability_mask_flag && (i != HEVC_SCALABILITY_MULTIVIEW)) { - av_log(avctx, AV_LOG_ERROR, "Scalability type %d not supported\n", i); - return AVERROR_PATCHWELCOME; - } - num_scalability_types += scalability_mask_flag; - } - if (num_scalability_types != 1) + vps->scalability_mask_flag = get_bits(gb, 16); + num_scalability_types = av_popcount(vps->scalability_mask_flag); + if (!num_scalability_types) { + av_log(avctx, AV_LOG_ERROR, "Missing scalability mask\n"); return AVERROR_INVALIDDATA; + } else if (num_scalability_types > 1) { + av_log(avctx, AV_LOG_ERROR, "Scalability number %d not supported\n", + num_scalability_types); + return AVERROR_PATCHWELCOME; + } + + if (!(vps->scalability_mask_flag & HEVC_SCALABILITY_MULTIVIEW)) { + av_log(avctx, AV_LOG_ERROR, "Scalability type %d not supported\n", + 15 - ff_ctz(vps->scalability_mask_flag)); + return AVERROR_PATCHWELCOME; + } if (!splitting_flag) dimension_id_len = get_bits(gb, 3) + 1; diff --git a/libavcodec/hevc/ps.h b/libavcodec/hevc/ps.h index 6f5b1f8755..d3465e3d27 100644 --- a/libavcodec/hevc/ps.h +++ b/libavcodec/hevc/ps.h @@ -205,6 +205,8 @@ typedef struct HEVCVPS { */ int nb_layers; + uint16_t scalability_mask_flag; + // LayerIdxInVps[nuh_layer_id], i.e. a mapping of nuh_layer_id to VPS layer // indices. Valid values are between 0 and HEVC_VPS_MAX_LAYERS. Entries for // unmapped values of nuh_layer_id are set to -1. -- 2.46.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
reply other threads:[~2025-02-06 3:50 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=tencent_0F40049A609F76ABD54E35709F2DEF9A2C08@qq.com \ --to=quinkblack-at-foxmail.com@ffmpeg.org \ --cc=ffmpeg-devel@ffmpeg.org \ --cc=zhilizhao@tencent.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git