Merge pull request #5502 from HiassofT/le10-ffmpeg-rpi-7

ffmpeg: update rpi patch
This commit is contained in:
CvH 2021-07-19 21:11:08 +02:00 committed by GitHub
commit 6533219d17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,5 @@
diff --git a/configure b/configure diff --git a/configure b/configure
index 36713ab658..89a47e046f 100755 index 36713ab658..665d247bf7 100755
--- a/configure --- a/configure
+++ b/configure +++ b/configure
@@ -274,6 +274,7 @@ External library support: @@ -274,6 +274,7 @@ External library support:
@ -122,7 +122,7 @@ index 36713ab658..89a47e046f 100755
hevc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferHEVC" hevc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferHEVC"
hevc_vaapi_hwaccel_select="hevc_decoder" hevc_vaapi_hwaccel_select="hevc_decoder"
hevc_vdpau_hwaccel_deps="vdpau VdpPictureInfoHEVC" hevc_vdpau_hwaccel_deps="vdpau VdpPictureInfoHEVC"
@@ -3401,8 +3428,13 @@ sndio_indev_deps="sndio" @@ -3401,8 +3428,14 @@ sndio_indev_deps="sndio"
sndio_outdev_deps="sndio" sndio_outdev_deps="sndio"
v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h" v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
v4l2_indev_suggest="libv4l2" v4l2_indev_suggest="libv4l2"
@ -130,13 +130,14 @@ index 36713ab658..89a47e046f 100755
v4l2_outdev_deps_any="linux_videodev2_h sys_videoio_h" v4l2_outdev_deps_any="linux_videodev2_h sys_videoio_h"
v4l2_outdev_suggest="libv4l2" v4l2_outdev_suggest="libv4l2"
+vout_drm_outdev_deps="libdrm vout_drm" +vout_drm_outdev_deps="libdrm vout_drm"
+vout_egl_outdev_deps="xlib"
+vout_egl_outdev_select="epoxy" +vout_egl_outdev_select="epoxy"
+vout_rpi_outdev_deps="rpi" +vout_rpi_outdev_deps="rpi"
+vout_rpi_outdev_select="sand" +vout_rpi_outdev_select="sand"
vfwcap_indev_deps="vfw32 vfwcap_defines" vfwcap_indev_deps="vfw32 vfwcap_defines"
xcbgrab_indev_deps="libxcb" xcbgrab_indev_deps="libxcb"
xcbgrab_indev_suggest="libxcb_shm libxcb_shape libxcb_xfixes" xcbgrab_indev_suggest="libxcb_shm libxcb_shape libxcb_xfixes"
@@ -3618,6 +3650,7 @@ tonemap_vaapi_filter_deps="vaapi VAProcFilterParameterBufferHDRToneMapping" @@ -3618,6 +3651,7 @@ tonemap_vaapi_filter_deps="vaapi VAProcFilterParameterBufferHDRToneMapping"
tonemap_opencl_filter_deps="opencl const_nan" tonemap_opencl_filter_deps="opencl const_nan"
transpose_opencl_filter_deps="opencl" transpose_opencl_filter_deps="opencl"
transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags" transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags"
@ -144,7 +145,7 @@ index 36713ab658..89a47e046f 100755
unsharp_opencl_filter_deps="opencl" unsharp_opencl_filter_deps="opencl"
uspp_filter_deps="gpl avcodec" uspp_filter_deps="gpl avcodec"
vaguedenoiser_filter_deps="gpl" vaguedenoiser_filter_deps="gpl"
@@ -6299,6 +6332,7 @@ enabled libdav1d && require_pkg_config libdav1d "dav1d >= 0.4.0" "dav1d @@ -6299,6 +6333,7 @@ enabled libdav1d && require_pkg_config libdav1d "dav1d >= 0.4.0" "dav1d
enabled libdavs2 && require_pkg_config libdavs2 "davs2 >= 1.6.0" davs2.h davs2_decoder_open enabled libdavs2 && require_pkg_config libdavs2 "davs2 >= 1.6.0" davs2.h davs2_decoder_open
enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 dc1394/dc1394.h dc1394_new enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 dc1394/dc1394.h dc1394_new
enabled libdrm && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion enabled libdrm && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion
@ -152,7 +153,7 @@ index 36713ab658..89a47e046f 100755
enabled libfdk_aac && { check_pkg_config libfdk_aac fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen || enabled libfdk_aac && { check_pkg_config libfdk_aac fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen ||
{ require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac && { require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac &&
warn "using libfdk without pkg-config"; } } warn "using libfdk without pkg-config"; } }
@@ -6376,6 +6410,7 @@ enabled libtls && require_pkg_config libtls libtls tls.h tls_configur @@ -6376,6 +6411,7 @@ enabled libtls && require_pkg_config libtls libtls tls.h tls_configur
enabled libtwolame && require libtwolame twolame.h twolame_init -ltwolame && enabled libtwolame && require libtwolame twolame.h twolame_init -ltwolame &&
{ check_lib libtwolame twolame.h twolame_encode_buffer_float32_interleaved -ltwolame || { check_lib libtwolame twolame.h twolame_encode_buffer_float32_interleaved -ltwolame ||
die "ERROR: libtwolame must be installed and version must be >= 0.3.10"; } die "ERROR: libtwolame must be installed and version must be >= 0.3.10"; }
@ -160,7 +161,7 @@ index 36713ab658..89a47e046f 100755
enabled libv4l2 && require_pkg_config libv4l2 libv4l2 libv4l2.h v4l2_ioctl enabled libv4l2 && require_pkg_config libv4l2 libv4l2 libv4l2.h v4l2_ioctl
enabled libvidstab && require_pkg_config libvidstab "vidstab >= 0.98" vid.stab/libvidstab.h vsMotionDetectInit enabled libvidstab && require_pkg_config libvidstab "vidstab >= 0.98" vid.stab/libvidstab.h vsMotionDetectInit
enabled libvmaf && require_pkg_config libvmaf "libvmaf >= 1.3.9" libvmaf.h compute_vmaf enabled libvmaf && require_pkg_config libvmaf "libvmaf >= 1.3.9" libvmaf.h compute_vmaf
@@ -6430,11 +6465,12 @@ enabled mbedtls && { check_pkg_config mbedtls mbedtls mbedtls/x509_crt @@ -6430,11 +6466,12 @@ enabled mbedtls && { check_pkg_config mbedtls mbedtls mbedtls/x509_crt
check_lib mbedtls mbedtls/ssl.h mbedtls_ssl_init -lmbedtls -lmbedx509 -lmbedcrypto || check_lib mbedtls mbedtls/ssl.h mbedtls_ssl_init -lmbedtls -lmbedx509 -lmbedcrypto ||
die "ERROR: mbedTLS not found"; } die "ERROR: mbedTLS not found"; }
enabled mediacodec && { enabled jni || die "ERROR: mediacodec requires --enable-jni"; } enabled mediacodec && { enabled jni || die "ERROR: mediacodec requires --enable-jni"; }
@ -175,7 +176,7 @@ index 36713ab658..89a47e046f 100755
die "ERROR: mmal not found" && die "ERROR: mmal not found" &&
check_func_headers interface/mmal/mmal.h "MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS"; } check_func_headers interface/mmal/mmal.h "MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS"; }
enabled openal && { { for al_extralibs in "${OPENAL_LIBS}" "-lopenal" "-lOpenAL32"; do enabled openal && { { for al_extralibs in "${OPENAL_LIBS}" "-lopenal" "-lOpenAL32"; do
@@ -6475,6 +6511,10 @@ enabled rkmpp && { require_pkg_config rkmpp rockchip_mpp rockchip/r @@ -6475,6 +6512,10 @@ enabled rkmpp && { require_pkg_config rkmpp rockchip_mpp rockchip/r
{ enabled libdrm || { enabled libdrm ||
die "ERROR: rkmpp requires --enable-libdrm"; } die "ERROR: rkmpp requires --enable-libdrm"; }
} }
@ -186,7 +187,7 @@ index 36713ab658..89a47e046f 100755
enabled vapoursynth && require_pkg_config vapoursynth "vapoursynth-script >= 42" VSScript.h vsscript_init enabled vapoursynth && require_pkg_config vapoursynth "vapoursynth-script >= 42" VSScript.h vsscript_init
@@ -6556,6 +6596,8 @@ if enabled v4l2_m2m; then @@ -6556,6 +6597,8 @@ if enabled v4l2_m2m; then
check_cc vp9_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VP9;" check_cc vp9_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VP9;"
fi fi
@ -46031,7 +46032,7 @@ index 0000000000..85c5b46d75
+}; +};
+ +
diff --git a/libavcodec/v4l2_buffers.c b/libavcodec/v4l2_buffers.c diff --git a/libavcodec/v4l2_buffers.c b/libavcodec/v4l2_buffers.c
index 02f23d954b..d4f26e416a 100644 index 02f23d954b..60c6793797 100644
--- a/libavcodec/v4l2_buffers.c --- a/libavcodec/v4l2_buffers.c
+++ b/libavcodec/v4l2_buffers.c +++ b/libavcodec/v4l2_buffers.c
@@ -21,6 +21,7 @@ @@ -21,6 +21,7 @@
@ -46542,7 +46543,7 @@ index 02f23d954b..d4f26e416a 100644
+ offset += dst_stride * out->context->height; + offset += dst_stride * out->context->height;
+ } + }
+ if (offset > out->plane_info[0].length) { + if (offset > out->plane_info[0].length) {
+ av_log(NULL, AV_LOG_ERROR, "%s: Plane total %d > buffer size %d\n", __func__, offset, out->plane_info[0].length); + av_log(NULL, AV_LOG_ERROR, "%s: Plane total %u > buffer size %zu\n", __func__, offset, out->plane_info[0].length);
+ return -1; + return -1;
+ } + }
@ -46909,7 +46910,7 @@ index 8dbc7fc104..9909f349bd 100644
/** /**
* Enqueues a V4L2Buffer * Enqueues a V4L2Buffer
diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c
index 29b144ed73..24cee598eb 100644 index 29b144ed73..48ef2a8219 100644
--- a/libavcodec/v4l2_context.c --- a/libavcodec/v4l2_context.c
+++ b/libavcodec/v4l2_context.c +++ b/libavcodec/v4l2_context.c
@@ -27,11 +27,13 @@ @@ -27,11 +27,13 @@
@ -47344,7 +47345,8 @@ index 29b144ed73..24cee598eb 100644
+ ctx->name, buf.index, + ctx->name, buf.index,
+ buf.timestamp.tv_sec, buf.timestamp.tv_usec, + buf.timestamp.tv_sec, buf.timestamp.tv_usec,
+ ctx->q_count, ++ctx->dq_count); + ctx->q_count, ++ctx->dq_count);
+
- if (ctx_to_m2mctx(ctx)->draining && !V4L2_TYPE_IS_OUTPUT(ctx->type)) {
+ avbuf = (V4L2Buffer *)ctx->bufrefs[buf.index]->data; + avbuf = (V4L2Buffer *)ctx->bufrefs[buf.index]->data;
+ avbuf->status = V4L2BUF_AVAILABLE; + avbuf->status = V4L2BUF_AVAILABLE;
+ avbuf->buf = buf; + avbuf->buf = buf;
@ -47352,8 +47354,7 @@ index 29b144ed73..24cee598eb 100644
+ memcpy(avbuf->planes, planes, sizeof(planes)); + memcpy(avbuf->planes, planes, sizeof(planes));
+ avbuf->buf.m.planes = avbuf->planes; + avbuf->buf.m.planes = avbuf->planes;
+ } + }
+
- if (ctx_to_m2mctx(ctx)->draining && !V4L2_TYPE_IS_OUTPUT(ctx->type)) {
+ if (ctx_to_m2mctx(ctx)->draining && is_capture) { + if (ctx_to_m2mctx(ctx)->draining && is_capture) {
int bytesused = V4L2_TYPE_IS_MULTIPLANAR(buf.type) ? int bytesused = V4L2_TYPE_IS_MULTIPLANAR(buf.type) ?
buf.m.planes[0].bytesused : buf.bytesused; buf.m.planes[0].bytesused : buf.bytesused;
@ -47426,19 +47427,19 @@ index 29b144ed73..24cee598eb 100644
+ for (i = 0; i < ctx->num_buffers; i++) + for (i = 0; i < ctx->num_buffers; i++)
+ av_buffer_unref(ctx->bufrefs + i); + av_buffer_unref(ctx->bufrefs + i);
+ } + }
+
+ if (fd != -1) {
+ struct v4l2_requestbuffers req = {
+ .memory = V4L2_MEMORY_MMAP,
+ .type = ctx->type,
+ .count = 0, /* 0 -> unmap all buffers from the driver */
+ };
- for (j = 0; j < buffer->num_planes; j++) { - for (j = 0; j < buffer->num_planes; j++) {
- struct V4L2Plane_info *p = &buffer->plane_info[j]; - struct V4L2Plane_info *p = &buffer->plane_info[j];
- if (p->mm_addr && p->length) - if (p->mm_addr && p->length)
- if (munmap(p->mm_addr, p->length) < 0) - if (munmap(p->mm_addr, p->length) < 0)
- av_log(logger(ctx), AV_LOG_ERROR, "%s unmap plane (%s))\n", ctx->name, av_err2str(AVERROR(errno))); - av_log(logger(ctx), AV_LOG_ERROR, "%s unmap plane (%s))\n", ctx->name, av_err2str(AVERROR(errno)));
+ if (fd != -1) {
+ struct v4l2_requestbuffers req = {
+ .memory = V4L2_MEMORY_MMAP,
+ .type = ctx->type,
+ .count = 0, /* 0 -> unmap all buffers from the driver */
+ };
+
+ while ((ret = ioctl(fd, VIDIOC_REQBUFS, &req)) == -1) { + while ((ret = ioctl(fd, VIDIOC_REQBUFS, &req)) == -1) {
+ if (errno == EINTR) + if (errno == EINTR)
+ continue; + continue;
@ -47615,17 +47616,14 @@ index 29b144ed73..24cee598eb 100644
} }
int ff_v4l2_context_dequeue_packet(V4L2Context* ctx, AVPacket* pkt) int ff_v4l2_context_dequeue_packet(V4L2Context* ctx, AVPacket* pkt)
@@ -702,78 +924,161 @@ int ff_v4l2_context_get_format(V4L2Context* ctx, int probe) @@ -702,78 +924,155 @@ int ff_v4l2_context_get_format(V4L2Context* ctx, int probe)
int ff_v4l2_context_set_format(V4L2Context* ctx) int ff_v4l2_context_set_format(V4L2Context* ctx)
{ {
- return ioctl(ctx_to_m2mctx(ctx)->fd, VIDIOC_S_FMT, &ctx->format); - return ioctl(ctx_to_m2mctx(ctx)->fd, VIDIOC_S_FMT, &ctx->format);
+ int ret; + int ret;
+ +
+ av_log(logger(ctx), AV_LOG_INFO, "Try with %d\n", ctx->format.fmt.pix_mp.plane_fmt[0].sizeimage);
+
+ ret = ioctl(ctx_to_m2mctx(ctx)->fd, VIDIOC_S_FMT, &ctx->format); + ret = ioctl(ctx_to_m2mctx(ctx)->fd, VIDIOC_S_FMT, &ctx->format);
+ av_log(logger(ctx), AV_LOG_INFO, "Got %d\n", ctx->format.fmt.pix_mp.plane_fmt[0].sizeimage);
+ if (ret != 0) + if (ret != 0)
+ return ret; + return ret;
+ +
@ -47644,10 +47642,7 @@ index 29b144ed73..24cee598eb 100644
+ ctx->format.fmt.pix.sizeimage = ctx->min_buf_size; + ctx->format.fmt.pix.sizeimage = ctx->min_buf_size;
+ } + }
+ +
+ av_log(logger(ctx), AV_LOG_INFO, "Retry with %d\n", ctx->format.fmt.pix_mp.plane_fmt[0].sizeimage);
+
+ ret = ioctl(ctx_to_m2mctx(ctx)->fd, VIDIOC_S_FMT, &ctx->format); + ret = ioctl(ctx_to_m2mctx(ctx)->fd, VIDIOC_S_FMT, &ctx->format);
+ av_log(logger(ctx), AV_LOG_INFO, "Got %d\n", ctx->format.fmt.pix_mp.plane_fmt[0].sizeimage);
+ return ret; + return ret;
} }
@ -49146,7 +49141,7 @@ index 0000000000..0baef36535
+#endif +#endif
diff --git a/libavcodec/v4l2_req_dmabufs.c b/libavcodec/v4l2_req_dmabufs.c diff --git a/libavcodec/v4l2_req_dmabufs.c b/libavcodec/v4l2_req_dmabufs.c
new file mode 100644 new file mode 100644
index 0000000000..828da1dd05 index 0000000000..0717279e75
--- /dev/null --- /dev/null
+++ b/libavcodec/v4l2_req_dmabufs.c +++ b/libavcodec/v4l2_req_dmabufs.c
@@ -0,0 +1,241 @@ @@ -0,0 +1,241 @@
@ -49228,7 +49223,7 @@ index 0000000000..828da1dd05
+ while (ioctl(dbsc->fd, DMA_HEAP_IOCTL_ALLOC, &data)) { + while (ioctl(dbsc->fd, DMA_HEAP_IOCTL_ALLOC, &data)) {
+ int err = errno; + int err = errno;
+ request_log("Failed to alloc %" PRIu64 " from dma-heap(fd=%d): %d (%s)\n", + request_log("Failed to alloc %" PRIu64 " from dma-heap(fd=%d): %d (%s)\n",
+ data.len, + (uint64_t)data.len,
+ dbsc->fd, + dbsc->fd,
+ err, + err,
+ strerror(err)); + strerror(err));
@ -49437,10 +49432,10 @@ index 0000000000..8d909c4297
+#endif +#endif
diff --git a/libavcodec/v4l2_req_media.c b/libavcodec/v4l2_req_media.c diff --git a/libavcodec/v4l2_req_media.c b/libavcodec/v4l2_req_media.c
new file mode 100644 new file mode 100644
index 0000000000..659835fcb7 index 0000000000..3a9d53169f
--- /dev/null --- /dev/null
+++ b/libavcodec/v4l2_req_media.c +++ b/libavcodec/v4l2_req_media.c
@@ -0,0 +1,1510 @@ @@ -0,0 +1,1514 @@
+/* +/*
+ * Copyright (C) 2018 Paul Kocialkowski <paul.kocialkowski@bootlin.com> + * Copyright (C) 2018 Paul Kocialkowski <paul.kocialkowski@bootlin.com>
+ * + *
@ -50182,10 +50177,10 @@ index 0000000000..659835fcb7
+{ +{
+ if (!be->dh[0] || len > dmabuf_size(be->dh[0])) { + if (!be->dh[0] || len > dmabuf_size(be->dh[0])) {
+ size_t newsize = round_up_size(len); + size_t newsize = round_up_size(len);
+ request_log("%s: Overrun %d > %d; trying %d\n", __func__, len, dmabuf_size(be->dh[0]), newsize); + request_log("%s: Overrun %zd > %zd; trying %zd\n", __func__, len, dmabuf_size(be->dh[0]), newsize);
+ if (!dbsc || + if (!dbsc ||
+ (be->dh[0] = dmabuf_realloc(dbsc, be->dh[0], newsize)) == NULL) { + (be->dh[0] = dmabuf_realloc(dbsc, be->dh[0], newsize)) == NULL) {
+ request_log("%s: Realloc %d failed\n", __func__, newsize); + request_log("%s: Realloc %zd failed\n", __func__, newsize);
+ return -ENOMEM; + return -ENOMEM;
+ } + }
+ } + }
@ -50247,6 +50242,9 @@ index 0000000000..659835fcb7
+ +
+ pthread_mutex_lock(&mbc->lock); + pthread_mutex_lock(&mbc->lock);
+ +
+ if (!src_be)
+ goto fail1;
+
+ if (dst_be) { + if (dst_be) {
+ if (qe_dst_waiting(dst_be)) { + if (qe_dst_waiting(dst_be)) {
+ request_info(mbc->dc, "Request buffer already waiting on start\n"); + request_info(mbc->dc, "Request buffer already waiting on start\n");
@ -50275,9 +50273,10 @@ index 0000000000..659835fcb7
+ +
+fail1: +fail1:
+ media_request_abort(&mreq); + media_request_abort(&mreq);
+ queue_put_free(mbc->src, &src_be->base); + if (src_be)
+ queue_put_free(mbc->src, &src_be->base);
+ +
+#warning If src Q fails this doesnt unwind properly - separate dst Q from src Q +// *** TODO: If src Q fails this doesnt unwind properly - separate dst Q from src Q
+ if (dst_be) + if (dst_be)
+ qe_dst_done(dst_be); + qe_dst_done(dst_be);
+ pthread_mutex_unlock(&mbc->lock); + pthread_mutex_unlock(&mbc->lock);
@ -51104,7 +51103,7 @@ index 0000000000..75956eb962
+#endif +#endif
diff --git a/libavcodec/v4l2_req_pollqueue.c b/libavcodec/v4l2_req_pollqueue.c diff --git a/libavcodec/v4l2_req_pollqueue.c b/libavcodec/v4l2_req_pollqueue.c
new file mode 100644 new file mode 100644
index 0000000000..6ef057232b index 0000000000..0f7d9020ee
--- /dev/null --- /dev/null
+++ b/libavcodec/v4l2_req_pollqueue.c +++ b/libavcodec/v4l2_req_pollqueue.c
@@ -0,0 +1,280 @@ @@ -0,0 +1,280 @@
@ -51261,7 +51260,7 @@ index 0000000000..6ef057232b
+ asize = asize ? asize * 2 : 4; + asize = asize ? asize * 2 : 4;
+ a = realloc(a, asize * sizeof(*a)); + a = realloc(a, asize * sizeof(*a));
+ if (!a) { + if (!a) {
+ request_log("Failed to realloc poll array to %d\n", asize); + request_log("Failed to realloc poll array to %zd\n", asize);
+ goto fail_locked; + goto fail_locked;
+ } + }
+ } + }
@ -51440,7 +51439,7 @@ index 0000000000..9e9a5f7e39
+ +
diff --git a/libavcodec/v4l2_request_hevc.c b/libavcodec/v4l2_request_hevc.c diff --git a/libavcodec/v4l2_request_hevc.c b/libavcodec/v4l2_request_hevc.c
new file mode 100644 new file mode 100644
index 0000000000..f869c4e3d5 index 0000000000..92205cc178
--- /dev/null --- /dev/null
+++ b/libavcodec/v4l2_request_hevc.c +++ b/libavcodec/v4l2_request_hevc.c
@@ -0,0 +1,1192 @@ @@ -0,0 +1,1192 @@
@ -51557,24 +51556,24 @@ index 0000000000..f869c4e3d5
+typedef struct V4L2ReqFrameDataPrivHEVC { +typedef struct V4L2ReqFrameDataPrivHEVC {
+} V4L2ReqFrameDataPrivHEVC; +} V4L2ReqFrameDataPrivHEVC;
+ +
+static uint8_t nalu_slice_start_code[] = { 0x00, 0x00, 0x01 }; +// static uint8_t nalu_slice_start_code[] = { 0x00, 0x00, 0x01 };
+ +
+static size_t bit_buf_size(unsigned int w, unsigned int h, unsigned int bits_minus8) +static size_t bit_buf_size(unsigned int w, unsigned int h, unsigned int bits_minus8)
+{ +{
+ const size_t wxh = w * h; + const size_t wxh = w * h;
+ size_t bits_alloc; + size_t bits_alloc;
+ +
+ /* Annex A gives a min compression of 2 @ lvl 3.1 + /* Annex A gives a min compression of 2 @ lvl 3.1
+ * (wxh <= 983040) and min 4 thereafter but avoid + * (wxh <= 983040) and min 4 thereafter but avoid
+ * the odity of 983041 having a lower limit than + * the odity of 983041 having a lower limit than
+ * 983040. + * 983040.
+ * Multiply by 3/2 for 4:2:0 + * Multiply by 3/2 for 4:2:0
+ */ + */
+ bits_alloc = wxh < 983040 ? wxh * 3 / 4 : + bits_alloc = wxh < 983040 ? wxh * 3 / 4 :
+ wxh < 983040 * 2 ? 983040 * 3 / 4 : + wxh < 983040 * 2 ? 983040 * 3 / 4 :
+ wxh * 3 / 8; + wxh * 3 / 8;
+ /* Allow for bit depth */ + /* Allow for bit depth */
+ bits_alloc += (bits_alloc * bits_minus8) / 8; + bits_alloc += (bits_alloc * bits_minus8) / 8;
+ return bits_alloc; + return bits_alloc;
+} +}
+ +
@ -52801,10 +52800,10 @@ index 8633433254..bc15112a00 100644
diff --git a/libavdevice/drm_vout.c b/libavdevice/drm_vout.c diff --git a/libavdevice/drm_vout.c b/libavdevice/drm_vout.c
new file mode 100644 new file mode 100644
index 0000000000..5362ac9e28 index 0000000000..d58b8fc7c8
--- /dev/null --- /dev/null
+++ b/libavdevice/drm_vout.c +++ b/libavdevice/drm_vout.c
@@ -0,0 +1,632 @@ @@ -0,0 +1,633 @@
+/* +/*
+ * Copyright (c) 2020 John Cox for Raspberry Pi Trading + * Copyright (c) 2020 John Cox for Raspberry Pi Trading
+ * + *
@ -52837,6 +52836,7 @@ index 0000000000..5362ac9e28
+ +
+#include "pthread.h" +#include "pthread.h"
+#include <semaphore.h> +#include <semaphore.h>
+#include <unistd.h>
+ +
+#include <xf86drm.h> +#include <xf86drm.h>
+#include <xf86drmMode.h> +#include <xf86drmMode.h>
@ -53439,10 +53439,10 @@ index 0000000000..5362ac9e28
+ +
diff --git a/libavdevice/egl_vout.c b/libavdevice/egl_vout.c diff --git a/libavdevice/egl_vout.c b/libavdevice/egl_vout.c
new file mode 100644 new file mode 100644
index 0000000000..5d97fe9310 index 0000000000..b1b1f7bb60
--- /dev/null --- /dev/null
+++ b/libavdevice/egl_vout.c +++ b/libavdevice/egl_vout.c
@@ -0,0 +1,824 @@ @@ -0,0 +1,825 @@
+/* +/*
+ * Copyright (c) 2020 John Cox for Raspberry Pi Trading + * Copyright (c) 2020 John Cox for Raspberry Pi Trading
+ * + *
@ -53483,6 +53483,7 @@ index 0000000000..5d97fe9310
+#include "pthread.h" +#include "pthread.h"
+#include <semaphore.h> +#include <semaphore.h>
+#include <stdatomic.h> +#include <stdatomic.h>
+#include <unistd.h>
+ +
+#include "drm_fourcc.h" +#include "drm_fourcc.h"
+#include <drm.h> +#include <drm.h>
@ -54269,10 +54270,10 @@ index 0000000000..5d97fe9310
+ +
diff --git a/libavdevice/rpi_vout.c b/libavdevice/rpi_vout.c diff --git a/libavdevice/rpi_vout.c b/libavdevice/rpi_vout.c
new file mode 100644 new file mode 100644
index 0000000000..b1617d48a8 index 0000000000..84723a34ad
--- /dev/null --- /dev/null
+++ b/libavdevice/rpi_vout.c +++ b/libavdevice/rpi_vout.c
@@ -0,0 +1,533 @@ @@ -0,0 +1,534 @@
+/* +/*
+ * Copyright (c) 2013 Jeff Moguillansky + * Copyright (c) 2013 Jeff Moguillansky
+ * + *
@ -54309,6 +54310,7 @@ index 0000000000..b1617d48a8
+#include "avdevice.h" +#include "avdevice.h"
+ +
+#include <stdatomic.h> +#include <stdatomic.h>
+#include <unistd.h>
+ +
+#pragma GCC diagnostic push +#pragma GCC diagnostic push
+// Many many redundant decls in the header files +// Many many redundant decls in the header files
@ -55360,7 +55362,7 @@ index 5613813ba8..ab8bcfcf34 100644
+ +
diff --git a/libavutil/aarch64/rpi_sand_neon.S b/libavutil/aarch64/rpi_sand_neon.S diff --git a/libavutil/aarch64/rpi_sand_neon.S b/libavutil/aarch64/rpi_sand_neon.S
new file mode 100644 new file mode 100644
index 0000000000..2169d4f0ed index 0000000000..cdcf71ee67
--- /dev/null --- /dev/null
+++ b/libavutil/aarch64/rpi_sand_neon.S +++ b/libavutil/aarch64/rpi_sand_neon.S
@@ -0,0 +1,676 @@ @@ -0,0 +1,676 @@
@ -55796,7 +55798,7 @@ index 0000000000..2169d4f0ed
+ b row_loop_y16 + b row_loop_y16
+row_loop_y16_fin2: +row_loop_y16_fin2:
+ +
+ sub x0, x0, x20, sxtw // with the last row we didn't actually move the dst ptr to far ahead, therefore readd the diference + sub x0, x0, w20, sxtw // with the last row we didn't actually move the dst ptr to far ahead, therefore readd the diference
+ +
+ // now we've got to handle the last block in the last row + // now we've got to handle the last block in the last row
+ eor w12, w12, w12 // w12 = 0 = counter + eor w12, w12, w12 // w12 = 0 = counter
@ -57047,18 +57049,21 @@ index fc67db0f6c..b1a7eb4858 100644
* @} * @}
*/ */
diff --git a/libavutil/hwcontext_drm.c b/libavutil/hwcontext_drm.c diff --git a/libavutil/hwcontext_drm.c b/libavutil/hwcontext_drm.c
index 32cbde82eb..c897dfade7 100644 index 32cbde82eb..b1fc82034b 100644
--- a/libavutil/hwcontext_drm.c --- a/libavutil/hwcontext_drm.c
+++ b/libavutil/hwcontext_drm.c +++ b/libavutil/hwcontext_drm.c
@@ -21,6 +21,7 @@ @@ -19,8 +19,10 @@
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h> #include <unistd.h>
+#include <sys/ioctl.h>
#include <drm.h> #include <drm.h>
+#include <libdrm/drm_fourcc.h> +#include <libdrm/drm_fourcc.h>
#include <xf86drm.h> #include <xf86drm.h>
#include "avassert.h" #include "avassert.h"
@@ -28,6 +29,11 @@ @@ -28,6 +30,11 @@
#include "hwcontext_drm.h" #include "hwcontext_drm.h"
#include "hwcontext_internal.h" #include "hwcontext_internal.h"
#include "imgutils.h" #include "imgutils.h"
@ -57070,7 +57075,7 @@ index 32cbde82eb..c897dfade7 100644
static void drm_device_free(AVHWDeviceContext *hwdev) static void drm_device_free(AVHWDeviceContext *hwdev)
@@ -43,6 +49,11 @@ static int drm_device_create(AVHWDeviceContext *hwdev, const char *device, @@ -43,6 +50,11 @@ static int drm_device_create(AVHWDeviceContext *hwdev, const char *device,
AVDRMDeviceContext *hwctx = hwdev->hwctx; AVDRMDeviceContext *hwctx = hwdev->hwctx;
drmVersionPtr version; drmVersionPtr version;
@ -57082,7 +57087,7 @@ index 32cbde82eb..c897dfade7 100644
hwctx->fd = open(device, O_RDWR); hwctx->fd = open(device, O_RDWR);
if (hwctx->fd < 0) if (hwctx->fd < 0)
return AVERROR(errno); return AVERROR(errno);
@@ -85,18 +96,37 @@ static int drm_get_buffer(AVHWFramesContext *hwfc, AVFrame *frame) @@ -85,18 +97,37 @@ static int drm_get_buffer(AVHWFramesContext *hwfc, AVFrame *frame)
typedef struct DRMMapping { typedef struct DRMMapping {
// Address and length of each mmap()ed region. // Address and length of each mmap()ed region.
int nb_regions; int nb_regions;
@ -57121,7 +57126,7 @@ index 32cbde82eb..c897dfade7 100644
av_free(map); av_free(map);
} }
@@ -114,15 +144,28 @@ static int drm_map_frame(AVHWFramesContext *hwfc, @@ -114,15 +145,28 @@ static int drm_map_frame(AVHWFramesContext *hwfc,
if (!map) if (!map)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
@ -57153,7 +57158,7 @@ index 32cbde82eb..c897dfade7 100644
desc->objects[i].fd, 0); desc->objects[i].fd, 0);
if (addr == MAP_FAILED) { if (addr == MAP_FAILED) {
err = AVERROR(errno); err = AVERROR(errno);
@@ -151,6 +194,23 @@ static int drm_map_frame(AVHWFramesContext *hwfc, @@ -151,6 +195,23 @@ static int drm_map_frame(AVHWFramesContext *hwfc,
dst->width = src->width; dst->width = src->width;
dst->height = src->height; dst->height = src->height;
@ -57177,7 +57182,7 @@ index 32cbde82eb..c897dfade7 100644
err = ff_hwframe_map_create(src->hw_frames_ctx, dst, src, err = ff_hwframe_map_create(src->hw_frames_ctx, dst, src,
&drm_unmap_frame, map); &drm_unmap_frame, map);
@@ -160,7 +220,9 @@ static int drm_map_frame(AVHWFramesContext *hwfc, @@ -160,7 +221,9 @@ static int drm_map_frame(AVHWFramesContext *hwfc,
return 0; return 0;
fail: fail:
@ -57188,7 +57193,7 @@ index 32cbde82eb..c897dfade7 100644
if (map->address[i]) if (map->address[i])
munmap(map->address[i], map->length[i]); munmap(map->address[i], map->length[i]);
} }
@@ -178,7 +240,15 @@ static int drm_transfer_get_formats(AVHWFramesContext *ctx, @@ -178,7 +241,15 @@ static int drm_transfer_get_formats(AVHWFramesContext *ctx,
if (!pix_fmts) if (!pix_fmts)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
@ -57205,7 +57210,7 @@ index 32cbde82eb..c897dfade7 100644
pix_fmts[1] = AV_PIX_FMT_NONE; pix_fmts[1] = AV_PIX_FMT_NONE;
*formats = pix_fmts; *formats = pix_fmts;
@@ -197,18 +267,82 @@ static int drm_transfer_data_from(AVHWFramesContext *hwfc, @@ -197,18 +268,82 @@ static int drm_transfer_data_from(AVHWFramesContext *hwfc,
map = av_frame_alloc(); map = av_frame_alloc();
if (!map) if (!map)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
@ -57292,7 +57297,7 @@ index 32cbde82eb..c897dfade7 100644
err = 0; err = 0;
fail: fail:
@@ -223,7 +357,10 @@ static int drm_transfer_data_to(AVHWFramesContext *hwfc, @@ -223,7 +358,10 @@ static int drm_transfer_data_to(AVHWFramesContext *hwfc,
int err; int err;
if (src->width > hwfc->width || src->height > hwfc->height) if (src->width > hwfc->width || src->height > hwfc->height)
@ -58924,7 +58929,7 @@ index 0000000000..fc14f2a3c2
+1,WPP_F_ericsson_MAIN_2,WPP_F_ericsson_MAIN_2.bit,WPP_F_ericsson_MAIN_2_yuv.md5 +1,WPP_F_ericsson_MAIN_2,WPP_F_ericsson_MAIN_2.bit,WPP_F_ericsson_MAIN_2_yuv.md5
diff --git a/pi-util/conf_native.sh b/pi-util/conf_native.sh diff --git a/pi-util/conf_native.sh b/pi-util/conf_native.sh
new file mode 100755 new file mode 100755
index 0000000000..38c16b1f11 index 0000000000..d5240ff388
--- /dev/null --- /dev/null
+++ b/pi-util/conf_native.sh +++ b/pi-util/conf_native.sh
@@ -0,0 +1,76 @@ @@ -0,0 +1,76 @@
@ -58955,7 +58960,7 @@ index 0000000000..38c16b1f11
+ RPI_INCLUDES="-I$RPI_OPT_VC/include -I$RPI_OPT_VC/include/interface/vcos/pthreads -I$RPI_OPT_VC/include/interface/vmcs_host/linux" + RPI_INCLUDES="-I$RPI_OPT_VC/include -I$RPI_OPT_VC/include/interface/vcos/pthreads -I$RPI_OPT_VC/include/interface/vmcs_host/linux"
+ RPI_LIBDIRS="-L$RPI_OPT_VC/lib" + RPI_LIBDIRS="-L$RPI_OPT_VC/lib"
+ RPI_DEFINES="-D__VCCOREVER__=0x4000000 -mfpu=neon-vfpv4" + RPI_DEFINES="-D__VCCOREVER__=0x4000000 -mfpu=neon-vfpv4"
+ RPI_EXTRALIBS="-Wl,--start-group -lbcm_host -lmmal -lmmal_util -lmmal_core -lvcos -lvcsm -lvchostif -lvchiq_arm" + RPI_EXTRALIBS="-Wl,--start-group -lbcm_host -lmmal -lmmal_util -lmmal_core -lvcos -lvcsm -lvchostif -lvchiq_arm -Wl,--end-group"
+ RPIOPTS="--enable-mmal --enable-rpi" + RPIOPTS="--enable-mmal --enable-rpi"
+fi +fi
+C=`lsb_release -sc` +C=`lsb_release -sc`