From: James Almer <jamrial@gmail.com> To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH v24 1/9] avcodec/evc_parser: Added parser implementation for EVC format Date: Mon, 12 Jun 2023 11:16:57 -0300 Message-ID: <4e439dde-45d5-d00a-2428-250944757342@gmail.com> (raw) In-Reply-To: <20230612122812.1153-1-d.kozinski@samsung.com> On 6/12/2023 9:28 AM, Dawid Kozinski wrote: > +int ff_evc_parse_nal_units(EVCParserContext *ctx, const uint8_t *buf, int buf_size, void *logctx) > +{ > + const uint8_t *data = buf; > + int data_size = buf_size; > + int bytes_read = 0; > + int nalu_size = 0; > + > + while (data_size > 0) { > + > + // Buffer size is not enough for buffer to store NAL unit 4-bytes prefix (length) > + if (data_size < EVC_NALU_LENGTH_PREFIX_SIZE) > + return END_NOT_FOUND; END_NOT_FOUND is a return value from the packet merging functionality of AVParser, which you're not using anymore. Given the parser now expects complete NALUs, this should be AVERROR_INVALIDDATA. Also, ff_evc_parse_nal_units() seems to be used only by this parser, so why is it shared? It's ff_evc_parse_nal_unit() that is also used by the merge bsf. > + > + nalu_size = ff_evc_read_nal_unit_length(data, data_size, logctx); > + > + bytes_read += EVC_NALU_LENGTH_PREFIX_SIZE; > + > + data += EVC_NALU_LENGTH_PREFIX_SIZE; > + data_size -= EVC_NALU_LENGTH_PREFIX_SIZE; > + > + if (data_size < nalu_size) > + return END_NOT_FOUND; Same. > + > + if (ff_evc_parse_nal_unit(ctx, data, nalu_size, logctx) != 0) { > + av_log(logctx, AV_LOG_ERROR, "Parsing of NAL unit failed\n"); > + return AVERROR_INVALIDDATA; > + } > + > + data += nalu_size; > + data_size -= nalu_size; > + } > + return 0; > +} [...] > +/** > + * Parse NAL units of found picture and decode some basic information. > + * > + * @param s parser context. > + * @param avctx codec context. > + * @param buf buffer with field/frame data. > + * @param buf_size size of the buffer. > + */ > +static int parse_nal_units(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t *buf, int buf_size) > +{ > + EVCParserContext *p = s->priv_data; > + > + int res = ff_evc_parse_nal_units(p, buf, buf_size, avctx); > + if(!res) > + return res; ff_evc_parse_nal_units() returns 0 on success, so the check should be ret < 0. Otherwise all the code below will never be used. > + > + s->picture_structure = AV_PICTURE_STRUCTURE_FRAME; > + > + if(p->nalu_type == EVC_SPS_NUT) { Wont p->nalu_type here be the value of the last NAL parsed in the AU? If so, I'd expect it to be a picture and not a sequence header, so this code will rarely if ever be covered. Since ff_evc_parse_nal_units() doesn't need to be shared, it can reside locally here and you can pass it the AVCodecParserContext pointer, setting all these values as soon as they are found while parsing the respective NALUs. > + > + s->coded_width = p->coded_width; > + s->coded_height = p->coded_height; > + s->width = p->width; > + s->height = p->height; > + > + s->format = p->format; > + > + avctx->coded_width = s->coded_width; > + avctx->coded_height = s->coded_height; > + avctx->width = s->width; > + avctx->height = s->height; Remove these four. They are set generically by the AVParser code. > + > + avctx->gop_size = p->gop_size; > + avctx->delay = p->delay; > + avctx->profile = p->profile; > + > + avctx->framerate.den = p->framerate.den; > + avctx->framerate.num = p->framerate.num; > + > + } else if(p->nalu_type == EVC_NOIDR_NUT) { > + s->pict_type = p->pict_type; > + s->key_frame = p->key_frame; > + s->output_picture_number = p->output_picture_number; Why export these only for non IDR pictures? > + } > + > + return 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".
prev parent reply other threads:[~2023-06-12 14:17 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <CGME20230612122825eucas1p28d58c77d18bc2f61cd00d2dc5c2f914d@eucas1p2.samsung.com> 2023-06-12 12:28 ` Dawid Kozinski 2023-06-12 14:16 ` James Almer [this message]
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=4e439dde-45d5-d00a-2428-250944757342@gmail.com \ --to=jamrial@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /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