MCPcopy Create free account
hub / github.com/TypesettingTools/Aegisub / cs_Create

Function cs_Create

src/MatroskaParser.c:3195–3239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3193};
3194
3195CompressedStream *cs_Create(/* in */ MatroskaFile *mf,
3196 /* in */ unsigned tracknum,
3197 /* out */ char *errormsg,
3198 /* in */ unsigned msgsize)
3199{
3200 CompressedStream *cs;
3201 TrackInfo *ti;
3202 int code;
3203
3204 ti = mkv_GetTrackInfo(mf, tracknum);
3205 if (ti == NULL) {
3206 mystrlcpy(errormsg, "No such track.", msgsize);
3207 return NULL;
3208 }
3209
3210 if (!ti->CompEnabled) {
3211 mystrlcpy(errormsg, "Track is not compressed.", msgsize);
3212 return NULL;
3213 }
3214
3215 if (ti->CompMethod != COMP_ZLIB) {
3216 mystrlcpy(errormsg, "Unsupported compression method.", msgsize);
3217 return NULL;
3218 }
3219
3220 cs = mf->cache->memalloc(mf->cache,sizeof(*cs));
3221 if (cs == NULL) {
3222 mystrlcpy(errormsg, "Ouf of memory.", msgsize);
3223 return NULL;
3224 }
3225
3226 memset(&cs->zs,0,sizeof(cs->zs));
3227 code = inflateInit(&cs->zs);
3228 if (code != Z_OK) {
3229 mystrlcpy(errormsg, "ZLib error.", msgsize);
3230 mf->cache->memfree(mf->cache,cs);
3231 return NULL;
3232 }
3233
3234 cs->frame_size = 0;
3235 cs->decoded_ptr = cs->decoded_size = 0;
3236 cs->mf = mf;
3237
3238 return cs;
3239}
3240
3241void cs_Destroy(/* in */ CompressedStream *cs) {
3242 if (cs == NULL)

Callers 1

GetSubtitlesMethod · 0.85

Calls 2

mkv_GetTrackInfoFunction · 0.85
mystrlcpyFunction · 0.85

Tested by

no test coverage detected