Compare commits
135 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a7cb7a2e43 | |||
| b429df281d | |||
| 7ce56329e7 | |||
| dbef08b60f | |||
| 77d244e7a9 | |||
| 8cee4190f3 | |||
| 04ce4cc072 | |||
| 5d208aac52 | |||
| 83bfd4f3b5 | |||
| 9bf40978c6 | |||
| 1e50a327c6 | |||
| ad12d9df1e | |||
| 67d030787e | |||
| c90836cc3d | |||
| 6c0124d392 | |||
| 29619a8ac2 | |||
| 09683e1f4e | |||
| 662b6351c8 | |||
| b8dd1d2d4b | |||
| 92335fc02b | |||
| ff491b1544 | |||
| 4e624c89fd | |||
| 9495228df0 | |||
| 339f40f618 | |||
| ec22b46a4d | |||
| 11375cd101 | |||
| f7f3937494 | |||
| cc5361ed18 | |||
| 4d1fcd734e | |||
| 8066cb3556 | |||
| d25f388584 | |||
| 1a82246cae | |||
| 7e204f7260 | |||
| 53f3f5233f | |||
| 110eff79ca | |||
| 33c8009773 | |||
| 74700e50bf | |||
| 00cdf4e4e5 | |||
| bcc71f30ad | |||
| 31a1d2aa83 | |||
| 7816497ba0 | |||
| 953f97979f | |||
| e75a73d629 | |||
| b482e94e59 | |||
| 0f1332309a | |||
| f5c9753bfd | |||
| d8b8b27dc3 | |||
| 62f5325ca3 | |||
| bcfd82b0be | |||
| 31fa50f3d9 | |||
| 552733d48b | |||
| a8b5990f45 | |||
| cb6af7dfa1 | |||
| 29d978c91e | |||
| 3a52cae2c7 | |||
| 792df36f42 | |||
| c694273feb | |||
| 9239d58b36 | |||
| 1623f42d99 | |||
| 99576bf034 | |||
| e385fc45dd | |||
| 15857674c5 | |||
| 6b6c854658 | |||
| 41ee513c81 | |||
| 33b4aba5bd | |||
| ea279bd160 | |||
| 929b5519d8 | |||
| 5ed024e40b | |||
| 5550946ff4 | |||
| daef9d4382 | |||
| 69f50eb915 | |||
| 73c90818b1 | |||
| c22b67feaa | |||
| 4c0be3a60c | |||
| 42357b37cb | |||
| e3fbbb7d18 | |||
| 2f75965c47 | |||
| e1f40f0dae | |||
| 45f5f2086e | |||
| 321c418b87 | |||
| f5859d4a8e | |||
| 54fbdacc37 | |||
| 228f17ced3 | |||
| 9b5a6bb67b | |||
| 219cbc5527 | |||
| 55c36d2498 | |||
| 558ba71de5 | |||
| 1a5db666ac | |||
| eee0cf487a | |||
| 90db1e441f | |||
| 4fe90900d8 | |||
| ee349bd0fd | |||
| ab744447e1 | |||
| 89d65915cf | |||
| e69bb0fb05 | |||
| 98a9d868d1 | |||
| b66152a4e5 | |||
| ac50246cc4 | |||
| ddc284300e | |||
| b420f23566 | |||
| 5356e61001 | |||
| a4ddc3c9fc | |||
| 59e30c05d7 | |||
| fcffed470a | |||
| 9efc591cb7 | |||
| d4c5f515f0 | |||
| bb01cd3cc0 | |||
| fed94c2f22 | |||
| a9e9303f26 | |||
| 49bc641e89 | |||
| 4f1e07090a | |||
| 11dff170ef | |||
| 10506de9ad | |||
| af3fccfeff | |||
| ec1b5216fc | |||
| 066ff02621 | |||
| 398a70309e | |||
| acd13f1255 | |||
| 1c98cf4ddd | |||
| 63c1e291ef | |||
| 7ebc27e1fa | |||
| bc5777bdab | |||
| 7d23ccac8d | |||
| 2f04b78b95 | |||
| fd05e20650 | |||
| a163384467 | |||
| b9875b7583 | |||
| ebc1c49e41 | |||
| 6feec11e48 | |||
| 67126555fc | |||
| 041231fcd6 | |||
| 765fb1f224 | |||
| 5060a615c7 | |||
| 1665ac6a44 | |||
| 3c7e973430 |
@@ -1,6 +1,118 @@
|
||||
Entries are sorted chronologically from oldest to youngest within each release,
|
||||
releases are sorted from youngest to oldest.
|
||||
|
||||
version 4.1.2:
|
||||
- avcodec/dfa: Check the chunk header is not truncated
|
||||
- avcodec/clearvideo: Check remaining data in P frames
|
||||
- avcodec/hevcdec: decode at most one slice reporting being the first in the picture
|
||||
- avcodec/dvbsubdec: Check object position
|
||||
- avcodec/cdgraphics: Use ff_set_dimensions()
|
||||
- avformat/gdv: Check fps
|
||||
- configure: use vpx_codec_vp8_dx/cx for libvpx-vp8 checking
|
||||
- configure: add missing pthreads extralibs dependency for libvpx-vp9
|
||||
- avcodec/mpeg4videodec: Check idx in mpeg4_decode_studio_block()
|
||||
- avcodec/dxv: Correct integer overflow in get_opcodes()
|
||||
- avcodec/scpr: Fix use of uninitialized variable
|
||||
- avcodec/qpeg: Limit copy in qpeg_decode_intra() to the available bytes
|
||||
- avcodec/aic: Check remaining bits in aic_decode_coeffs()
|
||||
- avcodec/gdv: Check for truncated tags in decompress_5()
|
||||
- avcodec/bethsoftvideo: Check block_type
|
||||
- avcodec/jpeg2000dwt: Fix integer overflow in dwt_decode97_int()
|
||||
- avcodec/error_resilience: Use a symmetric check for skipping MV estimation
|
||||
- avcodec/mlpdec: Insuffient typo
|
||||
- avcodec/zmbv: obtain frame later
|
||||
- avcodec/jvdec: Check available input space before decode8x8()
|
||||
- avcodec/h264_direct: Fix overflow in POC comparission
|
||||
- avformat/webmdashenc: Check id in adaption_sets
|
||||
- avformat/http: Fix Out-of-Bounds access in process_line()
|
||||
- avformat/ftp: Fix Out-of-Bounds Access and Information Leak in ftp.c:393
|
||||
- avcodec/htmlsubtitles: Fixes denial of service due to use of sscanf in inner loop for handling braces
|
||||
- avcodec/htmlsubtitles: Fixes denial of service due to use of sscanf in inner loop for tag scaning
|
||||
- avformat/matroskadec: Do not leak queued packets on sync errors
|
||||
- avcodec/mpeg4videodec: Clear interlaced_dct for studio profile
|
||||
- avformat/mov: Do not use reference stream in mov_read_sidx() if there is no reference stream
|
||||
- avcodec/sbrdsp_fixed.c: remove input value limit for sbr_sum_square_c()
|
||||
- avcodec/prores_ks: Fix luma quantization if q >= MAX_STORED_Q
|
||||
- avformat/mov: fix hang while seek on a kind of fragmented mp4
|
||||
- avformat/async: fix assertion condition when draining buffer
|
||||
- avcodec/cbs_av1: don't call cbs_av1_read_trailing_bits() when no bits remain in the OBU
|
||||
|
||||
version 4.1.1:
|
||||
- avformat/mov: validate chunk_count vs stsc_data
|
||||
- avformat/mov: require tfhd to begin parsing trun
|
||||
- avcodec/pgssubdec: Check for duplicate display segments
|
||||
- avformat/rtsp: Check number of streams in sdp_parse_line()
|
||||
- avformat/rtsp: Clear reply in every iteration in ff_rtsp_connect()
|
||||
- avcodec/rasc: Move ff_get_buffer() after frame checks
|
||||
- avcodec/rasc: Check uncompressed dlta size
|
||||
- avcodec/fic: Check that there is input left in fic_decode_block()
|
||||
- avcodec/ilbcdec: Fix undefined integer overflow lsf2poly()
|
||||
- avcodec/ilbcdec: Fix integer overflow in construct_vector()
|
||||
- avcodec/prosumer: Error out if decompress() stops reading data
|
||||
- avcodec/tiff: Check for 12bit gray fax
|
||||
- avutil/imgutils: Optimize memset_bytes() by using av_memcpy_backptr()
|
||||
- avutil/mem: Optimize fill32() by unrolling and using 64bit
|
||||
- configure: bump year
|
||||
- avcodec/tests/rangecoder: initialize array to avoid valgrind warning
|
||||
- avcodec/gdv: Optimize and factorize scaling loops
|
||||
- avcodec/h264_slice: Fix integer overflow in implicit_weight_table()
|
||||
- avcodec/exr: set layer_match in all branches
|
||||
- avcodec/exr: Check for duplicate channel index
|
||||
- avfilter/vf_tonemap_opencl: Make static tables const
|
||||
- doc/indevs: fix upto typo
|
||||
- avcodec/4xm: Fix returned error codes
|
||||
- avformat/libopenmpt: Fix successfull typo
|
||||
- avcodec/v4l2_m2m: fix cant typo
|
||||
- avcodec/mjpegbdec: Fix some misplaced {} and spaces
|
||||
- avformat/wvdec: detect and error out on WavPack DSD files
|
||||
- avcodec/mips: Fix failed case: hevc-conformance-AMP_A_Samsung_* when enable msa
|
||||
- avcodec/fic: Fail on invalid slice size/off
|
||||
- avcodec/ilbcdec: fix integer overflow in energy
|
||||
- postproc/postprocess_template: remove FF_REG_sp from clobber list
|
||||
- postproc/postprocess_template: Avoid using %4 for the threshold compare
|
||||
- libavformat/mov: Fix NULL-dereference read for some encrypted content.
|
||||
- avcodec/rpza: Check that there is enough data for all the blocks
|
||||
- avcodec/rpza: Move frame allocation to a later point
|
||||
- avcodec/avcodec: Document the data type for AV_PKT_DATA_MPEGTS_STREAM_ID
|
||||
- avformat/mpegts: Fix side data type for stream id
|
||||
- tests/fate/filter-video: increase fuzz for fate-filter-refcmp-psnr-rgb
|
||||
- avcodec/mjpegdec: Fix indention of ljpeg_decode_yuv_scan()
|
||||
- lavf/id3v2: fail read_apic on EOF reading mimetype
|
||||
- avcodec/rasc: Check that the number of moves is less than or equal the number of pixels
|
||||
- avformat/nutenc: Document trailer index assert better
|
||||
- lavf/mov: ensure only one tkhd per trak
|
||||
- avcodec/clearvideo: Check remaining input bits in P macro block loop
|
||||
- avcodec/rasc: Check input space before reading chunk
|
||||
- avcodec/dxv: Check that there is enough data to decompress
|
||||
- avcodec/ppc/hevcdsp: Fix build failures with powerpc-linux-gnu-gcc-4.8 with --disable-optimizations
|
||||
- avcodec/msvideo1: Check for too small dimensions
|
||||
- avcodec/wmv2dec: Skip I frame if its smaller than 1/8 of the minimal size
|
||||
- avcodec/msmpeg4dec: Skip frame if its smaller than 1/8 of the minimal size
|
||||
- avcodec/truemotion2rt: Fix rounding in input size check
|
||||
- avcodec/diracdec: Check component quant
|
||||
- avcodec/tiff: Limit filtering to decoded data
|
||||
- avcodec/truemotion2: fix integer overflows in tm2_low_chroma()
|
||||
- avcodec/pngdec: Check compression method
|
||||
- fftools/ffmpeg: Repair reinit_filter feature
|
||||
- avcodec/shorten: Fix integer overflow with offset
|
||||
- avcodec/imm4: Use ff_set_dimensions()
|
||||
- h264_redundant_pps: Fix logging context
|
||||
- avfilter/af_asetnsamples: fix last frame props
|
||||
- cbs_av1: Fix reading of overlong uvlc codes
|
||||
- avcodec/cbs_av1: fix parsing delta_frame_id_minus1
|
||||
- avfilter/vf_overlay: fix filtering with negative y
|
||||
- avformat/movenc: get number of written bytes from bitstream writer
|
||||
- avformat/movenc: fix size calculation in mov_write_eac3_tag()
|
||||
- avfilter/vf_overlay: fix crash with negative y
|
||||
- avcodec/mpeg_er: fix clearing chroma blocks for 422 and 444
|
||||
- avfilter/af_afade: fix duration maximum
|
||||
- avfilter/vf_fade: fix start/duration max value
|
||||
- avcodec/cbs_av1: fix parsing signed integer values
|
||||
- avcodec/cbs_av1: fix storage size for segmentation_params feature_value fields
|
||||
- configure: Add missing xlib dependency for VAAPI X11 code
|
||||
- avcodec/hevcdec: fix non-ref frame judgement
|
||||
|
||||
|
||||
version 4.1:
|
||||
- deblock filter
|
||||
- tmix filter
|
||||
@@ -42,6 +154,7 @@ version 4.1:
|
||||
- xstack filter
|
||||
- pcm vidc decoder and encoder
|
||||
- (a)graphmonitor filter
|
||||
- yadif_cuda filter
|
||||
|
||||
|
||||
version 4.0:
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
┌─────────────────────────────────────────────┐
|
||||
│ RELEASE NOTES for FFmpeg 4.1 "al-Khwarizmi" │
|
||||
└─────────────────────────────────────────────┘
|
||||
|
||||
The FFmpeg Project proudly presents FFmpeg 4.1 "al-Khwarizmi", about 6
|
||||
months after the release of FFmpeg 4.0.
|
||||
|
||||
A complete Changelog is available at the root of the project, and the
|
||||
complete Git history on https://git.ffmpeg.org/gitweb/ffmpeg.git
|
||||
|
||||
We hope you will like this release as much as we enjoyed working on it, and
|
||||
as usual, if you have any questions about it, or any FFmpeg related topic,
|
||||
feel free to join us on the #ffmpeg IRC channel (on irc.freenode.net) or ask
|
||||
on the mailing-lists.
|
||||
@@ -2812,6 +2812,7 @@ d3d11va_deps="dxva_h ID3D11VideoDecoder ID3D11VideoContext"
|
||||
dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode ole32 user32"
|
||||
ffnvcodec_deps_any="libdl LoadLibrary"
|
||||
nvdec_deps="ffnvcodec"
|
||||
vaapi_x11_deps="xlib"
|
||||
videotoolbox_hwaccel_deps="videotoolbox pthreads"
|
||||
videotoolbox_hwaccel_extralibs="-framework QuartzCore"
|
||||
xvmc_deps="X11_extensions_XvMClib_h"
|
||||
@@ -2957,6 +2958,7 @@ h264_rkmpp_decoder_deps="rkmpp"
|
||||
h264_rkmpp_decoder_select="h264_mp4toannexb_bsf"
|
||||
h264_vaapi_encoder_select="cbs_h264 vaapi_encode"
|
||||
h264_v4l2m2m_decoder_deps="v4l2_m2m h264_v4l2_m2m"
|
||||
h264_v4l2m2m_decoder_select="h264_mp4toannexb_bsf"
|
||||
h264_v4l2m2m_encoder_deps="v4l2_m2m h264_v4l2_m2m"
|
||||
hevc_amf_encoder_deps="amf"
|
||||
hevc_cuvid_decoder_deps="cuvid"
|
||||
@@ -2971,6 +2973,7 @@ hevc_rkmpp_decoder_select="hevc_mp4toannexb_bsf"
|
||||
hevc_vaapi_encoder_deps="VAEncPictureParameterBufferHEVC"
|
||||
hevc_vaapi_encoder_select="cbs_h265 vaapi_encode"
|
||||
hevc_v4l2m2m_decoder_deps="v4l2_m2m hevc_v4l2_m2m"
|
||||
hevc_v4l2m2m_decoder_select="hevc_mp4toannexb_bsf"
|
||||
hevc_v4l2m2m_encoder_deps="v4l2_m2m hevc_v4l2_m2m"
|
||||
mjpeg_cuvid_decoder_deps="cuvid"
|
||||
mjpeg_qsv_encoder_deps="libmfx"
|
||||
@@ -3180,6 +3183,7 @@ image2_alias_pix_demuxer_select="image2_demuxer"
|
||||
image2_brender_pix_demuxer_select="image2_demuxer"
|
||||
ipod_muxer_select="mov_muxer"
|
||||
ismv_muxer_select="mov_muxer"
|
||||
ivf_muxer_select="av1_metadata_bsf vp9_superframe_bsf"
|
||||
matroska_audio_muxer_select="matroska_muxer"
|
||||
matroska_demuxer_select="iso_media riffdec"
|
||||
matroska_demuxer_suggest="bzlib lzo zlib"
|
||||
@@ -3481,6 +3485,7 @@ zscale_filter_deps="libzimg const_nan"
|
||||
scale_vaapi_filter_deps="vaapi"
|
||||
vpp_qsv_filter_deps="libmfx"
|
||||
vpp_qsv_filter_select="qsvvpp"
|
||||
yadif_cuda_filter_deps="cuda_sdk"
|
||||
|
||||
# examples
|
||||
avio_dir_cmd_deps="avformat avutil"
|
||||
@@ -6147,21 +6152,21 @@ enabled libvorbis && require_pkg_config libvorbis vorbis vorbis/codec.h
|
||||
enabled libvpx && {
|
||||
enabled libvpx_vp8_decoder && {
|
||||
check_pkg_config libvpx_vp8_decoder "vpx >= 1.4.0" "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp8_dx ||
|
||||
check_lib libvpx_vp8_decoder "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_dec_init_ver VPX_IMG_FMT_HIGHBITDEPTH" -lvpx ||
|
||||
check_lib libvpx_vp8_decoder "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_vp8_dx VPX_IMG_FMT_HIGHBITDEPTH" "-lvpx $libm_extralibs $pthreads_extralibs" ||
|
||||
die "ERROR: libvpx decoder version must be >=1.4.0";
|
||||
}
|
||||
enabled libvpx_vp8_encoder && {
|
||||
check_pkg_config libvpx_vp8_encoder "vpx >= 1.4.0" "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp8_cx ||
|
||||
check_lib libvpx_vp8_encoder "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_enc_init_ver VPX_IMG_FMT_HIGHBITDEPTH" -lvpx ||
|
||||
check_lib libvpx_vp8_encoder "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp8_cx VPX_IMG_FMT_HIGHBITDEPTH" "-lvpx $libm_extralibs $pthreads_extralibs" ||
|
||||
die "ERROR: libvpx encoder version must be >=1.4.0";
|
||||
}
|
||||
enabled libvpx_vp9_decoder && {
|
||||
check_pkg_config libvpx_vp9_decoder "vpx >= 1.4.0" "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp9_dx ||
|
||||
check_lib libvpx_vp9_decoder "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_vp9_dx VPX_IMG_FMT_HIGHBITDEPTH" "-lvpx $libm_extralibs"
|
||||
check_lib libvpx_vp9_decoder "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_vp9_dx VPX_IMG_FMT_HIGHBITDEPTH" "-lvpx $libm_extralibs $pthreads_extralibs"
|
||||
}
|
||||
enabled libvpx_vp9_encoder && {
|
||||
check_pkg_config libvpx_vp9_encoder "vpx >= 1.4.0" "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp9_cx ||
|
||||
check_lib libvpx_vp9_encoder "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp9_cx VPX_IMG_FMT_HIGHBITDEPTH" "-lvpx $libm_extralibs"
|
||||
check_lib libvpx_vp9_encoder "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp9_cx VPX_IMG_FMT_HIGHBITDEPTH" "-lvpx $libm_extralibs $pthreads_extralibs"
|
||||
}
|
||||
if disabled_all libvpx_vp8_decoder libvpx_vp9_decoder libvpx_vp8_encoder libvpx_vp9_encoder; then
|
||||
die "libvpx enabled but no supported decoders found"
|
||||
@@ -7238,7 +7243,7 @@ cat > $TMPH <<EOF
|
||||
#define FFMPEG_CONFIG_H
|
||||
#define FFMPEG_CONFIGURATION "$(c_escape $FFMPEG_CONFIGURATION)"
|
||||
#define FFMPEG_LICENSE "$(c_escape $license)"
|
||||
#define CONFIG_THIS_YEAR 2018
|
||||
#define CONFIG_THIS_YEAR 2019
|
||||
#define FFMPEG_DATADIR "$(eval c_escape $datadir)"
|
||||
#define AVCONV_DATADIR "$(eval c_escape $datadir)"
|
||||
#define CC_IDENT "$(c_escape ${cc_ident:-Unknown compiler})"
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ PROJECT_NAME = FFmpeg
|
||||
# could be handy for archiving the generated documentation or if some version
|
||||
# control system is used.
|
||||
|
||||
PROJECT_NUMBER =
|
||||
PROJECT_NUMBER = 4.1.2
|
||||
|
||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||
# for a project that appears at the top of each page and should give viewer a
|
||||
|
||||
@@ -17943,6 +17943,64 @@ filter").
|
||||
It accepts the following parameters:
|
||||
|
||||
|
||||
@table @option
|
||||
|
||||
@item mode
|
||||
The interlacing mode to adopt. It accepts one of the following values:
|
||||
|
||||
@table @option
|
||||
@item 0, send_frame
|
||||
Output one frame for each frame.
|
||||
@item 1, send_field
|
||||
Output one frame for each field.
|
||||
@item 2, send_frame_nospatial
|
||||
Like @code{send_frame}, but it skips the spatial interlacing check.
|
||||
@item 3, send_field_nospatial
|
||||
Like @code{send_field}, but it skips the spatial interlacing check.
|
||||
@end table
|
||||
|
||||
The default value is @code{send_frame}.
|
||||
|
||||
@item parity
|
||||
The picture field parity assumed for the input interlaced video. It accepts one
|
||||
of the following values:
|
||||
|
||||
@table @option
|
||||
@item 0, tff
|
||||
Assume the top field is first.
|
||||
@item 1, bff
|
||||
Assume the bottom field is first.
|
||||
@item -1, auto
|
||||
Enable automatic detection of field parity.
|
||||
@end table
|
||||
|
||||
The default value is @code{auto}.
|
||||
If the interlacing is unknown or the decoder does not export this information,
|
||||
top field first will be assumed.
|
||||
|
||||
@item deint
|
||||
Specify which frames to deinterlace. Accept one of the following
|
||||
values:
|
||||
|
||||
@table @option
|
||||
@item 0, all
|
||||
Deinterlace all frames.
|
||||
@item 1, interlaced
|
||||
Only deinterlace frames marked as interlaced.
|
||||
@end table
|
||||
|
||||
The default value is @code{all}.
|
||||
@end table
|
||||
|
||||
@section yadif_cuda
|
||||
|
||||
Deinterlace the input video using the @ref{yadif} algorithm, but implemented
|
||||
in CUDA so that it can work as part of a GPU accelerated pipeline with nvdec
|
||||
and/or nvenc.
|
||||
|
||||
It accepts the following parameters:
|
||||
|
||||
|
||||
@table @option
|
||||
|
||||
@item mode
|
||||
|
||||
+1
-1
@@ -374,7 +374,7 @@ Defaults to @option{false}.
|
||||
@item timestamp_align
|
||||
Capture start time alignment in seconds. If set to nonzero, input frames are
|
||||
dropped till the system timestamp aligns with configured value.
|
||||
Alignment difference of upto one frame duration is tolerated.
|
||||
Alignment difference of up to one frame duration is tolerated.
|
||||
This is useful for maintaining input synchronization across N different
|
||||
hardware devices deployed for 'N-way' redundancy. The system time of different
|
||||
hardware devices should be synchronized with protocols such as NTP or PTP,
|
||||
|
||||
+7
-3
@@ -2139,9 +2139,6 @@ static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame)
|
||||
|
||||
/* determine if the parameters for this input changed */
|
||||
need_reinit = ifilter->format != frame->format;
|
||||
if (!!ifilter->hw_frames_ctx != !!frame->hw_frames_ctx ||
|
||||
(ifilter->hw_frames_ctx && ifilter->hw_frames_ctx->data != frame->hw_frames_ctx->data))
|
||||
need_reinit = 1;
|
||||
|
||||
switch (ifilter->ist->st->codecpar->codec_type) {
|
||||
case AVMEDIA_TYPE_AUDIO:
|
||||
@@ -2155,6 +2152,13 @@ static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ifilter->ist->reinit_filters && fg->graph)
|
||||
need_reinit = 0;
|
||||
|
||||
if (!!ifilter->hw_frames_ctx != !!frame->hw_frames_ctx ||
|
||||
(ifilter->hw_frames_ctx && ifilter->hw_frames_ctx->data != frame->hw_frames_ctx->data))
|
||||
need_reinit = 1;
|
||||
|
||||
if (need_reinit) {
|
||||
ret = ifilter_parameters_from_frame(ifilter, frame);
|
||||
if (ret < 0)
|
||||
|
||||
+2
-2
@@ -498,7 +498,7 @@ static int decode_i_block(FourXContext *f, int16_t *block)
|
||||
|
||||
if (get_bits_left(&f->gb) < 2){
|
||||
av_log(f->avctx, AV_LOG_ERROR, "%d bits left before decode_i_block()\n", get_bits_left(&f->gb));
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
/* DC coef */
|
||||
@@ -732,7 +732,7 @@ static int decode_i2_frame(FourXContext *f, const uint8_t *buf, int length)
|
||||
for (x = 0; x < width; x += 16) {
|
||||
unsigned int color[4] = { 0 }, bits;
|
||||
if (buf_end - buf < 8)
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
// warning following is purely guessed ...
|
||||
color[0] = bytestream2_get_le16u(&g3);
|
||||
color[1] = bytestream2_get_le16u(&g3);
|
||||
|
||||
@@ -208,6 +208,9 @@ static int aic_decode_coeffs(GetBitContext *gb, int16_t *dst,
|
||||
int mb, idx;
|
||||
unsigned val;
|
||||
|
||||
if (get_bits_left(gb) < 5)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
has_skips = get_bits1(gb);
|
||||
coeff_type = get_bits1(gb);
|
||||
coeff_bits = get_bits(gb, 3);
|
||||
|
||||
@@ -1321,7 +1321,7 @@ enum AVPacketSideDataType {
|
||||
AV_PKT_DATA_METADATA_UPDATE,
|
||||
|
||||
/**
|
||||
* MPEGTS stream ID, this is required to pass the stream ID
|
||||
* MPEGTS stream ID as uint8_t, this is required to pass the stream ID
|
||||
* information from the demuxer to the corresponding muxer.
|
||||
*/
|
||||
AV_PKT_DATA_MPEGTS_STREAM_ID,
|
||||
|
||||
@@ -109,6 +109,11 @@ static int bethsoftvid_decode_frame(AVCodecContext *avctx,
|
||||
if(yoffset >= avctx->height)
|
||||
return AVERROR_INVALIDDATA;
|
||||
dst += vid->frame->linesize[0] * yoffset;
|
||||
case VIDEO_P_FRAME:
|
||||
case VIDEO_I_FRAME:
|
||||
break;
|
||||
default:
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
// main code
|
||||
|
||||
+21
-8
@@ -591,14 +591,21 @@ static int decode_residual_block(AVSContext *h, GetBitContext *gb,
|
||||
}
|
||||
|
||||
|
||||
static inline void decode_residual_chroma(AVSContext *h)
|
||||
static inline int decode_residual_chroma(AVSContext *h)
|
||||
{
|
||||
if (h->cbp & (1 << 4))
|
||||
decode_residual_block(h, &h->gb, chroma_dec, 0,
|
||||
if (h->cbp & (1 << 4)) {
|
||||
int ret = decode_residual_block(h, &h->gb, chroma_dec, 0,
|
||||
ff_cavs_chroma_qp[h->qp], h->cu, h->c_stride);
|
||||
if (h->cbp & (1 << 5))
|
||||
decode_residual_block(h, &h->gb, chroma_dec, 0,
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
if (h->cbp & (1 << 5)) {
|
||||
int ret = decode_residual_block(h, &h->gb, chroma_dec, 0,
|
||||
ff_cavs_chroma_qp[h->qp], h->cv, h->c_stride);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int decode_residual_inter(AVSContext *h)
|
||||
@@ -649,6 +656,7 @@ static int decode_mb_i(AVSContext *h, int cbp_code)
|
||||
uint8_t top[18];
|
||||
uint8_t *left = NULL;
|
||||
uint8_t *d;
|
||||
int ret;
|
||||
|
||||
ff_cavs_init_mb(h);
|
||||
|
||||
@@ -692,8 +700,11 @@ static int decode_mb_i(AVSContext *h, int cbp_code)
|
||||
ff_cavs_load_intra_pred_luma(h, top, &left, block);
|
||||
h->intra_pred_l[h->pred_mode_Y[scan3x3[block]]]
|
||||
(d, top, left, h->l_stride);
|
||||
if (h->cbp & (1<<block))
|
||||
decode_residual_block(h, gb, intra_dec, 1, h->qp, d, h->l_stride);
|
||||
if (h->cbp & (1<<block)) {
|
||||
ret = decode_residual_block(h, gb, intra_dec, 1, h->qp, d, h->l_stride);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* chroma intra prediction */
|
||||
@@ -703,7 +714,9 @@ static int decode_mb_i(AVSContext *h, int cbp_code)
|
||||
h->intra_pred_c[pred_mode_uv](h->cv, &h->top_border_v[h->mbx * 10],
|
||||
h->left_border_v, h->c_stride);
|
||||
|
||||
decode_residual_chroma(h);
|
||||
ret = decode_residual_chroma(h);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
ff_cavs_filter(h, I_8X8);
|
||||
set_mv_intra(h);
|
||||
return 0;
|
||||
|
||||
+68
-46
@@ -29,45 +29,67 @@ static int cbs_av1_read_uvlc(CodedBitstreamContext *ctx, GetBitContext *gbc,
|
||||
const char *name, uint32_t *write_to,
|
||||
uint32_t range_min, uint32_t range_max)
|
||||
{
|
||||
uint32_t value;
|
||||
int position, zeroes, i, j;
|
||||
char bits[65];
|
||||
uint32_t zeroes, bits_value, value;
|
||||
int position;
|
||||
|
||||
if (ctx->trace_enable)
|
||||
position = get_bits_count(gbc);
|
||||
|
||||
zeroes = i = 0;
|
||||
zeroes = 0;
|
||||
while (1) {
|
||||
if (get_bits_left(gbc) < zeroes + 1) {
|
||||
if (get_bits_left(gbc) < 1) {
|
||||
av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid uvlc code at "
|
||||
"%s: bitstream ended.\n", name);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (get_bits1(gbc)) {
|
||||
bits[i++] = '1';
|
||||
if (get_bits1(gbc))
|
||||
break;
|
||||
} else {
|
||||
bits[i++] = '0';
|
||||
++zeroes;
|
||||
}
|
||||
++zeroes;
|
||||
}
|
||||
|
||||
if (zeroes >= 32) {
|
||||
value = MAX_UINT_BITS(32);
|
||||
} else {
|
||||
value = get_bits_long(gbc, zeroes);
|
||||
if (get_bits_left(gbc) < zeroes) {
|
||||
av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid uvlc code at "
|
||||
"%s: bitstream ended.\n", name);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
for (j = 0; j < zeroes; j++)
|
||||
bits[i++] = (value >> (zeroes - j - 1) & 1) ? '1' : '0';
|
||||
|
||||
value += (1 << zeroes) - 1;
|
||||
bits_value = get_bits_long(gbc, zeroes);
|
||||
value = bits_value + (UINT32_C(1) << zeroes) - 1;
|
||||
}
|
||||
|
||||
if (ctx->trace_enable) {
|
||||
char bits[65];
|
||||
int i, j, k;
|
||||
|
||||
if (zeroes >= 32) {
|
||||
while (zeroes > 32) {
|
||||
k = FFMIN(zeroes - 32, 32);
|
||||
for (i = 0; i < k; i++)
|
||||
bits[i] = '0';
|
||||
bits[i] = 0;
|
||||
ff_cbs_trace_syntax_element(ctx, position, name,
|
||||
NULL, bits, 0);
|
||||
zeroes -= k;
|
||||
position += k;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < zeroes; i++)
|
||||
bits[i] = '0';
|
||||
bits[i++] = '1';
|
||||
|
||||
if (zeroes < 32) {
|
||||
for (j = 0; j < zeroes; j++)
|
||||
bits[i++] = (bits_value >> (zeroes - j - 1) & 1) ? '1' : '0';
|
||||
}
|
||||
|
||||
bits[i] = 0;
|
||||
ff_cbs_trace_syntax_element(ctx, position, name, NULL,
|
||||
bits, value);
|
||||
ff_cbs_trace_syntax_element(ctx, position, name,
|
||||
NULL, bits, value);
|
||||
}
|
||||
|
||||
if (value < range_min || value > range_max) {
|
||||
@@ -189,30 +211,26 @@ static int cbs_av1_read_su(CodedBitstreamContext *ctx, GetBitContext *gbc,
|
||||
int width, const char *name,
|
||||
const int *subscripts, int32_t *write_to)
|
||||
{
|
||||
uint32_t magnitude;
|
||||
int position, sign;
|
||||
int position;
|
||||
int32_t value;
|
||||
|
||||
if (ctx->trace_enable)
|
||||
position = get_bits_count(gbc);
|
||||
|
||||
if (get_bits_left(gbc) < width + 1) {
|
||||
if (get_bits_left(gbc) < width) {
|
||||
av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid signed value at "
|
||||
"%s: bitstream ended.\n", name);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
magnitude = get_bits(gbc, width);
|
||||
sign = get_bits1(gbc);
|
||||
value = sign ? -(int32_t)magnitude : magnitude;
|
||||
value = get_sbits(gbc, width);
|
||||
|
||||
if (ctx->trace_enable) {
|
||||
char bits[33];
|
||||
int i;
|
||||
for (i = 0; i < width; i++)
|
||||
bits[i] = magnitude >> (width - i - 1) & 1 ? '1' : '0';
|
||||
bits[i] = sign ? '1' : '0';
|
||||
bits[i + 1] = 0;
|
||||
bits[i] = value & (1 << (width - i - 1)) ? '1' : '0';
|
||||
bits[i] = 0;
|
||||
|
||||
ff_cbs_trace_syntax_element(ctx, position,
|
||||
name, subscripts, bits, value);
|
||||
@@ -226,29 +244,21 @@ static int cbs_av1_write_su(CodedBitstreamContext *ctx, PutBitContext *pbc,
|
||||
int width, const char *name,
|
||||
const int *subscripts, int32_t value)
|
||||
{
|
||||
uint32_t magnitude;
|
||||
int sign;
|
||||
|
||||
if (put_bits_left(pbc) < width + 1)
|
||||
if (put_bits_left(pbc) < width)
|
||||
return AVERROR(ENOSPC);
|
||||
|
||||
sign = value < 0;
|
||||
magnitude = sign ? -value : value;
|
||||
|
||||
if (ctx->trace_enable) {
|
||||
char bits[33];
|
||||
int i;
|
||||
for (i = 0; i < width; i++)
|
||||
bits[i] = magnitude >> (width - i - 1) & 1 ? '1' : '0';
|
||||
bits[i] = sign ? '1' : '0';
|
||||
bits[i + 1] = 0;
|
||||
bits[i] = value & (1 << (width - i - 1)) ? '1' : '0';
|
||||
bits[i] = 0;
|
||||
|
||||
ff_cbs_trace_syntax_element(ctx, put_bits_count(pbc),
|
||||
name, subscripts, bits, value);
|
||||
}
|
||||
|
||||
put_bits(pbc, width, magnitude);
|
||||
put_bits(pbc, 1, sign);
|
||||
put_sbits(pbc, width, value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -996,7 +1006,10 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx,
|
||||
case AV1_OBU_REDUNDANT_FRAME_HEADER:
|
||||
{
|
||||
err = cbs_av1_read_frame_header_obu(ctx, &gbc,
|
||||
&obu->obu.frame_header);
|
||||
&obu->obu.frame_header,
|
||||
obu->header.obu_type ==
|
||||
AV1_OBU_REDUNDANT_FRAME_HEADER,
|
||||
unit->data_ref);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
@@ -1016,7 +1029,8 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx,
|
||||
break;
|
||||
case AV1_OBU_FRAME:
|
||||
{
|
||||
err = cbs_av1_read_frame_obu(ctx, &gbc, &obu->obu.frame);
|
||||
err = cbs_av1_read_frame_obu(ctx, &gbc, &obu->obu.frame,
|
||||
unit->data_ref);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
@@ -1057,8 +1071,12 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx,
|
||||
if (obu->obu_size > 0 &&
|
||||
obu->header.obu_type != AV1_OBU_TILE_GROUP &&
|
||||
obu->header.obu_type != AV1_OBU_FRAME) {
|
||||
err = cbs_av1_read_trailing_bits(ctx, &gbc,
|
||||
obu->obu_size * 8 + start_pos - end_pos);
|
||||
int nb_bits = obu->obu_size * 8 + start_pos - end_pos;
|
||||
|
||||
if (nb_bits <= 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
err = cbs_av1_read_trailing_bits(ctx, &gbc, nb_bits);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
@@ -1124,7 +1142,10 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx,
|
||||
case AV1_OBU_REDUNDANT_FRAME_HEADER:
|
||||
{
|
||||
err = cbs_av1_write_frame_header_obu(ctx, pbc,
|
||||
&obu->obu.frame_header);
|
||||
&obu->obu.frame_header,
|
||||
obu->header.obu_type ==
|
||||
AV1_OBU_REDUNDANT_FRAME_HEADER,
|
||||
NULL);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
@@ -1141,7 +1162,7 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx,
|
||||
break;
|
||||
case AV1_OBU_FRAME:
|
||||
{
|
||||
err = cbs_av1_write_frame_obu(ctx, pbc, &obu->obu.frame);
|
||||
err = cbs_av1_write_frame_obu(ctx, pbc, &obu->obu.frame, NULL);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
@@ -1179,7 +1200,7 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx,
|
||||
if (err < 0)
|
||||
return err;
|
||||
end_pos = put_bits_count(pbc);
|
||||
obu->obu_size = (end_pos - start_pos + 7) / 8;
|
||||
obu->obu_size = header_size = (end_pos - start_pos + 7) / 8;
|
||||
} else {
|
||||
// Empty OBU.
|
||||
obu->obu_size = 0;
|
||||
@@ -1302,6 +1323,7 @@ static void cbs_av1_close(CodedBitstreamContext *ctx)
|
||||
CodedBitstreamAV1Context *priv = ctx->priv_data;
|
||||
|
||||
av_buffer_unref(&priv->sequence_header_ref);
|
||||
av_buffer_unref(&priv->frame_header_ref);
|
||||
|
||||
av_freep(&priv->write_buffer);
|
||||
}
|
||||
|
||||
@@ -87,8 +87,8 @@ typedef struct AV1RawSequenceHeader {
|
||||
uint8_t seq_level_idx[AV1_MAX_OPERATING_POINTS];
|
||||
uint8_t seq_tier[AV1_MAX_OPERATING_POINTS];
|
||||
uint8_t decoder_model_present_for_this_op[AV1_MAX_OPERATING_POINTS];
|
||||
uint8_t decoder_buffer_delay[AV1_MAX_OPERATING_POINTS];
|
||||
uint8_t encoder_buffer_delay[AV1_MAX_OPERATING_POINTS];
|
||||
uint32_t decoder_buffer_delay[AV1_MAX_OPERATING_POINTS];
|
||||
uint32_t encoder_buffer_delay[AV1_MAX_OPERATING_POINTS];
|
||||
uint8_t low_delay_mode_flag[AV1_MAX_OPERATING_POINTS];
|
||||
uint8_t initial_display_delay_present_for_this_op[AV1_MAX_OPERATING_POINTS];
|
||||
uint8_t initial_display_delay_minus_1[AV1_MAX_OPERATING_POINTS];
|
||||
@@ -170,7 +170,7 @@ typedef struct AV1RawFrameHeader {
|
||||
uint8_t last_frame_idx;
|
||||
uint8_t golden_frame_idx;
|
||||
int8_t ref_frame_idx[AV1_REFS_PER_FRAME];
|
||||
uint8_t delta_frame_id_minus1;
|
||||
uint32_t delta_frame_id_minus1[AV1_REFS_PER_FRAME];
|
||||
|
||||
uint8_t allow_high_precision_mv;
|
||||
uint8_t is_filter_switchable;
|
||||
@@ -210,7 +210,7 @@ typedef struct AV1RawFrameHeader {
|
||||
uint8_t segmentation_temporal_update;
|
||||
uint8_t segmentation_update_data;
|
||||
uint8_t feature_enabled[AV1_MAX_SEGMENTS][AV1_SEG_LVL_MAX];
|
||||
uint8_t feature_value[AV1_MAX_SEGMENTS][AV1_SEG_LVL_MAX];
|
||||
int16_t feature_value[AV1_MAX_SEGMENTS][AV1_SEG_LVL_MAX];
|
||||
|
||||
uint8_t delta_q_present;
|
||||
uint8_t delta_q_res;
|
||||
@@ -399,7 +399,10 @@ typedef struct CodedBitstreamAV1Context {
|
||||
AV1RawSequenceHeader *sequence_header;
|
||||
AVBufferRef *sequence_header_ref;
|
||||
|
||||
int seen_frame_header;
|
||||
int seen_frame_header;
|
||||
AVBufferRef *frame_header_ref;
|
||||
uint8_t *frame_header;
|
||||
size_t frame_header_size;
|
||||
|
||||
int temporal_id;
|
||||
int spatial_id;
|
||||
|
||||
@@ -1323,8 +1323,8 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw,
|
||||
if (!current->frame_refs_short_signaling)
|
||||
fbs(3, ref_frame_idx[i], 1, i);
|
||||
if (seq->frame_id_numbers_present_flag) {
|
||||
fb(seq->delta_frame_id_length_minus_2 + 2,
|
||||
delta_frame_id_minus1);
|
||||
fbs(seq->delta_frame_id_length_minus_2 + 2,
|
||||
delta_frame_id_minus1[i], 1, i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1463,24 +1463,90 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw,
|
||||
}
|
||||
|
||||
static int FUNC(frame_header_obu)(CodedBitstreamContext *ctx, RWContext *rw,
|
||||
AV1RawFrameHeader *current)
|
||||
AV1RawFrameHeader *current, int redundant,
|
||||
AVBufferRef *rw_buffer_ref)
|
||||
{
|
||||
CodedBitstreamAV1Context *priv = ctx->priv_data;
|
||||
int err;
|
||||
|
||||
HEADER("Frame Header");
|
||||
int start_pos, fh_bits, fh_bytes, err;
|
||||
uint8_t *fh_start;
|
||||
|
||||
if (priv->seen_frame_header) {
|
||||
// Nothing to do.
|
||||
if (!redundant) {
|
||||
av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid repeated "
|
||||
"frame header OBU.\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
} else {
|
||||
GetBitContext fh;
|
||||
size_t i, b;
|
||||
uint32_t val;
|
||||
|
||||
HEADER("Redundant Frame Header");
|
||||
|
||||
av_assert0(priv->frame_header_ref && priv->frame_header);
|
||||
|
||||
init_get_bits(&fh, priv->frame_header,
|
||||
priv->frame_header_size);
|
||||
for (i = 0; i < priv->frame_header_size; i += 8) {
|
||||
b = FFMIN(priv->frame_header_size - i, 8);
|
||||
val = get_bits(&fh, b);
|
||||
xf(b, frame_header_copy[i],
|
||||
val, val, val, 1, i / 8);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (redundant)
|
||||
HEADER("Redundant Frame Header (used as Frame Header)");
|
||||
else
|
||||
HEADER("Frame Header");
|
||||
|
||||
priv->seen_frame_header = 1;
|
||||
|
||||
#ifdef READ
|
||||
start_pos = get_bits_count(rw);
|
||||
#else
|
||||
start_pos = put_bits_count(rw);
|
||||
#endif
|
||||
|
||||
CHECK(FUNC(uncompressed_header)(ctx, rw, current));
|
||||
|
||||
if (current->show_existing_frame) {
|
||||
priv->seen_frame_header = 0;
|
||||
} else {
|
||||
priv->seen_frame_header = 1;
|
||||
|
||||
av_buffer_unref(&priv->frame_header_ref);
|
||||
|
||||
#ifdef READ
|
||||
fh_bits = get_bits_count(rw) - start_pos;
|
||||
fh_start = (uint8_t*)rw->buffer + start_pos / 8;
|
||||
#else
|
||||
// Need to flush the bitwriter so that we can copy its output,
|
||||
// but use a copy so we don't affect the caller's structure.
|
||||
{
|
||||
PutBitContext tmp = *rw;
|
||||
flush_put_bits(&tmp);
|
||||
}
|
||||
|
||||
fh_bits = put_bits_count(rw) - start_pos;
|
||||
fh_start = rw->buf + start_pos / 8;
|
||||
#endif
|
||||
fh_bytes = (fh_bits + 7) / 8;
|
||||
|
||||
priv->frame_header_size = fh_bits;
|
||||
|
||||
if (rw_buffer_ref) {
|
||||
priv->frame_header_ref = av_buffer_ref(rw_buffer_ref);
|
||||
if (!priv->frame_header_ref)
|
||||
return AVERROR(ENOMEM);
|
||||
priv->frame_header = fh_start;
|
||||
} else {
|
||||
priv->frame_header_ref =
|
||||
av_buffer_alloc(fh_bytes + AV_INPUT_BUFFER_PADDING_SIZE);
|
||||
if (!priv->frame_header_ref)
|
||||
return AVERROR(ENOMEM);
|
||||
priv->frame_header = priv->frame_header_ref->data;
|
||||
memcpy(priv->frame_header, fh_start, fh_bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1524,11 +1590,13 @@ static int FUNC(tile_group_obu)(CodedBitstreamContext *ctx, RWContext *rw,
|
||||
}
|
||||
|
||||
static int FUNC(frame_obu)(CodedBitstreamContext *ctx, RWContext *rw,
|
||||
AV1RawFrame *current)
|
||||
AV1RawFrame *current,
|
||||
AVBufferRef *rw_buffer_ref)
|
||||
{
|
||||
int err;
|
||||
|
||||
CHECK(FUNC(frame_header_obu)(ctx, rw, ¤t->header));
|
||||
CHECK(FUNC(frame_header_obu)(ctx, rw, ¤t->header,
|
||||
0, rw_buffer_ref));
|
||||
|
||||
CHECK(FUNC(byte_alignment)(ctx, rw));
|
||||
|
||||
|
||||
@@ -81,11 +81,8 @@ static av_cold int cdg_decode_init(AVCodecContext *avctx)
|
||||
return AVERROR(ENOMEM);
|
||||
cc->transparency = -1;
|
||||
|
||||
avctx->width = CDG_FULL_WIDTH;
|
||||
avctx->height = CDG_FULL_HEIGHT;
|
||||
avctx->pix_fmt = AV_PIX_FMT_PAL8;
|
||||
|
||||
return 0;
|
||||
return ff_set_dimensions(avctx, CDG_FULL_WIDTH, CDG_FULL_HEIGHT);
|
||||
}
|
||||
|
||||
static void cdg_border_preset(CDGraphicsContext *cc, uint8_t *data)
|
||||
|
||||
@@ -555,6 +555,9 @@ static int clv_decode_frame(AVCodecContext *avctx, void *data,
|
||||
} else {
|
||||
int plane;
|
||||
|
||||
if (c->pmb_width * c->pmb_height > 8LL*(buf_size - bytestream2_tell(&gb)))
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if ((ret = ff_reget_buffer(avctx, c->pic)) < 0)
|
||||
return ret;
|
||||
|
||||
@@ -570,6 +573,8 @@ static int clv_decode_frame(AVCodecContext *avctx, void *data,
|
||||
|
||||
for (j = 0; j < c->pmb_height; j++) {
|
||||
for (i = 0; i < c->pmb_width; i++) {
|
||||
if (get_bits_left(&c->gb) <= 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (get_bits1(&c->gb)) {
|
||||
MV mv = mvi_predict(&c->mvi, i, j, zero_mv);
|
||||
|
||||
|
||||
@@ -355,6 +355,8 @@ static int dfa_decode_frame(AVCodecContext *avctx,
|
||||
|
||||
bytestream2_init(&gb, avpkt->data, avpkt->size);
|
||||
while (bytestream2_get_bytes_left(&gb) > 0) {
|
||||
if (bytestream2_get_bytes_left(&gb) < 12)
|
||||
return AVERROR_INVALIDDATA;
|
||||
bytestream2_skip(&gb, 4);
|
||||
chunk_size = bytestream2_get_le32(&gb);
|
||||
chunk_type = bytestream2_get_le32(&gb);
|
||||
|
||||
@@ -676,6 +676,11 @@ static int decode_component(DiracContext *s, int comp)
|
||||
b->length = get_interleaved_ue_golomb(&s->gb);
|
||||
if (b->length) {
|
||||
b->quant = get_interleaved_ue_golomb(&s->gb);
|
||||
if (b->quant > (DIRAC_MAX_QUANT_INDEX - 1)) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Unsupported quant %d\n", b->quant);
|
||||
b->quant = 0;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
align_get_bits(&s->gb);
|
||||
b->coeff_data = s->gb.buffer + get_bits_count(&s->gb)/8;
|
||||
b->length = FFMIN(b->length, FFMAX(get_bits_left(&s->gb)/8, 0));
|
||||
|
||||
@@ -1267,6 +1267,13 @@ static int dvbsub_parse_region_segment(AVCodecContext *avctx,
|
||||
display->y_pos = AV_RB16(buf) & 0xfff;
|
||||
buf += 2;
|
||||
|
||||
if (display->x_pos >= region->width ||
|
||||
display->y_pos >= region->height) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Object outside region\n");
|
||||
av_free(display);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if ((object->type == 1 || object->type == 2) && buf+1 < buf_end) {
|
||||
display->fgcolor = *buf++;
|
||||
display->bgcolor = *buf++;
|
||||
|
||||
+8
-1
@@ -426,7 +426,8 @@ static int fill_optable(unsigned *table0, OpcodeTable *table1, int nb_elements)
|
||||
static int get_opcodes(GetByteContext *gb, uint32_t *table, uint8_t *dst, int op_size, int nb_elements)
|
||||
{
|
||||
OpcodeTable optable[1024];
|
||||
int sum, x, val, lshift, rshift, ret, size_in_bits, i, idx;
|
||||
int sum, x, val, lshift, rshift, ret, i, idx;
|
||||
int64_t size_in_bits;
|
||||
unsigned endoffset, newoffset, offset;
|
||||
unsigned next;
|
||||
uint8_t *src = (uint8_t *)gb->buffer;
|
||||
@@ -1192,6 +1193,12 @@ static int dxv_decode(AVCodecContext *avctx, void *data,
|
||||
ret = decompress_tex(avctx);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
{
|
||||
int w_block = avctx->coded_width / ctx->texture_block_w;
|
||||
int h_block = avctx->coded_height / ctx->texture_block_h;
|
||||
if (w_block * h_block * ctx->tex_step > ctx->tex_size * 8LL)
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
tframe.f = data;
|
||||
ret = ff_thread_get_buffer(avctx, &tframe, 0);
|
||||
|
||||
@@ -437,7 +437,7 @@ static void guess_mv(ERContext *s)
|
||||
}
|
||||
|
||||
if ((!(s->avctx->error_concealment&FF_EC_GUESS_MVS)) ||
|
||||
num_avail <= mb_width / 2) {
|
||||
num_avail <= FFMAX(mb_width, mb_height) / 2) {
|
||||
for (mb_y = 0; mb_y < mb_height; mb_y++) {
|
||||
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
|
||||
const int mb_xy = mb_x + mb_y * s->mb_stride;
|
||||
|
||||
@@ -1389,6 +1389,7 @@ static int decode_header(EXRContext *s, AVFrame *frame)
|
||||
if (*ch_gb.buffer == '.')
|
||||
ch_gb.buffer++; /* skip dot if not given */
|
||||
} else {
|
||||
layer_match = 0;
|
||||
av_log(s->avctx, AV_LOG_INFO,
|
||||
"Channel doesn't match layer : %s.\n", ch_gb.buffer);
|
||||
}
|
||||
@@ -1463,6 +1464,11 @@ static int decode_header(EXRContext *s, AVFrame *frame)
|
||||
}
|
||||
s->pixel_type = current_pixel_type;
|
||||
s->channel_offsets[channel_index] = s->current_channel_offset;
|
||||
} else if (channel_index >= 0) {
|
||||
av_log(s->avctx, AV_LOG_ERROR,
|
||||
"Multiple channels with index %d.\n", channel_index);
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
s->channels = av_realloc(s->channels,
|
||||
|
||||
@@ -139,6 +139,9 @@ static int fic_decode_block(FICContext *ctx, GetBitContext *gb,
|
||||
{
|
||||
int i, num_coeff;
|
||||
|
||||
if (get_bits_left(gb) < 8)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
/* Is it a skip block? */
|
||||
if (get_bits1(gb)) {
|
||||
*is_p = 1;
|
||||
@@ -380,6 +383,8 @@ static int fic_decode_frame(AVCodecContext *avctx, void *data,
|
||||
slice_h = FFALIGN(avctx->height - ctx->slice_h * (nslices - 1), 16);
|
||||
} else {
|
||||
slice_size = AV_RB32(src + tsize + FIC_HEADER_SIZE + slice * 4 + 4);
|
||||
if (slice_size < slice_off)
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (slice_size < slice_off || slice_size > msize)
|
||||
|
||||
+66
-23
@@ -72,9 +72,64 @@ static av_cold int gdv_decode_init(AVCodecContext *avctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void scaleup(uint8_t *dst, const uint8_t *src, int w)
|
||||
{
|
||||
int x;
|
||||
for (x = 0; x < w - 7; x+=8) {
|
||||
dst[x + 0] =
|
||||
dst[x + 1] = src[(x>>1) + 0];
|
||||
dst[x + 2] =
|
||||
dst[x + 3] = src[(x>>1) + 1];
|
||||
dst[x + 4] =
|
||||
dst[x + 5] = src[(x>>1) + 2];
|
||||
dst[x + 6] =
|
||||
dst[x + 7] = src[(x>>1) + 3];
|
||||
}
|
||||
for (; x < w; x++) {
|
||||
dst[x] = src[(x>>1)];
|
||||
}
|
||||
}
|
||||
|
||||
static void scaleup_rev(uint8_t *dst, const uint8_t *src, int w)
|
||||
{
|
||||
int x;
|
||||
|
||||
for (x = w - 1; (x+1) & 7; x--) {
|
||||
dst[x] = src[(x>>1)];
|
||||
}
|
||||
for (x -= 7; x >= 0; x -= 8) {
|
||||
dst[x + 6] =
|
||||
dst[x + 7] = src[(x>>1) + 3];
|
||||
dst[x + 4] =
|
||||
dst[x + 5] = src[(x>>1) + 2];
|
||||
dst[x + 2] =
|
||||
dst[x + 3] = src[(x>>1) + 1];
|
||||
dst[x + 0] =
|
||||
dst[x + 1] = src[(x>>1) + 0];
|
||||
}
|
||||
}
|
||||
|
||||
static void scaledown(uint8_t *dst, const uint8_t *src, int w)
|
||||
{
|
||||
int x;
|
||||
for (x = 0; x < w - 7; x+=8) {
|
||||
dst[x + 0] = src[2*x + 0];
|
||||
dst[x + 1] = src[2*x + 2];
|
||||
dst[x + 2] = src[2*x + 4];
|
||||
dst[x + 3] = src[2*x + 6];
|
||||
dst[x + 4] = src[2*x + 8];
|
||||
dst[x + 5] = src[2*x +10];
|
||||
dst[x + 6] = src[2*x +12];
|
||||
dst[x + 7] = src[2*x +14];
|
||||
}
|
||||
for (; x < w; x++) {
|
||||
dst[x] = src[2*x];
|
||||
}
|
||||
}
|
||||
|
||||
static void rescale(GDVContext *gdv, uint8_t *dst, int w, int h, int scale_v, int scale_h)
|
||||
{
|
||||
int j, y, x;
|
||||
int j, y;
|
||||
|
||||
if ((gdv->scale_v == scale_v) && (gdv->scale_h == scale_h)) {
|
||||
return;
|
||||
@@ -86,14 +141,7 @@ static void rescale(GDVContext *gdv, uint8_t *dst, int w, int h, int scale_v, in
|
||||
uint8_t *dst1 = dst + PREAMBLE_SIZE + y * w;
|
||||
uint8_t *src1 = dst + PREAMBLE_SIZE + (y>>!!gdv->scale_h) * (w>>1);
|
||||
|
||||
for (x = w - 1; x >= 0 && !(x&1); x--) {
|
||||
dst1[x] = src1[(x>>1)];
|
||||
}
|
||||
|
||||
for (x--; x >= 0; x-=2) {
|
||||
dst1[x ] =
|
||||
dst1[x+1] = src1[(x>>1)];
|
||||
}
|
||||
scaleup_rev(dst1, src1, w);
|
||||
}
|
||||
} else if (gdv->scale_h) {
|
||||
for (j = 0; j < h; j++) {
|
||||
@@ -108,9 +156,7 @@ static void rescale(GDVContext *gdv, uint8_t *dst, int w, int h, int scale_v, in
|
||||
for (y = 0; y < (h>>1); y++) {
|
||||
uint8_t *dst1 = dst + PREAMBLE_SIZE + y * (w>>1);
|
||||
uint8_t *src1 = dst + PREAMBLE_SIZE + y*2 * w;
|
||||
for (x = 0; x < (w>>1); x++) {
|
||||
dst1[x] = src1[x*2];
|
||||
}
|
||||
scaledown(dst1, src1, w>>1);
|
||||
}
|
||||
} else if (scale_h) {
|
||||
for (y = 0; y < (h>>1); y++) {
|
||||
@@ -121,9 +167,7 @@ static void rescale(GDVContext *gdv, uint8_t *dst, int w, int h, int scale_v, in
|
||||
} else if (scale_v) {
|
||||
for (y = 0; y < h; y++) {
|
||||
uint8_t *dst1 = dst + PREAMBLE_SIZE + y * w;
|
||||
for (x = 0; x < (w>>1); x++) {
|
||||
dst1[x] = dst1[x*2];
|
||||
}
|
||||
scaledown(dst1, dst1, w>>1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,6 +294,8 @@ static int decompress_5(AVCodecContext *avctx, unsigned skip)
|
||||
|
||||
while (bytestream2_get_bytes_left_p(pb) > 0 && bytestream2_get_bytes_left(gb) > 0) {
|
||||
int tag = read_bits2(&bits, gb);
|
||||
if (bytestream2_get_bytes_left(gb) < 1)
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (tag == 0) {
|
||||
bytestream2_put_byte(pb, bytestream2_get_byte(gb));
|
||||
} else if (tag == 1) {
|
||||
@@ -481,19 +527,16 @@ static int gdv_decode_frame(AVCodecContext *avctx, void *data,
|
||||
}
|
||||
} else {
|
||||
int sidx = PREAMBLE_SIZE, didx = 0;
|
||||
int y, x;
|
||||
int y;
|
||||
|
||||
for (y = 0; y < avctx->height; y++) {
|
||||
if (!gdv->scale_v) {
|
||||
memcpy(dst + didx, gdv->frame + sidx, avctx->width);
|
||||
} else {
|
||||
for (x = 0; x < avctx->width - 1; x+=2) {
|
||||
dst[didx + x ] =
|
||||
dst[didx + x + 1] = gdv->frame[sidx + (x>>1)];
|
||||
}
|
||||
for (; x < avctx->width; x++) {
|
||||
dst[didx + x] = gdv->frame[sidx + (x>>1)];
|
||||
}
|
||||
uint8_t *dst2 = dst + didx;
|
||||
uint8_t *src2 = gdv->frame + sidx;
|
||||
|
||||
scaleup(dst2, src2, avctx->width);
|
||||
}
|
||||
if (!gdv->scale_h || ((y & 1) == 1)) {
|
||||
sidx += !gdv->scale_v ? avctx->width : avctx->width/2;
|
||||
|
||||
@@ -156,8 +156,8 @@ void ff_h264_direct_ref_list_init(const H264Context *const h, H264SliceContext *
|
||||
av_log(h->avctx, AV_LOG_ERROR, "co located POCs unavailable\n");
|
||||
sl->col_parity = 1;
|
||||
} else
|
||||
sl->col_parity = (FFABS(col_poc[0] - cur_poc) >=
|
||||
FFABS(col_poc[1] - cur_poc));
|
||||
sl->col_parity = (FFABS(col_poc[0] - (int64_t)cur_poc) >=
|
||||
FFABS(col_poc[1] - (int64_t)cur_poc));
|
||||
ref1sidx =
|
||||
sidx = sl->col_parity;
|
||||
// FL -> FL & differ parity
|
||||
|
||||
@@ -91,7 +91,7 @@ static int h264_redundant_pps_filter(AVBSFContext *bsf, AVPacket *out)
|
||||
if (nal->type == H264_NAL_PPS) {
|
||||
h264_redundant_pps_fixup_pps(ctx, nal->content);
|
||||
if (!au_has_sps) {
|
||||
av_log(ctx, AV_LOG_VERBOSE, "Deleting redundant PPS "
|
||||
av_log(bsf, AV_LOG_VERBOSE, "Deleting redundant PPS "
|
||||
"at %"PRId64".\n", in->pts);
|
||||
ff_cbs_delete_unit(ctx->input, au, i);
|
||||
}
|
||||
|
||||
@@ -678,7 +678,7 @@ static void implicit_weight_table(const H264Context *h, H264SliceContext *sl, in
|
||||
cur_poc = h->cur_pic_ptr->field_poc[h->picture_structure - 1];
|
||||
}
|
||||
if (sl->ref_count[0] == 1 && sl->ref_count[1] == 1 && !FRAME_MBAFF(h) &&
|
||||
sl->ref_list[0][0].poc + (int64_t)sl->ref_list[1][0].poc == 2 * cur_poc) {
|
||||
sl->ref_list[0][0].poc + (int64_t)sl->ref_list[1][0].poc == 2LL * cur_poc) {
|
||||
sl->pwt.use_weight = 0;
|
||||
sl->pwt.use_weight_chroma = 0;
|
||||
return;
|
||||
|
||||
@@ -2924,6 +2924,10 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
|
||||
}
|
||||
|
||||
if (s->sh.first_slice_in_pic_flag) {
|
||||
if (s->ref) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Two slices reporting being the first in the same frame.\n");
|
||||
goto fail;
|
||||
}
|
||||
if (s->max_ra == INT_MAX) {
|
||||
if (s->nal_unit_type == HEVC_NAL_CRA_NUT || IS_BLA(s)) {
|
||||
s->max_ra = s->poc;
|
||||
|
||||
@@ -559,8 +559,6 @@ static av_always_inline int ff_hevc_nal_is_nonref(enum HEVCNALUnitType type)
|
||||
case HEVC_NAL_VCL_N10:
|
||||
case HEVC_NAL_VCL_N12:
|
||||
case HEVC_NAL_VCL_N14:
|
||||
case HEVC_NAL_BLA_N_LP:
|
||||
case HEVC_NAL_IDR_N_LP:
|
||||
return 1;
|
||||
break;
|
||||
default: break;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "libavutil/common.h"
|
||||
#include "libavutil/parseutils.h"
|
||||
#include "htmlsubtitles.h"
|
||||
#include <ctype.h>
|
||||
|
||||
static int html_color_parse(void *log_ctx, const char *str)
|
||||
{
|
||||
@@ -44,14 +45,32 @@ static void rstrip_spaces_buf(AVBPrint *buf)
|
||||
buf->str[--buf->len] = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Fast code for scanning text enclosed in braces. Functionally
|
||||
* equivalent to this sscanf call:
|
||||
*
|
||||
* sscanf(in, "{\\an%*1u}%n", &len) >= 0 && len > 0
|
||||
*/
|
||||
static int scanbraces(const char* in) {
|
||||
if (strncmp(in, "{\\an", 4) != 0) {
|
||||
return 0;
|
||||
}
|
||||
if (!isdigit(in[4])) {
|
||||
return 0;
|
||||
}
|
||||
if (in[5] != '}') {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* skip all {\xxx} substrings except for {\an%d}
|
||||
and all microdvd like styles such as {Y:xxx} */
|
||||
static void handle_open_brace(AVBPrint *dst, const char **inp, int *an, int *closing_brace_missing)
|
||||
{
|
||||
int len = 0;
|
||||
const char *in = *inp;
|
||||
|
||||
*an += sscanf(in, "{\\an%*1u}%n", &len) >= 0 && len > 0;
|
||||
*an += scanbraces(in);
|
||||
|
||||
if (!*closing_brace_missing) {
|
||||
if ( (*an != 1 && in[1] == '\\')
|
||||
@@ -74,6 +93,34 @@ struct font_tag {
|
||||
uint32_t color;
|
||||
};
|
||||
|
||||
/*
|
||||
* Fast code for scanning the rest of a tag. Functionally equivalent to
|
||||
* this sscanf call:
|
||||
*
|
||||
* sscanf(in, "%127[^<>]>%n", buffer, lenp) == 2
|
||||
*/
|
||||
static int scantag(const char* in, char* buffer, int* lenp) {
|
||||
int len;
|
||||
|
||||
for (len = 0; len < 128; len++) {
|
||||
const char c = *in++;
|
||||
switch (c) {
|
||||
case '\0':
|
||||
return 0;
|
||||
case '<':
|
||||
return 0;
|
||||
case '>':
|
||||
buffer[len] = '\0';
|
||||
*lenp = len+1;
|
||||
return 1;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
buffer[len] = c;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* The general politic of the convert is to mask unsupported tags or formatting
|
||||
* errors (but still alert the user/subtitles writer with an error/warning)
|
||||
@@ -155,7 +202,7 @@ int ff_htmlmarkup_to_ass(void *log_ctx, AVBPrint *dst, const char *in)
|
||||
|
||||
len = 0;
|
||||
|
||||
if (sscanf(in+tag_close+1, "%127[^<>]>%n", buffer, &len) >= 1 && len > 0) {
|
||||
if (scantag(in+tag_close+1, buffer, &len) && len > 0) {
|
||||
const int skip = len + tag_close;
|
||||
const char *tagname = buffer;
|
||||
while (*tagname == ' ') {
|
||||
|
||||
@@ -408,11 +408,11 @@ static void lsf2poly(int16_t *a, int16_t *lsf)
|
||||
|
||||
a[0] = 4096;
|
||||
for (i = 5; i > 0; i--) {
|
||||
tmp = f[0][6 - i] + (unsigned)f[1][6 - i];
|
||||
a[6 - i] = (tmp + 4096) >> 13;
|
||||
tmp = f[0][6 - i] + (unsigned)f[1][6 - i] + 4096;
|
||||
a[6 - i] = tmp >> 13;
|
||||
|
||||
tmp = f[0][6 - i] - (unsigned)f[1][6 - i];
|
||||
a[5 + i] = (tmp + 4096) >> 13;
|
||||
tmp = f[0][6 - i] - (unsigned)f[1][6 - i] + 4096;
|
||||
a[5 + i] = tmp >> 13;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -745,7 +745,7 @@ static void construct_vector (
|
||||
for (j = 0; j < veclen; j++) {
|
||||
a32 = SPL_MUL_16_16(*gainPtr++, cbvec0[j]);
|
||||
a32 += SPL_MUL_16_16(*gainPtr++, cbvec1[j]);
|
||||
a32 += SPL_MUL_16_16(*gainPtr, cbvec2[j]);
|
||||
a32 += (unsigned)SPL_MUL_16_16(*gainPtr, cbvec2[j]);
|
||||
gainPtr -= 2;
|
||||
decvector[j] = (a32 + 8192) >> 14;
|
||||
}
|
||||
@@ -1303,7 +1303,8 @@ static int xcorr_coeff(int16_t *target, int16_t *regressor,
|
||||
pos += step;
|
||||
|
||||
/* Do a +/- to get the next energy */
|
||||
energy += step * ((*rp_end * *rp_end - *rp_beg * *rp_beg) >> shifts);
|
||||
energy += (unsigned)step * ((*rp_end * *rp_end - *rp_beg * *rp_beg) >> shifts);
|
||||
|
||||
rp_beg += step;
|
||||
rp_end += step;
|
||||
}
|
||||
|
||||
+3
-2
@@ -428,8 +428,9 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
||||
av_log(avctx, AV_LOG_ERROR, "Frame size change is unsupported.\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
avctx->width = width;
|
||||
avctx->height = height;
|
||||
ret = ff_set_dimensions(avctx, width, height);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
s->changed_size = 1;
|
||||
|
||||
@@ -531,7 +531,7 @@ static void dwt_decode97_int(DWTContext *s, int32_t *t)
|
||||
}
|
||||
|
||||
for (i = 0; i < w * h; i++)
|
||||
data[i] = (data[i] + ((1<<I_PRESHIFT)>>1)) >> I_PRESHIFT;
|
||||
data[i] = (data[i] + ((1LL<<I_PRESHIFT)>>1)) >> I_PRESHIFT;
|
||||
}
|
||||
|
||||
int ff_jpeg2000_dwt_init(DWTContext *s, int border[2][2],
|
||||
|
||||
@@ -170,6 +170,11 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
||||
GetBitContext gb;
|
||||
init_get_bits(&gb, buf, 8 * video_size);
|
||||
|
||||
if (avctx->height/8 * (avctx->width/8) > 4 * video_size) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Insufficient input data for dimensions\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
for (j = 0; j < avctx->height; j += 8)
|
||||
for (i = 0; i < avctx->width; i += 8)
|
||||
decode8x8(&gb,
|
||||
|
||||
@@ -2630,7 +2630,7 @@ void ff_hevc_sao_edge_filter_8_msa(uint8_t *dst, uint8_t *src,
|
||||
int16_t *sao_offset_val,
|
||||
int eo, int width, int height)
|
||||
{
|
||||
ptrdiff_t stride_src = (2 * 64 + 32) / sizeof(uint8_t);
|
||||
ptrdiff_t stride_src = (2 * MAX_PB_SIZE + AV_INPUT_BUFFER_PADDING_SIZE) / sizeof(uint8_t);
|
||||
|
||||
switch (eo) {
|
||||
case 0:
|
||||
|
||||
+9
-15
@@ -70,8 +70,7 @@ read_header:
|
||||
|
||||
skip_bits(&hgb, 32); /* reserved zeros */
|
||||
|
||||
if (get_bits_long(&hgb, 32) != MKBETAG('m','j','p','g'))
|
||||
{
|
||||
if (get_bits_long(&hgb, 32) != MKBETAG('m','j','p','g')) {
|
||||
av_log(avctx, AV_LOG_WARNING, "not mjpeg-b (bad fourcc)\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
@@ -85,19 +84,17 @@ read_header:
|
||||
|
||||
dqt_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "dqt is %d and size is %d\n");
|
||||
av_log(avctx, AV_LOG_DEBUG, "dqt offs: 0x%"PRIx32"\n", dqt_offs);
|
||||
if (dqt_offs)
|
||||
{
|
||||
if (dqt_offs) {
|
||||
init_get_bits(&s->gb, buf_ptr+dqt_offs, (buf_end - (buf_ptr+dqt_offs))*8);
|
||||
s->start_code = DQT;
|
||||
if (ff_mjpeg_decode_dqt(s) < 0 &&
|
||||
(avctx->err_recognition & AV_EF_EXPLODE))
|
||||
return AVERROR_INVALIDDATA;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
dht_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "dht is %d and size is %d\n");
|
||||
av_log(avctx, AV_LOG_DEBUG, "dht offs: 0x%"PRIx32"\n", dht_offs);
|
||||
if (dht_offs)
|
||||
{
|
||||
if (dht_offs) {
|
||||
init_get_bits(&s->gb, buf_ptr+dht_offs, (buf_end - (buf_ptr+dht_offs))*8);
|
||||
s->start_code = DHT;
|
||||
ff_mjpeg_decode_dht(s);
|
||||
@@ -105,8 +102,7 @@ read_header:
|
||||
|
||||
sof_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "sof is %d and size is %d\n");
|
||||
av_log(avctx, AV_LOG_DEBUG, "sof offs: 0x%"PRIx32"\n", sof_offs);
|
||||
if (sof_offs)
|
||||
{
|
||||
if (sof_offs) {
|
||||
init_get_bits(&s->gb, buf_ptr+sof_offs, (buf_end - (buf_ptr+sof_offs))*8);
|
||||
s->start_code = SOF0;
|
||||
if (ff_mjpeg_decode_sof(s) < 0)
|
||||
@@ -117,25 +113,23 @@ read_header:
|
||||
av_log(avctx, AV_LOG_DEBUG, "sos offs: 0x%"PRIx32"\n", sos_offs);
|
||||
sod_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "sof is %d and size is %d\n");
|
||||
av_log(avctx, AV_LOG_DEBUG, "sod offs: 0x%"PRIx32"\n", sod_offs);
|
||||
if (sos_offs)
|
||||
{
|
||||
if (sos_offs) {
|
||||
init_get_bits(&s->gb, buf_ptr + sos_offs,
|
||||
8 * FFMIN(field_size, buf_end - buf_ptr - sos_offs));
|
||||
s->mjpb_skiptosod = (sod_offs - sos_offs - show_bits(&s->gb, 16));
|
||||
s->start_code = SOS;
|
||||
if (ff_mjpeg_decode_sos(s, NULL, 0, NULL) < 0 &&
|
||||
(avctx->err_recognition & AV_EF_EXPLODE))
|
||||
return AVERROR_INVALIDDATA;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (s->interlaced) {
|
||||
s->bottom_field ^= 1;
|
||||
/* if not bottom field, do not output image yet */
|
||||
if (s->bottom_field != s->interlace_polarity && second_field_offs)
|
||||
{
|
||||
if (s->bottom_field != s->interlace_polarity && second_field_offs) {
|
||||
buf_ptr = buf + second_field_offs;
|
||||
goto read_header;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//XXX FIXME factorize, this looks very similar to the EOI code
|
||||
|
||||
+16
-16
@@ -1206,25 +1206,25 @@ static int ljpeg_decode_yuv_scan(MJpegDecodeContext *s, int predictor,
|
||||
|| v * mb_y + y >= s->height) {
|
||||
// Nothing to do
|
||||
} else if (bits<=8) {
|
||||
ptr = s->picture_ptr->data[c] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap
|
||||
if(y==0 && toprow){
|
||||
if(x==0 && leftcol){
|
||||
pred= 1 << (bits - 1);
|
||||
ptr = s->picture_ptr->data[c] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap
|
||||
if(y==0 && toprow){
|
||||
if(x==0 && leftcol){
|
||||
pred= 1 << (bits - 1);
|
||||
}else{
|
||||
pred= ptr[-1];
|
||||
}
|
||||
}else{
|
||||
pred= ptr[-1];
|
||||
if(x==0 && leftcol){
|
||||
pred= ptr[-linesize];
|
||||
}else{
|
||||
PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(x==0 && leftcol){
|
||||
pred= ptr[-linesize];
|
||||
}else{
|
||||
PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);
|
||||
}
|
||||
}
|
||||
|
||||
if (s->interlaced && s->bottom_field)
|
||||
ptr += linesize >> 1;
|
||||
pred &= mask;
|
||||
*ptr= pred + ((unsigned)dc << point_transform);
|
||||
if (s->interlaced && s->bottom_field)
|
||||
ptr += linesize >> 1;
|
||||
pred &= mask;
|
||||
*ptr= pred + ((unsigned)dc << point_transform);
|
||||
}else{
|
||||
ptr16 = (uint16_t*)(s->picture_ptr->data[c] + 2*(linesize * (v * mb_y + y)) + 2*(h * mb_x + x)); //FIXME optimize this crap
|
||||
if(y==0 && toprow){
|
||||
|
||||
+1
-1
@@ -1195,7 +1195,7 @@ static int read_access_unit(AVCodecContext *avctx, void* data,
|
||||
}
|
||||
|
||||
if (length < header_size + substr_header_size) {
|
||||
av_log(m->avctx, AV_LOG_ERROR, "Insuffient data for headers\n");
|
||||
av_log(m->avctx, AV_LOG_ERROR, "Insufficient data for headers\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
@@ -1899,14 +1899,20 @@ static int mpeg4_decode_studio_block(MpegEncContext *s, int32_t block[64], int n
|
||||
code >>= 1;
|
||||
run = (1 << (additional_code_len - 1)) + code;
|
||||
idx += run;
|
||||
if (idx > 63)
|
||||
return AVERROR_INVALIDDATA;
|
||||
j = scantable[idx++];
|
||||
block[j] = sign ? 1 : -1;
|
||||
} else if (group >= 13 && group <= 20) {
|
||||
/* Level value (Table B.49) */
|
||||
if (idx > 63)
|
||||
return AVERROR_INVALIDDATA;
|
||||
j = scantable[idx++];
|
||||
block[j] = get_xbits(&s->gb, additional_code_len);
|
||||
} else if (group == 21) {
|
||||
/* Escape */
|
||||
if (idx > 63)
|
||||
return AVERROR_INVALIDDATA;
|
||||
j = scantable[idx++];
|
||||
additional_code_len = s->avctx->bits_per_raw_sample + s->dct_precision + 4;
|
||||
flc = get_bits(&s->gb, additional_code_len);
|
||||
@@ -3056,6 +3062,8 @@ static int decode_studio_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb)
|
||||
if (get_bits_left(gb) <= 32)
|
||||
return 0;
|
||||
|
||||
s->partitioned_frame = 0;
|
||||
s->interlaced_dct = 0;
|
||||
s->decode_mb = mpeg4_decode_studio_mb;
|
||||
|
||||
decode_smpte_tc(ctx, gb);
|
||||
|
||||
@@ -78,6 +78,8 @@ static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
|
||||
ff_update_block_index(s);
|
||||
|
||||
s->bdsp.clear_blocks(s->block[0]);
|
||||
if (!s->chroma_y_shift)
|
||||
s->bdsp.clear_blocks(s->block[6]);
|
||||
|
||||
s->dest[0] = s->current_picture.f->data[0] +
|
||||
s->mb_y * 16 * s->linesize +
|
||||
|
||||
@@ -101,7 +101,7 @@ static int mpegaudio_parse(AVCodecParserContext *s1,
|
||||
"MP3ADU full parser");
|
||||
*poutbuf = NULL;
|
||||
*poutbuf_size = 0;
|
||||
return 0; /* parsers must not return error codes */
|
||||
return buf_size; /* parsers must not return error codes */
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -412,6 +412,14 @@ int ff_msmpeg4_decode_picture_header(MpegEncContext * s)
|
||||
{
|
||||
int code;
|
||||
|
||||
// at minimum one bit per macroblock is required at least in a valid frame,
|
||||
// we discard frames much smaller than this. Frames smaller than 1/8 of the
|
||||
// smallest "black/skip" frame generally contain not much recoverable content
|
||||
// while at the same time they have the highest computational requirements
|
||||
// per byte
|
||||
if (get_bits_left(&s->gb) * 8LL < (s->width+15)/16 * ((s->height+15)/16))
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if(s->msmpeg4_version==1){
|
||||
int start_code = get_bits_long(&s->gb, 32);
|
||||
if(start_code!=0x00000100){
|
||||
|
||||
@@ -62,6 +62,9 @@ static av_cold int msvideo1_decode_init(AVCodecContext *avctx)
|
||||
|
||||
s->avctx = avctx;
|
||||
|
||||
if (avctx->width < 4 || avctx->height < 4)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
/* figure out the colorspace based on the presence of a palette */
|
||||
if (s->avctx->bits_per_coded_sample == 8) {
|
||||
s->mode_8bit = 1;
|
||||
|
||||
+5
-1
@@ -601,7 +601,11 @@ int ff_nvdec_frame_params(AVCodecContext *avctx,
|
||||
frames_ctx->format = AV_PIX_FMT_CUDA;
|
||||
frames_ctx->width = (avctx->coded_width + 1) & ~1;
|
||||
frames_ctx->height = (avctx->coded_height + 1) & ~1;
|
||||
frames_ctx->initial_pool_size = dpb_size;
|
||||
/*
|
||||
* We add two extra frames to the pool to account for deinterlacing filters
|
||||
* holding onto their frames.
|
||||
*/
|
||||
frames_ctx->initial_pool_size = dpb_size + 2;
|
||||
|
||||
frames_ctx->free = nvdec_free_dummy;
|
||||
frames_ctx->pool = av_buffer_pool_init(0, nvdec_alloc_dummy);
|
||||
|
||||
@@ -676,6 +676,11 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size,
|
||||
*/
|
||||
break;
|
||||
case DISPLAY_SEGMENT:
|
||||
if (*data_size) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Duplicate display segment\n");
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
break;
|
||||
}
|
||||
ret = display_end_segment(avctx, data, buf, segment_length);
|
||||
if (ret >= 0)
|
||||
*data_size = ret;
|
||||
|
||||
@@ -578,6 +578,10 @@ static int decode_ihdr_chunk(AVCodecContext *avctx, PNGDecContext *s,
|
||||
}
|
||||
s->color_type = bytestream2_get_byte(&s->gb);
|
||||
s->compression_type = bytestream2_get_byte(&s->gb);
|
||||
if (s->compression_type) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid compression method %d\n", s->compression_type);
|
||||
goto error;
|
||||
}
|
||||
s->filter_type = bytestream2_get_byte(&s->gb);
|
||||
s->interlace_type = bytestream2_get_byte(&s->gb);
|
||||
bytestream2_skip(&s->gb, 4); /* crc */
|
||||
|
||||
@@ -58,7 +58,13 @@ static av_always_inline void transform4x4(vec_s16 src_01, vec_s16 src_23,
|
||||
e1 = vec_msums(src_02, trans4[2], zero);
|
||||
o1 = vec_msums(src_13, trans4[3], zero);
|
||||
|
||||
add = vec_sl(vec_splat_s32(1), vec_splat_u32(shift - 1));
|
||||
switch(shift) {
|
||||
case 7: add = vec_sl(vec_splat_s32(1), vec_splat_u32( 7 - 1)); break;
|
||||
case 10: add = vec_sl(vec_splat_s32(1), vec_splat_u32(10 - 1)); break;
|
||||
case 12: add = vec_sl(vec_splat_s32(1), vec_splat_u32(12 - 1)); break;
|
||||
default: abort();
|
||||
}
|
||||
|
||||
e0 = vec_add(e0, add);
|
||||
e1 = vec_add(e1, add);
|
||||
|
||||
@@ -72,7 +78,14 @@ static av_always_inline void scale(vec_s32 res[4], vec_s16 res_packed[2],
|
||||
const int shift)
|
||||
{
|
||||
int i;
|
||||
vec_u32 v_shift = vec_splat_u32(shift);
|
||||
vec_u32 v_shift;
|
||||
|
||||
switch(shift) {
|
||||
case 7: v_shift = vec_splat_u32(7) ; break;
|
||||
case 10: v_shift = vec_splat_u32(10); break;
|
||||
case 12: v_shift = vec_splat_u32(12); break;
|
||||
default: abort();
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
res[i] = vec_sra(res[i], v_shift);
|
||||
|
||||
@@ -221,6 +221,7 @@ typedef struct ProresThreadData {
|
||||
DECLARE_ALIGNED(16, int16_t, blocks)[MAX_PLANES][64 * 4 * MAX_MBS_PER_SLICE];
|
||||
DECLARE_ALIGNED(16, uint16_t, emu_buf)[16 * 16];
|
||||
int16_t custom_q[64];
|
||||
int16_t custom_chroma_q[64];
|
||||
struct TrellisNode *nodes;
|
||||
} ProresThreadData;
|
||||
|
||||
@@ -231,6 +232,7 @@ typedef struct ProresContext {
|
||||
int16_t quants[MAX_STORED_Q][64];
|
||||
int16_t quants_chroma[MAX_STORED_Q][64];
|
||||
int16_t custom_q[64];
|
||||
int16_t custom_chroma_q[64];
|
||||
const uint8_t *quant_mat;
|
||||
const uint8_t *quant_chroma_mat;
|
||||
const uint8_t *scantable;
|
||||
@@ -573,7 +575,7 @@ static int encode_slice(AVCodecContext *avctx, const AVFrame *pic,
|
||||
qmat_chroma = ctx->quants_chroma[quant];
|
||||
} else {
|
||||
qmat = ctx->custom_q;
|
||||
qmat_chroma = ctx->custom_q;
|
||||
qmat_chroma = ctx->custom_chroma_q;
|
||||
for (i = 0; i < 64; i++) {
|
||||
qmat[i] = ctx->quant_mat[i] * quant;
|
||||
qmat_chroma[i] = ctx->quant_chroma_mat[i] * quant;
|
||||
@@ -901,7 +903,7 @@ static int find_slice_quant(AVCodecContext *avctx,
|
||||
qmat_chroma = ctx->quants_chroma[q];
|
||||
} else {
|
||||
qmat = td->custom_q;
|
||||
qmat_chroma = td->custom_q;
|
||||
qmat_chroma = td->custom_chroma_q;
|
||||
for (i = 0; i < 64; i++) {
|
||||
qmat[i] = ctx->quant_mat[i] * q;
|
||||
qmat_chroma[i] = ctx->quant_chroma_mat[i] * q;
|
||||
|
||||
+10
-9
@@ -57,27 +57,25 @@ static int decompress(GetByteContext *gb, int size, PutByteContext *pb, const ui
|
||||
b = lut[2 * idx];
|
||||
|
||||
while (1) {
|
||||
if (bytestream2_get_bytes_left_p(pb) <= 0)
|
||||
if (bytestream2_get_bytes_left_p(pb) <= 0 || bytestream2_get_eof(pb))
|
||||
return 0;
|
||||
if (((b & 0xFF00u) != 0x8000u) || (b & 0xFFu)) {
|
||||
if ((b & 0xFF00u) != 0x8000u || (b & 0xFFu)) {
|
||||
if ((b & 0xFF00u) != 0x8000u) {
|
||||
bytestream2_put_le16(pb, b);
|
||||
} else if (b & 0xFFu) {
|
||||
} else {
|
||||
idx = 0;
|
||||
for (int i = 0; i < (b & 0xFFu); i++)
|
||||
bytestream2_put_le32(pb, 0);
|
||||
}
|
||||
c = b >> 16;
|
||||
if (c & 0xFF00u) {
|
||||
c = (((c >> 8) & 0xFFu) | (c & 0xFF00)) & 0xF00F;
|
||||
fill = lut[2 * idx + 1];
|
||||
if ((c & 0xFF00u) == 0x1000) {
|
||||
if ((c & 0xF000u) == 0x1000) {
|
||||
bytestream2_put_le16(pb, fill);
|
||||
c &= 0xFFFF00FFu;
|
||||
} else {
|
||||
bytestream2_put_le32(pb, fill);
|
||||
c &= 0xFFFF00FFu;
|
||||
}
|
||||
c = (c >> 8) & 0x0Fu;
|
||||
}
|
||||
while (c) {
|
||||
a <<= 4;
|
||||
@@ -101,6 +99,8 @@ static int decompress(GetByteContext *gb, int size, PutByteContext *pb, const ui
|
||||
}
|
||||
idx = a >> 20;
|
||||
b = lut[2 * idx];
|
||||
if (!b)
|
||||
return AVERROR_INVALIDDATA;
|
||||
continue;
|
||||
}
|
||||
idx = 2;
|
||||
@@ -161,8 +161,9 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
||||
memset(s->decbuffer, 0, s->size);
|
||||
bytestream2_init(&s->gb, avpkt->data, avpkt->size);
|
||||
bytestream2_init_writer(&s->pb, s->decbuffer, s->size);
|
||||
|
||||
decompress(&s->gb, AV_RL32(avpkt->data + 28) >> 1, &s->pb, s->lut);
|
||||
ret = decompress(&s->gb, AV_RL32(avpkt->data + 28) >> 1, &s->pb, s->lut);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
vertical_predict((uint32_t *)s->decbuffer, 0, (uint32_t *)s->initial_line, s->stride, 1);
|
||||
vertical_predict((uint32_t *)s->decbuffer, s->stride, (uint32_t *)s->decbuffer, s->stride, avctx->height - 1);
|
||||
|
||||
|
||||
@@ -90,6 +90,8 @@ static void qpeg_decode_intra(QpegContext *qctx, uint8_t *dst,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (bytestream2_get_bytes_left(&qctx->buffer) < copy)
|
||||
copy = bytestream2_get_bytes_left(&qctx->buffer);
|
||||
for(i = 0; i < copy; i++) {
|
||||
dst[filled++] = bytestream2_get_byte(&qctx->buffer);
|
||||
if (filled >= width) {
|
||||
|
||||
+9
-4
@@ -215,7 +215,7 @@ static int decode_move(AVCodecContext *avctx,
|
||||
bytestream2_skip(gb, 8);
|
||||
compression = bytestream2_get_le32(gb);
|
||||
|
||||
if (nb_moves > INT32_MAX / 16)
|
||||
if (nb_moves > INT32_MAX / 16 || nb_moves > avctx->width * avctx->height)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
uncompressed_size = 16 * nb_moves;
|
||||
@@ -353,6 +353,8 @@ static int decode_dlta(AVCodecContext *avctx,
|
||||
compression = bytestream2_get_le32(gb);
|
||||
|
||||
if (compression == 1) {
|
||||
if (w * h * s->bpp * 3 < uncompressed_size)
|
||||
return AVERROR_INVALIDDATA;
|
||||
ret = decode_zlib(avctx, avpkt, size, uncompressed_size);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
@@ -680,6 +682,9 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
while (bytestream2_get_bytes_left(gb) > 0) {
|
||||
unsigned type, size = 0;
|
||||
|
||||
if (bytestream2_get_bytes_left(gb) < 8)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
type = bytestream2_get_le32(gb);
|
||||
if (type == KBND || type == BNDL) {
|
||||
intra = type == KBND;
|
||||
@@ -718,12 +723,12 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = ff_get_buffer(avctx, s->frame, 0)) < 0)
|
||||
return ret;
|
||||
|
||||
if (!s->frame2->data[0] || !s->frame1->data[0])
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if ((ret = ff_get_buffer(avctx, s->frame, 0)) < 0)
|
||||
return ret;
|
||||
|
||||
copy_plane(avctx, s->frame2, s->frame);
|
||||
if (avctx->pix_fmt == AV_PIX_FMT_PAL8)
|
||||
memcpy(s->frame->data[1], s->frame2->data[1], 1024);
|
||||
|
||||
+11
-6
@@ -73,13 +73,12 @@ typedef struct RpzaContext {
|
||||
static int rpza_decode_stream(RpzaContext *s)
|
||||
{
|
||||
int width = s->avctx->width;
|
||||
int stride = s->frame->linesize[0] / 2;
|
||||
int row_inc = stride - 4;
|
||||
int stride, row_inc, ret;
|
||||
int chunk_size;
|
||||
uint16_t colorA = 0, colorB;
|
||||
uint16_t color4[4];
|
||||
uint16_t ta, tb;
|
||||
uint16_t *pixels = (uint16_t *)s->frame->data[0];
|
||||
uint16_t *pixels;
|
||||
|
||||
int row_ptr = 0;
|
||||
int pixel_ptr = 0;
|
||||
@@ -106,6 +105,15 @@ static int rpza_decode_stream(RpzaContext *s)
|
||||
/* Number of 4x4 blocks in frame. */
|
||||
total_blocks = ((s->avctx->width + 3) / 4) * ((s->avctx->height + 3) / 4);
|
||||
|
||||
if (total_blocks / 32 > bytestream2_get_bytes_left(&s->gb))
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if ((ret = ff_reget_buffer(s->avctx, s->frame)) < 0)
|
||||
return ret;
|
||||
pixels = (uint16_t *)s->frame->data[0];
|
||||
stride = s->frame->linesize[0] / 2;
|
||||
row_inc = stride - 4;
|
||||
|
||||
/* Process chunk data */
|
||||
while (bytestream2_get_bytes_left(&s->gb)) {
|
||||
uint8_t opcode = bytestream2_get_byte(&s->gb); /* Get opcode */
|
||||
@@ -256,9 +264,6 @@ static int rpza_decode_frame(AVCodecContext *avctx,
|
||||
|
||||
bytestream2_init(&s->gb, avpkt->data, avpkt->size);
|
||||
|
||||
if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
|
||||
return ret;
|
||||
|
||||
ret = rpza_decode_stream(s);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
+19
-15
@@ -34,32 +34,36 @@
|
||||
static SoftFloat sbr_sum_square_c(int (*x)[2], int n)
|
||||
{
|
||||
SoftFloat ret;
|
||||
uint64_t accu, round;
|
||||
uint64_t accu = 0, round;
|
||||
uint64_t accu0 = 0, accu1 = 0, accu2 = 0, accu3 = 0;
|
||||
int i, nz, nz0;
|
||||
unsigned u;
|
||||
|
||||
nz = 0;
|
||||
for (i = 0; i < n; i += 2) {
|
||||
// Larger values are inavlid and could cause overflows of accu.
|
||||
av_assert2(FFABS(x[i + 0][0]) >> 30 == 0);
|
||||
accu0 += (int64_t)x[i + 0][0] * x[i + 0][0];
|
||||
av_assert2(FFABS(x[i + 0][1]) >> 30 == 0);
|
||||
accu1 += (int64_t)x[i + 0][1] * x[i + 0][1];
|
||||
av_assert2(FFABS(x[i + 1][0]) >> 30 == 0);
|
||||
accu2 += (int64_t)x[i + 1][0] * x[i + 1][0];
|
||||
av_assert2(FFABS(x[i + 1][1]) >> 30 == 0);
|
||||
accu3 += (int64_t)x[i + 1][1] * x[i + 1][1];
|
||||
if ((accu0|accu1|accu2|accu3) > UINT64_MAX - INT32_MIN*(int64_t)INT32_MIN || i+2>=n) {
|
||||
accu0 >>= nz;
|
||||
accu1 >>= nz;
|
||||
accu2 >>= nz;
|
||||
accu3 >>= nz;
|
||||
while ((accu0|accu1|accu2|accu3) > (UINT64_MAX - accu) >> 2) {
|
||||
accu0 >>= 1;
|
||||
accu1 >>= 1;
|
||||
accu2 >>= 1;
|
||||
accu3 >>= 1;
|
||||
accu >>= 1;
|
||||
nz ++;
|
||||
}
|
||||
accu += accu0 + accu1 + accu2 + accu3;
|
||||
accu0 = accu1 = accu2 = accu3 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
nz0 = 15;
|
||||
while ((accu0|accu1|accu2|accu3) >> 62) {
|
||||
accu0 >>= 1;
|
||||
accu1 >>= 1;
|
||||
accu2 >>= 1;
|
||||
accu3 >>= 1;
|
||||
nz0 --;
|
||||
}
|
||||
accu = accu0 + accu1 + accu2 + accu3;
|
||||
nz0 = 15 - nz;
|
||||
|
||||
u = accu >> 32;
|
||||
if (u) {
|
||||
|
||||
+1
-1
@@ -512,7 +512,7 @@ static int decompress_p(AVCodecContext *avctx,
|
||||
{
|
||||
SCPRContext *s = avctx->priv_data;
|
||||
GetByteContext *gb = &s->gb;
|
||||
int ret, temp, min, max, x, y, cx = 0, cx1 = 0;
|
||||
int ret, temp = 0, min, max, x, y, cx = 0, cx1 = 0;
|
||||
int backstep = linesize - avctx->width;
|
||||
|
||||
if (bytestream2_get_byte(gb) == 0)
|
||||
|
||||
@@ -382,7 +382,7 @@ static int decode_subframe_lpc(ShortenContext *s, int command, int channel,
|
||||
/* subtract offset from previous samples to use in prediction */
|
||||
if (command == FN_QLPC && coffset)
|
||||
for (i = -pred_order; i < 0; i++)
|
||||
s->decoded[channel][i] -= coffset;
|
||||
s->decoded[channel][i] -= (unsigned)coffset;
|
||||
|
||||
/* decode residual and do LPC prediction */
|
||||
init_sum = pred_order ? (command == FN_QLPC ? s->lpcqoffset : 0) : coffset;
|
||||
@@ -397,7 +397,7 @@ static int decode_subframe_lpc(ShortenContext *s, int command, int channel,
|
||||
/* add offset to current samples */
|
||||
if (command == FN_QLPC && coffset)
|
||||
for (i = 0; i < s->blocksize; i++)
|
||||
s->decoded[channel][i] += coffset;
|
||||
s->decoded[channel][i] += (unsigned)coffset;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
int main(void)
|
||||
{
|
||||
RangeCoder c;
|
||||
uint8_t b[9 * SIZE];
|
||||
uint8_t b[9 * SIZE] = {0};
|
||||
uint8_t r[9 * SIZE];
|
||||
int i;
|
||||
uint8_t state[10];
|
||||
|
||||
+7
-4
@@ -571,7 +571,7 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid
|
||||
if (s->compr == TIFF_CCITT_RLE ||
|
||||
s->compr == TIFF_G3 ||
|
||||
s->compr == TIFF_G4) {
|
||||
if (is_yuv)
|
||||
if (is_yuv || p->format == AV_PIX_FMT_GRAY12)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
return tiff_unpack_fax(s, dst, stride, src, size, width, lines);
|
||||
@@ -1304,6 +1304,7 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
planes = s->planar ? s->bppcount : 1;
|
||||
for (plane = 0; plane < planes; plane++) {
|
||||
int remaining = avpkt->size;
|
||||
int decoded_height;
|
||||
stride = p->linesize[plane];
|
||||
dst = p->data[plane];
|
||||
for (i = 0; i < s->height; i += s->rps) {
|
||||
@@ -1331,6 +1332,8 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
break;
|
||||
}
|
||||
}
|
||||
decoded_height = FFMIN(i, s->height);
|
||||
|
||||
if (s->predictor == 2) {
|
||||
if (s->photometric == TIFF_PHOTOMETRIC_YCBCR) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "predictor == 2 with YUV is unsupported");
|
||||
@@ -1347,7 +1350,7 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
s->avctx->pix_fmt == AV_PIX_FMT_YA16LE ||
|
||||
s->avctx->pix_fmt == AV_PIX_FMT_GBRP16LE ||
|
||||
s->avctx->pix_fmt == AV_PIX_FMT_GBRAP16LE) {
|
||||
for (i = 0; i < s->height; i++) {
|
||||
for (i = 0; i < decoded_height; i++) {
|
||||
for (j = soff; j < ssize; j += 2)
|
||||
AV_WL16(dst + j, AV_RL16(dst + j) + AV_RL16(dst + j - soff));
|
||||
dst += stride;
|
||||
@@ -1358,13 +1361,13 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
s->avctx->pix_fmt == AV_PIX_FMT_YA16BE ||
|
||||
s->avctx->pix_fmt == AV_PIX_FMT_GBRP16BE ||
|
||||
s->avctx->pix_fmt == AV_PIX_FMT_GBRAP16BE) {
|
||||
for (i = 0; i < s->height; i++) {
|
||||
for (i = 0; i < decoded_height; i++) {
|
||||
for (j = soff; j < ssize; j += 2)
|
||||
AV_WB16(dst + j, AV_RB16(dst + j) + AV_RB16(dst + j - soff));
|
||||
dst += stride;
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < s->height; i++) {
|
||||
for (i = 0; i < decoded_height; i++) {
|
||||
for (j = soff; j < ssize; j++)
|
||||
dst[j] += dst[j - soff];
|
||||
dst += stride;
|
||||
|
||||
@@ -484,7 +484,7 @@ static inline void tm2_high_chroma(int *data, int stride, int *last, unsigned *C
|
||||
}
|
||||
}
|
||||
|
||||
static inline void tm2_low_chroma(int *data, int stride, int *clast, int *CD, int *deltas, int bx)
|
||||
static inline void tm2_low_chroma(int *data, int stride, int *clast, unsigned *CD, int *deltas, int bx)
|
||||
{
|
||||
int t;
|
||||
int l;
|
||||
@@ -494,8 +494,8 @@ static inline void tm2_low_chroma(int *data, int stride, int *clast, int *CD, in
|
||||
prev = clast[-3];
|
||||
else
|
||||
prev = 0;
|
||||
t = (CD[0] + CD[1]) >> 1;
|
||||
l = (prev - CD[0] - CD[1] + clast[1]) >> 1;
|
||||
t = (int)(CD[0] + CD[1]) >> 1;
|
||||
l = (int)(prev - CD[0] - CD[1] + clast[1]) >> 1;
|
||||
CD[1] = CD[0] + CD[1] - t;
|
||||
CD[0] = t;
|
||||
clast[0] = l;
|
||||
|
||||
@@ -116,7 +116,7 @@ static int truemotion2rt_decode_frame(AVCodecContext *avctx, void *data,
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (avctx->width / s->hscale * avctx->height * s->delta_size > avpkt->size * 8LL * 4)
|
||||
if ((avctx->width + s->hscale - 1)/ s->hscale * avctx->height * s->delta_size > avpkt->size * 8LL * 4)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
ret = init_get_bits8(gb, avpkt->data + ret, avpkt->size - ret);
|
||||
|
||||
@@ -104,7 +104,7 @@ int ff_v4l2_m2m_codec_init(AVCodecContext *avctx);
|
||||
int ff_v4l2_m2m_codec_end(AVCodecContext *avctx);
|
||||
|
||||
/**
|
||||
* Reinitializes the V4L2m2mContext when the driver cant continue processing
|
||||
* Reinitializes the V4L2m2mContext when the driver cannot continue processing
|
||||
* with the capture parameters.
|
||||
*
|
||||
* @param[in] ctx The V4L2m2mContext instantiated by the encoder/decoder.
|
||||
@@ -114,7 +114,7 @@ int ff_v4l2_m2m_codec_end(AVCodecContext *avctx);
|
||||
int ff_v4l2_m2m_codec_reinit(V4L2m2mContext *ctx);
|
||||
|
||||
/**
|
||||
* Reinitializes the V4L2m2mContext when the driver cant continue processing
|
||||
* Reinitializes the V4L2m2mContext when the driver cannot continue processing
|
||||
* with the any of the current V4L2Contexts (ie, changes in output and capture).
|
||||
*
|
||||
* @param[in] ctx The V4L2m2mContext instantiated by the encoder/decoder.
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "libavutil/version.h"
|
||||
|
||||
#define LIBAVCODEC_VERSION_MAJOR 58
|
||||
#define LIBAVCODEC_VERSION_MINOR 36
|
||||
#define LIBAVCODEC_VERSION_MINOR 35
|
||||
#define LIBAVCODEC_VERSION_MICRO 100
|
||||
|
||||
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
||||
|
||||
@@ -181,6 +181,14 @@ int ff_wmv2_decode_secondary_picture_header(MpegEncContext *s)
|
||||
}
|
||||
|
||||
s->dc_table_index = get_bits1(&s->gb);
|
||||
|
||||
// at minimum one bit per macroblock is required at least in a valid frame,
|
||||
// we discard frames much smaller than this. Frames smaller than 1/8 of the
|
||||
// smallest "black/skip" frame generally contain not much recoverable content
|
||||
// while at the same time they have the highest computational requirements
|
||||
// per byte
|
||||
if (get_bits_left(&s->gb) * 8LL < (s->width+15)/16 * ((s->height+15)/16))
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
s->inter_intra_pred = 0;
|
||||
s->no_rounding = 1;
|
||||
|
||||
+3
-3
@@ -525,9 +525,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
|
||||
return ret;
|
||||
|
||||
if (c->comp == 0) { // uncompressed data
|
||||
if (c->decomp_size < len) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Buffer too small\n");
|
||||
@@ -553,6 +550,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
|
||||
av_log(avctx, AV_LOG_ERROR, "decompressed size %d is incorrect, expected %d\n", c->decomp_len, expected_size);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
|
||||
return ret;
|
||||
|
||||
if (c->flags & ZMBV_KEYFRAME) {
|
||||
frame->key_frame = 1;
|
||||
frame->pict_type = AV_PICTURE_TYPE_I;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "libavutil/version.h"
|
||||
|
||||
#define LIBAVDEVICE_VERSION_MAJOR 58
|
||||
#define LIBAVDEVICE_VERSION_MINOR 6
|
||||
#define LIBAVDEVICE_VERSION_MINOR 5
|
||||
#define LIBAVDEVICE_VERSION_MICRO 100
|
||||
|
||||
#define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
|
||||
|
||||
@@ -407,7 +407,8 @@ OBJS-$(CONFIG_WAVEFORM_FILTER) += vf_waveform.o
|
||||
OBJS-$(CONFIG_WEAVE_FILTER) += vf_weave.o
|
||||
OBJS-$(CONFIG_XBR_FILTER) += vf_xbr.o
|
||||
OBJS-$(CONFIG_XSTACK_FILTER) += vf_stack.o framesync.o
|
||||
OBJS-$(CONFIG_YADIF_FILTER) += vf_yadif.o
|
||||
OBJS-$(CONFIG_YADIF_FILTER) += vf_yadif.o yadif_common.o
|
||||
OBJS-$(CONFIG_YADIF_CUDA_FILTER) += vf_yadif_cuda.o vf_yadif_cuda.ptx.o yadif_common.o
|
||||
OBJS-$(CONFIG_ZMQ_FILTER) += f_zmq.o
|
||||
OBJS-$(CONFIG_ZOOMPAN_FILTER) += vf_zoompan.o
|
||||
OBJS-$(CONFIG_ZSCALE_FILTER) += vf_zscale.o
|
||||
|
||||
@@ -245,8 +245,8 @@ static const AVOption afade_options[] = {
|
||||
{ "ns", "set number of samples for fade duration", OFFSET(nb_samples), AV_OPT_TYPE_INT64, {.i64 = 44100}, 1, INT64_MAX, FLAGS },
|
||||
{ "start_time", "set time to start fading", OFFSET(start_time), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, FLAGS },
|
||||
{ "st", "set time to start fading", OFFSET(start_time), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, FLAGS },
|
||||
{ "duration", "set fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS },
|
||||
{ "d", "set fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS },
|
||||
{ "duration", "set fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, FLAGS },
|
||||
{ "d", "set fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, FLAGS },
|
||||
{ "curve", "set fade curve type", OFFSET(curve), AV_OPT_TYPE_INT, {.i64 = TRI }, 0, NB_CURVES - 1, FLAGS, "curve" },
|
||||
{ "c", "set fade curve type", OFFSET(curve), AV_OPT_TYPE_INT, {.i64 = TRI }, 0, NB_CURVES - 1, FLAGS, "curve" },
|
||||
{ "tri", "linear slope", 0, AV_OPT_TYPE_CONST, {.i64 = TRI }, 0, 0, FLAGS, "curve" },
|
||||
|
||||
@@ -76,6 +76,13 @@ static int activate(AVFilterContext *ctx)
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
ret = av_frame_copy_props(pad_frame, frame);
|
||||
if (ret < 0) {
|
||||
av_frame_free(&pad_frame);
|
||||
av_frame_free(&frame);
|
||||
return ret;
|
||||
}
|
||||
|
||||
av_samples_copy(pad_frame->extended_data, frame->extended_data,
|
||||
0, 0, frame->nb_samples, frame->channels, frame->format);
|
||||
av_samples_set_silence(pad_frame->extended_data, frame->nb_samples,
|
||||
|
||||
@@ -389,6 +389,7 @@ extern AVFilter ff_vf_weave;
|
||||
extern AVFilter ff_vf_xbr;
|
||||
extern AVFilter ff_vf_xstack;
|
||||
extern AVFilter ff_vf_yadif;
|
||||
extern AVFilter ff_vf_yadif_cuda;
|
||||
extern AVFilter ff_vf_zmq;
|
||||
extern AVFilter ff_vf_zoompan;
|
||||
extern AVFilter ff_vf_zscale;
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
#include "libavutil/version.h"
|
||||
|
||||
#define LIBAVFILTER_VERSION_MAJOR 7
|
||||
#define LIBAVFILTER_VERSION_MINOR 41
|
||||
#define LIBAVFILTER_VERSION_MICRO 100
|
||||
#define LIBAVFILTER_VERSION_MINOR 40
|
||||
#define LIBAVFILTER_VERSION_MICRO 101
|
||||
|
||||
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
|
||||
LIBAVFILTER_VERSION_MINOR, \
|
||||
|
||||
@@ -386,13 +386,13 @@ static const AVOption fade_options[] = {
|
||||
OFFSET(nb_frames), AV_OPT_TYPE_INT, { .i64 = 25 }, 0, INT_MAX, FLAGS },
|
||||
{ "alpha", "fade alpha if it is available on the input", OFFSET(alpha), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, FLAGS },
|
||||
{ "start_time", "Number of seconds of the beginning of the effect.",
|
||||
OFFSET(start_time), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS },
|
||||
OFFSET(start_time), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, FLAGS },
|
||||
{ "st", "Number of seconds of the beginning of the effect.",
|
||||
OFFSET(start_time), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS },
|
||||
OFFSET(start_time), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, FLAGS },
|
||||
{ "duration", "Duration of the effect in seconds.",
|
||||
OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS },
|
||||
OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, FLAGS },
|
||||
{ "d", "Duration of the effect in seconds.",
|
||||
OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS },
|
||||
OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, FLAGS },
|
||||
{ "color", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, CHAR_MIN, CHAR_MAX, FLAGS },
|
||||
{ "c", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, CHAR_MIN, CHAR_MAX, FLAGS },
|
||||
{ NULL }
|
||||
|
||||
+13
-13
@@ -380,15 +380,15 @@ static av_always_inline void blend_slice_packed_rgb(AVFilterContext *ctx,
|
||||
uint8_t *S, *sp, *d, *dp;
|
||||
|
||||
i = FFMAX(-y, 0);
|
||||
imax = FFMIN(-y + dst_h, src_h);
|
||||
imax = FFMIN3(-y + dst_h, FFMIN(src_h, dst_h), y + src_h);
|
||||
|
||||
slice_start = (imax * jobnr) / nb_jobs;
|
||||
slice_end = (imax * (jobnr+1)) / nb_jobs;
|
||||
slice_start = i + (imax * jobnr) / nb_jobs;
|
||||
slice_end = i + (imax * (jobnr+1)) / nb_jobs;
|
||||
|
||||
sp = src->data[0] + (i + slice_start) * src->linesize[0];
|
||||
dp = dst->data[0] + (y + i + slice_start) * dst->linesize[0];
|
||||
sp = src->data[0] + (slice_start) * src->linesize[0];
|
||||
dp = dst->data[0] + (y + slice_start) * dst->linesize[0];
|
||||
|
||||
for (i = i + slice_start; i < slice_end; i++) {
|
||||
for (i = slice_start; i < slice_end; i++) {
|
||||
j = FFMAX(-x, 0);
|
||||
S = sp + j * sstep;
|
||||
d = dp + (x+j) * dstep;
|
||||
@@ -468,19 +468,19 @@ static av_always_inline void blend_plane(AVFilterContext *ctx,
|
||||
int slice_start, slice_end;
|
||||
|
||||
j = FFMAX(-yp, 0);
|
||||
jmax = FFMIN(-yp + dst_hp, src_hp);
|
||||
jmax = FFMIN3(-yp + dst_hp, FFMIN(src_hp, dst_hp), yp + src_hp);
|
||||
|
||||
slice_start = (jmax * jobnr) / nb_jobs;
|
||||
slice_end = (jmax * (jobnr+1)) / nb_jobs;
|
||||
slice_start = j + (jmax * jobnr) / nb_jobs;
|
||||
slice_end = j + (jmax * (jobnr+1)) / nb_jobs;
|
||||
|
||||
sp = src->data[i] + slice_start * src->linesize[i];
|
||||
sp = src->data[i] + (slice_start) * src->linesize[i];
|
||||
dp = dst->data[dst_plane]
|
||||
+ (yp + slice_start) * dst->linesize[dst_plane]
|
||||
+ dst_offset;
|
||||
ap = src->data[3] + (slice_start << vsub) * src->linesize[3];
|
||||
dap = dst->data[3] + ((yp + slice_start) << vsub) * dst->linesize[3];
|
||||
|
||||
for (j = j + slice_start; j < slice_end; j++) {
|
||||
for (j = slice_start; j < slice_end; j++) {
|
||||
k = FFMAX(-xp, 0);
|
||||
d = dp + (xp+k) * dst_step;
|
||||
s = sp + k;
|
||||
@@ -961,13 +961,13 @@ static int do_blend(FFFrameSync *fs)
|
||||
s->var_values[VAR_Y], s->y);
|
||||
}
|
||||
|
||||
if (s->x < mainpic->width && s->x + second->width >= 0 ||
|
||||
if (s->x < mainpic->width && s->x + second->width >= 0 &&
|
||||
s->y < mainpic->height && s->y + second->height >= 0) {
|
||||
ThreadData td;
|
||||
|
||||
td.dst = mainpic;
|
||||
td.src = second;
|
||||
ctx->internal->execute(ctx, s->blend_slice, &td, NULL, FFMIN(FFMIN(mainpic->height - s->y, second->height),
|
||||
ctx->internal->execute(ctx, s->blend_slice, &td, NULL, FFMIN(FFMAX(1, FFMIN3(s->y + second->height, FFMIN(second->height, mainpic->height), mainpic->height - s->y)),
|
||||
ff_filter_get_nb_threads(ctx)));
|
||||
}
|
||||
return ff_filter_frame(ctx->outputs[0], mainpic);
|
||||
|
||||
@@ -98,12 +98,12 @@ static const struct LumaCoefficients luma_coefficients[AVCOL_SPC_NB] = {
|
||||
[AVCOL_SPC_BT2020_NCL] = { 0.2627, 0.6780, 0.0593 },
|
||||
};
|
||||
|
||||
static struct PrimaryCoefficients primaries_table[AVCOL_PRI_NB] = {
|
||||
static const struct PrimaryCoefficients primaries_table[AVCOL_PRI_NB] = {
|
||||
[AVCOL_PRI_BT709] = { 0.640, 0.330, 0.300, 0.600, 0.150, 0.060 },
|
||||
[AVCOL_PRI_BT2020] = { 0.708, 0.292, 0.170, 0.797, 0.131, 0.046 },
|
||||
};
|
||||
|
||||
static struct WhitepointCoefficients whitepoint_table[AVCOL_PRI_NB] = {
|
||||
static const struct WhitepointCoefficients whitepoint_table[AVCOL_PRI_NB] = {
|
||||
[AVCOL_PRI_BT709] = { 0.3127, 0.3290 },
|
||||
[AVCOL_PRI_BT2020] = { 0.3127, 0.3290 },
|
||||
};
|
||||
|
||||
+9
-187
@@ -22,7 +22,6 @@
|
||||
#include "libavutil/avassert.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/common.h"
|
||||
#include "libavutil/opt.h"
|
||||
#include "libavutil/pixdesc.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
#include "avfilter.h"
|
||||
@@ -254,166 +253,6 @@ static void filter(AVFilterContext *ctx, AVFrame *dstpic,
|
||||
emms_c();
|
||||
}
|
||||
|
||||
static int return_frame(AVFilterContext *ctx, int is_second)
|
||||
{
|
||||
YADIFContext *yadif = ctx->priv;
|
||||
AVFilterLink *link = ctx->outputs[0];
|
||||
int tff, ret;
|
||||
|
||||
if (yadif->parity == -1) {
|
||||
tff = yadif->cur->interlaced_frame ?
|
||||
yadif->cur->top_field_first : 1;
|
||||
} else {
|
||||
tff = yadif->parity ^ 1;
|
||||
}
|
||||
|
||||
if (is_second) {
|
||||
yadif->out = ff_get_video_buffer(link, link->w, link->h);
|
||||
if (!yadif->out)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
av_frame_copy_props(yadif->out, yadif->cur);
|
||||
yadif->out->interlaced_frame = 0;
|
||||
}
|
||||
|
||||
filter(ctx, yadif->out, tff ^ !is_second, tff);
|
||||
|
||||
if (is_second) {
|
||||
int64_t cur_pts = yadif->cur->pts;
|
||||
int64_t next_pts = yadif->next->pts;
|
||||
|
||||
if (next_pts != AV_NOPTS_VALUE && cur_pts != AV_NOPTS_VALUE) {
|
||||
yadif->out->pts = cur_pts + next_pts;
|
||||
} else {
|
||||
yadif->out->pts = AV_NOPTS_VALUE;
|
||||
}
|
||||
}
|
||||
ret = ff_filter_frame(ctx->outputs[0], yadif->out);
|
||||
|
||||
yadif->frame_pending = (yadif->mode&1) && !is_second;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int checkstride(YADIFContext *yadif, const AVFrame *a, const AVFrame *b)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < yadif->csp->nb_components; i++)
|
||||
if (a->linesize[i] != b->linesize[i])
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void fixstride(AVFilterLink *link, AVFrame *f)
|
||||
{
|
||||
AVFrame *dst = ff_default_get_video_buffer(link, f->width, f->height);
|
||||
if(!dst)
|
||||
return;
|
||||
av_frame_copy_props(dst, f);
|
||||
av_image_copy(dst->data, dst->linesize,
|
||||
(const uint8_t **)f->data, f->linesize,
|
||||
dst->format, dst->width, dst->height);
|
||||
av_frame_unref(f);
|
||||
av_frame_move_ref(f, dst);
|
||||
av_frame_free(&dst);
|
||||
}
|
||||
|
||||
static int filter_frame(AVFilterLink *link, AVFrame *frame)
|
||||
{
|
||||
AVFilterContext *ctx = link->dst;
|
||||
YADIFContext *yadif = ctx->priv;
|
||||
|
||||
av_assert0(frame);
|
||||
|
||||
if (yadif->frame_pending)
|
||||
return_frame(ctx, 1);
|
||||
|
||||
if (yadif->prev)
|
||||
av_frame_free(&yadif->prev);
|
||||
yadif->prev = yadif->cur;
|
||||
yadif->cur = yadif->next;
|
||||
yadif->next = frame;
|
||||
|
||||
if (!yadif->cur &&
|
||||
!(yadif->cur = av_frame_clone(yadif->next)))
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
if (checkstride(yadif, yadif->next, yadif->cur)) {
|
||||
av_log(ctx, AV_LOG_VERBOSE, "Reallocating frame due to differing stride\n");
|
||||
fixstride(link, yadif->next);
|
||||
}
|
||||
if (checkstride(yadif, yadif->next, yadif->cur))
|
||||
fixstride(link, yadif->cur);
|
||||
if (yadif->prev && checkstride(yadif, yadif->next, yadif->prev))
|
||||
fixstride(link, yadif->prev);
|
||||
if (checkstride(yadif, yadif->next, yadif->cur) || (yadif->prev && checkstride(yadif, yadif->next, yadif->prev))) {
|
||||
av_log(ctx, AV_LOG_ERROR, "Failed to reallocate frame\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!yadif->prev)
|
||||
return 0;
|
||||
|
||||
if ((yadif->deint && !yadif->cur->interlaced_frame) ||
|
||||
ctx->is_disabled ||
|
||||
(yadif->deint && !yadif->prev->interlaced_frame && yadif->prev->repeat_pict) ||
|
||||
(yadif->deint && !yadif->next->interlaced_frame && yadif->next->repeat_pict)
|
||||
) {
|
||||
yadif->out = av_frame_clone(yadif->cur);
|
||||
if (!yadif->out)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
av_frame_free(&yadif->prev);
|
||||
if (yadif->out->pts != AV_NOPTS_VALUE)
|
||||
yadif->out->pts *= 2;
|
||||
return ff_filter_frame(ctx->outputs[0], yadif->out);
|
||||
}
|
||||
|
||||
yadif->out = ff_get_video_buffer(ctx->outputs[0], link->w, link->h);
|
||||
if (!yadif->out)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
av_frame_copy_props(yadif->out, yadif->cur);
|
||||
yadif->out->interlaced_frame = 0;
|
||||
|
||||
if (yadif->out->pts != AV_NOPTS_VALUE)
|
||||
yadif->out->pts *= 2;
|
||||
|
||||
return return_frame(ctx, 0);
|
||||
}
|
||||
|
||||
static int request_frame(AVFilterLink *link)
|
||||
{
|
||||
AVFilterContext *ctx = link->src;
|
||||
YADIFContext *yadif = ctx->priv;
|
||||
int ret;
|
||||
|
||||
if (yadif->frame_pending) {
|
||||
return_frame(ctx, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (yadif->eof)
|
||||
return AVERROR_EOF;
|
||||
|
||||
ret = ff_request_frame(ctx->inputs[0]);
|
||||
|
||||
if (ret == AVERROR_EOF && yadif->cur) {
|
||||
AVFrame *next = av_frame_clone(yadif->next);
|
||||
|
||||
if (!next)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
next->pts = yadif->next->pts * 2 - yadif->cur->pts;
|
||||
|
||||
filter_frame(ctx->inputs[0], next);
|
||||
yadif->eof = 1;
|
||||
} else if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static av_cold void uninit(AVFilterContext *ctx)
|
||||
{
|
||||
YADIFContext *yadif = ctx->priv;
|
||||
@@ -492,6 +331,7 @@ static int config_props(AVFilterLink *link)
|
||||
}
|
||||
|
||||
s->csp = av_pix_fmt_desc_get(link->format);
|
||||
s->filter = filter;
|
||||
if (s->csp->comp[0].depth > 8) {
|
||||
s->filter_line = filter_line_c_16bit;
|
||||
s->filter_edges = filter_edges_16bit;
|
||||
@@ -507,37 +347,19 @@ static int config_props(AVFilterLink *link)
|
||||
}
|
||||
|
||||
|
||||
#define OFFSET(x) offsetof(YADIFContext, x)
|
||||
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
|
||||
|
||||
#define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, INT_MIN, INT_MAX, FLAGS, unit }
|
||||
|
||||
static const AVOption yadif_options[] = {
|
||||
{ "mode", "specify the interlacing mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=YADIF_MODE_SEND_FRAME}, 0, 3, FLAGS, "mode"},
|
||||
CONST("send_frame", "send one frame for each frame", YADIF_MODE_SEND_FRAME, "mode"),
|
||||
CONST("send_field", "send one frame for each field", YADIF_MODE_SEND_FIELD, "mode"),
|
||||
CONST("send_frame_nospatial", "send one frame for each frame, but skip spatial interlacing check", YADIF_MODE_SEND_FRAME_NOSPATIAL, "mode"),
|
||||
CONST("send_field_nospatial", "send one frame for each field, but skip spatial interlacing check", YADIF_MODE_SEND_FIELD_NOSPATIAL, "mode"),
|
||||
|
||||
{ "parity", "specify the assumed picture field parity", OFFSET(parity), AV_OPT_TYPE_INT, {.i64=YADIF_PARITY_AUTO}, -1, 1, FLAGS, "parity" },
|
||||
CONST("tff", "assume top field first", YADIF_PARITY_TFF, "parity"),
|
||||
CONST("bff", "assume bottom field first", YADIF_PARITY_BFF, "parity"),
|
||||
CONST("auto", "auto detect parity", YADIF_PARITY_AUTO, "parity"),
|
||||
|
||||
{ "deint", "specify which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=YADIF_DEINT_ALL}, 0, 1, FLAGS, "deint" },
|
||||
CONST("all", "deinterlace all frames", YADIF_DEINT_ALL, "deint"),
|
||||
CONST("interlaced", "only deinterlace frames marked as interlaced", YADIF_DEINT_INTERLACED, "deint"),
|
||||
|
||||
{ NULL }
|
||||
static const AVClass yadif_class = {
|
||||
.class_name = "yadif",
|
||||
.item_name = av_default_item_name,
|
||||
.option = ff_yadif_options,
|
||||
.version = LIBAVUTIL_VERSION_INT,
|
||||
.category = AV_CLASS_CATEGORY_FILTER,
|
||||
};
|
||||
|
||||
AVFILTER_DEFINE_CLASS(yadif);
|
||||
|
||||
static const AVFilterPad avfilter_vf_yadif_inputs[] = {
|
||||
{
|
||||
.name = "default",
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.filter_frame = filter_frame,
|
||||
.filter_frame = ff_yadif_filter_frame,
|
||||
},
|
||||
{ NULL }
|
||||
};
|
||||
@@ -546,7 +368,7 @@ static const AVFilterPad avfilter_vf_yadif_outputs[] = {
|
||||
{
|
||||
.name = "default",
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.request_frame = request_frame,
|
||||
.request_frame = ff_yadif_request_frame,
|
||||
.config_props = config_props,
|
||||
},
|
||||
{ NULL }
|
||||
|
||||
@@ -0,0 +1,426 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Philip Langdale <philipl@overt.org>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <cuda.h>
|
||||
#include "libavutil/avassert.h"
|
||||
#include "libavutil/hwcontext_cuda.h"
|
||||
#include "internal.h"
|
||||
#include "yadif.h"
|
||||
|
||||
extern char vf_yadif_cuda_ptx[];
|
||||
|
||||
typedef struct DeintCUDAContext {
|
||||
YADIFContext yadif;
|
||||
|
||||
AVCUDADeviceContext *hwctx;
|
||||
AVBufferRef *device_ref;
|
||||
AVBufferRef *input_frames_ref;
|
||||
AVHWFramesContext *input_frames;
|
||||
|
||||
CUcontext cu_ctx;
|
||||
CUstream stream;
|
||||
CUmodule cu_module;
|
||||
CUfunction cu_func_uchar;
|
||||
CUfunction cu_func_uchar2;
|
||||
CUfunction cu_func_ushort;
|
||||
CUfunction cu_func_ushort2;
|
||||
} DeintCUDAContext;
|
||||
|
||||
#define DIV_UP(a, b) ( ((a) + (b) - 1) / (b) )
|
||||
#define ALIGN_UP(a, b) (((a) + (b) - 1) & ~((b) - 1))
|
||||
#define BLOCKX 32
|
||||
#define BLOCKY 16
|
||||
|
||||
static int check_cu(AVFilterContext *avctx, CUresult err, const char *func)
|
||||
{
|
||||
const char *err_name;
|
||||
const char *err_string;
|
||||
|
||||
av_log(avctx, AV_LOG_TRACE, "Calling %s\n", func);
|
||||
|
||||
if (err == CUDA_SUCCESS)
|
||||
return 0;
|
||||
|
||||
cuGetErrorName(err, &err_name);
|
||||
cuGetErrorString(err, &err_string);
|
||||
|
||||
av_log(avctx, AV_LOG_ERROR, "%s failed", func);
|
||||
if (err_name && err_string)
|
||||
av_log(avctx, AV_LOG_ERROR, " -> %s: %s", err_name, err_string);
|
||||
av_log(avctx, AV_LOG_ERROR, "\n");
|
||||
|
||||
return AVERROR_EXTERNAL;
|
||||
}
|
||||
|
||||
#define CHECK_CU(x) check_cu(ctx, (x), #x)
|
||||
|
||||
static CUresult call_kernel(AVFilterContext *ctx, CUfunction func,
|
||||
CUdeviceptr prev, CUdeviceptr cur, CUdeviceptr next,
|
||||
CUarray_format format, int channels,
|
||||
int src_width, // Width is pixels per channel
|
||||
int src_height, // Height is pixels per channel
|
||||
int src_pitch, // Pitch is bytes
|
||||
CUdeviceptr dst,
|
||||
int dst_width, // Width is pixels per channel
|
||||
int dst_height, // Height is pixels per channel
|
||||
int dst_pitch, // Pitch is pixels per channel
|
||||
int parity, int tff)
|
||||
{
|
||||
DeintCUDAContext *s = ctx->priv;
|
||||
CUtexObject tex_prev = 0, tex_cur = 0, tex_next = 0;
|
||||
CUresult err;
|
||||
int skip_spatial_check = s->yadif.mode&2;
|
||||
|
||||
void *args[] = { &dst, &tex_prev, &tex_cur, &tex_next,
|
||||
&dst_width, &dst_height, &dst_pitch,
|
||||
&src_width, &src_height, &parity, &tff,
|
||||
&skip_spatial_check };
|
||||
|
||||
CUDA_TEXTURE_DESC tex_desc = {
|
||||
.filterMode = CU_TR_FILTER_MODE_POINT,
|
||||
.flags = CU_TRSF_READ_AS_INTEGER,
|
||||
};
|
||||
|
||||
CUDA_RESOURCE_DESC res_desc = {
|
||||
.resType = CU_RESOURCE_TYPE_PITCH2D,
|
||||
.res.pitch2D.format = format,
|
||||
.res.pitch2D.numChannels = channels,
|
||||
.res.pitch2D.width = src_width,
|
||||
.res.pitch2D.height = src_height,
|
||||
.res.pitch2D.pitchInBytes = src_pitch,
|
||||
};
|
||||
|
||||
res_desc.res.pitch2D.devPtr = (CUdeviceptr)prev;
|
||||
err = CHECK_CU(cuTexObjectCreate(&tex_prev, &res_desc, &tex_desc, NULL));
|
||||
if (err != CUDA_SUCCESS) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
res_desc.res.pitch2D.devPtr = (CUdeviceptr)cur;
|
||||
err = CHECK_CU(cuTexObjectCreate(&tex_cur, &res_desc, &tex_desc, NULL));
|
||||
if (err != CUDA_SUCCESS) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
res_desc.res.pitch2D.devPtr = (CUdeviceptr)next;
|
||||
err = CHECK_CU(cuTexObjectCreate(&tex_next, &res_desc, &tex_desc, NULL));
|
||||
if (err != CUDA_SUCCESS) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
err = CHECK_CU(cuLaunchKernel(func,
|
||||
DIV_UP(dst_width, BLOCKX), DIV_UP(dst_height, BLOCKY), 1,
|
||||
BLOCKX, BLOCKY, 1,
|
||||
0, s->stream, args, NULL));
|
||||
|
||||
exit:
|
||||
if (tex_prev)
|
||||
CHECK_CU(cuTexObjectDestroy(tex_prev));
|
||||
if (tex_cur)
|
||||
CHECK_CU(cuTexObjectDestroy(tex_cur));
|
||||
if (tex_next)
|
||||
CHECK_CU(cuTexObjectDestroy(tex_next));
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static void filter(AVFilterContext *ctx, AVFrame *dst,
|
||||
int parity, int tff)
|
||||
{
|
||||
DeintCUDAContext *s = ctx->priv;
|
||||
YADIFContext *y = &s->yadif;
|
||||
CUcontext dummy;
|
||||
CUresult err;
|
||||
int i;
|
||||
|
||||
err = CHECK_CU(cuCtxPushCurrent(s->cu_ctx));
|
||||
if (err != CUDA_SUCCESS) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
for (i = 0; i < y->csp->nb_components; i++) {
|
||||
CUfunction func;
|
||||
CUarray_format format;
|
||||
int pixel_size, channels;
|
||||
const AVComponentDescriptor *comp = &y->csp->comp[i];
|
||||
|
||||
if (comp->plane < i) {
|
||||
// We process planes as a whole, so don't reprocess
|
||||
// them for additional components
|
||||
continue;
|
||||
}
|
||||
|
||||
pixel_size = (comp->depth + comp->shift) / 8;
|
||||
channels = comp->step / pixel_size;
|
||||
if (pixel_size > 2 || channels > 2) {
|
||||
av_log(ctx, AV_LOG_ERROR, "Unsupported pixel format: %s\n", y->csp->name);
|
||||
goto exit;
|
||||
}
|
||||
switch (pixel_size) {
|
||||
case 1:
|
||||
func = channels == 1 ? s->cu_func_uchar : s->cu_func_uchar2;
|
||||
format = CU_AD_FORMAT_UNSIGNED_INT8;
|
||||
break;
|
||||
case 2:
|
||||
func = channels == 1 ? s->cu_func_ushort : s->cu_func_ushort2;
|
||||
format = CU_AD_FORMAT_UNSIGNED_INT16;
|
||||
break;
|
||||
default:
|
||||
av_log(ctx, AV_LOG_ERROR, "Unsupported pixel format: %s\n", y->csp->name);
|
||||
goto exit;
|
||||
}
|
||||
av_log(ctx, AV_LOG_TRACE,
|
||||
"Deinterlacing plane %d: pixel_size: %d channels: %d\n",
|
||||
comp->plane, pixel_size, channels);
|
||||
call_kernel(ctx, func,
|
||||
(CUdeviceptr)y->prev->data[i],
|
||||
(CUdeviceptr)y->cur->data[i],
|
||||
(CUdeviceptr)y->next->data[i],
|
||||
format, channels,
|
||||
AV_CEIL_RSHIFT(y->cur->width, i ? y->csp->log2_chroma_w : 0),
|
||||
AV_CEIL_RSHIFT(y->cur->height, i ? y->csp->log2_chroma_h : 0),
|
||||
y->cur->linesize[i],
|
||||
(CUdeviceptr)dst->data[i],
|
||||
AV_CEIL_RSHIFT(dst->width, i ? y->csp->log2_chroma_w : 0),
|
||||
AV_CEIL_RSHIFT(dst->height, i ? y->csp->log2_chroma_h : 0),
|
||||
dst->linesize[i] / comp->step,
|
||||
parity, tff);
|
||||
}
|
||||
|
||||
err = CHECK_CU(cuStreamSynchronize(s->stream));
|
||||
if (err != CUDA_SUCCESS) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
exit:
|
||||
CHECK_CU(cuCtxPopCurrent(&dummy));
|
||||
return;
|
||||
}
|
||||
|
||||
static av_cold void deint_cuda_uninit(AVFilterContext *ctx)
|
||||
{
|
||||
CUcontext dummy;
|
||||
DeintCUDAContext *s = ctx->priv;
|
||||
YADIFContext *y = &s->yadif;
|
||||
|
||||
if (s->cu_module) {
|
||||
CHECK_CU(cuCtxPushCurrent(s->cu_ctx));
|
||||
CHECK_CU(cuModuleUnload(s->cu_module));
|
||||
CHECK_CU(cuCtxPopCurrent(&dummy));
|
||||
}
|
||||
|
||||
av_frame_free(&y->prev);
|
||||
av_frame_free(&y->cur);
|
||||
av_frame_free(&y->next);
|
||||
|
||||
av_buffer_unref(&s->device_ref);
|
||||
s->hwctx = NULL;
|
||||
av_buffer_unref(&s->input_frames_ref);
|
||||
s->input_frames = NULL;
|
||||
}
|
||||
|
||||
static int deint_cuda_query_formats(AVFilterContext *ctx)
|
||||
{
|
||||
enum AVPixelFormat pix_fmts[] = {
|
||||
AV_PIX_FMT_CUDA, AV_PIX_FMT_NONE,
|
||||
};
|
||||
int ret;
|
||||
|
||||
if ((ret = ff_formats_ref(ff_make_format_list(pix_fmts),
|
||||
&ctx->inputs[0]->out_formats)) < 0)
|
||||
return ret;
|
||||
if ((ret = ff_formats_ref(ff_make_format_list(pix_fmts),
|
||||
&ctx->outputs[0]->in_formats)) < 0)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int config_input(AVFilterLink *inlink)
|
||||
{
|
||||
AVFilterContext *ctx = inlink->dst;
|
||||
DeintCUDAContext *s = ctx->priv;
|
||||
|
||||
if (!inlink->hw_frames_ctx) {
|
||||
av_log(ctx, AV_LOG_ERROR, "A hardware frames reference is "
|
||||
"required to associate the processing device.\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
s->input_frames_ref = av_buffer_ref(inlink->hw_frames_ctx);
|
||||
if (!s->input_frames_ref) {
|
||||
av_log(ctx, AV_LOG_ERROR, "A input frames reference create "
|
||||
"failed.\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
s->input_frames = (AVHWFramesContext*)s->input_frames_ref->data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int config_output(AVFilterLink *link)
|
||||
{
|
||||
AVHWFramesContext *output_frames;
|
||||
AVFilterContext *ctx = link->src;
|
||||
DeintCUDAContext *s = ctx->priv;
|
||||
YADIFContext *y = &s->yadif;
|
||||
int ret = 0;
|
||||
CUcontext dummy;
|
||||
CUresult err;
|
||||
|
||||
av_assert0(s->input_frames);
|
||||
s->device_ref = av_buffer_ref(s->input_frames->device_ref);
|
||||
if (!s->device_ref) {
|
||||
av_log(ctx, AV_LOG_ERROR, "A device reference create "
|
||||
"failed.\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
s->hwctx = ((AVHWDeviceContext*)s->device_ref->data)->hwctx;
|
||||
s->cu_ctx = s->hwctx->cuda_ctx;
|
||||
s->stream = s->hwctx->stream;
|
||||
|
||||
link->hw_frames_ctx = av_hwframe_ctx_alloc(s->device_ref);
|
||||
if (!link->hw_frames_ctx) {
|
||||
av_log(ctx, AV_LOG_ERROR, "Failed to create HW frame context "
|
||||
"for output.\n");
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
output_frames = (AVHWFramesContext*)link->hw_frames_ctx->data;
|
||||
|
||||
output_frames->format = AV_PIX_FMT_CUDA;
|
||||
output_frames->sw_format = s->input_frames->sw_format;
|
||||
output_frames->width = ctx->inputs[0]->w;
|
||||
output_frames->height = ctx->inputs[0]->h;
|
||||
|
||||
output_frames->initial_pool_size = 4;
|
||||
|
||||
ret = ff_filter_init_hw_frames(ctx, link, 10);
|
||||
if (ret < 0)
|
||||
goto exit;
|
||||
|
||||
ret = av_hwframe_ctx_init(link->hw_frames_ctx);
|
||||
if (ret < 0) {
|
||||
av_log(ctx, AV_LOG_ERROR, "Failed to initialise CUDA frame "
|
||||
"context for output: %d\n", ret);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
link->time_base.num = ctx->inputs[0]->time_base.num;
|
||||
link->time_base.den = ctx->inputs[0]->time_base.den * 2;
|
||||
link->w = ctx->inputs[0]->w;
|
||||
link->h = ctx->inputs[0]->h;
|
||||
|
||||
if(y->mode & 1)
|
||||
link->frame_rate = av_mul_q(ctx->inputs[0]->frame_rate,
|
||||
(AVRational){2, 1});
|
||||
|
||||
if (link->w < 3 || link->h < 3) {
|
||||
av_log(ctx, AV_LOG_ERROR, "Video of less than 3 columns or lines is not supported\n");
|
||||
ret = AVERROR(EINVAL);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
y->csp = av_pix_fmt_desc_get(output_frames->sw_format);
|
||||
y->filter = filter;
|
||||
|
||||
err = CHECK_CU(cuCtxPushCurrent(s->cu_ctx));
|
||||
if (err != CUDA_SUCCESS) {
|
||||
ret = AVERROR_EXTERNAL;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
err = CHECK_CU(cuModuleLoadData(&s->cu_module, vf_yadif_cuda_ptx));
|
||||
if (err != CUDA_SUCCESS) {
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
err = CHECK_CU(cuModuleGetFunction(&s->cu_func_uchar, s->cu_module, "yadif_uchar"));
|
||||
if (err != CUDA_SUCCESS) {
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
err = CHECK_CU(cuModuleGetFunction(&s->cu_func_uchar2, s->cu_module, "yadif_uchar2"));
|
||||
if (err != CUDA_SUCCESS) {
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
err= CHECK_CU(cuModuleGetFunction(&s->cu_func_ushort, s->cu_module, "yadif_ushort"));
|
||||
if (err != CUDA_SUCCESS) {
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
err = CHECK_CU(cuModuleGetFunction(&s->cu_func_ushort2, s->cu_module, "yadif_ushort2"));
|
||||
if (err != CUDA_SUCCESS) {
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
exit:
|
||||
CHECK_CU(cuCtxPopCurrent(&dummy));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const AVClass yadif_cuda_class = {
|
||||
.class_name = "yadif_cuda",
|
||||
.item_name = av_default_item_name,
|
||||
.option = ff_yadif_options,
|
||||
.version = LIBAVUTIL_VERSION_INT,
|
||||
.category = AV_CLASS_CATEGORY_FILTER,
|
||||
};
|
||||
|
||||
static const AVFilterPad deint_cuda_inputs[] = {
|
||||
{
|
||||
.name = "default",
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.filter_frame = ff_yadif_filter_frame,
|
||||
.config_props = config_input,
|
||||
},
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static const AVFilterPad deint_cuda_outputs[] = {
|
||||
{
|
||||
.name = "default",
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.request_frame = ff_yadif_request_frame,
|
||||
.config_props = config_output,
|
||||
},
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
AVFilter ff_vf_yadif_cuda = {
|
||||
.name = "yadif_cuda",
|
||||
.description = NULL_IF_CONFIG_SMALL("Deinterlace CUDA frames"),
|
||||
.priv_size = sizeof(DeintCUDAContext),
|
||||
.priv_class = &yadif_cuda_class,
|
||||
.uninit = deint_cuda_uninit,
|
||||
.query_formats = deint_cuda_query_formats,
|
||||
.inputs = deint_cuda_inputs,
|
||||
.outputs = deint_cuda_outputs,
|
||||
.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,
|
||||
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
|
||||
};
|
||||
@@ -0,0 +1,299 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Philip Langdale <philipl@overt.org>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
__inline__ __device__ T spatial_predictor(T a, T b, T c, T d, T e, T f, T g,
|
||||
T h, T i, T j, T k, T l, T m, T n)
|
||||
{
|
||||
int spatial_pred = (d + k)/2;
|
||||
int spatial_score = abs(c - j) + abs(d - k) + abs(e - l);
|
||||
|
||||
int score = abs(b - k) + abs(c - l) + abs(d - m);
|
||||
if (score < spatial_score) {
|
||||
spatial_pred = (c + l)/2;
|
||||
spatial_score = score;
|
||||
score = abs(a - l) + abs(b - m) + abs(c - n);
|
||||
if (score < spatial_score) {
|
||||
spatial_pred = (b + m)/2;
|
||||
spatial_score = score;
|
||||
}
|
||||
}
|
||||
score = abs(d - i) + abs(e - j) + abs(f - k);
|
||||
if (score < spatial_score) {
|
||||
spatial_pred = (e + j)/2;
|
||||
spatial_score = score;
|
||||
score = abs(e - h) + abs(f - i) + abs(g - j);
|
||||
if (score < spatial_score) {
|
||||
spatial_pred = (f + i)/2;
|
||||
spatial_score = score;
|
||||
}
|
||||
}
|
||||
return spatial_pred;
|
||||
}
|
||||
|
||||
__inline__ __device__ int max3(int a, int b, int c)
|
||||
{
|
||||
int x = max(a, b);
|
||||
return max(x, c);
|
||||
}
|
||||
|
||||
__inline__ __device__ int min3(int a, int b, int c)
|
||||
{
|
||||
int x = min(a, b);
|
||||
return min(x, c);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
__inline__ __device__ T temporal_predictor(T A, T B, T C, T D, T E, T F,
|
||||
T G, T H, T I, T J, T K, T L,
|
||||
T spatial_pred, bool skip_check)
|
||||
{
|
||||
int p0 = (C + H) / 2;
|
||||
int p1 = F;
|
||||
int p2 = (D + I) / 2;
|
||||
int p3 = G;
|
||||
int p4 = (E + J) / 2;
|
||||
|
||||
int tdiff0 = abs(D - I);
|
||||
int tdiff1 = (abs(A - F) + abs(B - G)) / 2;
|
||||
int tdiff2 = (abs(K - F) + abs(G - L)) / 2;
|
||||
|
||||
int diff = max3(tdiff0, tdiff1, tdiff2);
|
||||
|
||||
if (!skip_check) {
|
||||
int maxi = max3(p2 - p3, p2 - p1, min(p0 - p1, p4 - p3));
|
||||
int mini = min3(p2 - p3, p2 - p1, max(p0 - p1, p4 - p3));
|
||||
diff = max3(diff, mini, -maxi);
|
||||
}
|
||||
|
||||
if (spatial_pred > p2 + diff) {
|
||||
spatial_pred = p2 + diff;
|
||||
}
|
||||
if (spatial_pred < p2 - diff) {
|
||||
spatial_pred = p2 - diff;
|
||||
}
|
||||
|
||||
return spatial_pred;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
__inline__ __device__ void yadif_single(T *dst,
|
||||
cudaTextureObject_t prev,
|
||||
cudaTextureObject_t cur,
|
||||
cudaTextureObject_t next,
|
||||
int dst_width, int dst_height, int dst_pitch,
|
||||
int src_width, int src_height,
|
||||
int parity, int tff, bool skip_spatial_check)
|
||||
{
|
||||
// Identify location
|
||||
int xo = blockIdx.x * blockDim.x + threadIdx.x;
|
||||
int yo = blockIdx.y * blockDim.y + threadIdx.y;
|
||||
|
||||
if (xo >= dst_width || yo >= dst_height) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't modify the primary field
|
||||
if (yo % 2 == parity) {
|
||||
dst[yo*dst_pitch+xo] = tex2D<T>(cur, xo, yo);
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate spatial prediction
|
||||
T a = tex2D<T>(cur, xo - 3, yo - 1);
|
||||
T b = tex2D<T>(cur, xo - 2, yo - 1);
|
||||
T c = tex2D<T>(cur, xo - 1, yo - 1);
|
||||
T d = tex2D<T>(cur, xo - 0, yo - 1);
|
||||
T e = tex2D<T>(cur, xo + 1, yo - 1);
|
||||
T f = tex2D<T>(cur, xo + 2, yo - 1);
|
||||
T g = tex2D<T>(cur, xo + 3, yo - 1);
|
||||
|
||||
T h = tex2D<T>(cur, xo - 3, yo + 1);
|
||||
T i = tex2D<T>(cur, xo - 2, yo + 1);
|
||||
T j = tex2D<T>(cur, xo - 1, yo + 1);
|
||||
T k = tex2D<T>(cur, xo - 0, yo + 1);
|
||||
T l = tex2D<T>(cur, xo + 1, yo + 1);
|
||||
T m = tex2D<T>(cur, xo + 2, yo + 1);
|
||||
T n = tex2D<T>(cur, xo + 3, yo + 1);
|
||||
|
||||
T spatial_pred =
|
||||
spatial_predictor(a, b, c, d, e, f, g, h, i, j, k, l, m, n);
|
||||
|
||||
// Calculate temporal prediction
|
||||
int is_second_field = !(parity ^ tff);
|
||||
|
||||
cudaTextureObject_t prev2 = prev;
|
||||
cudaTextureObject_t prev1 = is_second_field ? cur : prev;
|
||||
cudaTextureObject_t next1 = is_second_field ? next : cur;
|
||||
cudaTextureObject_t next2 = next;
|
||||
|
||||
T A = tex2D<T>(prev2, xo, yo - 1);
|
||||
T B = tex2D<T>(prev2, xo, yo + 1);
|
||||
T C = tex2D<T>(prev1, xo, yo - 2);
|
||||
T D = tex2D<T>(prev1, xo, yo + 0);
|
||||
T E = tex2D<T>(prev1, xo, yo + 2);
|
||||
T F = tex2D<T>(cur, xo, yo - 1);
|
||||
T G = tex2D<T>(cur, xo, yo + 1);
|
||||
T H = tex2D<T>(next1, xo, yo - 2);
|
||||
T I = tex2D<T>(next1, xo, yo + 0);
|
||||
T J = tex2D<T>(next1, xo, yo + 2);
|
||||
T K = tex2D<T>(next2, xo, yo - 1);
|
||||
T L = tex2D<T>(next2, xo, yo + 1);
|
||||
|
||||
spatial_pred = temporal_predictor(A, B, C, D, E, F, G, H, I, J, K, L,
|
||||
spatial_pred, skip_spatial_check);
|
||||
|
||||
dst[yo*dst_pitch+xo] = spatial_pred;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
__inline__ __device__ void yadif_double(T *dst,
|
||||
cudaTextureObject_t prev,
|
||||
cudaTextureObject_t cur,
|
||||
cudaTextureObject_t next,
|
||||
int dst_width, int dst_height, int dst_pitch,
|
||||
int src_width, int src_height,
|
||||
int parity, int tff, bool skip_spatial_check)
|
||||
{
|
||||
int xo = blockIdx.x * blockDim.x + threadIdx.x;
|
||||
int yo = blockIdx.y * blockDim.y + threadIdx.y;
|
||||
|
||||
if (xo >= dst_width || yo >= dst_height) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (yo % 2 == parity) {
|
||||
// Don't modify the primary field
|
||||
dst[yo*dst_pitch+xo] = tex2D<T>(cur, xo, yo);
|
||||
return;
|
||||
}
|
||||
|
||||
T a = tex2D<T>(cur, xo - 3, yo - 1);
|
||||
T b = tex2D<T>(cur, xo - 2, yo - 1);
|
||||
T c = tex2D<T>(cur, xo - 1, yo - 1);
|
||||
T d = tex2D<T>(cur, xo - 0, yo - 1);
|
||||
T e = tex2D<T>(cur, xo + 1, yo - 1);
|
||||
T f = tex2D<T>(cur, xo + 2, yo - 1);
|
||||
T g = tex2D<T>(cur, xo + 3, yo - 1);
|
||||
|
||||
T h = tex2D<T>(cur, xo - 3, yo + 1);
|
||||
T i = tex2D<T>(cur, xo - 2, yo + 1);
|
||||
T j = tex2D<T>(cur, xo - 1, yo + 1);
|
||||
T k = tex2D<T>(cur, xo - 0, yo + 1);
|
||||
T l = tex2D<T>(cur, xo + 1, yo + 1);
|
||||
T m = tex2D<T>(cur, xo + 2, yo + 1);
|
||||
T n = tex2D<T>(cur, xo + 3, yo + 1);
|
||||
|
||||
T spatial_pred;
|
||||
spatial_pred.x =
|
||||
spatial_predictor(a.x, b.x, c.x, d.x, e.x, f.x, g.x, h.x, i.x, j.x, k.x, l.x, m.x, n.x);
|
||||
spatial_pred.y =
|
||||
spatial_predictor(a.y, b.y, c.y, d.y, e.y, f.y, g.y, h.y, i.y, j.y, k.y, l.y, m.y, n.y);
|
||||
|
||||
// Calculate temporal prediction
|
||||
int is_second_field = !(parity ^ tff);
|
||||
|
||||
cudaTextureObject_t prev2 = prev;
|
||||
cudaTextureObject_t prev1 = is_second_field ? cur : prev;
|
||||
cudaTextureObject_t next1 = is_second_field ? next : cur;
|
||||
cudaTextureObject_t next2 = next;
|
||||
|
||||
T A = tex2D<T>(prev2, xo, yo - 1);
|
||||
T B = tex2D<T>(prev2, xo, yo + 1);
|
||||
T C = tex2D<T>(prev1, xo, yo - 2);
|
||||
T D = tex2D<T>(prev1, xo, yo + 0);
|
||||
T E = tex2D<T>(prev1, xo, yo + 2);
|
||||
T F = tex2D<T>(cur, xo, yo - 1);
|
||||
T G = tex2D<T>(cur, xo, yo + 1);
|
||||
T H = tex2D<T>(next1, xo, yo - 2);
|
||||
T I = tex2D<T>(next1, xo, yo + 0);
|
||||
T J = tex2D<T>(next1, xo, yo + 2);
|
||||
T K = tex2D<T>(next2, xo, yo - 1);
|
||||
T L = tex2D<T>(next2, xo, yo + 1);
|
||||
|
||||
spatial_pred.x =
|
||||
temporal_predictor(A.x, B.x, C.x, D.x, E.x, F.x, G.x, H.x, I.x, J.x, K.x, L.x,
|
||||
spatial_pred.x, skip_spatial_check);
|
||||
spatial_pred.y =
|
||||
temporal_predictor(A.y, B.y, C.y, D.y, E.y, F.y, G.y, H.y, I.y, J.y, K.y, L.y,
|
||||
spatial_pred.y, skip_spatial_check);
|
||||
|
||||
dst[yo*dst_pitch+xo] = spatial_pred;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
__global__ void yadif_uchar(unsigned char *dst,
|
||||
cudaTextureObject_t prev,
|
||||
cudaTextureObject_t cur,
|
||||
cudaTextureObject_t next,
|
||||
int dst_width, int dst_height, int dst_pitch,
|
||||
int src_width, int src_height,
|
||||
int parity, int tff, bool skip_spatial_check)
|
||||
{
|
||||
yadif_single(dst, prev, cur, next,
|
||||
dst_width, dst_height, dst_pitch,
|
||||
src_width, src_height,
|
||||
parity, tff, skip_spatial_check);
|
||||
}
|
||||
|
||||
__global__ void yadif_ushort(unsigned short *dst,
|
||||
cudaTextureObject_t prev,
|
||||
cudaTextureObject_t cur,
|
||||
cudaTextureObject_t next,
|
||||
int dst_width, int dst_height, int dst_pitch,
|
||||
int src_width, int src_height,
|
||||
int parity, int tff, bool skip_spatial_check)
|
||||
{
|
||||
yadif_single(dst, prev, cur, next,
|
||||
dst_width, dst_height, dst_pitch,
|
||||
src_width, src_height,
|
||||
parity, tff, skip_spatial_check);
|
||||
}
|
||||
|
||||
__global__ void yadif_uchar2(uchar2 *dst,
|
||||
cudaTextureObject_t prev,
|
||||
cudaTextureObject_t cur,
|
||||
cudaTextureObject_t next,
|
||||
int dst_width, int dst_height, int dst_pitch,
|
||||
int src_width, int src_height,
|
||||
int parity, int tff, bool skip_spatial_check)
|
||||
{
|
||||
yadif_double(dst, prev, cur, next,
|
||||
dst_width, dst_height, dst_pitch,
|
||||
src_width, src_height,
|
||||
parity, tff, skip_spatial_check);
|
||||
}
|
||||
|
||||
__global__ void yadif_ushort2(ushort2 *dst,
|
||||
cudaTextureObject_t prev,
|
||||
cudaTextureObject_t cur,
|
||||
cudaTextureObject_t next,
|
||||
int dst_width, int dst_height, int dst_pitch,
|
||||
int src_width, int src_height,
|
||||
int parity, int tff, bool skip_spatial_check)
|
||||
{
|
||||
yadif_double(dst, prev, cur, next,
|
||||
dst_width, dst_height, dst_pitch,
|
||||
src_width, src_height,
|
||||
parity, tff, skip_spatial_check);
|
||||
}
|
||||
|
||||
} /* extern "C" */
|
||||
@@ -19,6 +19,7 @@
|
||||
#ifndef AVFILTER_YADIF_H
|
||||
#define AVFILTER_YADIF_H
|
||||
|
||||
#include "libavutil/opt.h"
|
||||
#include "libavutil/pixdesc.h"
|
||||
#include "avfilter.h"
|
||||
|
||||
@@ -54,6 +55,8 @@ typedef struct YADIFContext {
|
||||
AVFrame *prev;
|
||||
AVFrame *out;
|
||||
|
||||
void (*filter)(AVFilterContext *ctx, AVFrame *dstpic, int parity, int tff);
|
||||
|
||||
/**
|
||||
* Required alignment for filter_line
|
||||
*/
|
||||
@@ -71,4 +74,10 @@ typedef struct YADIFContext {
|
||||
|
||||
void ff_yadif_init_x86(YADIFContext *yadif);
|
||||
|
||||
int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame);
|
||||
|
||||
int ff_yadif_request_frame(AVFilterLink *link);
|
||||
|
||||
extern const AVOption ff_yadif_options[];
|
||||
|
||||
#endif /* AVFILTER_YADIF_H */
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
* Copyright (C) 2006-2011 Michael Niedermayer <michaelni@gmx.at>
|
||||
* 2010 James Darnley <james.darnley@gmail.com>
|
||||
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "libavutil/avassert.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
#include "internal.h"
|
||||
#include "yadif.h"
|
||||
|
||||
static int return_frame(AVFilterContext *ctx, int is_second)
|
||||
{
|
||||
YADIFContext *yadif = ctx->priv;
|
||||
AVFilterLink *link = ctx->outputs[0];
|
||||
int tff, ret;
|
||||
|
||||
if (yadif->parity == -1) {
|
||||
tff = yadif->cur->interlaced_frame ?
|
||||
yadif->cur->top_field_first : 1;
|
||||
} else {
|
||||
tff = yadif->parity ^ 1;
|
||||
}
|
||||
|
||||
if (is_second) {
|
||||
yadif->out = ff_get_video_buffer(link, link->w, link->h);
|
||||
if (!yadif->out)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
av_frame_copy_props(yadif->out, yadif->cur);
|
||||
yadif->out->interlaced_frame = 0;
|
||||
}
|
||||
|
||||
yadif->filter(ctx, yadif->out, tff ^ !is_second, tff);
|
||||
|
||||
if (is_second) {
|
||||
int64_t cur_pts = yadif->cur->pts;
|
||||
int64_t next_pts = yadif->next->pts;
|
||||
|
||||
if (next_pts != AV_NOPTS_VALUE && cur_pts != AV_NOPTS_VALUE) {
|
||||
yadif->out->pts = cur_pts + next_pts;
|
||||
} else {
|
||||
yadif->out->pts = AV_NOPTS_VALUE;
|
||||
}
|
||||
}
|
||||
ret = ff_filter_frame(ctx->outputs[0], yadif->out);
|
||||
|
||||
yadif->frame_pending = (yadif->mode&1) && !is_second;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int checkstride(YADIFContext *yadif, const AVFrame *a, const AVFrame *b)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < yadif->csp->nb_components; i++)
|
||||
if (a->linesize[i] != b->linesize[i])
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void fixstride(AVFilterLink *link, AVFrame *f)
|
||||
{
|
||||
AVFrame *dst = ff_default_get_video_buffer(link, f->width, f->height);
|
||||
if(!dst)
|
||||
return;
|
||||
av_frame_copy_props(dst, f);
|
||||
av_image_copy(dst->data, dst->linesize,
|
||||
(const uint8_t **)f->data, f->linesize,
|
||||
dst->format, dst->width, dst->height);
|
||||
av_frame_unref(f);
|
||||
av_frame_move_ref(f, dst);
|
||||
av_frame_free(&dst);
|
||||
}
|
||||
|
||||
int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame)
|
||||
{
|
||||
AVFilterContext *ctx = link->dst;
|
||||
YADIFContext *yadif = ctx->priv;
|
||||
|
||||
av_assert0(frame);
|
||||
|
||||
if (yadif->frame_pending)
|
||||
return_frame(ctx, 1);
|
||||
|
||||
if (yadif->prev)
|
||||
av_frame_free(&yadif->prev);
|
||||
yadif->prev = yadif->cur;
|
||||
yadif->cur = yadif->next;
|
||||
yadif->next = frame;
|
||||
|
||||
if (!yadif->cur &&
|
||||
!(yadif->cur = av_frame_clone(yadif->next)))
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
if (checkstride(yadif, yadif->next, yadif->cur)) {
|
||||
av_log(ctx, AV_LOG_VERBOSE, "Reallocating frame due to differing stride\n");
|
||||
fixstride(link, yadif->next);
|
||||
}
|
||||
if (checkstride(yadif, yadif->next, yadif->cur))
|
||||
fixstride(link, yadif->cur);
|
||||
if (yadif->prev && checkstride(yadif, yadif->next, yadif->prev))
|
||||
fixstride(link, yadif->prev);
|
||||
if (checkstride(yadif, yadif->next, yadif->cur) || (yadif->prev && checkstride(yadif, yadif->next, yadif->prev))) {
|
||||
av_log(ctx, AV_LOG_ERROR, "Failed to reallocate frame\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!yadif->prev)
|
||||
return 0;
|
||||
|
||||
if ((yadif->deint && !yadif->cur->interlaced_frame) ||
|
||||
ctx->is_disabled ||
|
||||
(yadif->deint && !yadif->prev->interlaced_frame && yadif->prev->repeat_pict) ||
|
||||
(yadif->deint && !yadif->next->interlaced_frame && yadif->next->repeat_pict)
|
||||
) {
|
||||
yadif->out = av_frame_clone(yadif->cur);
|
||||
if (!yadif->out)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
av_frame_free(&yadif->prev);
|
||||
if (yadif->out->pts != AV_NOPTS_VALUE)
|
||||
yadif->out->pts *= 2;
|
||||
return ff_filter_frame(ctx->outputs[0], yadif->out);
|
||||
}
|
||||
|
||||
yadif->out = ff_get_video_buffer(ctx->outputs[0], link->w, link->h);
|
||||
if (!yadif->out)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
av_frame_copy_props(yadif->out, yadif->cur);
|
||||
yadif->out->interlaced_frame = 0;
|
||||
|
||||
if (yadif->out->pts != AV_NOPTS_VALUE)
|
||||
yadif->out->pts *= 2;
|
||||
|
||||
return return_frame(ctx, 0);
|
||||
}
|
||||
|
||||
int ff_yadif_request_frame(AVFilterLink *link)
|
||||
{
|
||||
AVFilterContext *ctx = link->src;
|
||||
YADIFContext *yadif = ctx->priv;
|
||||
int ret;
|
||||
|
||||
if (yadif->frame_pending) {
|
||||
return_frame(ctx, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (yadif->eof)
|
||||
return AVERROR_EOF;
|
||||
|
||||
ret = ff_request_frame(ctx->inputs[0]);
|
||||
|
||||
if (ret == AVERROR_EOF && yadif->cur) {
|
||||
AVFrame *next = av_frame_clone(yadif->next);
|
||||
|
||||
if (!next)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
next->pts = yadif->next->pts * 2 - yadif->cur->pts;
|
||||
|
||||
ff_yadif_filter_frame(ctx->inputs[0], next);
|
||||
yadif->eof = 1;
|
||||
} else if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define OFFSET(x) offsetof(YADIFContext, x)
|
||||
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
|
||||
|
||||
#define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, INT_MIN, INT_MAX, FLAGS, unit }
|
||||
|
||||
const AVOption ff_yadif_options[] = {
|
||||
{ "mode", "specify the interlacing mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=YADIF_MODE_SEND_FRAME}, 0, 3, FLAGS, "mode"},
|
||||
CONST("send_frame", "send one frame for each frame", YADIF_MODE_SEND_FRAME, "mode"),
|
||||
CONST("send_field", "send one frame for each field", YADIF_MODE_SEND_FIELD, "mode"),
|
||||
CONST("send_frame_nospatial", "send one frame for each frame, but skip spatial interlacing check", YADIF_MODE_SEND_FRAME_NOSPATIAL, "mode"),
|
||||
CONST("send_field_nospatial", "send one frame for each field, but skip spatial interlacing check", YADIF_MODE_SEND_FIELD_NOSPATIAL, "mode"),
|
||||
|
||||
{ "parity", "specify the assumed picture field parity", OFFSET(parity), AV_OPT_TYPE_INT, {.i64=YADIF_PARITY_AUTO}, -1, 1, FLAGS, "parity" },
|
||||
CONST("tff", "assume top field first", YADIF_PARITY_TFF, "parity"),
|
||||
CONST("bff", "assume bottom field first", YADIF_PARITY_BFF, "parity"),
|
||||
CONST("auto", "auto detect parity", YADIF_PARITY_AUTO, "parity"),
|
||||
|
||||
{ "deint", "specify which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=YADIF_DEINT_ALL}, 0, 1, FLAGS, "deint" },
|
||||
CONST("all", "deinterlace all frames", YADIF_DEINT_ALL, "deint"),
|
||||
CONST("interlaced", "only deinterlace frames marked as interlaced", YADIF_DEINT_INTERLACED, "deint"),
|
||||
|
||||
{ NULL }
|
||||
};
|
||||
+1
-1
@@ -142,7 +142,7 @@ static int ring_size_of_read_back(RingBuffer *ring)
|
||||
static int ring_drain(RingBuffer *ring, int offset)
|
||||
{
|
||||
av_assert2(offset >= -ring_size_of_read_back(ring));
|
||||
av_assert2(offset <= -ring_size(ring));
|
||||
av_assert2(offset <= ring_size(ring));
|
||||
ring->read_pos += offset;
|
||||
return 0;
|
||||
}
|
||||
|
||||
+4
-3
@@ -389,7 +389,7 @@ static int ftp_file_size(FTPContext *s)
|
||||
static const int size_codes[] = {213, 0};
|
||||
|
||||
snprintf(command, sizeof(command), "SIZE %s\r\n", s->path);
|
||||
if (ftp_send_command(s, command, size_codes, &res) == 213 && res) {
|
||||
if (ftp_send_command(s, command, size_codes, &res) == 213 && res && strlen(res) > 4) {
|
||||
s->filesize = strtoll(&res[4], NULL, 10);
|
||||
} else {
|
||||
s->filesize = -1;
|
||||
@@ -513,7 +513,7 @@ static int ftp_features(FTPContext *s)
|
||||
static const char *feat_command = "FEAT\r\n";
|
||||
static const char *enable_utf8_command = "OPTS UTF8 ON\r\n";
|
||||
static const int feat_codes[] = {211, 0};
|
||||
static const int opts_codes[] = {200, 451, 0};
|
||||
static const int opts_codes[] = {200, 202, 451, 0};
|
||||
|
||||
av_freep(&s->features);
|
||||
if (ftp_send_command(s, feat_command, feat_codes, &s->features) != 211) {
|
||||
@@ -521,7 +521,8 @@ static int ftp_features(FTPContext *s)
|
||||
}
|
||||
|
||||
if (ftp_has_feature(s, "UTF8")) {
|
||||
if (ftp_send_command(s, enable_utf8_command, opts_codes, NULL) == 200)
|
||||
int ret = ftp_send_command(s, enable_utf8_command, opts_codes, NULL);
|
||||
if (ret == 200 || ret == 202)
|
||||
s->utf8 = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -86,6 +86,9 @@ static int gdv_read_header(AVFormatContext *ctx)
|
||||
vst->nb_frames = avio_rl16(pb);
|
||||
|
||||
fps = avio_rl16(pb);
|
||||
if (!fps)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
snd_flags = avio_rl16(pb);
|
||||
if (snd_flags & 1) {
|
||||
ast = avformat_new_stream(ctx, 0);
|
||||
|
||||
+1
-1
@@ -915,7 +915,7 @@ static int process_line(URLContext *h, char *line, int line_count,
|
||||
while (av_isspace(*p))
|
||||
p++;
|
||||
resource = p;
|
||||
while (!av_isspace(*p))
|
||||
while (*p && !av_isspace(*p))
|
||||
p++;
|
||||
*(p++) = '\0';
|
||||
av_log(h, AV_LOG_TRACE, "Requested resource: %s\n", resource);
|
||||
|
||||
+4
-2
@@ -590,7 +590,7 @@ static void read_apic(AVFormatContext *s, AVIOContext *pb, int taglen,
|
||||
int isv34)
|
||||
{
|
||||
int enc, pic_type;
|
||||
char mimetype[64];
|
||||
char mimetype[64] = {0};
|
||||
const CodecMime *mime = ff_id3v2_mime_tags;
|
||||
enum AVCodecID id = AV_CODEC_ID_NONE;
|
||||
ID3v2ExtraMetaAPIC *apic = NULL;
|
||||
@@ -612,7 +612,9 @@ static void read_apic(AVFormatContext *s, AVIOContext *pb, int taglen,
|
||||
if (isv34) {
|
||||
taglen -= avio_get_str(pb, taglen, mimetype, sizeof(mimetype));
|
||||
} else {
|
||||
avio_read(pb, mimetype, 3);
|
||||
if (avio_read(pb, mimetype, 3) < 0)
|
||||
goto fail;
|
||||
|
||||
mimetype[3] = 0;
|
||||
taglen -= 3;
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ typedef struct MOVAtom {
|
||||
struct MOVParseTableEntry;
|
||||
|
||||
typedef struct MOVFragment {
|
||||
int found_tfhd;
|
||||
unsigned track_id;
|
||||
uint64_t base_data_offset;
|
||||
uint64_t moof_offset;
|
||||
|
||||
@@ -97,6 +97,8 @@ static int ivf_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt)
|
||||
|
||||
if (st->codecpar->codec_id == AV_CODEC_ID_VP9)
|
||||
ret = ff_stream_add_bitstream_filter(st, "vp9_superframe", NULL);
|
||||
else if (st->codecpar->codec_id == AV_CODEC_ID_AV1)
|
||||
ret = ff_stream_add_bitstream_filter(st, "av1_metadata", "td=insert");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ static int read_probe_openmpt(AVProbeData *p)
|
||||
} else {
|
||||
/* The file extension is unknown and we have very few data
|
||||
* bytes available. libopenmpt cannot decide anything here,
|
||||
* and returning any score > 0 would result in successfull
|
||||
* and returning any score > 0 would result in successful
|
||||
* probing of random data.
|
||||
*/
|
||||
return 0;
|
||||
|
||||
@@ -3541,7 +3541,7 @@ static int matroska_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
ret = matroska_resync(matroska, pos);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int matroska_read_seek(AVFormatContext *s, int stream_index,
|
||||
|
||||
+49
-16
@@ -1270,7 +1270,7 @@ static int64_t get_frag_time(MOVFragmentIndex *frag_index,
|
||||
static int search_frag_timestamp(MOVFragmentIndex *frag_index,
|
||||
AVStream *st, int64_t timestamp)
|
||||
{
|
||||
int a, b, m;
|
||||
int a, b, m, m0;
|
||||
int64_t frag_time;
|
||||
int id = -1;
|
||||
|
||||
@@ -1286,15 +1286,18 @@ static int search_frag_timestamp(MOVFragmentIndex *frag_index,
|
||||
b = frag_index->nb_items;
|
||||
|
||||
while (b - a > 1) {
|
||||
m = (a + b) >> 1;
|
||||
frag_time = get_frag_time(frag_index, m, id);
|
||||
if (frag_time != AV_NOPTS_VALUE) {
|
||||
if (frag_time >= timestamp)
|
||||
b = m;
|
||||
if (frag_time <= timestamp)
|
||||
a = m;
|
||||
}
|
||||
m0 = m = (a + b) >> 1;
|
||||
|
||||
while (m < b &&
|
||||
(frag_time = get_frag_time(frag_index, m, id)) == AV_NOPTS_VALUE)
|
||||
m++;
|
||||
|
||||
if (m < b && frag_time <= timestamp)
|
||||
a = m;
|
||||
else
|
||||
b = m0;
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -1326,6 +1329,10 @@ static int update_frag_index(MOVContext *c, int64_t offset)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < c->fc->nb_streams; i++) {
|
||||
// Avoid building frag index if streams lack track id.
|
||||
if (c->fc->streams[i]->id < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
frag_stream_info[i].id = c->fc->streams[i]->id;
|
||||
frag_stream_info[i].sidx_pts = AV_NOPTS_VALUE;
|
||||
frag_stream_info[i].tfdt_dts = AV_NOPTS_VALUE;
|
||||
@@ -1366,6 +1373,9 @@ static void fix_frag_index_entries(MOVFragmentIndex *frag_index, int index,
|
||||
|
||||
static int mov_read_moof(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
{
|
||||
// Set by mov_read_tfhd(). mov_read_trun() will reject files missing tfhd.
|
||||
c->fragment.found_tfhd = 0;
|
||||
|
||||
if (!c->has_looked_for_mfra && c->use_mfra_for > 0) {
|
||||
c->has_looked_for_mfra = 1;
|
||||
if (pb->seekable & AVIO_SEEKABLE_NORMAL) {
|
||||
@@ -2689,8 +2699,11 @@ static inline int64_t mov_get_stsc_samples(MOVStreamContext *sc, unsigned int in
|
||||
|
||||
if (mov_stsc_index_valid(index, sc->stsc_count))
|
||||
chunk_count = sc->stsc_data[index + 1].first - sc->stsc_data[index].first;
|
||||
else
|
||||
else {
|
||||
// Validation for stsc / stco happens earlier in mov_read_stsc + mov_read_trak.
|
||||
av_assert0(sc->stsc_data[index].first <= sc->chunk_count);
|
||||
chunk_count = sc->chunk_count - (sc->stsc_data[index].first - 1);
|
||||
}
|
||||
|
||||
return sc->stsc_data[index].count * (int64_t)chunk_count;
|
||||
}
|
||||
@@ -4154,7 +4167,7 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
|
||||
st = avformat_new_stream(c->fc, NULL);
|
||||
if (!st) return AVERROR(ENOMEM);
|
||||
st->id = c->fc->nb_streams;
|
||||
st->id = -1;
|
||||
sc = av_mallocz(sizeof(MOVStreamContext));
|
||||
if (!sc) return AVERROR(ENOMEM);
|
||||
|
||||
@@ -4168,6 +4181,13 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
|
||||
c->trak_index = -1;
|
||||
|
||||
// Here stsc refers to a chunk not described in stco. This is technically invalid,
|
||||
// but we can overlook it (clearing stsc) whenever stts_count == 0 (indicating no samples).
|
||||
if (!sc->chunk_count && !sc->stts_count && sc->stsc_count) {
|
||||
sc->stsc_count = 0;
|
||||
av_freep(&sc->stsc_data);
|
||||
}
|
||||
|
||||
/* sanity checks */
|
||||
if ((sc->chunk_count && (!sc->stts_count || !sc->stsc_count ||
|
||||
(!sc->sample_size && !sc->sample_count))) ||
|
||||
@@ -4176,7 +4196,7 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
st->index);
|
||||
return 0;
|
||||
}
|
||||
if (sc->chunk_count && sc->stsc_count && sc->stsc_data[ sc->stsc_count - 1 ].first > sc->chunk_count) {
|
||||
if (sc->stsc_count && sc->stsc_data[ sc->stsc_count - 1 ].first > sc->chunk_count) {
|
||||
av_log(c->fc, AV_LOG_ERROR, "stream %d, contradictionary STSC and STCO\n",
|
||||
st->index);
|
||||
return AVERROR_INVALIDDATA;
|
||||
@@ -4438,6 +4458,11 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
st = c->fc->streams[c->fc->nb_streams-1];
|
||||
sc = st->priv_data;
|
||||
|
||||
// Each stream (trak) should have exactly 1 tkhd. This catches bad files and
|
||||
// avoids corrupting AVStreams mapped to an earlier tkhd.
|
||||
if (st->id != -1)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
version = avio_r8(pb);
|
||||
flags = avio_rb24(pb);
|
||||
st->disposition |= (flags & MOV_TKHD_FLAG_ENABLED) ? AV_DISPOSITION_DEFAULT : 0;
|
||||
@@ -4540,6 +4565,8 @@ static int mov_read_tfhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
MOVTrackExt *trex = NULL;
|
||||
int flags, track_id, i;
|
||||
|
||||
c->fragment.found_tfhd = 1;
|
||||
|
||||
avio_r8(pb); /* version */
|
||||
flags = avio_rb24(pb);
|
||||
|
||||
@@ -4675,6 +4702,11 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
AVIndexEntry *new_entries;
|
||||
MOVFragmentStreamInfo * frag_stream_info;
|
||||
|
||||
if (!frag->found_tfhd) {
|
||||
av_log(c->fc, AV_LOG_ERROR, "trun track id unknown, no tfhd was found\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
for (i = 0; i < c->fc->nb_streams; i++) {
|
||||
if (c->fc->streams[i]->id == frag->track_id) {
|
||||
st = c->fc->streams[i];
|
||||
@@ -4704,6 +4736,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
break;
|
||||
}
|
||||
}
|
||||
av_assert0(index_entry_pos <= st->nb_index_entries);
|
||||
|
||||
avio_r8(pb); /* version */
|
||||
flags = avio_rb24(pb);
|
||||
@@ -5017,7 +5050,7 @@ static int mov_read_sidx(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
}
|
||||
}
|
||||
}
|
||||
for (i = 0; i < c->fc->nb_streams; i++) {
|
||||
if (ref_st) for (i = 0; i < c->fc->nb_streams; i++) {
|
||||
st = c->fc->streams[i];
|
||||
sc = st->priv_data;
|
||||
if (!sc->has_sidx) {
|
||||
@@ -6546,14 +6579,14 @@ static int cenc_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryptionInfo *s
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cenc_filter(MOVContext *mov, MOVStreamContext *sc, AVPacket *pkt, int current_index)
|
||||
static int cenc_filter(MOVContext *mov, AVStream* st, MOVStreamContext *sc, AVPacket *pkt, int current_index)
|
||||
{
|
||||
MOVFragmentStreamInfo *frag_stream_info;
|
||||
MOVEncryptionIndex *encryption_index;
|
||||
AVEncryptionInfo *encrypted_sample;
|
||||
int encrypted_index, ret;
|
||||
|
||||
frag_stream_info = get_current_frag_stream_info(&mov->frag_index);
|
||||
frag_stream_info = get_frag_stream_info(&mov->frag_index, mov->frag_index.current, st->id);
|
||||
encrypted_index = current_index;
|
||||
encryption_index = NULL;
|
||||
if (frag_stream_info) {
|
||||
@@ -7783,7 +7816,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
if (mov->aax_mode)
|
||||
aax_filter(pkt->data, pkt->size, mov);
|
||||
|
||||
ret = cenc_filter(mov, sc, pkt, current_index);
|
||||
ret = cenc_filter(mov, st, sc, pkt, current_index);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
||||
@@ -541,7 +541,7 @@ static int mov_write_eac3_tag(AVIOContext *pb, MOVTrack *track)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
info = track->eac3_priv;
|
||||
size = 2 + 4 * (info->num_ind_sub + 1);
|
||||
size = 2 + ((34 * (info->num_ind_sub + 1) + 7) >> 3);
|
||||
buf = av_malloc(size);
|
||||
if (!buf) {
|
||||
size = AVERROR(ENOMEM);
|
||||
@@ -563,12 +563,12 @@ static int mov_write_eac3_tag(AVIOContext *pb, MOVTrack *track)
|
||||
put_bits(&pbc, 4, info->substream[i].num_dep_sub);
|
||||
if (!info->substream[i].num_dep_sub) {
|
||||
put_bits(&pbc, 1, 0); /* reserved */
|
||||
size--;
|
||||
} else {
|
||||
put_bits(&pbc, 9, info->substream[i].chan_loc);
|
||||
}
|
||||
}
|
||||
flush_put_bits(&pbc);
|
||||
size = put_bits_count(&pbc) >> 3;
|
||||
|
||||
avio_wb32(pb, size + 8);
|
||||
ffio_wfourcc(pb, "dec3");
|
||||
|
||||
@@ -918,7 +918,7 @@ static void new_data_packet(const uint8_t *buffer, int len, AVPacket *pkt)
|
||||
|
||||
static int new_pes_packet(PESContext *pes, AVPacket *pkt)
|
||||
{
|
||||
char *sd;
|
||||
uint8_t *sd;
|
||||
|
||||
av_init_packet(pkt);
|
||||
|
||||
|
||||
@@ -1172,7 +1172,7 @@ static int nut_write_trailer(AVFormatContext *s)
|
||||
|
||||
ret = avio_open_dyn_buf(&dyn_bc);
|
||||
if (ret >= 0 && nut->sp_count) {
|
||||
av_assert1(nut->write_index);
|
||||
av_assert1(nut->write_index); // sp_count should be 0 if no index is going to be written
|
||||
write_index(nut, dyn_bc);
|
||||
put_packet(nut, bc, dyn_bc, 1, INDEX_STARTCODE);
|
||||
}
|
||||
|
||||
+6
-2
@@ -454,7 +454,10 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
|
||||
} else if (!strcmp(st_type, "text")) {
|
||||
codec_type = AVMEDIA_TYPE_SUBTITLE;
|
||||
}
|
||||
if (codec_type == AVMEDIA_TYPE_UNKNOWN || !(rt->media_type_mask & (1 << codec_type))) {
|
||||
if (codec_type == AVMEDIA_TYPE_UNKNOWN ||
|
||||
!(rt->media_type_mask & (1 << codec_type)) ||
|
||||
rt->nb_rtsp_streams >= s->max_streams
|
||||
) {
|
||||
s1->skip_media = 1;
|
||||
return;
|
||||
}
|
||||
@@ -1663,7 +1666,7 @@ int ff_rtsp_connect(AVFormatContext *s)
|
||||
char tcpname[1024], cmd[2048], auth[128];
|
||||
const char *lower_rtsp_proto = "tcp";
|
||||
int port, err, tcp_fd;
|
||||
RTSPMessageHeader reply1 = {0}, *reply = &reply1;
|
||||
RTSPMessageHeader reply1, *reply = &reply1;
|
||||
int lower_transport_mask = 0;
|
||||
int default_port = RTSP_DEFAULT_PORT;
|
||||
char real_challenge[64] = "";
|
||||
@@ -1692,6 +1695,7 @@ int ff_rtsp_connect(AVFormatContext *s)
|
||||
rt->lower_transport_mask &= (1 << RTSP_LOWER_TRANSPORT_NB) - 1;
|
||||
|
||||
redirect:
|
||||
memset(&reply1, 0, sizeof(reply1));
|
||||
/* extract hostname and port */
|
||||
av_url_split(proto, sizeof(proto), auth, sizeof(auth),
|
||||
host, sizeof(host), &port, path, sizeof(path), s->url);
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
|
||||
// Also please add any ticket numbers that you believe might be affected here
|
||||
#define LIBAVFORMAT_VERSION_MAJOR 58
|
||||
#define LIBAVFORMAT_VERSION_MINOR 21
|
||||
#define LIBAVFORMAT_VERSION_MINOR 20
|
||||
#define LIBAVFORMAT_VERSION_MICRO 100
|
||||
|
||||
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
|
||||
|
||||
@@ -466,6 +466,7 @@ static int parse_adaptation_sets(AVFormatContext *s)
|
||||
continue;
|
||||
else if (state == new_set && !strncmp(p, "id=", 3)) {
|
||||
void *mem = av_realloc(w->as, sizeof(*w->as) * (w->nb_as + 1));
|
||||
const char *comma;
|
||||
if (mem == NULL)
|
||||
return AVERROR(ENOMEM);
|
||||
w->as = mem;
|
||||
@@ -474,6 +475,11 @@ static int parse_adaptation_sets(AVFormatContext *s)
|
||||
w->as[w->nb_as - 1].streams = NULL;
|
||||
p += 3; // consume "id="
|
||||
q = w->as[w->nb_as - 1].id;
|
||||
comma = strchr(p, ',');
|
||||
if (!comma || comma - p >= sizeof(w->as[w->nb_as - 1].id)) {
|
||||
av_log(s, AV_LOG_ERROR, "'id' in 'adaptation_sets' is malformed.\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
while (*p != ',') *q++ = *p++;
|
||||
*q = 0;
|
||||
p++;
|
||||
|
||||
@@ -40,6 +40,7 @@ enum WV_FLAGS {
|
||||
WV_HBAL = 0x0400,
|
||||
WV_MCINIT = 0x0800,
|
||||
WV_MCEND = 0x1000,
|
||||
WV_DSD = 0x80000000,
|
||||
};
|
||||
|
||||
static const int wv_rates[16] = {
|
||||
@@ -97,6 +98,11 @@ static int wv_read_block_header(AVFormatContext *ctx, AVIOContext *pb)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (wc->header.flags & WV_DSD) {
|
||||
avpriv_report_missing_feature(ctx, "WV DSD");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
|
||||
if (wc->header.version < 0x402 || wc->header.version > 0x410) {
|
||||
avpriv_report_missing_feature(ctx, "WV version 0x%03X",
|
||||
wc->header.version);
|
||||
|
||||
+5
-22
@@ -501,7 +501,6 @@ int av_image_copy_to_buffer(uint8_t *dst, int dst_size,
|
||||
static void memset_bytes(uint8_t *dst, size_t dst_size, uint8_t *clear,
|
||||
size_t clear_size)
|
||||
{
|
||||
size_t pos = 0;
|
||||
int same = 1;
|
||||
int i;
|
||||
|
||||
@@ -521,28 +520,12 @@ static void memset_bytes(uint8_t *dst, size_t dst_size, uint8_t *clear,
|
||||
if (clear_size == 1) {
|
||||
memset(dst, clear[0], dst_size);
|
||||
dst_size = 0;
|
||||
} else if (clear_size == 2) {
|
||||
uint16_t val = AV_RN16(clear);
|
||||
for (; dst_size >= 2; dst_size -= 2) {
|
||||
AV_WN16(dst, val);
|
||||
dst += 2;
|
||||
}
|
||||
} else if (clear_size == 4) {
|
||||
uint32_t val = AV_RN32(clear);
|
||||
for (; dst_size >= 4; dst_size -= 4) {
|
||||
AV_WN32(dst, val);
|
||||
dst += 4;
|
||||
}
|
||||
} else if (clear_size == 8) {
|
||||
uint32_t val = AV_RN64(clear);
|
||||
for (; dst_size >= 8; dst_size -= 8) {
|
||||
AV_WN64(dst, val);
|
||||
dst += 8;
|
||||
}
|
||||
} else {
|
||||
if (clear_size > dst_size)
|
||||
clear_size = dst_size;
|
||||
memcpy(dst, clear, clear_size);
|
||||
av_memcpy_backptr(dst + clear_size, clear_size, dst_size - clear_size);
|
||||
}
|
||||
|
||||
for (; dst_size; dst_size--)
|
||||
*dst++ = clear[pos++ % clear_size];
|
||||
}
|
||||
|
||||
// Maximum size in bytes of a plane element (usually a pixel, or multiple pixels
|
||||
|
||||
@@ -399,6 +399,18 @@ static void fill32(uint8_t *dst, int len)
|
||||
{
|
||||
uint32_t v = AV_RN32(dst - 4);
|
||||
|
||||
#if HAVE_FAST_64BIT
|
||||
uint64_t v2= v + ((uint64_t)v<<32);
|
||||
while (len >= 32) {
|
||||
AV_WN64(dst , v2);
|
||||
AV_WN64(dst+ 8, v2);
|
||||
AV_WN64(dst+16, v2);
|
||||
AV_WN64(dst+24, v2);
|
||||
dst += 32;
|
||||
len -= 32;
|
||||
}
|
||||
#endif
|
||||
|
||||
while (len >= 4) {
|
||||
AV_WN32(dst, v);
|
||||
dst += 4;
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@
|
||||
*/
|
||||
|
||||
#define LIBAVUTIL_VERSION_MAJOR 56
|
||||
#define LIBAVUTIL_VERSION_MINOR 23
|
||||
#define LIBAVUTIL_VERSION_MINOR 22
|
||||
#define LIBAVUTIL_VERSION_MICRO 100
|
||||
|
||||
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
||||
|
||||
@@ -1184,10 +1184,10 @@ FIND_MIN_MAX((%0, %1, 8))
|
||||
#endif
|
||||
"movq %%mm6, %%mm0 \n\t" // max
|
||||
"psubb %%mm7, %%mm6 \n\t" // max - min
|
||||
"push %4 \n\t"
|
||||
"movd %%mm6, %k4 \n\t"
|
||||
"cmpb "MANGLE(deringThreshold)", %b4 \n\t"
|
||||
"pop %4 \n\t"
|
||||
"push %%"FF_REG_a" \n\t"
|
||||
"movd %%mm6, %%eax \n\t"
|
||||
"cmpb "MANGLE(deringThreshold)", %%al \n\t"
|
||||
"pop %%"FF_REG_a" \n\t"
|
||||
" jb 1f \n\t"
|
||||
PAVGB(%%mm0, %%mm7) // a=(max + min)/2
|
||||
"punpcklbw %%mm7, %%mm7 \n\t"
|
||||
@@ -1317,7 +1317,7 @@ DERING_CORE((%0, %1, 8) ,(%%FF_REGd, %1, 4),%%mm2,%%mm4,%%mm0,%%mm3,%%mm5,
|
||||
"1: \n\t"
|
||||
: : "r" (src), "r" ((x86_reg)stride), "m" (c->pQPb), "m"(c->pQPb2), "q"(tmp)
|
||||
NAMED_CONSTRAINTS_ADD(deringThreshold,b00,b02,b08)
|
||||
: "%"FF_REG_a, "%"FF_REG_d, "%"FF_REG_sp
|
||||
: "%"FF_REG_a, "%"FF_REG_d
|
||||
);
|
||||
#else // HAVE_7REGS && (TEMPLATE_PP_MMXEXT || TEMPLATE_PP_3DNOW)
|
||||
int y;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user