On Sat, Jan 9, 2021 at 2:56 PM Nuo Mi <nuomi2...@gmail.com> wrote: > > > On Mon, Dec 21, 2020 at 11:15 PM James Almer <jamr...@gmail.com> wrote: > >> On 12/21/2020 3:07 AM, Nuo Mi wrote: >> > --- >> > configure | 3 + >> > libavcodec/Makefile | 1 + >> > libavcodec/h2645_parse.c | 73 +++++++++- >> > libavcodec/h266_parser.c | 284 +++++++++++++++++++++++++++++++++++++++ >> > libavcodec/parsers.c | 1 + >> > 5 files changed, 360 insertions(+), 2 deletions(-) >> > create mode 100644 libavcodec/h266_parser.c >> > >> > diff --git a/configure b/configure >> > index 90914752f1..77272948e3 100755 >> > --- a/configure >> > +++ b/configure >> > @@ -2354,6 +2354,7 @@ CONFIG_EXTRA=" >> > cbs_av1 >> > cbs_h264 >> > cbs_h265 >> > + cbs_h266 >> > cbs_jpeg >> > cbs_mpeg2 >> > cbs_vp9 >> > @@ -2622,6 +2623,7 @@ threads_if_any="$THREADS_LIST" >> > cbs_av1_select="cbs" >> > cbs_h264_select="cbs" >> > cbs_h265_select="cbs" >> > +cbs_h266_select="cbs" >> >> These two chunks belong to the previous patch adding cbs_h266. Otherwise >> CONFIG_CBS_H266 will not be defined for Makefile to use. >> > fixed > >> >> > >> > diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c >> > index 0f98b49fbe..2600371d3c 100644 >> > --- a/libavcodec/h2645_parse.c >> > +++ b/libavcodec/h2645_parse.c >> >> cbs_h266 needs the changes to this file you're adding here to split >> NALUs, so it should be done in a new separate patch applied before patch >> 4/6. >> > done > >> >> >> > +static int h266_parse_nal_header(H2645NAL *nal, void *logctx) >> > +{ >> > + GetBitContext *gb = &nal->gb; >> > + >> > + if (get_bits1(gb) != 0) //forbidden_zero_bit >> > + return AVERROR_INVALIDDATA; >> > + >> > + if (get_bits1(gb) != 0) //nuh_reserved_zero_bit >> >> This one should be ignored, otherwise bitstreams compliant with an >> hypotetical future revision of the spec that defines this bit will not >> work, when they should. >> >> But current current cbs uses fixed to check the server value, like > fixed(24, general_reserved_zero_33bits, 0); > it always return error for none zero > >> >> > + ctx->key_frame = ph->ph_gdr_or_irap_pic_flag; >> >> Should a gdr pic also marked as keyframe? If not, this should also >> ensure ph->ph_gdr_pic_flag is 0. >> >> > + >> > + ctx->coded_width = pps->pps_pic_width_in_luma_samples; >> > + ctx->coded_height = pps->pps_pic_height_in_luma_samples; >> > + ctx->width = pps->pps_pic_width_in_luma_samples - >> pps->pps_conf_win_left_offset - pps->pps_conf_win_right_offset; >> > + ctx->height = pps->pps_pic_height_in_luma_samples - >> pps->pps_conf_win_top_offset - pps->pps_conf_win_bottom_offset; >> > + ctx->pict_type = get_pict_type(pu); >> > + ctx->format = get_format(sps); >> > + avctx->profile = sps->profile_tier_level.general_profile_idc; >> > + avctx->level = sps->profile_tier_level.general_level_idc; >> > + >> > + >> > + >> > + if(sps->sps_ptl_dpb_hrd_params_present_flag && >> sps->sps_timing_hrd_params_present_flag) { >> > + num = sps->sps_general_timing_hrd_parameters.num_units_in_tick; >> > + den = sps->sps_general_timing_hrd_parameters.time_scale; >> > + } else { >> > + av_log(avctx, AV_LOG_INFO, "No >> sps_timing_hrd_params_present_flag in sps, the fps may not right.\n"); >> >> No need for this warning. >> >> > + goto end; >> > + } >> > + if (num != 0 && den != 0) >> > + av_reduce(&avctx->framerate.den, &avctx->framerate.num, >> > + num, den, 1 << 30); >> > +end: >> > + >> > + ff_cbs_fragment_reset(pu); >> > + s->cbc->log_ctx = NULL; >> > + return 0; >> > +} >> > + >> > +static int h266_parser_parse(AVCodecParserContext *s, AVCodecContext >> *avctx, >> > + const uint8_t **poutbuf, int *poutbuf_size, >> > + const uint8_t *buf, int buf_size) >> > +{ >> > + int next; >> > + H266ParserContext *ctx = s->priv_data; >> > + ParseContext *pc = &ctx->pc; >> > + int is_dummy_buf = !buf_size; >> > + const uint8_t *dummy_buf = buf; >> > + >> > + if (avctx->extradata && !ctx->parsed_extradata) { >> > + av_log(avctx, AV_LOG_INFO, "extra data is not supported >> yet.\n"); >> > + return AVERROR_PATCHWELCOME; >> > + } >> > + >> > + if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { >> > + next = buf_size; >> > + } else { >> > + next = find_frame_end(s, buf, buf_size); >> > + if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { >> > + *poutbuf = NULL; >> > + *poutbuf_size = 0; >> > + return buf_size; >> > + } >> > + } >> > + >> > + is_dummy_buf &= (dummy_buf == buf); >> > + >> > + if (!is_dummy_buf) >> > + parse_nal_units(s, buf, buf_size, avctx); >> > + >> > + *poutbuf = buf; >> > + *poutbuf_size = buf_size; >> > + return next; >> > + >> > +} >> > + >> > +static const CodedBitstreamUnitType decompose_unit_types[] = { >> > + H266_NAL_TRAIL, >> > + H266_NAL_STSA, >> > + H266_NAL_RADL, >> > + H266_NAL_RASL, >> > + H266_NAL_IDR_W_RADL, >> > + H266_NAL_IDR_N_LP, >> > + H266_NAL_CRA_NUT, >> > + H266_NAL_GDR_NUT, >> > + H266_NAL_VPS, >> > + H266_NAL_SPS, >> > + H266_NAL_PPS, >> > + H266_NAL_PH, >> > + H266_NAL_AUD, >> > +}; >> > + >> > +static av_cold int h266_parser_init(AVCodecParserContext *ctx) >> > +{ >> > + H266ParserContext *s = ctx->priv_data; >> > + int ret; >> > + >> > + ret = ff_cbs_init(&s->cbc, AV_CODEC_ID_VVC, NULL); >> > + if (ret < 0) >> > + return ret; >> > + >> > + s->cbc->decompose_unit_types = (CodedBitstreamUnitType >> *)decompose_unit_types; >> > + s->cbc->nb_decompose_unit_types = >> FF_ARRAY_ELEMS(decompose_unit_types); >> > + >> > + return 0; >> > +} >> > + >> > +static void h266_parser_close(AVCodecParserContext *ctx) >> > +{ >> > + H266ParserContext *s = ctx->priv_data; >> > + >> > + ff_cbs_fragment_free(&s->picture_unit); >> > + ff_cbs_close(&s->cbc); >> > + av_freep(&s->pc.buffer); >> > +} >> > + >> > +AVCodecParser ff_h266_parser = { >> > + .codec_ids = { AV_CODEC_ID_VVC }, >> > + .priv_data_size = sizeof(H266ParserContext), >> > + .parser_init = h266_parser_init, >> > + .parser_close = h266_parser_close, >> > + .parser_parse = h266_parser_parse, >> > +}; >> > diff --git a/libavcodec/parsers.c b/libavcodec/parsers.c >> > index 83271d95a3..155aec71aa 100644 >> > --- a/libavcodec/parsers.c >> > +++ b/libavcodec/parsers.c >> > @@ -49,6 +49,7 @@ extern AVCodecParser ff_gsm_parser; >> > extern AVCodecParser ff_h261_parser; >> > extern AVCodecParser ff_h263_parser; >> > extern AVCodecParser ff_h264_parser; >> > +extern AVCodecParser ff_h266_parser; >> > extern AVCodecParser ff_hevc_parser; >> > extern AVCodecParser ff_ipu_parser; >> > extern AVCodecParser ff_jpeg2000_parser; >> > >> >> _______________________________________________ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> >> To unsubscribe, visit link above, or email >> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".