* [FFmpeg-devel] [PATCH 01/10] lavc/videotoolboxenc: use common routine for pixfmt conversion
2021-12-17 0:12 [FFmpeg-devel] lavc/videotoolboxenc: add ProRes support rcombs
@ 2021-12-17 0:12 ` rcombs
2021-12-17 0:12 ` [FFmpeg-devel] [PATCH 02/10] lavc/videotoolboxenc: don't access int64_t member as int rcombs
` (9 subsequent siblings)
10 siblings, 0 replies; 16+ messages in thread
From: rcombs @ 2021-12-17 0:12 UTC (permalink / raw)
To: ffmpeg-devel
---
libavcodec/videotoolboxenc.c | 21 +++------------------
1 file changed, 3 insertions(+), 18 deletions(-)
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index ebaa3ebdc8..1e7c164a97 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -29,6 +29,7 @@
#include "libavutil/avstring.h"
#include "libavcodec/avcodec.h"
#include "libavutil/pixdesc.h"
+#include "libavutil/hwcontext_videotoolbox.h"
#include "internal.h"
#include <pthread.h>
#include "atsc_a53.h"
@@ -797,25 +798,9 @@ static int get_cv_pixel_format(AVCodecContext* avctx,
range != AVCOL_RANGE_JPEG;
//MPEG range is used when no range is set
- if (fmt == AV_PIX_FMT_NV12) {
- *av_pixel_format = range == AVCOL_RANGE_JPEG ?
- kCVPixelFormatType_420YpCbCr8BiPlanarFullRange :
- kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange;
- } else if (fmt == AV_PIX_FMT_YUV420P) {
- *av_pixel_format = range == AVCOL_RANGE_JPEG ?
- kCVPixelFormatType_420YpCbCr8PlanarFullRange :
- kCVPixelFormatType_420YpCbCr8Planar;
- } else if (fmt == AV_PIX_FMT_BGRA) {
- *av_pixel_format = kCVPixelFormatType_32BGRA;
- } else if (fmt == AV_PIX_FMT_P010LE) {
- *av_pixel_format = range == AVCOL_RANGE_JPEG ?
- kCVPixelFormatType_420YpCbCr10BiPlanarFullRange :
- kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange;
- } else {
- return AVERROR(EINVAL);
- }
+ *av_pixel_format = av_map_videotoolbox_format_from_pixfmt2(fmt, range == AVCOL_RANGE_JPEG);
- return 0;
+ return *av_pixel_format ? 0 : AVERROR(EINVAL);
}
static void add_color_attr(AVCodecContext *avctx, CFMutableDictionaryRef dict) {
--
2.33.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] 16+ messages in thread
* [FFmpeg-devel] [PATCH 02/10] lavc/videotoolboxenc: don't access int64_t member as int
2021-12-17 0:12 [FFmpeg-devel] lavc/videotoolboxenc: add ProRes support rcombs
2021-12-17 0:12 ` [FFmpeg-devel] [PATCH 01/10] lavc/videotoolboxenc: use common routine for pixfmt conversion rcombs
@ 2021-12-17 0:12 ` rcombs
2021-12-17 0:12 ` [FFmpeg-devel] [PATCH 03/10] lavc/videotoolboxenc: detect alpha more generically rcombs
` (8 subsequent siblings)
10 siblings, 0 replies; 16+ messages in thread
From: rcombs @ 2021-12-17 0:12 UTC (permalink / raw)
To: ffmpeg-devel
---
libavcodec/videotoolboxenc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 1e7c164a97..9857e55fdc 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -2618,7 +2618,7 @@ static const enum AVPixelFormat hevc_pix_fmts[] = {
#define OFFSET(x) offsetof(VTEncContext, x)
static const AVOption h264_options[] = {
- { "profile", "Profile", OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = H264_PROF_AUTO }, H264_PROF_AUTO, H264_PROF_COUNT, VE, "profile" },
+ { "profile", "Profile", OFFSET(profile), AV_OPT_TYPE_INT64, { .i64 = H264_PROF_AUTO }, H264_PROF_AUTO, H264_PROF_COUNT, VE, "profile" },
{ "baseline", "Baseline Profile", 0, AV_OPT_TYPE_CONST, { .i64 = H264_PROF_BASELINE }, INT_MIN, INT_MAX, VE, "profile" },
{ "main", "Main Profile", 0, AV_OPT_TYPE_CONST, { .i64 = H264_PROF_MAIN }, INT_MIN, INT_MAX, VE, "profile" },
{ "high", "High Profile", 0, AV_OPT_TYPE_CONST, { .i64 = H264_PROF_HIGH }, INT_MIN, INT_MAX, VE, "profile" },
@@ -2672,7 +2672,7 @@ const AVCodec ff_h264_videotoolbox_encoder = {
};
static const AVOption hevc_options[] = {
- { "profile", "Profile", OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = HEVC_PROF_AUTO }, HEVC_PROF_AUTO, HEVC_PROF_COUNT, VE, "profile" },
+ { "profile", "Profile", OFFSET(profile), AV_OPT_TYPE_INT64, { .i64 = HEVC_PROF_AUTO }, HEVC_PROF_AUTO, HEVC_PROF_COUNT, VE, "profile" },
{ "main", "Main Profile", 0, AV_OPT_TYPE_CONST, { .i64 = HEVC_PROF_MAIN }, INT_MIN, INT_MAX, VE, "profile" },
{ "main10", "Main10 Profile", 0, AV_OPT_TYPE_CONST, { .i64 = HEVC_PROF_MAIN10 }, INT_MIN, INT_MAX, VE, "profile" },
--
2.33.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] 16+ messages in thread
* [FFmpeg-devel] [PATCH 03/10] lavc/videotoolboxenc: detect alpha more generically
2021-12-17 0:12 [FFmpeg-devel] lavc/videotoolboxenc: add ProRes support rcombs
2021-12-17 0:12 ` [FFmpeg-devel] [PATCH 01/10] lavc/videotoolboxenc: use common routine for pixfmt conversion rcombs
2021-12-17 0:12 ` [FFmpeg-devel] [PATCH 02/10] lavc/videotoolboxenc: don't access int64_t member as int rcombs
@ 2021-12-17 0:12 ` rcombs
2021-12-17 0:12 ` [FFmpeg-devel] [PATCH 04/10] lavc/videotoolboxenc: fix RGB support rcombs
` (7 subsequent siblings)
10 siblings, 0 replies; 16+ messages in thread
From: rcombs @ 2021-12-17 0:12 UTC (permalink / raw)
To: ffmpeg-devel
Fixes support for alpha in hardware input frames
---
libavcodec/videotoolboxenc.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 9857e55fdc..fa8f717a6c 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -406,14 +406,14 @@ static int count_nalus(size_t length_code_size,
return 0;
}
-static CMVideoCodecType get_cm_codec_type(enum AVCodecID id,
- enum AVPixelFormat fmt,
+static CMVideoCodecType get_cm_codec_type(AVCodecContext *avctx,
double alpha_quality)
{
- switch (id) {
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt == AV_PIX_FMT_VIDEOTOOLBOX ? avctx->sw_pix_fmt : avctx->pix_fmt);
+ switch (avctx->codec_id) {
case AV_CODEC_ID_H264: return kCMVideoCodecType_H264;
case AV_CODEC_ID_HEVC:
- if (fmt == AV_PIX_FMT_BGRA && alpha_quality > 0.0) {
+ if (desc && (desc->flags & AV_PIX_FMT_FLAG_ALPHA) && alpha_quality > 0.0) {
return kCMVideoCodecType_HEVCWithAlpha;
}
return kCMVideoCodecType_HEVC;
@@ -1376,7 +1376,7 @@ static int vtenc_configure_encoder(AVCodecContext *avctx)
CFNumberRef gamma_level = NULL;
int status;
- codec_type = get_cm_codec_type(avctx->codec_id, avctx->pix_fmt, vtctx->alpha_quality);
+ codec_type = get_cm_codec_type(avctx, vtctx->alpha_quality);
if (!codec_type) {
av_log(avctx, AV_LOG_ERROR, "Error: no mapping for AVCodecID %d\n", avctx->codec_id);
return AVERROR(EINVAL);
--
2.33.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] 16+ messages in thread
* [FFmpeg-devel] [PATCH 04/10] lavc/videotoolboxenc: fix RGB support
2021-12-17 0:12 [FFmpeg-devel] lavc/videotoolboxenc: add ProRes support rcombs
` (2 preceding siblings ...)
2021-12-17 0:12 ` [FFmpeg-devel] [PATCH 03/10] lavc/videotoolboxenc: detect alpha more generically rcombs
@ 2021-12-17 0:12 ` rcombs
2021-12-19 16:18 ` Rick Kern
2021-12-17 0:12 ` [FFmpeg-devel] [PATCH 05/10] lavc/videotoolboxenc: config-gate ATSC CC support rcombs
` (6 subsequent siblings)
10 siblings, 1 reply; 16+ messages in thread
From: rcombs @ 2021-12-17 0:12 UTC (permalink / raw)
To: ffmpeg-devel
---
libavcodec/videotoolboxenc.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index fa8f717a6c..e10373dded 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -1012,6 +1012,9 @@ static int get_cv_ycbcr_matrix(AVCodecContext *avctx, CFStringRef *matrix) {
*matrix = compat_keys.kCVImageBufferYCbCrMatrix_ITU_R_2020;
break;
+ case AVCOL_SPC_RGB:
+ break;
+
default:
av_log(avctx, AV_LOG_ERROR, "Color space %s is not supported.\n", av_color_space_name(avctx->colorspace));
return -1;
--
2.33.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] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH 04/10] lavc/videotoolboxenc: fix RGB support
2021-12-17 0:12 ` [FFmpeg-devel] [PATCH 04/10] lavc/videotoolboxenc: fix RGB support rcombs
@ 2021-12-19 16:18 ` Rick Kern
0 siblings, 0 replies; 16+ messages in thread
From: Rick Kern @ 2021-12-19 16:18 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Thu, Dec 16, 2021 at 7:13 PM rcombs <rcombs@rcombs.me> wrote:
> ---
> libavcodec/videotoolboxenc.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index fa8f717a6c..e10373dded 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -1012,6 +1012,9 @@ static int get_cv_ycbcr_matrix(AVCodecContext
> *avctx, CFStringRef *matrix) {
> *matrix = compat_keys.kCVImageBufferYCbCrMatrix_ITU_R_2020;
> break;
>
> + case AVCOL_SPC_RGB:
>
It would be clearer to set the matrix to NULL here (like the
AVCOL_SPC_UNSPECIFIED case).
+ break;
> +
> default:
> av_log(avctx, AV_LOG_ERROR, "Color space %s is not
> supported.\n", av_color_space_name(avctx->colorspace));
> return -1;
> --
> 2.33.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] 16+ messages in thread
* [FFmpeg-devel] [PATCH 05/10] lavc/videotoolboxenc: config-gate ATSC CC support
2021-12-17 0:12 [FFmpeg-devel] lavc/videotoolboxenc: add ProRes support rcombs
` (3 preceding siblings ...)
2021-12-17 0:12 ` [FFmpeg-devel] [PATCH 04/10] lavc/videotoolboxenc: fix RGB support rcombs
@ 2021-12-17 0:12 ` rcombs
2021-12-17 0:12 ` [FFmpeg-devel] [PATCH 06/10] lavc/videotoolboxenc: vastly simplify get_cv_pixel_info rcombs
` (5 subsequent siblings)
10 siblings, 0 replies; 16+ messages in thread
From: rcombs @ 2021-12-17 0:12 UTC (permalink / raw)
To: ffmpeg-devel
---
libavcodec/videotoolboxenc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index e10373dded..b66d44f6b7 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -2363,6 +2363,7 @@ static int vtenc_send_frame(AVCodecContext *avctx,
return status;
}
+#if CONFIG_ATSC_A53
side_data = av_frame_get_side_data(frame, AV_FRAME_DATA_A53_CC);
if (vtctx->a53_cc && side_data && side_data->size) {
sei = av_mallocz(sizeof(*sei));
@@ -2377,6 +2378,7 @@ static int vtenc_send_frame(AVCodecContext *avctx,
}
}
}
+#endif
time = CMTimeMake(frame->pts * avctx->time_base.num, avctx->time_base.den);
status = VTCompressionSessionEncodeFrame(
--
2.33.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] 16+ messages in thread
* [FFmpeg-devel] [PATCH 06/10] lavc/videotoolboxenc: vastly simplify get_cv_pixel_info
2021-12-17 0:12 [FFmpeg-devel] lavc/videotoolboxenc: add ProRes support rcombs
` (4 preceding siblings ...)
2021-12-17 0:12 ` [FFmpeg-devel] [PATCH 05/10] lavc/videotoolboxenc: config-gate ATSC CC support rcombs
@ 2021-12-17 0:12 ` rcombs
2021-12-19 16:25 ` Rick Kern
2021-12-17 0:12 ` [FFmpeg-devel] [PATCH 07/10] lavc/videotoolboxenc: add handling for non-NAL-based codecs rcombs
` (4 subsequent siblings)
10 siblings, 1 reply; 16+ messages in thread
From: rcombs @ 2021-12-17 0:12 UTC (permalink / raw)
To: ffmpeg-devel
No longer requires per-format switch cases.
The frame==0 path was unused (and would've crashed anyway).
---
libavcodec/videotoolboxenc.c | 69 +++++++-----------------------------
1 file changed, 13 insertions(+), 56 deletions(-)
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index b66d44f6b7..82e01fbe29 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -2034,6 +2034,7 @@ static int get_cv_pixel_info(
size_t *strides,
size_t *contiguous_buf_size)
{
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
VTEncContext *vtctx = avctx->priv_data;
int av_format = frame->format;
int av_color_range = frame->color_range;
@@ -2041,6 +2042,9 @@ static int get_cv_pixel_info(
int range_guessed;
int status;
+ if (!desc)
+ return AVERROR(EINVAL);
+
status = get_cv_pixel_format(avctx, av_format, av_color_range, color, &range_guessed);
if (status) {
av_log(avctx,
@@ -2065,63 +2069,16 @@ static int get_cv_pixel_info(
}
}
- switch (av_format) {
- case AV_PIX_FMT_NV12:
- *plane_count = 2;
-
- widths [0] = avctx->width;
- heights[0] = avctx->height;
- strides[0] = frame ? frame->linesize[0] : avctx->width;
-
- widths [1] = (avctx->width + 1) / 2;
- heights[1] = (avctx->height + 1) / 2;
- strides[1] = frame ? frame->linesize[1] : (avctx->width + 1) & -2;
- break;
-
- case AV_PIX_FMT_YUV420P:
- *plane_count = 3;
-
- widths [0] = avctx->width;
- heights[0] = avctx->height;
- strides[0] = frame ? frame->linesize[0] : avctx->width;
-
- widths [1] = (avctx->width + 1) / 2;
- heights[1] = (avctx->height + 1) / 2;
- strides[1] = frame ? frame->linesize[1] : (avctx->width + 1) / 2;
-
- widths [2] = (avctx->width + 1) / 2;
- heights[2] = (avctx->height + 1) / 2;
- strides[2] = frame ? frame->linesize[2] : (avctx->width + 1) / 2;
- break;
+ *plane_count = av_pix_fmt_count_planes(avctx->pix_fmt);
- case AV_PIX_FMT_BGRA:
- *plane_count = 1;
-
- widths [0] = avctx->width;
- heights[0] = avctx->height;
- strides[0] = frame ? frame->linesize[0] : avctx->width * 4;
- break;
-
- case AV_PIX_FMT_P010LE:
- *plane_count = 2;
- widths[0] = avctx->width;
- heights[0] = avctx->height;
- strides[0] = frame ? frame->linesize[0] : (avctx->width * 2 + 63) & -64;
-
- widths[1] = (avctx->width + 1) / 2;
- heights[1] = (avctx->height + 1) / 2;
- strides[1] = frame ? frame->linesize[1] : ((avctx->width + 1) / 2 + 63) & -64;
- break;
-
- default:
- av_log(
- avctx,
- AV_LOG_ERROR,
- "Could not get frame format info for color %d range %d.\n",
- av_format,
- av_color_range);
-
- return AVERROR(EINVAL);
+ for (i = 0; i < desc->nb_components; i++) {
+ int p = desc->comp[i].plane;
+ int chroma = (p != 0) && (!(desc->flags & AV_PIX_FMT_FLAG_ALPHA) || p + 1 != *plane_count);
+ int shiftw = chroma ? desc->log2_chroma_w : 0;
+ int shifth = chroma ? desc->log2_chroma_h : 0;
+ widths[p] = (avctx->width + ((1 << shiftw) >> 1)) >> shiftw;
+ heights[p] = (avctx->height + ((1 << shifth) >> 1)) >> shifth;
+ strides[p] = frame->linesize[p];
}
*contiguous_buf_size = 0;
--
2.33.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] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH 06/10] lavc/videotoolboxenc: vastly simplify get_cv_pixel_info
2021-12-17 0:12 ` [FFmpeg-devel] [PATCH 06/10] lavc/videotoolboxenc: vastly simplify get_cv_pixel_info rcombs
@ 2021-12-19 16:25 ` Rick Kern
0 siblings, 0 replies; 16+ messages in thread
From: Rick Kern @ 2021-12-19 16:25 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Thu, Dec 16, 2021 at 7:13 PM rcombs <rcombs@rcombs.me> wrote:
> No longer requires per-format switch cases.
>
> The frame==0 path was unused (and would've crashed anyway).
> ---
> libavcodec/videotoolboxenc.c | 69 +++++++-----------------------------
> 1 file changed, 13 insertions(+), 56 deletions(-)
>
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index b66d44f6b7..82e01fbe29 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -2034,6 +2034,7 @@ static int get_cv_pixel_info(
> size_t *strides,
> size_t *contiguous_buf_size)
> {
> + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
> VTEncContext *vtctx = avctx->priv_data;
> int av_format = frame->format;
> int av_color_range = frame->color_range;
> @@ -2041,6 +2042,9 @@ static int get_cv_pixel_info(
> int range_guessed;
> int status;
>
> + if (!desc)
> + return AVERROR(EINVAL);
> +
> status = get_cv_pixel_format(avctx, av_format, av_color_range, color,
> &range_guessed);
> if (status) {
> av_log(avctx,
> @@ -2065,63 +2069,16 @@ static int get_cv_pixel_info(
> }
> }
>
> - switch (av_format) {
> - case AV_PIX_FMT_NV12:
> - *plane_count = 2;
> -
> - widths [0] = avctx->width;
> - heights[0] = avctx->height;
> - strides[0] = frame ? frame->linesize[0] : avctx->width;
> -
> - widths [1] = (avctx->width + 1) / 2;
> - heights[1] = (avctx->height + 1) / 2;
> - strides[1] = frame ? frame->linesize[1] : (avctx->width + 1) & -2;
> - break;
> -
> - case AV_PIX_FMT_YUV420P:
> - *plane_count = 3;
> -
> - widths [0] = avctx->width;
> - heights[0] = avctx->height;
> - strides[0] = frame ? frame->linesize[0] : avctx->width;
> -
> - widths [1] = (avctx->width + 1) / 2;
> - heights[1] = (avctx->height + 1) / 2;
> - strides[1] = frame ? frame->linesize[1] : (avctx->width + 1) / 2;
> -
> - widths [2] = (avctx->width + 1) / 2;
> - heights[2] = (avctx->height + 1) / 2;
> - strides[2] = frame ? frame->linesize[2] : (avctx->width + 1) / 2;
> - break;
> + *plane_count = av_pix_fmt_count_planes(avctx->pix_fmt);
>
> - case AV_PIX_FMT_BGRA:
> - *plane_count = 1;
> -
> - widths [0] = avctx->width;
> - heights[0] = avctx->height;
> - strides[0] = frame ? frame->linesize[0] : avctx->width * 4;
> - break;
> -
> - case AV_PIX_FMT_P010LE:
> - *plane_count = 2;
> - widths[0] = avctx->width;
> - heights[0] = avctx->height;
> - strides[0] = frame ? frame->linesize[0] : (avctx->width * 2 + 63)
> & -64;
> -
> - widths[1] = (avctx->width + 1) / 2;
> - heights[1] = (avctx->height + 1) / 2;
> - strides[1] = frame ? frame->linesize[1] : ((avctx->width + 1) / 2
> + 63) & -64;
> - break;
> -
> - default:
> - av_log(
> - avctx,
> - AV_LOG_ERROR,
> - "Could not get frame format info for color %d range %d.\n",
> - av_format,
> - av_color_range);
> -
> - return AVERROR(EINVAL);
> + for (i = 0; i < desc->nb_components; i++) {
> + int p = desc->comp[i].plane;
> + int chroma = (p != 0) && (!(desc->flags & AV_PIX_FMT_FLAG_ALPHA)
> || p + 1 != *plane_count);
>
This could be broken out into more variables to make the logic clearer. It
took me a while to parse this.
> + int shiftw = chroma ? desc->log2_chroma_w : 0;
> + int shifth = chroma ? desc->log2_chroma_h : 0;
> + widths[p] = (avctx->width + ((1 << shiftw) >> 1)) >> shiftw;
> + heights[p] = (avctx->height + ((1 << shifth) >> 1)) >> shifth;
> + strides[p] = frame->linesize[p];
> }
>
> *contiguous_buf_size = 0;
> --
> 2.33.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] 16+ messages in thread
* [FFmpeg-devel] [PATCH 07/10] lavc/videotoolboxenc: add handling for non-NAL-based codecs
2021-12-17 0:12 [FFmpeg-devel] lavc/videotoolboxenc: add ProRes support rcombs
` (5 preceding siblings ...)
2021-12-17 0:12 ` [FFmpeg-devel] [PATCH 06/10] lavc/videotoolboxenc: vastly simplify get_cv_pixel_info rcombs
@ 2021-12-17 0:12 ` rcombs
2021-12-19 16:40 ` Rick Kern
2021-12-17 0:12 ` [FFmpeg-devel] [PATCH 08/10] lavc/Makefile: fix missing hevc_videotoolbox case rcombs
` (3 subsequent siblings)
10 siblings, 1 reply; 16+ messages in thread
From: rcombs @ 2021-12-17 0:12 UTC (permalink / raw)
To: ffmpeg-devel
---
libavcodec/videotoolboxenc.c | 149 +++++++++++++++++++++--------------
1 file changed, 92 insertions(+), 57 deletions(-)
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 82e01fbe29..67bb563639 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -549,6 +549,7 @@ static int copy_param_sets(
static int set_extradata(AVCodecContext *avctx, CMSampleBufferRef sample_buffer)
{
+ VTEncContext *vtctx = avctx->priv_data;
CMVideoFormatDescriptionRef vid_fmt;
size_t total_size;
int status;
@@ -559,23 +560,37 @@ static int set_extradata(AVCodecContext *avctx, CMSampleBufferRef sample_buffer)
return AVERROR_EXTERNAL;
}
- status = get_params_size(avctx, vid_fmt, &total_size);
- if (status) {
- av_log(avctx, AV_LOG_ERROR, "Could not get parameter sets.\n");
- return status;
- }
+ if (vtctx->get_param_set_func) {
+ status = get_params_size(avctx, vid_fmt, &total_size);
+ if (status) {
+ av_log(avctx, AV_LOG_ERROR, "Could not get parameter sets.\n");
+ return status;
+ }
- avctx->extradata = av_mallocz(total_size + AV_INPUT_BUFFER_PADDING_SIZE);
- if (!avctx->extradata) {
- return AVERROR(ENOMEM);
- }
- avctx->extradata_size = total_size;
+ avctx->extradata = av_mallocz(total_size + AV_INPUT_BUFFER_PADDING_SIZE);
+ if (!avctx->extradata) {
+ return AVERROR(ENOMEM);
+ }
+ avctx->extradata_size = total_size;
- status = copy_param_sets(avctx, vid_fmt, avctx->extradata, total_size);
+ status = copy_param_sets(avctx, vid_fmt, avctx->extradata, total_size);
- if (status) {
- av_log(avctx, AV_LOG_ERROR, "Could not copy param sets.\n");
- return status;
+ if (status) {
+ av_log(avctx, AV_LOG_ERROR, "Could not copy param sets.\n");
+ return status;
+ }
+ } else {
+ CFDataRef data = CMFormatDescriptionGetExtension(vid_fmt, kCMFormatDescriptionExtension_VerbatimSampleDescription);
+ if (data && CFGetTypeID(data) == CFDataGetTypeID()) {
+ CFIndex size = CFDataGetLength(data);
+
+ avctx->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
+ if (!avctx->extradata)
+ return AVERROR(ENOMEM);
+ avctx->extradata_size = size;
+
+ CFDataGetBytes(data, CFRangeMake(0, size), avctx->extradata);
+ }
}
return 0;
@@ -1938,62 +1953,82 @@ static int vtenc_cm_to_avpacket(
CMTime dts;
CMVideoFormatDescriptionRef vid_fmt;
-
vtenc_get_frame_info(sample_buffer, &is_key_frame);
- status = get_length_code_size(avctx, sample_buffer, &length_code_size);
- if (status) return status;
- add_header = is_key_frame && !(avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER);
+ if (vtctx->get_param_set_func) {
+ status = get_length_code_size(avctx, sample_buffer, &length_code_size);
+ if (status) return status;
- if (add_header) {
- vid_fmt = CMSampleBufferGetFormatDescription(sample_buffer);
- if (!vid_fmt) {
- av_log(avctx, AV_LOG_ERROR, "Cannot get format description.\n");
- return AVERROR_EXTERNAL;
+ add_header = is_key_frame && !(avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER);
+
+ if (add_header) {
+ vid_fmt = CMSampleBufferGetFormatDescription(sample_buffer);
+ if (!vid_fmt) {
+ av_log(avctx, AV_LOG_ERROR, "Cannot get format description.\n");
+ return AVERROR_EXTERNAL;
+ }
+
+ int status = get_params_size(avctx, vid_fmt, &header_size);
+ if (status) return status;
}
- int status = get_params_size(avctx, vid_fmt, &header_size);
- if (status) return status;
- }
+ status = count_nalus(length_code_size, sample_buffer, &nalu_count);
+ if(status)
+ return status;
- status = count_nalus(length_code_size, sample_buffer, &nalu_count);
- if(status)
- return status;
+ if (sei) {
+ size_t msg_size = get_sei_msg_bytes(sei,
+ SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35);
- if (sei) {
- size_t msg_size = get_sei_msg_bytes(sei,
- SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35);
+ sei_nalu_size = sizeof(start_code) + 1 + msg_size + 1;
+ }
- sei_nalu_size = sizeof(start_code) + 1 + msg_size + 1;
- }
+ in_buf_size = CMSampleBufferGetTotalSampleSize(sample_buffer);
+ out_buf_size = header_size +
+ in_buf_size +
+ sei_nalu_size +
+ nalu_count * ((int)sizeof(start_code) - (int)length_code_size);
- in_buf_size = CMSampleBufferGetTotalSampleSize(sample_buffer);
- out_buf_size = header_size +
- in_buf_size +
- sei_nalu_size +
- nalu_count * ((int)sizeof(start_code) - (int)length_code_size);
+ status = ff_get_encode_buffer(avctx, pkt, out_buf_size, 0);
+ if (status < 0)
+ return status;
- status = ff_get_encode_buffer(avctx, pkt, out_buf_size, 0);
- if (status < 0)
- return status;
+ if (add_header) {
+ status = copy_param_sets(avctx, vid_fmt, pkt->data, out_buf_size);
+ if(status) return status;
+ }
- if (add_header) {
- status = copy_param_sets(avctx, vid_fmt, pkt->data, out_buf_size);
- if(status) return status;
- }
+ status = copy_replace_length_codes(
+ avctx,
+ length_code_size,
+ sample_buffer,
+ sei,
+ pkt->data + header_size,
+ pkt->size - header_size
+ );
- status = copy_replace_length_codes(
- avctx,
- length_code_size,
- sample_buffer,
- sei,
- pkt->data + header_size,
- pkt->size - header_size
- );
+ if (status) {
+ av_log(avctx, AV_LOG_ERROR, "Error copying packet data: %d\n", status);
+ return status;
+ }
+ } else {
+ CMBlockBufferRef buf = CMSampleBufferGetDataBuffer(sample_buffer);
+ if (!buf) {
+ av_log(avctx, AV_LOG_ERROR, "Error getting block buffer\n");
+ return AVERROR_EXTERNAL;
+ }
- if (status) {
- av_log(avctx, AV_LOG_ERROR, "Error copying packet data: %d\n", status);
- return status;
+ size_t len = CMBlockBufferGetDataLength(buf);
+
+ status = ff_get_encode_buffer(avctx, pkt, len, 0);
+ if (status < 0)
+ return status;
+
+ status = CMBlockBufferCopyDataBytes(buf, 0, len, pkt->data);
+ if (status) {
+ av_log(avctx, AV_LOG_ERROR, "Error copying packet data: %d\n", status);
+ return AVERROR_EXTERNAL;
+ }
}
if (is_key_frame) {
--
2.33.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] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH 07/10] lavc/videotoolboxenc: add handling for non-NAL-based codecs
2021-12-17 0:12 ` [FFmpeg-devel] [PATCH 07/10] lavc/videotoolboxenc: add handling for non-NAL-based codecs rcombs
@ 2021-12-19 16:40 ` Rick Kern
0 siblings, 0 replies; 16+ messages in thread
From: Rick Kern @ 2021-12-19 16:40 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Thu, Dec 16, 2021 at 7:13 PM rcombs <rcombs@rcombs.me> wrote:
> ---
> libavcodec/videotoolboxenc.c | 149 +++++++++++++++++++++--------------
> 1 file changed, 92 insertions(+), 57 deletions(-)
>
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index 82e01fbe29..67bb563639 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -549,6 +549,7 @@ static int copy_param_sets(
>
> static int set_extradata(AVCodecContext *avctx, CMSampleBufferRef
> sample_buffer)
> {
> + VTEncContext *vtctx = avctx->priv_data;
> CMVideoFormatDescriptionRef vid_fmt;
> size_t total_size;
> int status;
> @@ -559,23 +560,37 @@ static int set_extradata(AVCodecContext *avctx,
> CMSampleBufferRef sample_buffer)
> return AVERROR_EXTERNAL;
> }
>
> - status = get_params_size(avctx, vid_fmt, &total_size);
> - if (status) {
> - av_log(avctx, AV_LOG_ERROR, "Could not get parameter sets.\n");
> - return status;
> - }
> + if (vtctx->get_param_set_func) {
> + status = get_params_size(avctx, vid_fmt, &total_size);
> + if (status) {
> + av_log(avctx, AV_LOG_ERROR, "Could not get parameter
> sets.\n");
> + return status;
> + }
>
> - avctx->extradata = av_mallocz(total_size +
> AV_INPUT_BUFFER_PADDING_SIZE);
> - if (!avctx->extradata) {
> - return AVERROR(ENOMEM);
> - }
> - avctx->extradata_size = total_size;
> + avctx->extradata = av_mallocz(total_size +
> AV_INPUT_BUFFER_PADDING_SIZE);
> + if (!avctx->extradata) {
> + return AVERROR(ENOMEM);
> + }
> + avctx->extradata_size = total_size;
>
> - status = copy_param_sets(avctx, vid_fmt, avctx->extradata,
> total_size);
> + status = copy_param_sets(avctx, vid_fmt, avctx->extradata,
> total_size);
>
> - if (status) {
> - av_log(avctx, AV_LOG_ERROR, "Could not copy param sets.\n");
> - return status;
> + if (status) {
> + av_log(avctx, AV_LOG_ERROR, "Could not copy param sets.\n");
> + return status;
> + }
> + } else {
> + CFDataRef data = CMFormatDescriptionGetExtension(vid_fmt,
> kCMFormatDescriptionExtension_VerbatimSampleDescription);
> + if (data && CFGetTypeID(data) == CFDataGetTypeID()) {
> + CFIndex size = CFDataGetLength(data);
> +
> + avctx->extradata = av_mallocz(size +
> AV_INPUT_BUFFER_PADDING_SIZE);
> + if (!avctx->extradata)
> + return AVERROR(ENOMEM);
> + avctx->extradata_size = size;
> +
> + CFDataGetBytes(data, CFRangeMake(0, size), avctx->extradata);
> + }
> }
>
> return 0;
> @@ -1938,62 +1953,82 @@ static int vtenc_cm_to_avpacket(
> CMTime dts;
> CMVideoFormatDescriptionRef vid_fmt;
>
> -
> vtenc_get_frame_info(sample_buffer, &is_key_frame);
> - status = get_length_code_size(avctx, sample_buffer,
> &length_code_size);
> - if (status) return status;
>
> - add_header = is_key_frame && !(avctx->flags &
> AV_CODEC_FLAG_GLOBAL_HEADER);
> + if (vtctx->get_param_set_func) {
> + status = get_length_code_size(avctx, sample_buffer,
> &length_code_size);
> + if (status) return status;
>
> - if (add_header) {
> - vid_fmt = CMSampleBufferGetFormatDescription(sample_buffer);
> - if (!vid_fmt) {
> - av_log(avctx, AV_LOG_ERROR, "Cannot get format
> description.\n");
> - return AVERROR_EXTERNAL;
> + add_header = is_key_frame && !(avctx->flags &
> AV_CODEC_FLAG_GLOBAL_HEADER);
> +
> + if (add_header) {
> + vid_fmt = CMSampleBufferGetFormatDescription(sample_buffer);
> + if (!vid_fmt) {
> + av_log(avctx, AV_LOG_ERROR, "Cannot get format
> description.\n");
> + return AVERROR_EXTERNAL;
> + }
> +
> + int status = get_params_size(avctx, vid_fmt, &header_size);
> + if (status) return status;
> }
>
> - int status = get_params_size(avctx, vid_fmt, &header_size);
> - if (status) return status;
> - }
> + status = count_nalus(length_code_size, sample_buffer,
> &nalu_count);
> + if(status)
> + return status;
>
> - status = count_nalus(length_code_size, sample_buffer, &nalu_count);
> - if(status)
> - return status;
> + if (sei) {
> + size_t msg_size = get_sei_msg_bytes(sei,
> +
> SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35);
>
> - if (sei) {
> - size_t msg_size = get_sei_msg_bytes(sei,
> -
> SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35);
> + sei_nalu_size = sizeof(start_code) + 1 + msg_size + 1;
> + }
>
> - sei_nalu_size = sizeof(start_code) + 1 + msg_size + 1;
> - }
> + in_buf_size = CMSampleBufferGetTotalSampleSize(sample_buffer);
> + out_buf_size = header_size +
> + in_buf_size +
> + sei_nalu_size +
> + nalu_count * ((int)sizeof(start_code) -
> (int)length_code_size);
>
> - in_buf_size = CMSampleBufferGetTotalSampleSize(sample_buffer);
> - out_buf_size = header_size +
> - in_buf_size +
> - sei_nalu_size +
> - nalu_count * ((int)sizeof(start_code) -
> (int)length_code_size);
> + status = ff_get_encode_buffer(avctx, pkt, out_buf_size, 0);
> + if (status < 0)
> + return status;
>
> - status = ff_get_encode_buffer(avctx, pkt, out_buf_size, 0);
> - if (status < 0)
> - return status;
> + if (add_header) {
> + status = copy_param_sets(avctx, vid_fmt, pkt->data,
> out_buf_size);
> + if(status) return status;
> + }
>
> - if (add_header) {
> - status = copy_param_sets(avctx, vid_fmt, pkt->data, out_buf_size);
> - if(status) return status;
> - }
> + status = copy_replace_length_codes(
> + avctx,
> + length_code_size,
> + sample_buffer,
> + sei,
> + pkt->data + header_size,
> + pkt->size - header_size
> + );
>
> - status = copy_replace_length_codes(
> - avctx,
> - length_code_size,
> - sample_buffer,
> - sei,
> - pkt->data + header_size,
> - pkt->size - header_size
> - );
> + if (status) {
> + av_log(avctx, AV_LOG_ERROR, "Error copying packet data:
> %d\n", status);
> + return status;
> + }
> + } else {
> + CMBlockBufferRef buf = CMSampleBufferGetDataBuffer(sample_buffer);
> + if (!buf) {
> + av_log(avctx, AV_LOG_ERROR, "Error getting block buffer\n");
> + return AVERROR_EXTERNAL;
> + }
>
> - if (status) {
> - av_log(avctx, AV_LOG_ERROR, "Error copying packet data: %d\n",
> status);
> - return status;
> + size_t len = CMBlockBufferGetDataLength(buf);
>
The declaration should be at the beginning of the block.
> +
> + status = ff_get_encode_buffer(avctx, pkt, len, 0);
> + if (status < 0)
> + return status;
> +
> + status = CMBlockBufferCopyDataBytes(buf, 0, len, pkt->data);
> + if (status) {
> + av_log(avctx, AV_LOG_ERROR, "Error copying packet data:
> %d\n", status);
> + return AVERROR_EXTERNAL;
> + }
> }
>
> if (is_key_frame) {
> --
> 2.33.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] 16+ messages in thread
* [FFmpeg-devel] [PATCH 08/10] lavc/Makefile: fix missing hevc_videotoolbox case
2021-12-17 0:12 [FFmpeg-devel] lavc/videotoolboxenc: add ProRes support rcombs
` (6 preceding siblings ...)
2021-12-17 0:12 ` [FFmpeg-devel] [PATCH 07/10] lavc/videotoolboxenc: add handling for non-NAL-based codecs rcombs
@ 2021-12-17 0:12 ` rcombs
2021-12-17 0:12 ` [FFmpeg-devel] [PATCH 09/10] swscale: add P210/P410/P216/P416 output rcombs
` (2 subsequent siblings)
10 siblings, 0 replies; 16+ messages in thread
From: rcombs @ 2021-12-17 0:12 UTC (permalink / raw)
To: ffmpeg-devel
---
libavcodec/Makefile | 1 +
1 file changed, 1 insertion(+)
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 4122a9b144..beb91e8c12 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -403,6 +403,7 @@ OBJS-$(CONFIG_HEVC_RKMPP_DECODER) += rkmppdec.o
OBJS-$(CONFIG_HEVC_VAAPI_ENCODER) += vaapi_encode_h265.o h265_profile_level.o
OBJS-$(CONFIG_HEVC_V4L2M2M_DECODER) += v4l2_m2m_dec.o
OBJS-$(CONFIG_HEVC_V4L2M2M_ENCODER) += v4l2_m2m_enc.o
+OBJS-$(CONFIG_HEVC_VIDEOTOOLBOX_ENCODER) += videotoolboxenc.o
OBJS-$(CONFIG_HNM4_VIDEO_DECODER) += hnm4video.o
OBJS-$(CONFIG_HQ_HQA_DECODER) += hq_hqa.o hq_hqadata.o hq_hqadsp.o \
canopus.o
--
2.33.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] 16+ messages in thread
* [FFmpeg-devel] [PATCH 09/10] swscale: add P210/P410/P216/P416 output
2021-12-17 0:12 [FFmpeg-devel] lavc/videotoolboxenc: add ProRes support rcombs
` (7 preceding siblings ...)
2021-12-17 0:12 ` [FFmpeg-devel] [PATCH 08/10] lavc/Makefile: fix missing hevc_videotoolbox case rcombs
@ 2021-12-17 0:12 ` rcombs
2021-12-23 11:00 ` Michael Niedermayer
2021-12-17 0:12 ` [FFmpeg-devel] [PATCH 10/10] lavc/videotoolboxenc: add ProRes support rcombs
2021-12-19 17:30 ` [FFmpeg-devel] " Rick Kern
10 siblings, 1 reply; 16+ messages in thread
From: rcombs @ 2021-12-17 0:12 UTC (permalink / raw)
To: ffmpeg-devel
---
libswscale/output.c | 8 ++++++--
libswscale/utils.c | 16 ++++++++--------
libswscale/version.h | 2 +-
3 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/libswscale/output.c b/libswscale/output.c
index 58b10f85a5..4b4b186be9 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -2563,14 +2563,18 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
enum AVPixelFormat dstFormat = c->dstFormat;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(dstFormat);
- if (dstFormat == AV_PIX_FMT_P010LE || dstFormat == AV_PIX_FMT_P010BE) {
+ if (dstFormat == AV_PIX_FMT_P010LE || dstFormat == AV_PIX_FMT_P010BE ||
+ dstFormat == AV_PIX_FMT_P210LE || dstFormat == AV_PIX_FMT_P210BE ||
+ dstFormat == AV_PIX_FMT_P410LE || dstFormat == AV_PIX_FMT_P410BE) {
*yuv2plane1 = isBE(dstFormat) ? yuv2p010l1_BE_c : yuv2p010l1_LE_c;
*yuv2planeX = isBE(dstFormat) ? yuv2p010lX_BE_c : yuv2p010lX_LE_c;
*yuv2nv12cX = yuv2p010cX_c;
} else if (is16BPS(dstFormat)) {
*yuv2planeX = isBE(dstFormat) ? yuv2planeX_16BE_c : yuv2planeX_16LE_c;
*yuv2plane1 = isBE(dstFormat) ? yuv2plane1_16BE_c : yuv2plane1_16LE_c;
- if (dstFormat == AV_PIX_FMT_P016LE || dstFormat == AV_PIX_FMT_P016BE) {
+ if (dstFormat == AV_PIX_FMT_P016LE || dstFormat == AV_PIX_FMT_P016BE ||
+ dstFormat == AV_PIX_FMT_P216LE || dstFormat == AV_PIX_FMT_P216BE ||
+ dstFormat == AV_PIX_FMT_P416LE || dstFormat == AV_PIX_FMT_P416BE) {
*yuv2nv12cX = yuv2p016cX_c;
}
} else if (isNBPS(dstFormat)) {
diff --git a/libswscale/utils.c b/libswscale/utils.c
index d4a72d3ce1..c80b4f3e35 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -268,14 +268,14 @@ static const FormatEntry format_entries[] = {
[AV_PIX_FMT_Y210LE] = { 1, 0 },
[AV_PIX_FMT_X2RGB10LE] = { 1, 1 },
[AV_PIX_FMT_X2BGR10LE] = { 1, 1 },
- [AV_PIX_FMT_P210BE] = { 1, 0 },
- [AV_PIX_FMT_P210LE] = { 1, 0 },
- [AV_PIX_FMT_P410BE] = { 1, 0 },
- [AV_PIX_FMT_P410LE] = { 1, 0 },
- [AV_PIX_FMT_P216BE] = { 1, 0 },
- [AV_PIX_FMT_P216LE] = { 1, 0 },
- [AV_PIX_FMT_P416BE] = { 1, 0 },
- [AV_PIX_FMT_P416LE] = { 1, 0 },
+ [AV_PIX_FMT_P210BE] = { 1, 1 },
+ [AV_PIX_FMT_P210LE] = { 1, 1 },
+ [AV_PIX_FMT_P410BE] = { 1, 1 },
+ [AV_PIX_FMT_P410LE] = { 1, 1 },
+ [AV_PIX_FMT_P216BE] = { 1, 1 },
+ [AV_PIX_FMT_P216LE] = { 1, 1 },
+ [AV_PIX_FMT_P416BE] = { 1, 1 },
+ [AV_PIX_FMT_P416LE] = { 1, 1 },
};
void ff_shuffle_filter_coefficients(SwsContext *c, int *filterPos, int filterSize, int16_t *filter, int dstW){
diff --git a/libswscale/version.h b/libswscale/version.h
index 15ad54319c..8f7b56df9a 100644
--- a/libswscale/version.h
+++ b/libswscale/version.h
@@ -28,7 +28,7 @@
#define LIBSWSCALE_VERSION_MAJOR 6
#define LIBSWSCALE_VERSION_MINOR 1
-#define LIBSWSCALE_VERSION_MICRO 101
+#define LIBSWSCALE_VERSION_MICRO 102
#define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \
LIBSWSCALE_VERSION_MINOR, \
--
2.33.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] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH 09/10] swscale: add P210/P410/P216/P416 output
2021-12-17 0:12 ` [FFmpeg-devel] [PATCH 09/10] swscale: add P210/P410/P216/P416 output rcombs
@ 2021-12-23 11:00 ` Michael Niedermayer
0 siblings, 0 replies; 16+ messages in thread
From: Michael Niedermayer @ 2021-12-23 11:00 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 1738 bytes --]
On Thu, Dec 16, 2021 at 06:12:14PM -0600, rcombs wrote:
> ---
> libswscale/output.c | 8 ++++++--
> libswscale/utils.c | 16 ++++++++--------
> libswscale/version.h | 2 +-
> 3 files changed, 15 insertions(+), 11 deletions(-)
breaks MIPS
TEST filter-pixfmts-pad
--- src/tests/ref/fate/filter-pixfmts-pad 2021-12-23 11:58:16.416901175 +0100
+++ tests/data/fate/filter-pixfmts-pad 2021-12-23 11:58:43.897117890 +0100
@@ -25,10 +25,10 @@
nv21 0fdeb2cdd56cf5a7147dc273456fa217
nv24 193b9eadcc06ad5081609f76249b3e47
nv42 1738ad3c31c6c16e17679f5b09ce4677
-p210le 10b53de63b086de93c076d1d40f9da42
-p216le 0bbf778e1b6101a3f650ce0454a357f2
-p410le fcab6381bde9cd84b813925ff29be4d2
-p416le 6db094f8d7d27d7299bf9496ad66e2e0
+p210le abc02945a9b9585f0914716e4787cefb
+p216le 1b43feb94b8a030c0c699aa0deff017b
+p410le 1f0294141ae1657d6c10c6a0d46a879f
+p416le 320e558b7ee8d598231ae0763ecca275
rgb0 78d500c8361ab6423a4826a00268c908
rgb24 17f9e2e0c609009acaf2175c42d4a2a5
rgba b157c90191463d34fb3ce77b36c96386
Test filter-pixfmts-pad failed. Look at tests/data/fate/filter-pixfmts-pad.err for details.
src/tests/Makefile:256: recipe for target 'fate-filter-pixfmts-pad' failed
make: *** [fate-filter-pixfmts-pad] Error 1
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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] 16+ messages in thread
* [FFmpeg-devel] [PATCH 10/10] lavc/videotoolboxenc: add ProRes support
2021-12-17 0:12 [FFmpeg-devel] lavc/videotoolboxenc: add ProRes support rcombs
` (8 preceding siblings ...)
2021-12-17 0:12 ` [FFmpeg-devel] [PATCH 09/10] swscale: add P210/P410/P216/P416 output rcombs
@ 2021-12-17 0:12 ` rcombs
2021-12-19 17:30 ` [FFmpeg-devel] " Rick Kern
10 siblings, 0 replies; 16+ messages in thread
From: rcombs @ 2021-12-17 0:12 UTC (permalink / raw)
To: ffmpeg-devel
---
Changelog | 1 +
configure | 2 +
libavcodec/Makefile | 1 +
libavcodec/allcodecs.c | 1 +
libavcodec/version.h | 2 +-
libavcodec/videotoolboxenc.c | 119 +++++++++++++++++++++++++++++++++--
6 files changed, 119 insertions(+), 7 deletions(-)
diff --git a/Changelog b/Changelog
index 5c6adc0fa7..ebbfed14a0 100644
--- a/Changelog
+++ b/Changelog
@@ -41,6 +41,7 @@ version <next>:
- libplacebo filter
- vflip_vulkan, hflip_vulkan and flip_vulkan filters
- adynamicequalizer audio filter
+- VideoToolbox ProRes encoder
version 4.4:
diff --git a/configure b/configure
index 5fffcb8afe..0146b28ff1 100755
--- a/configure
+++ b/configure
@@ -3300,6 +3300,8 @@ h264_videotoolbox_encoder_deps="pthreads"
h264_videotoolbox_encoder_select="atsc_a53 videotoolbox_encoder"
hevc_videotoolbox_encoder_deps="pthreads"
hevc_videotoolbox_encoder_select="atsc_a53 videotoolbox_encoder"
+prores_videotoolbox_encoder_deps="pthreads"
+prores_videotoolbox_encoder_select="videotoolbox_encoder"
libaom_av1_decoder_deps="libaom"
libaom_av1_encoder_deps="libaom"
libaom_av1_encoder_select="extract_extradata_bsf"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index beb91e8c12..f15a56eabd 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -565,6 +565,7 @@ OBJS-$(CONFIG_PRORES_DECODER) += proresdec2.o proresdsp.o proresdata.o
OBJS-$(CONFIG_PRORES_ENCODER) += proresenc_anatoliy.o proresdata.o
OBJS-$(CONFIG_PRORES_AW_ENCODER) += proresenc_anatoliy.o proresdata.o
OBJS-$(CONFIG_PRORES_KS_ENCODER) += proresenc_kostya.o proresdata.o
+OBJS-$(CONFIG_PRORES_VIDEOTOOLBOX_ENCODER) += videotoolboxenc.o
OBJS-$(CONFIG_PROSUMER_DECODER) += prosumer.o
OBJS-$(CONFIG_PSD_DECODER) += psd.o
OBJS-$(CONFIG_PTX_DECODER) += ptx.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 89d65266c8..d1e10197de 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -837,6 +837,7 @@ extern const AVCodec ff_mpeg4_cuvid_decoder;
extern const AVCodec ff_mpeg4_mediacodec_decoder;
extern const AVCodec ff_mpeg4_omx_encoder;
extern const AVCodec ff_mpeg4_v4l2m2m_encoder;
+extern const AVCodec ff_prores_videotoolbox_encoder;
extern const AVCodec ff_vc1_cuvid_decoder;
extern const AVCodec ff_vp8_cuvid_decoder;
extern const AVCodec ff_vp8_mediacodec_decoder;
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 8a0b94f5aa..db71fb1130 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -28,7 +28,7 @@
#include "libavutil/version.h"
#define LIBAVCODEC_VERSION_MAJOR 59
-#define LIBAVCODEC_VERSION_MINOR 14
+#define LIBAVCODEC_VERSION_MINOR 15
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 67bb563639..8453da7bc4 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -407,6 +407,7 @@ static int count_nalus(size_t length_code_size,
}
static CMVideoCodecType get_cm_codec_type(AVCodecContext *avctx,
+ int64_t profile,
double alpha_quality)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt == AV_PIX_FMT_VIDEOTOOLBOX ? avctx->sw_pix_fmt : avctx->pix_fmt);
@@ -417,6 +418,31 @@ static CMVideoCodecType get_cm_codec_type(AVCodecContext *avctx,
return kCMVideoCodecType_HEVCWithAlpha;
}
return kCMVideoCodecType_HEVC;
+ case AV_CODEC_ID_PRORES:
+ switch (profile) {
+ case FF_PROFILE_PRORES_PROXY:
+ return MKBETAG('a','p','c','o'); // kCMVideoCodecType_AppleProRes422Proxy
+ case FF_PROFILE_PRORES_LT:
+ return MKBETAG('a','p','c','s'); // kCMVideoCodecType_AppleProRes422LT
+ case FF_PROFILE_PRORES_STANDARD:
+ return MKBETAG('a','p','c','n'); // kCMVideoCodecType_AppleProRes422
+ case FF_PROFILE_PRORES_HQ:
+ return MKBETAG('a','p','c','h'); // kCMVideoCodecType_AppleProRes422HQ
+ case FF_PROFILE_PRORES_4444:
+ return MKBETAG('a','p','4','h'); // kCMVideoCodecType_AppleProRes4444
+ case FF_PROFILE_PRORES_XQ:
+ return MKBETAG('a','p','4','x'); // kCMVideoCodecType_AppleProRes4444XQ
+
+ default:
+ av_log(avctx, AV_LOG_ERROR, "Unknown profile ID: %"PRId64", using auto\n", profile);
+ case FF_PROFILE_UNKNOWN:
+ if (desc &&
+ ((desc->flags & AV_PIX_FMT_FLAG_ALPHA) ||
+ desc->log2_chroma_w == 0))
+ return MKBETAG('a','p','4','h'); // kCMVideoCodecType_AppleProRes4444
+ else
+ return MKBETAG('a','p','c','n'); // kCMVideoCodecType_AppleProRes422
+ }
default: return 0;
}
}
@@ -1104,7 +1130,7 @@ static int vtenc_create_encoder(AVCodecContext *avctx,
kVTCompressionPropertyKey_Quality,
quality_num);
CFRelease(quality_num);
- } else {
+ } else if (avctx->codec_id != AV_CODEC_ID_PRORES) {
bit_rate_num = CFNumberCreate(kCFAllocatorDefault,
kCFNumberSInt32Type,
&bit_rate);
@@ -1191,7 +1217,7 @@ static int vtenc_create_encoder(AVCodecContext *avctx,
}
}
- if (avctx->gop_size > 0) {
+ if (avctx->gop_size > 0 && avctx->codec_id != AV_CODEC_ID_PRORES) {
CFNumberRef interval = CFNumberCreate(kCFAllocatorDefault,
kCFNumberIntType,
&avctx->gop_size);
@@ -1340,7 +1366,7 @@ static int vtenc_create_encoder(AVCodecContext *avctx,
}
}
- if (!vtctx->has_b_frames) {
+ if (!vtctx->has_b_frames && avctx->codec_id != AV_CODEC_ID_PRORES) {
status = VTSessionSetProperty(vtctx->session,
kVTCompressionPropertyKey_AllowFrameReordering,
kCFBooleanFalse);
@@ -1390,16 +1416,24 @@ static int vtenc_configure_encoder(AVCodecContext *avctx)
CFMutableDictionaryRef pixel_buffer_info;
CMVideoCodecType codec_type;
VTEncContext *vtctx = avctx->priv_data;
- CFStringRef profile_level;
+ CFStringRef profile_level = NULL;
CFNumberRef gamma_level = NULL;
int status;
- codec_type = get_cm_codec_type(avctx, vtctx->alpha_quality);
+ codec_type = get_cm_codec_type(avctx, vtctx->profile, vtctx->alpha_quality);
if (!codec_type) {
av_log(avctx, AV_LOG_ERROR, "Error: no mapping for AVCodecID %d\n", avctx->codec_id);
return AVERROR(EINVAL);
}
+#if defined(MAC_OS_X_VERSION_10_9) && !TARGET_OS_IPHONE && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9)
+ if (avctx->codec_id == AV_CODEC_ID_PRORES) {
+ if (__builtin_available(macOS 10.9, *)) {
+ VTRegisterProfessionalVideoWorkflowVideoEncoders();
+ }
+ }
+#endif
+
vtctx->codec_id = avctx->codec_id;
if (vtctx->codec_id == AV_CODEC_ID_H264) {
@@ -1417,12 +1451,14 @@ static int vtenc_configure_encoder(AVCodecContext *avctx)
}
if (!get_vt_h264_profile_level(avctx, &profile_level)) return AVERROR(EINVAL);
- } else {
+ } else if (vtctx->codec_id == AV_CODEC_ID_HEVC) {
vtctx->get_param_set_func = compat_keys.CMVideoFormatDescriptionGetHEVCParameterSetAtIndex;
if (!vtctx->get_param_set_func) return AVERROR(EINVAL);
if (!get_vt_hevc_profile_level(avctx, &profile_level)) return AVERROR(EINVAL);
// HEVC has b-byramid
vtctx->has_b_frames = avctx->max_b_frames > 0 ? 2 : 0;
+ } else if (vtctx->codec_id == AV_CODEC_ID_PRORES) {
+ avctx->codec_tag = av_bswap32(codec_type);
}
enc_info = CFDictionaryCreateMutable(
@@ -2600,6 +2636,38 @@ static const enum AVPixelFormat hevc_pix_fmts[] = {
AV_PIX_FMT_NONE
};
+static const enum AVPixelFormat prores_pix_fmts[] = {
+ AV_PIX_FMT_YUV420P,
+#ifdef kCFCoreFoundationVersionNumber10_7
+ AV_PIX_FMT_NV12,
+ AV_PIX_FMT_AYUV64,
+#endif
+ AV_PIX_FMT_UYVY422,
+#if HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE
+ AV_PIX_FMT_P010,
+#endif
+#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR8BIPLANARVIDEORANGE
+ AV_PIX_FMT_NV16,
+#endif
+#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR10BIPLANARVIDEORANGE
+ AV_PIX_FMT_P210,
+#endif
+#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR16BIPLANARVIDEORANGE
+ AV_PIX_FMT_P216,
+#endif
+#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR8BIPLANARVIDEORANGE
+ AV_PIX_FMT_NV24,
+#endif
+#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR10BIPLANARVIDEORANGE
+ AV_PIX_FMT_P410,
+#endif
+#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR16BIPLANARVIDEORANGE
+ AV_PIX_FMT_P416,
+#endif
+ AV_PIX_FMT_BGRA,
+ AV_PIX_FMT_NONE
+};
+
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
#define COMMON_OPTIONS \
{ "allow_sw", "Allow software encoding", OFFSET(allow_sw), AV_OPT_TYPE_BOOL, \
@@ -2703,3 +2771,42 @@ const AVCodec ff_hevc_videotoolbox_encoder = {
FF_CODEC_CAP_INIT_CLEANUP,
.wrapper_name = "videotoolbox",
};
+
+static const AVOption prores_options[] = {
+ { "profile", "Profile", OFFSET(profile), AV_OPT_TYPE_INT64, { .i64 = FF_PROFILE_UNKNOWN }, FF_PROFILE_UNKNOWN, FF_PROFILE_PRORES_XQ, VE, "profile" },
+ { "auto", "Automatically determine based on input format", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_UNKNOWN }, INT_MIN, INT_MAX, VE, "profile" },
+ { "proxy", "ProRes 422 Proxy", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_PRORES_PROXY }, INT_MIN, INT_MAX, VE, "profile" },
+ { "lt", "ProRes 422 LT", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_PRORES_LT }, INT_MIN, INT_MAX, VE, "profile" },
+ { "standard", "ProRes 422", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_PRORES_STANDARD }, INT_MIN, INT_MAX, VE, "profile" },
+ { "hq", "ProRes 422 HQ", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_PRORES_HQ }, INT_MIN, INT_MAX, VE, "profile" },
+ { "4444", "ProRes 4444", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_PRORES_4444 }, INT_MIN, INT_MAX, VE, "profile" },
+ { "xq", "ProRes 4444 XQ", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_PRORES_XQ }, INT_MIN, INT_MAX, VE, "profile" },
+
+ COMMON_OPTIONS
+ { NULL },
+};
+
+static const AVClass prores_videotoolbox_class = {
+ .class_name = "prores_videotoolbox",
+ .item_name = av_default_item_name,
+ .option = prores_options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
+const AVCodec ff_prores_videotoolbox_encoder = {
+ .name = "prores_videotoolbox",
+ .long_name = NULL_IF_CONFIG_SMALL("VideoToolbox ProRes Encoder"),
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_PRORES,
+ .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
+ AV_CODEC_CAP_HARDWARE,
+ .priv_data_size = sizeof(VTEncContext),
+ .pix_fmts = prores_pix_fmts,
+ .init = vtenc_init,
+ .encode2 = vtenc_frame,
+ .close = vtenc_close,
+ .priv_class = &prores_videotoolbox_class,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
+ FF_CODEC_CAP_INIT_CLEANUP,
+ .wrapper_name = "videotoolbox",
+};
--
2.33.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] 16+ messages in thread
* Re: [FFmpeg-devel] lavc/videotoolboxenc: add ProRes support
2021-12-17 0:12 [FFmpeg-devel] lavc/videotoolboxenc: add ProRes support rcombs
` (9 preceding siblings ...)
2021-12-17 0:12 ` [FFmpeg-devel] [PATCH 10/10] lavc/videotoolboxenc: add ProRes support rcombs
@ 2021-12-19 17:30 ` Rick Kern
10 siblings, 0 replies; 16+ messages in thread
From: Rick Kern @ 2021-12-19 17:30 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Thu, Dec 16, 2021 at 7:12 PM rcombs <rcombs@rcombs.me> wrote:
> This patchset includes several infrastructural improvements to
> videotoolboxenc,
> an added group of output formats for swscale, and a ProRes encoder wrapper.
>
> Also available as a GitHub PR here:
> https://github.com/FFmpeg/FFmpeg/pull/378
>
> Review comments and followup changes will be applied there to reduce ML
> noise.
>
I noticed this a little late. I'll add my comments on github too. Is that
the preferred way now? Seems better to me.
>
>
> _______________________________________________
> 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] 16+ messages in thread