summaryrefslogtreecommitdiff
path: root/libavcodec/vc1_block.c
Commit message (Collapse)AuthorAge
* avcodec/vc1: Avoid superfluous VLC structuresAndreas Rheinhardt2023-10-31
| | | | | | | | | | | For all VLCs here, the number of bits of the VLC is write-only, because it is hardcoded at the call site. Therefore one can replace these VLC structures with the only thing that is actually used: The pointer to the VLCElem table. And in some cases one can even avoid this. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/msmpeg4_vc1_data: Avoid superfluous VLC structuresAndreas Rheinhardt2023-10-31
| | | | | | | | | | 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. Also combine the ff_msmp4_dc_(luma|chroma)_vlcs as well as the tables used to generate them to simplify the code. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/vc1_block: Remove redundant writeAndreas Rheinhardt2022-11-06
| | | | | | | | | vc1_decode_skip_blocks() is only called if the current picture is a P frame. So setting pict_type to AV_PICTURE_TYPE_P is redundant; removing it makes pict_type read-only in vc1_block.c (as it should be). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/msmpeg4data: Move data shared between msmpeg4 and VC-1 outAndreas Rheinhardt2022-11-06
| | | | | | | | This is in preparation for splitting VC-1 from msmpeg4. (msmpeg4data.c was originally intended to be just this; 9488b966c76a7a52e9a1f7756bda82dbe1070399 changed it). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/vc1_block: Don't duplicate #definesAndreas Rheinhardt2022-11-06
| | | | | | | | | | VC1 shares some VLCs with MSMPEG-4, but vc1_block.c simply duplicates the defines instead of including the appropriate headers; furthermore, use a proper prefix for these defines: DC_VLC_BITS is also used by other codecs. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/vc1_block: Remove dead calls to ff_mpeg_draw_horiz_band()Andreas Rheinhardt2022-10-20
| | | | | | The VC-1 decoders don't support draw_horiz_band at all. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Inline values in ff_update_block_index()Andreas Rheinhardt2022-07-31
| | | | | | | | | This is possible for most of the callers, because e.g. only the MPEG-4 decoder can have bits_per_raw_sample > 8. Also most mpegvideo-based codecs are 420 only. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Move decoder-only stuff to a new headerAndreas Rheinhardt2022-02-13
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/vc1_pred: Remove unused function parameterAndreas Rheinhardt2021-10-02
| | | | | Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/msmpeg4dec: Don't check for errors for complete VLCsAndreas Rheinhardt2021-01-29
| | | | | | | This also affected other users of VLCs from msmpeg4dec, namely vc1_block and wmv2dec. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/vc1_block: Fix integer overflow in ac valueMichael Niedermayer2020-10-02
| | | | | | | | Fixes: signed integer overflow: 25488 * 87381 cannot be represented in type 'int' Fixes: 24765/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1_fuzzer-5108259565076480 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* libavcodec/vc1: Remove bits variableMichael Niedermayer2020-01-11
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1_block: Fix integer overflow in AC rescaling in ↵Michael Niedermayer2019-12-01
| | | | | | | | | | vc1_decode_i_block_adv() Fixes: signed integer overflow: 50176 * 262144 cannot be represented in type 'int' Fixes: 18629/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-5182370286403584 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1_block: Fix undefined behavior in ac prediction rescalingMichael Niedermayer2019-11-20
| | | | | | | | | | | The intermediates are required to fit in 12bit (8.1.3.9 Coefficient Scaling) See SMPTE 421M-2006 and Amendment 1-2007 Fixes: signed integer overflow: -20691 * 262144 cannot be represented in type 'int' Fixes: 18479/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1_fuzzer-5128912371187712 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1_block: Check input in the block decode loopsMichael Niedermayer2019-11-09
| | | | | | | | Fixes: Timeout (196sec -> 2sec) Fixes: 18026/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1_fuzzer-5640941108461568 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1_block: Check for end of bitstream at the top of ↵Michael Niedermayer2019-11-09
| | | | | | | | | | vc1_decode_i_blocks_adv() Fixes: Timeout (147sec -> 2sec) Fixes: 17704/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-5723851098423296 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1_block: Fixes integer overflow in vc1_decode_i_block_adv()Michael Niedermayer2019-10-20
| | | | | | | | Fixes: signed integer overflow: 62220 * 262144 cannot be represented in type 'int' Fixes: 17145/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-5667394743173120 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1_block: Fix invalid left shift in vc1_decode_p_mb()Michael Niedermayer2019-10-03
| | | | | | | | | Fixes: left shift of negative value -6 Fixes: 17810/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1_fuzzer-5638541240958976 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>
* avcodec/vc1_block: Fix invalid shift with rangeredfrmMichael Niedermayer2019-09-28
| | | | | | | | Fixes: left shift of negative value -7 Fixes: 16959/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV3_fuzzer-5200360825683968 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1_block: Check the return code from vc1_decode_p_block()Michael Niedermayer2019-08-31
| | | | | | | | | Fixes: left shift of negative value -1 Fixes: 16424/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV3_fuzzer-5656579055026176 Fixes: 16358/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-5714436358144000 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1_block: Check for double escapesMichael Niedermayer2019-08-31
| | | | | | | | Fixes: out of array read Fixes: 16331/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV3IMAGE_fuzzer-5672735195267072 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1_block: Fix invalid shifts in vc1_decode_i_blocks()Michael Niedermayer2019-08-11
| | | | | | | | | Fixes: left shift of negative value -9 Fixes: 15299/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MSS2_fuzzer-5660922678345728 Fixes: 15557/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-5673351911047168 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1_block: fix invalid shift in vc1_decode_p_mb()Michael Niedermayer2019-08-11
| | | | | | | | Fixes: left shift of negative value -5 Fixes: 15294/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1_fuzzer-5733921754447872 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1_block: Check get_vlc2() return before useMichael Niedermayer2019-08-05
| | | | | | | | Fixes: index -1 out of bounds for type 'const uint8_t [185][2]' Fixes: 15720/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MSS2_fuzzer-5666071933091840 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1_block: Fix integer overflow in ff_vc1_pred_dc()Michael Niedermayer2019-07-31
| | | | | | | | Fixes: signed integer overflow: 32796 * 65536 cannot be represented in type 'int' Fixes: 15430/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-5735424087031808 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1_block: Check for vlc error in vc1_decode_ac_coeff()Michael Niedermayer2019-07-08
| | | | | | | | Fixes: index -1 out of bounds for type 'const uint8_t [185][2]' Fixes: 15250/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV3IMAGE_fuzzer-5648992869810176 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1_block: Fix mqaunt check for negative valuesMichael Niedermayer2018-06-30
| | | | | | | | | | | Fixes: out of array access Fixes: ffmpeg_bof_4.avi Fixes: ffmpeg_bof_5.avi Fixes: ffmpeg_bof_6.avi Found-by: Thuan Pham, Marcel Böhme, Andrew Santosa and Alexandru Razvan Caciulescu with AFLSmart Reviewed-by: Jerome Borsboom <jerome.borsboom@carpalis.nl> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1: change the internal ordering of blocks within a macroblockJerome Borsboom2018-06-29
| | | | | | | | | | The overlap filter needs to cover a full macroblock vertical edge when the FIELDTX value for two neighbouring macroblocks is not equal. By changing the internal ordering of the blocks from row major to column major, we do not need to reinterlace a FIELDTX coded macroblock before running the overlap filter. Signed-off-by: Jerome Borsboom <jerome.borsboom@carpalis.nl>
* avcodec/vc1: fix condition guarding overlap filter on I pictureJerome Borsboom2018-06-29
| | | | | | | The overlap filter needs to run when PQUANT is 9 or higher, irrespective of CONDOVER. Signed-off-by: Jerome Borsboom <jerome.borsboom@carpalis.nl>
* avcodec/vc1: rewrite vc1_decode_i_blocks to align with VC-1 specJerome Borsboom2018-06-18
| | | | | | | Change vc1_decode_i_blocks to use vc1_put_blocks_clamped and ff_vc1_i_loop_filter. Signed-off-by: Jerome Borsboom <jerome.borsboom@carpalis.nl>
* avcodec/vc1: add Simple and Main profile to vc1_put_signed_blocks_clampedJerome Borsboom2018-06-18
| | | | | | | | Simple and Main Profile also need unsigned put_pixels_clamped. Add an argument to choose between signed and unsigned put_pixels and change function name to vc1_put_blocks_clamped. Signed-off-by: Jerome Borsboom <jerome.borsboom@carpalis.nl>
* Revert "avcodec/vc1: add Simple and Main profile to ↵Carl Eugen Hoyos2018-06-18
| | | | | | | | | vc1_put_signed_blocks_clamped" This reverts commit 2065317db6dc3a219f8ed2de427fe7e19e02eb68. I committed a wrong version of this patch. Also reverts the follow-up commits 77a3dfb3 and 8331e591.
* avcodec/vc1: rewrite vc1_decode_i_blocks to align with VC-1 specJerome Borsboom2018-06-16
| | | | | | | Change vc1_decode_i_blocks to use vc1_put_blocks_clamped and ff_vc1_i_loop_filter. Signed-off-by: Jerome Borsboom <jerome.borsboom@carpalis.nl>
* avcodec/vc1: add Simple and Main profile to vc1_put_signed_blocks_clampedJerome Borsboom2018-06-16
| | | | | | | | Simple and Main profile also need unsigned put_pixels_clamped. Add an argument to choose between signed and unsigned put_pixels and change function name to vc1_put_blocks_clamped. Signed-off-by: Jerome Borsboom <jerome.borsboom@carpalis.nl>
* avcodec/vc1: store zero MVs for all blocks in a MBJerome Borsboom2018-05-28
| | | | | | | | Direct prediction for interlace frame B pictures references the mv in the second block in an MB in the backward reference frame for the twomv case. When the backward reference frame is an I frame, this value may be unset. Signed-off-by: Jerome Borsboom <jerome.borsboom@carpalis.nl>
* avcodec/vc1: fix mquant calculation for interlace field picturesJerome Borsboom2018-05-28
| | | | | | | | | For interlace field pictures s->mb_height indicates the height of the full picture in MBs, i.e. the two fields combined. A single field is half this size. When calculating mquant for interlace field pictures, the bottom edge is the last MB row of the field. Signed-off-by: Jerome Borsboom <jerome.borsboom@carpalis.nl>
* avcodec/vc1: DIRECTBIT is only present in inter MBsJerome Borsboom2018-05-20
| | | | | | | | | DIRECTBIT was decoded before the intra/inter MB branching when decoding interlace frame B pictures. Resulting in mistakenly also decoding it for intra MBs where this syntax element is not present. Signed-off-by: Jerome Borsboom <jerome.borsboom@carpalis.nl> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1: fix mquant calculationJerome Borsboom2018-04-29
| | | | | | | | | | | | In vc1_decode_i_blocks_adv mquant needs to be reset to its default value for each macroblock, instead of once at the beginning of the slice. DQPROFILE specifies which macroblocks can have an alternative quantizer step size. When DQPROFILE specifies edges, the selection is applicable to the edges of the picture. Slice edges are not selected by DQPROFILE. Signed-off-by: Jerome Borsboom <jerome.borsboom@carpalis.nl> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1: more corrections for AC inverse quantization scalingJerome Borsboom2018-04-25
| | | | | | | | | | | HALFQP should only be added to the inverse quantizer when the block is coded with PQUANT. When PQUANT is equal to ALTPQUANT, the original test for the addition of HALFQP fails. A negative value for mquant indicates that the value was derived from VOPDQUANT. Fixes #4372 Signed-off-by: Jerome Borsboom <jerome.borsboom@carpalis.nl>
* avcodec/vc1: correct AC inverse quantization scalingJerome Borsboom2018-04-25
| | | | | | | HALFQP should only be added to the inverse quantizer when the block is coded with PQUANT. See 8.1.3.8 in VC-1 spec. Signed-off-by: Jerome Borsboom <jerome.borsboom@carpalis.nl>
* avcodec/vc1: add overlap smooting and loop filter for frame/field-interlaceJerome Borsboom2018-04-25
| | | | | | | | Add previously omitted overlap smooting and loop filtering for frame/field-interlace pictures. For progressive pictures switch to the re-implemented versions of overlap smooting and loop filtering. Signed-off-by: Jerome Borsboom <jerome.borsboom@carpalis.nl>
* avcodec/vc1: re-implement vc1_put_signed_blocks_clampedJerome Borsboom2018-04-25
| | | | | | | | The existing implementation only used vc1_put_signed_blocks_clamped for I and BI frames. This rewritten version is also applicable to P frame both progressive and frame/field-interlace. Signed-off-by: Jerome Borsboom <jerome.borsboom@carpalis.nl>
* avcodec/vc1: store additional bitstream elements during MB decodingJerome Borsboom2018-04-25
| | | | | | | The new loop filter needs additional MB properties to make its filtering decisions. Signed-off-by: Jerome Borsboom <jerome.borsboom@carpalis.nl>
* avcodec/vc1: change to using v->block instead of s->block for P framesJerome Borsboom2018-04-25
| | | | | | | | | The new overlap smooting filter smoothes image pixels stored in v->block. Switch to v->block instead of s->block for storing decoded image pixels for P frames. Additionally, we must take incrementing *_blk_idx out of the vc1_put_signed_blocks_clamped function. Signed-off-by: Jerome Borsboom <jerome.borsboom@carpalis.nl>
* avcodec/vc1_block: simplify ac_val computationMichael Niedermayer2018-04-24
| | | | | | | | also fixes: runtime error: index 1456 out of bounds for type 'int16_t [16]' Found-by: durandal_1707 Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Merge commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb'Clément Bœsch2016-06-21
|\ | | | | | | | | | | | | * commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb': cosmetics: Fix spelling mistakes Merged-by: Clément Bœsch <u@pkh.me>
| * cosmetics: Fix spelling mistakesVittorio Giovara2016-05-04
| | | | | | | | Signed-off-by: Diego Biurrun <diego@biurrun.de>
* | Merge commit 'c2084ffcbfc11d1b6ed3a4a0df9cafd56fbb896f'Derek Buitenhuis2016-05-07
|\| | | | | | | | | | | | | * commit 'c2084ffcbfc11d1b6ed3a4a0df9cafd56fbb896f': intrax8: Use the generic horizband function Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
| * intrax8: Use the generic horizband functionVittorio Giovara2016-03-29
| | | | | | | | | | This is assuming that intrax8 has no support for interlacing Carry over lowdelay value in ff_intrax8_decode_picture.
* | Merge commit 'b1268e0f032a3af3912fe3fb8d3855e12d7ea83b'Derek Buitenhuis2016-05-07
|\| | | | | | | | | | | | | * commit 'b1268e0f032a3af3912fe3fb8d3855e12d7ea83b': intrax8: Pass macroblock coordinates to ff_intrax8_decode_picture Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>