边缘性行为包括什么| 悦字属于五行属什么| 脾大是什么病| 办离婚证需要带什么证件| 铲垃圾的工具叫什么| 什么的彩虹| 总胆红素偏高是什么引起的| 孕期吃什么好| 喝什么茶能减肥| 5月4日是什么星座| 521是什么星座的| 薤是什么菜图片| 往事不堪回首是什么意思| 贾字五行属什么| 维生素b2有什么功效| 楚楚动人是什么意思| 尿葡萄糖阴性什么意思| 腺瘤样增生是什么意思| 皮肤有白点是什么原因| 鱼鳞云有什么预兆| 夏天喝什么饮料好| 牛鬼蛇神指什么生肖| 缺钾吃什么食物| 上海话十三点是什么意思| 爱而不得是什么感觉| 肾阴虚吃什么药| 为什么不建议吃大豆油| 心脏由什么组织构成| 大肠在人体什么位置图| 乌冬面是什么做的| 小孩嘴臭是什么原因| 什么的旅行| 孕妇吃什么好| 梦见跳舞是什么意思| 深圳市长什么级别| 疯狂动物城树懒叫什么| 蒽是什么意思| 环状肉芽肿是什么皮肤病| 一日清闲一日仙是什么生肖| 肺炎吃什么药| 月经不来要吃什么药| ecl是什么意思| 印度为什么用手吃饭| 孩子注意力不集中去医院看什么科| 物以类聚形容什么动物| 手术后吃什么鱼伤口愈合快| 什么血型招蚊子| wis是什么牌子| 天才是什么意思| 脚气应该挂什么科| 血压低吃什么东西好| 波罗蜜多什么意思| 毓婷是什么药| 湿疹用什么| svc是什么意思| wt什么意思| 右胸痛什么原因| 骨折后吃什么食物促进骨头愈合| 女人适合喝什么茶最好| 月出念什么| 一起共勉是什么意思| 放疗化疗有什么区别| 气血不足什么引起的| 决明子泡水喝有什么功效| 什么牌子的风扇好| 薇字五行属什么| 弥勒佛为什么是未来佛| 什么是肝阳上亢| 恩字五行属什么| 炒什么菜好吃又简单| bdp是什么意思| 无国界医生是什么意思| br是什么元素| 女人下巴长痘痘是什么原因| 失眠吃什么食物效果最好| 内敛是什么意思| 回民不吃什么| 手指尖麻木是什么原因| 什么是高原反应| 喝酒前吃什么不会醉| 天生一对成伴侣是什么生肖| 肾在五行中属什么| 三世诸佛是什么意思| 尿亚硝酸盐阳性是什么意思| 偏旁和部首有什么区别| 痛风性关节炎吃什么药| 什么的温度| 氪金什么意思| 夏天喝什么水最好| 想吐头晕是什么原因| 肉刺长什么样子图片| 爽约什么意思| 瘦的人吃什么才能变胖| 喝什么可以排便通畅| 国花是什么花| nicole是什么意思| 摩羯座女和什么座最配| 腰上长痘痘是什么原因| 神经内科主要看什么病| 吃什么食物能降低胆固醇| 腿抽筋是什么问题| 1月13是什么星座| 月子中心需要什么资质| 内鬼是什么意思| 眼睛雾化的作用是什么| 什么手机最贵| 胸有成竹什么意思| 卵泡不破是什么原因造成的| 为什么低血压| 什么动物最容易摔倒| 低gi是什么意思| 什么是肾功能不全| 儿童流鼻涕吃什么药| 老打嗝是什么原因| 朝阳是什么意思| 做梦笑出声是什么预兆| 什么叫唐卡| 冗长是什么意思| 经常放屁什么原因| 汉语拼音是什么时候发明的| 叩齿是什么意思| 俄罗斯为什么要打乌克兰| 舌苔发黄是什么症状| 怀孕什么东西不能吃| 蟑螂讨厌什么味道| m2是什么意思| 血管瘤有什么危害吗| 85属什么生肖| 感冒吃什么水果好得快| cin3是什么意思| 柔然人是现在的什么人| 昆仑山在什么地方| 二月初四是什么星座| 眼压高是什么症状| 蚂蚁为什么要搬家| 多读书有什么好处| 栗子不能和什么一起吃| 河蚌吃什么| 筑基是什么意思| 胆红素三个指标都高是什么原因| 郭德纲什么学历| 6月16日什么星座| 偏头疼吃什么药| 乳腺实性结节是什么意思| 拉黄尿是什么原因| 力不从心的意思是什么| 糖类抗原50是什么指标| 做梦梦见剪头发是什么意思| 何首乌长什么样| 少将是什么级别| 京东自营店是什么意思| 大腿前侧肌肉叫什么| 什么什么相什么的成语| 鼻炎吃什么药| 水浒是什么意思| 吃东西感觉口苦是什么原因| 甲状腺与甲亢有什么区别| 手臂有痣代表什么| 肋膈角锐利是什么意思| 分散片是什么意思| 益气养阴是什么意思| 口腔脱皮是什么原因引起的| 脚气挂什么科室| 乌冬面为什么叫乌冬面| 短杆菌是什么意思| 睚眦欲裂什么意思| 梦见打麻将是什么意思| 地贫是什么病| 脊膜瘤是什么样的病| 急性结肠炎什么症状| 人艰不拆是什么意思| poscer是什么牌子手表| 心脏疼是什么感觉| 胸闷是什么原因引起的| 上海为什么叫魔都| 西皮是什么意思| 什么是大健康产业| 益是什么意思| 神什么活什么| 什么的糯米| 代肝是什么意思| 12岁属什么| 九月十七日是什么星座| 山根是什么| 什么生火| 颈椎退行性病变是什么意思| 表姐的儿子叫什么| 敏感是什么意思| 印度为什么叫三哥| 烈士家属有什么待遇| 眼睛蒙蒙的是什么原因| 吃什么药去体内湿气| 长绒棉和全棉什么区别| 国家发改委主任什么级别| 粪便隐血试验弱阳性是什么意思| 手汗脚汗多是什么原因| 脑梗吃什么药最好| 口甜是什么原因引起的| 红豆配什么打豆浆好喝| 为什么脚底会脱皮| 刚需是什么意思| 蜡烛燃烧会产生什么| 什么是阴历什么是阳历| 牙痛吃什么药最有效| 怀孕前三个月应该注意什么| 脾胃虚弱吃什么食物补| 1983年五行属什么| 急性鼻窦炎吃什么药| 侧写是什么意思| 万事顺意是什么意思| 苦瓜吃多了有什么坏处| 甲状腺结节吃什么食物好| 鸽子拉水便是什么原因| 揽子是什么意思| 生津是什么意思| 丁克夫妻是什么意思| 与自己和解什么意思| 白居易是诗什么| 为什么最迷人的最危险是什么歌| 牛腩炖什么好吃| 游车河什么意思| 什么叫做脂肪肝| 尿液有隐血是什么情况| 日落西山是什么生肖| 子宫收缩是什么感觉| 胸闷喘不上气什么原因| 什么叫安置房| 97年属什么的生肖| 人间尤物什么意思| 耳朵发热是什么预兆| 补钾吃什么| 附件炎是什么引起的| 三个小是什么字| 直白是什么意思| 食管炎是什么原因引起的| 地屈孕酮片什么时候吃| 男人阴茎硬不起来是什么原因| 尿的颜色有点红褐色是什么原因| 悬钟为什么叫绝骨| 鬼针草有什么功效| 扁桃体发炎用什么药| 吃什么补钾最快| 六点是什么时辰| 盲袋是什么| 林俊杰什么时候出道的| 小孩脾胃虚弱吃什么药| 杨公忌日是什么意思| 酸菜是什么菜做的| 左侧脖子疼是什么原因| 胰腺在什么位置图片| 酒精胶是粘什么的| 破绽是什么意思| 杨的右边念什么| 消肿吃什么食物好| 吴亦凡属什么生肖| 骨髓捐赠对自己有什么影响没有| 缺钾吃什么药| 688是什么意思| 谷丙转氨酶高是什么原因| 挂是什么意思| 什么是碱性磷酸酶高怎么回事| 肾虚是什么原因引起的| 迪赛尼斯属于什么档次| 橘白猫是什么品种| 百度

