From: James Almer <jamrial@gmail.com> To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH v23 04/10] avformat/evc_demuxer: Added demuxer to handle reading EVC video files Date: Mon, 29 May 2023 10:07:47 -0300 Message-ID: <60cedee7-fe0e-8764-42d5-241875adaab5@gmail.com> (raw) In-Reply-To: <20230526103145.1277-1-d.kozinski@samsung.com> On 5/26/2023 7:31 AM, Dawid Kozinski wrote: > +static int get_temporal_id(const uint8_t *bits, int bits_size) > +{ > + int temporal_id = 0; > + short t = 0; > + > + if (bits_size >= EVC_NALU_HEADER_SIZE) { > + unsigned char *p = (unsigned char *)bits; > + // forbidden_zero_bit > + if ((p[0] & 0x80) != 0) > + return -1; > + > + for (int i = 0; i < EVC_NALU_HEADER_SIZE; i++) > + t = (t << 8) | p[i]; I think this can be replaced with AV_RB16. > + > + temporal_id = (t >> 6) & 0x0007; > + } > + > + return temporal_id; > +} [...] > +static uint32_t read_nal_unit_length(const uint8_t *bits, int bits_size) > +{ > + uint32_t nalu_len = 0; > + > + if (bits_size >= EVC_NALU_LENGTH_PREFIX_SIZE) { > + > + int t = 0; > + unsigned char *p = (unsigned char *)bits; > + > + for (int i = 0; i < EVC_NALU_LENGTH_PREFIX_SIZE; i++) > + t = (t << 8) | p[i]; AV_RB32. > + > + nalu_len = t; > + if (nalu_len == 0) // Invalid bitstream size > + return 0; > + } > + > + return nalu_len; > +} [...] > +static int evc_frame_merge_filter(AVBSFContext *bsf, AVPacket *out) > +{ > + EVCMergeContext *ctx = bsf->priv_data; > + AVPacket *in = ctx->in; > + > + int free_space = 0; > + size_t nalu_size = 0; > + uint8_t *nalu = NULL; > + int au_end_found = 0; > + int err; > + > + err = ff_bsf_get_packet_ref(bsf, in); > + if (err < 0) > + return err; > + > + nalu_size = read_nal_unit_length(in->data, EVC_NALU_LENGTH_PREFIX_SIZE); > + if(nalu_size <= 0) { > + av_packet_unref(in); > + return AVERROR_INVALIDDATA; > + } > + > + nalu = in->data + EVC_NALU_LENGTH_PREFIX_SIZE; > + nalu_size = in->size - EVC_NALU_LENGTH_PREFIX_SIZE; > + > + // NAL unit parsing needed to determine if end of AU was found > + err = parse_nal_unit(nalu, nalu_size, bsf); > + if (err < 0) { > + av_log(bsf, AV_LOG_ERROR, "NAL Unit parsing error\n"); > + av_packet_unref(in); > + > + return err; > + } > + > + au_end_found = end_of_access_unit_found(bsf); > + > + free_space = ctx->au_buffer.capacity - ctx->au_buffer.data_size; > + while( free_space < in->size ) { > + ctx->au_buffer.capacity *= 2; > + free_space = ctx->au_buffer.capacity - ctx->au_buffer.data_size; > + > + if(free_space >= in->size) { > + ctx->au_buffer.data = av_realloc(ctx->au_buffer.data, ctx->au_buffer.capacity); > + } > + } > + > + memcpy(ctx->au_buffer.data + ctx->au_buffer.data_size, in->data, in->size); This is including the Annex-B's nal_unit_lenght value into the assembled packet. I assume libxevd expects this? Also, is it defined as part of the ISOBMFF encapsulation? Patch 07/10 does not seem to strip it. _______________________________________________ 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".
next prev parent reply other threads:[~2023-05-29 13:07 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <CGME20230526103158eucas1p1e8b2adfc43aaf57c62e23e78571df817@eucas1p1.samsung.com> 2023-05-26 10:31 ` Dawid Kozinski 2023-05-29 13:07 ` James Almer [this message] 2023-06-07 13:36 ` Dawid Kozinski/Multimedia (PLT) /SRPOL/Staff Engineer/Samsung Electronics 2023-06-07 13:39 ` James Almer 2023-06-07 15:41 ` Dawid Kozinski/Multimedia (PLT) /SRPOL/Staff Engineer/Samsung Electronics 2023-06-07 16:30 ` Dawid Kozinski/Multimedia (PLT) /SRPOL/Staff Engineer/Samsung Electronics 2023-06-07 16:37 ` James Almer 2023-06-07 22:11 ` Dawid Kozinski/Multimedia (PLT) /SRPOL/Staff Engineer/Samsung Electronics
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=60cedee7-fe0e-8764-42d5-241875adaab5@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