[FFmpeg-devel] [PATCH 1/4] avcodec/bitpacked_enc: add support for uyvy422 encoding
Lance Wang
lance.lmwang at gmail.com
Mon May 8 04:29:15 EEST 2023
On Mon, May 8, 2023 at 6:56 AM James Almer <jamrial at gmail.com> wrote:
> On 5/7/2023 4:00 AM, Lance Wang wrote:
> > On Sun, May 7, 2023 at 1:38 AM James Almer <jamrial at gmail.com> wrote:
> >
> >> Signed-off-by: James Almer <jamrial at gmail.com>
> >> ---
> >> libavcodec/bitpacked_enc.c | 27 ++++++++++++++++++++++++++-
> >> 1 file changed, 26 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/libavcodec/bitpacked_enc.c b/libavcodec/bitpacked_enc.c
> >> index 3c4e11293d..cbca38006b 100644
> >> --- a/libavcodec/bitpacked_enc.c
> >> +++ b/libavcodec/bitpacked_enc.c
> >> @@ -25,12 +25,36 @@
> >> #include "encode.h"
> >> #include "internal.h"
> >> #include "put_bits.h"
> >> +#include "libavutil/imgutils.h"
> >> #include "libavutil/pixdesc.h"
> >>
> >> struct BitpackedContext {
> >> int (*encode)(AVCodecContext *avctx, AVPacket *pkt, const AVFrame
> >> *frame);
> >> };
> >>
> >> +static int encode_uyvy422(AVCodecContext *avctx, AVPacket *pkt, const
> >> AVFrame *frame)
> >> +{
> >> + int ret = av_image_get_buffer_size(frame->format,
> >> + frame->width, frame->height, 1);
> >> +
> >> + if (ret < 0)
> >> + return ret;
> >> +
> >> + ret = ff_get_encode_buffer(avctx, pkt, ret, 0);
> >> + if (ret < 0)
> >> + return ret;
> >> +
> >> + ret = av_image_copy_to_buffer(pkt->data, pkt->size,
> >> + (const uint8_t **)frame->data,
> >> frame->linesize,
> >> + frame->format,
> >> + frame->width, frame->height, 1);
> >> +
> >> + if (ret < 0)
> >> + return ret;
> >> +
> >> + return 0;
> >> +}
> >> +
> >>
> >
> >
> > I prefer to bitpack will used for 10-bit 4:2:2 packed format. uyvy422
> > should use rawvideo as it'll passthrough directly.
>
> I'm not sure i follow. The rawvideo encoder will do exactly the same
> thing I'm doing here.
>
> Are you maybe talking about patch 3/4?
>
The old rtpdec_rfc4175 use bitpack with rawvideo for uyvy422 and I have
changed to
used rawvideo directly. For I think bitpacked is better to use for 10-bit
4:2:2 packed format.
However I haven't removed the old uyvy422 decode code in 3/4 for I'm not
sure whether
it'll break any ABI for old avformat.
> >
> >
> > static int encode_yuv422p10(AVCodecContext *avctx, AVPacket *pkt, const
> >> AVFrame *frame)
> >> {
> >> const int buf_size = avctx->height * avctx->width *
> >> avctx->bits_per_coded_sample / 8;
> >> @@ -85,7 +109,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
> >> if (avctx->pix_fmt == AV_PIX_FMT_YUV422P10)
> >> s->encode = encode_yuv422p10;
> >> else
> >> - return AVERROR(EINVAL);
> >> + s->encode = encode_uyvy422;
> >>
> >> return 0;
> >> }
> >> @@ -115,5 +139,6 @@ const FFCodec ff_bitpacked_encoder = {
> >> .init = encode_init,
> >> FF_CODEC_ENCODE_CB(encode_frame),
> >> .p.pix_fmts = (const enum AVPixelFormat[]){
> AV_PIX_FMT_YUV422P10,
> >> + AV_PIX_FMT_UYVY422,
> >> AV_PIX_FMT_NONE },
> >> };
> >> --
> >> 2.40.1
> >>
> >> _______________________________________________
> >> ffmpeg-devel mailing list
> >> ffmpeg-devel at ffmpeg.org
> >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >>
> >> To unsubscribe, visit link above, or email
> >> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
> >>
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel at ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>
More information about the ffmpeg-devel
mailing list