Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/4] avcodec/bitpacked_enc: add support for uyvy422 encoding
@ 2023-05-06 17:37 James Almer
  2023-05-06 17:37 ` [FFmpeg-devel] [PATCH 2/4] avcodec/bitpacked_dec: add missing props to decoded uyvy422 streams James Almer
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: James Almer @ 2023-05-06 17:37 UTC (permalink / raw)
  To: ffmpeg-devel

Signed-off-by: James Almer <jamrial@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;
+}
+
 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@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-05-08  1:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-06 17:37 [FFmpeg-devel] [PATCH 1/4] avcodec/bitpacked_enc: add support for uyvy422 encoding James Almer
2023-05-06 17:37 ` [FFmpeg-devel] [PATCH 2/4] avcodec/bitpacked_dec: add missing props to decoded uyvy422 streams James Almer
2023-05-06 17:37 ` [FFmpeg-devel] [PATCH 3/4] aformat/rawvideodec: don't force the rawvideo decoder for uyvy422 bitpacked streams James Almer
2023-05-06 17:37 ` [FFmpeg-devel] [PATCH 4/4] fate/vcodec: add bitpacked tests James Almer
2023-05-07  7:00 ` [FFmpeg-devel] [PATCH 1/4] avcodec/bitpacked_enc: add support for uyvy422 encoding Lance Wang
2023-05-07 22:56   ` James Almer
2023-05-08  1:29     ` Lance Wang

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