summaryrefslogtreecommitdiff
path: root/libavcodec/cfhddata.c
Commit message (Collapse)AuthorAgeFilesLines
* avcodec/cfhddata: Reduce stack usageAndreas Rheinhardt2022-09-051-24/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Creating CFHD RL VLC tables works by first extending the codes by the sign, followed by creating a VLC, followed by deriving the RL VLC from this VLC (which is then discarded). Extending the codes uses stack arrays. The tables used to initialize the VLC are already sorted from left-to-right in the tree. This means that the corresponding VLC entries are generally also ascending, but not always: Entries from subtables always follow the corresponding main table although it is possible for the right-most node to fit into the main table. This suggests that one can try to use the final destination buffer as scratch buffer for the tables with sign included. Unfortunately it works for neither of the tables if one uses the right-most part of the RL VLC buffer as scratch buffer; using the left-most part of the RL VLC buffer as scratch buffer might work if one traverses the VLC entries from end to start. But it works only for the little RL VLC (table 9), not for table 18. Therefore this patch uses the RL VLC buffer for table 9 as scratch buffer for creating the bigger table 18. Afterwards the left part of the buffer for table 9 is used as scratch buffer to create table 9. This fixes the cfhd part of ticket #9399 (if it is not already fixed). Notice that I do not consider the previous stack usage excessive. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/cfhd, cfhddata: Free VLC as soon as it is not neededAndreas Rheinhardt2022-09-051-7/+10
| | | | | | | The VLC is only used to initialize RL VLC. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/cfhddata: Avoid code duplication when creating codebooksAndreas Rheinhardt2022-09-051-55/+39
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/cfhddata: Avoid code tablesAndreas Rheinhardt2022-09-051-261/+111
| | | | | | | | | | | | | | | | | | | | | | | | | cfhddata.c initializes a RL VLC table via code tables and corresponding tables for length, run and level. code and length tables are used to initialize a VLC, no symbol table is used. Afterwards the symbols of said VLC are just the indices of the corresponding entries in the code and length table that were used for initialization; they can therefore be used to get the matching level and run entry and they are not used for anything else. Therefore one can just permute these tables without changing the resulting RL VLC tables. This commit does just this. It permutes these tables so that the code tables are ordered from left to right in the resulting tree and then switches to ff_init_vlc_from_lengths(), which allows to remove the codes table altogether. Given that these tables are constructed on the stack, this also reduces stack usage, potentially fixing part of #9399. (The size of the tables on the stack decreases from 4752 to 2640.) Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/cfhd, cfhddata: Simplify check for escapeAndreas Rheinhardt2022-09-051-2/+2
| | | | | | | | | | | | | | cfhd.c checked for level being equal to a certain codebook- dependent constant and to run being two. The first check is actually redundant, as all codebooks contain only one (real) entry with run == 2 (as is usual with VLCs, this one real entry has several corresponding entries in the table). But given that no entry has a run of zero (except incomplete entries which just signal that one needs to do another round of parsing), one can actually use that as sentinel. This patch does so. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/cfhd: fix escape handling for old codebookPaul B Mahol2022-09-031-1/+1
|
* avcodec/cfhddata: remove unused definesPaul B Mahol2022-09-031-8/+0
|
* avcodec/vlc: Use structure instead of VLC_TYPE array as VLC elementAndreas Rheinhardt2022-06-171-4/+4
| | | | | | | | | | | | | | | | | | 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>
* Merge commit '5f794aa1653aa04c1da7397e9ccacad947fadf5f'James Almer2017-10-171-80/+128
|\ | | | | | | | | | | | | | | | | | | | | | | * commit '5f794aa1653aa04c1da7397e9ccacad947fadf5f': Add Cineform HD Decoder See 3485332bf99602910fe8830b0230d02fc653135d. Some cosmetics are merged. The refactoring is not merged at the request of Kieran Kunhya. Merged-by: James Almer <jamrial@gmail.com>
| * Add Cineform HD DecoderKieran Kunhya2017-03-091-0/+337
| | | | | | | | | | Decodes YUV 4:2:2 10-bit and RGB 12-bit files. Older files with more subbands, skips, Bayer, alpha not supported. Further fixes and refactorings by Anton Khirnov <anton@khirnov.net>, Diego Biurrun <diego@biurrun.de>, Vittorio Giovara <vittorio.giovara@gmail.com> Signed-off-by: Diego Biurrun <diego@biurrun.de>
* avcodec: Cineform HD DecoderKieran Kunhya2016-01-301-0/+323
Decodes YUV 4:2:2 10-bit and RGB 12-bit files. Older files with more subbands, skips, Bayer, alpha not supported. Alpha requires addition of GBRAP12 pixel format.