Please don't use "initial implementation", it's either done or not done ;)
On Fri, Oct 9, 2015 at 4:26 PM, Luca Barbato <[email protected]> wrote: > --- > libavcodec/Makefile | 1 + > libavcodec/allcodecs.c | 1 + > libavcodec/avcodec.h | 1 + > libavcodec/codec_desc.c | 7 ++++ > libavcodec/wrapped_avframe.c | 94 > ++++++++++++++++++++++++++++++++++++++++++++ > 5 files changed, 104 insertions(+) > create mode 100644 libavcodec/wrapped_avframe.c needs version bump > diff --git a/libavcodec/wrapped_avframe.c b/libavcodec/wrapped_avframe.c > new file mode 100644 > index 0000000..527ddda > --- /dev/null > +++ b/libavcodec/wrapped_avframe.c > +static av_cold int wrapped_avframe_encode_init(AVCodecContext *avctx) > +{ > + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); desc can be NULL, check it and maybe report AVERROR_BUG > + > +#if FF_API_CODED_FRAME > +FF_DISABLE_DEPRECATION_WARNINGS > + avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; > + avctx->coded_frame->key_frame = 1; > +FF_ENABLE_DEPRECATION_WARNINGS > +#endif nope nope nope > + avctx->bits_per_coded_sample = av_get_bits_per_pixel(desc); Is this initialization needed? > + > + return 0; > +} > + > +static void wrapped_avframe_release_buffer(void *unused, uint8_t *data) > +{ > + AVFrame *frame = (AVFrame *)data; > + > + av_frame_free(&frame); > +} > + > +static int wrapped_avframe_encode(AVCodecContext *avctx, AVPacket *pkt, > + const AVFrame *frame, int *got_packet) > +{ > + AVFrame *wrapped = av_frame_alloc(); > + int ret; > + > + if (!wrapped) > + return AVERROR(ENOMEM); > + > + stray line > + ret = av_frame_ref(wrapped, frame); > + if (ret < 0) > + return ret; > + > + pkt->buf = av_buffer_create((uint8_t *)wrapped, sizeof(wrapped), > + wrapped_avframe_release_buffer, NULL, > + AV_BUFFER_FLAG_READONLY); > + if (!pkt->buf) { > + av_frame_free(&wrapped); > + return AVERROR(ENOMEM); > + } > + > + pkt->data = (uint8_t *)wrapped; > + pkt->size = sizeof(wrapped); > + > + pkt->flags |= AV_PKT_FLAG_KEY; > + *got_packet = 1; > + return 0; > +} > + > +AVCodec ff_wrapped_avframe_encoder = { > + .name = "wrapped_avframe", > + .long_name = NULL_IF_CONFIG_SMALL("AVFrame to AVPacket > passthrough"), > + .type = AVMEDIA_TYPE_VIDEO, > + .id = AV_CODEC_ID_WRAPPED_AVFRAME, > + .init = wrapped_avframe_encode_init, > + .encode2 = wrapped_avframe_encode, needs caps_internal for init thread safety ;) very nice overall Vittorio _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
