History

avformat/matroskadec: Beautify matroska_parse_laces()

Andreas Rheinhardt committed 6 years ago

Commit 1fd85281 parent 2a3bbc01 file · +11 −16Browse files

Unified · Split

libavformat/matroskadec.c+11−16
@@ -3037,9 +3037,9 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, · 3036 unmodified lines
30373037 if (size <= 0)
30383038 return AVERROR_INVALIDDATA;
30393039
3040− *laces = *data + 1;
3041− data += 1;
3042− size -= 1;
3040+ *laces = *data + 1;
3041+ data += 1;
3042+ size -= 1;
30433043
30443044 switch (type) {
30453045 case 0x1: /* Xiph lacing */
@@ -3049,31 +3049,26 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, · 3 unmodified lines
30493049 for (n = 0; n < *laces - 1; n++) {
30503050 lace_size[n] = 0;
30513051
3052− while (1) {
3053− if (size <= total) {
3052+ do {
3053+ if (size <= total)
30543054 return AVERROR_INVALIDDATA;
3055− }
30563055 temp = *data;
30573056 total += temp;
30583057 lace_size[n] += temp;
30593058 data += 1;
30603059 size -= 1;
3061− if (temp != 0xff)
3062− break;
3063− }
3060+ } while (temp == 0xff);
30643061 }
3065− if (size < total) {
3062+ if (size < total)
30663063 return AVERROR_INVALIDDATA;
3067− }
30683064
30693065 lace_size[n] = size - total;
30703066 break;
30713067 }
30723068
30733069 case 0x2: /* fixed-size lacing */
3074− if (size % (*laces)) {
3070+ if (size % (*laces))
30753071 return AVERROR_INVALIDDATA;
3076− }
30773072 for (n = 0; n < *laces; n++)
30783073 lace_size[n] = size / *laces;
30793074 break;
@@ -3109,15 +3104,15 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, · 29 unmodified lines
31093104 }
31103105 data += offset;
31113106 size -= offset;
3112− if (size < total) {
3107+ if (size < total)
31133108 return AVERROR_INVALIDDATA;
3114− }
3109+
31153110 lace_size[*laces - 1] = size - total;
31163111 break;
31173112 }
31183113 }
31193114
3120− *buf = data;
3115+ *buf = data;
31213116
31223117 return 0;
31233118 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t