经常腰酸是什么原因女性| pwp是什么意思| 什么人容易长智齿| 外婆的弟弟叫什么| 什么都有| 西康省是现在什么地方| 为什么叫基围虾| 特警力量第二部叫什么| 面包虫长大后变成什么| 角化型脚气用什么药| 午餐吃什么好又能减肥| fb是什么意思| 2月什么星座| 黛力新主治什么病| 属蛇的本命佛是什么佛| 过敏性紫癜用什么药| 为什么不敢挖雍正陵墓| 黑色车牌是什么车| 耳道炎是什么原因引起的| 口腔溃疡吃什么水果好| 11.28什么星座| 免疫力低吃什么补| 药物流产最佳时间什么时候| 吃饭吧唧嘴有什么说法| 神灵是什么意思| 久卧伤什么| 甘油三酯高不能吃什么| 姨妈期可以吃什么水果| 吃芒果对身体有什么好处| 上呼吸道感染吃什么中成药| crh是什么意思| 小便短赤是什么意思| 1.17是什么星座| 技校是什么| 糖尿病人适合吃什么水果| 腋下淋巴结肿大挂什么科| 肩膀痛挂什么科| 甲钴胺片主治什么病| 十月一日是什么星座| 子宫有积液是什么原因引起的| 副支队长是什么级别| 多多益善是什么意思| 肾结石看什么科| 胎盘老化对胎儿有什么影响| 丝瓜水敷脸有什么作用| 谷草转氨酶偏低是什么意思| 物尽其用什么意思| 风包念什么| 桐字属于五行属什么| 晚上吃什么有助于减肥| 白蛋白低吃什么补得快| 蛋白肉是什么东西做的| 喜欢一个人是什么感觉| 牙疼吃什么药效果好| 洗牙为什么要验血| 全品类是什么意思| 负离子是什么| 阴道炎用什么药最好| 尿液发黄什么原因| chloe什么牌子| 俄罗斯乌克兰为什么打仗| 吃什么药怀孕最快| 脚气有什么症状| 心脏搭桥是什么病| 吃苹果有什么好处| 罐肠什么意思| 有出息是什么意思| 什么品种的芒果最好吃| 男人为什么会出轨| 夜尿多吃什么药效果好| 为什么不能叫醒梦游的人| 植物光合作用产生什么| 贿赂是什么意思| 苍耳是什么| 西兰花是什么季节的蔬菜| 梨状肌综合症吃什么药| 5月11日是什么星座| 晕车吃什么能缓解| ug什么意思| 女人的逼长什么样| 嗜睡是什么病的前兆| 红细胞高是什么意思| 掉头发什么原因| 小孩拉肚子吃什么食物好| 反哺是什么意思| 眼睛下面有痣代表什么| 浓绿的什么| 受精卵着床是什么意思| 洁身自爱是什么生肖| 甘油三酯偏高是什么原因| 抖腿是什么毛病| 什么叫个人修养| 一阴一阳是什么数字| 山竹和什么不能一起吃| 老头乐是什么| 什么是佝偻病有什么症状| 脚背浮肿是什么原因引起的| 5月31日什么星座| 为什么不来大姨妈也没有怀孕| 支付宝余额和余额宝有什么区别| 荷叶和什么搭配最减肥| 血钾低会有什么症状| 脚肿什么原因| 为什么胃酸会分泌过多| 头发掉什么原因| 91年的羊是什么命| 属马与什么属相最配| 子宫内膜c型什么意思| 9价疫苗适合什么年龄人打| 边界尚清是什么意思| 小便无力是什么原因| 刘邦为什么要杀韩信| 梦见大水是什么预兆| 祛痣挂什么科| 治疗肝脏硬化要吃什么药好| 足外翻挂什么科| 涅盘什么意思| 6月22日什么星座| 吃维生素e有什么好处| 一什么桃花| 雨露是什么意思| 三本是什么学历| 心肌病是什么病严重吗| 什么是相向而行| 盆腔磁共振平扫能查出什么| 自尊心是什么意思| 血氧低会有什么危害| 压力是什么| 鸡拉绿色粪便吃什么药| 什么叫应届毕业生| 下午七点是什么时辰| 什么是电解水| 解脲脲原体是什么病| 什么是葡萄胎| 天蝎男喜欢什么样的女生| 海狗是什么动物| 苯海拉明是什么药| 真好是什么意思| 属龙和什么属相相冲| 开门杀是什么意思| 冥想有什么好处| 本虚标实是什么意思| 什么车可以闯红灯| 吃三七粉有什么作用| 客厅挂画有什么讲究| 脸热发红是什么原因| 芥末是什么做的| 屁很臭是什么原因| 果脯是什么东西| 缱绻旖旎是什么意思| 装什么病能容易开病假| 修面皮是什么皮| 血糖高是什么引起的| 和胃降逆是什么意思| 二月初十是什么星座| 什么茶好喝| 什么是年金| 手抽筋吃什么药| 叶倩文属什么生肖| 疏风解表的意思是什么| 双手发麻是什么原因| 回声欠均匀是什么意思| 武则天为什么立无字碑| 橘色五行属什么| cts是什么意思| 屁很臭是什么原因| 男人吃什么容易生儿子| 血糖高初期有什么症状| 心悸是什么意思啊| 区间放量是什么意思| 为什么叫211大学| 减肥适合吃什么主食| 玉竹长什么样子| 悲催是什么意思| 肿瘤前期有什么症状| 六月是什么季节| 什么是癌胚抗原| 人模狗样是什么生肖| 猴赛雷什么意思| 水果皇后是什么水果| 了加一笔是什么字| 月子吃什么最下奶| 嘉字属于五行属什么| 鹅蛋不能和什么一起吃| 一片冰心在玉壶的冰心是什么意思| 天月二德是什么意思| 常德有什么大学| 梦见死人复活什么预兆| 深圳副市长什么级别| 一什么旋风| 荨麻疹吃什么中药| 杺字五行属什么| 小白脸是什么意思| 开字五行属什么| 四月二十一是什么星座| 复方药是什么意思| 什么人容易得圆锥角膜| 京剧脸谱黑色代表什么| 妈妈咪呀是什么意思| 什么食物补锌效果最好| 穿什么衣服好看| 五月十三日是什么星座| 低盐饮食有利于预防什么疾病| 女人小便出血是什么原因| 耳垂上有痣代表什么| tao是什么意思| 碧螺春属于什么茶| 阴道瘙痒用什么药| 爬行对身体有什么好处| 谢霆锋什么学历| 朱元璋长什么样| 犹太人是什么人种| 张牙舞爪是什么意思| 梦见烙饼是什么意思| 一九七七年属什么生肖| 喝酒后头疼吃什么药| 手发麻是什么原因| prp是什么意思| 种什么药材最快又值钱| 稀料是什么| 银镯子变黑是什么原因| 梦见钱是什么预兆| 九月三日是什么日子| bid医学上是什么意思| 一什么陆地| 万寿菊什么时候开花| 指南针为什么不叫指北针| 咽喉炎挂什么科| 什么道路| 什么星空| 员外是什么生肖| ad滴剂什么时候吃最好| 口苦口干是什么原因引起的| lfc是什么意思| 牙龈爱出血是什么原因| 茄子吃了有什么好处| 四爱是什么意思| 股票除权是什么意思| 怎么知道自己五行缺什么| 半夜口干舌燥是什么原因| 什么叫醪糟| 太平猴魁属于什么茶类| 深海鱼油有什么功效| 西宁有什么好玩的| 难耐是什么意思| 富翁是什么意思| 隐是什么意思| 双眼屈光不正是什么意思| 补体c3偏高说明什么| 膛目结舌是什么意思| 新生儿什么时候能看见东西| 梦见小孩是什么| 灰指甲是什么症状| 乌鸡汤放什么材料| 血压和血糖有什么关系| 16岁是什么年华| 闫学晶是什么军衔| 洗面奶什么牌子好| 子宫粘连有什么症状| 属虎的适合什么职业| 深圳到香港需要办理什么手续| 走路气喘是什么原因| 余事勿取 什么意思| 总是放屁是什么原因引起的| 百度

