疤痕憩室什么意思| 虎什么熊什么| 贪是什么意思| 口苦口臭吃什么药| 反响是什么意思| lsa是什么胎位| 颞下颌关节炎吃什么药| 菠萝为什么要泡盐水| 女人裹脚是从什么时候开始的| 网恋是什么意思| 梦见大青蛇是什么预兆| 窦性心律不齐是什么情况| joan什么意思| 猪宝是什么东西| 夏至有什么习俗| 猪狗不如是什么意思| 鬼剃头是因为什么原因引起的| 靶向药是什么意思| c5是什么意思| 神态自若是什么意思| 什么虎什么山| 梦见自己爷爷死了是什么预兆| 2333是什么意思啊| 人工受孕和试管婴儿有什么区别| d什么意思| 燕窝什么味道| 黄色是什么意思| afc是什么意思| 太阳黑子是什么东西| 月经量少是什么原因啊| 泡芙是什么| 全麦面包是什么做的| 琥珀色是什么颜色| inf是什么意思| 6月18日是什么节| 海马有什么功效作用| 脾胃虚寒者有什么症状| 柠檬片泡水喝有什么功效和作用| 什么颜色最吸热| 1999年是什么生肖| 四十岁月经量少是什么原因| 术后吃什么营养品好| 词牌名是什么意思| 健胃消食片什么时候吃| 低血压低是什么原因| 血糖高的人吃什么水果好| 嘴巴里长血泡是什么原因| 一厢情愿什么意思| wlw是什么意思| 高定是什么意思| 栖字五行属什么| 梦见捉黄鳝是什么意思| 36d什么意思| 老婆的弟弟叫什么| 雷达表属于什么档次| 学前班是什么意思| 打破伤风针挂什么科| 中秋节为什么要吃月饼| 带状疱疹长什么样| 新白娘子传奇许仙为什么用女的演| 梦到牛是什么预兆| 二姨子是什么意思| 什么烟最贵| 911是什么电话| hpv吃什么药| 石家庄为什么叫国际庄| 大腿外侧疼痛是什么原因| 马后炮是什么意思| 古人的婚礼在什么时候举行| 手心烫是什么原因| 舌头裂纹是什么病| 山药炖什么好吃| 原因是什么| 看眼睛挂什么科| 浅显是什么意思| 肌肉劳损吃什么药| 鳞状上皮内高度病变什么意思| 分泌物呈褐色是什么原因| 改善什么| 埃及是什么人种| 肾阴虚是什么症状| 怀孕吃什么水果好对胎儿好| 手指甲有月牙代表什么| 去韩国需要办理什么手续| 什么的嘴巴| 脂溢性皮炎头皮用什么洗发水| 89年的蛇是什么命| 什么是行政职务| 梦见捡钱是什么预兆| 永恒是什么意思| 中国为什么叫中国| 女孩缺金取什么名字好| 苍蝇吃什么食物| 冷冻是什么意思| 电销是什么| 李宁是什么运动员| 内招是什么意思| 想请假找什么理由好| 坐车头疼是什么原因| gi值是什么意思| 郑州有什么大学| 牙齿松动了有什么办法能固齿吗| 喉咙痰多吃什么药最好| 炉中火是什么意思| 军衔是什么意思| 精神洁癖是什么| 人体左边肋骨下疼是什么原因| 溜肩是什么意思| 胃酸过多有什么症状| 扁桃体肿大吃什么药好| 莱猪是什么| 胆囊结石会引起身体什么症状| 血糖查什么项目| 走肾不走心什么意思| 甲沟炎什么症状| 七月份有什么节日吗| 天龙八部是指佛教中的什么| 高血压吃什么盐比较好| 属猴本命佛是什么佛| 桑黄长在什么树上| 眼睛发炎吃什么消炎药| nas是什么| 黑海为什么叫黑海| dream car是什么意思| 闲敲棋子落灯花上一句是什么| 孕妇吃什么血糖降得快| 晚上睡觉脚底发热是什么原因| 奴役是什么意思| 安全期一般是什么时候| 金鸡独立什么意思| 天天晚上睡觉做梦是什么原因| hcg稀释是什么意思| 儒雅什么意思| 撕脱性骨折是什么意思| asus是什么牌子| 雅五行属性是什么| 佛跳墙是什么意思| 什么药可以帮助睡眠| 病毒性感冒吃什么药| 湿热内蕴证有什么症状| 带状疱疹不能吃什么食物| 梦见狗咬自己是什么意思| 戴黄金对身体有什么好处| 做核磁共振需要注意什么| 凝血四项是查什么的| 狗跟什么生肖最配| 鹅蛋什么人不能吃| 赖是什么意思| 腋下有异味是什么原因导致的| 霉菌性阴道炎用什么栓剂| 血压低吃什么食物| 耳屎多是什么原因| 时蔬是什么菜| 蝉蜕有什么功效| 什么怎么什么造句| 下肢血液循环不好吃什么药| 固本培元是什么意思| 肺部疼痛什么原因| 肝硬化早期吃什么药| 转呼啦圈有什么好处| 胃息肉吃什么好| 送手镯的寓意是什么| bunny是什么意思| o型血的孩子父母是什么血型| 梦见别人吐血是什么预兆| 附件炎吃什么药效果好| 台湾是什么民族| 喉咙有烧灼感吃什么药| 白化病是什么| 养尊处优的意思是什么| 乳腺纤维瘤是什么原因引起的| o型血不能和什么血型的人生孩子| 贴切是什么意思| 套是什么意思| 分娩是什么意思啊| 城投公司是干什么的| robinhood是什么牌子| 梦见修坟墓是什么预兆| 面瘫是什么意思| 经常拉屎是什么原因| ly是什么意思| cr医学上是什么意思| 螨虫是什么样子的| 痰中带血吃什么药| 长痘要忌口什么东西| 油烟机没有吸力是什么原因| 肾阳虚有什么症状男性| feno是什么检查| 六腑指的是什么| 手指经常抽筋是什么原因| gjb2基因杂合突变是什么意思| 俄罗斯什么东西值得买| tag什么意思| 化纤是什么面料| 家里出现蚂蚁预示什么| 鬼门关是什么意思| 口差念什么| ct腹部平扫能检查什么| 鸭子烧什么好吃| 眼睛看东西模糊是什么原因| 克服是什么意思| 淳朴是什么意思| 妇科腺肌症是什么病| 李子是什么水果| 儿童回春颗粒主要治什么| 傻白甜是什么意思| 机关党委是干什么的| 北京市长什么级别| 流注是什么意思| 为什么一紧张就想拉屎| 牙髓炎是什么原因引起的| rl是什么意思| 自闭症是什么原因引起| 89年的属什么| 胃病可以吃什么水果| 桑葚酒有什么功效| 吃莲雾有什么好处| 早搏什么症状| 早餐吃什么减肥| 水印是什么意思| 足及念什么| 镜子是什么生肖| 什么是视同缴费| f4什么意思| 择日不如撞日什么意思| 查血常规能查出什么| 感冒吃什么消炎药| 肌肉疼是什么原因| 1878年属什么生肖| 肺部条索灶是什么意思| 面基什么意思| pin什么意思| 满清是什么民族| 做馒头用什么面粉好| 肠道紊乱吃什么药| 4月19是什么星座| 擎什么意思| 备孕要吃什么| 心跳加速心慌吃什么药| 芈月和嬴政什么关系| 宝宝惊跳反射什么时候消失| 脾肺气虚吃什么中成药| 聚乙二醇是什么东西| 金砖国家是什么意思| ih医学上是什么意思| 什么洗发水去屑效果好| 乳房皮肤痒是什么原因| 逆行是什么意思| 咽鼓管炎吃什么药| 吃什么不会长胖| attach什么意思| 利普刀是什么手术| 乌鸡白凤丸有什么功效| 吃什么受孕率又快又高| 沙和尚的武器叫什么| 间接胆红素是什么意思| 直接胆红素偏高是什么意思| 丙肝抗体阳性是什么意思呢| 脚底发黄是什么原因| 葫芦藓是什么植物| 耳朵痛用什么药| 欺山莫欺水是什么意思| 脸发红发痒是什么原因| sample是什么意思| 百度

