Commit Graph

42030 Commits

Author SHA1 Message Date
Lynne
6b22e28f4c opusdsp: adjust and optimize C function to match assembly
The C and asm versions behaved differently _outside_ of the codec.

The C version returned pre-multiplied 'state' for the next execution
to use right away, while the assembly version outputted non-multiplied
'state' for the next execution to multiply to save instructions.
Since the initial state when initialized or seeking is always 0,
and since C and asm versions were never mixed, there was no issue.

However, comparing outputs directly in checkasm doesn't work without
dividing the initial state by CELT_EMPH_COEFF and multiplying the
returned state by CELT_EMPH_COEFF for the assembly function.

Since its actually faster to do this in C as well, copy the behavior the
asm versions use. As a reminder, the initial state 0 is divided by
CELT_EMPH_COEFF on seek and init (just in case in the future this is
changed, its technically more correct to init with CELT_EMPH_COEFF than 0,
however when seeking this will result in more audiable pops, unlike with 0
where the output gets in sync over a few samples).
2019-09-11 03:28:22 +01:00
Lukas Rusak
40a433e34b avcodec/v4l2_buffers: split out v4l2_buf_increase_ref helper
Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-10 19:12:47 -07:00
Aman Gupta
d620b1f9de avcodec/v4l2_buffers: split out V4L2Buffer generation into helper method
Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-10 19:12:47 -07:00
Aman Gupta
2b21bb4a87 avcodec/v4l2_buffers: split out AVFrame generation into helper method
Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-10 19:12:47 -07:00
Aman Gupta
b3b958c19e avcodec/v4l2_buffers: teach ff_v4l2_buffer_avframe_to_buf about contiguous planar formats
This fixes h264_v4l2m2m encoding on the Raspberry Pi

Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-10 19:05:31 -07:00
Aman Gupta
84540b2b84 avcodec/v4l2_m2m_enc: fix indentation and add M2MENC_CLASS macro
Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-10 19:05:31 -07:00
Lukas Rusak
f9b0f88aa4 avcodec/v4l2_m2m_dec: fix indentation and add M2MDEC_CLASS macro
This just makes the M2MDEC_CLASS similar to how it is done in rkmpp. It looks
clean and has proper indentation

Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-10 19:05:18 -07:00
Aman Gupta
c0c7946196 avcodec/v4l2_m2m: decouple v4l2_m2m helpers from AVCodecContext
This will allow re-use of the m2m backend with AVFilterContext

Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-10 19:01:13 -07:00
Dave Stevenson
d61cf1b1eb avcodec/v4l2_buffers: Add handling for NV21 and YUV420P
The single planar support was for NV12 only.
Add NV21 and YUV420P support.

Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-10 18:56:40 -07:00
Aman Gupta
7bb6898b16 avcodec/v4l2_m2m: fix av_pix_fmt changing when multiple /dev/video* devices are probed
On the RPI, three different /dev/video devices exist (decoder, scaler, encoder).

When probing the devices in order, the originally requested pix fmt
would be mutated causing the wrong one to be chosen when a matching
device was finally found.

Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-10 18:52:37 -07:00
Aman Gupta
ac52e06e56 avcodec/v4l2_m2m: disable info logging during device probe
Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-10 18:52:37 -07:00
Aman Gupta
ab4835f418 avcodec/v4l2_m2m_enc: add support for -force_key_frames
Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-10 18:52:37 -07:00
Aman Gupta
7fddf4b266 avcodec/mediacodec_surface: define and use FFANativeWindow to mimic NDK interface
This will make it easy to switch to ANativeWindow_fromSurface
and ANativeWindow_release in the future.

Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-10 13:51:05 -07:00
Aman Gupta
8a3623e2fb avcodec/mediacodecdec: warn when input buffers are not configured with proper size
In rare circumstances, if the codec is not configured with the
proper parameters the input buffers can be allocated with a size
that's too small to hold an individual packet. Since MediaCodec
expects exactly one incoming buffer with a given PTS, it is not
valid to split data for a given PTS across two input buffers.

