History

libswresample/rematrix: Check for malloc errors

Michael Niedermayer committed 11 years ago

Commit 52acd221 parent e91debf1 file · +8 −0Browse files

Unified · Split

libswresample/rematrix.c+8−0
@@ -364,6 +364,8 @@ av_cold int swri_rematrix_init(SwrContext *s){ · 363 unmodified lines
364 if (s->midbuf.fmt == AV_SAMPLE_FMT_S16P){364 if (s->midbuf.fmt == AV_SAMPLE_FMT_S16P){
365 s->native_matrix = av_calloc(nb_in * nb_out, sizeof(int));365 s->native_matrix = av_calloc(nb_in * nb_out, sizeof(int));
366 s->native_one = av_mallocz(sizeof(int));366 s->native_one = av_mallocz(sizeof(int));
367 if (!s->native_matrix || !s->native_one)
368 return AVERROR(ENOMEM);
367 for (i = 0; i < nb_out; i++)369 for (i = 0; i < nb_out; i++)
368 for (j = 0; j < nb_in; j++)370 for (j = 0; j < nb_in; j++)
369 ((int*)s->native_matrix)[i * nb_in + j] = lrintf(s->matrix[i][j] * 32768);371 ((int*)s->native_matrix)[i * nb_in + j] = lrintf(s->matrix[i][j] * 32768);
@@ -374,6 +376,8 @@ av_cold int swri_rematrix_init(SwrContext *s){ · 4 unmodified lines
374 }else if(s->midbuf.fmt == AV_SAMPLE_FMT_FLTP){376 }else if(s->midbuf.fmt == AV_SAMPLE_FMT_FLTP){
375 s->native_matrix = av_calloc(nb_in * nb_out, sizeof(float));377 s->native_matrix = av_calloc(nb_in * nb_out, sizeof(float));
376 s->native_one = av_mallocz(sizeof(float));378 s->native_one = av_mallocz(sizeof(float));
379 if (!s->native_matrix || !s->native_one)
380 return AVERROR(ENOMEM);
377 for (i = 0; i < nb_out; i++)381 for (i = 0; i < nb_out; i++)
378 for (j = 0; j < nb_in; j++)382 for (j = 0; j < nb_in; j++)
379 ((float*)s->native_matrix)[i * nb_in + j] = s->matrix[i][j];383 ((float*)s->native_matrix)[i * nb_in + j] = s->matrix[i][j];
@@ -384,6 +388,8 @@ av_cold int swri_rematrix_init(SwrContext *s){ · 4 unmodified lines
384 }else if(s->midbuf.fmt == AV_SAMPLE_FMT_DBLP){388 }else if(s->midbuf.fmt == AV_SAMPLE_FMT_DBLP){
385 s->native_matrix = av_calloc(nb_in * nb_out, sizeof(double));389 s->native_matrix = av_calloc(nb_in * nb_out, sizeof(double));
386 s->native_one = av_mallocz(sizeof(double));390 s->native_one = av_mallocz(sizeof(double));
391 if (!s->native_matrix || !s->native_one)
392 return AVERROR(ENOMEM);
387 for (i = 0; i < nb_out; i++)393 for (i = 0; i < nb_out; i++)
388 for (j = 0; j < nb_in; j++)394 for (j = 0; j < nb_in; j++)
389 ((double*)s->native_matrix)[i * nb_in + j] = s->matrix[i][j];395 ((double*)s->native_matrix)[i * nb_in + j] = s->matrix[i][j];
@@ -395,6 +401,8 @@ av_cold int swri_rematrix_init(SwrContext *s){ · 5 unmodified lines
395 // Only for dithering currently401 // Only for dithering currently
396// s->native_matrix = av_calloc(nb_in * nb_out, sizeof(double));402// s->native_matrix = av_calloc(nb_in * nb_out, sizeof(double));
397 s->native_one = av_mallocz(sizeof(int));403 s->native_one = av_mallocz(sizeof(int));
404 if (!s->native_one)
405 return AVERROR(ENOMEM);
398// for (i = 0; i < nb_out; i++)406// for (i = 0; i < nb_out; i++)
399// for (j = 0; j < nb_in; j++)407// for (j = 0; j < nb_in; j++)
400// ((double*)s->native_matrix)[i * nb_in + j] = s->matrix[i][j];408// ((double*)s->native_matrix)[i * nb_in + j] = s->matrix[i][j];

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