mirror of https://github.com/FFmpeg/FFmpeg.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
2.2 KiB
75 lines
2.2 KiB
3 months ago
|
/*
|
||
|
* FFv1 codec
|
||
|
*
|
||
|
* Copyright (c) 2024 Lynne <dev@lynne.ee>
|
||
|
*
|
||
|
* 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
|
||
|
*/
|
||
|
|
||
|
struct SliceContext {
|
||
|
RangeCoder c;
|
||
|
|
||
|
#ifdef GOLOMB
|
||
|
PutBitContext pb; /* 8*8 bytes */
|
||
|
#endif
|
||
|
|
||
|
ivec2 slice_dim;
|
||
|
ivec2 slice_pos;
|
||
|
ivec2 slice_rct_coef;
|
||
|
|
||
|
uint hdr_len; // only used for golomb
|
||
|
int slice_coding_mode;
|
||
|
};
|
||
|
|
||
|
/* -1, { -1, 0 } */
|
||
|
int predict(int L, ivec2 top)
|
||
|
{
|
||
|
return mid_pred(L, L + top[1] - top[0], top[1]);
|
||
|
}
|
||
|
|
||
|
/* { -2, -1 }, { -1, 0, 1 }, 0 */
|
||
|
int get_context(VTYPE2 cur_l, VTYPE3 top_l, TYPE top2, uint8_t quant_table_idx)
|
||
|
{
|
||
|
const int LT = top_l[0]; /* -1 */
|
||
|
const int T = top_l[1]; /* 0 */
|
||
|
const int RT = top_l[2]; /* 1 */
|
||
|
const int L = cur_l[1]; /* -1 */
|
||
|
|
||
|
int base = quant_table[quant_table_idx][0][(L - LT) & MAX_QUANT_TABLE_MASK] +
|
||
|
quant_table[quant_table_idx][1][(LT - T) & MAX_QUANT_TABLE_MASK] +
|
||
|
quant_table[quant_table_idx][2][(T - RT) & MAX_QUANT_TABLE_MASK];
|
||
|
|
||
|
if ((quant_table[quant_table_idx][3][127] == 0) &&
|
||
|
(quant_table[quant_table_idx][4][127] == 0))
|
||
|
return base;
|
||
|
|
||
|
const int TT = top2; /* -2 */
|
||
|
const int LL = cur_l[0]; /* -2 */
|
||
|
return base +
|
||
|
quant_table[quant_table_idx][3][(LL - L) & MAX_QUANT_TABLE_MASK] +
|
||
|
quant_table[quant_table_idx][4][(TT - T) & MAX_QUANT_TABLE_MASK];
|
||
|
}
|
||
|
|
||
|
const uint32_t log2_run[41] = {
|
||
|
0, 0, 0, 0, 1, 1, 1, 1,
|
||
|
2, 2, 2, 2, 3, 3, 3, 3,
|
||
|
4, 4, 5, 5, 6, 6, 7, 7,
|
||
|
8, 9, 10, 11, 12, 13, 14, 15,
|
||
|
16, 17, 18, 19, 20, 21, 22, 23,
|
||
|
24,
|
||
|
};
|