Andreas Rheinhardt
ab8a8246c8
avcodec/h264_cavlc: Remove code duplication
...
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-10-31 20:46:59 +01:00
Andreas Rheinhardt
bd4c778e19
avcodec/h264_cavlc: Avoid indirection for coefficient table VLCs
...
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-10-31 20:46:59 +01:00
Andreas Rheinhardt
fe748ddf62
avcodec/h264_cavlc: Avoid superfluous VLC structures
...
Of all these VLCs here, only VLC.table was really used
after init, so use the ff_vlc_init_tables API
to get rid of them.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-10-31 20:46:59 +01:00
Andreas Rheinhardt
4e6cf5e52b
avcodec/h264dec: Constify H.264 decoder
...
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-10-13 14:35:07 +02:00
Andreas Rheinhardt
9cdf82c2c2
avcodec/vlc: Use proper namespace
...
Therefore use a proper prefix for this API, e.g.
ff_init_vlc_sparse -> ff_vlc_init_sparse
ff_free_vlc -> ff_vlc_free
INIT_VLC_LE -> VLC_INIT_LE
INIT_VLC_USE_NEW_STATIC -> VLC_INIT_USE_STATIC
(The ancient INIT_VLC_USE_STATIC has been removed
in 595324e143 , so that
the NEW has been dropped.)
Finally, reorder the flags and change their values
accordingly.
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-11 00:27:45 +02:00
Andreas Rheinhardt
2d764069be
avcodec/vlc: Use structure instead of VLC_TYPE array as VLC element
...
In C, qualifiers for arrays are broken:
const VLC_TYPE (*foo)[2] is a pointer to an array of two const VLC_TYPE
elements and unfortunately this is not compatible with a pointer
to a const array of two VLC_TYPE, because the latter does not exist
as array types are never qualified (the qualifier applies to the base
type instead). This is the reason why get_vlc2() doesn't accept
a const VLC table despite not modifying the table at all, as
there is no automatic conversion from VLC_TYPE (*)[2] to
const VLC_TYPE (*)[2].
Fix this by using a structure VLCElem for the VLC table.
This also has the advantage of making it clear which
element is which.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-06-17 16:47:29 +02:00
Andreas Rheinhardt
c3ff716808
avcodec/h264_*: Remove unnecessary internal.h inclusions
...
Also remove some other unnecessary headers while at it.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-26 15:30:54 +01:00
Andreas Rheinhardt
25c8507818
Remove/replace some unnecessary avcodec.h inclusions
...
Also remove other unnecessary headers and include headers directly while
at it.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 15:29:46 +02:00
Andreas Rheinhardt
a581370f54
avcodec/h264_cavlc: Reindent after the previous commit
...
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-15 06:42:29 +01:00
Andreas Rheinhardt
b41e4f6187
avcodec/h264_cavlc: Remove redundant check
...
The only caller to ff_h264_decode_init_vlc() already uses
ff_thread_once() for the call; ergo the check via a simple int with
static storage duration in ff_h264_decode_init_vlc() is redundant.
And if it were not redundant, it would be a potential for data races.
So remove it.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-15 06:29:42 +01:00
Michael Niedermayer
b789ebf681
avcodec/h264_cavlc: Fix integer overflows with motion vector residual addition
...
Fixes: signed integer overflow: 14 + 2147483647 cannot be represented in type 'int'
Fixes: 14794/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-5677380695228416
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-07-19 21:42:38 +02:00
Michael Niedermayer
f72b9904fe
avcodec/h264_cavlc: Check mb_skip_run
...
Fixes: 10300/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-6292205497483264
Fixes: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-10-18 02:28:54 +02:00
Xiaohan Wang
71f39de2a5
avcodec/h264_cavlc: Set valid qscale value in ff_h264_decode_mb_cavlc()
...
When ff_h264_decode_mb_cavlc() failed due to wrong sl->qscale values,
e.g. dquant out of range, set the qscale to be a valid value before
returning -1 and exiting the function. The qscale value can be used
later e.g. in loop filter.
BUG=806122
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-02-14 01:06:37 +01:00
Wan-Teh Chang
99c5ac2039
avcodec/h264: Declare the local variable decode_chroma as const.
...
ff_h264_decode_mb_cabac() and ff_h264_decode_mb_cavlc() are very long
functions. Declaring decode_chroma as const makes it clear the variable
doesn't change after initialization.
Signed-off-by: Wan-Teh Chang <wtc@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-07-21 02:08:33 +02:00
Anton Mitrofanov
cf231b68da
avcodec/h264: Fix mix of lossless and lossy MBs decoding
...
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2017-06-19 14:33:40 -04:00
Michael Niedermayer
0e87c07d87
avcodec/h264_cavlc: Fix runtime error: index -1 out of bounds for type 'VLC [6]'
...
Fixes: 1639/clusterfuzz-testcase-minimized-5693801463021568
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-05-17 02:07:17 +02:00
Michael Niedermayer
54e1b62ee2
avcodec/h264_cavlc: Fix runtime error: index -1 out of bounds for type 'VLC [15]
...
Fixes: 1513/clusterfuzz-testcase-minimized-6246484833992704
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-05-13 15:54:33 +02:00
Michael Niedermayer
fc8cff96ed
avcodec/h264_cavlc: Fix undefined behavior on qscale overflow
...
Fixes: 1214/clusterfuzz-testcase-minimized-6130606599569408
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-04-22 22:26:00 +02:00
Clément Bœsch
15b26e88cb
Merge commit ' 9df889a5f1'
...
* commit '9df889a5f1 ':
h264: rename h264.[ch] to h264dec.[ch]
Merged-by: Clément Bœsch <u@pkh.me>
2016-07-29 11:01:36 +02:00
Clément Bœsch
5565e27111
Merge commit ' 6e92181bf8'
...
* commit '6e92181bf8 ':
h264: pass just the PPS to get_chroma_qp()
Merged-by: Clément Bœsch <clement@stupeflix.com>
2016-07-01 14:23:38 +02:00
Hendrik Leppkes
e2836397f1
Merge commit ' 52567e8198'
...
* commit '52567e8198 ':
get_bits: Drop some TRACE-level debug code
Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-06-26 14:19:48 +02:00
Clément Bœsch
8ef57a0d61
Merge commit ' 41ed7ab45f'
...
* commit '41ed7ab45f ':
cosmetics: Fix spelling mistakes
Merged-by: Clément Bœsch <u@pkh.me>
2016-06-21 21:55:34 +02:00
Anton Khirnov
9df889a5f1
h264: rename h264.[ch] to h264dec.[ch]
...
This is more consistent with the naming of other decoders.
2016-06-21 11:11:26 +02:00
James Almer
94011f994a
avodec/h264dec: fix compilation with -DTRACE
...
Signed-off-by: James Almer <jamrial@gmail.com>
2016-06-16 18:52:23 -03:00
Anton Khirnov
6e92181bf8
h264: pass just the PPS to get_chroma_qp()
...
It does not need the whole context. This will simplify the following
commit.
2016-06-12 20:27:53 +02:00
Clément Bœsch
1534ef87c7
Merge commit ' 3176217c60'
...
* commit '3176217c60 ':
h264: decouple h264_ps from the h264 decoder
Main changes:
- a local GetBitContext is created for the various
ff_h264_decode_seq_parameter_set() attempts
- just like the old code, remove_sps() is adjusted so it doesn't remove
the pps.
Fixes decode with Ticket #631
http://ffmpeg.org/pipermail/ffmpeg-user/attachments/20111108/dae58f17/attachment.mp4
but see next point as well.
- ff_h264_update_thread_context() is updated to work even when SPS
isn't set as it breaks current skip_frame code. This makes sure we
can still decode the sample from ticket #631 without the need for
-flags2 +chunks. (Thanks to Michael)
- keep {sps,pps}_ref pointers that stay alive even when the active
pps/sps get removed from the available lists (patch by michaelni with
additionnal frees in ff_h264_free_context() from mateo)
- added a check on sps in avpriv_h264_has_num_reorder_frames() to fix
crashes with mpegts_with_dvbsubs.ts from Ticket #4074
http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4074/mpegts_with_dvbsubs.ts
- in h264_parser.c:h264_parse(), after the ff_h264_decode_extradata() is
called, the pps and sps from the local parser context are updated with
the pps and sps from the used h264context. This fixes fate-flv-demux.
- in h264_slice.c, "PPS changed between slices" error is not triggered
anymore in one condition as it makes fate-h264-xavc-4389 fails with
THREADS=N (Thanks to Michael)
Merged-by: Clément Bœsch <clement@stupeflix.com>
Merged-by: Michael Niedermayer <michael@niedermayer.cc>
Merged-by: Matthieu Bouron <matthieu.bouron@stupeflix.com>
2016-06-12 13:26:52 +02:00
Diego Biurrun
52567e8198
get_bits: Drop some TRACE-level debug code
...
It will not be provided by the new bit reader anyway.
2016-05-22 20:22:43 +02:00
Vittorio Giovara
41ed7ab45f
cosmetics: Fix spelling mistakes
...
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2016-05-04 18:16:21 +02:00
Diego Biurrun
c11c693acc
h264: Drop broken trace debug output
2016-05-03 15:45:11 +02:00
Derek Buitenhuis
a2922b5d61
Merge commit ' ecc31f6b08'
...
* commit 'ecc31f6b08 ':
h264: move ff_h264_check_intra[4x4]_pred_mode() to h264_parse
Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-04-27 16:34:40 +01:00
Derek Buitenhuis
9809371aa5
Merge commit ' a7da517f6a'
...
* commit 'a7da517f6a ':
h264data: Move all data tables from a header to a .c file
Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-04-24 11:54:53 +01:00
Anton Khirnov
3176217c60
h264: decouple h264_ps from the h264 decoder
...
Make the SPS/PPS parsing independent of the H264Context, to allow
decoupling the parser from the decoder. The change is modelled after the
one done earlier for HEVC.
Move the dequant buffers to the PPS to avoid complex checks whether they
changed and an expensive copy for frame threads.
2016-04-24 10:06:23 +02:00
Anton Khirnov
ecc31f6b08
h264: move ff_h264_check_intra[4x4]_pred_mode() to h264_parse
...
It is shared with svq3.
2016-03-28 09:53:56 +02:00
Diego Biurrun
a7da517f6a
h264data: Move all data tables from a header to a .c file
2016-03-25 15:56:14 +01:00
Derek Buitenhuis
5eb4073781
Merge commit ' 6b96d2dcda'
...
* commit '6b96d2dcda ':
cosmetics: Drop particularly redundant silly comments
Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-02-24 17:35:47 +00:00
Diego Biurrun
6b96d2dcda
cosmetics: Drop particularly redundant silly comments
2016-02-18 15:35:43 +01:00
Michael Niedermayer
8f7b022c8c
Merge commit ' 6a85dfc830'
...
* commit '6a85dfc830 ':
lavc: Replace av_dlog and tprintf with internal macros
Conflicts:
libavcodec/aacdec.c
libavcodec/audio_frame_queue.c
libavcodec/bitstream.c
libavcodec/dcadec.c
libavcodec/dnxhddec.c
libavcodec/dvbsubdec.c
libavcodec/dvdec.c
libavcodec/dvdsubdec.c
libavcodec/get_bits.h
libavcodec/gifdec.c
libavcodec/h264.h
libavcodec/h264_cabac.c
libavcodec/h264_cavlc.c
libavcodec/h264_loopfilter.c
libavcodec/h264_refs.c
libavcodec/imc.c
libavcodec/interplayvideo.c
libavcodec/jpeglsdec.c
libavcodec/libopencore-amr.c
libavcodec/mjpegdec.c
libavcodec/mpeg12dec.c
libavcodec/mpegvideo_enc.c
libavcodec/mpegvideo_parser.c
libavcodec/pngdec.c
libavcodec/ratecontrol.c
libavcodec/rv10.c
libavcodec/svq1dec.c
libavcodec/vqavideo.c
libavcodec/wmadec.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-20 04:10:10 +02:00
Vittorio Giovara
6a85dfc830
lavc: Replace av_dlog and tprintf with internal macros
2015-04-19 12:41:59 +01:00
Michael Niedermayer
797ba4d53b
avcodec/h264_cavlc: Drop local_ref_count
...
This basically switches to the implementation from f6f7d15041
which seems faster
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-22 14:39:38 +01:00
Michael Niedermayer
e845b9573d
Merge commit ' 7505c8dfba'
...
* commit '7505c8dfba ':
h264_cavlc: constify all uses of H264Context
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-21 18:19:58 +01:00
Michael Niedermayer
9d0450ae94
Merge commit ' e9b2383bf8'
...
* commit 'e9b2383bf8 ':
h264: move mb_mbaff into the per-slice context
Conflicts:
libavcodec/h264_cabac.c
libavcodec/h264_cavlc.c
libavcodec/h264_slice.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-21 18:07:01 +01:00
Michael Niedermayer
d511dc6530
Merge commit ' bc98e8c0e0'
...
* commit 'bc98e8c0e0 ':
h264: move mb_field_decoding_flag into the per-slice context
Conflicts:
libavcodec/h264_slice.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-21 18:03:54 +01:00
Michael Niedermayer
55215383dc
Merge commit ' f42485dbce'
...
* commit 'f42485dbce ':
h264: use a separate GetBitContext for slice data
Conflicts:
libavcodec/h264.c
libavcodec/h264_cavlc.c
libavcodec/h264_parser.c
libavcodec/h264_slice.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-21 17:13:24 +01:00
Michael Niedermayer
eba2c2321b
Merge commit ' 404a416d4b'
...
* commit '404a416d4b ':
h264: remove some remnants of data partitioning
Conflicts:
libavcodec/h264.c
libavcodec/h264_slice.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-21 17:00:51 +01:00
Michael Niedermayer
d76559fb5f
Merge commit ' d4d9068cdf'
...
* commit 'd4d9068cdf ':
h264: move mb_{x,y} into the per-slice context
Conflicts:
libavcodec/h264.c
libavcodec/h264_cavlc.c
libavcodec/h264_mb.c
libavcodec/h264_slice.c
libavcodec/svq3.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-21 16:46:15 +01:00
Michael Niedermayer
668c65e7e7
Merge commit ' 0edbe6faa7'
...
* commit '0edbe6faa7 ':
h264: move mb_xy into the per-slice context
Conflicts:
libavcodec/h264.c
libavcodec/h264_cabac.c
libavcodec/svq3.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-21 16:18:29 +01:00
Michael Niedermayer
70eec8f432
Merge commit ' 47a0d39350'
...
* commit '47a0d39350 ':
h264: move mb_skip_run into the per-slice context
Conflicts:
libavcodec/h264_cavlc.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-21 16:09:14 +01:00
Michael Niedermayer
4c5c913dd8
Merge commit ' e7226984ac'
...
* commit 'e7226984ac ':
h264: move [{top,left}_]cbp into the per-slice context
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-21 15:48:13 +01:00
Michael Niedermayer
739edc1a7e
Merge commit ' bf03a878a7'
...
* commit 'bf03a878a7 ':
h264: move mb[_{padding,luma_dc}] into the per-slice context
Conflicts:
libavcodec/h264.h
libavcodec/h264_cavlc.c
libavcodec/h264_mb.c
libavcodec/h264_slice.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-21 15:36:57 +01:00
Michael Niedermayer
35a788d953
Merge commit ' b063582e0c'
...
* commit 'b063582e0c ':
h264: move intra_pcm_ptr into the per-slice context
Conflicts:
libavcodec/h264.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-21 15:27:29 +01:00