From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH] add media100 bsf and use it Date: Tue, 31 Jan 2023 12:20:21 +0100 Message-ID: <GV1P250MB0737D7E043DDFEAB07A903AA8FD09@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM> (raw) In-Reply-To: <CAPYw7P5-MfOkHnnxaQa5DLtx_hRSEg4ACafrbGPUjTBr0ZsS8w@mail.gmail.com> Paul B Mahol: > -static int media100_decode_frame(AVCodecContext *avctx, > - AVFrame *frame, int *got_frame, > - AVPacket *avpkt) > +static int filter(AVBSFContext *ctx, AVPacket *avpkt) > { > - Media100Context *ctx = avctx->priv_data; > + Media100Context *s = ctx->priv_data; > unsigned second_field_offset = 0; > unsigned next_field = 0; > unsigned dht_offset[2]; > @@ -83,18 +62,20 @@ static int media100_decode_frame(AVCodecContext *avctx, > AVPacket *pkt; > int ret; > > - if (avpkt->size + 1024 > ctx->pkt->size) { > - ret = av_grow_packet(ctx->pkt, avpkt->size + 1024 - ctx->pkt->size); > - if (ret < 0) > - return ret; > - } > + ret = ff_bsf_get_packet_ref(ctx, avpkt); The avpkt here is destined for output; you should use s->pkt to get the new input packet. This will allow to avoid the av_packet_move_ref() below. > + if (ret < 0) > + return ret; > > - ret = av_packet_make_writable(ctx->pkt); > + ret = av_new_packet(s->pkt, avpkt->size + 1024); > + if (ret < 0) > + return ret; > + > + ret = av_packet_make_writable(s->pkt); av_new_packet() always returns writable packets. > if (ret < 0) > return ret; > > bytestream2_init(&gb, avpkt->data, avpkt->size); > - bytestream2_init_writer(&pb, ctx->pkt->data, ctx->pkt->size); > + bytestream2_init_writer(&pb, s->pkt->data, s->pkt->size); > > second_field: > bytestream2_put_be32(&pb, 0); > @@ -107,8 +88,8 @@ second_field: > sof_offset[field] = bytestream2_tell_p(&pb); > bytestream2_put_be16(&pb, 17); > bytestream2_put_byte(&pb, 8); > - bytestream2_put_be16(&pb, avctx->height / 2); > - bytestream2_put_be16(&pb, avctx->width); > + bytestream2_put_be16(&pb, ctx->par_in->height / 2); > + bytestream2_put_be16(&pb, ctx->par_in->width); > bytestream2_put_byte(&pb, 3); > bytestream2_put_byte(&pb, 1); > bytestream2_put_byte(&pb, 0x21); > @@ -164,7 +145,7 @@ second_field: > goto second_field; > } > > - pkt = ctx->pkt; > + pkt = s->pkt; > > AV_WB32(pkt->data + 8, second_field_offset); > AV_WB32(pkt->data + 12, second_field_offset); > @@ -186,40 +167,33 @@ second_field: > > pkt->size = bytestream2_tell_p(&pb); > > - ret = avcodec_send_packet(ctx->avctx, pkt); > - if (ret < 0) { > - av_log(avctx, AV_LOG_ERROR, "Error submitting a packet for decoding\n"); > - return ret; > - } > + av_packet_copy_props(pkt, avpkt); > + av_packet_unref(avpkt); > + av_packet_move_ref(avpkt, s->pkt); > > - ret = avcodec_receive_frame(ctx->avctx, frame); > - if (ret < 0) > - return ret; > + 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".
next prev parent reply other threads:[~2023-01-31 11:20 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-01-31 10:18 Paul B Mahol 2023-01-31 11:20 ` Andreas Rheinhardt [this message] 2023-01-31 12:48 ` Anton Khirnov 2023-01-31 15:33 ` Paul B Mahol
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=GV1P250MB0737D7E043DDFEAB07A903AA8FD09@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM \ --to=andreas.rheinhardt@outlook.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