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-requ...@ffmpeg.org with subject "unsubscribe".