2018斯诺克中国公开赛奖金超百万镑 仅次世锦赛


Directory: ../../../ffmpeg/
File: src/libavformat/mxg.c
Date: 2025-08-04 11:35:17
Exec Total Coverage
Lines: 114 131 87.0%
Functions: 5 5 100.0%
Branches: 62 86 72.1%

Line Branch Exec Source
1 /*
2 * MxPEG clip file demuxer
3 * Copyright (c) 2010 Anatoly Nenashev
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 #include "libavutil/channel_layout.h"
23 #include "libavutil/internal.h"
24 #include "libavutil/intreadwrite.h"
25 #include "libavutil/mem.h"
26 #include "libavcodec/mjpeg.h"
27 #include "avformat.h"
28 #include "demux.h"
29 #include "internal.h"
30 #include "avio.h"
31
32 #define DEFAULT_PACKET_SIZE 1024
33 #define OVERREAD_SIZE 3
34
35 typedef struct MXGContext {
36 uint8_t *buffer;
37 uint8_t *buffer_ptr;
38 uint8_t *soi_ptr;
39 unsigned int buffer_size;
40 int64_t dts;
41 unsigned int cache_size;
42 } MXGContext;
43
44 1 static int mxg_read_header(AVFormatContext *s)
45 {
46 AVStream *video_st, *audio_st;
47 1 MXGContext *mxg = s->priv_data;
48
49 /* video parameters will be extracted from the compressed bitstream */
50 1 video_st = avformat_new_stream(s, NULL);
51
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (!video_st)
52 return AVERROR(ENOMEM);
53 1 video_st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
54 1 video_st->codecpar->codec_id = AV_CODEC_ID_MXPEG;
55 1 avpriv_set_pts_info(video_st, 64, 1, 1000000);
56
57 1 audio_st = avformat_new_stream(s, NULL);
58
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (!audio_st)
59 return AVERROR(ENOMEM);
60 1 audio_st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
61 1 audio_st->codecpar->codec_id = AV_CODEC_ID_PCM_ALAW;
62 1 audio_st->codecpar->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
63 1 audio_st->codecpar->sample_rate = 8000;
64 1 audio_st->codecpar->bits_per_coded_sample = 8;
65 1 audio_st->codecpar->block_align = 1;
66 1 avpriv_set_pts_info(audio_st, 64, 1, 1000000);
67
68 1 mxg->soi_ptr = mxg->buffer_ptr = mxg->buffer = 0;
69 1 mxg->buffer_size = 0;
70 1 mxg->dts = AV_NOPTS_VALUE;
71 1 mxg->cache_size = 0;
72
73 1 return 0;
74 }
75
76 8365 static uint8_t* mxg_find_startmarker(uint8_t *p, uint8_t *end)
77 {
78
2/2
✓ Branch 0 taken 138625 times.
✓ Branch 1 taken 524 times.
139149 for (; p < end - 3; p += 4) {
79 138625 uint32_t x = AV_RN32(p);
80
81
2/2
✓ Branch 0 taken 7841 times.
✓ Branch 1 taken 130784 times.
138625 if (x & (~(x+0x01010101)) & 0x80808080) {
82
2/2
✓ Branch 0 taken 1627 times.
✓ Branch 1 taken 6214 times.
7841 if (p[0] == 0xff) {
83 1627 return p;
84
2/2
✓ Branch 0 taken 1718 times.
✓ Branch 1 taken 4496 times.
6214 } else if (p[1] == 0xff) {
85 1718 return p+1;
86
2/2
✓ Branch 0 taken 2815 times.
✓ Branch 1 taken 1681 times.
4496 } else if (p[2] == 0xff) {
87 2815 return p+2;
88
1/2
✓ Branch 0 taken 1681 times.
✗ Branch 1 not taken.
1681 } else if (p[3] == 0xff) {
89 1681 return p+3;
90 }
91 }
92 }
93
94
2/2
✓ Branch 0 taken 763 times.
✓ Branch 1 taken 511 times.
1274 for (; p < end; ++p) {
95
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 750 times.
763 if (*p == 0xff) return p;
96 }
97
98 511 return end;
99 }
100
101 590 static int mxg_update_cache(AVFormatContext *s, unsigned int cache_size)
102 {
103 590 MXGContext *mxg = s->priv_data;
104 590 unsigned int current_pos = mxg->buffer_ptr - mxg->buffer;
105 unsigned int soi_pos;
106 uint8_t *buffer;
107 int ret;
108
109 /* reallocate internal buffer */
110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 590 times.
590 if (current_pos > current_pos + cache_size)
111 return AVERROR(ENOMEM);
112 590 soi_pos = mxg->soi_ptr - mxg->buffer;
113 590 buffer = av_fast_realloc(mxg->buffer, &mxg->buffer_size,
114 590 current_pos + cache_size +
115 AV_INPUT_BUFFER_PADDING_SIZE);
116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 590 times.
590 if (!buffer)
117 return AVERROR(ENOMEM);
118 590 mxg->buffer = buffer;
119 590 mxg->buffer_ptr = mxg->buffer + current_pos;
120
2/2
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 3 times.
590 if (mxg->soi_ptr) mxg->soi_ptr = mxg->buffer + soi_pos;
121
122 /* get data */
123 590 ret = avio_read(s->pb, mxg->buffer_ptr + mxg->cache_size,
124 590 cache_size - mxg->cache_size);
125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 590 times.
590 if (ret < 0)
126 return ret;
127
128 590 mxg->cache_size += ret;
129
130 590 memset(mxg->buffer_ptr + mxg->cache_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
131
132 590 return ret;
133 }
134
135 32 static int mxg_read_packet(AVFormatContext *s, AVPacket *pkt)
136 {
137 int ret;
138 unsigned int size;
139 uint8_t *startmarker_ptr, *end, *search_end, marker;
140 32 MXGContext *mxg = s->priv_data;
141
142
3/4
✓ Branch 1 taken 8365 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 8365 times.
✗ Branch 4 not taken.
8366 while (!avio_feof(s->pb) && !s->pb->error){
143
2/2
✓ Branch 0 taken 560 times.
✓ Branch 1 taken 7805 times.
8365 if (mxg->cache_size <= OVERREAD_SIZE) {
144 /* update internal buffer */
145 560 ret = mxg_update_cache(s, DEFAULT_PACKET_SIZE + OVERREAD_SIZE);
146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 560 times.
560 if (ret < 0)
147 return ret;
148 }
149 8365 end = mxg->buffer_ptr + mxg->cache_size;
150
151 /* find start marker - 0xff */
152
1/2
✓ Branch 0 taken 8365 times.
✗ Branch 1 not taken.
8365 if (mxg->cache_size > OVERREAD_SIZE) {
153 8365 search_end = end - OVERREAD_SIZE;
154 8365 startmarker_ptr = mxg_find_startmarker(mxg->buffer_ptr, search_end);
155 } else {
156 search_end = end;
157 startmarker_ptr = mxg_find_startmarker(mxg->buffer_ptr, search_end);
158 if (startmarker_ptr >= search_end - 1 ||
159 *(startmarker_ptr + 1) != EOI) break;
160 }
161
162
2/2
✓ Branch 0 taken 7854 times.
✓ Branch 1 taken 511 times.
8365 if (startmarker_ptr != search_end) { /* start marker found */
163 7854 marker = *(startmarker_ptr + 1);
164 7854 mxg->buffer_ptr = startmarker_ptr + 2;
165 7854 mxg->cache_size = end - mxg->buffer_ptr;
166
167
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 7823 times.
7854 if (marker == SOI) {
168 31 mxg->soi_ptr = startmarker_ptr;
169
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 7793 times.
7823 } else if (marker == EOI) {
170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if (!mxg->soi_ptr) {
171 av_log(s, AV_LOG_WARNING, "Found EOI before SOI, skipping\n");
172 continue;
173 }
174
175 30 size = mxg->buffer_ptr - mxg->soi_ptr;
176 30 ret = av_new_packet(pkt, size);
177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if (ret < 0)
178 return ret;
179 30 memcpy(pkt->data, mxg->soi_ptr, size);
180
181 30 pkt->pts = pkt->dts = mxg->dts;
182 30 pkt->stream_index = 0;
183
184
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 16 times.
30 if (mxg->soi_ptr - mxg->buffer > mxg->cache_size) {
185
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (mxg->cache_size > 0) {
186 14 memmove(mxg->buffer, mxg->buffer_ptr, mxg->cache_size);
187 }
188
189 14 mxg->buffer_ptr = mxg->buffer;
190 }
191 30 mxg->soi_ptr = 0;
192
193 30 return pkt->size;
194
6/6
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 7660 times.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 7660 times.
7793 } else if ( (SOF0 <= marker && marker <= SOF15) ||
195
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 (SOS <= marker && marker <= COM) ) {
196 /* all other markers that start marker segment also contain
197 length value (see specification for JPEG Annex B.1) */
198 133 size = AV_RB16(mxg->buffer_ptr);
199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
133 if (size < 2)
200 return AVERROR(EINVAL);
201
202
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 103 times.
133 if (mxg->cache_size < size) {
203 30 ret = mxg_update_cache(s, size);
204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if (ret < 0)
205 return ret;
206 30 startmarker_ptr = mxg->buffer_ptr - 2;
207 30 mxg->cache_size = 0;
208 } else {
209 103 mxg->cache_size -= size;
210 }
211
212 133 mxg->buffer_ptr += size;
213
214
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 132 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
133 if (marker == APP13 && size >= 16) { /* audio data */
215 1 ret = av_new_packet(pkt, size - 14);
216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (ret < 0)
217 return ret;
218 1 memcpy(pkt->data, startmarker_ptr + 16, size - 14);
219
220 /* time (GMT) of first sample in usec since 1970, little-endian */
221 1 pkt->pts = pkt->dts = AV_RL64(startmarker_ptr + 8);
222 1 pkt->stream_index = 1;
223
224
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (startmarker_ptr - mxg->buffer > mxg->cache_size) {
225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (mxg->cache_size > 0) {
226 memcpy(mxg->buffer, mxg->buffer_ptr, mxg->cache_size);
227 }
228 1 mxg->buffer_ptr = mxg->buffer;
229 }
230
231 1 return pkt->size;
232
3/4
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 69 times.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
132 } else if (marker == COM && size >= 18 &&
233
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 32 times.
63 !strncmp(startmarker_ptr + 4, "MXF", 3)) {
234 /* time (GMT) of video frame in usec since 1970, little-endian */
235 31 mxg->dts = AV_RL64(startmarker_ptr + 12);
236 }
237 }
238 } else {
239 /* start marker not found */
240 511 mxg->buffer_ptr = search_end;
241 511 mxg->cache_size = OVERREAD_SIZE;
242 }
243 }
244
245 1 return AVERROR_EOF;
246 }
247
248 1 static int mxg_close(struct AVFormatContext *s)
249 {
250 1 MXGContext *mxg = s->priv_data;
251 1 av_freep(&mxg->buffer);
252 1 return 0;
253 }
254
255 const FFInputFormat ff_mxg_demuxer = {
256 .p.name = "mxg",
257 .p.long_name = NULL_IF_CONFIG_SMALL("MxPEG clip"),
258 .p.extensions = "mxg",
259 .priv_data_size = sizeof(MXGContext),
260 .read_header = mxg_read_header,
261 .read_packet = mxg_read_packet,
262 .read_close = mxg_close,
263 };
264

小孩子拉肚子吃什么药 为什么突然得了荨麻疹 2型糖尿病吃什么药降糖效果好 龋齿挂什么科 金牛女跟什么星座最配
什么时候吃苹果最好 兄弟是什么生肖 2018属什么生肖 牡丹什么时候开放 手上起小水泡是什么原因
俄狄浦斯情结是什么意思 增生期子宫内膜是什么意思 孩子发烧按摩什么部位退烧 15度穿什么衣服 铁达时手表什么档次
辽国是现在的什么地方 十月初七是什么星座 舌头灼热感是什么原因 04属什么生肖 气质是什么
脾胃虚吃什么好hcv9jop5ns5r.cn 逆流而上是什么意思hcv9jop0ns9r.cn 做b超能查出什么hcv8jop1ns1r.cn 荷花是什么季节mmeoe.com 耳鸣是什么原因造成的baiqunet.com
面诊是什么意思hcv7jop9ns7r.cn 什么叫肠化生hcv9jop6ns1r.cn 单脐动脉对胎儿有什么影响hcv9jop2ns0r.cn 永无止境是什么意思hcv9jop4ns5r.cn 尿常规红细胞高是什么原因ff14chat.com
肝火旺喝什么茶hcv7jop5ns6r.cn 爱出油的人身体缺什么hcv9jop3ns0r.cn romoss是什么牌子zhongyiyatai.com 峦是什么意思hcv9jop3ns7r.cn 猫咪来家里是什么寓意hcv8jop2ns0r.cn
吃什么补脑clwhiglsz.com 4.24是什么星座hcv9jop5ns8r.cn 黄辣丁吃什么hcv8jop9ns9r.cn 三尖瓣反流什么意思hcv8jop1ns0r.cn 老是口腔溃疡是什么原因zhiyanzhang.com
百度