You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
tests/utils: don't ignore the return value of fwrite()
Signed-off-by: Diego Biurrun <diego@biurrun.de>
This commit is contained in:
committed by
Diego Biurrun
parent
d4ac703c7f
commit
be6009d32c
@@ -16,13 +16,22 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#define SCALEBITS 8
|
#define SCALEBITS 8
|
||||||
#define ONE_HALF (1 << (SCALEBITS - 1))
|
#define ONE_HALF (1 << (SCALEBITS - 1))
|
||||||
#define FIX(x) ((int) ((x) * (1L << SCALEBITS) + 0.5))
|
#define FIX(x) ((int) ((x) * (1L << SCALEBITS) + 0.5))
|
||||||
|
|
||||||
|
#define err_if(expr) do { \
|
||||||
|
if (expr) { \
|
||||||
|
fprintf(stderr, "%s\n", strerror(errno)); \
|
||||||
|
exit(1); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
static void rgb24_to_yuv420p(unsigned char *lum, unsigned char *cb,
|
static void rgb24_to_yuv420p(unsigned char *lum, unsigned char *cb,
|
||||||
unsigned char *cr, unsigned char *src,
|
unsigned char *cr, unsigned char *src,
|
||||||
int width, int height)
|
int width, int height)
|
||||||
@@ -108,14 +117,14 @@ static void pgmyuv_save(const char *filename, int w, int h,
|
|||||||
|
|
||||||
f = fopen(filename, "wb");
|
f = fopen(filename, "wb");
|
||||||
fprintf(f, "P5\n%d %d\n%d\n", w, h * 3 / 2, 255);
|
fprintf(f, "P5\n%d %d\n%d\n", w, h * 3 / 2, 255);
|
||||||
fwrite(lum_tab, 1, w * h, f);
|
err_if(fwrite(lum_tab, 1, w * h, f) != w * h);
|
||||||
h2 = h / 2;
|
h2 = h / 2;
|
||||||
w2 = w / 2;
|
w2 = w / 2;
|
||||||
cb = cb_tab;
|
cb = cb_tab;
|
||||||
cr = cr_tab;
|
cr = cr_tab;
|
||||||
for (i = 0; i < h2; i++) {
|
for (i = 0; i < h2; i++) {
|
||||||
fwrite(cb, 1, w2, f);
|
err_if(fwrite(cb, 1, w2, f) != w2);
|
||||||
fwrite(cr, 1, w2, f);
|
err_if(fwrite(cr, 1, w2, f) != w2);
|
||||||
cb += w2;
|
cb += w2;
|
||||||
cr += w2;
|
cr += w2;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user