See https://developer.android.com/reference/android/media/MediaCodec#data-processing:

  > Do not submit multiple input buffers with the same timestamp

Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-10 13:51:05 -07:00
Michael Niedermayer
10ea6c3116 avcodec/pnm_parser: Use memchr() in pnm_parse()
Fixes: Timeout (45sec -> 0.5sec)
Fixes: 16942/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PPM_fuzzer-5085393073995776

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-09-10 17:21:54 +02:00
Pascal Massimino
857fd2ad99 avcodec/webp: fix decoding for trailing junk
some bitstream have trailing junk, despite being valid webp data.
In case of apparent error, abort the loop and let *got_frame
decide whether this is an error or not.

fixes trac #8107 (/#7612)

Another possibility would be turning the loop into:
    while (!*got_frame) {...}

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-09-10 17:21:54 +02:00
Shiyou Yin
de5543d8d4 avcodec/mips: Fix a warnning of indentation not reflect the block structure.
The indentation of code dose not reflect the if block structure in
'apply_ltp_mips', and this will generate a warnning when build with
'-Wall' or '-Wmisleading-indentation'.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-09-10 17:21:53 +02:00
Nicolas Gaullier
cae5b36e20 avcodec/h264: Fix poc_lsb in open gop context
When no IDR nor mmco_reset is found, prev_poc_lsb is
undefined and shall not be assumed to be zero
2019-09-10 12:19:23 +02:00
Aman Gupta
35b0e75b54 avcodec/mediacodec_surface: drop unnecessary local variable
Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-09 13:25:12 -07:00
Aman Gupta
d0e6762768 avcodec/mediacodecdec_common: log codec name during configure/start failures
Signed-off-by: Aman Gupta <aman@tmm1.net>
Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com>
2019-09-09 13:25:09 -07:00
Aman Gupta
ca613dcc38 avcodec/mediacodecdec_common: ensure current input buffer is always used correctly
The loop may mutate the input buffer, so re-fetch it to ensure
the current one is always used.

Signed-off-by: Aman Gupta <aman@tmm1.net>
Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com>
2019-09-09 13:25:06 -07:00
Aman Gupta
f821d19531 avcodec/mediacodecdec_common: improve trace logging for end-of-stream
Signed-off-by: Aman Gupta <aman@tmm1.net>
Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com>
2019-09-09 13:25:03 -07:00
Aman Gupta
425be35c26 avcodec/mediacodecdec_common: warn when PTS is missing
MediaCodec decoders require PTS for proper operation.

Signed-off-by: Aman Gupta <aman@tmm1.net>
Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com>
2019-09-09 13:24:58 -07:00
Michael Niedermayer
12b909ba31 avcodec/qdm2: Check frame size
Fixes: index 2304 out of bounds for type 'float [2304]'
Fixes: 16332/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_QDM2_fuzzer-5679142481166336

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-09-06 22:26:55 +02:00
Michael Niedermayer
413e0f2516 avcodec/vc1_pred: Fix refdist in scaleforopp()
Fixes: out of array access
Fixes: 16601/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-5656105392275456

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-09-06 22:24:50 +02:00
Michael Niedermayer
722fd46965 avcodec/vorbisdec: fix FASTDIV usage for vr_type == 2
This reverts a hunk from f1ca40ee00

Fixes: out of array read
Fixes: 16924/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VORBIS_fuzzer-5157893162139648

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-09-06 22:06:12 +02:00
Michael Niedermayer
dfa5d1a366 avcodec/iff: Check for overlap in cmap_read_palette()
Fixes: undefined memcpy() use
Fixes: 16302/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5678750575886336

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-09-05 19:45:53 +02:00
Michael Niedermayer
8a1a9588fb avcodec/vqavideo: Limit resolution
Fixes: Timeout (288sec -> 1ms)
Fixes: 16353/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VQA_fuzzer-5633402606190592

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-09-05 19:45:53 +02:00
Michael Niedermayer
9d3ddef519 avcodec/apedec: Fix 32bit int overflow in do_apply_filter()
Fixes: signed integer overflow: 2147480546 + 4096 cannot be represented in type 'int'
Fixes: 16280/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5123442566758400

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-09-05 19:45:53 +02:00
Akemi
2a9d461abc avcodec/videotoolbox: add support for full range pixel formats
Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-04 10:51:20 -07:00
James Almer
a0739e8a16 avcodec/nuv: prevent frame copying when outputting duplicate frames
Signed-off-by: James Almer <jamrial@gmail.com>
2019-09-04 10:07:12 -03:00
James Almer
343f8d514e avcodec/wcmv: prevent frame copying when outputting duplicate frames
Signed-off-by: James Almer <jamrial@gmail.com>
2019-09-04 10:07:12 -03:00
James Almer
5102999223 Revert "avcodec/wcmv: Avoid copying frames if they are unchanged"
This reverts commit 976dae8b32.