小姐姐是什么意思


Directory: ../../../ffmpeg/
File: src/libavcodec/ttaenc.c
Date: 2025-08-04 00:43:16
Exec Total Coverage
Lines: 85 103 82.5%
Functions: 4 4 100.0%
Branches: 39 53 73.6%

Line Branch Exec Source
1 /*
2 * TTA (The Lossless True Audio) encoder
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #define BITSTREAM_WRITER_LE
22 #include "ttadata.h"
23 #include "ttaencdsp.h"
24 #include "avcodec.h"
25 #include "codec_internal.h"
26 #include "encode.h"
27 #include "put_bits.h"
28 #include "libavutil/crc.h"
29 #include "libavutil/mem.h"
30
31 typedef struct TTAEncContext {
32 const AVCRC *crc_table;
33 int bps;
34 TTAChannel *ch_ctx;
35 TTAEncDSPContext dsp;
36 } TTAEncContext;
37
38 3 static av_cold int tta_encode_init(AVCodecContext *avctx)
39 {
40 3 TTAEncContext *s = avctx->priv_data;
41
42 3 s->crc_table = av_crc_get_table(AV_CRC_32_IEEE_LE);
43
44
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 switch (avctx->sample_fmt) {
45 case AV_SAMPLE_FMT_U8:
46 avctx->bits_per_raw_sample = 8;
47 break;
48 3 case AV_SAMPLE_FMT_S16:
49 3 avctx->bits_per_raw_sample = 16;
50 3 break;
51 case AV_SAMPLE_FMT_S32:
52 if (avctx->bits_per_raw_sample > 24)
53 av_log(avctx, AV_LOG_WARNING, "encoding as 24 bits-per-sample\n");
54 avctx->bits_per_raw_sample = 24;
55 }
56
57 3 s->bps = avctx->bits_per_raw_sample >> 3;
58 3 avctx->frame_size = 256 * avctx->sample_rate / 245;
59
60 3 s->ch_ctx = av_malloc_array(avctx->ch_layout.nb_channels, sizeof(*s->ch_ctx));
61
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!s->ch_ctx)
62 return AVERROR(ENOMEM);
63
64 3 ff_ttaencdsp_init(&s->dsp);
65
66 3 return 0;
67 }
68
69 882000 static int32_t get_sample(const AVFrame *frame, int sample,
70 enum AVSampleFormat format)
71 {
72 int32_t ret;
73
74
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 882000 times.
882000 if (format == AV_SAMPLE_FMT_U8) {
75 ret = frame->data[0][sample] - 0x80;
76
1/2
✓ Branch 0 taken 882000 times.
✗ Branch 1 not taken.
882000 } else if (format == AV_SAMPLE_FMT_S16) {
77 882000 const int16_t *ptr = (const int16_t *)frame->data[0];
78 882000 ret = ptr[sample];
79 } else {
80 const int32_t *ptr = (const int32_t *)frame->data[0];
81 ret = ptr[sample] >> 8;
82 }
83
84 882000 return ret;
85 }
86
87 8 static int tta_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
88 const AVFrame *frame, int *got_packet_ptr)
89 {
90 8 TTAEncContext *s = avctx->priv_data;
91 PutBitContext pb;
92 int ret, i, out_bytes, cur_chan, res, samples;
93 8 int64_t pkt_size = frame->nb_samples * 2LL * avctx->ch_layout.nb_channels * s->bps;
94
95 8 pkt_alloc:
96 8 cur_chan = 0, res = 0, samples = 0;
97
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
8 if ((ret = ff_alloc_packet(avctx, avpkt, pkt_size)) < 0)
98 return ret;
99 8 init_put_bits(&pb, avpkt->data, avpkt->size);
100
101 // init per channel states
102
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 8 times.
22 for (i = 0; i < avctx->ch_layout.nb_channels; i++) {
103 14 s->ch_ctx[i].predictor = 0;
104 14 ff_tta_filter_init(&s->ch_ctx[i].filter, ff_tta_filter_configs[s->bps - 1]);
105 14 ff_tta_rice_init(&s->ch_ctx[i].rice, 10, 10);
106 }
107
108
2/2
✓ Branch 0 taken 617400 times.
✓ Branch 1 taken 8 times.
617408 for (i = 0; i < frame->nb_samples * avctx->ch_layout.nb_channels; i++) {
109 617400 TTAChannel *c = &s->ch_ctx[cur_chan];
110 617400 TTAFilter *filter = &c->filter;
111 617400 TTARice *rice = &c->rice;
112 uint32_t k, unary, outval;
113 int32_t value, temp;
114
115 617400 value = get_sample(frame, samples++, avctx->sample_fmt);
116
117
2/2
✓ Branch 0 taken 529200 times.
✓ Branch 1 taken 88200 times.
617400 if (avctx->ch_layout.nb_channels > 1) {
118
2/2
✓ Branch 0 taken 264600 times.
✓ Branch 1 taken 264600 times.
529200 if (cur_chan < avctx->ch_layout.nb_channels - 1)
119 264600 value = res = get_sample(frame, samples, avctx->sample_fmt) - value;
120 else
121 264600 value -= res / 2;
122 }
123
124 617400 temp = value;
125 #define PRED(x, k) (int32_t)((((uint64_t)(x) << (k)) - (x)) >> (k))
126
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 617400 times.
✗ Branch 2 not taken.
617400 switch (s->bps) {
127 case 1: value -= PRED(c->predictor, 4); break;
128 617400 case 2:
129 617400 case 3: value -= PRED(c->predictor, 5); break;
130 }
131 617400 c->predictor = temp;
132
133 617400 s->dsp.filter_process(filter->qm, filter->dx, filter->dl, &filter->error, &value,
134 filter->shift, filter->round);
135
2/2
✓ Branch 0 taken 223671 times.
✓ Branch 1 taken 393729 times.
617400 outval = (value > 0) ? (value << 1) - 1: -value << 1;
136
137 617400 k = rice->k0;
138
139 617400 rice->sum0 += outval - (rice->sum0 >> 4);
140
4/4
✓ Branch 0 taken 483852 times.
✓ Branch 1 taken 133548 times.
✓ Branch 2 taken 17694 times.
✓ Branch 3 taken 466158 times.
617400 if (rice->k0 > 0 && rice->sum0 < ff_tta_shift_16[rice->k0])
141 17694 rice->k0--;
142
2/2
✓ Branch 0 taken 17600 times.
✓ Branch 1 taken 582106 times.
599706 else if (rice->sum0 > ff_tta_shift_16[rice->k0 + 1])
143 17600 rice->k0++;
144
145
2/2
✓ Branch 0 taken 257183 times.
✓ Branch 1 taken 360217 times.
617400 if (outval >= ff_tta_shift_1[k]) {
146 257183 outval -= ff_tta_shift_1[k];
147 257183 k = rice->k1;
148
149 257183 rice->sum1 += outval - (rice->sum1 >> 4);
150
4/4
✓ Branch 0 taken 253882 times.
✓ Branch 1 taken 3301 times.
✓ Branch 2 taken 7967 times.
✓ Branch 3 taken 245915 times.
257183 if (rice->k1 > 0 && rice->sum1 < ff_tta_shift_16[rice->k1])
151 7967 rice->k1--;
152
2/2
✓ Branch 0 taken 7889 times.
✓ Branch 1 taken 241327 times.
249216 else if (rice->sum1 > ff_tta_shift_16[rice->k1 + 1])
153 7889 rice->k1++;
154
155 257183 unary = 1 + (outval >> k);
156
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 257183 times.
257183 if (unary + 100LL > put_bits_left(&pb)) {
157 if (pkt_size < INT_MAX/2) {
158 pkt_size *= 2;
159 av_packet_unref(avpkt);
160 goto pkt_alloc;
161 } else
162 return AVERROR(ENOMEM);
163 }
164 do {
165
2/2
✓ Branch 0 taken 580 times.
✓ Branch 1 taken 257183 times.
257763 if (unary > 31) {
166 580 put_bits(&pb, 31, 0x7FFFFFFF);
167 580 unary -= 31;
168 } else {
169 257183 put_bits(&pb, unary, (1U << unary) - 1);
170 257183 unary = 0;
171 }
172
2/2
✓ Branch 0 taken 580 times.
✓ Branch 1 taken 257183 times.
257763 } while (unary);
173 }
174
175 617400 put_bits(&pb, 1, 0);
176
177
2/2
✓ Branch 0 taken 481630 times.
✓ Branch 1 taken 135770 times.
617400 if (k)
178 481630 put_bits(&pb, k, outval & (ff_tta_shift_1[k] - 1));
179
180
2/2
✓ Branch 0 taken 264600 times.
✓ Branch 1 taken 352800 times.
617400 if (cur_chan < avctx->ch_layout.nb_channels - 1)
181 264600 cur_chan++;
182 else
183 352800 cur_chan = 0;
184 }
185
186 8 flush_put_bits(&pb);
187 8 out_bytes = put_bytes_output(&pb);
188 8 put_bits32(&pb, av_crc(s->crc_table, UINT32_MAX, avpkt->data, out_bytes) ^ UINT32_MAX);
189 8 flush_put_bits(&pb);
190
191 8 avpkt->size = out_bytes + 4;
192 8 *got_packet_ptr = 1;
193 8 return 0;
194 }
195
196 3 static av_cold int tta_encode_close(AVCodecContext *avctx)
197 {
198 3 TTAEncContext *s = avctx->priv_data;
199 3 av_freep(&s->ch_ctx);
200 3 return 0;
201 }
202
203 const FFCodec ff_tta_encoder = {
204 .p.name = "tta",
205 CODEC_LONG_NAME("TTA (True Audio)"),
206 .p.type = AVMEDIA_TYPE_AUDIO,
207 .p.id = AV_CODEC_ID_TTA,
208 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME |
209 AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
210 .priv_data_size = sizeof(TTAEncContext),
211 .init = tta_encode_init,
212 .close = tta_encode_close,
213 FF_CODEC_ENCODE_CB(tta_encode_frame),
214 CODEC_SAMPLEFMTS(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32),
215 };
216

硬汉是什么意思 520是什么日子 硝酸酯类药物有什么药 补钙什么季节补最好 一览无余是什么意思
有尿意但是尿不出来是什么原因 福建有什么特产 酒精和碘伏有什么区别 qid医学上是什么意思 七月十五是什么节
发飙是什么意思 梦见小女孩是什么意思 膀胱炎看什么科 做什么生意最赚钱 豆花是什么
疱疹长什么样子图片 职业病是什么意思 减肥有什么方法 肾阴虚是什么原因造成的 泳帽什么材质的好
胎儿左心室强光斑是什么意思hcv8jop3ns5r.cn 俄罗斯是什么国家hkuteam.com 渣男之首是什么星座hcv9jop7ns4r.cn 舌头发黑是什么原因520myf.com 母亲节一般送什么礼物dajiketang.com
为什么晒太阳能补钙hcv8jop9ns5r.cn 8月24是什么星座hcv8jop9ns0r.cn 痔瘘和痔疮有什么区别hcv9jop1ns2r.cn 喉咙沙哑吃什么药hcv8jop1ns4r.cn saa是什么意思xjhesheng.com
君子什么意思hcv8jop8ns0r.cn 开业送什么好hcv8jop5ns8r.cn 耵聍栓塞是什么意思hcv7jop5ns0r.cn tct是检查什么hcv8jop7ns2r.cn 鳊鱼是什么鱼hcv7jop9ns4r.cn
月经期间洗澡会有什么影响吗hcv9jop2ns8r.cn 牛筋草用什么除草剂hcv9jop8ns0r.cn 麸质是什么hcv9jop0ns1r.cn 友尽是什么意思hcv8jop9ns4r.cn 骨显像主要检查什么hcv8jop3ns2r.cn
百度