FFmpeg
Loading...
Searching...
No Matches
cavs_aec.c
Go to the documentation of this file.
1/*
2 * Chinese AVS video (AVS1-P16, Broadcasting profile) AEC decoder.
3 * Copyright (c) 2026 Rainbaby <r@bgr.jp>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22/**
23 * @file
24 * Chinese AVS video (AVS1-P16, Broadcasting profile) AEC decoder
25 *
26 * Clause numbers refer to GY/T 257.1-2012. The renormalization loops end
27 * with the buffer, so truncated input terminates. The caller must have
28 * removed the annex A pseudo start codes from the payload.
29 */
30
31#include <stdint.h>
32
33#include "cavs_aec.h"
34#include "get_bits.h"
35
37{
38 for (int i = 0; i < CAVS_AEC_NUM_CTX; i++) {
39 aec->ctx[i].mps = 0;
40 aec->ctx[i].cycno = 0;
42 }
43
44 aec->gb = gb;
45 aec->rs1 = 0;
47 aec->vs = 0;
48 aec->vt = get_bits(gb, 9);
49 while (!((aec->vt >> 8) & 0x01) && get_bits_left(gb) > 0) {
50 aec->vt = (aec->vt << 1) | get_bits1(gb);
51 aec->vs++;
52 }
53 aec->vt &= 0xFF;
54}
void ff_cavs_aec_init(CAVSAECContext *aec, GetBitContext *gb)
Reset all contexts and start the decoder on byte aligned gb (8.4.1).
Definition cavs_aec.c:36
Chinese AVS video (AVS1-P16, Broadcasting profile) AEC decoder.
#define CAVS_AEC_RT1_INIT
Definition cavs_aec.h:74
#define CAVS_AEC_LGPMPS_INIT
Definition cavs_aec.h:69
#define CAVS_AEC_NUM_CTX
Definition cavs_aec.h:40
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
bitstream reader API header.
static int get_bits_left(GetBitContext *gb)
Definition get_bits.h:688
static unsigned int get_bits1(GetBitContext *s)
Definition get_bits.h:391
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition get_bits.h:337
int vs
offset exponent (valueS)
Definition cavs_aec.h:63
GetBitContext * gb
bitstream reader, shared with the slice parser
Definition cavs_aec.h:60
CAVSAECModel ctx[CAVS_AEC_NUM_CTX]
context models, 8.4.2.1
Definition cavs_aec.h:65
int rt1
range mantissa, init 0xFF (rT1)
Definition cavs_aec.h:62
int rs1
range exponent, init 0 (rS1)
Definition cavs_aec.h:61
int vt
offset mantissa, 9 bits inside a call (valueT)
Definition cavs_aec.h:64
uint8_t mps
mps: more probable symbol, 1 bit, init 0
Definition cavs_aec.h:54
uint8_t cycno
cycno: adaptation counter, 2 bits, init 0
Definition cavs_aec.h:55
uint16_t lg_pmps
lgPmps: log domain P(MPS), 11 bits, init 1023
Definition cavs_aec.h:56