[交易时间]边看边聊 程毅敏:美联储加息对A股形成短期扰动


Directory: ../../../ffmpeg/
File: src/libavcodec/indeo5.c
Date: 2025-08-04 00:43:16
Exec Total Coverage
Lines: 245 353 69.4%
Functions: 7 8 87.5%
Branches: 120 214 56.1%

Line Branch Exec Source
1 /*
2 * Indeo Video Interactive v5 compatible decoder
3 * Copyright (c) 2009 Maxim Poliakovski
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 * Indeo Video Interactive version 5 decoder
25 *
26 * Indeo5 data is usually transported within .avi or .mov files.
27 * Known FOURCCs: 'IV50'
28 */
29
30 #define BITSTREAM_READER_LE
31 #include "avcodec.h"
32 #include "codec_internal.h"
33 #include "get_bits.h"
34 #include "ivi.h"
35 #include "ivi_dsp.h"
36 #include "indeo5data.h"
37
38 /**
39 * Indeo5 frame types.
40 */
41 enum {
42 FRAMETYPE_INTRA = 0,
43 FRAMETYPE_INTER = 1, ///< non-droppable P-frame
44 FRAMETYPE_INTER_SCAL = 2, ///< droppable P-frame used in the scalability mode
45 FRAMETYPE_INTER_NOREF = 3, ///< droppable P-frame
46 FRAMETYPE_NULL = 4 ///< empty frame with no data
47 };
48
49 #define IVI5_PIC_SIZE_ESC 15
50
51 /**
52 * Decode Indeo5 GOP (Group of pictures) header.
53 * This header is present in key frames only.
54 * It defines parameters for all frames in a GOP.
55 *
56 * @param[in,out] ctx ptr to the decoder context
57 * @param[in] avctx ptr to the AVCodecContext
58 * @return result code: 0 = OK, -1 = error
59 */
60 9 static int decode_gop_header(IVI45DecContext *ctx, AVCodecContext *avctx)
61 {
62 int result, i, p, tile_size, pic_size_indx, mb_size, blk_size, is_scalable;
63 9 int quant_mat, blk_size_changed = 0;
64 IVIBandDesc *band, *band1, *band2;
65 IVIPicConfig pic_conf;
66
67 9 ctx->gop_flags = get_bits(&ctx->gb, 8);
68
69
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 ctx->gop_hdr_size = (ctx->gop_flags & 1) ? get_bits(&ctx->gb, 16) : 0;
70
71
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (ctx->gop_flags & IVI5_IS_PROTECTED)
72 ctx->lock_word = get_bits_long(&ctx->gb, 32);
73
74
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 tile_size = (ctx->gop_flags & 0x40) ? 64 << get_bits(&ctx->gb, 2) : 0;
75
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (tile_size > 256) {
76 av_log(avctx, AV_LOG_ERROR, "Invalid tile size: %d\n", tile_size);
77 return AVERROR_INVALIDDATA;
78 }
79
80 /* decode number of wavelet bands */
81 /* num_levels * 3 + 1 */
82 9 pic_conf.luma_bands = get_bits(&ctx->gb, 2) * 3 + 1;
83 9 pic_conf.chroma_bands = get_bits1(&ctx->gb) * 3 + 1;
84
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
9 is_scalable = pic_conf.luma_bands != 1 || pic_conf.chroma_bands != 1;
85
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9 if (is_scalable && (pic_conf.luma_bands != 4 || pic_conf.chroma_bands != 1)) {
86 av_log(avctx, AV_LOG_ERROR, "Scalability: unsupported subdivision! Luma bands: %d, chroma bands: %d\n",
87 pic_conf.luma_bands, pic_conf.chroma_bands);
88 return AVERROR_INVALIDDATA;
89 }
90
91 9 pic_size_indx = get_bits(&ctx->gb, 4);
92
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (pic_size_indx == IVI5_PIC_SIZE_ESC) {
93 pic_conf.pic_height = get_bits(&ctx->gb, 13);
94 pic_conf.pic_width = get_bits(&ctx->gb, 13);
95 } else {
96 9 pic_conf.pic_height = ivi5_common_pic_sizes[pic_size_indx * 2 + 1] << 2;
97 9 pic_conf.pic_width = ivi5_common_pic_sizes[pic_size_indx * 2 ] << 2;
98 }
99
100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (ctx->gop_flags & 2) {
101 avpriv_report_missing_feature(avctx, "YV12 picture format");
102 return AVERROR_PATCHWELCOME;
103 }
104
105 9 pic_conf.chroma_height = (pic_conf.pic_height + 3) >> 2;
106 9 pic_conf.chroma_width = (pic_conf.pic_width + 3) >> 2;
107
108
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if (!tile_size) {
109 9 pic_conf.tile_height = pic_conf.pic_height;
110 9 pic_conf.tile_width = pic_conf.pic_width;
111 } else {
112 pic_conf.tile_height = pic_conf.tile_width = tile_size;
113 }
114
115 /* check if picture layout was changed and reallocate buffers */
116
3/4
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 8 times.
9 if (ivi_pic_config_cmp(&pic_conf, &ctx->pic_conf) || ctx->gop_invalid) {
117 1 result = ff_ivi_init_planes(avctx, ctx->planes, &pic_conf, 0);
118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (result < 0) {
119 av_log(avctx, AV_LOG_ERROR, "Couldn't reallocate color planes!\n");
120 return result;
121 }
122 1 ctx->pic_conf = pic_conf;
123 1 ctx->is_scalable = is_scalable;
124 1 blk_size_changed = 1; /* force reallocation of the internal structures */
125 }
126
127
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 9 times.
27 for (p = 0; p <= 1; p++) {
128
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 18 times.
36 for (i = 0; i < (!p ? pic_conf.luma_bands : pic_conf.chroma_bands); i++) {
129 18 band = &ctx->planes[p].bands[i];
130
131 18 band->is_halfpel = get_bits1(&ctx->gb);
132
133 18 mb_size = get_bits1(&ctx->gb);
134 18 blk_size = 8 >> get_bits1(&ctx->gb);
135 18 mb_size = blk_size << !mb_size;
136
137
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
18 if (p==0 && blk_size==4) {
138 av_log(avctx, AV_LOG_ERROR, "4x4 luma blocks are unsupported!\n");
139 return AVERROR_PATCHWELCOME;
140 }
141
142
3/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
18 blk_size_changed = mb_size != band->mb_size || blk_size != band->blk_size;
143
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 16 times.
18 if (blk_size_changed) {
144 2 band->mb_size = mb_size;
145 2 band->blk_size = blk_size;
146 }
147
148
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
18 if (get_bits1(&ctx->gb)) {
149 avpriv_report_missing_feature(avctx, "Extended transform info");
150 return AVERROR_PATCHWELCOME;
151 }
152
153 /* select transform function and scan pattern according to plane and band number */
154
2/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
18 switch ((p << 2) + i) {
155 9 case 0:
156 9 band->inv_transform = ff_ivi_inverse_slant_8x8;
157 9 band->dc_transform = ff_ivi_dc_slant_2d;
158 9 band->scan = ff_zigzag_direct;
159 9 band->transform_size = 8;
160 9 break;
161
162 case 1:
163 band->inv_transform = ff_ivi_row_slant8;
164 band->dc_transform = ff_ivi_dc_row_slant;
165 band->scan = ff_ivi_vertical_scan_8x8;
166 band->transform_size = 8;
167 break;
168
169 case 2:
170 band->inv_transform = ff_ivi_col_slant8;
171 band->dc_transform = ff_ivi_dc_col_slant;
172 band->scan = ff_ivi_horizontal_scan_8x8;
173 band->transform_size = 8;
174 break;
175
176 case 3:
177 band->inv_transform = ff_ivi_put_pixels_8x8;
178 band->dc_transform = ff_ivi_put_dc_pixel_8x8;
179 band->scan = ff_ivi_horizontal_scan_8x8;
180 band->transform_size = 8;
181 break;
182
183 9 case 4:
184 9 band->inv_transform = ff_ivi_inverse_slant_4x4;
185 9 band->dc_transform = ff_ivi_dc_slant_2d;
186 9 band->scan = ff_ivi_direct_scan_4x4;
187 9 band->transform_size = 4;
188 9 break;
189 }
190
191
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
27 band->is_2d_trans = band->inv_transform == ff_ivi_inverse_slant_8x8 ||
192
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 band->inv_transform == ff_ivi_inverse_slant_4x4;
193
194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (band->transform_size != band->blk_size) {
195 av_log(avctx, AV_LOG_ERROR, "transform and block size mismatch (%d != %d)\n", band->transform_size, band->blk_size);
196 return AVERROR_INVALIDDATA;
197 }
198
199 /* select dequant matrix according to plane and band number */
200
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 if (!p) {
201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 quant_mat = (pic_conf.luma_bands > 1) ? i+1 : 0;
202 } else {
203 9 quant_mat = 5;
204 }
205
206
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 if (band->blk_size == 8) {
207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(quant_mat >= 5){
208 av_log(avctx, AV_LOG_ERROR, "quant_mat %d too large!\n", quant_mat);
209 return -1;
210 }
211 9 band->intra_base = &ivi5_base_quant_8x8_intra[quant_mat][0];
212 9 band->inter_base = &ivi5_base_quant_8x8_inter[quant_mat][0];
213 9 band->intra_scale = &ivi5_scale_quant_8x8_intra[quant_mat][0];
214 9 band->inter_scale = &ivi5_scale_quant_8x8_inter[quant_mat][0];
215 } else {
216 9 band->intra_base = ivi5_base_quant_4x4_intra;
217 9 band->inter_base = ivi5_base_quant_4x4_inter;
218 9 band->intra_scale = ivi5_scale_quant_4x4_intra;
219 9 band->inter_scale = ivi5_scale_quant_4x4_inter;
220 }
221
222
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
18 if (get_bits(&ctx->gb, 2)) {
223 av_log(avctx, AV_LOG_ERROR, "End marker missing!\n");
224 return AVERROR_INVALIDDATA;
225 }
226 }
227 }
228
229 /* copy chroma parameters into the 2nd chroma plane */
230
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 for (i = 0; i < pic_conf.chroma_bands; i++) {
231 9 band1 = &ctx->planes[1].bands[i];
232 9 band2 = &ctx->planes[2].bands[i];
233
234 9 band2->width = band1->width;
235 9 band2->height = band1->height;
236 9 band2->mb_size = band1->mb_size;
237 9 band2->blk_size = band1->blk_size;
238 9 band2->is_halfpel = band1->is_halfpel;
239 9 band2->intra_base = band1->intra_base;
240 9 band2->inter_base = band1->inter_base;
241 9 band2->intra_scale = band1->intra_scale;
242 9 band2->inter_scale = band1->inter_scale;
243 9 band2->scan = band1->scan;
244 9 band2->inv_transform = band1->inv_transform;
245 9 band2->dc_transform = band1->dc_transform;
246 9 band2->is_2d_trans = band1->is_2d_trans;
247 9 band2->transform_size= band1->transform_size;
248 }
249
250 /* reallocate internal structures if needed */
251
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8 times.
9 if (blk_size_changed) {
252 1 result = ff_ivi_init_tiles(ctx->planes, pic_conf.tile_width,
253 1 pic_conf.tile_height);
254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (result < 0) {
255 av_log(avctx, AV_LOG_ERROR,
256 "Couldn't reallocate internal structures!\n");
257 return result;
258 }
259 }
260
261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (ctx->gop_flags & 8) {
262 if (get_bits(&ctx->gb, 3)) {
263 av_log(avctx, AV_LOG_ERROR, "Alignment bits are not zero!\n");
264 return AVERROR_INVALIDDATA;
265 }
266
267 if (get_bits1(&ctx->gb))
268 skip_bits(&ctx->gb, 24); /* skip transparency fill color */
269 }
270
271 9 align_get_bits(&ctx->gb);
272
273 9 skip_bits(&ctx->gb, 23); /* FIXME: unknown meaning */
274
275 /* skip GOP extension if any */
276
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
9 if (get_bits1(&ctx->gb)) {
277 do {
278 i = get_bits(&ctx->gb, 16);
279 } while (i & 0x8000);
280 }
281
282 9 align_get_bits(&ctx->gb);
283
284 9 return 0;
285 }
286
287
288 /**
289 * Skip a header extension.
290 *
291 * @param[in,out] gb the GetBit context
292 */
293 static inline int skip_hdr_extension(GetBitContext *gb)
294 {
295 int i, len;
296
297 do {
298 len = get_bits(gb, 8);
299 if (8*len > get_bits_left(gb))
300 return AVERROR_INVALIDDATA;
301 for (i = 0; i < len; i++) skip_bits(gb, 8);
302 } while(len);
303
304 return 0;
305 }
306
307
308 /**
309 * Decode Indeo5 picture header.
310 *
311 * @param[in,out] ctx ptr to the decoder context
312 * @param[in] avctx ptr to the AVCodecContext
313 * @return result code: 0 = OK, -1 = error
314 */
315 134 static int decode_pic_hdr(IVI45DecContext *ctx, AVCodecContext *avctx)
316 {
317 int ret;
318
319
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 134 times.
134 if (get_bits(&ctx->gb, 5) != 0x1F) {
320 av_log(avctx, AV_LOG_ERROR, "Invalid picture start code!\n");
321 return AVERROR_INVALIDDATA;
322 }
323
324 134 ctx->prev_frame_type = ctx->frame_type;
325 134 ctx->frame_type = get_bits(&ctx->gb, 3);
326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134 times.
134 if (ctx->frame_type >= 5) {
327 av_log(avctx, AV_LOG_ERROR, "Invalid frame type: %d \n", ctx->frame_type);
328 ctx->frame_type = FRAMETYPE_INTRA;
329 return AVERROR_INVALIDDATA;
330 }
331
332 134 ctx->frame_num = get_bits(&ctx->gb, 8);
333
334
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 125 times.
134 if (ctx->frame_type == FRAMETYPE_INTRA) {
335
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
9 if ((ret = decode_gop_header(ctx, avctx)) < 0) {
336 av_log(avctx, AV_LOG_ERROR, "Invalid GOP header, skipping frames.\n");
337 ctx->gop_invalid = 1;
338 return ret;
339 }
340 9 ctx->gop_invalid = 0;
341 }
342
343
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 134 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
134 if (ctx->frame_type == FRAMETYPE_INTER_SCAL && !ctx->is_scalable) {
344 av_log(avctx, AV_LOG_ERROR, "Scalable inter frame in non scalable stream\n");
345 ctx->frame_type = FRAMETYPE_INTER;
346 return AVERROR_INVALIDDATA;
347 }
348
349
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 1 times.
134 if (ctx->frame_type != FRAMETYPE_NULL) {
350 133 ctx->frame_flags = get_bits(&ctx->gb, 8);
351
352
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 ctx->pic_hdr_size = (ctx->frame_flags & 1) ? get_bits(&ctx->gb, 24) : 0;
353
354
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 ctx->checksum = (ctx->frame_flags & 0x10) ? get_bits(&ctx->gb, 16) : 0;
355
356 /* skip unknown extension if any */
357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
133 if (ctx->frame_flags & 0x20)
358 skip_hdr_extension(&ctx->gb); /* XXX: untested */
359
360 /* decode macroblock huffman codebook */
361 133 ret = ff_ivi_dec_huff_desc(&ctx->gb, ctx->frame_flags & 0x40,
362 IVI_MB_HUFF, &ctx->mb_vlc, avctx);
363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
133 if (ret < 0)
364 return ret;
365
366 133 skip_bits(&ctx->gb, 3); /* FIXME: unknown meaning! */
367 }
368
369 134 align_get_bits(&ctx->gb);
370
371 134 return 0;
372 }
373
374
375 /**
376 * Decode Indeo5 band header.
377 *
378 * @param[in,out] ctx ptr to the decoder context
379 * @param[in,out] band ptr to the band descriptor
380 * @param[in] avctx ptr to the AVCodecContext
381 * @return result code: 0 = OK, -1 = error
382 */
383 399 static int decode_band_hdr(IVI45DecContext *ctx, IVIBandDesc *band,
384 AVCodecContext *avctx)
385 {
386 int i, ret;
387 uint8_t band_flags;
388
389 399 band_flags = get_bits(&ctx->gb, 8);
390
391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if (band_flags & 1) {
392 band->is_empty = 1;
393 return 0;
394 }
395
396
1/2
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
399 band->data_size = (ctx->frame_flags & 0x80) ? get_bits(&ctx->gb, 24) : 0;
397
398 399 band->inherit_mv = band_flags & 2;
399 399 band->inherit_qdelta = band_flags & 8;
400 399 band->qdelta_present = band_flags & 4;
401
1/2
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
399 if (!band->qdelta_present) band->inherit_qdelta = 1;
402
403 /* decode rvmap probability corrections if any */
404 399 band->num_corr = 0; /* there are no corrections */
405
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 147 times.
399 if (band_flags & 0x10) {
406 252 band->num_corr = get_bits(&ctx->gb, 8); /* get number of correction pairs */
407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if (band->num_corr > 61) {
408 av_log(avctx, AV_LOG_ERROR, "Too many corrections: %d\n",
409 band->num_corr);
410 return AVERROR_INVALIDDATA;
411 }
412
413 /* read correction pairs */
414
2/2
✓ Branch 0 taken 2064 times.
✓ Branch 1 taken 252 times.
2316 for (i = 0; i < band->num_corr * 2; i++)
415 2064 band->corr[i] = get_bits(&ctx->gb, 8);
416 }
417
418 /* select appropriate rvmap table for this band */
419
2/2
✓ Branch 0 taken 397 times.
✓ Branch 1 taken 2 times.
399 band->rvmap_sel = (band_flags & 0x40) ? get_bits(&ctx->gb, 3) : 8;
420
421 /* decode block huffman codebook */
422 399 ret = ff_ivi_dec_huff_desc(&ctx->gb, band_flags & 0x80, IVI_BLK_HUFF,
423 &band->blk_vlc, avctx);
424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if (ret < 0)
425 return ret;
426
427 399 band->checksum_present = get_bits1(&ctx->gb);
428
1/2
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
399 if (band->checksum_present)
429 399 band->checksum = get_bits(&ctx->gb, 16);
430
431 399 band->glob_quant = get_bits(&ctx->gb, 5);
432
433 /* skip unknown extension if any */
434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if (band_flags & 0x20) { /* XXX: untested */
435 align_get_bits(&ctx->gb);
436 skip_hdr_extension(&ctx->gb);
437 }
438
439 399 align_get_bits(&ctx->gb);
440
441 399 return 0;
442 }
443
444
445 /**
446 * Decode info (block type, cbp, quant delta, motion vector)
447 * for all macroblocks in the current tile.
448 *
449 * @param[in,out] ctx ptr to the decoder context
450 * @param[in,out] band ptr to the band descriptor
451 * @param[in,out] tile ptr to the tile descriptor
452 * @param[in] avctx ptr to the AVCodecContext
453 * @return result code: 0 = OK, -1 = error
454 */
455 399 static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc *band,
456 IVITile *tile, AVCodecContext *avctx)
457 {
458 int x, y, mv_x, mv_y, mv_delta, offs, mb_offset,
459 mv_scale, blks_per_mb, s;
460 IVIMbInfo *mb, *ref_mb;
461 399 int row_offset = band->mb_size * band->pitch;
462
463 399 mb = tile->mbs;
464 399 ref_mb = tile->ref_mbs;
465 399 offs = tile->ypos * band->pitch + tile->xpos;
466
467
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 266 times.
399 if (!ref_mb &&
468
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 133 times.
133 ((band->qdelta_present && band->inherit_qdelta) || band->inherit_mv))
469 return AVERROR_INVALIDDATA;
470
471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if (tile->num_MBs != IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size)) {
472 av_log(avctx, AV_LOG_ERROR, "Allocated tile size %d mismatches parameters %d\n",
473 tile->num_MBs, IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size));
474 return AVERROR_INVALIDDATA;
475 }
476
477 /* scale factor for motion vectors */
478 399 mv_scale = (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3);
479 399 mv_x = mv_y = 0;
480
481
2/2
✓ Branch 0 taken 4788 times.
✓ Branch 1 taken 399 times.
5187 for (y = tile->ypos; y < (tile->ypos + tile->height); y += band->mb_size) {
482 4788 mb_offset = offs;
483
484
2/2
✓ Branch 0 taken 71820 times.
✓ Branch 1 taken 4788 times.
76608 for (x = tile->xpos; x < (tile->xpos + tile->width); x += band->mb_size) {
485 71820 mb->xpos = x;
486 71820 mb->ypos = y;
487 71820 mb->buf_offs = mb_offset;
488
489
2/2
✓ Branch 1 taken 27025 times.
✓ Branch 2 taken 44795 times.
71820 if (get_bits1(&ctx->gb)) {
490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27025 times.
27025 if (ctx->frame_type == FRAMETYPE_INTRA) {
491 av_log(avctx, AV_LOG_ERROR, "Empty macroblock in an INTRA picture!\n");
492 return AVERROR_INVALIDDATA;
493 }
494 27025 mb->type = 1; /* empty macroblocks are always INTER */
495 27025 mb->cbp = 0; /* all blocks are empty */
496
497 27025 mb->q_delta = 0;
498
4/6
✓ Branch 0 taken 7730 times.
✓ Branch 1 taken 19295 times.
✓ Branch 2 taken 7730 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7730 times.
27025 if (!band->plane && !band->band_num && (ctx->frame_flags & 8)) {
499 mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
500 IVI_VLC_BITS, 1);
501 mb->q_delta = IVI_TOSIGNED(mb->q_delta);
502 }
503
504 27025 mb->mv_x = mb->mv_y = 0; /* no motion vector coded */
505
3/4
✓ Branch 0 taken 19295 times.
✓ Branch 1 taken 7730 times.
✓ Branch 2 taken 19295 times.
✗ Branch 3 not taken.
27025 if (band->inherit_mv && ref_mb){
506 /* motion vector inheritance */
507
1/2
✓ Branch 0 taken 19295 times.
✗ Branch 1 not taken.
19295 if (mv_scale) {
508 19295 mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
509 19295 mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
510 } else {
511 mb->mv_x = ref_mb->mv_x;
512 mb->mv_y = ref_mb->mv_y;
513 }
514 }
515 } else {
516
3/4
✓ Branch 0 taken 28585 times.
✓ Branch 1 taken 16210 times.
✓ Branch 2 taken 28585 times.
✗ Branch 3 not taken.
44795 if (band->inherit_mv && ref_mb) {
517 28585 mb->type = ref_mb->type; /* copy mb_type from corresponding reference mb */
518
2/2
✓ Branch 0 taken 1620 times.
✓ Branch 1 taken 14590 times.
16210 } else if (ctx->frame_type == FRAMETYPE_INTRA) {
519 1620 mb->type = 0; /* mb_type is always INTRA for intra-frames */
520 } else {
521 14590 mb->type = get_bits1(&ctx->gb);
522 }
523
524
2/2
✓ Branch 0 taken 16210 times.
✓ Branch 1 taken 28585 times.
44795 blks_per_mb = band->mb_size != band->blk_size ? 4 : 1;
525 44795 mb->cbp = get_bits(&ctx->gb, blks_per_mb);
526
527 44795 mb->q_delta = 0;
528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44795 times.
44795 if (band->qdelta_present) {
529 if (band->inherit_qdelta) {
530 if (ref_mb) mb->q_delta = ref_mb->q_delta;
531 } else if (mb->cbp || (!band->plane && !band->band_num &&
532 (ctx->frame_flags & 8))) {
533 mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
534 IVI_VLC_BITS, 1);
535 mb->q_delta = IVI_TOSIGNED(mb->q_delta);
536 }
537 }
538
539
2/2
✓ Branch 0 taken 13239 times.
✓ Branch 1 taken 31556 times.
44795 if (!mb->type) {
540 13239 mb->mv_x = mb->mv_y = 0; /* there is no motion vector in intra-macroblocks */
541 } else {
542
3/4
✓ Branch 0 taken 19759 times.
✓ Branch 1 taken 11797 times.
✓ Branch 2 taken 19759 times.
✗ Branch 3 not taken.
31556 if (band->inherit_mv && ref_mb){
543 /* motion vector inheritance */
544
1/2
✓ Branch 0 taken 19759 times.
✗ Branch 1 not taken.
19759 if (mv_scale) {
545 19759 mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
546 19759 mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
547 } else {
548 mb->mv_x = ref_mb->mv_x;
549 mb->mv_y = ref_mb->mv_y;
550 }
551 } else {
552 /* decode motion vector deltas */
553 11797 mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
554 IVI_VLC_BITS, 1);
555 11797 mv_y += IVI_TOSIGNED(mv_delta);
556 11797 mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
557 IVI_VLC_BITS, 1);
558 11797 mv_x += IVI_TOSIGNED(mv_delta);
559 11797 mb->mv_x = mv_x;
560 11797 mb->mv_y = mv_y;
561 }
562 }
563 }
564
565 71820 s= band->is_halfpel;
566
2/2
✓ Branch 0 taken 58581 times.
✓ Branch 1 taken 13239 times.
71820 if (mb->type)
567
1/2
✓ Branch 0 taken 58581 times.
✗ Branch 1 not taken.
58581 if ( x + (mb->mv_x >>s) + (y+ (mb->mv_y >>s))*band->pitch < 0 ||
568 58581 x + ((mb->mv_x+s)>>s) + band->mb_size - 1
569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58581 times.
58581 + (y+band->mb_size - 1 +((mb->mv_y+s)>>s))*band->pitch > band->bufsize - 1) {
570 av_log(avctx, AV_LOG_ERROR, "motion vector %d %d outside reference\n", x*s + mb->mv_x, y*s + mb->mv_y);
571 return AVERROR_INVALIDDATA;
572 }
573
574 71820 mb++;
575
2/2
✓ Branch 0 taken 47880 times.
✓ Branch 1 taken 23940 times.
71820 if (ref_mb)
576 47880 ref_mb++;
577 71820 mb_offset += band->mb_size;
578 }
579
580 4788 offs += row_offset;
581 }
582
583 399 align_get_bits(&ctx->gb);
584
585 399 return 0;
586 }
587
588
589 /**
590 * Switch buffers.
591 *
592 * @param[in,out] ctx ptr to the decoder context
593 */
594 134 static void switch_buffers(IVI45DecContext *ctx)
595 {
596
2/4
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
134 switch (ctx->prev_frame_type) {
597 133 case FRAMETYPE_INTRA:
598 case FRAMETYPE_INTER:
599 133 ctx->buf_switch ^= 1;
600 133 ctx->dst_buf = ctx->buf_switch;
601 133 ctx->ref_buf = ctx->buf_switch ^ 1;
602 133 break;
603 case FRAMETYPE_INTER_SCAL:
604 if (!ctx->inter_scal) {
605 ctx->ref2_buf = 2;
606 ctx->inter_scal = 1;
607 }
608 FFSWAP(int, ctx->dst_buf, ctx->ref2_buf);
609 ctx->ref_buf = ctx->ref2_buf;
610 break;
611 case FRAMETYPE_INTER_NOREF:
612 break;
613 }
614
615
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 124 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
134 switch (ctx->frame_type) {
616 9 case FRAMETYPE_INTRA:
617 9 ctx->buf_switch = 0;
618 /* FALLTHROUGH */
619 133 case FRAMETYPE_INTER:
620 133 ctx->inter_scal = 0;
621 133 ctx->dst_buf = ctx->buf_switch;
622 133 ctx->ref_buf = ctx->buf_switch ^ 1;
623 133 break;
624 1 case FRAMETYPE_INTER_SCAL:
625 case FRAMETYPE_INTER_NOREF:
626 case FRAMETYPE_NULL:
627 1 break;
628 }
629 134 }
630
631
632 268 static int is_nonnull_frame(IVI45DecContext *ctx)
633 {
634 268 return ctx->frame_type != FRAMETYPE_NULL;
635 }
636
637
638 /**
639 * Initialize Indeo5 decoder.
640 */
641 2 static av_cold int decode_init(AVCodecContext *avctx)
642 {
643 2 IVI45DecContext *ctx = avctx->priv_data;
644 int result;
645
646 2 ctx->gop_invalid = 1;
647
648 2 ff_ivi_init_static_vlc();
649
650 /* copy rvmap tables in our context so we can apply changes to them */
651 2 memcpy(ctx->rvmap_tabs, ff_ivi_rvmap_tabs, sizeof(ff_ivi_rvmap_tabs));
652
653 /* set the initial picture layout according to the basic profile:
654 there is only one band per plane (no scalability), only one tile (no local decoding)
655 and picture format = YVU9 */
656 2 ctx->pic_conf.pic_width = avctx->width;
657 2 ctx->pic_conf.pic_height = avctx->height;
658 2 ctx->pic_conf.chroma_width = (avctx->width + 3) >> 2;
659 2 ctx->pic_conf.chroma_height = (avctx->height + 3) >> 2;
660 2 ctx->pic_conf.tile_width = avctx->width;
661 2 ctx->pic_conf.tile_height = avctx->height;
662 2 ctx->pic_conf.luma_bands = ctx->pic_conf.chroma_bands = 1;
663
664 2 result = ff_ivi_init_planes(avctx, ctx->planes, &ctx->pic_conf, 0);
665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (result) {
666 av_log(avctx, AV_LOG_ERROR, "Couldn't allocate color planes!\n");
667 return AVERROR_INVALIDDATA;
668 }
669
670 2 ctx->buf_switch = 0;
671 2 ctx->inter_scal = 0;
672
673 2 ctx->decode_pic_hdr = decode_pic_hdr;
674 2 ctx->decode_band_hdr = decode_band_hdr;
675 2 ctx->decode_mb_info = decode_mb_info;
676 2 ctx->switch_buffers = switch_buffers;
677 2 ctx->is_nonnull_frame = is_nonnull_frame;
678
679 2 ctx->is_indeo4 = 0;
680
681 2 avctx->pix_fmt = AV_PIX_FMT_YUV410P;
682
683 2 return 0;
684 }
685
686 const FFCodec ff_indeo5_decoder = {
687 .p.name = "indeo5",
688 CODEC_LONG_NAME("Intel Indeo Video Interactive 5"),
689 .p.type = AVMEDIA_TYPE_VIDEO,
690 .p.id = AV_CODEC_ID_INDEO5,
691 .priv_data_size = sizeof(IVI45DecContext),
692 .init = decode_init,
693 .close = ff_ivi_decode_close,
694 FF_CODEC_DECODE_CB(ff_ivi_decode_frame),
695 .p.capabilities = AV_CODEC_CAP_DR1,
696 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
697 };
698

