ffmpeg: update rpi patch

Patch created using revisions dc91b91..4a75a07
from branch dev/4.4/rpi_import_1 of https://github.com/jc-kynesim/rpi-ffmpeg
This commit is contained in:
Matthias Reichl 2022-05-26 18:09:19 +02:00
parent 21b80d26a6
commit 90555b4694

View File

@ -1,16 +1,24 @@
diff --git a/configure b/configure diff --git a/configure b/configure
index d7a3f507e8..cfbbb4f27d 100755 index d7a3f507e8..9b7435ec79 100755
--- a/configure --- a/configure
+++ b/configure +++ b/configure
@@ -279,6 +279,7 @@ External library support: @@ -207,6 +207,7 @@ External library support:
--disable-bzlib disable bzlib [autodetect]
--disable-coreimage disable Apple CoreImage framework [autodetect]
--enable-chromaprint enable audio fingerprinting with chromaprint [no]
+ --disable-epoxy disable epoxy [autodetect]
--enable-frei0r enable frei0r video filtering [no]
--enable-gcrypt enable gcrypt, needed for rtmp(t)e support
if openssl, librtmp or gmp is not used [no]
@@ -279,6 +280,7 @@ External library support:
if openssl, gnutls or mbedtls is not used [no] if openssl, gnutls or mbedtls is not used [no]
--enable-libtwolame enable MP2 encoding via libtwolame [no] --enable-libtwolame enable MP2 encoding via libtwolame [no]
--enable-libuavs3d enable AVS3 decoding via libuavs3d [no] --enable-libuavs3d enable AVS3 decoding via libuavs3d [no]
+ --enable-libudev enable libudev [no] + --disable-libudev disable libudev [autodetect]
--enable-libv4l2 enable libv4l2/v4l-utils [no] --enable-libv4l2 enable libv4l2/v4l-utils [no]
--enable-libvidstab enable video stabilization using vid.stab [no] --enable-libvidstab enable video stabilization using vid.stab [no]
--enable-libvmaf enable vmaf filter via libvmaf [no] --enable-libvmaf enable vmaf filter via libvmaf [no]
@@ -340,12 +341,17 @@ External library support: @@ -340,12 +342,17 @@ External library support:
--enable-libmfx enable Intel MediaSDK (AKA Quick Sync Video) code via libmfx [no] --enable-libmfx enable Intel MediaSDK (AKA Quick Sync Video) code via libmfx [no]
--enable-libnpp enable Nvidia Performance Primitives-based code [no] --enable-libnpp enable Nvidia Performance Primitives-based code [no]
--enable-mmal enable Broadcom Multi-Media Abstraction Layer (Raspberry Pi) via MMAL [no] --enable-mmal enable Broadcom Multi-Media Abstraction Layer (Raspberry Pi) via MMAL [no]
@ -28,23 +36,17 @@ index d7a3f507e8..cfbbb4f27d 100755
--disable-vaapi disable Video Acceleration API (mainly Unix/Intel) code [autodetect] --disable-vaapi disable Video Acceleration API (mainly Unix/Intel) code [autodetect]
--disable-vdpau disable Nvidia Video Decode and Presentation API for Unix code [autodetect] --disable-vdpau disable Nvidia Video Decode and Presentation API for Unix code [autodetect]
--disable-videotoolbox disable VideoToolbox code [autodetect] --disable-videotoolbox disable VideoToolbox code [autodetect]
@@ -1774,6 +1780,7 @@ EXTERNAL_LIBRARY_LIST=" @@ -1703,7 +1710,9 @@ EXTERNAL_AUTODETECT_LIBRARY_LIST="
libdav1d avfoundation
libdc1394 bzlib
libdrm coreimage
+ epoxy + epoxy
libflite iconv
libfontconfig
libfreetype
@@ -1814,6 +1821,7 @@ EXTERNAL_LIBRARY_LIST="
libtheora
libtwolame
libuavs3d
+ libudev + libudev
libv4l2 libxcb
libvmaf libxcb_shm
libvorbis libxcb_shape
@@ -1868,7 +1876,10 @@ HWACCEL_LIBRARY_LIST=" @@ -1868,7 +1877,10 @@ HWACCEL_LIBRARY_LIST="
mmal mmal
omx omx
opencl opencl
@ -55,7 +57,7 @@ index d7a3f507e8..cfbbb4f27d 100755
" "
DOCUMENT_LIST=" DOCUMENT_LIST="
@@ -1884,12 +1895,16 @@ FEATURE_LIST=" @@ -1884,12 +1896,16 @@ FEATURE_LIST="
gray gray
hardcoded_tables hardcoded_tables
omx_rpi omx_rpi
@ -72,7 +74,7 @@ index d7a3f507e8..cfbbb4f27d 100755
" "
# this list should be kept in linking order # this list should be kept in linking order
@@ -1930,6 +1945,7 @@ SUBSYSTEM_LIST=" @@ -1930,6 +1946,7 @@ SUBSYSTEM_LIST="
pixelutils pixelutils
network network
rdft rdft
@ -80,7 +82,7 @@ index d7a3f507e8..cfbbb4f27d 100755
" "
# COMPONENT_LIST needs to come last to ensure correct dependency checking # COMPONENT_LIST needs to come last to ensure correct dependency checking
@@ -2416,9 +2432,11 @@ CONFIG_EXTRA=" @@ -2416,9 +2433,11 @@ CONFIG_EXTRA="
rangecoder rangecoder
riffdec riffdec
riffenc riffenc
@ -92,7 +94,7 @@ index d7a3f507e8..cfbbb4f27d 100755
scene_sad scene_sad
sinewin sinewin
snappy snappy
@@ -2750,6 +2768,8 @@ hap_decoder_select="snappy texturedsp" @@ -2750,6 +2769,8 @@ hap_decoder_select="snappy texturedsp"
hap_encoder_deps="libsnappy" hap_encoder_deps="libsnappy"
hap_encoder_select="texturedspenc" hap_encoder_select="texturedspenc"
hevc_decoder_select="atsc_a53 bswapdsp cabac golomb hevcparse videodsp" hevc_decoder_select="atsc_a53 bswapdsp cabac golomb hevcparse videodsp"
@ -101,7 +103,7 @@ index d7a3f507e8..cfbbb4f27d 100755
huffyuv_decoder_select="bswapdsp huffyuvdsp llviddsp" huffyuv_decoder_select="bswapdsp huffyuvdsp llviddsp"
huffyuv_encoder_select="bswapdsp huffman huffyuvencdsp llvidencdsp" huffyuv_encoder_select="bswapdsp huffman huffyuvencdsp llvidencdsp"
hymt_decoder_select="huffyuv_decoder" hymt_decoder_select="huffyuv_decoder"
@@ -2919,6 +2939,7 @@ d3d11va_deps="dxva_h ID3D11VideoDecoder ID3D11VideoContext" @@ -2919,6 +2940,7 @@ d3d11va_deps="dxva_h ID3D11VideoDecoder ID3D11VideoContext"
dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode ole32 user32" dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode ole32 user32"
ffnvcodec_deps_any="libdl LoadLibrary" ffnvcodec_deps_any="libdl LoadLibrary"
nvdec_deps="ffnvcodec" nvdec_deps="ffnvcodec"
@ -109,7 +111,7 @@ index d7a3f507e8..cfbbb4f27d 100755
vaapi_x11_deps="xlib" vaapi_x11_deps="xlib"
videotoolbox_hwaccel_deps="videotoolbox pthreads" videotoolbox_hwaccel_deps="videotoolbox pthreads"
videotoolbox_hwaccel_extralibs="-framework QuartzCore" videotoolbox_hwaccel_extralibs="-framework QuartzCore"
@@ -2960,6 +2981,12 @@ hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC" @@ -2960,6 +2982,12 @@ hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC"
hevc_dxva2_hwaccel_select="hevc_decoder" hevc_dxva2_hwaccel_select="hevc_decoder"
hevc_nvdec_hwaccel_deps="nvdec" hevc_nvdec_hwaccel_deps="nvdec"
hevc_nvdec_hwaccel_select="hevc_decoder" hevc_nvdec_hwaccel_select="hevc_decoder"
@ -122,16 +124,15 @@ index d7a3f507e8..cfbbb4f27d 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"
@@ -3437,8 +3464,14 @@ sndio_indev_deps="sndio" @@ -3437,8 +3465,13 @@ 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"
+v4l2_outdev_deps="libdrm" +v4l2_outdev_deps="libdrm"
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_egl_outdev_deps="xlib" +vout_egl_outdev_deps="xlib 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"
@ -145,23 +146,20 @@ index d7a3f507e8..cfbbb4f27d 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"
@@ -6357,6 +6391,7 @@ enabled libdav1d && require_pkg_config libdav1d "dav1d >= 0.5.0" "dav1d @@ -6154,6 +6188,12 @@ check_func_headers glob.h glob
enabled libdavs2 && require_pkg_config libdavs2 "davs2 >= 1.6.0" davs2.h davs2_decoder_open enabled xlib &&
enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 dc1394/dc1394.h dc1394_new check_lib xlib "X11/Xlib.h X11/extensions/Xvlib.h" XvGetPortAttribute -lXv -lX11 -lXext
enabled libdrm && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion
+enabled epoxy && require_pkg_config epoxy epoxy epoxy/egl.h epoxy_egl_version +enabled libudev &&
enabled libfdk_aac && { check_pkg_config libfdk_aac fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen || + check_pkg_config libudev libudev libudev.h udev_new
{ require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac && +
warn "using libfdk without pkg-config"; } } +enabled epoxy &&
@@ -6438,6 +6473,7 @@ enabled libtwolame && require libtwolame twolame.h twolame_init -ltwolame + check_pkg_config epoxy epoxy epoxy/egl.h epoxy_egl_version
{ check_lib libtwolame twolame.h twolame_encode_buffer_float32_interleaved -ltwolame || +
die "ERROR: libtwolame must be installed and version must be >= 0.3.10"; } check_headers direct.h
enabled libuavs3d && require_pkg_config libuavs3d "uavs3d >= 1.1.41" uavs3d.h uavs3d_decode check_headers dirent.h
+enabled libudev && require_pkg_config libudev libudev libudev.h udev_new check_headers dxgidebug.h
enabled libv4l2 && require_pkg_config libv4l2 libv4l2 libv4l2.h v4l2_ioctl @@ -6491,11 +6531,12 @@ enabled mbedtls && { check_pkg_config mbedtls mbedtls mbedtls/x509_crt
enabled libvidstab && require_pkg_config libvidstab "vidstab >= 0.98" vid.stab/libvidstab.h vsMotionDetectInit
enabled libvmaf && require_pkg_config libvmaf "libvmaf >= 1.5.2" libvmaf.h compute_vmaf
@@ -6491,11 +6527,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"; }
@ -176,18 +174,24 @@ index d7a3f507e8..cfbbb4f27d 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
@@ -6536,6 +6573,10 @@ enabled rkmpp && { require_pkg_config rkmpp rockchip_mpp rockchip/r @@ -6536,8 +6577,16 @@ 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"; }
} }
+enabled v4l2_request && { enabled libdrm || +enabled v4l2_request && { enabled libdrm ||
+ die "ERROR: v4l2-request requires --enable-libdrm"; } && + die "ERROR: v4l2-request requires --enable-libdrm"; } &&
+ { enabled libudev || + { enabled libudev ||
+ die "ERROR: v4l2-request requires --enable-libudev"; } + die "ERROR: v4l2-request requires libudev"; }
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
+enabled vout_drm && { enabled libdrm || die "ERROR: vout_drm requires --enable-libdrm"; }
+
+enabled vout_egl && { enabled epoxy || die "ERROR: vout_egl requires epoxy"; } &&
+ { enabled xlib || die "ERROR: vout_egl requires xlib"; }
@@ -6617,6 +6658,8 @@ if enabled v4l2_m2m; then if enabled gcrypt; then
GCRYPT_CONFIG="${cross_prefix}libgcrypt-config"
@@ -6617,6 +6666,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
@ -50535,7 +50539,7 @@ index 8dbc7fc104..7d5fadcd3d 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 ff1ea8e57b..e4c848d6da 100644 index ff1ea8e57b..c0d257e5d3 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 @@
@ -51270,7 +51274,7 @@ index ff1ea8e57b..e4c848d6da 100644
pixfmt = ff_v4l2_format_v4l2_to_avfmt(fdesc.pixelformat, AV_CODEC_ID_RAWVIDEO); pixfmt = ff_v4l2_format_v4l2_to_avfmt(fdesc.pixelformat, AV_CODEC_ID_RAWVIDEO);
ret = v4l2_try_raw_format(ctx, pixfmt); ret = v4l2_try_raw_format(ctx, pixfmt);
if (ret){ if (ret){
@@ -569,18 +722,84 @@ static int v4l2_get_coded_format(V4L2Context* ctx, uint32_t *p) @@ -569,18 +722,83 @@ static int v4l2_get_coded_format(V4L2Context* ctx, uint32_t *p)
* *
*****************************************************************************/ *****************************************************************************/
@ -51317,22 +51321,25 @@ index ff1ea8e57b..e4c848d6da 100644
int ff_v4l2_context_set_status(V4L2Context* ctx, uint32_t cmd) int ff_v4l2_context_set_status(V4L2Context* ctx, uint32_t cmd)
{ {
int type = ctx->type; int type = ctx->type;
int ret; - int ret;
+ int ret = 0;
+ AVCodecContext * const avctx = logger(ctx); + AVCodecContext * const avctx = logger(ctx);
+
- ret = ioctl(ctx_to_m2mctx(ctx)->fd, cmd, &type);
- if (ret < 0)
- return AVERROR(errno);
+ // Avoid doing anything if there is nothing we can do + // Avoid doing anything if there is nothing we can do
+ if (cmd == VIDIOC_STREAMOFF && !ctx_buffers_alloced(ctx) && !ctx->streamon) + if (cmd == VIDIOC_STREAMOFF && !ctx_buffers_alloced(ctx) && !ctx->streamon)
+ return 0; + return 0;
+
- ctx->streamon = (cmd == VIDIOC_STREAMON);
+ ff_mutex_lock(&ctx->lock); + ff_mutex_lock(&ctx->lock);
+
- return 0;
+ if (cmd == VIDIOC_STREAMON && !V4L2_TYPE_IS_OUTPUT(ctx->type)) + if (cmd == VIDIOC_STREAMON && !V4L2_TYPE_IS_OUTPUT(ctx->type))
+ stuff_all_buffers(avctx, ctx); + stuff_all_buffers(avctx, ctx);
+
ret = ioctl(ctx_to_m2mctx(ctx)->fd, cmd, &type); + if (ioctl(ctx_to_m2mctx(ctx)->fd, cmd, &type) < 0) {
- if (ret < 0)
- return AVERROR(errno);
+ if (ret < 0) {
+ const int err = errno; + const int err = errno;
+ av_log(avctx, AV_LOG_ERROR, "%s set status %d (%s) failed: err=%d\n", ctx->name, + av_log(avctx, AV_LOG_ERROR, "%s set status %d (%s) failed: err=%d\n", ctx->name,
+ cmd, (cmd == VIDIOC_STREAMON) ? "ON" : "OFF", err); + cmd, (cmd == VIDIOC_STREAMON) ? "ON" : "OFF", err);
@ -51342,14 +51349,12 @@ index ff1ea8e57b..e4c848d6da 100644
+ { + {
+ if (cmd == VIDIOC_STREAMOFF) + if (cmd == VIDIOC_STREAMOFF)
+ flush_all_buffers_status(ctx); + flush_all_buffers_status(ctx);
+
- ctx->streamon = (cmd == VIDIOC_STREAMON);
+ ctx->streamon = (cmd == VIDIOC_STREAMON); + ctx->streamon = (cmd == VIDIOC_STREAMON);
+ av_log(avctx, AV_LOG_DEBUG, "%s set status %d (%s) OK\n", ctx->name, + av_log(avctx, AV_LOG_DEBUG, "%s set status %d (%s) OK\n", ctx->name,
+ cmd, (cmd == VIDIOC_STREAMON) ? "ON" : "OFF"); + cmd, (cmd == VIDIOC_STREAMON) ? "ON" : "OFF");
+ } + }
+
- return 0;
+ // Both stream off & on effectively clear flag_last + // Both stream off & on effectively clear flag_last
+ ctx->flag_last = 0; + ctx->flag_last = 0;
+ +
@ -51359,7 +51364,7 @@ index ff1ea8e57b..e4c848d6da 100644
} }
int ff_v4l2_context_enqueue_frame(V4L2Context* ctx, const AVFrame* frame) int ff_v4l2_context_enqueue_frame(V4L2Context* ctx, const AVFrame* frame)
@@ -608,7 +827,8 @@ int ff_v4l2_context_enqueue_frame(V4L2Context* ctx, const AVFrame* frame) @@ -608,7 +826,8 @@ int ff_v4l2_context_enqueue_frame(V4L2Context* ctx, const AVFrame* frame)
return ff_v4l2_buffer_enqueue(avbuf); return ff_v4l2_buffer_enqueue(avbuf);
} }
@ -51369,7 +51374,7 @@ index ff1ea8e57b..e4c848d6da 100644
{ {
V4L2m2mContext *s = ctx_to_m2mctx(ctx); V4L2m2mContext *s = ctx_to_m2mctx(ctx);
V4L2Buffer* avbuf; V4L2Buffer* avbuf;
@@ -616,8 +836,9 @@ int ff_v4l2_context_enqueue_packet(V4L2Context* ctx, const AVPacket* pkt) @@ -616,8 +835,9 @@ int ff_v4l2_context_enqueue_packet(V4L2Context* ctx, const AVPacket* pkt)
if (!pkt->size) { if (!pkt->size) {
ret = v4l2_stop_decode(ctx); ret = v4l2_stop_decode(ctx);
@ -51380,7 +51385,7 @@ index ff1ea8e57b..e4c848d6da 100644
s->draining = 1; s->draining = 1;
return 0; return 0;
} }
@@ -626,8 +847,11 @@ int ff_v4l2_context_enqueue_packet(V4L2Context* ctx, const AVPacket* pkt) @@ -626,8 +846,11 @@ int ff_v4l2_context_enqueue_packet(V4L2Context* ctx, const AVPacket* pkt)
if (!avbuf) if (!avbuf)
return AVERROR(EAGAIN); return AVERROR(EAGAIN);
@ -51394,7 +51399,7 @@ index ff1ea8e57b..e4c848d6da 100644
return ret; return ret;
return ff_v4l2_buffer_enqueue(avbuf); return ff_v4l2_buffer_enqueue(avbuf);
@@ -636,19 +860,10 @@ int ff_v4l2_context_enqueue_packet(V4L2Context* ctx, const AVPacket* pkt) @@ -636,19 +859,10 @@ int ff_v4l2_context_enqueue_packet(V4L2Context* ctx, const AVPacket* pkt)
int ff_v4l2_context_dequeue_frame(V4L2Context* ctx, AVFrame* frame, int timeout) int ff_v4l2_context_dequeue_frame(V4L2Context* ctx, AVFrame* frame, int timeout)
{ {
V4L2Buffer *avbuf; V4L2Buffer *avbuf;
@ -51417,7 +51422,7 @@ index ff1ea8e57b..e4c848d6da 100644
return ff_v4l2_buffer_buf_to_avframe(frame, avbuf); return ff_v4l2_buffer_buf_to_avframe(frame, avbuf);
} }
@@ -656,19 +871,10 @@ int ff_v4l2_context_dequeue_frame(V4L2Context* ctx, AVFrame* frame, int timeout) @@ -656,19 +870,10 @@ int ff_v4l2_context_dequeue_frame(V4L2Context* ctx, AVFrame* frame, int timeout)
int ff_v4l2_context_dequeue_packet(V4L2Context* ctx, AVPacket* pkt) int ff_v4l2_context_dequeue_packet(V4L2Context* ctx, AVPacket* pkt)
{ {
V4L2Buffer *avbuf; V4L2Buffer *avbuf;
@ -51440,7 +51445,7 @@ index ff1ea8e57b..e4c848d6da 100644
return ff_v4l2_buffer_buf_to_avpkt(pkt, avbuf); return ff_v4l2_buffer_buf_to_avpkt(pkt, avbuf);
} }
@@ -702,78 +908,160 @@ int ff_v4l2_context_get_format(V4L2Context* ctx, int probe) @@ -702,78 +907,160 @@ 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)
{ {
@ -51583,8 +51588,7 @@ index ff1ea8e57b..e4c848d6da 100644
+ +
+ // It is not valid to reinit a context without a previous release + // It is not valid to reinit a context without a previous release
+ av_assert0(ctx->bufrefs == NULL); + av_assert0(ctx->bufrefs == NULL);
+
- av_freep(&ctx->buffers);
+ if (!v4l2_type_supported(ctx)) { + if (!v4l2_type_supported(ctx)) {
+ av_log(logger(ctx), AV_LOG_ERROR, "type %i not supported\n", ctx->type); + av_log(logger(ctx), AV_LOG_ERROR, "type %i not supported\n", ctx->type);
+ return AVERROR_PATCHWELCOME; + return AVERROR_PATCHWELCOME;
@ -51612,7 +51616,8 @@ index ff1ea8e57b..e4c848d6da 100644
+ if (ret < 0) + if (ret < 0)
+ goto fail_unref_hwframes; + goto fail_unref_hwframes;
+ } + }
+
- av_freep(&ctx->buffers);
+ ret = ioctl(s->fd, VIDIOC_G_FMT, &ctx->format); + ret = ioctl(s->fd, VIDIOC_G_FMT, &ctx->format);
+ if (ret) { + if (ret) {
+ ret = AVERROR(errno); + ret = AVERROR(errno);
@ -51708,7 +51713,7 @@ index 22a9532444..a56216e990 100644
/** /**
* Enqueues a buffer to a V4L2Context from an AVFrame * Enqueues a buffer to a V4L2Context from an AVFrame
diff --git a/libavcodec/v4l2_m2m.c b/libavcodec/v4l2_m2m.c diff --git a/libavcodec/v4l2_m2m.c b/libavcodec/v4l2_m2m.c
index cdfd579810..010b4232d4 100644 index cdfd579810..f14ed0b708 100644
--- a/libavcodec/v4l2_m2m.c --- a/libavcodec/v4l2_m2m.c
+++ b/libavcodec/v4l2_m2m.c +++ b/libavcodec/v4l2_m2m.c
@@ -215,13 +215,7 @@ int ff_v4l2_m2m_codec_reinit(V4L2m2mContext *s) @@ -215,13 +215,7 @@ int ff_v4l2_m2m_codec_reinit(V4L2m2mContext *s)
@ -51741,7 +51746,7 @@ index cdfd579810..010b4232d4 100644
ret = ff_v4l2_context_get_format(&s->output, 0); ret = ff_v4l2_context_get_format(&s->output, 0);
if (ret) { if (ret) {
@@ -328,11 +320,14 @@ static void v4l2_m2m_destroy_context(void *opaque, uint8_t *context) @@ -328,10 +320,14 @@ static void v4l2_m2m_destroy_context(void *opaque, uint8_t *context)
ff_v4l2_context_release(&s->capture); ff_v4l2_context_release(&s->capture);
sem_destroy(&s->refsync); sem_destroy(&s->refsync);
@ -51751,13 +51756,13 @@ index cdfd579810..010b4232d4 100644
av_frame_unref(s->frame); av_frame_unref(s->frame);
av_frame_free(&s->frame); av_frame_free(&s->frame);
av_packet_unref(&s->buf_pkt); av_packet_unref(&s->buf_pkt);
+ av_freep(&s->extdata_data);
+ av_log(s->avctx, AV_LOG_DEBUG, "V4L2 Context destroyed\n");
+ +
+ av_log(s->avctx, AV_LOG_DEBUG, "V4L2 Context destroyed\n");
av_free(s); av_free(s);
} }
@@ -344,6 +340,11 @@ int ff_v4l2_m2m_codec_end(V4L2m2mPriv *priv)
@@ -344,6 +339,11 @@ int ff_v4l2_m2m_codec_end(V4L2m2mPriv *priv)
if (!s) if (!s)
return 0; return 0;
@ -51769,7 +51774,7 @@ index cdfd579810..010b4232d4 100644
if (s->fd >= 0) { if (s->fd >= 0) {
ret = ff_v4l2_context_set_status(&s->output, VIDIOC_STREAMOFF); ret = ff_v4l2_context_set_status(&s->output, VIDIOC_STREAMOFF);
if (ret) if (ret)
@@ -356,7 +356,14 @@ int ff_v4l2_m2m_codec_end(V4L2m2mPriv *priv) @@ -356,7 +357,14 @@ int ff_v4l2_m2m_codec_end(V4L2m2mPriv *priv)
ff_v4l2_context_release(&s->output); ff_v4l2_context_release(&s->output);
@ -51785,7 +51790,7 @@ index cdfd579810..010b4232d4 100644
return 0; return 0;
diff --git a/libavcodec/v4l2_m2m.h b/libavcodec/v4l2_m2m.h diff --git a/libavcodec/v4l2_m2m.h b/libavcodec/v4l2_m2m.h
index b67b216331..6bd5e8eda7 100644 index b67b216331..19d618698d 100644
--- a/libavcodec/v4l2_m2m.h --- a/libavcodec/v4l2_m2m.h
+++ b/libavcodec/v4l2_m2m.h +++ b/libavcodec/v4l2_m2m.h
@@ -30,6 +30,7 @@ @@ -30,6 +30,7 @@
@ -51844,7 +51849,7 @@ index b67b216331..6bd5e8eda7 100644
/* null frame/packet received */ /* null frame/packet received */
int draining; int draining;
@@ -66,6 +97,30 @@ typedef struct V4L2m2mContext { @@ -66,6 +97,33 @@ typedef struct V4L2m2mContext {
/* reference back to V4L2m2mPriv */ /* reference back to V4L2m2mPriv */
void *priv; void *priv;
@ -51866,6 +51871,9 @@ index b67b216331..6bd5e8eda7 100644
+ +
+ /* Ext data sent */ + /* Ext data sent */
+ int extdata_sent; + int extdata_sent;
+ /* Ext data sent in packet - overrides ctx */
+ uint8_t * extdata_data;
+ size_t extdata_size;
+ +
+#define FF_V4L2_QUIRK_REINIT_ALWAYS 1 +#define FF_V4L2_QUIRK_REINIT_ALWAYS 1
+#define FF_V4L2_QUIRK_ENUM_FRAMESIZES_BROKEN 2 +#define FF_V4L2_QUIRK_ENUM_FRAMESIZES_BROKEN 2
@ -51875,7 +51883,7 @@ index b67b216331..6bd5e8eda7 100644
} V4L2m2mContext; } V4L2m2mContext;
typedef struct V4L2m2mPriv { typedef struct V4L2m2mPriv {
@@ -76,6 +131,7 @@ typedef struct V4L2m2mPriv { @@ -76,6 +134,7 @@ typedef struct V4L2m2mPriv {
int num_output_buffers; int num_output_buffers;
int num_capture_buffers; int num_capture_buffers;
@ -51883,7 +51891,7 @@ index b67b216331..6bd5e8eda7 100644
} V4L2m2mPriv; } V4L2m2mPriv;
/** /**
@@ -129,4 +185,26 @@ int ff_v4l2_m2m_codec_reinit(V4L2m2mContext *ctx); @@ -129,4 +188,26 @@ int ff_v4l2_m2m_codec_reinit(V4L2m2mContext *ctx);
*/ */
int ff_v4l2_m2m_codec_full_reinit(V4L2m2mContext *ctx); int ff_v4l2_m2m_codec_full_reinit(V4L2m2mContext *ctx);
@ -51911,7 +51919,7 @@ index b67b216331..6bd5e8eda7 100644
+ +
#endif /* AVCODEC_V4L2_M2M_H */ #endif /* AVCODEC_V4L2_M2M_H */
diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
index ab07c0a24a..a3d9f1b790 100644 index ab07c0a24a..dd383f31e5 100644
--- a/libavcodec/v4l2_m2m_dec.c --- a/libavcodec/v4l2_m2m_dec.c
+++ b/libavcodec/v4l2_m2m_dec.c +++ b/libavcodec/v4l2_m2m_dec.c
@@ -23,6 +23,10 @@ @@ -23,6 +23,10 @@
@ -51925,7 +51933,7 @@ index ab07c0a24a..a3d9f1b790 100644
#include "libavutil/pixfmt.h" #include "libavutil/pixfmt.h"
#include "libavutil/pixdesc.h" #include "libavutil/pixdesc.h"
#include "libavutil/opt.h" #include "libavutil/opt.h"
@@ -30,75 +34,102 @@ @@ -30,75 +34,107 @@
#include "libavcodec/decode.h" #include "libavcodec/decode.h"
#include "libavcodec/internal.h" #include "libavcodec/internal.h"
@ -52022,21 +52030,16 @@ index ab07c0a24a..a3d9f1b790 100644
- ret = ioctl(s->fd, VIDIOC_G_FMT, &capture->format); - ret = ioctl(s->fd, VIDIOC_G_FMT, &capture->format);
- if (ret) { - if (ret) {
- av_log(avctx, AV_LOG_WARNING, "VIDIOC_G_FMT ioctl\n"); - av_log(avctx, AV_LOG_WARNING, "VIDIOC_G_FMT ioctl\n");
- return ret;
- }
+ ret = ff_v4l2_context_set_status(&s->output, VIDIOC_STREAMON); + ret = ff_v4l2_context_set_status(&s->output, VIDIOC_STREAMON);
+ if (ret < 0) + if (ret != 0) {
+ av_log(avctx, AV_LOG_ERROR, "VIDIOC_STREAMON on output context\n"); + av_log(avctx, AV_LOG_ERROR, "VIDIOC_STREAMON on output context: %s\n", av_err2str(ret));
return ret;
}
- /* 2.1 update the AVCodecContext */ - /* 2.1 update the AVCodecContext */
- avctx->pix_fmt = ff_v4l2_format_v4l2_to_avfmt(capture->format.fmt.pix_mp.pixelformat, AV_CODEC_ID_RAWVIDEO); - avctx->pix_fmt = ff_v4l2_format_v4l2_to_avfmt(capture->format.fmt.pix_mp.pixelformat, AV_CODEC_ID_RAWVIDEO);
- capture->av_pix_fmt = avctx->pix_fmt; - capture->av_pix_fmt = avctx->pix_fmt;
+ ret = ioctl(s->fd, VIDIOC_DECODER_CMD, &cmd); -
+ if (ret < 0)
+ av_log(avctx, AV_LOG_ERROR, "VIDIOC_DECODER_CMD start error: %d\n", errno);
+ else
+ av_log(avctx, AV_LOG_DEBUG, "VIDIOC_DECODER_CMD start OK\n");
- /* 3. set the crop parameters */ - /* 3. set the crop parameters */
- selection.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - selection.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- selection.r.height = avctx->coded_height; - selection.r.height = avctx->coded_height;
@ -52052,10 +52055,13 @@ index ab07c0a24a..a3d9f1b790 100644
- capture->height = selection.r.height; - capture->height = selection.r.height;
- capture->width = selection.r.width; - capture->width = selection.r.width;
- } - }
- } + // STREAMON should do implicit START so this just for those that don't.
+ return ret; + // It is optional so don't worry if it fails
+} + if (ioctl(s->fd, VIDIOC_DECODER_CMD, &cmd) < 0) {
+ ret = AVERROR(errno);
+ av_log(avctx, AV_LOG_WARNING, "VIDIOC_DECODER_CMD start error: %s\n", av_err2str(ret));
}
-
- /* 4. init the capture context now that we have the capture format */ - /* 4. init the capture context now that we have the capture format */
- if (!capture->buffers) { - if (!capture->buffers) {
- ret = ff_v4l2_context_init(capture); - ret = ff_v4l2_context_init(capture);
@ -52063,25 +52069,30 @@ index ab07c0a24a..a3d9f1b790 100644
- av_log(avctx, AV_LOG_ERROR, "can't request capture buffers\n"); - av_log(avctx, AV_LOG_ERROR, "can't request capture buffers\n");
- return AVERROR(ENOMEM); - return AVERROR(ENOMEM);
- } - }
+ else {
+ av_log(avctx, AV_LOG_TRACE, "VIDIOC_DECODER_CMD start OK\n");
}
+ return 0;
+}
- /* 5. start the capture process */
- ret = ff_v4l2_context_set_status(capture, VIDIOC_STREAMON);
- if (ret) {
- av_log(avctx, AV_LOG_DEBUG, "VIDIOC_STREAMON, on capture context\n");
- return ret;
- } - }
+static int v4l2_try_start(AVCodecContext *avctx) +static int v4l2_try_start(AVCodecContext *avctx)
+{ +{
+ V4L2m2mContext * const s = ((V4L2m2mPriv*)avctx->priv_data)->context; + V4L2m2mContext * const s = ((V4L2m2mPriv*)avctx->priv_data)->context;
+ int ret; + int ret;
- /* 5. start the capture process */
- ret = ff_v4l2_context_set_status(capture, VIDIOC_STREAMON);
- if (ret) {
- av_log(avctx, AV_LOG_DEBUG, "VIDIOC_STREAMON, on capture context\n");
+ /* 1. start the output process */ + /* 1. start the output process */
+ if ((ret = check_output_streamon(avctx, s)) != 0) + if ((ret = check_output_streamon(avctx, s)) != 0)
return ret; + return ret;
- }
-
return 0; return 0;
} }
@@ -133,58 +164,588 @@ static int v4l2_prepare_decoder(V4L2m2mContext *s) @@ -133,58 +169,637 @@ static int v4l2_prepare_decoder(V4L2m2mContext *s)
return 0; return 0;
} }
@ -52265,12 +52276,52 @@ index ab07c0a24a..a3d9f1b790 100644
int ret; int ret;
- if (!s->buf_pkt.size) { - if (!s->buf_pkt.size) {
- ret = ff_decode_get_packet(avctx, &s->buf_pkt);
- if (ret < 0 && ret != AVERROR_EOF)
+ // If we don't already have a coded packet - get a new one + // If we don't already have a coded packet - get a new one
+ // We will already have a coded pkt if the output Q was full last time we + // We will already have a coded pkt if the output Q was full last time we
+ // tried to Q it + // tried to Q it
+ if (!s->buf_pkt.size && !do_not_get) { + if (!s->buf_pkt.size && !do_not_get) {
ret = ff_decode_get_packet(avctx, &s->buf_pkt); + unsigned int i;
- if (ret < 0 && ret != AVERROR_EOF) +
+ for (i = 0; i < 256; ++i) {
+ uint8_t * side_data;
+ size_t side_size;
+
+ ret = ff_decode_get_packet(avctx, &s->buf_pkt);
+ if (ret != 0)
+ break;
+
+ // New extradata is the only side-data we undertand
+ side_data = av_packet_get_side_data(&s->buf_pkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size);
+ if (side_data) {
+ av_log(avctx, AV_LOG_DEBUG, "New extradata\n");
+ av_freep(&s->extdata_data);
+ if ((s->extdata_data = av_malloc(side_size ? side_size : 1)) == NULL) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to alloc %zd bytes of extra data\n", side_size);
+ return AVERROR(ENOMEM);
+ }
+ memcpy(s->extdata_data, side_data, side_size);
+ s->extdata_size = side_size;
+ s->extdata_sent = 0;
+ }
+
+ if (s->buf_pkt.size != 0)
+ break;
+
+ if (s->buf_pkt.side_data_elems == 0) {
+ av_log(avctx, AV_LOG_WARNING, "Empty pkt from ff_decode_get_packet - treating as EOF\n");
+ ret = AVERROR_EOF;
+ break;
+ }
+
+ // Retry a side-data only pkt
+ }
+ // If i >= 256 something has gone wrong
+ if (i >= 256) {
+ av_log(avctx, AV_LOG_ERROR, "Too many side-data only packets\n");
+ return AVERROR(EIO);
+ }
+ +
+ if (ret == AVERROR(EAGAIN)) { + if (ret == AVERROR(EAGAIN)) {
+ if (!stream_started(s)) { + if (!stream_started(s)) {
@ -52330,8 +52381,12 @@ index ab07c0a24a..a3d9f1b790 100644
- ret = ff_v4l2_context_enqueue_packet(output, &s->buf_pkt); - ret = ff_v4l2_context_enqueue_packet(output, &s->buf_pkt);
- if (ret < 0 && ret != AVERROR(EAGAIN)) - if (ret < 0 && ret != AVERROR(EAGAIN))
- goto fail; - goto fail;
+ ret = ff_v4l2_context_enqueue_packet(&s->output, &s->buf_pkt, + if (s->extdata_sent)
+ avctx->extradata, s->extdata_sent ? 0 : avctx->extradata_size); + ret = ff_v4l2_context_enqueue_packet(&s->output, &s->buf_pkt, NULL, 0);
+ else if (s->extdata_data)
+ ret = ff_v4l2_context_enqueue_packet(&s->output, &s->buf_pkt, s->extdata_data, s->extdata_size);
+ else
+ ret = ff_v4l2_context_enqueue_packet(&s->output, &s->buf_pkt, avctx->extradata, avctx->extradata_size);
- /* if EAGAIN don't unref packet and try to enqueue in the next iteration */ - /* if EAGAIN don't unref packet and try to enqueue in the next iteration */
- if (ret != AVERROR(EAGAIN)) - if (ret != AVERROR(EAGAIN))
@ -52405,13 +52460,14 @@ index ab07c0a24a..a3d9f1b790 100644
+static int v4l2_receive_frame(AVCodecContext *avctx, AVFrame *frame) +static int v4l2_receive_frame(AVCodecContext *avctx, AVFrame *frame)
+{ +{
+ V4L2m2mContext *const s = ((V4L2m2mPriv*)avctx->priv_data)->context; + V4L2m2mContext *const s = ((V4L2m2mPriv*)avctx->priv_data)->context;
+ int src_rv; + int src_rv = NQ_OK;
+ int dst_rv = 1; // Non-zero (done), non-negative (error) number + int dst_rv = 1; // Non-zero (done), non-negative (error) number
+ unsigned int i = 0; + unsigned int i = 0;
+ +
+ do { + do {
+ const int pending = xlat_pending(&s->xlat); + const int pending = xlat_pending(&s->xlat);
+ const int prefer_dq = (pending > s->pending_hw / 16); + const int prefer_dq = (pending > s->pending_hw / 16);
+ const int last_src_rv = src_rv;
+ +
+ // Enqueue another pkt for decode if + // Enqueue another pkt for decode if
+ // (a) We don't have a lot of stuff in the buffer already OR + // (a) We don't have a lot of stuff in the buffer already OR
@ -52427,6 +52483,11 @@ index ab07c0a24a..a3d9f1b790 100644
+ if ((i != 0 || s->req_pkt) && src_rv == NQ_SRC_EMPTY) + if ((i != 0 || s->req_pkt) && src_rv == NQ_SRC_EMPTY)
+ break; + break;
+ +
+ if (src_rv == NQ_Q_FULL && last_src_rv == NQ_Q_FULL) {
+ av_log(avctx, AV_LOG_WARNING, "Poll thinks src Q has space; none found\n");
+ break;
+ }
+
+ // Try to get a new frame if + // Try to get a new frame if
+ // (a) we haven't already got one AND + // (a) we haven't already got one AND
+ // (b) enqueue returned a status indicating that decode should be attempted + // (b) enqueue returned a status indicating that decode should be attempted
@ -52484,7 +52545,7 @@ index ab07c0a24a..a3d9f1b790 100644
+ +
+ ++i; + ++i;
+ if (i >= 256) { + if (i >= 256) {
+ av_log(avctx, AV_LOG_ERROR, "Unexpectedly large retry count: %d", i); + av_log(avctx, AV_LOG_ERROR, "Unexpectedly large retry count: %d\n", i);
+ src_rv = AVERROR(EIO); + src_rv = AVERROR(EIO);
+ } + }
+ +
@ -52693,7 +52754,7 @@ index ab07c0a24a..a3d9f1b790 100644
capture = &s->capture; capture = &s->capture;
output = &s->output; output = &s->output;
@@ -192,14 +753,53 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx) @@ -192,14 +807,53 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx)
* by the v4l2 driver; this event will trigger a full pipeline reconfig and * by the v4l2 driver; this event will trigger a full pipeline reconfig and
* the proper values will be retrieved from the kernel driver. * the proper values will be retrieved from the kernel driver.
*/ */
@ -52749,7 +52810,7 @@ index ab07c0a24a..a3d9f1b790 100644
s->avctx = avctx; s->avctx = avctx;
ret = ff_v4l2_m2m_codec_init(priv); ret = ff_v4l2_m2m_codec_init(priv);
@@ -208,12 +808,74 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx) @@ -208,12 +862,74 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx)
return ret; return ret;
} }
@ -52826,7 +52887,7 @@ index ab07c0a24a..a3d9f1b790 100644
} }
#define OFFSET(x) offsetof(V4L2m2mPriv, x) #define OFFSET(x) offsetof(V4L2m2mPriv, x)
@@ -222,10 +884,16 @@ static av_cold int v4l2_decode_close(AVCodecContext *avctx) @@ -222,10 +938,16 @@ static av_cold int v4l2_decode_close(AVCodecContext *avctx)
static const AVOption options[] = { static const AVOption options[] = {
V4L_M2M_DEFAULT_OPTS, V4L_M2M_DEFAULT_OPTS,
{ "num_capture_buffers", "Number of buffers in the capture context", { "num_capture_buffers", "Number of buffers in the capture context",
@ -52844,7 +52905,7 @@ index ab07c0a24a..a3d9f1b790 100644
#define M2MDEC_CLASS(NAME) \ #define M2MDEC_CLASS(NAME) \
static const AVClass v4l2_m2m_ ## NAME ## _dec_class = { \ static const AVClass v4l2_m2m_ ## NAME ## _dec_class = { \
.class_name = #NAME "_v4l2m2m_decoder", \ .class_name = #NAME "_v4l2m2m_decoder", \
@@ -246,9 +914,15 @@ static const AVOption options[] = { @@ -246,9 +968,15 @@ static const AVOption options[] = {
.init = v4l2_decode_init, \ .init = v4l2_decode_init, \
.receive_frame = v4l2_receive_frame, \ .receive_frame = v4l2_receive_frame, \
.close = v4l2_decode_close, \ .close = v4l2_decode_close, \
@ -65316,10 +65377,10 @@ 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..65576846e8 index 0000000000..37cea71756
--- /dev/null --- /dev/null
+++ b/pi-util/conf_native.sh +++ b/pi-util/conf_native.sh
@@ -0,0 +1,108 @@ @@ -0,0 +1,106 @@
+echo "Configure for native build" +echo "Configure for native build"
+ +
+FFSRC=`pwd` +FFSRC=`pwd`
@ -65413,8 +65474,6 @@ index 0000000000..65576846e8
+ --disable-thumb\ + --disable-thumb\
+ --enable-v4l2-request\ + --enable-v4l2-request\
+ --enable-libdrm\ + --enable-libdrm\
+ --enable-epoxy\
+ --enable-libudev\
+ --enable-vout-egl\ + --enable-vout-egl\
+ --enable-vout-drm\ + --enable-vout-drm\
+ $SHARED_LIBS\ + $SHARED_LIBS\