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

* [FFmpeg-devel] [PATCH 2/4] avcodec/bitpacked_dec: add missing props to decoded uyvy422 streams
  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 ` 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
                   ` (2 subsequent siblings)
  3 siblings, 0 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_dec.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/libavcodec/bitpacked_dec.c b/libavcodec/bitpacked_dec.c
index c88f861993..064cc29e7a 100644
--- a/libavcodec/bitpacked_dec.c
+++ b/libavcodec/bitpacked_dec.c
@@ -27,6 +27,7 @@
  */
 
 #include "avcodec.h"
+#include "decode.h"
 #include "codec_internal.h"
 #include "get_bits.h"
 #include "libavutil/imgutils.h"
@@ -43,6 +44,12 @@ static int bitpacked_decode_uyvy422(AVCodecContext *avctx, AVFrame *frame,
 {
     int ret;
 
+    frame->width = avctx->width;
+    frame->height = avctx->height;
+    ret = ff_decode_frame_props(avctx, frame);
+    if (ret < 0)
+        return ret;
+
     /* there is no need to copy as the data already match
      * a known pixel format */
     frame->buf[0] = av_buffer_ref(avpkt->buf);
-- 
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

* [FFmpeg-devel] [PATCH 3/4] aformat/rawvideodec: don't force the rawvideo decoder for uyvy422 bitpacked streams
  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 ` 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
  3 siblings, 0 replies; 7+ messages in thread
From: James Almer @ 2023-05-06 17:37 UTC (permalink / raw)
  To: ffmpeg-devel

The bitpacked decoder can handle it.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/rawvideodec.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavformat/rawvideodec.c b/libavformat/rawvideodec.c
index 514e4e044f..d58e54ce24 100644
--- a/libavformat/rawvideodec.c
+++ b/libavformat/rawvideodec.c
@@ -88,7 +88,6 @@ static int rawvideo_read_header(AVFormatContext *ctx)
             tag = MKTAG('U', 'Y', 'V', 'Y');
             pgroup = 4;
             xinc   = 2;
-            st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
         } else {
             av_log(ctx, AV_LOG_ERROR, "unsupported format: %s for bitpacked.\n",
                     s->pixel_format);
-- 
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

* [FFmpeg-devel] [PATCH 4/4] fate/vcodec: add bitpacked tests
  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 ` James Almer
  2023-05-07  7:00 ` [FFmpeg-devel] [PATCH 1/4] avcodec/bitpacked_enc: add support for uyvy422 encoding Lance Wang
  3 siblings, 0 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>
---
 tests/fate/vcodec.mak                              | 13 ++++++++++++-
 tests/ref/vsynth/vsynth1-bitpacked-uyvy422         |  4 ++++
 tests/ref/vsynth/vsynth1-bitpacked-yuv422p10le     |  4 ++++
 tests/ref/vsynth/vsynth2-bitpacked-uyvy422         |  4 ++++
 tests/ref/vsynth/vsynth2-bitpacked-yuv422p10le     |  4 ++++
 tests/ref/vsynth/vsynth3-bitpacked-uyvy422         |  4 ++++
 tests/ref/vsynth/vsynth3-bitpacked-yuv422p10le     |  4 ++++
 tests/ref/vsynth/vsynth_lena-bitpacked-uyvy422     |  4 ++++
 tests/ref/vsynth/vsynth_lena-bitpacked-yuv422p10le |  4 ++++
 9 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 tests/ref/vsynth/vsynth1-bitpacked-uyvy422
 create mode 100644 tests/ref/vsynth/vsynth1-bitpacked-yuv422p10le
 create mode 100644 tests/ref/vsynth/vsynth2-bitpacked-uyvy422
 create mode 100644 tests/ref/vsynth/vsynth2-bitpacked-yuv422p10le
 create mode 100644 tests/ref/vsynth/vsynth3-bitpacked-uyvy422
 create mode 100644 tests/ref/vsynth/vsynth3-bitpacked-yuv422p10le
 create mode 100644 tests/ref/vsynth/vsynth_lena-bitpacked-uyvy422
 create mode 100644 tests/ref/vsynth/vsynth_lena-bitpacked-yuv422p10le

diff --git a/tests/fate/vcodec.mak b/tests/fate/vcodec.mak
index fbee264a9d..e0a5f541f6 100644
--- a/tests/fate/vcodec.mak
+++ b/tests/fate/vcodec.mak
@@ -6,7 +6,7 @@ fate-vsynth%: CODEC = $(word 3, $(subst -, ,$(@)))
 fate-vsynth%: FMT = avi
 fate-vsynth%: DEFAULT_SIZE = -s 352x288
 fate-vsynth3-%: DEFAULT_SIZE = -s $(FATEW)x$(FATEH)
-fate-vsynth%: CMD = enc_dec "rawvideo $(DEFAULT_SIZE) -pix_fmt yuv420p $(RAWDECOPTS)" $(SRC) $(FMT) "-c $(CODEC) $(ENCOPTS)" rawvideo "-pix_fmt yuv420p -vsync passthrough $(DECOPTS)" "" "" ${TWOPASS}
+fate-vsynth%: CMD = enc_dec "rawvideo $(DEFAULT_SIZE) -pix_fmt yuv420p $(RAWDECOPTS)" $(SRC) $(FMT) "-c $(CODEC) $(ENCOPTS)" rawvideo "-pix_fmt yuv420p -vsync passthrough $(DECOPTS)" "$(DECOPTSIN)" "" ${TWOPASS}
 fate-vsynth%: CMP_UNIT = 1
 fate-vsynth%: REF = $(SRC_PATH)/tests/ref/vsynth/$(@:fate-%=%)
 
@@ -19,6 +19,17 @@ fate-vsynth%-asv1:               ENCOPTS = -qscale 10
 FATE_VCODEC-$(call ENCDEC, ASV2, AVI)   += asv2
 fate-vsynth%-asv2:               ENCOPTS = -qscale 10
 
+FATE_VCODEC-$(call ENCDEC, BITPACKED, IMAGE2 BITPACKED) += bitpacked-yuv422p10le bitpacked-uyvy422
+fate-vsynth%-bitpacked-yuv422p10le:   FMT = image2
+fate-vsynth%-bitpacked-yuv422p10le:   ENCOPTS = -frames 1 -sws_flags neighbor+bitexact -pix_fmt yuv422p10le
+fate-vsynth%-bitpacked-yuv422p10le:   DECOPTSIN = -f bitpacked $(DEFAULT_SIZE) -pix_fmt yuv422p10le
+fate-vsynth%-bitpacked-yuv422p10le:   DECOPTS = -sws_flags neighbor+bitexact
+
+fate-vsynth%-bitpacked-uyvy422:       FMT = image2
+fate-vsynth%-bitpacked-uyvy422:       ENCOPTS = -frames 1 -sws_flags neighbor+bitexact -pix_fmt uyvy422
+fate-vsynth%-bitpacked-uyvy422:       DECOPTSIN = -f bitpacked $(DEFAULT_SIZE) -pix_fmt uyvy422
+fate-vsynth%-bitpacked-uyvy422:       DECOPTS = -sws_flags neighbor+bitexact
+
 FATE_VCODEC_SCALE-$(call ENCDEC, CINEPAK, AVI) += cinepak
 fate-vsynth%-cinepak:            ENCOPTS = -s sqcif -strip_number_adaptivity 1
 
diff --git a/tests/ref/vsynth/vsynth1-bitpacked-uyvy422 b/tests/ref/vsynth/vsynth1-bitpacked-uyvy422
new file mode 100644
index 0000000000..af6291f205
--- /dev/null
+++ b/tests/ref/vsynth/vsynth1-bitpacked-uyvy422
@@ -0,0 +1,4 @@
+3cc44d70e515c5a767a11fe67b89bc45 *tests/data/fate/vsynth1-bitpacked-uyvy422.image2
+202752 tests/data/fate/vsynth1-bitpacked-uyvy422.image2
+32d8f3223cda1cec632c0f3ca5b2e037 *tests/data/fate/vsynth1-bitpacked-uyvy422.out.rawvideo
+stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  7603200/   152064
diff --git a/tests/ref/vsynth/vsynth1-bitpacked-yuv422p10le b/tests/ref/vsynth/vsynth1-bitpacked-yuv422p10le
new file mode 100644
index 0000000000..ee77b98b2a
--- /dev/null
+++ b/tests/ref/vsynth/vsynth1-bitpacked-yuv422p10le
@@ -0,0 +1,4 @@
+a2c5c43e4afa7b14bae65da26b98952c *tests/data/fate/vsynth1-bitpacked-yuv422p10le.image2
+253440 tests/data/fate/vsynth1-bitpacked-yuv422p10le.image2
+32d8f3223cda1cec632c0f3ca5b2e037 *tests/data/fate/vsynth1-bitpacked-yuv422p10le.out.rawvideo
+stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  7603200/   152064
diff --git a/tests/ref/vsynth/vsynth2-bitpacked-uyvy422 b/tests/ref/vsynth/vsynth2-bitpacked-uyvy422
new file mode 100644
index 0000000000..9abde4493e
--- /dev/null
+++ b/tests/ref/vsynth/vsynth2-bitpacked-uyvy422
@@ -0,0 +1,4 @@
+82b63ef3911ec62a5e48c3b94d061c85 *tests/data/fate/vsynth2-bitpacked-uyvy422.image2
+202752 tests/data/fate/vsynth2-bitpacked-uyvy422.image2
+38c45025d01438c3da880c520827420a *tests/data/fate/vsynth2-bitpacked-uyvy422.out.rawvideo
+stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  7603200/   152064
diff --git a/tests/ref/vsynth/vsynth2-bitpacked-yuv422p10le b/tests/ref/vsynth/vsynth2-bitpacked-yuv422p10le
new file mode 100644
index 0000000000..647c1ed4e6
--- /dev/null
+++ b/tests/ref/vsynth/vsynth2-bitpacked-yuv422p10le
@@ -0,0 +1,4 @@
+a4202e285ad3667dddb0722b327f01cb *tests/data/fate/vsynth2-bitpacked-yuv422p10le.image2
+253440 tests/data/fate/vsynth2-bitpacked-yuv422p10le.image2
+38c45025d01438c3da880c520827420a *tests/data/fate/vsynth2-bitpacked-yuv422p10le.out.rawvideo
+stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  7603200/   152064
diff --git a/tests/ref/vsynth/vsynth3-bitpacked-uyvy422 b/tests/ref/vsynth/vsynth3-bitpacked-uyvy422
new file mode 100644
index 0000000000..0b703370d3
--- /dev/null
+++ b/tests/ref/vsynth/vsynth3-bitpacked-uyvy422
@@ -0,0 +1,4 @@
+f687e1f38ddb711942ad70dc3bfdb11e *tests/data/fate/vsynth3-bitpacked-uyvy422.image2
+2312 tests/data/fate/vsynth3-bitpacked-uyvy422.image2
+ce92e2b6c27f51aec06bb96adbb33a42 *tests/data/fate/vsynth3-bitpacked-uyvy422.out.rawvideo
+stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:    86700/     1734
diff --git a/tests/ref/vsynth/vsynth3-bitpacked-yuv422p10le b/tests/ref/vsynth/vsynth3-bitpacked-yuv422p10le
new file mode 100644
index 0000000000..e7b2dc6ab4
--- /dev/null
+++ b/tests/ref/vsynth/vsynth3-bitpacked-yuv422p10le
@@ -0,0 +1,4 @@
+544274ad9b88f3055bd6bba521d12d2e *tests/data/fate/vsynth3-bitpacked-yuv422p10le.image2
+2890 tests/data/fate/vsynth3-bitpacked-yuv422p10le.image2
+ce92e2b6c27f51aec06bb96adbb33a42 *tests/data/fate/vsynth3-bitpacked-yuv422p10le.out.rawvideo
+stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:    86700/     1734
diff --git a/tests/ref/vsynth/vsynth_lena-bitpacked-uyvy422 b/tests/ref/vsynth/vsynth_lena-bitpacked-uyvy422
new file mode 100644
index 0000000000..ab5a15e1d2
--- /dev/null
+++ b/tests/ref/vsynth/vsynth_lena-bitpacked-uyvy422
@@ -0,0 +1,4 @@
+987c552e5f73e14dcae5ff7f917ceebd *tests/data/fate/vsynth_lena-bitpacked-uyvy422.image2
+202752 tests/data/fate/vsynth_lena-bitpacked-uyvy422.image2
+64ffa0d5a62ddf325a92195fda238dd4 *tests/data/fate/vsynth_lena-bitpacked-uyvy422.out.rawvideo
+stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  7603200/   152064
diff --git a/tests/ref/vsynth/vsynth_lena-bitpacked-yuv422p10le b/tests/ref/vsynth/vsynth_lena-bitpacked-yuv422p10le
new file mode 100644
index 0000000000..e5447e0d9f
--- /dev/null
+++ b/tests/ref/vsynth/vsynth_lena-bitpacked-yuv422p10le
@@ -0,0 +1,4 @@
+530fe0ec23e7c4165f550fa12b831901 *tests/data/fate/vsynth_lena-bitpacked-yuv422p10le.image2
+253440 tests/data/fate/vsynth_lena-bitpacked-yuv422p10le.image2
+64ffa0d5a62ddf325a92195fda238dd4 *tests/data/fate/vsynth_lena-bitpacked-yuv422p10le.out.rawvideo
+stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  7603200/   152064
-- 
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

* Re: [FFmpeg-devel] [PATCH 1/4] avcodec/bitpacked_enc: add support for uyvy422 encoding
  2023-05-06 17:37 [FFmpeg-devel] [PATCH 1/4] avcodec/bitpacked_enc: add support for uyvy422 encoding James Almer
                   ` (2 preceding siblings ...)
  2023-05-06 17:37 ` [FFmpeg-devel] [PATCH 4/4] fate/vcodec: add bitpacked tests James Almer
@ 2023-05-07  7:00 ` Lance Wang
  2023-05-07 22:56   ` James Almer
  3 siblings, 1 reply; 7+ messages in thread
From: Lance Wang @ 2023-05-07  7:00 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Sun, May 7, 2023 at 1:38 AM James Almer <jamrial@gmail.com> wrote:

> 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;
> +}
> +
>


I prefer to bitpack will used for 10-bit 4:2:2 packed format.  uyvy422
should use rawvideo as it'll passthrough directly.


 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".
>
_______________________________________________
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

* Re: [FFmpeg-devel] [PATCH 1/4] avcodec/bitpacked_enc: add support for uyvy422 encoding
  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
  0 siblings, 1 reply; 7+ messages in thread
From: James Almer @ 2023-05-07 22:56 UTC (permalink / raw)
  To: ffmpeg-devel

On 5/7/2023 4:00 AM, Lance Wang wrote:
> On Sun, May 7, 2023 at 1:38 AM James Almer <jamrial@gmail.com> wrote:
> 
>> 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;
>> +}
>> +
>>
> 
> 
> 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?

> 
> 
>   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".
>>
> _______________________________________________
> 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".
_______________________________________________
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

* Re: [FFmpeg-devel] [PATCH 1/4] avcodec/bitpacked_enc: add support for uyvy422 encoding
  2023-05-07 22:56   ` James Almer
@ 2023-05-08  1:29     ` Lance Wang
  0 siblings, 0 replies; 7+ messages in thread
From: Lance Wang @ 2023-05-08  1:29 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Mon, May 8, 2023 at 6:56 AM James Almer <jamrial@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@gmail.com> wrote:
> >
> >> 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;
> >> +}
> >> +
> >>
> >
> >
> > 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@ffmpeg.org
> >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >>
> >> To unsubscribe, visit link above, or email
> >> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> >>
> > _______________________________________________
> > 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".
> _______________________________________________
> 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".
>
_______________________________________________
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