女人梦见猫是什么预兆 新疆人是什么人种 什么食物含钾 罗盘是干什么用的 甲减饮食需要注意什么
送男生什么生日礼物 啵啵是什么意思 妈祖是什么意思 阿尔茨海默症是什么病 未来的未多一横念什么
晚上睡觉脚抽搐是什么原因 检车需要什么手续 钟馗是什么人物 叶五行属什么 登高望远是什么生肖
西红柿可以做什么菜 茶叶有什么功效 9月13日是什么星座 被蚂蚁咬了涂什么药 欣赏一个人是什么意思
水仙茶适合什么人喝hcv9jop4ns9r.cn 什么叫精神病hcv9jop7ns1r.cn 大葱和小葱有什么区别hcv7jop6ns1r.cn 孕妇心率快是什么原因hcv8jop4ns4r.cn 七月十三号是什么星座hcv9jop1ns4r.cn
减肥头晕是什么原因hcv9jop1ns1r.cn 系统性红斑狼疮不能吃什么hcv8jop1ns7r.cn 观音菩萨叫什么名字hcv9jop6ns0r.cn 来例假头晕是什么原因96micro.com 忌口不能吃什么sscsqa.com
雀舌是什么茶hcv9jop1ns0r.cn 5.3什么星座hcv8jop0ns2r.cn 双重所有格是什么意思bjcbxg.com 冷的什么hcv8jop9ns5r.cn 精子碎片率高吃什么药beikeqingting.com
什么事的英文hcv8jop2ns2r.cn 为什么心细的男人危险hcv7jop6ns6r.cn 血小板是干什么用的hcv9jop0ns0r.cn 送男生什么礼物hcv9jop4ns3r.cn 米线是用什么做的hcv8jop2ns3r.cn
百度