An alternative approach to reduce frame copying will follow.
2019-09-04 10:07:12 -03:00
James Almer
c14a12ac84 avcodec/wcmv: use ff_reget_buffer()
Signed-off-by: James Almer <jamrial@gmail.com>
2019-09-04 10:07:12 -03:00
James Almer
9ea6d2149e avcodec/decode: add a flags parameter to ff_reget_buffer()
Some decoders may not need a writable buffer in some specific cases, but only
a reference to the existing buffer with updated frame properties instead, for
the purpose of returning duplicate frames. For this, the
FF_REGET_BUFFER_FLAG_READONLY flag is added, which will prevent potential
allocations and buffer copies when they are not needed.

Signed-off-by: James Almer <jamrial@gmail.com>
2019-09-04 10:07:12 -03:00
Aman Gupta
e9cc873636 avcodec/v4l2_m2m: fix minor indentation issue 2019-09-02 15:17:57 -07:00
Aman Gupta
b6c6f56e38 avcodec/v4l2_m2m: use log_ctx variable consistently
Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-02 15:12:44 -07:00
Aman Gupta
e8c5ce1acb avcodec/v4l2_m2m: log planar mode used by driver
Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-02 15:12:20 -07:00
Aman Gupta
c95b127733 avcodec/v4l2_context: use EAGAIN to signal when input buffers are unavailable
ENOMEM indicates an allocation failure, and there are no allocations
happening here. The buffers are pre-allocated and there are simply
none available at this time.

Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-02 15:08:34 -07:00
Jorge Ramirez-Ortiz
da45ad48f9 avcodec/v4l2m2m: fix error handling during buffer init
Signed-off-by: Jorge Ramirez-Ortiz <jramirez@baylibre.com>
Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-02 15:08:34 -07:00
Lukas Rusak
1d36b7b47a avcodec/v4l2_buffers: return int64_t in v4l2_get_pts
v4l2_pts is type int64_t we should return that instead of uint64_t

Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-02 15:08:29 -07:00
Aman Gupta
bad8365b2b avcodec/v4l2_context: return {decoder,encoder}_cmd errors
Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-02 15:06:45 -07:00
Aman Gupta
6852b85020 avcodec/v4l2_m2m_enc: fix typo in log message
Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-02 15:06:38 -07:00
Aman Gupta
dc180cd815 avcodec/v4l2_m2m_enc: log errno on v4l2_set_ext_ctrl failures
Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-02 15:06:32 -07:00
Aman Gupta
5e2436c6de avcodec/v4l2_buffers: fix minor typos and whitespace
Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-02 15:06:28 -07:00
Aman Gupta
87daee944b avcodec/v4l2_context: log VIDIOC_REQBUFS failures
Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-02 15:06:22 -07:00
Aman Gupta
7b092a074b avcodec/v4l2_m2m: remove trailing whitespace in output identifier
Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-02 15:06:17 -07:00
Aman Gupta
3a5bcb1d13 avcodec/v4l2_m2m: log requested pixel formats
Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-02 15:06:12 -07:00
Aman Gupta
b022d9ba28 avcodec/omx: fix xFramerate calculation
Integer overflow in the Q16 framerate calculation was sending
invalid values to the OMX encoder.

On the RPI4, this manifested as bitrate controls being ignored
on video streams with 60000/1001 framerates. Video streams with
30000/1001 framerates were not affected.

Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-02 13:46:11 -07:00
Michael Niedermayer
4778407ab3 avcodec/ralf: fix undefined shift in extend_code()
Fixes: left shift of negative value -3
Fixes: 16147/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RALF_fuzzer-5658392722407424

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-09-02 21:37:18 +02:00