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
3037 if (size <= 0)3037 if (size <= 0)
3038 return AVERROR_INVALIDDATA;3038 return AVERROR_INVALIDDATA;
3039 3039
3040 *laces = *data + 1;3040 *laces = *data + 1;
3041 data += 1;3041 data += 1;
3042 size -= 1;3042 size -= 1;
3043 3043
3044 switch (type) {3044 switch (type) {
3045 case 0x1: /* Xiph lacing */3045 case 0x1: /* Xiph lacing */
@@ -3049,31 +3049,26 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, · 3 unmodified lines
3049 for (n = 0; n < *laces - 1; n++) {3049 for (n = 0; n < *laces - 1; n++) {
3050 lace_size[n] = 0;3050 lace_size[n] = 0;
3051 3051
3052 while (1) {3052 do {
3053 if (size <= total) {3053 if (size <= total)
3054 return AVERROR_INVALIDDATA;3054 return AVERROR_INVALIDDATA;
3055 }
3056 temp = *data;3055 temp = *data;
3057 total += temp;3056 total += temp;
3058 lace_size[n] += temp;3057 lace_size[n] += temp;
3059 data += 1;3058 data += 1;
3060 size -= 1;3059 size -= 1;
3061 if (temp != 0xff)3060 } while (temp == 0xff);
3062 break;
3063 }
3064 }3061 }
3065 if (size < total) {3062 if (size < total)
3066 return AVERROR_INVALIDDATA;3063 return AVERROR_INVALIDDATA;
3067 }
3068 3064
3069 lace_size[n] = size - total;3065 lace_size[n] = size - total;
3070 break;3066 break;
3071 }3067 }
3072 3068
3073 case 0x2: /* fixed-size lacing */3069 case 0x2: /* fixed-size lacing */
3074 if (size % (*laces)) {3070 if (size % (*laces))
3075 return AVERROR_INVALIDDATA;3071 return AVERROR_INVALIDDATA;
3076 }
3077 for (n = 0; n < *laces; n++)3072 for (n = 0; n < *laces; n++)
3078 lace_size[n] = size / *laces;3073 lace_size[n] = size / *laces;
3079 break;3074 break;
@@ -3109,15 +3104,15 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, · 29 unmodified lines
3109 }3104 }
3110 data += offset;3105 data += offset;
3111 size -= offset;3106 size -= offset;
3112 if (size < total) {3107 if (size < total)
3113 return AVERROR_INVALIDDATA;3108 return AVERROR_INVALIDDATA;
3114 }3109
3115 lace_size[*laces - 1] = size - total;3110 lace_size[*laces - 1] = size - total;
3116 break;3111 break;
3117 }3112 }
3118 }3113 }
3119 3114
3120 *buf = data;3115 *buf = data;
3121 3116
3122 return 0;3117 return 0;
3123}3118}

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